@betteroffice/docx 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/chunk-AEQOEQJ7.mjs +57 -0
- package/dist/chunk-AZ52IWB6.mjs +16 -0
- package/dist/{chunk-SINEY6ZF.mjs → chunk-B4IR6YP4.mjs} +1 -1
- package/dist/chunk-GGEGIQRK.mjs +1 -0
- package/dist/chunk-IFT6DUJX.mjs +1 -0
- package/dist/chunk-J7LNO6SM.mjs +1 -0
- package/dist/{chunk-H3JCIGWK.mjs → chunk-NJHOPXZW.mjs} +1 -1
- package/dist/{chunk-KXNZFTTK.mjs → chunk-WBH3SXI6.mjs} +1 -1
- package/dist/chunk-WON6K4FY.mjs +1 -0
- package/dist/chunk-Y7RUNRU2.mjs +1 -0
- package/dist/collaboration/index.d.mts +65 -0
- package/dist/collaboration/index.mjs +1 -0
- package/dist/{content-sSHuWw49.d.mts → content-MOZ6hKP4.d.mts} +357 -357
- package/dist/core.d.mts +148 -341
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-p-ijSzdh.d.mts → displayListQueries-BJlo7Jkz.d.mts} +24 -6
- package/dist/docx/index.d.mts +40 -520
- package/dist/docx/index.mjs +2 -2
- package/dist/editor/index.d.mts +36 -151
- package/dist/editor/index.mjs +1 -1
- package/dist/{fontLoader-Bx6DK6-2.d.mts → fontLoader-aSewHMKF.d.mts} +65 -63
- package/dist/{formatting-DoL7KBSL.d.mts → formatting-D1EPSaJP.d.mts} +1 -1
- package/dist/{rustDisplayList-dqunvwxH.d.mts → frameDelta-D965X8yK.d.mts} +3 -274
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/index-Dx4Z3lkz.d.mts +1010 -0
- package/dist/layout/index.d.mts +19 -240
- package/dist/layout/index.mjs +1 -1
- package/dist/layout/pagination/index.d.mts +10 -58
- package/dist/layout/pagination/index.mjs +1 -1
- package/dist/layout/render/index.d.mts +11 -11
- package/dist/layout/render/index.mjs +1 -1
- package/dist/plugin-api/RenderedDomContext.d.mts +9 -9
- package/dist/plugin-api/index.d.mts +191 -6
- package/dist/plugin-api/resolveItemPositions.d.mts +4 -5
- package/dist/rustDisplayList-BRuZBqdL.d.mts +278 -0
- package/dist/rustMeasureSource-D1KsQvVC.d.mts +106 -0
- package/dist/selectiveSave-CVoajSKE.d.mts +56 -0
- package/dist/styles/index.d.mts +4 -39
- package/dist/styles/index.mjs +1 -1
- package/dist/{styles-VxNcXLdi.d.mts → styles-Dn_o3Vo5.d.mts} +2 -2
- package/dist/types/content.d.mts +2 -2
- package/dist/types/document.d.mts +40 -14
- package/dist/{types-DNrYr6yQ.d.mts → types-BfqUl2h_.d.mts} +3 -71
- package/dist/utils/comments.d.mts +2 -2
- package/dist/utils/index.d.mts +110 -576
- package/dist/utils/index.mjs +1 -84
- package/dist/utils/stylePreview.d.mts +2 -2
- package/dist/utils/units.d.mts +33 -2
- package/dist/wasm-DO3BUV7C.mjs +1 -0
- package/dist/wasm-NWXX4H5G.mjs +1 -0
- package/dist/wasm-edit.d.mts +14 -5
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-layout.d.mts +10 -1
- package/dist/wasm-layout.mjs +1 -1
- package/dist/wasm-opc.mjs +1 -1
- package/dist/wasm-parse.mjs +1 -1
- package/dist/yrs/index.d.mts +6 -881
- package/dist/yrs/index.mjs +1 -1
- package/dist/yrs/residentEngineWorker.mjs +1 -1
- package/package.json +16 -139
- package/dist/Subscribable-DOz6Ohoo.d.mts +0 -33
- package/dist/agent/index.d.mts +0 -531
- package/dist/agent/index.mjs +0 -1
- package/dist/chunk-34K66SY4.mjs +0 -1
- package/dist/chunk-4RCISPPE.mjs +0 -1
- package/dist/chunk-52GB3Y42.mjs +0 -1
- package/dist/chunk-6NEKRDXF.mjs +0 -1
- package/dist/chunk-6PW4CWUG.mjs +0 -1
- package/dist/chunk-7DEIW7FL.mjs +0 -1
- package/dist/chunk-7PCO5I2O.mjs +0 -1
- package/dist/chunk-BI3B33LI.mjs +0 -1
- package/dist/chunk-BIQWVK5P.mjs +0 -2
- package/dist/chunk-CIRN3LZA.mjs +0 -1
- package/dist/chunk-DXKG3HQ5.mjs +0 -16
- package/dist/chunk-FPZBTOD6.mjs +0 -1
- package/dist/chunk-FZIA7OFY.mjs +0 -1
- package/dist/chunk-GWKJ2Y4Y.mjs +0 -1
- package/dist/chunk-HJGAQIU7.mjs +0 -2
- package/dist/chunk-I6KKMUUC.mjs +0 -1
- package/dist/chunk-IL5JZJT7.mjs +0 -1
- package/dist/chunk-JY6ILTNS.mjs +0 -1
- package/dist/chunk-KEE52TT5.mjs +0 -1
- package/dist/chunk-KVKLLTDP.mjs +0 -58
- package/dist/chunk-L5ISVQ3W.mjs +0 -1
- package/dist/chunk-LDUWIM7M.mjs +0 -1
- package/dist/chunk-N5Q3YN64.mjs +0 -1
- package/dist/chunk-NEWOMDTX.mjs +0 -1
- package/dist/chunk-O2QSE2I7.mjs +0 -1
- package/dist/chunk-OJOHXQNQ.mjs +0 -1
- package/dist/chunk-OMR3TWCD.mjs +0 -2
- package/dist/chunk-P3KDV4M2.mjs +0 -1
- package/dist/chunk-Q7PO7V73.mjs +0 -1
- package/dist/chunk-QOUFE3VX.mjs +0 -1
- package/dist/chunk-TYHI7RAD.mjs +0 -1
- package/dist/chunk-UIEJWORW.mjs +0 -1
- package/dist/chunk-VAOUFAUH.mjs +0 -1
- package/dist/chunk-VBOTMRXV.mjs +0 -1
- package/dist/chunk-VCER63GQ.mjs +0 -1
- package/dist/chunk-WAUF2UC7.mjs +0 -2
- package/dist/chunk-X4XDO3LZ.mjs +0 -1
- package/dist/chunk-XQBCCJBO.mjs +0 -9
- package/dist/chunk-XWUOLYRQ.mjs +0 -2
- package/dist/chunk-XYH6XWP3.mjs +0 -10
- package/dist/chunk-YBIM6UJV.mjs +0 -8
- package/dist/chunk-YCIH2Q3E.mjs +0 -1
- package/dist/chunk-ZOV5KL7C.mjs +0 -1
- package/dist/colorResolver-n0o7H7ep.d.mts +0 -290
- package/dist/core-plugins.d.mts +0 -37
- package/dist/core-plugins.mjs +0 -1
- package/dist/docx/parser.d.mts +0 -41
- package/dist/docx/parser.mjs +0 -1
- package/dist/docx/rezip.d.mts +0 -148
- package/dist/docx/rezip.mjs +0 -1
- package/dist/docx/serializer/index.d.mts +0 -42
- package/dist/docx/serializer/index.mjs +0 -1
- package/dist/editorTree-DO5PyDK8.d.mts +0 -37
- package/dist/executor-7O2RBJ2B.mjs +0 -1
- package/dist/headerFooterLayout-0zPT64Qc.d.mts +0 -316
- package/dist/headless.d.mts +0 -69
- package/dist/headless.mjs +0 -1
- package/dist/layout/flow/index.d.mts +0 -149
- package/dist/layout/flow/index.mjs +0 -1
- package/dist/layout/measure/index.d.mts +0 -324
- package/dist/layout/measure/index.mjs +0 -1
- package/dist/layout/pagination/types.d.mts +0 -4
- package/dist/layout/pagination/types.mjs +0 -1
- package/dist/managers/AutoSaveManager.d.mts +0 -81
- package/dist/managers/AutoSaveManager.mjs +0 -1
- package/dist/managers/TableSelectionManager.d.mts +0 -74
- package/dist/managers/TableSelectionManager.mjs +0 -1
- package/dist/managers/types.d.mts +0 -113
- package/dist/managers/types.mjs +0 -0
- package/dist/mcp-cli.mjs +0 -142
- package/dist/mcp.d.mts +0 -162
- package/dist/mcp.mjs +0 -16
- package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +0 -109
- package/dist/measuredBlock-DZwz8zhD.d.mts +0 -26
- package/dist/plugin-api/types.d.mts +0 -193
- package/dist/plugin-api/types.mjs +0 -0
- package/dist/processTemplate-HDUIZFJ5.mjs +0 -1
- package/dist/registry-DMM5VTdT.d.mts +0 -165
- package/dist/rustPagination-Bj2hq013.d.mts +0 -106
- package/dist/sectionConfigs-DW3J8q0X.d.mts +0 -55
- package/dist/selectionContext-Buc9BCU1.d.mts +0 -570
- package/dist/selectiveSave-oFBJ1n71.d.mts +0 -16
- package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +0 -23
- package/dist/settingsParser-CcGvtmCK.d.mts +0 -33
- package/dist/types/agentApi.d.mts +0 -456
- package/dist/types/agentApi.mjs +0 -1
- package/dist/types-dYdjUZMo.d.mts +0 -311
- package/dist/units-O5Y02RKQ.d.mts +0 -34
- package/dist/utils/headingCollector.d.mts +0 -28
- package/dist/utils/headingCollector.mjs +0 -1
- package/dist/utils/highlightColors.d.mts +0 -14
- package/dist/utils/highlightColors.mjs +0 -1
- package/dist/utils/textSelection.d.mts +0 -92
- package/dist/utils/textSelection.mjs +0 -1
- package/dist/variableDetector-Borj29SF.d.mts +0 -115
- package/dist/wasm-FZQ5XB2Y.mjs +0 -1
- package/dist/wasm-SA237OSP.mjs +0 -1
- package/dist/watermarkApi-DCxjutkg.d.mts +0 -38
package/dist/docx/index.d.mts
CHANGED
|
@@ -1,68 +1,10 @@
|
|
|
1
|
-
export { parseDocx } from '
|
|
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';
|
|
1
|
+
export { a as attemptSelectiveSave, c as createDocx, p as parseDocx, r as repackDocx, u as updateMultipleFiles } from '../selectiveSave-CVoajSKE.mjs';
|
|
8
2
|
import { WrapType } from './wrapTypes.mjs';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
export { e as emuToPixels, p as pixelsToEmu } from '../units-O5Y02RKQ.mjs';
|
|
12
|
-
import '../types/document.mjs';
|
|
13
|
-
import '../settingsParser-CcGvtmCK.mjs';
|
|
3
|
+
import { B as BlockContent, g as Comment, W as Watermark } from '../content-MOZ6hKP4.mjs';
|
|
4
|
+
import { Document } from '../types/document.mjs';
|
|
14
5
|
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
|
-
};
|
|
6
|
+
import '../formatting-D1EPSaJP.mjs';
|
|
7
|
+
import '../styles-Dn_o3Vo5.mjs';
|
|
66
8
|
|
|
67
9
|
type AnchorWrapType = Exclude<WrapType, 'inline'>;
|
|
68
10
|
type ImageLayoutTarget = AnchorWrapType | 'squareLeft' | 'squareRight' | 'inline';
|
|
@@ -123,462 +65,6 @@ declare function isImageLayoutOptionEnabled(_option: ImageLayoutOptionDef, _curr
|
|
|
123
65
|
/** Map legacy toolbar wrap values onto the shared image command target. */
|
|
124
66
|
declare function toolbarValueToLayoutTarget(value: string): ImageLayoutTarget | undefined;
|
|
125
67
|
|
|
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
68
|
/**
|
|
583
69
|
* Reply-range marker injection for serialization.
|
|
584
70
|
*
|
|
@@ -615,4 +101,38 @@ declare function injectReplyRangeMarkers(content: BlockContent[], comments: Comm
|
|
|
615
101
|
*/
|
|
616
102
|
declare function injectTCReplyRangeMarkers(content: BlockContent[], comments: Comment[]): void;
|
|
617
103
|
|
|
618
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Watermark document API
|
|
106
|
+
*
|
|
107
|
+
* Platform-agnostic helpers for reading and applying a document watermark.
|
|
108
|
+
* Shared by the React and Vue adapters (and the imperative ref API) so the
|
|
109
|
+
* "Design → Watermark" behavior stays identical across frameworks.
|
|
110
|
+
*
|
|
111
|
+
* A watermark lives on `HeaderFooter.watermark`. MS Word repeats the same
|
|
112
|
+
* watermark across the default, first-page, and even-page headers of every
|
|
113
|
+
* section, so `setDocumentWatermark`:
|
|
114
|
+
*
|
|
115
|
+
* 1. Applies the watermark (a per-header copy) to every existing header, and
|
|
116
|
+
* 2. Creates the header parts a section needs but lacks, so the watermark
|
|
117
|
+
* still shows on title pages (`w:titlePg`) and even pages
|
|
118
|
+
* (`w:evenAndOddHeaders`) and on documents that had no header at all.
|
|
119
|
+
*
|
|
120
|
+
* To avoid breaking header inheritance (a section that omits a header
|
|
121
|
+
* reference inherits the previous section's header — Word's "link to
|
|
122
|
+
* previous"), a missing `first`/`even` header part is only created when **no**
|
|
123
|
+
* header of that type exists anywhere in the document, i.e. there is nothing to
|
|
124
|
+
* inherit. All updates are immutable — a new `Document` is returned so the
|
|
125
|
+
* change lands in the host's undo/redo history.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/** Read the document's watermark (the first header that carries one). */
|
|
129
|
+
declare function getDocumentWatermark(doc: Document | null | undefined): Watermark | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Return a new `Document` with the watermark applied to all headers, or removed
|
|
132
|
+
* when `watermark` is null. Creates the header parts a section needs but lacks
|
|
133
|
+
* (default for a headerless doc; first/even for title/even pages) so the
|
|
134
|
+
* watermark shows on every page MS Word would show it.
|
|
135
|
+
*/
|
|
136
|
+
declare function setDocumentWatermark(doc: Document, watermark: Watermark | null): Document;
|
|
137
|
+
|
|
138
|
+
export { type AnchorWrapType, IMAGE_LAYOUT_OPTIONS, type ImageLayoutAttrs, type ImageLayoutCurrentAttrs, type ImageLayoutIconHint, type ImageLayoutOptionDef, type ImageLayoutPosition, type ImageLayoutTarget, type ImageResizeHandle, type SetImageWrapTypeOptions, calculateResizedImageDimensions, deriveLayoutChoice, getDocumentWatermark, injectReplyRangeMarkers, injectTCReplyRangeMarkers, isImageLayoutOptionEnabled, resolveImageLayoutAttrs, setDocumentWatermark, toolbarValueToLayoutTarget };
|