wordinweb 0.1.7 → 0.1.9

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/dist/index.d.ts CHANGED
@@ -16,6 +16,8 @@ interface XmlElement {
16
16
  children: XmlElement[];
17
17
  /** Concatenated character data directly inside this element. */
18
18
  text: string;
19
+ /** Editor placeholder retained in memory but omitted from XML while empty. */
20
+ omitWhenEmpty?: boolean;
19
21
  }
20
22
 
21
23
  /**
@@ -272,6 +274,27 @@ interface ImageContent {
272
274
  };
273
275
  /** Source w:drawing (or pict) element, for resize/move editing. */
274
276
  srcDrawing?: XmlElement;
277
+ /** Native Office 3D model shown through its saved poster raster. */
278
+ model3D?: Model3DReference;
279
+ /** Word online-video metadata shown through its saved poster raster. */
280
+ webVideo?: WebVideoReference;
281
+ /** Embedded OLE package activated as a safe download in the browser. */
282
+ embeddedObject?: EmbeddedObjectReference;
283
+ }
284
+ interface Model3DReference {
285
+ part: string;
286
+ posterPart: string;
287
+ }
288
+ interface WebVideoReference {
289
+ url: string;
290
+ embeddedHtml: string;
291
+ width: number;
292
+ height: number;
293
+ }
294
+ interface EmbeddedObjectReference {
295
+ part: string;
296
+ filename: string;
297
+ progId: string;
275
298
  }
276
299
  /** OMML equation node (subset: runs, scripts, fractions, radicals). */
277
300
  type MathNode = {
@@ -466,6 +489,10 @@ interface ShapeTextbox {
466
489
  * be an interactive hit target (select the shape instead of the body text
467
490
  * behind it). */
468
491
  srcDrawing?: XmlElement;
492
+ /** Header/footer-owned textbox whose text is edited as an independent story. */
493
+ textboxStory?: boolean;
494
+ /** DrawingML WordArt, including the identity textNoShape preset. */
495
+ wordArt?: boolean;
469
496
  /** bodyPr a:prstTxWarp preset name (textArchUp, textWave1, textChevron,
470
497
  * textCirclePour, …): the shape's text is bent onto the preset's envelope
471
498
  * rather than flowed as ordinary lines. "textNoShape" (no warp) is dropped. */
@@ -509,6 +536,8 @@ interface ShapeWordArt {
509
536
  interface ShapeArt {
510
537
  type: "art";
511
538
  srcDrawing?: XmlElement;
539
+ /** A freehand stroke, selectable by the Draw ribbon's stroke eraser. */
540
+ ink?: boolean;
512
541
  x: number;
513
542
  y: number;
514
543
  /** Percent-of-page offsets (wp14:pctPos*Offset), 0..1. */
@@ -519,7 +548,10 @@ interface ShapeArt {
519
548
  hRel: AnchorRel;
520
549
  vRel: AnchorRel;
521
550
  hAlign?: "left" | "center" | "right";
551
+ vAlign?: "top" | "center" | "bottom";
522
552
  behind?: boolean;
553
+ /** a:xfrm rotation, degrees clockwise. */
554
+ rotation?: number;
523
555
  lines: DrawingLine[];
524
556
  images: DrawingImage[];
525
557
  paths: DrawingPath[];
@@ -566,8 +598,14 @@ interface ShapeImage {
566
598
  };
567
599
  /** Source w:drawing element (editing). */
568
600
  srcDrawing?: XmlElement;
601
+ model3D?: Model3DReference;
602
+ webVideo?: WebVideoReference;
603
+ embeddedObject?: EmbeddedObjectReference;
569
604
  }
570
- type Shape = ShapeLine | ShapeTextbox | ShapeImage | ShapeArt | ShapeWordArt;
605
+ type Shape = (ShapeLine | ShapeTextbox | ShapeImage | ShapeArt | ShapeWordArt) & {
606
+ /** wp:anchor relativeHeight, used for object stacking order. */
607
+ z?: number;
608
+ };
571
609
  /**
572
610
  * Floating/anchored object: does not occupy inline space; positioned against
573
611
  * page/margin/paragraph during layout. (How classic pleading paper draws its
@@ -615,6 +653,10 @@ interface DrawingContent {
615
653
  height: number;
616
654
  lines: DrawingLine[];
617
655
  images: DrawingImage[];
656
+ /** Native ChartML chart data resolved from the related chart part. */
657
+ chart?: ChartData;
658
+ /** Native SmartArt diagram data resolved from its diagram parts. */
659
+ smartArt?: SmartArtData;
618
660
  /** Freeform vector shapes (a:custGeom), as SVG path data. */
619
661
  paths?: DrawingPath[];
620
662
  /** An INLINE wps text box (wp:inline wps:txbx): a fixed-extent box that
@@ -642,6 +684,22 @@ interface DrawingContent {
642
684
  * SmartArt cached-drawing shapes). Painted above lines/paths. */
643
685
  texts?: DrawingTextShape[];
644
686
  }
687
+ type ChartType = "column" | "bar" | "line" | "pie";
688
+ interface ChartSeries {
689
+ name: string;
690
+ values: number[];
691
+ }
692
+ interface ChartData {
693
+ type: ChartType;
694
+ title?: string;
695
+ categories: string[];
696
+ series: ChartSeries[];
697
+ }
698
+ type SmartArtLayout = "process" | "cycle" | "hierarchy" | "list";
699
+ interface SmartArtData {
700
+ layout: SmartArtLayout;
701
+ items: string[];
702
+ }
645
703
  /** A text body positioned inside a composite drawing (a wps textbox in a
646
704
  * group, or a SmartArt dsp:sp txBody), px relative to the drawing's box. */
647
705
  interface DrawingTextShape {
@@ -681,6 +739,7 @@ interface DrawingPath {
681
739
  stroke?: {
682
740
  color: string;
683
741
  width: number;
742
+ opacity?: number;
684
743
  };
685
744
  }
686
745
  /**
@@ -1064,7 +1123,10 @@ declare class DocxDocument {
1064
1123
  /** Changes whenever refresh() rebuilds the parsed model. Plain in-place text
1065
1124
  * edits can keep this stable so incremental layout reuses model-only caches. */
1066
1125
  private _modelVersion;
1126
+ private _packageResourceVersion;
1067
1127
  get modelVersion(): number;
1128
+ /** Invalidate layout derived from related parts such as ChartML. */
1129
+ markPackageResourceChanged(): void;
1068
1130
  readonly pkg: Package;
1069
1131
  readonly theme: Theme;
1070
1132
  styles: Styles;
@@ -1137,6 +1199,11 @@ declare class DocxDocument {
1137
1199
  private commentsDirty;
1138
1200
  /** Retained XML roots — source of truth for editing and save(). */
1139
1201
  private readonly docPart;
1202
+ /** Retained settings.xml tree. A synthetic empty root keeps history root
1203
+ * indices stable for documents that did not originally contain the part. */
1204
+ private readonly settingsPart;
1205
+ private readonly settingsRoot;
1206
+ private settingsDirty;
1140
1207
  /** Parsed document.xml root (read-only outside the class; the layout engine
1141
1208
  * scans it for incremental-reuse eligibility, tests walk it). */
1142
1209
  readonly docRoot: XmlElement;
@@ -1147,6 +1214,10 @@ declare class DocxDocument {
1147
1214
  private readonly relsPath;
1148
1215
  private relsRoot;
1149
1216
  private contentTypesRoot;
1217
+ /** Canonical XML as first parsed from each always-modeled package part.
1218
+ * If the retained tree still matches on save, keep the part's original
1219
+ * bytes instead of replacing producer formatting such as CRLF line ends. */
1220
+ private readonly originalModeledXml;
1150
1221
  private nextDocPrId;
1151
1222
  /** Transient layout state: set by the engine while laying out a docGrid
1152
1223
  * type="charsAndLines" section so line measurement can give East-Asian
@@ -1155,6 +1226,8 @@ declare class DocxDocument {
1155
1226
  * single-threaded and sequential per section. */
1156
1227
  charGridEa: boolean;
1157
1228
  private constructor();
1229
+ /** Repair only objects emitted by older WordInWeb builds that Word rejects. */
1230
+ private repairLegacyWordInWebObjects;
1158
1231
  /**
1159
1232
  * Re-derive the document model from the retained XML trees. Called after
1160
1233
  * edit commands mutate the XML.
@@ -1172,6 +1245,24 @@ declare class DocxDocument {
1172
1245
  * stable across a plain text edit). */
1173
1246
  layoutGlobalSig(): string;
1174
1247
  refresh(): void;
1248
+ /** Reparse the two sibling body-story paragraphs created by Enter without
1249
+ * rebuilding the complete document model. Paragraphs nested in table cells
1250
+ * are included because legal documents spend most of their body inside
1251
+ * tables; revisions, bookmarks, fields, and section breaks use refresh(). */
1252
+ reparseDirectBodyParagraphSplit(beforeSource: XmlElement, afterSource: XmlElement): {
1253
+ before: Paragraph;
1254
+ after: Paragraph;
1255
+ } | null;
1256
+ /** Reparse a body paragraph plus several new siblings created by
1257
+ * click-and-type without rebuilding the complete document model. */
1258
+ reparseDirectBodyParagraphSplits(beforeSource: XmlElement, afterSources: XmlElement[]): Paragraph[] | null;
1259
+ /** Reparse one retained body-story paragraph after a structural edit that
1260
+ * leaves its surrounding block list unchanged, such as inserting ink. */
1261
+ reparseBodyParagraph(source: XmlElement): Paragraph | null;
1262
+ /** Reparse two sibling body-story paragraphs after Backspace/Delete merged
1263
+ * their XML into one. Keeps the parsed model generation stable so long
1264
+ * documents can use incremental layout instead of repaginating in full. */
1265
+ reparseDirectBodyParagraphMerge(beforeSource: XmlElement, afterSource: XmlElement, survivorSource: XmlElement): Paragraph | null;
1175
1266
  private deriveComments;
1176
1267
  /** Retained comments tree for edit commands (null when the doc has none). */
1177
1268
  /**
@@ -1222,13 +1313,16 @@ declare class DocxDocument {
1222
1313
  * nearest preceding w:t.
1223
1314
  */
1224
1315
  commentAnchors(): Map<string, XmlElement[]>;
1225
- /** The mutable XML roots (document body, header/footer parts, comments).
1226
- * The comments root is last so history snapshot indices stay stable. */
1227
1316
  /** Flag the footnotes part dirty when `t` lives inside it, so save()
1228
1317
  * re-serializes footnotes.xml. Called by the editor after a text edit; a
1229
1318
  * no-op for body/header/footer targets. */
1230
1319
  markDirtyIfFootnote(t: XmlElement): void;
1320
+ /** The mutable XML roots (document body, related modeled parts, settings).
1321
+ * settingsRoot is always second and always present so its history snapshot
1322
+ * index stays stable even when optional related roots are created later. */
1231
1323
  editableRoots(): XmlElement[];
1324
+ /** Toggle the document-global facing-page margin mode in settings.xml. */
1325
+ setMirrorMargins(enabled: boolean): void;
1232
1326
  /**
1233
1327
  * Find the parent element of `target` in any modeled XML tree (document
1234
1328
  * body, headers, footers). Linear scan — documents are small and this only
@@ -1242,6 +1336,8 @@ declare class DocxDocument {
1242
1336
  * XML parts we model are re-serialized; every other part round-trips
1243
1337
  * byte-for-byte.
1244
1338
  */
1339
+ private rememberOriginalXml;
1340
+ private writeModeledXml;
1245
1341
  save(): Uint8Array;
1246
1342
  /** Fresh unique docPr id for inserted drawings. */
1247
1343
  nextDrawingId(): number;
@@ -1260,6 +1356,34 @@ declare class DocxDocument {
1260
1356
  /** Retarget an existing external relationship (hyperlink href edit). */
1261
1357
  setRelTarget(relId: string, url: string): boolean;
1262
1358
  addImageResource(bytes: Uint8Array, ext: string): string;
1359
+ /** Add a GLB model part and its Office 2019 model3d relationship. */
1360
+ addModel3DResource(bytes: Uint8Array): {
1361
+ relId: string;
1362
+ part: string;
1363
+ };
1364
+ /** Add an OLE package part used by a Word w:object. */
1365
+ addEmbeddedObjectResource(bytes: Uint8Array): {
1366
+ relId: string;
1367
+ part: string;
1368
+ };
1369
+ /** Add a DOCX package embedded as an activatable Word.Document.12 object. */
1370
+ addEmbeddedWordDocumentResource(bytes: Uint8Array): {
1371
+ relId: string;
1372
+ part: string;
1373
+ };
1374
+ /** Add a native ChartML part and its embedded editable workbook. */
1375
+ addChartResource(chartXml: string, workbook: Uint8Array): {
1376
+ relId: string;
1377
+ part: string;
1378
+ };
1379
+ /** Add the SmartArt data/layout/style/color parts and its cached diagram drawing. */
1380
+ addSmartArtResources(layoutXml: string, styleXml: string, colorsXml: string, drawingXml: string, dataXml: (drawingRelId: string) => string): {
1381
+ dataRelId: string;
1382
+ layoutRelId: string;
1383
+ styleRelId: string;
1384
+ colorsRelId: string;
1385
+ drawingRelId: string;
1386
+ };
1263
1387
  static load(data: ArrayBuffer | Uint8Array): DocxDocument;
1264
1388
  media(part: string): Uint8Array | undefined;
1265
1389
  /** Effective paragraph properties: docDefaults → table style → style chain → direct. */
@@ -1321,10 +1445,17 @@ interface PathItem {
1321
1445
  stroke?: {
1322
1446
  color: string;
1323
1447
  width: number;
1448
+ opacity?: number;
1449
+ };
1450
+ rotate?: {
1451
+ deg: number;
1452
+ ox: number;
1453
+ oy: number;
1324
1454
  };
1325
1455
  /** Paint under / over the body text (anchored-shape layering). */
1326
1456
  behind?: boolean;
1327
1457
  front?: boolean;
1458
+ z?: number;
1328
1459
  }
1329
1460
  interface TextItem {
1330
1461
  kind: "text";
@@ -1366,6 +1497,9 @@ interface TextItem {
1366
1497
  href?: string;
1367
1498
  /** Present for editable text (absent on numbering labels etc.). */
1368
1499
  src?: TextSource;
1500
+ /** Source drawing when this text belongs to an independently editable
1501
+ * text-box story. */
1502
+ textboxStory?: XmlElement;
1369
1503
  /** Rotate about a point (px, relative to this item's top-left). */
1370
1504
  rotate?: {
1371
1505
  deg: number;
@@ -1377,6 +1511,7 @@ interface TextItem {
1377
1511
  /** Paint over the body text (non-behindDoc anchored shape content: Word
1378
1512
  * layers in-front shapes above the text layer). */
1379
1513
  front?: boolean;
1514
+ z?: number;
1380
1515
  /** Right-to-left run: renderer sets direction:rtl so the browser shapes and
1381
1516
  * orders the (Arabic/Hebrew) glyphs within the span box. */
1382
1517
  rtl?: boolean;
@@ -1407,6 +1542,7 @@ interface RectItem {
1407
1542
  behind?: boolean;
1408
1543
  /** Paint over the body text (non-behindDoc anchored shape fill). */
1409
1544
  front?: boolean;
1545
+ z?: number;
1410
1546
  }
1411
1547
  interface LineEdgeItem {
1412
1548
  kind: "edge";
@@ -1425,6 +1561,7 @@ interface LineEdgeItem {
1425
1561
  };
1426
1562
  /** Paint over the body text (non-behindDoc anchored shape border). */
1427
1563
  front?: boolean;
1564
+ z?: number;
1428
1565
  }
1429
1566
  interface ImageItem {
1430
1567
  kind: "image";
@@ -1442,6 +1579,12 @@ interface ImageItem {
1442
1579
  b: number;
1443
1580
  };
1444
1581
  rotation?: number;
1582
+ /** Whole-group rotation about an external origin. */
1583
+ rotate?: {
1584
+ deg: number;
1585
+ ox: number;
1586
+ oy: number;
1587
+ };
1445
1588
  /** Picture-watermark "washout" (VML v:imagedata gain/blacklevel, 0..1
1446
1589
  * fractions). Per-channel linear recolor, measured against Word's PDF of
1447
1590
  * probe2-picture-watermark (gain 0.3, blacklevel 0.35: source 32 -> 215,
@@ -1462,8 +1605,20 @@ interface ImageItem {
1462
1605
  * (Word's z-order; without this, later-emitted text spans cover the image
1463
1606
  * and it neither shows in front nor receives clicks/drags). */
1464
1607
  front?: boolean;
1608
+ z?: number;
1465
1609
  /** Source w:drawing element (for interactive resize/move). */
1466
1610
  src?: XmlElement;
1611
+ model3D?: Model3DReference;
1612
+ webVideo?: WebVideoReference;
1613
+ embeddedObject?: EmbeddedObjectReference;
1614
+ }
1615
+ interface ChartItem {
1616
+ kind: "chart";
1617
+ x: number;
1618
+ y: number;
1619
+ width: number;
1620
+ height: number;
1621
+ data: ChartData;
1467
1622
  }
1468
1623
  /** Interactive resize zone over a table boundary (column or row). */
1469
1624
  interface DrawingHitItem {
@@ -1476,16 +1631,28 @@ interface DrawingHitItem {
1476
1631
  src: XmlElement;
1477
1632
  /** Anchored drawings drag by offset; inline ones re-anchor into text. */
1478
1633
  anchored: boolean;
1634
+ /** Freehand stroke that may be removed with the Draw ribbon's eraser. */
1635
+ ink?: boolean;
1636
+ /** Native SmartArt diagram selection target. */
1637
+ smartArt?: boolean;
1479
1638
  /** A shape fill hit that sits UNDER the shape's own text spans (same z): a
1480
- * click on bare fill selects the shape, but clicks on the text glyphs still
1481
- * reach the text for editing. Such hits select only (never drag-move). */
1639
+ * click on bare fill selects or drags the shape, while clicks on its text
1640
+ * glyphs still reach the text editor. */
1482
1641
  belowText?: boolean;
1642
+ /** The drawing owns an independently editable text-box story. */
1643
+ textboxStory?: boolean;
1644
+ rotate?: {
1645
+ deg: number;
1646
+ ox: number;
1647
+ oy: number;
1648
+ };
1649
+ z?: number;
1483
1650
  }
1484
1651
  interface GripItem {
1485
1652
  kind: "grip";
1486
1653
  /** "col": vertical zone at x spanning y1..y2. "row": horizontal zone at y1
1487
- * spanning x..x2. */
1488
- axis: "col" | "row";
1654
+ * spanning x..x2. "move": table bounds x..x2, y1..y2. */
1655
+ axis: "col" | "row" | "move";
1489
1656
  x: number;
1490
1657
  y1: number;
1491
1658
  y2: number;
@@ -1545,10 +1712,16 @@ interface WarpTextItem {
1545
1712
  fill: string;
1546
1713
  /** Preset name (textArchUp, textWave1, textChevron, textCirclePour, …). */
1547
1714
  warp: string;
1715
+ rotate?: {
1716
+ deg: number;
1717
+ ox: number;
1718
+ oy: number;
1719
+ };
1548
1720
  behind?: boolean;
1549
1721
  front?: boolean;
1722
+ z?: number;
1550
1723
  }
1551
- type PageItem = TextItem | PathItem | RectItem | LineEdgeItem | ImageItem | DrawingHitItem | GripItem | WordArtItem | WarpTextItem;
1724
+ type PageItem = TextItem | PathItem | RectItem | LineEdgeItem | ImageItem | ChartItem | DrawingHitItem | GripItem | WordArtItem | WarpTextItem;
1552
1725
  interface LaidOutPage {
1553
1726
  width: number;
1554
1727
  height: number;
@@ -1570,6 +1743,13 @@ interface LayoutResult {
1570
1743
  * back as LayoutOptions.prev to enable incremental relayout. Not part of the
1571
1744
  * rendered output and ignored by the equivalence harness. */
1572
1745
  _incr?: unknown;
1746
+ /** Internal marker: unchanged pages in this result retain exact object
1747
+ * identity from the previous layout, so the DOM diff can use identity
1748
+ * instead of structurally walking a dense changed page. */
1749
+ _incremental?: boolean;
1750
+ /** Exclusive global page index through which an incremental render may run
1751
+ * pageEq before the page containing the exact dirty text source. */
1752
+ _incrementalStructuralPrefixEnd?: number;
1573
1753
  /** Opaque page state used to refresh headers/footers without repaginating
1574
1754
  * the body when their measured geometry is unchanged. */
1575
1755
  _hf?: unknown;
@@ -1620,11 +1800,12 @@ interface LayoutOptions {
1620
1800
  * type/delete. Lets the incremental scan skip re-hashing every block: it
1621
1801
  * re-hashes only the hinted block and its two neighbours and reuses prev's
1622
1802
  * per-block signatures for the rest. Purely an optimisation — the fast path
1623
- * is gated on block-count parity and neighbour-signature checks, so a stale,
1624
- * structural, or wrong hint falls through to the full block scan. Absent for
1625
- * multi-block edits (paste, paragraph split/merge, undo/redo, structural ops),
1626
- * which take the full scan. */
1803
+ * is gated on block identity/count and neighbour-signature checks, so a stale
1804
+ * or wrong hint falls through to the full block scan. */
1627
1805
  dirtyHint?: XmlElement;
1806
+ /** Exact retained text element changed by a local edit. Used only to bound
1807
+ * structural page comparison before the first actually dirty page. */
1808
+ dirtySource?: XmlElement;
1628
1809
  }
1629
1810
  declare function layoutDocument(doc: DocxDocument, options?: LayoutOptions): LayoutResult;
1630
1811
 
@@ -1762,6 +1943,25 @@ interface SelectionFormat {
1762
1943
  verticalAlign?: "superscript" | "subscript";
1763
1944
  }
1764
1945
 
1946
+ type ShapePreset = "rectangle" | "roundedRectangle" | "ellipse" | "diamond" | "textBox";
1947
+ type WordArtPreset = "plain" | "archUp" | "archDown" | "wave" | "chevron";
1948
+ type DrawingTool = {
1949
+ kind?: "pen";
1950
+ color: string;
1951
+ width: number;
1952
+ } | {
1953
+ kind: "highlighter";
1954
+ color: string;
1955
+ width: number;
1956
+ } | {
1957
+ kind: "eraser";
1958
+ size: number;
1959
+ } | {
1960
+ kind: "lasso";
1961
+ };
1962
+
1963
+ type ObjectArrangeAction = "alignLeft" | "alignCenter" | "alignRight" | "alignTop" | "alignMiddle" | "alignBottom" | "rotateLeft" | "rotateRight" | "bringToFront" | "sendToBack";
1964
+
1765
1965
  type ParagraphAlignment = "left" | "center" | "right" | "justify";
1766
1966
  interface PageLayoutPatch {
1767
1967
  /** Margins in inches. */
@@ -1771,6 +1971,8 @@ interface PageLayoutPatch {
1771
1971
  bottom?: number;
1772
1972
  left?: number;
1773
1973
  };
1974
+ /** Document-global facing-page mode (settings.xml w:mirrorMargins). */
1975
+ mirrorMargins?: boolean;
1774
1976
  /** Page size in inches (before orientation). */
1775
1977
  size?: {
1776
1978
  width: number;
@@ -1802,6 +2004,11 @@ type TableOp = "rowAbove" | "rowBelow" | "deleteRow" | "colLeft" | "colRight" |
1802
2004
  v: "top" | "center" | "bottom";
1803
2005
  };
1804
2006
 
2007
+ interface CoverPageContent {
2008
+ title: string;
2009
+ subtitle?: string;
2010
+ author?: string;
2011
+ }
1805
2012
  interface LineNumberingPatch {
1806
2013
  /** Turn margin line numbering on/off for the target section(s). */
1807
2014
  enabled: boolean;
@@ -1821,17 +2028,21 @@ interface MissingFont {
1821
2028
  }
1822
2029
 
1823
2030
  /** Toolbar control groups a host can disable via the `features` prop. */
1824
- type ToolbarFeature = "history" | "styles" | "font" | "size" | "format" | "color" | "highlight" | "alignment" | "indent" | "spacing" | "link" | "lists" | "table" | "image" | "comment" | "footnote" | "layout" | "download";
1825
- declare function DocxToolbar({ api, onSave, features, className, style, }: {
2031
+ 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
+ type ToolbarMode = "simple" | "advanced";
2033
+ interface DocxToolbarProps {
1826
2034
  api: DocxViewApi | null;
1827
2035
  onSave?: (bytes: Uint8Array) => void;
2036
+ /** Simple shows basic Home editing; advanced adds the Insert, Draw, and Layout ribbons. */
2037
+ mode?: ToolbarMode;
1828
2038
  /** Per-group overrides; every group defaults to enabled. */
1829
2039
  features?: Partial<Record<ToolbarFeature, boolean>>;
1830
2040
  /** Extra class on the toolbar root (e.g. a scope for CSS-variable overrides). */
1831
2041
  className?: string;
1832
2042
  /** Inline overrides merged onto the toolbar root; wins over the defaults. */
1833
2043
  style?: React.CSSProperties;
1834
- }): react.JSX.Element;
2044
+ }
2045
+ declare function DocxToolbar({ api, onSave, mode, features, className, style, }: DocxToolbarProps): react.JSX.Element;
1835
2046
 
1836
2047
  interface DocxViewApi {
1837
2048
  /** Apply character formatting to the current browser selection. */
@@ -1842,6 +2053,44 @@ interface DocxViewApi {
1842
2053
  addFootnote(text: string): boolean;
1843
2054
  /** Insert a dynamic page-number field at the caret (body, header or footer). */
1844
2055
  insertPageNumber(kind?: "page" | "pageOfTotal"): boolean;
2056
+ /** Insert any Word field instruction supported by the renderer. */
2057
+ insertField(instruction: string, cachedResult?: string): boolean;
2058
+ /** Insert a live DATE or TIME field with an optional Word date picture. */
2059
+ insertDateTime(kind: "date" | "time", picture?: string): boolean;
2060
+ /** Named bookmarks in document order. */
2061
+ listBookmarks(): string[];
2062
+ /** Add a bookmark around the selection, or a zero-length bookmark at the caret. */
2063
+ addBookmark(name: string): boolean;
2064
+ /** Insert a live text or page reference to a bookmark. */
2065
+ insertCrossReference(bookmark: string, kind: "text" | "page"): boolean;
2066
+ /** Insert an editable inline equation from WordInWeb's linear math syntax. */
2067
+ insertEquation(linear: string): boolean;
2068
+ /** Insert a Unicode symbol through the normal undo/suggestion-aware typing path. */
2069
+ insertSymbol(symbol: string): boolean;
2070
+ /** Insert a floating editable DrawingML shape at the caret. */
2071
+ insertShape(preset: ShapePreset, text?: string): boolean;
2072
+ /** Insert editable DrawingML WordArt at the caret. */
2073
+ insertWordArt(text: string, preset?: WordArtPreset): boolean;
2074
+ /** Insert a native editable ChartML chart at the caret. */
2075
+ insertChart(data: ChartData): boolean;
2076
+ /** Replace the selected native chart's type and data. */
2077
+ updateSelectedChart(data: ChartData): boolean;
2078
+ /** Insert a native editable SmartArt diagram at the caret. */
2079
+ insertSmartArt(data: SmartArtData): boolean;
2080
+ /** Replace the selected native SmartArt diagram's layout and node text. */
2081
+ updateSelectedSmartArt(data: SmartArtData): boolean;
2082
+ /** Insert a native Office 3D model with an optional custom poster image. */
2083
+ insertModel3D(file: Blob, poster?: Blob): Promise<boolean>;
2084
+ /** Insert Word online-video metadata with a browser-safe poster. */
2085
+ insertOnlineVideo(url: string): Promise<boolean>;
2086
+ /** Embed an arbitrary file as a native OLE Package object. */
2087
+ insertEmbeddedObject(file: Blob, filename?: string): Promise<boolean>;
2088
+ /** Activate a freehand pen, or return to selection mode with null. */
2089
+ setDrawingTool(tool: DrawingTool | null): void;
2090
+ /** Current freehand pen, or null while in selection mode. */
2091
+ getDrawingTool(): DrawingTool | null;
2092
+ /** Align, rotate, or reorder the selected image, shape, or ink group. */
2093
+ arrangeObject(action: ObjectArrangeAction): boolean;
1845
2094
  undo(): void;
1846
2095
  redo(): void;
1847
2096
  canUndo(): boolean;
@@ -1852,6 +2101,8 @@ interface DocxViewApi {
1852
2101
  tableOp(op: TableOp): void;
1853
2102
  /** Insert an image file at the caret (inline, natural size clamped to column). */
1854
2103
  insertImage(file: Blob): Promise<void>;
2104
+ /** Capture a screen, window, or browser tab and insert the current frame as a PNG picture. */
2105
+ insertScreenshot(): Promise<ScreenshotInsertResult>;
1855
2106
  /** Align the paragraph(s) under the caret or selection. */
1856
2107
  setAlignment(align: ParagraphAlignment): void;
1857
2108
  /** Apply a named paragraph style (null clears back to Normal). */
@@ -1872,6 +2123,8 @@ interface DocxViewApi {
1872
2123
  beforePt?: number | null;
1873
2124
  afterPt?: number | null;
1874
2125
  }): void;
2126
+ /** Apply or remove a native Word drop cap on the caret paragraph. */
2127
+ setDropCap(mode: "drop" | "margin" | null, lines?: number): boolean;
1875
2128
  /** Remove direct character formatting from the selection. */
1876
2129
  clearFormatting(): void;
1877
2130
  /** Change the selection's case. */
@@ -1897,6 +2150,10 @@ interface DocxViewApi {
1897
2150
  setPageLayout(patch: PageLayoutPatch, scope?: "document" | "section"): void;
1898
2151
  /** Insert a page/column break or a section break at the caret. */
1899
2152
  insertBreak(kind: "page" | "column" | "sectionNextPage" | "sectionContinuous"): boolean;
2153
+ /** Insert a full blank page at the caret (two consecutive page breaks). */
2154
+ insertBlankPage(): boolean;
2155
+ /** Insert an editable cover page before the current document. */
2156
+ insertCoverPage(content: CoverPageContent): boolean;
1900
2157
  /** Toggle/configure margin line numbers (Word's Layout > Line Numbers).
1901
2158
  * scope "section" targets the caret's section; "document" every section. */
1902
2159
  setLineNumbering(patch: LineNumberingPatch, scope?: "document" | "section"): void;
@@ -1908,6 +2165,8 @@ interface DocxViewApi {
1908
2165
  } | null;
1909
2166
  /** Leave header/footer editing mode. */
1910
2167
  closeHeaderFooter(): void;
2168
+ /** Enter and, if needed, create the header or footer on the caret's page. */
2169
+ openHeaderFooter(kind: "header" | "footer"): boolean;
1911
2170
  /** Effective formatting of the current selection (toolbar state), or null. */
1912
2171
  getSelectionFormat(): SelectionFormat | null;
1913
2172
  /** Print the rendered pages (browser print dialog / save as PDF). */
@@ -1936,6 +2195,7 @@ interface DocxViewApi {
1936
2195
  rejectAllRevisions(): number;
1937
2196
  document: DocxDocument;
1938
2197
  }
2198
+ type ScreenshotInsertResult = "inserted" | "unsupported" | "cancelled" | "error" | "no-caret";
1939
2199
  interface DocxViewProps {
1940
2200
  /** The document: raw bytes, a File/Blob, or a URL to fetch. */
1941
2201
  source: ArrayBuffer | Uint8Array | Blob | string;
@@ -1990,4 +2250,4 @@ interface DocxViewProps {
1990
2250
  */
1991
2251
  declare function DocxView({ source, zoom, fitWidth, narrowWidth, editable, className, style, onLoad, onReady, onError, commentAuthor, showComments, revisions, onMissingFonts, }: DocxViewProps): react.JSX.Element;
1992
2252
 
1993
- export { DocxDocument, DocxToolbar, DocxView, type DocxViewApi, type DocxViewProps, type LineNumberingPatch, type PageLayoutPatch, type ParagraphAlignment, type RunFormatPatch, type SelectionFormat, layoutDocument, printPages, renderToDom };
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 };