wordinweb 0.1.13 → 0.1.15

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 CHANGED
@@ -10,7 +10,7 @@ import { DocxView } from "wordinweb";
10
10
  <DocxView source="/report.docx" />; // render-only viewer
11
11
  ```
12
12
 
13
- Editing is in an Alpha state and is strictly opt-in via the `editable` flag; the default is a pure viewer.
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
@@ -1363,6 +1363,14 @@ declare class DocxDocument {
1363
1363
  */
1364
1364
  private rememberOriginalXml;
1365
1365
  private writeModeledXml;
1366
+ /**
1367
+ * Canonicalize producer shorthand that Google Docs otherwise interprets as
1368
+ * a fixed, few-twip table. Word treats `tblW="100%"` plus a placeholder
1369
+ * grid as autofit; Google needs the standard pct value and a usable cached
1370
+ * grid. The cached widths follow the same content-dominant shape and do not
1371
+ * change Word's autofit result.
1372
+ */
1373
+ private normalizePercentageTableGrids;
1366
1374
  save(): Uint8Array;
1367
1375
  /** Fresh unique docPr id for inserted drawings. */
1368
1376
  nextDrawingId(): number;
@@ -1588,6 +1596,8 @@ interface LineEdgeItem {
1588
1596
  };
1589
1597
  /** Paint over the body text (non-behindDoc anchored shape border). */
1590
1598
  front?: boolean;
1599
+ /** Paint below the body text (behindDoc anchored shape border). */
1600
+ behind?: boolean;
1591
1601
  z?: number;
1592
1602
  }
1593
1603
  interface ImageItem {
@@ -1666,6 +1676,8 @@ interface DrawingHitItem {
1666
1676
  * click on bare fill selects or drags the shape, while clicks on its text
1667
1677
  * glyphs still reach the text editor. */
1668
1678
  belowText?: boolean;
1679
+ /** Keep a behindDoc drawing target under the body text. */
1680
+ behind?: boolean;
1669
1681
  /** The drawing owns an independently editable text-box story. */
1670
1682
  textboxStory?: boolean;
1671
1683
  rotate?: {
@@ -1762,6 +1774,13 @@ interface LaidOutPage {
1762
1774
  bodyBottom: number;
1763
1775
  /** Items from this index on belong to the header/footer parts. */
1764
1776
  hfStart: number;
1777
+ /** Column geometry for editor hit-testing. A page can contain more than one
1778
+ * band when a continuous section changes the column layout mid-page. */
1779
+ columnBands: Array<{
1780
+ top: number;
1781
+ colXs: number[];
1782
+ colWidths: number[];
1783
+ }>;
1765
1784
  }
1766
1785
  interface LayoutResult {
1767
1786
  pages: LaidOutPage[];
@@ -2008,6 +2027,8 @@ interface PageLayoutPatch {
2008
2027
  orientation?: "portrait" | "landscape";
2009
2028
  /** Equal-width text columns (1 removes w:cols). */
2010
2029
  columns?: number;
2030
+ /** Draw a vertical rule between text columns. Used with columns > 1. */
2031
+ columnSeparator?: boolean;
2011
2032
  /** Box page border (null removes). sz in eighth-points, color hex. */
2012
2033
  pageBorders?: {
2013
2034
  sz?: number;
@@ -2079,7 +2100,7 @@ interface ToolbarMenuSelectProps {
2079
2100
  * every user-facing part is a button/listbox rendered by us. */
2080
2101
  declare function ToolbarMenuSelect({ value, options, onChange, placeholder, title, ariaLabel, triggerAriaLabel, width, menuWidth, className, style, }: ToolbarMenuSelectProps): react.JSX.Element;
2081
2102
  /** 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";
2103
+ 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
2104
  type ToolbarMode = "simple" | "advanced";
2084
2105
  interface DocxToolbarProps {
2085
2106
  api: DocxViewApi | null;
@@ -2142,6 +2163,8 @@ interface DocxViewApi {
2142
2163
  getDrawingTool(): DrawingTool | null;
2143
2164
  /** Align, rotate, or reorder the selected image, shape, or ink group. */
2144
2165
  arrangeObject(action: ObjectArrangeAction): boolean;
2166
+ /** True while an image, shape, or ink group is selected. */
2167
+ hasSelectedObject(): boolean;
2145
2168
  undo(): void;
2146
2169
  redo(): void;
2147
2170
  canUndo(): boolean;
@@ -2168,9 +2191,10 @@ interface DocxViewApi {
2168
2191
  getLinkAt(): string | null;
2169
2192
  /** Step paragraph indent by half an inch (Word's indent buttons). */
2170
2193
  adjustIndent(direction: 1 | -1): void;
2171
- /** Line spacing multiple and/or space before/after (points). */
2194
+ /** Line spacing multiple or exact point height, and/or space before/after (points). */
2172
2195
  setParagraphSpacing(patch: {
2173
2196
  lineMultiple?: number;
2197
+ exactLinePt?: number;
2174
2198
  beforePt?: number | null;
2175
2199
  afterPt?: number | null;
2176
2200
  }): void;
@@ -2199,6 +2223,11 @@ interface DocxViewApi {
2199
2223
  getParagraphStyleId(): string | null;
2200
2224
  /** Change margins / page size / orientation (inches). */
2201
2225
  setPageLayout(patch: PageLayoutPatch, scope?: "document" | "section"): void;
2226
+ /** One-based logical section containing the caret or selection. */
2227
+ getSectionContext(): {
2228
+ index: number;
2229
+ count: number;
2230
+ } | null;
2202
2231
  /** Insert a page/column break or a section break at the caret. */
2203
2232
  insertBreak(kind: "page" | "column" | "sectionNextPage" | "sectionContinuous"): boolean;
2204
2233
  /** Insert a full blank page at the caret (two consecutive page breaks). */
@@ -2277,6 +2306,8 @@ interface DocxViewProps {
2277
2306
  pageCount: number;
2278
2307
  document: DocxDocument;
2279
2308
  }) => void;
2309
+ /** Fires whenever editing changes the rendered page count. */
2310
+ onPageCountChange?: (pageCount: number) => void;
2280
2311
  /** Fires when the document is ready; the api is only usable while mounted. */
2281
2312
  onReady?: (api: DocxViewApi) => void;
2282
2313
  onError?: (error: Error) => void;
@@ -2299,6 +2330,6 @@ interface DocxViewProps {
2299
2330
  * <DocxView source="/report.docx" editable onReady={setApi} /> // editing
2300
2331
  * ```
2301
2332
  */
2302
- declare function DocxView({ source, zoom, fitWidth, narrowWidth, editable, className, style, onLoad, onReady, onError, commentAuthor, showComments, revisions, onMissingFonts, }: DocxViewProps): react.JSX.Element;
2333
+ declare function DocxView({ source, zoom, fitWidth, narrowWidth, editable, className, style, onLoad, onPageCountChange, onReady, onError, commentAuthor, showComments, revisions, onMissingFonts, }: DocxViewProps): react.JSX.Element;
2303
2334
 
2304
2335
  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 };