@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,956 @@
1
+ export { TWIPS_PER_INCH, clamp, eighthsToPixels, emuToTwips, formatPx, halfPointsToPixels, halfPointsToPoints, pixelsToTwips, pointsToHalfPoints, roundPixels, twipsToEmu, twipsToPixels } from './units.mjs';
2
+ export { C as CreateEmptyDocumentOptions, P as ProcessTemplateOptions, a as ProcessTemplateResult, T as TemplateError, c as colorsEqual, b as createDocumentWithText, d as createEmptyDocument, e as createRgbColor, f as createTemplateProcessor, g as createThemeColor, t as ensureHexPrefix, h as getMissingVariables, i as getTemplateTags, j as isBlack, k as isWhite, p as parseColorString, l as previewTemplate, m as processTemplate, n as processTemplateAdvanced, w as processTemplateAndDownload, o as processTemplateAsBlob, q as processTemplateDetailed, r as resolveHighlightColor, u as resolveHighlightToCss, s as resolveShadingColor, v as validateTemplate } from '../colorResolver-n0o7H7ep.mjs';
3
+ import { a as Theme, B as BorderSpec, P as ParagraphFormatting, S as ShadingProperties, T as TextFormatting } from '../formatting-DoL7KBSL.mjs';
4
+ export { G as ThemeMatrixCell, b as blendColors, d as darkenColor, H as generateThemeTintShadeMatrix, g as getContrastingColor, I as getThemeTintShadeHex, l as lightenColor, r as resolveColor, J as resolveColorToHex } from '../formatting-DoL7KBSL.mjs';
5
+ import { R as Run, P as Paragraph, C as Comment } from '../content-sSHuWw49.mjs';
6
+ export { D as DocxInput, t as toArrayBuffer } from '../docxInput-DTbCa48g.mjs';
7
+ export { F as FONT_MAPPING, B as FontDefinition, I as InsertPosition, c as canRenderFont, a as countPageBreaks, b as createColumnBreak, d as createHorizontalRule, e as createLineBreak, f as createPageBreak, g as createPageBreakParagraph, h as createPageBreakRun, C as extractFontsFromDocument, i as findPageBreaks, D as getGoogleFontEquivalent, j as getLoadedFonts, k as hasPageBreakBefore, l as insertHorizontalRule, m as insertPageBreak, n as isBreakContent, o as isColumnBreak, p as isFontLoaded, r as isGoogleFontsEnabled, s as isLineBreak, q as isLoading, t as isPageBreak, E as loadDocumentFonts, u as loadFont, G as loadFontDefinitions, v as loadFontFromBuffer, H as loadFontFromUrl, J as loadFontWithMapping, w as loadFonts, K as loadFontsWithMapping, L as onFontError, x as onFontsLoaded, y as preloadCommonFonts, z as removePageBreak, A as setGoogleFontsEnabled } from '../fontLoader-Bx6DK6-2.mjs';
8
+ import { F as FontTable } from '../styles-VxNcXLdi.mjs';
9
+ import { Document } from '../types/document.mjs';
10
+ import { FontOption } from './fontOptions.mjs';
11
+ export { HeadingInfo, collectHeadings } from './headingCollector.mjs';
12
+ export { WordSelectionResult, createDoubleClickWordSelector, createTripleClickParagraphSelector, expandSelectionToWordBoundaries, findWordAt, findWordBoundaries, getWordAt, handleClickForMultiClick, selectParagraphAtCursor, selectWordAtCursor, selectWordInTextNode } from './textSelection.mjs';
13
+ export { MIN_CARD_GAP, SIDEBAR_DOCUMENT_SHIFT, SIDEBAR_PAGE_GAP, SIDEBAR_WIDTH } from './sidebarConstants.mjs';
14
+ export { P as PIXELS_PER_INCH, e as emuToPixels, p as pixelsToEmu, a as pointsToPixels } from '../units-O5Y02RKQ.mjs';
15
+ import '../docx/wrapTypes.mjs';
16
+ import '../settingsParser-CcGvtmCK.mjs';
17
+ import '../editorTree-DO5PyDK8.mjs';
18
+
19
+ /**
20
+ * Clipboard utilities for copy/paste with formatting
21
+ *
22
+ * Handles:
23
+ * - Copy: puts formatted HTML and plain text on clipboard
24
+ * - Paste: reads HTML clipboard, converts to runs with formatting
25
+ * - Handles paste from Word (cleans up Word HTML)
26
+ * - Ctrl+C, Ctrl+V, Ctrl+X keyboard shortcuts
27
+ */
28
+
29
+ /**
30
+ * Clipboard content format
31
+ */
32
+ interface ClipboardContent {
33
+ /** Plain text representation */
34
+ plainText: string;
35
+ /** HTML representation */
36
+ html: string;
37
+ /** Internal format (JSON) for preserving full formatting */
38
+ internal?: string;
39
+ }
40
+ /**
41
+ * Parsed clipboard content
42
+ */
43
+ interface ParsedClipboardContent {
44
+ /** Runs parsed from clipboard */
45
+ runs: Run[];
46
+ /** Whether content came from Word */
47
+ fromWord: boolean;
48
+ /** Whether content came from our editor */
49
+ fromEditor: boolean;
50
+ /** Original plain text */
51
+ plainText: string;
52
+ }
53
+ /**
54
+ * Options for clipboard operations
55
+ */
56
+ interface ClipboardOptions {
57
+ /** Whether to include formatting in copy */
58
+ includeFormatting?: boolean;
59
+ /** Whether to clean Word-specific formatting */
60
+ cleanWordFormatting?: boolean;
61
+ /** Callback for handling errors */
62
+ onError?: (error: Error) => void;
63
+ /** Document theme — required to resolve themed text/shading colors in HTML. */
64
+ theme?: Theme | null;
65
+ }
66
+ /**
67
+ * Custom MIME type for internal clipboard format
68
+ */
69
+ declare const INTERNAL_CLIPBOARD_TYPE = "application/x-docx-editor";
70
+ /**
71
+ * Standard clipboard MIME types
72
+ */
73
+ declare const CLIPBOARD_TYPES: {
74
+ readonly HTML: "text/html";
75
+ readonly PLAIN: "text/plain";
76
+ };
77
+ /**
78
+ * Extract image files from clipboard data (if present).
79
+ */
80
+ declare function getClipboardImageFiles(clipboardData: DataTransfer | null): File[];
81
+ /**
82
+ * Copy runs to clipboard with formatting
83
+ */
84
+ declare function copyRuns(runs: Run[], options?: ClipboardOptions): Promise<boolean>;
85
+ /**
86
+ * Copy paragraphs to clipboard with formatting
87
+ */
88
+ declare function copyParagraphs(paragraphs: Paragraph[], options?: ClipboardOptions): Promise<boolean>;
89
+ /**
90
+ * Convert runs to clipboard content (HTML and plain text).
91
+ *
92
+ * @param theme - Optional document theme. Pass it so themed text color and
93
+ * shading resolve correctly in the HTML payload (matters when pasting into
94
+ * Gmail/Word/etc.). Omit for rgb-only content.
95
+ */
96
+ declare function runsToClipboardContent(runs: Run[], includeFormatting?: boolean, theme?: Theme | null): ClipboardContent;
97
+ /**
98
+ * Convert paragraphs to clipboard content.
99
+ *
100
+ * @param theme - See {@link runsToClipboardContent}.
101
+ */
102
+ declare function paragraphsToClipboardContent(paragraphs: Paragraph[], includeFormatting?: boolean, theme?: Theme | null): ClipboardContent;
103
+ /**
104
+ * Write content to clipboard
105
+ */
106
+ declare function writeToClipboard(content: ClipboardContent): Promise<boolean>;
107
+ /**
108
+ * Read content from clipboard
109
+ */
110
+ declare function readFromClipboard(options?: ClipboardOptions): Promise<ParsedClipboardContent | null>;
111
+ /**
112
+ * Handle paste event
113
+ */
114
+ declare function handlePasteEvent(event: ClipboardEvent, options?: ClipboardOptions): ParsedClipboardContent | null;
115
+ /**
116
+ * Parse HTML from clipboard
117
+ */
118
+ declare function parseClipboardHtml(html: string, plainText: string, cleanWordFormatting?: boolean): ParsedClipboardContent;
119
+ /**
120
+ * Check if HTML is from Microsoft Word
121
+ */
122
+ declare function isWordHtml(html: string): boolean;
123
+ /**
124
+ * Check if HTML is from our editor
125
+ */
126
+ declare function isEditorHtml(html: string): boolean;
127
+ /**
128
+ * Clean Microsoft Word HTML
129
+ */
130
+ declare function cleanWordHtml(html: string): string;
131
+ /**
132
+ * Convert HTML to runs
133
+ */
134
+ declare function htmlToRuns(html: string, plainTextFallback: string): Run[];
135
+ /**
136
+ * Create clipboard keyboard handlers for an editor
137
+ */
138
+ declare function createClipboardHandlers(options: {
139
+ onCopy?: () => {
140
+ runs: Run[];
141
+ } | null;
142
+ onCut?: () => {
143
+ runs: Run[];
144
+ } | null;
145
+ onPaste?: (content: ParsedClipboardContent) => void;
146
+ clipboardOptions?: ClipboardOptions;
147
+ }): {
148
+ handleCopy: (event: ClipboardEvent) => Promise<void>;
149
+ handleCut: (event: ClipboardEvent) => Promise<void>;
150
+ handlePaste: (event: ClipboardEvent) => void;
151
+ handleKeyDown: (event: KeyboardEvent) => Promise<void>;
152
+ };
153
+
154
+ /**
155
+ * Embedded font de-obfuscation (ECMA-376 Part 4 §2.8.1, "Font Embedding").
156
+ *
157
+ * Word stores embedded fonts as obfuscated OpenType (`.odttf`): the first 32
158
+ * bytes of the font binary are XOR-scrambled with a 16-byte key, the rest of
159
+ * the file is untouched. The key is the font's `w:fontKey` GUID with its byte
160
+ * order REVERSED, applied once to bytes 0-15 and again to bytes 16-31.
161
+ *
162
+ * Example (from the spec): GUID `001B70DC-AA60-4AD5-90EC-18A0948E1EAE` yields
163
+ * the key bytes `AE 1E 8E 94 A0 18 EC 90 D5 4A 60 AA DC 70 1B 00`.
164
+ *
165
+ * The scheme is a pure XOR, so the same operation obfuscates and de-obfuscates.
166
+ */
167
+ /**
168
+ * Whether a string is a usable embedded-font obfuscation key (a 128-bit GUID,
169
+ * with or without braces/hyphens).
170
+ *
171
+ * @public
172
+ */
173
+ declare function isValidFontKey(fontKey: string | undefined | null): boolean;
174
+ /**
175
+ * De-obfuscate an embedded `.odttf` font into a usable OpenType/TrueType
176
+ * binary by XOR-ing its first 32 bytes with the reversed `w:fontKey` GUID.
177
+ *
178
+ * Returns a new buffer; the input is not mutated. Throws if `fontKey` is not a
179
+ * valid 128-bit GUID.
180
+ *
181
+ * @param data - Raw obfuscated font bytes from `word/fonts/*.odttf`.
182
+ * @param fontKey - The `w:fontKey` GUID from the `w:embed*` element.
183
+ * @public
184
+ */
185
+ declare function deobfuscateFont(data: ArrayBuffer, fontKey: string): ArrayBuffer;
186
+
187
+ /**
188
+ * Embedded font loading.
189
+ *
190
+ * Turns the obfuscated `word/fonts/*.odttf` binaries a DOCX carries into live
191
+ * `@font-face` registrations so documents render in their authored fonts
192
+ * instead of falling back to a metric-compatible substitute.
193
+ *
194
+ * The pure half ({@link getEmbeddedFontFaces}) resolves + de-obfuscates the
195
+ * faces; {@link loadEmbeddedFonts} registers them with the browser (no-op
196
+ * outside a DOM). Round-trip preservation is unaffected: the serializer copies
197
+ * `word/fonts/*` and `fontTable.xml` from the original package untouched.
198
+ */
199
+
200
+ /**
201
+ * Names of the fonts a table embeds at least one face for. Used by the picker
202
+ * to surface embedded fonts even when the canvas probe is unreliable for a
203
+ * subsetted face.
204
+ *
205
+ * @public
206
+ */
207
+ declare function getEmbeddedFontFamilies(fontTable: FontTable | undefined): Set<string>;
208
+ /** A single de-obfuscated embedded font face, ready for `loadFontFromBuffer`. */
209
+ interface EmbeddedFontFace {
210
+ /** Word font name to register the face under. */
211
+ family: string;
212
+ /** CSS `font-weight` the face maps to (`embedBold*` → `'bold'`). */
213
+ weight: 'normal' | 'bold';
214
+ /** CSS `font-style` the face maps to (`embed*Italic` → `'italic'`). */
215
+ style: 'normal' | 'italic';
216
+ /** De-obfuscated OpenType/TrueType bytes. */
217
+ data: ArrayBuffer;
218
+ /** Whether the source face was subsetted (`w:subsetted`). */
219
+ subsetted: boolean;
220
+ }
221
+ /**
222
+ * Resolve and de-obfuscate every embedded font face declared in a font table.
223
+ * Pure: does not touch the DOM. Faces whose relationship or binary is missing,
224
+ * or whose key is unusable, are skipped.
225
+ *
226
+ * @param fontTable - Parsed `fontTable.xml` (`pkg.fontTable`).
227
+ * @param rawFonts - Unzipped font binaries keyed by package path.
228
+ * @param fontTableRelsXml - Raw `word/_rels/fontTable.xml.rels` XML.
229
+ * @public
230
+ */
231
+ declare function getEmbeddedFontFaces(fontTable: FontTable | undefined, rawFonts: ReadonlyMap<string, ArrayBuffer>, fontTableRelsXml: string | null | undefined): EmbeddedFontFace[];
232
+ /**
233
+ * Resolve + de-obfuscate the embedded faces of an already-parsed Document by
234
+ * re-reading its `originalBuffer` (parseDocx registers the faces with the
235
+ * browser during load but does not retain the raw bytes on the model).
236
+ * Returns `[]` when the document declares no embeds, carries no original
237
+ * buffer, or the parts cannot be resolved. The zip pass goes through the
238
+ * hardened `unzipDocx` container facade.
239
+ *
240
+ * Used by the experimental Rust measurement source, which needs the byte
241
+ * form of every embedded face for the wasm FontStore.
242
+ *
243
+ * @public
244
+ */
245
+ declare function extractEmbeddedFontFaces(document: Document): Promise<EmbeddedFontFace[]>;
246
+ /**
247
+ * Register every embedded font face with the browser via `@font-face`. No-op
248
+ * outside a DOM (headless/SSR). Resolves to the set of font family names that
249
+ * were registered (deduped), so callers can surface them in the font picker.
250
+ *
251
+ * @public
252
+ */
253
+ declare function loadEmbeddedFonts(fontTable: FontTable | undefined, rawFonts: ReadonlyMap<string, ArrayBuffer>, fontTableRelsXml: string | null | undefined): Promise<Set<string>>;
254
+
255
+ /**
256
+ * Discover the fonts a document actually references and that the browser can
257
+ * render, so they can be offered in the font picker under a "Document fonts"
258
+ * group. A font qualifies when it is embedded in the file (already loaded via
259
+ * {@link loadEmbeddedFonts}) or when the host system can render it
260
+ * ({@link canRenderFont}). Fonts that would only fall back to a substitute are
261
+ * left out, so the selector never lists a face it cannot actually show.
262
+ */
263
+
264
+ interface RenderableFontOptions {
265
+ /** Font families already loaded from the document (embedded faces). */
266
+ embeddedFamilies?: ReadonlySet<string>;
267
+ /** Names already present in the picker (built-in / configured) to skip. */
268
+ exclude?: Iterable<string>;
269
+ /** Override the system-font probe. Defaults to {@link canRenderFont}. */
270
+ canRender?: (name: string) => boolean;
271
+ }
272
+ /**
273
+ * Filter a list of referenced font names down to renderable {@link FontOption}s.
274
+ * Pure and DOM-free when `canRender` is injected.
275
+ *
276
+ * @public
277
+ */
278
+ declare function selectRenderableFonts(names: readonly string[], options?: RenderableFontOptions): FontOption[];
279
+ /**
280
+ * Walk a parsed document for the fonts it references and return those the
281
+ * browser can render (embedded or system-resolved) as picker options.
282
+ *
283
+ * @public
284
+ */
285
+ declare function getRenderableDocumentFonts(doc: Document, options?: RenderableFontOptions): FontOption[];
286
+ /**
287
+ * Drop fonts whose names already appear in `existingNames` (case-insensitive),
288
+ * also deduping the input. Used by both adapters' pickers to render the
289
+ * "Document fonts" group without repeating a font the built-in list covers.
290
+ *
291
+ * @public
292
+ */
293
+ declare function excludeFontsByName(fonts: readonly FontOption[] | undefined, existingNames: Iterable<string>): FontOption[];
294
+
295
+ /**
296
+ * Formatting to CSS Converter
297
+ *
298
+ * Converts OOXML formatting objects (TextFormatting, ParagraphFormatting)
299
+ * to React CSSProperties for rendering.
300
+ *
301
+ * Handles ALL formatting properties:
302
+ * - Font: family, size, weight, style
303
+ * - Text: color, background, decoration (underline, strike, double-strike)
304
+ * - Effects: superscript, subscript, small-caps, all-caps
305
+ * - Spacing: letter-spacing
306
+ * - Paragraph: alignment, line-height, margins, padding, borders, background
307
+ */
308
+ /** Framework-agnostic CSS properties type (compatible with React.CSSProperties) */
309
+ type CSSProperties$1 = Record<string, any>;
310
+
311
+ /**
312
+ * Convert TextFormatting to CSS properties for a run/span
313
+ *
314
+ * @param formatting - Text formatting from OOXML
315
+ * @param theme - Theme for resolving colors and fonts
316
+ * @returns React CSSProperties
317
+ */
318
+ declare function textToStyle(formatting: TextFormatting | undefined | null, theme?: Theme | null): CSSProperties$1;
319
+ /**
320
+ * Convert ParagraphFormatting to CSS properties
321
+ *
322
+ * @param formatting - Paragraph formatting from OOXML
323
+ * @param theme - Theme for resolving colors
324
+ * @returns React CSSProperties
325
+ */
326
+ declare function paragraphToStyle(formatting: ParagraphFormatting | undefined | null, theme?: Theme | null): CSSProperties$1;
327
+ /**
328
+ * Convert a BorderSpec to CSS border properties
329
+ *
330
+ * @param border - Border specification
331
+ * @param side - 'Top' | 'Bottom' | 'Left' | 'Right' | '' for all
332
+ * @param theme - Theme for color resolution
333
+ * @returns Partial CSSProperties with border styles
334
+ */
335
+ declare function borderToStyle(border: BorderSpec | undefined | null, side?: 'Top' | 'Bottom' | 'Left' | 'Right' | '', theme?: Theme | null): CSSProperties$1;
336
+ /**
337
+ * Convert ShadingProperties to background color
338
+ *
339
+ * @param shading - Shading properties
340
+ * @param theme - Theme for color resolution
341
+ * @returns CSS color string or empty string
342
+ */
343
+ declare function resolveShadingFill(shading: ShadingProperties | undefined | null, theme?: Theme | null): string;
344
+ /**
345
+ * Merge multiple CSSProperties objects
346
+ *
347
+ * Later objects override earlier ones for conflicting properties.
348
+ *
349
+ * @param styles - Array of CSSProperties objects
350
+ * @returns Merged CSSProperties
351
+ */
352
+ declare function mergeStyles(...styles: (CSSProperties$1 | undefined | null)[]): CSSProperties$1;
353
+ /**
354
+ * Get CSS for a table cell based on formatting
355
+ *
356
+ * @param formatting - Table cell formatting
357
+ * @param theme - Theme for color resolution
358
+ * @returns CSSProperties for the cell
359
+ */
360
+ declare function tableCellToStyle(formatting: {
361
+ verticalAlign?: 'top' | 'center' | 'bottom';
362
+ textDirection?: string;
363
+ shading?: ShadingProperties;
364
+ borders?: {
365
+ top?: BorderSpec;
366
+ bottom?: BorderSpec;
367
+ left?: BorderSpec;
368
+ right?: BorderSpec;
369
+ };
370
+ margins?: {
371
+ top?: {
372
+ value: number;
373
+ type: string;
374
+ };
375
+ bottom?: {
376
+ value: number;
377
+ type: string;
378
+ };
379
+ left?: {
380
+ value: number;
381
+ type: string;
382
+ };
383
+ right?: {
384
+ value: number;
385
+ type: string;
386
+ };
387
+ };
388
+ } | undefined | null, theme?: Theme | null): CSSProperties$1;
389
+ /**
390
+ * Get CSS for page/section container
391
+ *
392
+ * @param sectionProps - Section properties
393
+ * @returns CSSProperties for the page container
394
+ */
395
+ declare function sectionToStyle(sectionProps: {
396
+ pageWidth?: number;
397
+ pageHeight?: number;
398
+ marginTop?: number;
399
+ marginBottom?: number;
400
+ marginLeft?: number;
401
+ marginRight?: number;
402
+ background?: {
403
+ color?: {
404
+ rgb?: string;
405
+ themeColor?: string;
406
+ };
407
+ };
408
+ } | undefined | null, theme?: Theme | null): CSSProperties$1;
409
+
410
+ /**
411
+ * Keyboard Navigation Utilities
412
+ *
413
+ * Provides enhanced keyboard navigation for the editor:
414
+ * - Ctrl+Left/Right: Move by word
415
+ * - Home/End: Move to start/end of line
416
+ * - Ctrl+Home/End: Move to start/end of document
417
+ * - Ctrl+Shift+Left/Right: Select by word
418
+ * - Shift+Home/End: Select to start/end of line
419
+ */
420
+ /**
421
+ * Navigation direction
422
+ */
423
+ type NavigationDirection = 'left' | 'right' | 'up' | 'down';
424
+ /**
425
+ * Navigation unit
426
+ */
427
+ type NavigationUnit = 'character' | 'word' | 'line' | 'paragraph' | 'document';
428
+ /**
429
+ * Keyboard navigation action
430
+ */
431
+ interface NavigationAction {
432
+ /** Direction to navigate */
433
+ direction: NavigationDirection;
434
+ /** Unit of movement */
435
+ unit: NavigationUnit;
436
+ /** Whether to extend selection */
437
+ extend: boolean;
438
+ }
439
+ /**
440
+ * Keyboard shortcut definition
441
+ */
442
+ interface KeyboardShortcut {
443
+ key: string;
444
+ ctrlKey?: boolean;
445
+ metaKey?: boolean;
446
+ shiftKey?: boolean;
447
+ altKey?: boolean;
448
+ }
449
+ /**
450
+ * Check if a character is a word character (letter, digit, or underscore)
451
+ */
452
+ declare function isWordCharacter(char: string): boolean;
453
+ /**
454
+ * Check if a character is whitespace
455
+ */
456
+ declare function isWhitespace(char: string): boolean;
457
+ /**
458
+ * Check if a character is a punctuation character
459
+ */
460
+ declare function isPunctuation(char: string): boolean;
461
+ /**
462
+ * Find the start of the current or previous word
463
+ */
464
+ declare function findWordStart(text: string, position: number): number;
465
+ /**
466
+ * Find the end of the current or next word
467
+ */
468
+ declare function findWordEnd(text: string, position: number): number;
469
+ /**
470
+ * Find the next word start (for Ctrl+Right navigation)
471
+ */
472
+ declare function findNextWordStart(text: string, position: number): number;
473
+ /**
474
+ * Find the previous word start (for Ctrl+Left navigation)
475
+ */
476
+ declare function findPreviousWordStart(text: string, position: number): number;
477
+ /**
478
+ * Find the start of the current line in a text node
479
+ * Uses visual line detection based on bounding rectangles
480
+ */
481
+ declare function findVisualLineStart(container: Node, offset: number): {
482
+ node: Node;
483
+ offset: number;
484
+ } | null;
485
+ /**
486
+ * Find the end of the current line in a text node
487
+ * Uses visual line detection based on bounding rectangles
488
+ */
489
+ declare function findVisualLineEnd(container: Node, offset: number): {
490
+ node: Node;
491
+ offset: number;
492
+ } | null;
493
+ /**
494
+ * Get the current selection info
495
+ */
496
+ declare function getSelectionInfo(): {
497
+ node: Node;
498
+ offset: number;
499
+ anchorNode: Node | null;
500
+ anchorOffset: number;
501
+ focusNode: Node | null;
502
+ focusOffset: number;
503
+ isCollapsed: boolean;
504
+ text: string;
505
+ } | null;
506
+ /**
507
+ * Set the selection to a specific position
508
+ */
509
+ declare function setSelectionPosition(node: Node, offset: number): void;
510
+ /**
511
+ * Extend selection to a specific position
512
+ */
513
+ declare function extendSelectionTo(node: Node, offset: number): void;
514
+ /**
515
+ * Move selection by word in a text node
516
+ */
517
+ declare function moveByWord(direction: 'left' | 'right', extend?: boolean): boolean;
518
+ /**
519
+ * Move to start/end of line
520
+ */
521
+ declare function moveToLineEdge(edge: 'start' | 'end', extend?: boolean): boolean;
522
+ /**
523
+ * Parse a keyboard event into a navigation action
524
+ */
525
+ declare function parseNavigationAction(event: KeyboardEvent): NavigationAction | null;
526
+ /**
527
+ * Handle a keyboard navigation event
528
+ * Returns true if the event was handled
529
+ */
530
+ declare function handleNavigationKey(event: KeyboardEvent, options?: {
531
+ onDocumentStart?: () => void;
532
+ onDocumentEnd?: () => void;
533
+ }): boolean;
534
+ /**
535
+ * Check if an event is a navigation key event
536
+ */
537
+ declare function isNavigationKey(event: KeyboardEvent): boolean;
538
+ /**
539
+ * Expand selection to word boundaries
540
+ * Used for double-click word selection
541
+ */
542
+ declare function expandSelectionToWord(): boolean;
543
+ /**
544
+ * Get the word at the current cursor position
545
+ */
546
+ declare function getWordAtCursor(): string | null;
547
+ /**
548
+ * Check if a keyboard event matches a shortcut definition
549
+ */
550
+ declare function matchesShortcut(event: KeyboardEvent, shortcut: KeyboardShortcut): boolean;
551
+ /**
552
+ * Common navigation shortcuts
553
+ */
554
+ declare const NAVIGATION_SHORTCUTS: {
555
+ readonly wordLeft: KeyboardShortcut;
556
+ readonly wordRight: KeyboardShortcut;
557
+ readonly selectWordLeft: KeyboardShortcut;
558
+ readonly selectWordRight: KeyboardShortcut;
559
+ readonly lineStart: KeyboardShortcut;
560
+ readonly lineEnd: KeyboardShortcut;
561
+ readonly selectToLineStart: KeyboardShortcut;
562
+ readonly selectToLineEnd: KeyboardShortcut;
563
+ readonly documentStart: KeyboardShortcut;
564
+ readonly documentEnd: KeyboardShortcut;
565
+ readonly selectToDocumentStart: KeyboardShortcut;
566
+ readonly selectToDocumentEnd: KeyboardShortcut;
567
+ };
568
+ /**
569
+ * Get a human-readable description of a shortcut
570
+ */
571
+ declare function describeShortcut(shortcut: KeyboardShortcut): string;
572
+ /**
573
+ * Get all navigation shortcuts with descriptions
574
+ */
575
+ declare function getNavigationShortcutDescriptions(): Array<{
576
+ action: string;
577
+ shortcut: string;
578
+ }>;
579
+
580
+ /**
581
+ * Selection Highlight Utilities
582
+ *
583
+ * Provides visual highlighting for text selection across multiple runs.
584
+ * Browsers handle ::selection pseudo-element differently, especially when
585
+ * selection spans multiple elements with different backgrounds or styling.
586
+ *
587
+ * This module provides:
588
+ * - Custom selection highlight rendering
589
+ * - Programmatic selection range marking
590
+ * - Visual feedback for selection across runs
591
+ */
592
+ /** Framework-agnostic CSS properties type (compatible with React.CSSProperties) */
593
+ type CSSProperties = Record<string, any>;
594
+ /**
595
+ * Highlight rectangle representing a selected region
596
+ */
597
+ interface HighlightRect {
598
+ /** Left position in pixels */
599
+ left: number;
600
+ /** Top position in pixels */
601
+ top: number;
602
+ /** Width in pixels */
603
+ width: number;
604
+ /** Height in pixels */
605
+ height: number;
606
+ }
607
+ /**
608
+ * Selection highlight configuration
609
+ */
610
+ interface SelectionHighlightConfig {
611
+ /** Background color for selection */
612
+ backgroundColor: string;
613
+ /** Optional border color for selection */
614
+ borderColor?: string;
615
+ /** Optional border radius */
616
+ borderRadius?: number;
617
+ /** Z-index for overlay */
618
+ zIndex?: number;
619
+ /** Opacity for highlight */
620
+ opacity?: number;
621
+ /** Mix blend mode */
622
+ mixBlendMode?: CSSProperties['mixBlendMode'];
623
+ }
624
+ /**
625
+ * Selection range in document coordinates
626
+ */
627
+ interface SelectionRange {
628
+ /** Start position */
629
+ start: {
630
+ paragraphIndex: number;
631
+ contentIndex: number;
632
+ offset: number;
633
+ };
634
+ /** End position */
635
+ end: {
636
+ paragraphIndex: number;
637
+ contentIndex: number;
638
+ offset: number;
639
+ };
640
+ }
641
+ /**
642
+ * Default selection highlight style (matches Word/Google Docs)
643
+ */
644
+ declare const DEFAULT_SELECTION_STYLE: SelectionHighlightConfig;
645
+ /**
646
+ * High contrast selection style
647
+ */
648
+ declare const HIGH_CONTRAST_SELECTION_STYLE: SelectionHighlightConfig;
649
+ /**
650
+ * Selection highlight CSS custom properties
651
+ */
652
+ declare const SELECTION_CSS_VARS: {
653
+ readonly backgroundColor: "--docx-selection-bg";
654
+ readonly borderColor: "--docx-selection-border";
655
+ readonly textColor: "--docx-selection-text";
656
+ };
657
+ /**
658
+ * Get all selection rectangles from the current DOM selection
659
+ *
660
+ * Uses getClientRects() to get accurate rectangles even when
661
+ * selection spans multiple inline elements.
662
+ */
663
+ declare function getSelectionRects(containerElement?: HTMLElement | null): HighlightRect[];
664
+ /**
665
+ * Merge adjacent or overlapping rectangles
666
+ *
667
+ * This reduces the number of highlight elements needed and creates
668
+ * a cleaner visual appearance.
669
+ */
670
+ declare function mergeAdjacentRects(rects: HighlightRect[], tolerance?: number): HighlightRect[];
671
+ /**
672
+ * Get selection rectangles with merging applied
673
+ */
674
+ declare function getMergedSelectionRects(containerElement?: HTMLElement | null): HighlightRect[];
675
+ /**
676
+ * Generate CSS styles for a highlight rectangle
677
+ */
678
+ declare function getHighlightRectStyle(rect: HighlightRect, config?: SelectionHighlightConfig): CSSProperties;
679
+ /**
680
+ * Generate inline CSS for selection pseudo-elements
681
+ *
682
+ * This is used to inject consistent selection styling
683
+ * across all editable elements.
684
+ */
685
+ declare function generateSelectionCSS(selector: string, config?: SelectionHighlightConfig): string;
686
+ /**
687
+ * Check if there is an active text selection (not collapsed)
688
+ */
689
+ declare function hasActiveSelection(): boolean;
690
+ /**
691
+ * Get the selected text
692
+ */
693
+ declare function getSelectedText(): string;
694
+ /**
695
+ * Check if selection is within a specific element
696
+ */
697
+ declare function isSelectionWithin(element: HTMLElement): boolean;
698
+ /**
699
+ * Get the bounding rect of the current selection
700
+ */
701
+ declare function getSelectionBoundingRect(): DOMRect | null;
702
+ /**
703
+ * Create a selection highlight for a specific text range
704
+ *
705
+ * This is useful for find/replace highlighting, AI action previews, etc.
706
+ */
707
+ declare function highlightTextRange(_containerElement: HTMLElement, startNode: Node, startOffset: number, endNode: Node, endOffset: number): Range | null;
708
+ /**
709
+ * Select a text range programmatically
710
+ */
711
+ declare function selectRange(range: Range): void;
712
+ /**
713
+ * Clear the current selection
714
+ */
715
+ declare function clearSelection(): void;
716
+ /**
717
+ * Check if selection is backwards (focus before anchor)
718
+ */
719
+ declare function isSelectionBackwards(): boolean;
720
+ /**
721
+ * Normalize selection to always be forward (start before end)
722
+ */
723
+ declare function normalizeSelectionDirection(): void;
724
+ /**
725
+ * Inject selection highlight CSS into document
726
+ */
727
+ declare function injectSelectionStyles(config?: SelectionHighlightConfig): void;
728
+ /**
729
+ * Remove injected selection styles
730
+ */
731
+ declare function removeSelectionStyles(): void;
732
+ /**
733
+ * Check if selection styles are injected
734
+ */
735
+ declare function areSelectionStylesInjected(): boolean;
736
+ /**
737
+ * Create a selection change handler that updates highlight rects
738
+ */
739
+ declare function createSelectionChangeHandler(containerElement: HTMLElement | null, onRectsChange: (rects: HighlightRect[]) => void, merge?: boolean): () => void;
740
+
741
+ /**
742
+ * Option shapes for `scrollToParaId(paraId, { highlight })`.
743
+ *
744
+ * Kept in a DOM-free module (no imports, no browser globals) so non-browser
745
+ * consumers can type-import them without pulling `paragraphFlash`'s DOM code
746
+ * into their type-check surface.
747
+ */
748
+ /**
749
+ * Customization for the transient paragraph flash applied by
750
+ * `scrollToParaId(paraId, { highlight })`.
751
+ *
752
+ * @public
753
+ */
754
+ interface ParagraphHighlightOptions {
755
+ /** CSS color used for the transient paragraph flash. Defaults to yellow. */
756
+ color?: string;
757
+ /** How long the flash remains visible before it is removed. Defaults to 1200ms. */
758
+ durationMs?: number;
759
+ }
760
+ /**
761
+ * Optional reveal behavior for `scrollToParaId`.
762
+ *
763
+ * @public
764
+ */
765
+ interface ScrollToParaIdOptions {
766
+ /** Flash rendered paragraph fragments after scrolling to the paragraph. */
767
+ highlight?: ParagraphHighlightOptions;
768
+ }
769
+
770
+ /**
771
+ * DOM helpers for transient paragraph flashes on the painted layout surface.
772
+ */
773
+
774
+ /** Default color used by paragraph flashes. */
775
+ declare const DEFAULT_PARAGRAPH_FLASH_COLOR = "rgba(255, 235, 59, 0.55)";
776
+ /** Default duration for paragraph flashes. */
777
+ declare const DEFAULT_PARAGRAPH_FLASH_DURATION_MS = 1200;
778
+ /** CSS class applied to paragraph fragments during a transient flash. */
779
+ declare const PARAGRAPH_FLASH_CLASS_NAME = "docx-paragraph-flash";
780
+ /**
781
+ * Find all painted paragraph fragments with a stable `data-para-id`.
782
+ *
783
+ * @public
784
+ */
785
+ declare function findParagraphFragmentsByParaId(root: ParentNode, paraId: string): HTMLElement[];
786
+ /**
787
+ * Apply a transient flash to a collection of paragraph elements.
788
+ *
789
+ * @returns the number of elements flashed
790
+ * @public
791
+ */
792
+ declare function flashParagraphElements(elements: Iterable<HTMLElement>, options?: ParagraphHighlightOptions): number;
793
+ /**
794
+ * Find paragraph fragments by `paraId` and flash them.
795
+ *
796
+ * @returns whether at least one rendered fragment was found
797
+ * @public
798
+ */
799
+ declare function flashParagraphFragmentsByParaId(root: ParentNode, paraId: string, options?: ParagraphHighlightOptions): boolean;
800
+
801
+ /**
802
+ * Shared table split algorithm — model-agnostic core logic.
803
+ *
804
+ * This module contains the pure layout computation for splitting a table cell:
805
+ * column width redistribution, neighbor span adjustment, and new-cell placement.
806
+ * Both the ProseMirror path (tableSplit.ts) and the Document-model path
807
+ * (TableToolbar.tsx) delegate to these functions.
808
+ */
809
+ /** A cell's position and span within the logical grid. */
810
+ interface CellAnchor<T> {
811
+ /** Opaque payload — the caller's cell type (PMNode, TableCell, etc.) */
812
+ data: T;
813
+ row: number;
814
+ col: number;
815
+ rowspan: number;
816
+ colspan: number;
817
+ }
818
+ /** Parameters describing the split target. */
819
+ interface SplitTarget {
820
+ row: number;
821
+ col: number;
822
+ rowspan: number;
823
+ colspan: number;
824
+ }
825
+ /** Result of `computeSplitLayout`. */
826
+ interface SplitLayoutResult<T> {
827
+ /** All anchors after the split (neighbors adjusted + new split cells). */
828
+ anchors: CellAnchor<T>[];
829
+ deltaRows: number;
830
+ deltaCols: number;
831
+ newRowCount: number;
832
+ }
833
+ declare function sumColumnWidths(widths: number[], start: number, span: number): number;
834
+ /**
835
+ * Redistribute column widths when splitting a cell's column span.
836
+ *
837
+ * @param existing Current column widths array for the whole table.
838
+ * @param startCol First column of the cell being split.
839
+ * @param currentSpan Current column span of the cell.
840
+ * @param targetSpan Desired column span after split.
841
+ * @returns New column widths array with the split applied.
842
+ */
843
+ declare function redistributeColumnWidths(existing: number[], startCol: number, currentSpan: number, targetSpan: number): number[];
844
+ /**
845
+ * Compute the new anchor layout after splitting a target cell.
846
+ *
847
+ * This is the core algorithm shared between ProseMirror and Document-model
848
+ * paths. It adjusts neighbor spans, shifts positions for inserted rows/cols,
849
+ * and creates placeholder anchors for the new split cells.
850
+ *
851
+ * @param anchors All cell anchors in the current table.
852
+ * @param target The anchor being split.
853
+ * @param rows Number of rows the target should become.
854
+ * @param cols Number of columns the target should become.
855
+ * @param totalRows Current total row count.
856
+ * @param createSplitCellData Factory to create `data` for each new split cell.
857
+ * Called with `(isOriginal, rowOffset, colOffset)` — `isOriginal` is true for
858
+ * the top-left cell that retains the original content.
859
+ */
860
+ declare function computeSplitLayout<T>(anchors: CellAnchor<T>[], target: CellAnchor<T>, rows: number, cols: number, totalRows: number, createSplitCellData: (isOriginal: boolean, rowOffset: number, colOffset: number) => T): SplitLayoutResult<T>;
861
+ /**
862
+ * Build lookup maps from an anchor list — by start position and by covered slot.
863
+ */
864
+ declare function buildAnchorMaps<T>(anchors: CellAnchor<T>[]): {
865
+ byStart: Map<string, CellAnchor<T>>;
866
+ byCoveredSlot: Map<string, CellAnchor<T>>;
867
+ };
868
+ /**
869
+ * Compute the initial dialog values for a split-cell dialog.
870
+ */
871
+ declare function computeSplitDialogDefaults(rowspan: number, colspan: number): {
872
+ minRows: number;
873
+ minCols: number;
874
+ initialRows: number;
875
+ initialCols: number;
876
+ };
877
+
878
+ /**
879
+ * Shared file-input → docx-buffer reader.
880
+ *
881
+ * React (DocxEditor.tsx `handleDocxFileChange`) and Vue
882
+ * (DocxEditor.vue `handleDocxFileChange`) had byte-equivalent
883
+ * `await file.arrayBuffer()` + `name.replace(/\.docx$/i, '')` boilerplate
884
+ * around their hidden file inputs. This helper folds the common steps
885
+ * into one place so the two adapters can never drift on filename
886
+ * normalization or on the "reset input.value so re-picking the same
887
+ * file fires `change` again" detail.
888
+ *
889
+ * Returns `null` when the user cancelled the picker (no file chosen).
890
+ */
891
+ interface ReadDocxFileResult {
892
+ /** ArrayBuffer ready to feed into `loadBuffer` / `parseDocx`. */
893
+ buffer: ArrayBuffer;
894
+ /** File name with the trailing `.docx` extension stripped. */
895
+ name: string;
896
+ }
897
+ /**
898
+ * Read the first selected file out of an `<input type="file">` change
899
+ * event, return its ArrayBuffer + a stem-form name. Always resets
900
+ * `input.value` so re-selecting the same file in the same picker fires
901
+ * the next `change` event.
902
+ */
903
+ declare function readDocxFileFromInput(event: Event): Promise<ReadDocxFileResult | null>;
904
+
905
+ /**
906
+ * Color-mode resolution shared by every adapter so the light/dark/auto logic
907
+ * (and its SSR + prefers-color-scheme handling) can't drift between React, Vue,
908
+ * or any future host. The adapters keep only their framework binding
909
+ * (useState/useEffect vs ref/watchEffect); the rules live here.
910
+ *
911
+ * @packageDocumentation
912
+ */
913
+ /** UI color theme for the editor chrome and canvas. */
914
+ type ColorMode = 'light' | 'dark' | 'system';
915
+ /**
916
+ * Current OS dark-mode preference. Returns false when `matchMedia` is
917
+ * unavailable (e.g. server-side render), so it is safe to call as a state seed.
918
+ *
919
+ * @public
920
+ */
921
+ declare function prefersColorSchemeDark(): boolean;
922
+ /**
923
+ * Resolve the effective dark flag from a {@link ColorMode} and the current OS
924
+ * preference. `'system'` follows the OS; `'dark'`/`'light'` are explicit.
925
+ *
926
+ * @public
927
+ */
928
+ declare function resolveIsDark(colorMode: ColorMode, systemDark: boolean): boolean;
929
+ /**
930
+ * Subscribe to OS dark-mode changes. Invokes `onChange` immediately with the
931
+ * current value (so a stale seed is corrected on entry), then on every change.
932
+ * Returns an unsubscribe function. A no-op under SSR.
933
+ *
934
+ * @public
935
+ */
936
+ declare function subscribeSystemDark(onChange: (dark: boolean) => void): () => void;
937
+
938
+ /** Numeric OOXML comment-id allocation, independent of any editor engine. */
939
+ declare const PENDING_COMMENT_ID = -1;
940
+ interface CommentIdAllocator {
941
+ next(): number;
942
+ seedAbove(maxId: number): void;
943
+ }
944
+ declare function createCommentIdAllocator(): CommentIdAllocator;
945
+
946
+ /** Build a comment thread entry with a freshly allocated numeric OOXML id. */
947
+ declare function createComment(allocator: CommentIdAllocator, text: string, authorName: string, parentId?: number): Comment;
948
+
949
+ /**
950
+ * Allowlist URL schemes on hrefs that originate from untrusted input
951
+ * (DOCX relationship targets, pasted HTML). Fragments and relative paths
952
+ * pass through; anything with a scheme outside the allowlist is dropped.
953
+ */
954
+ declare function sanitizeHref(href: string | null | undefined): string | undefined;
955
+
956
+ export { CLIPBOARD_TYPES, type CellAnchor, type ClipboardContent, type ClipboardOptions, type ColorMode, type CommentIdAllocator, DEFAULT_PARAGRAPH_FLASH_COLOR, DEFAULT_PARAGRAPH_FLASH_DURATION_MS, DEFAULT_SELECTION_STYLE, type EmbeddedFontFace, HIGH_CONTRAST_SELECTION_STYLE, type HighlightRect, INTERNAL_CLIPBOARD_TYPE, type KeyboardShortcut, NAVIGATION_SHORTCUTS, type NavigationAction, type NavigationDirection, type NavigationUnit, PARAGRAPH_FLASH_CLASS_NAME, PENDING_COMMENT_ID, type ParagraphHighlightOptions, type ParsedClipboardContent, type ReadDocxFileResult, type RenderableFontOptions, SELECTION_CSS_VARS, type ScrollToParaIdOptions, type SelectionHighlightConfig, type SelectionRange, type SplitLayoutResult, type SplitTarget, areSelectionStylesInjected, borderToStyle, buildAnchorMaps, cleanWordHtml, clearSelection, computeSplitDialogDefaults, computeSplitLayout, copyParagraphs, copyRuns, createClipboardHandlers, createComment, createCommentIdAllocator, createSelectionChangeHandler, deobfuscateFont, describeShortcut, excludeFontsByName, expandSelectionToWord, extendSelectionTo, extractEmbeddedFontFaces, findNextWordStart, findParagraphFragmentsByParaId, findPreviousWordStart, findVisualLineEnd, findVisualLineStart, findWordEnd, findWordStart, flashParagraphElements, flashParagraphFragmentsByParaId, generateSelectionCSS, getClipboardImageFiles, getEmbeddedFontFaces, getEmbeddedFontFamilies, getHighlightRectStyle, getMergedSelectionRects, getNavigationShortcutDescriptions, getRenderableDocumentFonts, getSelectedText, getSelectionBoundingRect, getSelectionInfo, getSelectionRects, getWordAtCursor, handleNavigationKey, handlePasteEvent, hasActiveSelection, highlightTextRange, htmlToRuns, injectSelectionStyles, isEditorHtml, isNavigationKey, isPunctuation, isSelectionBackwards, isSelectionWithin, isValidFontKey, isWhitespace, isWordCharacter, isWordHtml, loadEmbeddedFonts, matchesShortcut, mergeAdjacentRects, mergeStyles, moveByWord, moveToLineEdge, normalizeSelectionDirection, paragraphToStyle, paragraphsToClipboardContent, parseClipboardHtml, parseNavigationAction, prefersColorSchemeDark, readDocxFileFromInput, readFromClipboard, redistributeColumnWidths, removeSelectionStyles, resolveIsDark, resolveShadingFill, runsToClipboardContent, sanitizeHref, sectionToStyle, selectRange, selectRenderableFonts, setSelectionPosition, subscribeSystemDark, sumColumnWidths, tableCellToStyle, textToStyle, writeToClipboard };