wordinweb 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/index.d.ts +26 -3
- package/dist/index.js +1766 -739
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# WordInWeb
|
|
2
2
|
|
|
3
|
-
[**Live demo →**](https://
|
|
3
|
+
[**Live demo →**](https://word-in-web.com/)
|
|
4
4
|
|
|
5
5
|
A Word/.docx viewer and editor for the web, embeddable as a single React component.
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ import { DocxView } from "wordinweb";
|
|
|
10
10
|
<DocxView source="/report.docx" />; // render-only viewer
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Set the `editable` flag to enable editing; the default configuration is a pure viewer.
|
|
14
14
|
|
|
15
15
|
If you discover an edge case or perf issue create an issue and include the offending Word file.
|
|
16
16
|
|
|
@@ -93,6 +93,7 @@ export function Editor() {
|
|
|
93
93
|
| `revisions` | `"final" \| "markup"` | `"final"` | Tracked-changes display: clean final text, or insertions underlined / deletions struck. |
|
|
94
94
|
| `commentAuthor` | `string` | `"You"` | Name stamped on comments, replies, and suggestions. |
|
|
95
95
|
| `onLoad` | `(info: { pageCount; document }) => void` | — | Fires once the document is parsed and laid out. |
|
|
96
|
+
| `onPageCountChange` | `(pageCount: number) => void` | — | Fires when editing changes the rendered page count. |
|
|
96
97
|
| `onReady` | `(api: DocxViewApi) => void` | — | Fires when editing is wired up; the `api` is valid only while mounted. Only called when `editable`. |
|
|
97
98
|
| `onMissingFonts` | `(missing: MissingFont[]) => void` | — | Fires after render with any requested faces the browser can't render (silently substituted; layout may differ from Word). Empty array = all good. |
|
|
98
99
|
| `onError` | `(error: Error) => void` | — | Fires if parsing or rendering throws. |
|
|
@@ -110,7 +111,7 @@ The object passed to `onReady`. Every command operates on the current selection
|
|
|
110
111
|
- `setAlignment("left" | "center" | "right" | "justify")`.
|
|
111
112
|
- `setParagraphStyle(styleId | null)`, `listParagraphStyles()`, `getParagraphStyleId()`.
|
|
112
113
|
- `toggleList("bullet" | "number")`, `getListType()`.
|
|
113
|
-
- `adjustIndent(1 | -1)`, `setParagraphSpacing({ lineMultiple?, beforePt?, afterPt? })`.
|
|
114
|
+
- `adjustIndent(1 | -1)`, `setParagraphSpacing({ lineMultiple?, exactLinePt?, beforePt?, afterPt? })`.
|
|
114
115
|
- `setLink(url | null)`, `getLinkAt()`.
|
|
115
116
|
|
|
116
117
|
**Page layout**
|
|
@@ -166,10 +167,11 @@ The object passed to `onReady`. Every command operates on the current selection
|
|
|
166
167
|
### `DocxToolbar`
|
|
167
168
|
|
|
168
169
|
A ready-made formatting toolbar for an editable `DocxView`. Use `mode="simple"` for the basic Home editing strip or `mode="advanced"` for the full Home / Insert / Draw / Layout ribbon supported by the installed version.
|
|
170
|
+
The searchable Help guide opens from the toolbar, `F1`, or `Cmd/Ctrl+/`. It documents the current tools, platform-specific shortcuts, object controls, and recipes for pleading-paper rules, column dividers, resume lines, and repeating page art; set `features={{ help: false }}` to hide it.
|
|
169
171
|
Layout includes Word-style paper presets plus a custom width/height dialog; both document and current-section scope emit native page-size properties.
|
|
170
172
|
Editable text also has a right-click menu for clipboard, formatting, links,
|
|
171
173
|
comments, lists, and alignment. Word-style shortcuts include heading levels,
|
|
172
|
-
page breaks, links, comments, lists, and paragraph alignment in addition to the
|
|
174
|
+
page and column breaks, links, comments, lists, and paragraph alignment in addition to the
|
|
173
175
|
standard formatting and history commands.
|
|
174
176
|
|
|
175
177
|
| Prop | Type | What it does |
|
package/dist/index.d.ts
CHANGED
|
@@ -1588,6 +1588,8 @@ interface LineEdgeItem {
|
|
|
1588
1588
|
};
|
|
1589
1589
|
/** Paint over the body text (non-behindDoc anchored shape border). */
|
|
1590
1590
|
front?: boolean;
|
|
1591
|
+
/** Paint below the body text (behindDoc anchored shape border). */
|
|
1592
|
+
behind?: boolean;
|
|
1591
1593
|
z?: number;
|
|
1592
1594
|
}
|
|
1593
1595
|
interface ImageItem {
|
|
@@ -1666,6 +1668,8 @@ interface DrawingHitItem {
|
|
|
1666
1668
|
* click on bare fill selects or drags the shape, while clicks on its text
|
|
1667
1669
|
* glyphs still reach the text editor. */
|
|
1668
1670
|
belowText?: boolean;
|
|
1671
|
+
/** Keep a behindDoc drawing target under the body text. */
|
|
1672
|
+
behind?: boolean;
|
|
1669
1673
|
/** The drawing owns an independently editable text-box story. */
|
|
1670
1674
|
textboxStory?: boolean;
|
|
1671
1675
|
rotate?: {
|
|
@@ -1762,6 +1766,13 @@ interface LaidOutPage {
|
|
|
1762
1766
|
bodyBottom: number;
|
|
1763
1767
|
/** Items from this index on belong to the header/footer parts. */
|
|
1764
1768
|
hfStart: number;
|
|
1769
|
+
/** Column geometry for editor hit-testing. A page can contain more than one
|
|
1770
|
+
* band when a continuous section changes the column layout mid-page. */
|
|
1771
|
+
columnBands: Array<{
|
|
1772
|
+
top: number;
|
|
1773
|
+
colXs: number[];
|
|
1774
|
+
colWidths: number[];
|
|
1775
|
+
}>;
|
|
1765
1776
|
}
|
|
1766
1777
|
interface LayoutResult {
|
|
1767
1778
|
pages: LaidOutPage[];
|
|
@@ -2008,6 +2019,8 @@ interface PageLayoutPatch {
|
|
|
2008
2019
|
orientation?: "portrait" | "landscape";
|
|
2009
2020
|
/** Equal-width text columns (1 removes w:cols). */
|
|
2010
2021
|
columns?: number;
|
|
2022
|
+
/** Draw a vertical rule between text columns. Used with columns > 1. */
|
|
2023
|
+
columnSeparator?: boolean;
|
|
2011
2024
|
/** Box page border (null removes). sz in eighth-points, color hex. */
|
|
2012
2025
|
pageBorders?: {
|
|
2013
2026
|
sz?: number;
|
|
@@ -2079,7 +2092,7 @@ interface ToolbarMenuSelectProps {
|
|
|
2079
2092
|
* every user-facing part is a button/listbox rendered by us. */
|
|
2080
2093
|
declare function ToolbarMenuSelect({ value, options, onChange, placeholder, title, ariaLabel, triggerAriaLabel, width, menuWidth, className, style, }: ToolbarMenuSelectProps): react.JSX.Element;
|
|
2081
2094
|
/** Toolbar control groups a host can disable via the `features` prop. */
|
|
2082
|
-
type ToolbarFeature = "history" | "styles" | "font" | "size" | "format" | "color" | "highlight" | "alignment" | "indent" | "spacing" | "link" | "lists" | "table" | "image" | "icon" | "screenshot" | "model3D" | "media" | "object" | "chart" | "smartArt" | "comment" | "footnote" | "bookmark" | "crossReference" | "dateTime" | "field" | "equation" | "symbol" | "shape" | "textBox" | "wordArt" | "drawing" | "arrange" | "dropCap" | "headerFooter" | "coverPage" | "pageNumber" | "break" | "layout" | "download";
|
|
2095
|
+
type ToolbarFeature = "history" | "styles" | "font" | "size" | "format" | "color" | "highlight" | "alignment" | "indent" | "spacing" | "link" | "lists" | "table" | "image" | "icon" | "screenshot" | "model3D" | "media" | "object" | "chart" | "smartArt" | "comment" | "footnote" | "bookmark" | "crossReference" | "dateTime" | "field" | "equation" | "symbol" | "shape" | "textBox" | "wordArt" | "drawing" | "arrange" | "dropCap" | "headerFooter" | "coverPage" | "pageNumber" | "break" | "layout" | "help" | "download";
|
|
2083
2096
|
type ToolbarMode = "simple" | "advanced";
|
|
2084
2097
|
interface DocxToolbarProps {
|
|
2085
2098
|
api: DocxViewApi | null;
|
|
@@ -2142,6 +2155,8 @@ interface DocxViewApi {
|
|
|
2142
2155
|
getDrawingTool(): DrawingTool | null;
|
|
2143
2156
|
/** Align, rotate, or reorder the selected image, shape, or ink group. */
|
|
2144
2157
|
arrangeObject(action: ObjectArrangeAction): boolean;
|
|
2158
|
+
/** True while an image, shape, or ink group is selected. */
|
|
2159
|
+
hasSelectedObject(): boolean;
|
|
2145
2160
|
undo(): void;
|
|
2146
2161
|
redo(): void;
|
|
2147
2162
|
canUndo(): boolean;
|
|
@@ -2168,9 +2183,10 @@ interface DocxViewApi {
|
|
|
2168
2183
|
getLinkAt(): string | null;
|
|
2169
2184
|
/** Step paragraph indent by half an inch (Word's indent buttons). */
|
|
2170
2185
|
adjustIndent(direction: 1 | -1): void;
|
|
2171
|
-
/** Line spacing multiple and/or space before/after (points). */
|
|
2186
|
+
/** Line spacing multiple or exact point height, and/or space before/after (points). */
|
|
2172
2187
|
setParagraphSpacing(patch: {
|
|
2173
2188
|
lineMultiple?: number;
|
|
2189
|
+
exactLinePt?: number;
|
|
2174
2190
|
beforePt?: number | null;
|
|
2175
2191
|
afterPt?: number | null;
|
|
2176
2192
|
}): void;
|
|
@@ -2199,6 +2215,11 @@ interface DocxViewApi {
|
|
|
2199
2215
|
getParagraphStyleId(): string | null;
|
|
2200
2216
|
/** Change margins / page size / orientation (inches). */
|
|
2201
2217
|
setPageLayout(patch: PageLayoutPatch, scope?: "document" | "section"): void;
|
|
2218
|
+
/** One-based logical section containing the caret or selection. */
|
|
2219
|
+
getSectionContext(): {
|
|
2220
|
+
index: number;
|
|
2221
|
+
count: number;
|
|
2222
|
+
} | null;
|
|
2202
2223
|
/** Insert a page/column break or a section break at the caret. */
|
|
2203
2224
|
insertBreak(kind: "page" | "column" | "sectionNextPage" | "sectionContinuous"): boolean;
|
|
2204
2225
|
/** Insert a full blank page at the caret (two consecutive page breaks). */
|
|
@@ -2277,6 +2298,8 @@ interface DocxViewProps {
|
|
|
2277
2298
|
pageCount: number;
|
|
2278
2299
|
document: DocxDocument;
|
|
2279
2300
|
}) => void;
|
|
2301
|
+
/** Fires whenever editing changes the rendered page count. */
|
|
2302
|
+
onPageCountChange?: (pageCount: number) => void;
|
|
2280
2303
|
/** Fires when the document is ready; the api is only usable while mounted. */
|
|
2281
2304
|
onReady?: (api: DocxViewApi) => void;
|
|
2282
2305
|
onError?: (error: Error) => void;
|
|
@@ -2299,6 +2322,6 @@ interface DocxViewProps {
|
|
|
2299
2322
|
* <DocxView source="/report.docx" editable onReady={setApi} /> // editing
|
|
2300
2323
|
* ```
|
|
2301
2324
|
*/
|
|
2302
|
-
declare function DocxView({ source, zoom, fitWidth, narrowWidth, editable, className, style, onLoad, onReady, onError, commentAuthor, showComments, revisions, onMissingFonts, }: DocxViewProps): react.JSX.Element;
|
|
2325
|
+
declare function DocxView({ source, zoom, fitWidth, narrowWidth, editable, className, style, onLoad, onPageCountChange, onReady, onError, commentAuthor, showComments, revisions, onMissingFonts, }: DocxViewProps): react.JSX.Element;
|
|
2303
2326
|
|
|
2304
2327
|
export { type CoverPageContent, DocxDocument, DocxToolbar, type DocxToolbarProps, DocxView, type DocxViewApi, type DocxViewProps, type DrawingTool, type LineNumberingPatch, type PageLayoutPatch, type ParagraphAlignment, type RunFormatPatch, type ScreenshotInsertResult, type SelectionFormat, type ShapePreset, type ToolbarFeature, ToolbarMenuSelect, type ToolbarMenuSelectOption, type ToolbarMenuSelectProps, type ToolbarMode, layoutDocument, printPages, renderToDom };
|