wordinweb 0.1.9 → 0.1.11

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
@@ -119,7 +119,7 @@ The object passed to `onReady`. Every command operates on the current selection
119
119
  - `insertBlankPage()` — inserts a complete blank page at the caret.
120
120
  - `insertCoverPage({ title, subtitle?, author? })` — prepends an editable, styled cover page.
121
121
  - `setLineNumbering(patch, scope?)`, `getLineNumbering()`.
122
- - `openHeaderFooter("header" | "footer")`, `closeHeaderFooter()` — create or directly enter page header/footer editing; Escape closes it.
122
+ - `openHeaderFooter("header" | "footer")`, `closeHeaderFooter()` — create or directly enter the repeating page layer; shapes and lines inserted there repeat on the pages using that header/footer. Escape closes it.
123
123
 
124
124
  **Tables**
125
125
  - `insertTable(rows, cols)`.
@@ -139,7 +139,7 @@ The object passed to `onReady`. Every command operates on the current selection
139
139
  - `insertField(instruction, cachedResult?)`, `insertDateTime("date" | "time", picture?)` — live Word fields.
140
140
  - `addBookmark(name)`, `listBookmarks()`, `insertCrossReference(name, "text" | "page")` — named bookmark targets and live `REF` / `PAGEREF` fields.
141
141
  - `insertEquation(linear)`, `insertSymbol(symbol)` — native editable OMML equations and arbitrary Unicode symbols.
142
- - `insertShape(preset, text?)` — floating editable DrawingML rectangles, rounded rectangles, ellipses, diamonds, and text boxes. Advanced mode also exposes Text Box as its own Insert control.
142
+ - `insertShape(preset, text?)` — floating editable DrawingML lines, rectangles, rounded rectangles, ellipses, diamonds, and text boxes. Selected objects expose exact page position, size, outline, wrapping, and layer controls.
143
143
  - `insertWordArt(text, preset?)` — editable DrawingML WordArt with plain, arch, wave, and chevron presets.
144
144
  - `insertChart(data)`, `updateSelectedChart(data)` — native editable ChartML with its embedded workbook.
145
145
  - `insertSmartArt(data)`, `updateSelectedSmartArt(data)` — native editable SmartArt data, layout, style, colors, and cached drawing parts.
@@ -167,6 +167,10 @@ The object passed to `onReady`. Every command operates on the current selection
167
167
 
168
168
  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.
169
169
  Layout includes Word-style paper presets plus a custom width/height dialog; both document and current-section scope emit native page-size properties.
170
+ Editable text also has a right-click menu for clipboard, formatting, links,
171
+ comments, lists, and alignment. Word-style shortcuts include heading levels,
172
+ page breaks, links, comments, lists, and paragraph alignment in addition to the
173
+ standard formatting and history commands.
170
174
 
171
175
  | Prop | Type | What it does |
172
176
  | --- | --- | --- |
@@ -198,6 +202,24 @@ Every color the chrome paints — the toolbar, comment cards, selection, caret,
198
202
  | `--dxw-layout-menu-width` | `304px` | Layout option-menu width |
199
203
  | `--dxw-layout-menu-max-height` | `480px` | Layout option-menu scroll limit |
200
204
  | `--dxw-layout-preview-bg` | `#fff` | Paper fill in Layout option previews |
205
+ | `--dxw-select-height` | `26px` | Custom select trigger height |
206
+ | `--dxw-select-border` | `transparent` | Custom select trigger border color |
207
+ | `--dxw-select-radius` | `4px` | Custom select trigger corner radius |
208
+ | `--dxw-select-bg` | `transparent` | Custom select trigger fill |
209
+ | `--dxw-select-fg` | toolbar foreground | Custom select trigger text |
210
+ | `--dxw-select-font` | `13px system-ui` | Custom select trigger font |
211
+ | `--dxw-select-padding` | `0 6px` | Custom select trigger padding |
212
+ | `--dxw-select-menu-bg` | popover background | Custom select menu fill |
213
+ | `--dxw-select-menu-border` | toolbar border | Custom select menu border color |
214
+ | `--dxw-select-menu-radius` | `8px` | Custom select menu corner radius |
215
+ | `--dxw-select-menu-shadow` | popover shadow | Custom select menu shadow |
216
+ | `--dxw-select-menu-max-height` | `320px` | Custom select menu scroll limit |
217
+ | `--dxw-color-menu-width` | `236px` | Text and drawing color palette width |
218
+ | `--dxw-dialog-backdrop` | `rgba(32,33,36,.38)` | Editor dialog scrim |
219
+ | `--dxw-dialog-z-index` | `1000` | Editor dialog stacking level |
220
+ | `--dxw-dialog-width` | `420px` | Editor dialog width |
221
+ | `--dxw-dialog-radius` | `10px` | Editor dialog corner radius |
222
+ | `--dxw-dialog-field-bg` | popover background | Editor dialog field fill |
201
223
  | `--dxw-canvas-bg` | `#e8eaed` | Scroll area behind the pages |
202
224
  | `--dxw-page-bg` | `#ffffff` | Page paper |
203
225
  | `--dxw-page-shadow` | `0 1px 3px …, 0 4px 14px …` | Page drop shadow |
@@ -238,6 +260,31 @@ Or in a stylesheet:
238
260
  .dxw-dark { --dxw-toolbar-bg: #1f2937; --dxw-toolbar-fg: #e5e7eb; /* … */ }
239
261
  ```
240
262
 
263
+ ### Custom menus and dialogs
264
+
265
+ All visible toolbar choices use WordInWeb-rendered controls rather than the
266
+ browser's native select, prompt, or color-picker UI. `ToolbarMenuSelect` is
267
+ exported for host-app controls that should match the toolbar:
268
+
269
+ ```tsx
270
+ <ToolbarMenuSelect
271
+ value={zoom}
272
+ ariaLabel="Document zoom"
273
+ options={[
274
+ { value: "0.75", label: "75%" },
275
+ { value: "1", label: "100%" },
276
+ { value: "1.25", label: "125%" },
277
+ ]}
278
+ onChange={setZoom}
279
+ />
280
+ ```
281
+
282
+ For selector-level styling, the stable hooks are
283
+ `.dxw-menu-select-trigger`, `.dxw-menu-select-menu`,
284
+ `.dxw-menu-select-option`, `.dxw-color-menu`, `.dxw-color-swatch`,
285
+ `.dxw-input-dialog`, `.dxw-input-dialog-field`, and the dialog action button
286
+ classes. Prefer the variables above for theme changes.
287
+
241
288
  Layout controls also expose stable `.dxw-layout-ribbon`, `.dxw-layout-menu-trigger`,
242
289
  `.dxw-layout-menu`, `.dxw-layout-menu-item`, and `.dxw-layout-preview` classes.
243
290
  Their `data-dxw-layout-menu`, `data-dxw-layout-option`, and
package/dist/index.d.ts CHANGED
@@ -109,6 +109,11 @@ interface RunProps {
109
109
  smallCaps?: boolean;
110
110
  /** Letter spacing px (w:spacing, twips in OOXML). */
111
111
  letterSpacing?: number;
112
+ /** Minimum font size in px at which w:kern enables pair kerning; null is
113
+ * the explicit w:kern=0 override. */
114
+ kerningThreshold?: number | null;
115
+ /** Paint-only letter spacing when layout advances intentionally differ. */
116
+ paintLetterSpacing?: number;
112
117
  /** w:w horizontal character scaling as a fraction (1.5 = 150%). */
113
118
  textScale?: number;
114
119
  /** w:fitText target width in px: the run's advances scale so its text
@@ -376,6 +381,9 @@ interface MathContent {
376
381
  * display-style layout - larger n-ary operators with limits stacked
377
382
  * above/below, and full-size fraction numerators/denominators. */
378
383
  display?: boolean;
384
+ /** Display group with several direct equations. Word leaves a small
385
+ * advance after script clusters in these grouped displays. */
386
+ multiEquationDisplay?: boolean;
379
387
  /** m:oMathParaPr/m:jc - display-equation justification. Absent: the
380
388
  * document default (settings m:mathPr/m:defJc, itself "centerGroup" when
381
389
  * unset). */
@@ -521,13 +529,11 @@ interface ShapeWordArt {
521
529
  /** Clockwise degrees. */
522
530
  rotation: number;
523
531
  behind?: boolean;
524
- /** The v:textpath font-size (px). Only used when the text is NOT fit to the
525
- * shape (see noFit). */
532
+ /** The source v:textpath font-size (px). */
526
533
  fontSize?: number;
527
534
  /** The referenced v:shapetype has a malformed text-guide path (missing
528
- * coordinates), so Word cannot compute the fitshape scale and falls back to
529
- * drawing the string at its nominal font-size — a near-invisible mark rather
530
- * than a box-filling watermark. Render at fontSize, unstretched, to match. */
535
+ * coordinates), so Word collapses its horizontal glyph outlines into a thin
536
+ * vertical band instead of painting a box-filling watermark. */
531
537
  noFit?: boolean;
532
538
  /** Source VML shape element (v:shape / v:rect) for interactive editing:
533
539
  * the v:textpath string, fill/opacity, and rotation live under it. */
@@ -724,6 +730,8 @@ interface DrawingTextShape {
724
730
  };
725
731
  /** Vertical anchoring of the text inside the box (bodyPr anchor). */
726
732
  textAnchor?: "top" | "middle" | "bottom";
733
+ /** DrawingML cached text paint-only baseline adjustment in px. */
734
+ paintOffsetY?: number;
727
735
  }
728
736
  interface DrawingPath {
729
737
  /** Position/size inside the drawing, px. */
@@ -753,6 +761,8 @@ interface NoteRefContent {
753
761
  noteType: "footnote" | "endnote";
754
762
  id: number;
755
763
  self?: boolean;
764
+ /** The document supplies the visible mark in the following run content. */
765
+ customMarkFollows?: boolean;
756
766
  }
757
767
  /** w:ruby — an East-Asian ruby (furigana) cluster: an annotation run (w:rt)
758
768
  * riding above a base run (w:rubyBase). Both sides render as their own runs;
@@ -801,6 +811,8 @@ interface Paragraph {
801
811
  interface TableCellProps {
802
812
  /** Preferred width px (from tcW when dxa). */
803
813
  width?: number;
814
+ /** The source explicitly declares tcW type="auto" (distinct from no tcW). */
815
+ widthAuto?: boolean;
804
816
  gridSpan: number;
805
817
  vMerge?: "restart" | "continue";
806
818
  borders?: {
@@ -1138,6 +1150,9 @@ declare class DocxDocument {
1138
1150
  /** Note content by note id (render-only; sources stripped). */
1139
1151
  readonly footnotes: Map<number, Block[]>;
1140
1152
  readonly endnotes: Map<number, Block[]>;
1153
+ /** The separator paragraph controls the gap between its rule and the first
1154
+ * footnote. */
1155
+ readonly footnoteSeparator: Block[];
1141
1156
  /** `_Ref` cross-reference bookmark ranges (name → captured runs). REF
1142
1157
  * fields re-render the referenced text from these — Word recomputes REF on
1143
1158
  * open, so the cached field result in the file is stale. */
@@ -1226,6 +1241,10 @@ declare class DocxDocument {
1226
1241
  * single-threaded and sequential per section. */
1227
1242
  charGridEa: boolean;
1228
1243
  private constructor();
1244
+ /** Resolve content controls mapped to standard package core properties.
1245
+ * Word refreshes these bindings on open, so the serialized sdtContent can
1246
+ * be stale even though the visible value comes from docProps/core.xml. */
1247
+ private hydrateCorePropertyControls;
1229
1248
  /** Repair only objects emitted by older WordInWeb builds that Word rejects. */
1230
1249
  private repairLegacyWordInWebObjects;
1231
1250
  /**
@@ -1420,6 +1439,8 @@ interface FontSpec {
1420
1439
  size: number;
1421
1440
  bold: boolean;
1422
1441
  italic: boolean;
1442
+ /** Pair kerning is active because the run met its w:kern size threshold. */
1443
+ kerning?: boolean;
1423
1444
  /** Optional PAINT-only family tried before `family` in the CSS stack, without
1424
1445
  * affecting metrics or width lookups (keyed by `family`). Used for CJK: the
1425
1446
  * line-pitch profile stays keyed by the macOS substitute face while the real
@@ -1684,10 +1705,10 @@ interface WordArtItem {
1684
1705
  /** Clockwise degrees. */
1685
1706
  rotation: number;
1686
1707
  behind?: boolean;
1687
- /** v:textpath font-size (px), used only when noFit is set. */
1708
+ /** Source v:textpath font-size (px). */
1688
1709
  fontSize?: number;
1689
- /** Malformed shapetype guide path: render at nominal fontSize, unstretched
1690
- * (Word can't fitshape, so it draws a near-invisible mark). */
1710
+ /** Malformed shapetype guide path: Word collapses the fitted glyph outlines
1711
+ * into a thin vertical band. */
1691
1712
  noFit?: boolean;
1692
1713
  /** Source VML shape element (v:shape / v:rect), for interactive select/edit. */
1693
1714
  src?: XmlElement;
@@ -1943,7 +1964,7 @@ interface SelectionFormat {
1943
1964
  verticalAlign?: "superscript" | "subscript";
1944
1965
  }
1945
1966
 
1946
- type ShapePreset = "rectangle" | "roundedRectangle" | "ellipse" | "diamond" | "textBox";
1967
+ type ShapePreset = "line" | "rectangle" | "roundedRectangle" | "ellipse" | "diamond" | "textBox";
1947
1968
  type WordArtPreset = "plain" | "archUp" | "archDown" | "wave" | "chevron";
1948
1969
  type DrawingTool = {
1949
1970
  kind?: "pen";
@@ -2027,6 +2048,30 @@ interface MissingFont {
2027
2048
  sample: string;
2028
2049
  }
2029
2050
 
2051
+ interface ToolbarMenuSelectOption {
2052
+ value: string;
2053
+ label: React.ReactNode;
2054
+ group?: string;
2055
+ disabled?: boolean;
2056
+ fontFamily?: string;
2057
+ }
2058
+ interface ToolbarMenuSelectProps {
2059
+ value: string;
2060
+ options: ToolbarMenuSelectOption[];
2061
+ onChange: (value: string) => void;
2062
+ placeholder?: React.ReactNode;
2063
+ title?: string;
2064
+ ariaLabel?: string;
2065
+ triggerAriaLabel?: string;
2066
+ width?: number | string;
2067
+ menuWidth?: number;
2068
+ className?: string;
2069
+ style?: React.CSSProperties;
2070
+ }
2071
+ /** CSS-overridable replacement for visible native selects. An inert,
2072
+ * transparent select is kept as an event bridge for existing integrations;
2073
+ * every user-facing part is a button/listbox rendered by us. */
2074
+ declare function ToolbarMenuSelect({ value, options, onChange, placeholder, title, ariaLabel, triggerAriaLabel, width, menuWidth, className, style, }: ToolbarMenuSelectProps): react.JSX.Element;
2030
2075
  /** Toolbar control groups a host can disable via the `features` prop. */
2031
2076
  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";
2032
2077
  type ToolbarMode = "simple" | "advanced";
@@ -2250,4 +2295,4 @@ interface DocxViewProps {
2250
2295
  */
2251
2296
  declare function DocxView({ source, zoom, fitWidth, narrowWidth, editable, className, style, onLoad, onReady, onError, commentAuthor, showComments, revisions, onMissingFonts, }: DocxViewProps): react.JSX.Element;
2252
2297
 
2253
- 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, type ToolbarMode, layoutDocument, printPages, renderToDom };
2298
+ 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 };