@betteroffice/docx 0.0.1

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.
Files changed (190) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -0
  3. package/dist/Subscribable-DOz6Ohoo.d.mts +33 -0
  4. package/dist/agent/index.d.mts +531 -0
  5. package/dist/agent/index.mjs +1 -0
  6. package/dist/chunk-34K66SY4.mjs +1 -0
  7. package/dist/chunk-3UBMCDME.mjs +1 -0
  8. package/dist/chunk-4RCISPPE.mjs +1 -0
  9. package/dist/chunk-4UD54UM5.mjs +1 -0
  10. package/dist/chunk-52GB3Y42.mjs +1 -0
  11. package/dist/chunk-6NEKRDXF.mjs +1 -0
  12. package/dist/chunk-6PW4CWUG.mjs +1 -0
  13. package/dist/chunk-7DEIW7FL.mjs +1 -0
  14. package/dist/chunk-7PCO5I2O.mjs +1 -0
  15. package/dist/chunk-BI3B33LI.mjs +1 -0
  16. package/dist/chunk-BIQWVK5P.mjs +2 -0
  17. package/dist/chunk-CIRN3LZA.mjs +1 -0
  18. package/dist/chunk-DXKG3HQ5.mjs +16 -0
  19. package/dist/chunk-EUUIJVM6.mjs +0 -0
  20. package/dist/chunk-FPZBTOD6.mjs +1 -0
  21. package/dist/chunk-FZIA7OFY.mjs +1 -0
  22. package/dist/chunk-GWKJ2Y4Y.mjs +1 -0
  23. package/dist/chunk-H3JCIGWK.mjs +1 -0
  24. package/dist/chunk-HJGAQIU7.mjs +2 -0
  25. package/dist/chunk-I6KKMUUC.mjs +1 -0
  26. package/dist/chunk-IL5JZJT7.mjs +1 -0
  27. package/dist/chunk-JY6ILTNS.mjs +1 -0
  28. package/dist/chunk-KEE52TT5.mjs +1 -0
  29. package/dist/chunk-KVKLLTDP.mjs +58 -0
  30. package/dist/chunk-KXNZFTTK.mjs +1 -0
  31. package/dist/chunk-L5ISVQ3W.mjs +1 -0
  32. package/dist/chunk-LDUWIM7M.mjs +1 -0
  33. package/dist/chunk-N5Q3YN64.mjs +1 -0
  34. package/dist/chunk-NEWOMDTX.mjs +1 -0
  35. package/dist/chunk-O2QSE2I7.mjs +1 -0
  36. package/dist/chunk-OBQGPMPQ.mjs +1 -0
  37. package/dist/chunk-OJOHXQNQ.mjs +1 -0
  38. package/dist/chunk-OMR3TWCD.mjs +2 -0
  39. package/dist/chunk-P3KDV4M2.mjs +1 -0
  40. package/dist/chunk-Q7PO7V73.mjs +1 -0
  41. package/dist/chunk-QOUFE3VX.mjs +1 -0
  42. package/dist/chunk-SINEY6ZF.mjs +1 -0
  43. package/dist/chunk-T4EZMUXM.mjs +1 -0
  44. package/dist/chunk-TTRUPDAB.mjs +1 -0
  45. package/dist/chunk-TYHI7RAD.mjs +1 -0
  46. package/dist/chunk-UIEJWORW.mjs +1 -0
  47. package/dist/chunk-VAOUFAUH.mjs +1 -0
  48. package/dist/chunk-VBOTMRXV.mjs +1 -0
  49. package/dist/chunk-VCER63GQ.mjs +1 -0
  50. package/dist/chunk-WAUF2UC7.mjs +2 -0
  51. package/dist/chunk-WRWRCBLK.mjs +1 -0
  52. package/dist/chunk-X4XDO3LZ.mjs +1 -0
  53. package/dist/chunk-XQBCCJBO.mjs +9 -0
  54. package/dist/chunk-XWUOLYRQ.mjs +2 -0
  55. package/dist/chunk-XYH6XWP3.mjs +10 -0
  56. package/dist/chunk-YBIM6UJV.mjs +8 -0
  57. package/dist/chunk-YCIH2Q3E.mjs +1 -0
  58. package/dist/chunk-YUOKI2HB.mjs +1 -0
  59. package/dist/chunk-ZOV5KL7C.mjs +1 -0
  60. package/dist/colorResolver-n0o7H7ep.d.mts +290 -0
  61. package/dist/content-sSHuWw49.d.mts +2202 -0
  62. package/dist/core-plugins.d.mts +37 -0
  63. package/dist/core-plugins.mjs +1 -0
  64. package/dist/core.d.mts +451 -0
  65. package/dist/core.mjs +1 -0
  66. package/dist/displayListQueries-p-ijSzdh.d.mts +222 -0
  67. package/dist/docx/index.d.mts +618 -0
  68. package/dist/docx/index.mjs +2 -0
  69. package/dist/docx/parser.d.mts +41 -0
  70. package/dist/docx/parser.mjs +1 -0
  71. package/dist/docx/rezip.d.mts +148 -0
  72. package/dist/docx/rezip.mjs +1 -0
  73. package/dist/docx/serializer/index.d.mts +42 -0
  74. package/dist/docx/serializer/index.mjs +1 -0
  75. package/dist/docx/wrapTypes.d.mts +19 -0
  76. package/dist/docx/wrapTypes.mjs +1 -0
  77. package/dist/docxInput-DTbCa48g.d.mts +21 -0
  78. package/dist/editor/index.d.mts +170 -0
  79. package/dist/editor/index.mjs +1 -0
  80. package/dist/editorTree-DO5PyDK8.d.mts +37 -0
  81. package/dist/executor-7O2RBJ2B.mjs +1 -0
  82. package/dist/fontLoader-Bx6DK6-2.d.mts +327 -0
  83. package/dist/formatting-DoL7KBSL.d.mts +823 -0
  84. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  85. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  86. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  87. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  88. package/dist/headerFooterLayout-0zPT64Qc.d.mts +316 -0
  89. package/dist/headless.d.mts +69 -0
  90. package/dist/headless.mjs +1 -0
  91. package/dist/layout/flow/index.d.mts +149 -0
  92. package/dist/layout/flow/index.mjs +1 -0
  93. package/dist/layout/index.d.mts +307 -0
  94. package/dist/layout/index.mjs +1 -0
  95. package/dist/layout/measure/index.d.mts +324 -0
  96. package/dist/layout/measure/index.mjs +1 -0
  97. package/dist/layout/pagination/index.d.mts +60 -0
  98. package/dist/layout/pagination/index.mjs +1 -0
  99. package/dist/layout/pagination/types.d.mts +4 -0
  100. package/dist/layout/pagination/types.mjs +1 -0
  101. package/dist/layout/render/index.d.mts +733 -0
  102. package/dist/layout/render/index.mjs +1 -0
  103. package/dist/loadWasmAsset-CMvnVkfA.d.mts +3 -0
  104. package/dist/managers/AutoSaveManager.d.mts +81 -0
  105. package/dist/managers/AutoSaveManager.mjs +1 -0
  106. package/dist/managers/TableSelectionManager.d.mts +74 -0
  107. package/dist/managers/TableSelectionManager.mjs +1 -0
  108. package/dist/managers/types.d.mts +113 -0
  109. package/dist/managers/types.mjs +0 -0
  110. package/dist/mcp-cli.mjs +142 -0
  111. package/dist/mcp.d.mts +162 -0
  112. package/dist/mcp.mjs +16 -0
  113. package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +109 -0
  114. package/dist/measuredBlock-DZwz8zhD.d.mts +26 -0
  115. package/dist/plugin-api/RenderedDomContext.d.mts +114 -0
  116. package/dist/plugin-api/RenderedDomContext.mjs +1 -0
  117. package/dist/plugin-api/index.d.mts +7 -0
  118. package/dist/plugin-api/index.mjs +0 -0
  119. package/dist/plugin-api/resolveItemPositions.d.mts +39 -0
  120. package/dist/plugin-api/resolveItemPositions.mjs +1 -0
  121. package/dist/plugin-api/types.d.mts +193 -0
  122. package/dist/plugin-api/types.mjs +0 -0
  123. package/dist/processTemplate-HDUIZFJ5.mjs +1 -0
  124. package/dist/registry-DMM5VTdT.d.mts +165 -0
  125. package/dist/rustDisplayList-dqunvwxH.d.mts +1036 -0
  126. package/dist/rustPagination-Bj2hq013.d.mts +106 -0
  127. package/dist/sectionConfigs-DW3J8q0X.d.mts +55 -0
  128. package/dist/selectionContext-Buc9BCU1.d.mts +570 -0
  129. package/dist/selectiveSave-oFBJ1n71.d.mts +16 -0
  130. package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +23 -0
  131. package/dist/settingsParser-CcGvtmCK.d.mts +33 -0
  132. package/dist/styles/index.d.mts +162 -0
  133. package/dist/styles/index.mjs +1 -0
  134. package/dist/styles-VxNcXLdi.d.mts +189 -0
  135. package/dist/types/agentApi.d.mts +456 -0
  136. package/dist/types/agentApi.mjs +1 -0
  137. package/dist/types/content.d.mts +3 -0
  138. package/dist/types/content.mjs +1 -0
  139. package/dist/types/document.d.mts +117 -0
  140. package/dist/types/document.mjs +1 -0
  141. package/dist/types-DNrYr6yQ.d.mts +1754 -0
  142. package/dist/types-dYdjUZMo.d.mts +311 -0
  143. package/dist/units-O5Y02RKQ.d.mts +34 -0
  144. package/dist/utils/autoScroll.d.mts +24 -0
  145. package/dist/utils/autoScroll.mjs +1 -0
  146. package/dist/utils/cardStyles.d.mts +22 -0
  147. package/dist/utils/cardStyles.mjs +1 -0
  148. package/dist/utils/comments.d.mts +120 -0
  149. package/dist/utils/comments.mjs +4 -0
  150. package/dist/utils/findReplace.d.mts +114 -0
  151. package/dist/utils/findReplace.mjs +2 -0
  152. package/dist/utils/findVerticalScrollParent.d.mts +25 -0
  153. package/dist/utils/findVerticalScrollParent.mjs +1 -0
  154. package/dist/utils/fontOptions.d.mts +21 -0
  155. package/dist/utils/fontOptions.mjs +1 -0
  156. package/dist/utils/headingCollector.d.mts +28 -0
  157. package/dist/utils/headingCollector.mjs +1 -0
  158. package/dist/utils/highlightColors.d.mts +14 -0
  159. package/dist/utils/highlightColors.mjs +1 -0
  160. package/dist/utils/index.d.mts +956 -0
  161. package/dist/utils/index.mjs +84 -0
  162. package/dist/utils/listState.d.mts +27 -0
  163. package/dist/utils/listState.mjs +1 -0
  164. package/dist/utils/reportIssue.d.mts +23 -0
  165. package/dist/utils/reportIssue.mjs +2 -0
  166. package/dist/utils/sidebarConstants.d.mts +10 -0
  167. package/dist/utils/sidebarConstants.mjs +1 -0
  168. package/dist/utils/stylePreview.d.mts +70 -0
  169. package/dist/utils/stylePreview.mjs +1 -0
  170. package/dist/utils/textSelection.d.mts +92 -0
  171. package/dist/utils/textSelection.mjs +1 -0
  172. package/dist/utils/units.d.mts +78 -0
  173. package/dist/utils/units.mjs +1 -0
  174. package/dist/variableDetector-Borj29SF.d.mts +115 -0
  175. package/dist/wasm-FZQ5XB2Y.mjs +1 -0
  176. package/dist/wasm-SA237OSP.mjs +1 -0
  177. package/dist/wasm-edit.d.mts +473 -0
  178. package/dist/wasm-edit.mjs +1 -0
  179. package/dist/wasm-layout.d.mts +112 -0
  180. package/dist/wasm-layout.mjs +1 -0
  181. package/dist/wasm-opc.d.mts +16 -0
  182. package/dist/wasm-opc.mjs +1 -0
  183. package/dist/wasm-parse.d.mts +18 -0
  184. package/dist/wasm-parse.mjs +1 -0
  185. package/dist/watermarkApi-DCxjutkg.d.mts +38 -0
  186. package/dist/yrs/index.d.mts +882 -0
  187. package/dist/yrs/index.mjs +1 -0
  188. package/dist/yrs/residentEngineWorker.d.mts +2 -0
  189. package/dist/yrs/residentEngineWorker.mjs +1 -0
  190. package/package.json +365 -0
@@ -0,0 +1,618 @@
1
+ export { parseDocx } from './parser.mjs';
2
+ import { F as FontTable, b as RelationshipMap, M as MediaFile, S as Style } from '../styles-VxNcXLdi.mjs';
3
+ export { createDocx, default as repackDocx, updateMultipleFiles } from './rezip.mjs';
4
+ export { a as attemptSelectiveSave } from '../selectiveSave-oFBJ1n71.mjs';
5
+ export { b as buildPatchedDocumentXml, v as validatePatchSafety } from '../selectiveXmlPatch-ypkxlTD_.mjs';
6
+ import { I as Image, n as Chart, N as NumberingDefinitions, L as ListLevel, A as AbstractNumbering, aD as NumberingInstance, aq as ListRendering, aC as NumberFormat, E as Endnote, F as Footnote, a0 as EndnoteProperties, a8 as FootnoteProperties, R as Run, a5 as FieldType, a1 as Field, b2 as SimpleField, H as Hyperlink, aU as Shape, T as Table, h as TableCell, P as Paragraph, bc as TextBox, ai as ImageSize, ag as ImagePosition, ak as ImageWrap, B as BlockContent, C as Comment } from '../content-sSHuWw49.mjs';
7
+ import { Element } from 'xml-js';
8
+ import { WrapType } from './wrapTypes.mjs';
9
+ import { a as Theme, k as TabStopAlignment, i as TabLeader, j as TabStop, B as BorderSpec, c as CellMargins, F as FloatingTableProperties, S as ShadingProperties, m as TableBorders, p as TableLook, q as TableMeasurement, o as TableFormatting } from '../formatting-DoL7KBSL.mjs';
10
+ export { g as getDocumentWatermark, s as setDocumentWatermark } from '../watermarkApi-DCxjutkg.mjs';
11
+ export { e as emuToPixels, p as pixelsToEmu } from '../units-O5Y02RKQ.mjs';
12
+ import '../types/document.mjs';
13
+ import '../settingsParser-CcGvtmCK.mjs';
14
+ import '../docxInput-DTbCa48g.mjs';
15
+
16
+ /**
17
+ * Font Table Parser
18
+ *
19
+ * Parses `word/fontTable.xml` into a {@link FontTable}. The main payload we
20
+ * care about beyond font names is the `w:embed*` elements, which reference the
21
+ * obfuscated font binaries under `word/fonts/` (resolved via the font table's
22
+ * own `.rels`) and carry the `w:fontKey` GUID used to de-obfuscate them.
23
+ *
24
+ * Structure:
25
+ * ```xml
26
+ * <w:fonts>
27
+ * <w:font w:name="My Brand Sans">
28
+ * <w:family w:val="swiss"/>
29
+ * <w:pitch w:val="variable"/>
30
+ * <w:embedRegular r:id="rId1" w:fontKey="{GUID}" w:subsetted="true"/>
31
+ * </w:font>
32
+ * </w:fonts>
33
+ * ```
34
+ */
35
+
36
+ /**
37
+ * Parse `word/fontTable.xml` into a {@link FontTable}. Returns an empty table
38
+ * for missing/empty/unparseable input.
39
+ *
40
+ * @public
41
+ */
42
+ declare function parseFontTable(fontTableXml: string | null | undefined): FontTable;
43
+
44
+ /**
45
+ * Public XmlElement image compatibility adapter.
46
+ *
47
+ * Rust S9 owns package drawing/media parsing. This adapter remains for the
48
+ * published leaf API and pure image-model helpers.
49
+ */
50
+
51
+ declare function parseDrawing(drawingEl: Element, rels: RelationshipMap | undefined, media: Map<string, MediaFile> | undefined): Image | null;
52
+ declare function parseImage(node: Element, rels: RelationshipMap | undefined, media: Map<string, MediaFile> | undefined): Image | null;
53
+ declare function isInlineImage(image: Image): boolean;
54
+ declare function isFloatingImage(image: Image): boolean;
55
+ declare function isBehindText(image: Image): boolean;
56
+ declare function isInFrontOfText(image: Image): boolean;
57
+ declare function getImageWidthPx(image: Image): number;
58
+ declare function getImageHeightPx(image: Image): number;
59
+ declare function isDecorativeImage(image: Image): boolean;
60
+ declare function getWrapDistancesPx(image: Image): {
61
+ top: number;
62
+ bottom: number;
63
+ left: number;
64
+ right: number;
65
+ };
66
+
67
+ type AnchorWrapType = Exclude<WrapType, 'inline'>;
68
+ type ImageLayoutTarget = AnchorWrapType | 'squareLeft' | 'squareRight' | 'inline';
69
+ type ImageResizeHandle = 'nw' | 'ne' | 'se' | 'sw' | 'n' | 's' | 'e' | 'w';
70
+ /** Compute the preview dimensions for an image resize gesture. */
71
+ declare function calculateResizedImageDimensions(handle: ImageResizeHandle, deltaX: number, deltaY: number, startWidth: number, startHeight: number, lockAspect: boolean): {
72
+ width: number;
73
+ height: number;
74
+ };
75
+ interface SetImageWrapTypeOptions {
76
+ initialPositionEmu?: {
77
+ horizontalEmu: number;
78
+ verticalEmu: number;
79
+ };
80
+ }
81
+ interface ImageLayoutPosition {
82
+ horizontal?: {
83
+ relativeTo?: string;
84
+ posOffset?: number;
85
+ align?: string;
86
+ };
87
+ vertical?: {
88
+ relativeTo?: string;
89
+ posOffset?: number;
90
+ align?: string;
91
+ };
92
+ }
93
+ interface ImageLayoutCurrentAttrs {
94
+ wrapType?: string | null;
95
+ cssFloat?: string | null;
96
+ position?: ImageLayoutPosition | null;
97
+ }
98
+ interface ImageLayoutAttrs extends Record<string, unknown> {
99
+ wrapType: WrapType;
100
+ displayMode: 'inline' | 'float' | 'block';
101
+ cssFloat: 'left' | 'right' | 'none';
102
+ wrapText?: 'bothSides' | 'left' | 'right' | 'largest';
103
+ position?: ImageLayoutPosition;
104
+ distTop?: number;
105
+ distBottom?: number;
106
+ distLeft?: number;
107
+ distRight?: number;
108
+ }
109
+ /** Resolve the authored image attributes for one Word-style wrap choice. */
110
+ declare function resolveImageLayoutAttrs(target: ImageLayoutTarget, current: ImageLayoutCurrentAttrs, opts?: SetImageWrapTypeOptions): ImageLayoutAttrs;
111
+ /** Map current OOXML image attrs to the shared menu choice vocabulary. */
112
+ declare function deriveLayoutChoice(wrapType: WrapType, cssFloat?: string | null): ImageLayoutTarget | null;
113
+ type ImageLayoutIconHint = 'inline' | 'squareLeft' | 'squareRight' | 'behind' | 'inFront';
114
+ interface ImageLayoutOptionDef {
115
+ choice: ImageLayoutTarget;
116
+ i18nLabelKey: string;
117
+ i18nDescKey: string;
118
+ iconHint: ImageLayoutIconHint;
119
+ }
120
+ /** Word's five directional Wrap Text menu entries. */
121
+ declare const IMAGE_LAYOUT_OPTIONS: readonly ImageLayoutOptionDef[];
122
+ declare function isImageLayoutOptionEnabled(_option: ImageLayoutOptionDef, _currentWrapType: WrapType): boolean;
123
+ /** Map legacy toolbar wrap values onto the shared image command target. */
124
+ declare function toolbarValueToLayoutTarget(value: string): ImageLayoutTarget | undefined;
125
+
126
+ /**
127
+ * Compatibility context retained in public leaf-parser signatures.
128
+ * Full package chart parsing is owned by Rust S9.
129
+ */
130
+ type ChartPartsMap = Map<string, Chart>;
131
+
132
+ /**
133
+ * Numbering/List Parser for DOCX
134
+ *
135
+ * Parses numbering.xml to extract:
136
+ * - Abstract numbering definitions (templates with levels)
137
+ * - Numbering instances (concrete references with optional overrides)
138
+ *
139
+ * OOXML Structure:
140
+ * - w:abstractNum - Template definitions with 9 levels (0-8)
141
+ * - w:num - Instances that reference abstractNum and can override levels
142
+ * - w:lvl - Level definition with start, format, text pattern, etc.
143
+ */
144
+
145
+ type NumberingMap = {
146
+ definitions: NumberingDefinitions;
147
+ getLevel: (numId: number, ilvl: number) => ListLevel | null;
148
+ getAbstract: (abstractNumId: number) => AbstractNumbering | null;
149
+ getInstance: (numId: number) => NumberingInstance | null;
150
+ hasNumbering: (numId: number) => boolean;
151
+ };
152
+ /** Rust-backed adapter for the published raw-numbering.xml leaf API. */
153
+ declare function parseNumbering(numberingXml: string | null): NumberingMap;
154
+ declare function getCachedNumberingMap(definitions: NumberingDefinitions): NumberingMap;
155
+ declare function createNumberingMap(definitions: NumberingDefinitions): NumberingMap;
156
+ /**
157
+ * Resolve a paragraph's `numPr` against the numbering definitions into the
158
+ * `ListRendering` the layout pipeline needs (marker template, per-level
159
+ * numFmts, counter key, start override). Returns null when the numPr doesn't
160
+ * name a real level — including `numId === 0`, "no numbering" per ECMA-376.
161
+ *
162
+ * Shared by the parser (document load) and `applyStyle` (style picker), so a
163
+ * style-attached list renders identically in both paths.
164
+ */
165
+ declare function computeListRendering(numPr: {
166
+ numId?: number;
167
+ ilvl?: number;
168
+ }, numbering: NumberingMap): ListRendering | null;
169
+ /**
170
+ * Format a number according to the specified format
171
+ *
172
+ * @param num - The number to format
173
+ * @param format - The number format
174
+ * @returns Formatted string
175
+ */
176
+ declare function formatNumber(num: number, format: NumberFormat): string;
177
+ /**
178
+ * Render list marker text by replacing placeholders with formatted numbers
179
+ *
180
+ * @param lvlText - The level text pattern (e.g., "%1.", "%1.%2")
181
+ * @param counters - Array of counter values for each level (index 0 = level 0, etc.)
182
+ * @param formats - Array of number formats for each level
183
+ * @returns Rendered marker text
184
+ */
185
+ declare function renderListMarker(lvlText: string, counters: number[], formats: NumberFormat[]): string;
186
+ /**
187
+ * Get the bullet character for a bullet list level
188
+ *
189
+ * @param level - The list level definition
190
+ * @returns The bullet character to display
191
+ */
192
+ declare function getBulletCharacter(level: ListLevel): string;
193
+ /**
194
+ * Check if a list level is a bullet (not numbered)
195
+ */
196
+ declare function isBulletLevel(level: ListLevel): boolean;
197
+
198
+ /** Compatibility context retained in public leaf-parser signatures. */
199
+ interface SmartArtContext {
200
+ parts: Map<string, string>;
201
+ warnings?: string[];
202
+ }
203
+
204
+ /** Compatibility type retained for public XmlElement leaf adapters. */
205
+ type StyleMap = Map<string, Style>;
206
+
207
+ /** Public note compatibility helpers backed by the Rust story parser. */
208
+
209
+ interface FootnoteMap {
210
+ byId: Map<number, Footnote>;
211
+ footnotes: Footnote[];
212
+ getFootnote(id: number): Footnote | undefined;
213
+ hasFootnote(id: number): boolean;
214
+ getNormalFootnotes(): Footnote[];
215
+ getSeparator(): Footnote | undefined;
216
+ getContinuationSeparator(): Footnote | undefined;
217
+ }
218
+ interface EndnoteMap {
219
+ byId: Map<number, Endnote>;
220
+ endnotes: Endnote[];
221
+ getEndnote(id: number): Endnote | undefined;
222
+ hasEndnote(id: number): boolean;
223
+ getNormalEndnotes(): Endnote[];
224
+ getSeparator(): Endnote | undefined;
225
+ getContinuationSeparator(): Endnote | undefined;
226
+ }
227
+ declare function parseFootnotes(footnotesXml: string | null, _styles?: StyleMap | null, _theme?: Theme | null, _numbering?: NumberingMap | null, _rels?: RelationshipMap | null, _media?: Map<string, MediaFile> | null, _charts?: ChartPartsMap | null, _smartArt?: SmartArtContext | null): FootnoteMap;
228
+ declare function parseEndnotes(endnotesXml: string | null, _styles?: StyleMap | null, _theme?: Theme | null, _numbering?: NumberingMap | null, _rels?: RelationshipMap | null, _media?: Map<string, MediaFile> | null, _charts?: ChartPartsMap | null, _smartArt?: SmartArtContext | null): EndnoteMap;
229
+ declare function parseFootnoteProperties(element: Element | null): FootnoteProperties;
230
+ declare function parseEndnoteProperties(element: Element | null): EndnoteProperties;
231
+ declare function getFootnoteText(footnote: Footnote): string;
232
+ declare function getEndnoteText(endnote: Endnote): string;
233
+ declare function isSeparatorFootnote(note: Footnote): boolean;
234
+ declare function isSeparatorEndnote(note: Endnote): boolean;
235
+
236
+ /** Public field model helpers and a small XmlElement compatibility adapter. */
237
+
238
+ declare const KNOWN_FIELD_TYPES: FieldType[];
239
+ declare function parseFieldType(instruction: string): FieldType;
240
+ declare function isKnownFieldType(type: string): type is FieldType;
241
+ interface ParsedFieldInstruction {
242
+ type: FieldType;
243
+ raw: string;
244
+ argument?: string;
245
+ switches: FieldSwitch[];
246
+ }
247
+ interface FieldSwitch {
248
+ switch: string;
249
+ value?: string;
250
+ }
251
+ declare function parseFieldInstruction(instruction: string): ParsedFieldInstruction;
252
+ declare function getFormatSwitch(instruction: ParsedFieldInstruction): string | undefined;
253
+ declare function hasMergeFormat(instruction: ParsedFieldInstruction): boolean;
254
+ declare function parseSimpleField(node: Element, _styles: StyleMap | null, _theme: Theme | null): SimpleField;
255
+ type ComplexFieldState = 'outside' | 'code' | 'result';
256
+ interface ComplexFieldContext {
257
+ state: ComplexFieldState;
258
+ instruction: string;
259
+ codeRuns: Run[];
260
+ resultRuns: Run[];
261
+ fldLock: boolean;
262
+ dirty: boolean;
263
+ nestingLevel: number;
264
+ }
265
+ declare function createComplexFieldContext(): ComplexFieldContext;
266
+ declare function getFieldDisplayValue(field: Field): string;
267
+ declare function isPageNumberField(field: Field): boolean;
268
+ declare function isTotalPagesField(field: Field): boolean;
269
+ declare function isDateTimeField(field: Field): boolean;
270
+ declare function isDocPropertyField(field: Field): boolean;
271
+ declare function isReferenceField(field: Field): boolean;
272
+ declare function isMergeField(field: Field): boolean;
273
+ declare function isTocField(field: Field): boolean;
274
+
275
+ /** Public hyperlink helpers and XmlElement compatibility adapter. */
276
+
277
+ declare function parseHyperlink(node: Element, rels: RelationshipMap | null, _styles?: StyleMap | null, _theme?: Theme | null, _media?: Map<string, MediaFile> | null, _charts?: ChartPartsMap | null, _smartArt?: SmartArtContext | null): Hyperlink;
278
+ declare function getHyperlinkText(hyperlink: Hyperlink): string;
279
+ declare function isExternalLink(hyperlink: Hyperlink): boolean;
280
+ declare function isInternalLink(hyperlink: Hyperlink): boolean;
281
+ declare function getHyperlinkUrl(hyperlink: Hyperlink): string | undefined;
282
+ declare function hasContent(hyperlink: Hyperlink): boolean;
283
+ declare function getHyperlinkRuns(hyperlink: Hyperlink): Run[];
284
+ declare function resolveHyperlinkUrl(hyperlink: Hyperlink, rels: RelationshipMap): string | undefined;
285
+
286
+ /**
287
+ * Public XmlElement shape compatibility adapter.
288
+ *
289
+ * Rust S9 owns package drawing parsing. These small helpers remain because
290
+ * the published ./docx surface accepts xml-js elements directly.
291
+ */
292
+
293
+ declare function parseShape(node: Element): Shape;
294
+ declare function parseShapeFromDrawing(drawingEl: Element): Shape | null;
295
+ declare function isShapeDrawing(drawingEl: Element): boolean;
296
+ declare function isLineShape(shape: Shape): boolean;
297
+ declare function isTextBoxShape(shape: Shape): boolean;
298
+ declare function hasTextContent(shape: Shape): boolean;
299
+ declare function getShapeWidthPx(shape: Shape): number;
300
+ declare function getShapeHeightPx(shape: Shape): number;
301
+ declare function getShapeDimensionsPx(shape: Shape): {
302
+ width: number;
303
+ height: number;
304
+ };
305
+ declare function isFloatingShape(shape: Shape): boolean;
306
+ declare function hasFill(shape: Shape): boolean;
307
+ declare function hasOutline(shape: Shape): boolean;
308
+ declare function getOutlineWidthPx(shape: Shape): number;
309
+ declare function resolveFillColor(shape: Shape): string | undefined;
310
+ declare function resolveOutlineColor(shape: Shape): string | undefined;
311
+
312
+ /**
313
+ * Tab Parser - Parse and handle tab stops in DOCX documents
314
+ *
315
+ * Tab stops define positions where the cursor jumps when the user presses Tab.
316
+ * They can have different alignments (left, center, right, decimal) and
317
+ * leader characters (dots, dashes, underscores).
318
+ *
319
+ * OOXML Reference:
320
+ * - Tab stops container: w:tabs
321
+ * - Individual tab stop: w:tab
322
+ * - Tab character in runs: w:tab (different from tab stop definition)
323
+ *
324
+ * Attributes of w:tab in w:tabs:
325
+ * - w:val - alignment type (left, center, right, decimal, bar, clear, num)
326
+ * - w:pos - position in twips from left margin
327
+ * - w:leader - leader character (none, dot, hyphen, underscore, heavy, middleDot)
328
+ */
329
+
330
+ /**
331
+ * Default tab stop interval in twips (0.5 inches = 720 twips at 1440 twips/inch)
332
+ * Word uses this when no explicit tab stops are defined
333
+ */
334
+ declare const DEFAULT_TAB_INTERVAL_TWIPS = 720;
335
+ /**
336
+ * Default tab alignment
337
+ */
338
+ declare const DEFAULT_TAB_ALIGNMENT: TabStopAlignment;
339
+ /**
340
+ * Default tab leader
341
+ */
342
+ declare const DEFAULT_TAB_LEADER: TabLeader;
343
+ /**
344
+ * Parse a single tab stop element (w:tab within w:tabs)
345
+ *
346
+ * @param tab - The w:tab XML element
347
+ * @returns Parsed TabStop or null if invalid
348
+ */
349
+ declare function parseTabStop(tab: Element): TabStop | null;
350
+ /**
351
+ * Parse tab stops container (w:tabs)
352
+ *
353
+ * @param tabs - The w:tabs XML element
354
+ * @returns Array of TabStop objects, sorted by position
355
+ */
356
+ declare function parseTabStops(tabs: Element | null): TabStop[];
357
+ /**
358
+ * Parse tab stops from paragraph properties element
359
+ *
360
+ * @param pPr - The w:pPr XML element
361
+ * @returns Array of TabStop objects or undefined if none
362
+ */
363
+ declare function parseTabStopsFromParagraphProperties(pPr: Element | null): TabStop[] | undefined;
364
+ /**
365
+ * Merge tab stops from different sources (style, direct formatting)
366
+ *
367
+ * Direct formatting tab stops override style tab stops at the same position.
368
+ * "clear" alignment removes a tab stop from the style.
369
+ *
370
+ * @param styleTabs - Tab stops from style
371
+ * @param directTabs - Tab stops from direct formatting (w:pPr in paragraph)
372
+ * @returns Merged and filtered tab stops
373
+ */
374
+ declare function mergeTabStops(styleTabs: TabStop[] | undefined, directTabs: TabStop[] | undefined): TabStop[];
375
+ /**
376
+ * Get the next tab stop position for a given current position
377
+ *
378
+ * @param currentPosition - Current position in twips from left margin
379
+ * @param tabStops - Defined tab stops
380
+ * @param pageWidth - Page content width in twips (for boundary)
381
+ * @returns The next tab stop or a default position
382
+ */
383
+ declare function getNextTabStop(currentPosition: number, tabStops: TabStop[], pageWidth: number): TabStop;
384
+ /**
385
+ * Calculate the width needed for a tab at a given position
386
+ *
387
+ * @param currentPosition - Current position in twips
388
+ * @param tabStops - Defined tab stops
389
+ * @param pageWidth - Page content width in twips
390
+ * @returns Width in twips that the tab should span
391
+ */
392
+ declare function calculateTabWidth(currentPosition: number, tabStops: TabStop[], pageWidth: number): number;
393
+ /**
394
+ * Calculate tab width considering alignment
395
+ *
396
+ * For non-left alignments (center, right, decimal), the width depends on
397
+ * the content that follows the tab.
398
+ *
399
+ * @param currentPosition - Current position in twips
400
+ * @param tabStops - Defined tab stops
401
+ * @param pageWidth - Page content width in twips
402
+ * @param followingContentWidth - Width of content after the tab (for alignment)
403
+ * @returns Width in twips
404
+ */
405
+ declare function calculateTabWidthWithAlignment(currentPosition: number, tabStops: TabStop[], pageWidth: number, followingContentWidth?: number): {
406
+ width: number;
407
+ alignment: TabStopAlignment;
408
+ };
409
+ /**
410
+ * Get the character used for a tab leader
411
+ *
412
+ * @param leader - Tab leader type
413
+ * @returns The character to use for filling
414
+ */
415
+ declare function getLeaderCharacter(leader: TabLeader | undefined): string;
416
+ /**
417
+ * Check if a leader type requires visible filling
418
+ *
419
+ * @param leader - Tab leader type
420
+ * @returns true if the leader needs visible characters
421
+ */
422
+ declare function hasVisibleLeader(leader: TabLeader | undefined): boolean;
423
+
424
+ /**
425
+ * Shared border parsing for every `CT_Border` field — table borders
426
+ * (`w:tblBorders`/`w:tcBorders`), paragraph borders (`w:pBdr`), and page borders
427
+ * (`w:pgBorders`). Mirrors {@link ../serializer/borderSerializer} on the parse
428
+ * side: the table/paragraph/section/style parsers all delegate here so a border
429
+ * is read identically everywhere (one place to fix, one place to harden).
430
+ */
431
+
432
+ /**
433
+ * Parse a single border element (`<w:top>`, `<w:left>`, ...) into a
434
+ * {@link BorderSpec}.
435
+ *
436
+ * A missing `w:val` defaults to `none` (the attribute is required by the schema,
437
+ * so this only guards malformed input) and `w:color="auto"` maps to
438
+ * `{ auto: true }` via {@link parseColorValue} rather than being stored as a
439
+ * literal `rgb`. Returns `undefined` only when the element itself is absent.
440
+ */
441
+ declare function parseBorderSpec(element: Element | null): BorderSpec | undefined;
442
+
443
+ /**
444
+ * Table Atom-level Property Parsers
445
+ *
446
+ * Parsers for the small, leaf-style table property elements:
447
+ * - measurements (w:tblW, w:tcW, w:trHeight twip values + width type)
448
+ * - borders (w:tblBorders, w:tcBorders, individual side specs)
449
+ * - cell margins (w:tblCellMar, w:tcMar)
450
+ * - shading (w:shd background + theme tint/shade)
451
+ * - table look flags (w:tblLook firstRow/lastRow/etc.)
452
+ * - floating table positioning (w:tblpPr anchors + offsets)
453
+ *
454
+ * These are leaf parsers — they don't recurse into rows/cells. The composite
455
+ * row/cell/table parsers (in `../tableParser.ts`) compose these.
456
+ */
457
+
458
+ /**
459
+ * Parse a table measurement (width, height, etc.)
460
+ *
461
+ * @param element - Element with w:w and w:type attributes
462
+ * @returns Parsed measurement or undefined
463
+ */
464
+ declare function parseTableMeasurement(element: Element | null): TableMeasurement | undefined;
465
+ /** Parse physical, logical, inside, and diagonal table/cell border sides. */
466
+ declare function parseTableBorders(element: Element | null): TableBorders | undefined;
467
+ /**
468
+ * Parse cell margins (w:tblCellMar or w:tcMar)
469
+ *
470
+ * @param marginsElement - The margins container element
471
+ * @returns Parsed margins or undefined
472
+ */
473
+ declare function parseCellMargins(marginsElement: Element | null): CellMargins | undefined;
474
+ /**
475
+ * Parse shading properties (w:shd)
476
+ *
477
+ * @param shdElement - The w:shd element
478
+ * @returns Parsed shading or undefined
479
+ */
480
+ declare function parseShading(shdElement: Element | null): ShadingProperties | undefined;
481
+ /**
482
+ * Parse table look flags (w:tblLook)
483
+ *
484
+ * @param lookElement - The w:tblLook element
485
+ * @returns Parsed table look or undefined
486
+ */
487
+ declare function parseTableLook(lookElement: Element | null): TableLook | undefined;
488
+ /**
489
+ * Parse floating table properties (w:tblpPr)
490
+ *
491
+ * @param tblpPrElement - The w:tblpPr element
492
+ * @returns Parsed floating properties or undefined
493
+ */
494
+ declare function parseFloatingTableProperties(tblpPrElement: Element | null): FloatingTableProperties | undefined;
495
+
496
+ /**
497
+ * Table Query Helpers
498
+ *
499
+ * Read-only utilities for inspecting a parsed Table model — column/row
500
+ * counts, cell merge state, plain-text extraction, header detection,
501
+ * floating-table detection. No XML access; these operate on the parsed
502
+ * `Table` shape.
503
+ */
504
+
505
+ /**
506
+ * Get the number of columns in a table
507
+ *
508
+ * Uses the table grid if available, otherwise counts cells in first row.
509
+ *
510
+ * @param table - The table to measure
511
+ * @returns Number of columns
512
+ */
513
+ declare function getTableColumnCount(table: Table): number;
514
+ /**
515
+ * Get the number of rows in a table
516
+ *
517
+ * @param table - The table to measure
518
+ * @returns Number of rows
519
+ */
520
+ declare function getTableRowCount(table: Table): number;
521
+ /**
522
+ * Check if a cell is part of a vertical merge
523
+ *
524
+ * @param cell - The cell to check
525
+ * @returns true if cell continues a vertical merge
526
+ */
527
+ declare function isCellMergeContinuation(cell: TableCell): boolean;
528
+ /**
529
+ * Check if a cell starts a vertical merge
530
+ *
531
+ * @param cell - The cell to check
532
+ * @returns true if cell starts a vertical merge
533
+ */
534
+ declare function isCellMergeStart(cell: TableCell): boolean;
535
+ /**
536
+ * Check if table has header row
537
+ *
538
+ * @param table - The table to check
539
+ * @returns true if first row is marked as header
540
+ */
541
+ declare function hasHeaderRow(table: Table): boolean;
542
+
543
+ /** Public table property/query compatibility helpers; Rust owns table stories. */
544
+
545
+ declare function parseTableProperties(element: Element | null): TableFormatting | undefined;
546
+
547
+ /** Public XmlElement text-box compatibility adapter and pure model helpers. */
548
+
549
+ declare function extractTextBoxContentElements(txbxContent: Element | null): {
550
+ paragraphElements: Element[];
551
+ tableElements: Element[];
552
+ };
553
+ type ParagraphParserFn = (node: Element, styles: StyleMap | null, theme: Theme | null, numbering: NumberingMap | null, rels?: RelationshipMap | null) => Paragraph;
554
+ type TableParserFn = (node: Element, styles: StyleMap | null, theme: Theme | null, numbering: NumberingMap | null, rels?: RelationshipMap | null, media?: Map<string, MediaFile>) => Table;
555
+ declare function parseTextBoxContent(txbxContent: Element | null, parseParagraph: ParagraphParserFn, parseTable: TableParserFn | null, styles: StyleMap | null, theme: Theme | null, numbering: NumberingMap | null, rels?: RelationshipMap | null, _media?: Map<string, MediaFile>): Paragraph[];
556
+ declare function isTextBoxDrawing(drawingEl: Element): boolean;
557
+ declare function isShapeTextBox(wsp: Element): boolean;
558
+ declare function parseTextBox(drawingEl: Element): TextBox | null;
559
+ declare function getTextBoxContentElement(wsp: Element): Element | null;
560
+ declare function parseTextBoxFromShape(wsp: Element, size: ImageSize, position?: ImagePosition, wrap?: ImageWrap): TextBox | null;
561
+ declare function getTextBoxWidthPx(textBox: TextBox): number;
562
+ declare function getTextBoxHeightPx(textBox: TextBox): number;
563
+ declare function getTextBoxDimensionsPx(textBox: TextBox): {
564
+ width: number;
565
+ height: number;
566
+ };
567
+ declare function getTextBoxMarginsPx(textBox: TextBox): {
568
+ top: number;
569
+ bottom: number;
570
+ left: number;
571
+ right: number;
572
+ };
573
+ declare function isFloatingTextBox(textBox: TextBox): boolean;
574
+ declare function hasTextBoxFill(textBox: TextBox): boolean;
575
+ declare function hasTextBoxOutline(textBox: TextBox): boolean;
576
+ declare function hasTextBoxContent(textBox: TextBox): boolean;
577
+ declare function getTextBoxText(textBox: TextBox): string;
578
+ declare function resolveTextBoxFillColor(textBox: TextBox): string | undefined;
579
+ declare function resolveTextBoxOutlineColor(textBox: TextBox): string | undefined;
580
+ declare function getTextBoxOutlineWidthPx(textBox: TextBox): number;
581
+
582
+ /**
583
+ * Reply-range marker injection for serialization.
584
+ *
585
+ * Word / Pages / LibreOffice expect every comment in `comments.xml`
586
+ * (including REPLY threads) to have matching `commentRangeStart` /
587
+ * `commentRangeEnd` / `commentReference` markers in `document.xml`.
588
+ * The PM document only stamps marks for the parent comment because
589
+ * replies don't have their own visible range — they share the parent
590
+ * thread's text. So before serialization we walk the body content and
591
+ * synthesize parallel range markers for every reply.
592
+ *
593
+ * Two helpers, one per parent shape:
594
+ * - `injectReplyRangeMarkers` — replies whose parent is another
595
+ * comment (regular threaded discussion). Finds the parent's
596
+ * `commentRangeStart`/`End` and adds parallel markers next to them.
597
+ * - `injectTCReplyRangeMarkers` — replies whose parent is a tracked
598
+ * change (insertion/deletion). Wraps the TC content with
599
+ * commentRange markers.
600
+ *
601
+ * Pre-#... this code lived inside React's DocxEditor.tsx; Vue had no
602
+ * equivalent and so silently lost reply markers when saving collab
603
+ * documents. Living in core means both adapters get it for free.
604
+ */
605
+
606
+ /**
607
+ * Inject `commentRangeStart`/`commentRangeEnd` for reply comments
608
+ * that share their parent comment's text range.
609
+ */
610
+ declare function injectReplyRangeMarkers(content: BlockContent[], comments: Comment[]): void;
611
+ /**
612
+ * Inject `commentRangeStart`/`commentRangeEnd` for comments whose
613
+ * parent is a tracked-change revision (insertion/deletion). The TC
614
+ * content nodes don't carry the comment's range, so we wrap them.
615
+ */
616
+ declare function injectTCReplyRangeMarkers(content: BlockContent[], comments: Comment[]): void;
617
+
618
+ export { type AnchorWrapType, type ComplexFieldContext, type ComplexFieldState, DEFAULT_TAB_ALIGNMENT, DEFAULT_TAB_INTERVAL_TWIPS, DEFAULT_TAB_LEADER, type EndnoteMap, type FieldSwitch, type FootnoteMap, IMAGE_LAYOUT_OPTIONS, type ImageLayoutAttrs, type ImageLayoutCurrentAttrs, type ImageLayoutIconHint, type ImageLayoutOptionDef, type ImageLayoutPosition, type ImageLayoutTarget, type ImageResizeHandle, KNOWN_FIELD_TYPES, type NumberingMap, type ParagraphParserFn, type ParsedFieldInstruction, type SetImageWrapTypeOptions, type TableParserFn, calculateResizedImageDimensions, calculateTabWidth, calculateTabWidthWithAlignment, computeListRendering, createComplexFieldContext, createNumberingMap, deriveLayoutChoice, extractTextBoxContentElements, formatNumber, getBulletCharacter, getCachedNumberingMap, getEndnoteText, getFieldDisplayValue, getFootnoteText, getFormatSwitch, getHyperlinkRuns, getHyperlinkText, getHyperlinkUrl, getImageHeightPx, getImageWidthPx, getLeaderCharacter, getNextTabStop, getOutlineWidthPx, getShapeDimensionsPx, getShapeHeightPx, getShapeWidthPx, getTableColumnCount, getTableRowCount, getTextBoxContentElement, getTextBoxDimensionsPx, getTextBoxHeightPx, getTextBoxMarginsPx, getTextBoxOutlineWidthPx, getTextBoxText, getTextBoxWidthPx, getWrapDistancesPx, hasContent, hasFill, hasHeaderRow, hasMergeFormat, hasOutline, hasTextBoxContent, hasTextBoxFill, hasTextBoxOutline, hasTextContent, hasVisibleLeader, injectReplyRangeMarkers, injectTCReplyRangeMarkers, isBehindText, isBulletLevel, isCellMergeContinuation, isCellMergeStart, isDateTimeField, isDecorativeImage, isDocPropertyField, isExternalLink, isFloatingImage, isFloatingShape, isFloatingTextBox, isImageLayoutOptionEnabled, isInFrontOfText, isInlineImage, isInternalLink, isKnownFieldType, isLineShape, isMergeField, isPageNumberField, isReferenceField, isSeparatorEndnote, isSeparatorFootnote, isShapeDrawing, isShapeTextBox, isTextBoxDrawing, isTextBoxShape, isTocField, isTotalPagesField, mergeTabStops, parseBorderSpec, parseCellMargins, parseDrawing, parseEndnoteProperties, parseEndnotes, parseFieldInstruction, parseFieldType, parseFloatingTableProperties, parseFontTable, parseFootnoteProperties, parseFootnotes, parseHyperlink, parseImage, parseNumbering, parseShading, parseShape, parseShapeFromDrawing, parseSimpleField, parseTabStop, parseTabStops, parseTabStopsFromParagraphProperties, parseTableBorders, parseTableLook, parseTableMeasurement, parseTableProperties, parseTextBox, parseTextBoxContent, parseTextBoxFromShape, renderListMarker, resolveFillColor, resolveHyperlinkUrl, resolveImageLayoutAttrs, resolveOutlineColor, resolveTextBoxFillColor, resolveTextBoxOutlineColor, toolbarValueToLayoutTarget };