@eigenpal/docx-editor-agents 0.1.0 → 0.2.0
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 +69 -16
- package/dist/ai-sdk/react.d.mts +67 -0
- package/dist/ai-sdk/react.d.ts +67 -0
- package/dist/ai-sdk/react.js +1 -0
- package/dist/ai-sdk/react.mjs +1 -0
- package/dist/ai-sdk/server.d.mts +42 -0
- package/dist/ai-sdk/server.d.ts +42 -0
- package/dist/ai-sdk/server.js +1 -0
- package/dist/ai-sdk/server.mjs +1 -0
- package/dist/bridge.d.mts +1 -11
- package/dist/bridge.d.ts +1 -11
- package/dist/bridge.js +1 -1
- package/dist/bridge.mjs +1 -1
- package/dist/{chunk-W2QSJSB7.mjs → chunk-25L7AEDN.mjs} +11 -11
- package/dist/chunk-2MJYWSD3.js +2 -0
- package/dist/chunk-4OJA3FMM.mjs +5 -0
- package/dist/chunk-AITWKLUF.mjs +2 -0
- package/dist/chunk-ALS6DG4A.js +1 -0
- package/dist/chunk-CWKXKM35.mjs +1 -0
- package/dist/chunk-DOKVZKIP.js +5 -0
- package/dist/chunk-GZG3RJXW.js +8 -0
- package/dist/chunk-S2PFUY23.mjs +8 -0
- package/dist/{chunk-G5XAABHF.js → chunk-VF25WARH.js} +11 -11
- package/dist/headless-B7TGKW6I.js +1 -0
- package/dist/{headless-I5CZ42MD.mjs → headless-PZWHORT6.mjs} +1 -1
- package/dist/index.d.mts +118 -1997
- package/dist/index.d.ts +118 -1997
- package/dist/index.js +1 -5
- package/dist/index.mjs +1 -5
- package/dist/mcp.d.mts +180 -0
- package/dist/mcp.d.ts +180 -0
- package/dist/mcp.js +4 -0
- package/dist/mcp.mjs +4 -0
- package/dist/react.d.mts +78 -0
- package/dist/react.d.ts +78 -0
- package/dist/react.js +1 -0
- package/dist/react.mjs +1 -0
- package/dist/server-B7dGWiLh.d.mts +2395 -0
- package/dist/server-B7dGWiLh.d.ts +2395 -0
- package/dist/server.d.mts +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +1 -0
- package/dist/server.mjs +1 -0
- package/package.json +52 -1
- package/dist/headless-DGAHMYIU.js +0 -1
|
@@ -0,0 +1,2395 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color & Styling Primitives
|
|
3
|
+
*
|
|
4
|
+
* Basic types used throughout OOXML for colors, borders, and shading.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Theme color slots from theme1.xml
|
|
8
|
+
*/
|
|
9
|
+
type ThemeColorSlot = 'dk1' | 'lt1' | 'dk2' | 'lt2' | 'accent1' | 'accent2' | 'accent3' | 'accent4' | 'accent5' | 'accent6' | 'hlink' | 'folHlink' | 'background1' | 'text1' | 'background2' | 'text2';
|
|
10
|
+
/**
|
|
11
|
+
* Color value - can be direct RGB, theme reference, or auto
|
|
12
|
+
*/
|
|
13
|
+
interface ColorValue {
|
|
14
|
+
/** RGB hex value without # (e.g., "FF0000") */
|
|
15
|
+
rgb?: string;
|
|
16
|
+
/** Theme color slot reference */
|
|
17
|
+
themeColor?: ThemeColorSlot;
|
|
18
|
+
/** Tint modifier (0-255 as hex string, e.g., "80") - makes color lighter */
|
|
19
|
+
themeTint?: string;
|
|
20
|
+
/** Shade modifier (0-255 as hex string) - makes color darker */
|
|
21
|
+
themeShade?: string;
|
|
22
|
+
/** Auto color - context-dependent (usually black for text) */
|
|
23
|
+
auto?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Border specification for any border (paragraph, table, page)
|
|
27
|
+
*/
|
|
28
|
+
interface BorderSpec {
|
|
29
|
+
/** Border style */
|
|
30
|
+
style: 'none' | 'single' | 'double' | 'dotted' | 'dashed' | 'thick' | 'triple' | 'thinThickSmallGap' | 'thickThinSmallGap' | 'thinThickMediumGap' | 'thickThinMediumGap' | 'thinThickLargeGap' | 'thickThinLargeGap' | 'wave' | 'doubleWave' | 'dashSmallGap' | 'dashDotStroked' | 'threeDEmboss' | 'threeDEngrave' | 'outset' | 'inset' | 'nil';
|
|
31
|
+
/** Color of the border */
|
|
32
|
+
color?: ColorValue;
|
|
33
|
+
/** Width in eighths of a point (1/8 pt) */
|
|
34
|
+
size?: number;
|
|
35
|
+
/** Spacing from text in points */
|
|
36
|
+
space?: number;
|
|
37
|
+
/** Shadow effect */
|
|
38
|
+
shadow?: boolean;
|
|
39
|
+
/** Frame effect */
|
|
40
|
+
frame?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Shading/background properties
|
|
44
|
+
*/
|
|
45
|
+
interface ShadingProperties {
|
|
46
|
+
/** Pattern fill color */
|
|
47
|
+
color?: ColorValue;
|
|
48
|
+
/** Background fill color */
|
|
49
|
+
fill?: ColorValue;
|
|
50
|
+
/** Shading pattern type */
|
|
51
|
+
pattern?: 'clear' | 'solid' | 'horzStripe' | 'vertStripe' | 'reverseDiagStripe' | 'diagStripe' | 'horzCross' | 'diagCross' | 'thinHorzStripe' | 'thinVertStripe' | 'thinReverseDiagStripe' | 'thinDiagStripe' | 'thinHorzCross' | 'thinDiagCross' | 'pct5' | 'pct10' | 'pct12' | 'pct15' | 'pct20' | 'pct25' | 'pct30' | 'pct35' | 'pct37' | 'pct40' | 'pct45' | 'pct50' | 'pct55' | 'pct60' | 'pct62' | 'pct65' | 'pct70' | 'pct75' | 'pct80' | 'pct85' | 'pct87' | 'pct90' | 'pct95' | 'nil';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Text, Paragraph, and Table Formatting Types
|
|
56
|
+
*
|
|
57
|
+
* Properties that control how text, paragraphs, and table structures
|
|
58
|
+
* are formatted in OOXML (w:rPr, w:pPr, w:tblPr, etc.).
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Underline style options
|
|
63
|
+
*/
|
|
64
|
+
type UnderlineStyle = 'none' | 'single' | 'words' | 'double' | 'thick' | 'dotted' | 'dottedHeavy' | 'dash' | 'dashedHeavy' | 'dashLong' | 'dashLongHeavy' | 'dotDash' | 'dashDotHeavy' | 'dotDotDash' | 'dashDotDotHeavy' | 'wave' | 'wavyHeavy' | 'wavyDouble';
|
|
65
|
+
/**
|
|
66
|
+
* Text effect animations
|
|
67
|
+
*/
|
|
68
|
+
type TextEffect = 'none' | 'blinkBackground' | 'lights' | 'antsBlack' | 'antsRed' | 'shimmer' | 'sparkle';
|
|
69
|
+
/**
|
|
70
|
+
* Emphasis mark type
|
|
71
|
+
*/
|
|
72
|
+
type EmphasisMark = 'none' | 'dot' | 'comma' | 'circle' | 'underDot';
|
|
73
|
+
/**
|
|
74
|
+
* Complete text formatting properties (w:rPr)
|
|
75
|
+
*/
|
|
76
|
+
interface TextFormatting {
|
|
77
|
+
/** Bold (w:b) */
|
|
78
|
+
bold?: boolean;
|
|
79
|
+
/** Bold complex script (w:bCs) */
|
|
80
|
+
boldCs?: boolean;
|
|
81
|
+
/** Italic (w:i) */
|
|
82
|
+
italic?: boolean;
|
|
83
|
+
/** Italic complex script (w:iCs) */
|
|
84
|
+
italicCs?: boolean;
|
|
85
|
+
/** Underline style and color (w:u) */
|
|
86
|
+
underline?: {
|
|
87
|
+
style: UnderlineStyle;
|
|
88
|
+
color?: ColorValue;
|
|
89
|
+
};
|
|
90
|
+
/** Strikethrough (w:strike) */
|
|
91
|
+
strike?: boolean;
|
|
92
|
+
/** Double strikethrough (w:dstrike) */
|
|
93
|
+
doubleStrike?: boolean;
|
|
94
|
+
/** Superscript/subscript (w:vertAlign) */
|
|
95
|
+
vertAlign?: 'baseline' | 'superscript' | 'subscript';
|
|
96
|
+
/** Small caps (w:smallCaps) */
|
|
97
|
+
smallCaps?: boolean;
|
|
98
|
+
/** All caps (w:caps) */
|
|
99
|
+
allCaps?: boolean;
|
|
100
|
+
/** Hidden text (w:vanish) */
|
|
101
|
+
hidden?: boolean;
|
|
102
|
+
/** Text color (w:color) */
|
|
103
|
+
color?: ColorValue;
|
|
104
|
+
/** Highlight/background color (w:highlight) */
|
|
105
|
+
highlight?: 'black' | 'blue' | 'cyan' | 'darkBlue' | 'darkCyan' | 'darkGray' | 'darkGreen' | 'darkMagenta' | 'darkRed' | 'darkYellow' | 'green' | 'lightGray' | 'magenta' | 'none' | 'red' | 'white' | 'yellow';
|
|
106
|
+
/** Character shading (w:shd) */
|
|
107
|
+
shading?: ShadingProperties;
|
|
108
|
+
/** Font size in half-points (w:sz) - e.g., 24 = 12pt */
|
|
109
|
+
fontSize?: number;
|
|
110
|
+
/** Font size complex script (w:szCs) */
|
|
111
|
+
fontSizeCs?: number;
|
|
112
|
+
/** Font family (w:rFonts) */
|
|
113
|
+
fontFamily?: {
|
|
114
|
+
ascii?: string;
|
|
115
|
+
hAnsi?: string;
|
|
116
|
+
eastAsia?: string;
|
|
117
|
+
cs?: string;
|
|
118
|
+
/** Theme font reference */
|
|
119
|
+
asciiTheme?: 'majorAscii' | 'majorHAnsi' | 'majorEastAsia' | 'majorBidi' | 'minorAscii' | 'minorHAnsi' | 'minorEastAsia' | 'minorBidi';
|
|
120
|
+
hAnsiTheme?: string;
|
|
121
|
+
eastAsiaTheme?: string;
|
|
122
|
+
csTheme?: string;
|
|
123
|
+
};
|
|
124
|
+
/** Character spacing in twips (w:spacing) */
|
|
125
|
+
spacing?: number;
|
|
126
|
+
/** Raised/lowered text position in half-points (w:position) */
|
|
127
|
+
position?: number;
|
|
128
|
+
/** Horizontal text scale percentage (w:w) */
|
|
129
|
+
scale?: number;
|
|
130
|
+
/** Kerning threshold in half-points (w:kern) */
|
|
131
|
+
kerning?: number;
|
|
132
|
+
/** Text effect animation (w:effect) */
|
|
133
|
+
effect?: TextEffect;
|
|
134
|
+
/** Emphasis mark (w:em) */
|
|
135
|
+
emphasisMark?: EmphasisMark;
|
|
136
|
+
/** Emboss effect (w:emboss) */
|
|
137
|
+
emboss?: boolean;
|
|
138
|
+
/** Imprint/engrave effect (w:imprint) */
|
|
139
|
+
imprint?: boolean;
|
|
140
|
+
/** Outline effect (w:outline) */
|
|
141
|
+
outline?: boolean;
|
|
142
|
+
/** Shadow effect (w:shadow) */
|
|
143
|
+
shadow?: boolean;
|
|
144
|
+
/** Right-to-left text (w:rtl) */
|
|
145
|
+
rtl?: boolean;
|
|
146
|
+
/** Complex script formatting (w:cs) */
|
|
147
|
+
cs?: boolean;
|
|
148
|
+
/** Character style ID (w:rStyle) */
|
|
149
|
+
styleId?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Tab stop alignment
|
|
153
|
+
*/
|
|
154
|
+
type TabStopAlignment = 'left' | 'center' | 'right' | 'decimal' | 'bar' | 'clear' | 'num';
|
|
155
|
+
/**
|
|
156
|
+
* Tab leader character
|
|
157
|
+
*/
|
|
158
|
+
type TabLeader = 'none' | 'dot' | 'hyphen' | 'underscore' | 'heavy' | 'middleDot';
|
|
159
|
+
/**
|
|
160
|
+
* Tab stop definition
|
|
161
|
+
*/
|
|
162
|
+
interface TabStop {
|
|
163
|
+
/** Position in twips from left margin */
|
|
164
|
+
position: number;
|
|
165
|
+
/** Alignment at tab stop */
|
|
166
|
+
alignment: TabStopAlignment;
|
|
167
|
+
/** Leader character */
|
|
168
|
+
leader?: TabLeader;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Line spacing rule
|
|
172
|
+
*/
|
|
173
|
+
type LineSpacingRule = 'auto' | 'exact' | 'atLeast';
|
|
174
|
+
/**
|
|
175
|
+
* Paragraph alignment/justification
|
|
176
|
+
*/
|
|
177
|
+
type ParagraphAlignment = 'left' | 'center' | 'right' | 'both' | 'distribute' | 'mediumKashida' | 'highKashida' | 'lowKashida' | 'thaiDistribute';
|
|
178
|
+
/**
|
|
179
|
+
* Complete paragraph formatting properties (w:pPr)
|
|
180
|
+
*/
|
|
181
|
+
interface ParagraphFormatting {
|
|
182
|
+
/** Paragraph alignment (w:jc) */
|
|
183
|
+
alignment?: ParagraphAlignment;
|
|
184
|
+
/** Text direction (w:bidi) */
|
|
185
|
+
bidi?: boolean;
|
|
186
|
+
/** Spacing before in twips (w:spacing/@w:before) */
|
|
187
|
+
spaceBefore?: number;
|
|
188
|
+
/** Spacing after in twips (w:spacing/@w:after) */
|
|
189
|
+
spaceAfter?: number;
|
|
190
|
+
/** Line spacing value (w:spacing/@w:line) */
|
|
191
|
+
lineSpacing?: number;
|
|
192
|
+
/** Line spacing rule (w:spacing/@w:lineRule) */
|
|
193
|
+
lineSpacingRule?: LineSpacingRule;
|
|
194
|
+
/** Auto space before (w:spacing/@w:beforeAutospacing) */
|
|
195
|
+
beforeAutospacing?: boolean;
|
|
196
|
+
/** Auto space after (w:spacing/@w:afterAutospacing) */
|
|
197
|
+
afterAutospacing?: boolean;
|
|
198
|
+
/** Left indent in twips (w:ind/@w:left) */
|
|
199
|
+
indentLeft?: number;
|
|
200
|
+
/** Right indent in twips (w:ind/@w:right) */
|
|
201
|
+
indentRight?: number;
|
|
202
|
+
/** First line indent in twips - positive for indent, negative for hanging (w:ind/@w:firstLine or @w:hanging) */
|
|
203
|
+
indentFirstLine?: number;
|
|
204
|
+
/** Whether first line is hanging indent */
|
|
205
|
+
hangingIndent?: boolean;
|
|
206
|
+
/** Paragraph borders (w:pBdr) */
|
|
207
|
+
borders?: {
|
|
208
|
+
top?: BorderSpec;
|
|
209
|
+
bottom?: BorderSpec;
|
|
210
|
+
left?: BorderSpec;
|
|
211
|
+
right?: BorderSpec;
|
|
212
|
+
between?: BorderSpec;
|
|
213
|
+
bar?: BorderSpec;
|
|
214
|
+
};
|
|
215
|
+
/** Paragraph shading (w:shd) */
|
|
216
|
+
shading?: ShadingProperties;
|
|
217
|
+
/** Custom tab stops (w:tabs) */
|
|
218
|
+
tabs?: TabStop[];
|
|
219
|
+
/** Keep with next paragraph (w:keepNext) */
|
|
220
|
+
keepNext?: boolean;
|
|
221
|
+
/** Keep lines together (w:keepLines) */
|
|
222
|
+
keepLines?: boolean;
|
|
223
|
+
/** Widow/orphan control (w:widowControl) */
|
|
224
|
+
widowControl?: boolean;
|
|
225
|
+
/** Page break before (w:pageBreakBefore) */
|
|
226
|
+
pageBreakBefore?: boolean;
|
|
227
|
+
/** Contextual spacing — suppress space between paragraphs of the same style (w:contextualSpacing) */
|
|
228
|
+
contextualSpacing?: boolean;
|
|
229
|
+
/** Numbering properties (w:numPr) */
|
|
230
|
+
numPr?: {
|
|
231
|
+
/** Numbering definition ID (w:numId) */
|
|
232
|
+
numId?: number;
|
|
233
|
+
/** List level (0-8) (w:ilvl) */
|
|
234
|
+
ilvl?: number;
|
|
235
|
+
};
|
|
236
|
+
/** Outline level 0-9 (w:outlineLvl) */
|
|
237
|
+
outlineLevel?: number;
|
|
238
|
+
/** Paragraph style ID (w:pStyle) */
|
|
239
|
+
styleId?: string;
|
|
240
|
+
/** Text frame properties (w:framePr) */
|
|
241
|
+
frame?: {
|
|
242
|
+
width?: number;
|
|
243
|
+
height?: number;
|
|
244
|
+
hAnchor?: 'text' | 'margin' | 'page';
|
|
245
|
+
vAnchor?: 'text' | 'margin' | 'page';
|
|
246
|
+
x?: number;
|
|
247
|
+
y?: number;
|
|
248
|
+
xAlign?: 'left' | 'center' | 'right' | 'inside' | 'outside';
|
|
249
|
+
yAlign?: 'top' | 'center' | 'bottom' | 'inside' | 'outside' | 'inline';
|
|
250
|
+
wrap?: 'around' | 'auto' | 'none' | 'notBeside' | 'through' | 'tight';
|
|
251
|
+
};
|
|
252
|
+
/** Suppress line numbers (w:suppressLineNumbers) */
|
|
253
|
+
suppressLineNumbers?: boolean;
|
|
254
|
+
/** Suppress auto hyphens (w:suppressAutoHyphens) */
|
|
255
|
+
suppressAutoHyphens?: boolean;
|
|
256
|
+
/** Run properties to apply to all runs (w:rPr) */
|
|
257
|
+
runProperties?: TextFormatting;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Table width type
|
|
261
|
+
*/
|
|
262
|
+
type TableWidthType = 'auto' | 'dxa' | 'nil' | 'pct';
|
|
263
|
+
/**
|
|
264
|
+
* Table measurement (width or height)
|
|
265
|
+
*/
|
|
266
|
+
interface TableMeasurement {
|
|
267
|
+
/** Value in twips (for dxa) or fifths of a percent (for pct) */
|
|
268
|
+
value: number;
|
|
269
|
+
/** Measurement type */
|
|
270
|
+
type: TableWidthType;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Table borders
|
|
274
|
+
*/
|
|
275
|
+
interface TableBorders {
|
|
276
|
+
top?: BorderSpec;
|
|
277
|
+
bottom?: BorderSpec;
|
|
278
|
+
left?: BorderSpec;
|
|
279
|
+
right?: BorderSpec;
|
|
280
|
+
insideH?: BorderSpec;
|
|
281
|
+
insideV?: BorderSpec;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Cell margins
|
|
285
|
+
*/
|
|
286
|
+
interface CellMargins {
|
|
287
|
+
top?: TableMeasurement;
|
|
288
|
+
bottom?: TableMeasurement;
|
|
289
|
+
left?: TableMeasurement;
|
|
290
|
+
right?: TableMeasurement;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Table look flags (for table styles)
|
|
294
|
+
*/
|
|
295
|
+
interface TableLook {
|
|
296
|
+
firstColumn?: boolean;
|
|
297
|
+
firstRow?: boolean;
|
|
298
|
+
lastColumn?: boolean;
|
|
299
|
+
lastRow?: boolean;
|
|
300
|
+
noHBand?: boolean;
|
|
301
|
+
noVBand?: boolean;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Floating table properties
|
|
305
|
+
*/
|
|
306
|
+
interface FloatingTableProperties {
|
|
307
|
+
/** Horizontal anchor */
|
|
308
|
+
horzAnchor?: 'margin' | 'page' | 'text';
|
|
309
|
+
/** Vertical anchor */
|
|
310
|
+
vertAnchor?: 'margin' | 'page' | 'text';
|
|
311
|
+
/** Horizontal position */
|
|
312
|
+
tblpX?: number;
|
|
313
|
+
tblpXSpec?: 'left' | 'center' | 'right' | 'inside' | 'outside';
|
|
314
|
+
/** Vertical position */
|
|
315
|
+
tblpY?: number;
|
|
316
|
+
tblpYSpec?: 'top' | 'center' | 'bottom' | 'inside' | 'outside' | 'inline';
|
|
317
|
+
/** Distance from surrounding text */
|
|
318
|
+
topFromText?: number;
|
|
319
|
+
bottomFromText?: number;
|
|
320
|
+
leftFromText?: number;
|
|
321
|
+
rightFromText?: number;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Table formatting properties (w:tblPr)
|
|
325
|
+
*/
|
|
326
|
+
interface TableFormatting {
|
|
327
|
+
/** Table width */
|
|
328
|
+
width?: TableMeasurement;
|
|
329
|
+
/** Table justification */
|
|
330
|
+
justification?: 'left' | 'center' | 'right';
|
|
331
|
+
/** Cell spacing */
|
|
332
|
+
cellSpacing?: TableMeasurement;
|
|
333
|
+
/** Table indent from left margin */
|
|
334
|
+
indent?: TableMeasurement;
|
|
335
|
+
/** Table borders */
|
|
336
|
+
borders?: TableBorders;
|
|
337
|
+
/** Default cell margins */
|
|
338
|
+
cellMargins?: CellMargins;
|
|
339
|
+
/** Table layout */
|
|
340
|
+
layout?: 'fixed' | 'autofit';
|
|
341
|
+
/** Table style ID */
|
|
342
|
+
styleId?: string;
|
|
343
|
+
/** Table look (conditional formatting flags) */
|
|
344
|
+
look?: TableLook;
|
|
345
|
+
/** Shading/background */
|
|
346
|
+
shading?: ShadingProperties;
|
|
347
|
+
/** Overlap for floating tables */
|
|
348
|
+
overlap?: 'never' | 'overlap';
|
|
349
|
+
/** Floating table properties */
|
|
350
|
+
floating?: FloatingTableProperties;
|
|
351
|
+
/** Right to left table */
|
|
352
|
+
bidi?: boolean;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Table row formatting properties (w:trPr)
|
|
356
|
+
*/
|
|
357
|
+
interface TableRowFormatting {
|
|
358
|
+
/** Row height */
|
|
359
|
+
height?: TableMeasurement;
|
|
360
|
+
/** Height rule */
|
|
361
|
+
heightRule?: 'auto' | 'atLeast' | 'exact';
|
|
362
|
+
/** Header row (repeats on each page) */
|
|
363
|
+
header?: boolean;
|
|
364
|
+
/** Allow row to break across pages */
|
|
365
|
+
cantSplit?: boolean;
|
|
366
|
+
/** Row justification */
|
|
367
|
+
justification?: 'left' | 'center' | 'right';
|
|
368
|
+
/** Hidden row */
|
|
369
|
+
hidden?: boolean;
|
|
370
|
+
/** Conditional format style */
|
|
371
|
+
conditionalFormat?: ConditionalFormatStyle;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Conditional format style
|
|
375
|
+
*/
|
|
376
|
+
interface ConditionalFormatStyle {
|
|
377
|
+
/** First row */
|
|
378
|
+
firstRow?: boolean;
|
|
379
|
+
/** Last row */
|
|
380
|
+
lastRow?: boolean;
|
|
381
|
+
/** First column */
|
|
382
|
+
firstColumn?: boolean;
|
|
383
|
+
/** Last column */
|
|
384
|
+
lastColumn?: boolean;
|
|
385
|
+
/** Odd horizontal band */
|
|
386
|
+
oddHBand?: boolean;
|
|
387
|
+
/** Even horizontal band */
|
|
388
|
+
evenHBand?: boolean;
|
|
389
|
+
/** Odd vertical band */
|
|
390
|
+
oddVBand?: boolean;
|
|
391
|
+
/** Even vertical band */
|
|
392
|
+
evenVBand?: boolean;
|
|
393
|
+
/** Northwest corner */
|
|
394
|
+
nwCell?: boolean;
|
|
395
|
+
/** Northeast corner */
|
|
396
|
+
neCell?: boolean;
|
|
397
|
+
/** Southwest corner */
|
|
398
|
+
swCell?: boolean;
|
|
399
|
+
/** Southeast corner */
|
|
400
|
+
seCell?: boolean;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Table cell formatting properties (w:tcPr)
|
|
404
|
+
*/
|
|
405
|
+
interface TableCellFormatting {
|
|
406
|
+
/** Cell width */
|
|
407
|
+
width?: TableMeasurement;
|
|
408
|
+
/** Cell borders */
|
|
409
|
+
borders?: TableBorders;
|
|
410
|
+
/** Cell margins (override table default) */
|
|
411
|
+
margins?: CellMargins;
|
|
412
|
+
/** Cell shading/background */
|
|
413
|
+
shading?: ShadingProperties;
|
|
414
|
+
/** Vertical alignment */
|
|
415
|
+
verticalAlign?: 'top' | 'center' | 'bottom';
|
|
416
|
+
/** Text direction */
|
|
417
|
+
textDirection?: 'lr' | 'lrV' | 'rl' | 'rlV' | 'tb' | 'tbV' | 'tbRl' | 'tbRlV' | 'btLr';
|
|
418
|
+
/** Grid span (horizontal merge) */
|
|
419
|
+
gridSpan?: number;
|
|
420
|
+
/** Vertical merge */
|
|
421
|
+
vMerge?: 'restart' | 'continue';
|
|
422
|
+
/** Fit text to cell width */
|
|
423
|
+
fitText?: boolean;
|
|
424
|
+
/** Wrap text */
|
|
425
|
+
noWrap?: boolean;
|
|
426
|
+
/** Hide cell marker */
|
|
427
|
+
hideMark?: boolean;
|
|
428
|
+
/** Conditional format style */
|
|
429
|
+
conditionalFormat?: ConditionalFormatStyle;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Lists & Numbering Types
|
|
434
|
+
*
|
|
435
|
+
* Types for bullet lists, numbered lists, and numbering definitions.
|
|
436
|
+
*/
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Number format type
|
|
440
|
+
*/
|
|
441
|
+
type NumberFormat = 'decimal' | 'upperRoman' | 'lowerRoman' | 'upperLetter' | 'lowerLetter' | 'ordinal' | 'cardinalText' | 'ordinalText' | 'hex' | 'chicago' | 'ideographDigital' | 'japaneseCounting' | 'aiueo' | 'iroha' | 'decimalFullWidth' | 'decimalHalfWidth' | 'japaneseLegal' | 'japaneseDigitalTenThousand' | 'decimalEnclosedCircle' | 'decimalFullWidth2' | 'aiueoFullWidth' | 'irohaFullWidth' | 'decimalZero' | 'bullet' | 'ganada' | 'chosung' | 'decimalEnclosedFullstop' | 'decimalEnclosedParen' | 'decimalEnclosedCircleChinese' | 'ideographEnclosedCircle' | 'ideographTraditional' | 'ideographZodiac' | 'ideographZodiacTraditional' | 'taiwaneseCounting' | 'ideographLegalTraditional' | 'taiwaneseCountingThousand' | 'taiwaneseDigital' | 'chineseCounting' | 'chineseLegalSimplified' | 'chineseCountingThousand' | 'koreanDigital' | 'koreanCounting' | 'koreanLegal' | 'koreanDigital2' | 'vietnameseCounting' | 'russianLower' | 'russianUpper' | 'none' | 'numberInDash' | 'hebrew1' | 'hebrew2' | 'arabicAlpha' | 'arabicAbjad' | 'hindiVowels' | 'hindiConsonants' | 'hindiNumbers' | 'hindiCounting' | 'thaiLetters' | 'thaiNumbers' | 'thaiCounting';
|
|
442
|
+
/**
|
|
443
|
+
* Multi-level suffix (what follows the number)
|
|
444
|
+
*/
|
|
445
|
+
type LevelSuffix = 'tab' | 'space' | 'nothing';
|
|
446
|
+
/**
|
|
447
|
+
* List level definition
|
|
448
|
+
*/
|
|
449
|
+
interface ListLevel {
|
|
450
|
+
/** Level index (0-8) */
|
|
451
|
+
ilvl: number;
|
|
452
|
+
/** Starting number */
|
|
453
|
+
start?: number;
|
|
454
|
+
/** Number format */
|
|
455
|
+
numFmt: NumberFormat;
|
|
456
|
+
/** Level text (e.g., "%1." or "•") */
|
|
457
|
+
lvlText: string;
|
|
458
|
+
/** Justification */
|
|
459
|
+
lvlJc?: 'left' | 'center' | 'right';
|
|
460
|
+
/** Suffix after number */
|
|
461
|
+
suffix?: LevelSuffix;
|
|
462
|
+
/** Paragraph properties for this level */
|
|
463
|
+
pPr?: ParagraphFormatting;
|
|
464
|
+
/** Run properties for the number/bullet */
|
|
465
|
+
rPr?: TextFormatting;
|
|
466
|
+
/** Restart numbering from higher level */
|
|
467
|
+
lvlRestart?: number;
|
|
468
|
+
/** Is legal numbering style */
|
|
469
|
+
isLgl?: boolean;
|
|
470
|
+
/** Legacy settings */
|
|
471
|
+
legacy?: {
|
|
472
|
+
legacy?: boolean;
|
|
473
|
+
legacySpace?: number;
|
|
474
|
+
legacyIndent?: number;
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Abstract numbering definition (w:abstractNum)
|
|
479
|
+
*/
|
|
480
|
+
interface AbstractNumbering {
|
|
481
|
+
/** Abstract numbering ID */
|
|
482
|
+
abstractNumId: number;
|
|
483
|
+
/** Multi-level type */
|
|
484
|
+
multiLevelType?: 'hybridMultilevel' | 'multilevel' | 'singleLevel';
|
|
485
|
+
/** Numbering style link */
|
|
486
|
+
numStyleLink?: string;
|
|
487
|
+
/** Style link */
|
|
488
|
+
styleLink?: string;
|
|
489
|
+
/** Level definitions */
|
|
490
|
+
levels: ListLevel[];
|
|
491
|
+
/** Name */
|
|
492
|
+
name?: string;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Numbering instance (w:num)
|
|
496
|
+
*/
|
|
497
|
+
interface NumberingInstance {
|
|
498
|
+
/** Numbering ID (referenced by paragraphs) */
|
|
499
|
+
numId: number;
|
|
500
|
+
/** Reference to abstract numbering */
|
|
501
|
+
abstractNumId: number;
|
|
502
|
+
/** Level overrides */
|
|
503
|
+
levelOverrides?: Array<{
|
|
504
|
+
ilvl: number;
|
|
505
|
+
startOverride?: number;
|
|
506
|
+
lvl?: ListLevel;
|
|
507
|
+
}>;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Computed list rendering info
|
|
511
|
+
*/
|
|
512
|
+
interface ListRendering {
|
|
513
|
+
/** Computed marker text (e.g., "1.", "a)", "•") */
|
|
514
|
+
marker: string;
|
|
515
|
+
/** List level (0-8) */
|
|
516
|
+
level: number;
|
|
517
|
+
/** Numbering ID */
|
|
518
|
+
numId: number;
|
|
519
|
+
/** Whether this is a bullet or numbered list */
|
|
520
|
+
isBullet: boolean;
|
|
521
|
+
/** Number format type (decimal, lowerRoman, upperRoman, etc.) */
|
|
522
|
+
numFmt?: NumberFormat;
|
|
523
|
+
/** Whether the list marker is hidden (w:vanish on level rPr) */
|
|
524
|
+
markerHidden?: boolean;
|
|
525
|
+
/** Marker font family from numbering level rPr (ascii name) */
|
|
526
|
+
markerFontFamily?: string;
|
|
527
|
+
/** Marker font size from numbering level rPr, in points */
|
|
528
|
+
markerFontSize?: number;
|
|
529
|
+
/**
|
|
530
|
+
* NumberFormat for each level from 0..ilvl (inclusive).
|
|
531
|
+
* Used to resolve multi-level templates like "%1.%2." where each %N
|
|
532
|
+
* may need a different format (e.g., upperRoman parent + decimal child).
|
|
533
|
+
*/
|
|
534
|
+
levelNumFmts?: NumberFormat[];
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Complete numbering definitions
|
|
538
|
+
*/
|
|
539
|
+
interface NumberingDefinitions {
|
|
540
|
+
/** Abstract numbering definitions */
|
|
541
|
+
abstractNums: AbstractNumbering[];
|
|
542
|
+
/** Numbering instances */
|
|
543
|
+
nums: NumberingInstance[];
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Document Content Model
|
|
548
|
+
*
|
|
549
|
+
* All content-bearing types: runs, hyperlinks, bookmarks, fields,
|
|
550
|
+
* images, shapes, tables, lists, paragraphs, headers/footers,
|
|
551
|
+
* footnotes/endnotes, and sections.
|
|
552
|
+
*
|
|
553
|
+
* These types form a deeply interrelated tree (Paragraph ↔ Table ↔ ShapeTextBody)
|
|
554
|
+
* and are kept together to avoid circular import issues.
|
|
555
|
+
*/
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Plain text content
|
|
559
|
+
*/
|
|
560
|
+
interface TextContent {
|
|
561
|
+
type: 'text';
|
|
562
|
+
/** The text string */
|
|
563
|
+
text: string;
|
|
564
|
+
/** Preserve whitespace (xml:space="preserve") */
|
|
565
|
+
preserveSpace?: boolean;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Tab character
|
|
569
|
+
*/
|
|
570
|
+
interface TabContent {
|
|
571
|
+
type: 'tab';
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Line break
|
|
575
|
+
*/
|
|
576
|
+
interface BreakContent {
|
|
577
|
+
type: 'break';
|
|
578
|
+
/** Break type */
|
|
579
|
+
breakType?: 'page' | 'column' | 'textWrapping';
|
|
580
|
+
/** Clear type for text wrapping break */
|
|
581
|
+
clear?: 'none' | 'left' | 'right' | 'all';
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Symbol character (special font character)
|
|
585
|
+
*/
|
|
586
|
+
interface SymbolContent {
|
|
587
|
+
type: 'symbol';
|
|
588
|
+
/** Font name */
|
|
589
|
+
font: string;
|
|
590
|
+
/** Character code */
|
|
591
|
+
char: string;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Footnote or endnote reference
|
|
595
|
+
*/
|
|
596
|
+
interface NoteReferenceContent {
|
|
597
|
+
type: 'footnoteRef' | 'endnoteRef';
|
|
598
|
+
/** Note ID */
|
|
599
|
+
id: number;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Field character (begin/separate/end)
|
|
603
|
+
*/
|
|
604
|
+
interface FieldCharContent {
|
|
605
|
+
type: 'fieldChar';
|
|
606
|
+
/** Field character type */
|
|
607
|
+
charType: 'begin' | 'separate' | 'end';
|
|
608
|
+
/** Field is locked */
|
|
609
|
+
fldLock?: boolean;
|
|
610
|
+
/** Field is dirty (needs update) */
|
|
611
|
+
dirty?: boolean;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Field instruction text
|
|
615
|
+
*/
|
|
616
|
+
interface InstrTextContent {
|
|
617
|
+
type: 'instrText';
|
|
618
|
+
/** Field instruction */
|
|
619
|
+
text: string;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Soft hyphen
|
|
623
|
+
*/
|
|
624
|
+
interface SoftHyphenContent {
|
|
625
|
+
type: 'softHyphen';
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Non-breaking hyphen
|
|
629
|
+
*/
|
|
630
|
+
interface NoBreakHyphenContent {
|
|
631
|
+
type: 'noBreakHyphen';
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Drawing/image reference
|
|
635
|
+
*/
|
|
636
|
+
interface DrawingContent {
|
|
637
|
+
type: 'drawing';
|
|
638
|
+
/** Image data */
|
|
639
|
+
image: Image;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Shape reference
|
|
643
|
+
*/
|
|
644
|
+
interface ShapeContent {
|
|
645
|
+
type: 'shape';
|
|
646
|
+
/** Shape data */
|
|
647
|
+
shape: Shape;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* All possible run content types
|
|
651
|
+
*/
|
|
652
|
+
type RunContent = TextContent | TabContent | BreakContent | SymbolContent | NoteReferenceContent | FieldCharContent | InstrTextContent | SoftHyphenContent | NoBreakHyphenContent | DrawingContent | ShapeContent;
|
|
653
|
+
/**
|
|
654
|
+
* A run is a contiguous region of text with the same formatting
|
|
655
|
+
*/
|
|
656
|
+
interface Run {
|
|
657
|
+
type: 'run';
|
|
658
|
+
/** Text formatting properties */
|
|
659
|
+
formatting?: TextFormatting;
|
|
660
|
+
/** Run-level tracked property changes (w:rPrChange) */
|
|
661
|
+
propertyChanges?: RunPropertyChange[];
|
|
662
|
+
/** Run content (text, tabs, breaks, etc.) */
|
|
663
|
+
content: RunContent[];
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Hyperlink (w:hyperlink)
|
|
667
|
+
*/
|
|
668
|
+
interface Hyperlink {
|
|
669
|
+
type: 'hyperlink';
|
|
670
|
+
/** Relationship ID for external link */
|
|
671
|
+
rId?: string;
|
|
672
|
+
/** Resolved URL (from relationships) */
|
|
673
|
+
href?: string;
|
|
674
|
+
/** Internal bookmark anchor */
|
|
675
|
+
anchor?: string;
|
|
676
|
+
/** Tooltip text */
|
|
677
|
+
tooltip?: string;
|
|
678
|
+
/** Target frame */
|
|
679
|
+
target?: string;
|
|
680
|
+
/** Link history tracking */
|
|
681
|
+
history?: boolean;
|
|
682
|
+
/** Document location */
|
|
683
|
+
docLocation?: string;
|
|
684
|
+
/** Child runs */
|
|
685
|
+
children: (Run | BookmarkStart | BookmarkEnd)[];
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Bookmark start marker (w:bookmarkStart)
|
|
689
|
+
*/
|
|
690
|
+
interface BookmarkStart {
|
|
691
|
+
type: 'bookmarkStart';
|
|
692
|
+
/** Bookmark ID */
|
|
693
|
+
id: number;
|
|
694
|
+
/** Bookmark name */
|
|
695
|
+
name: string;
|
|
696
|
+
/** Column index for table bookmarks */
|
|
697
|
+
colFirst?: number;
|
|
698
|
+
colLast?: number;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Bookmark end marker (w:bookmarkEnd)
|
|
702
|
+
*/
|
|
703
|
+
interface BookmarkEnd {
|
|
704
|
+
type: 'bookmarkEnd';
|
|
705
|
+
/** Bookmark ID */
|
|
706
|
+
id: number;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Known field types
|
|
710
|
+
*/
|
|
711
|
+
type FieldType = 'PAGE' | 'NUMPAGES' | 'NUMWORDS' | 'NUMCHARS' | 'DATE' | 'TIME' | 'CREATEDATE' | 'SAVEDATE' | 'PRINTDATE' | 'AUTHOR' | 'TITLE' | 'SUBJECT' | 'KEYWORDS' | 'COMMENTS' | 'FILENAME' | 'FILESIZE' | 'TEMPLATE' | 'DOCPROPERTY' | 'DOCVARIABLE' | 'REF' | 'PAGEREF' | 'NOTEREF' | 'HYPERLINK' | 'TOC' | 'TOA' | 'INDEX' | 'SEQ' | 'STYLEREF' | 'AUTONUM' | 'AUTONUMLGL' | 'AUTONUMOUT' | 'IF' | 'MERGEFIELD' | 'NEXT' | 'NEXTIF' | 'ASK' | 'SET' | 'QUOTE' | 'INCLUDETEXT' | 'INCLUDEPICTURE' | 'SYMBOL' | 'ADVANCE' | 'EDITTIME' | 'REVNUM' | 'SECTION' | 'SECTIONPAGES' | 'USERADDRESS' | 'USERNAME' | 'USERINITIALS' | 'UNKNOWN';
|
|
712
|
+
/**
|
|
713
|
+
* Simple field (w:fldSimple)
|
|
714
|
+
*/
|
|
715
|
+
interface SimpleField {
|
|
716
|
+
type: 'simpleField';
|
|
717
|
+
/** Field instruction (e.g., "PAGE \\* MERGEFORMAT") */
|
|
718
|
+
instruction: string;
|
|
719
|
+
/** Parsed field type */
|
|
720
|
+
fieldType: FieldType;
|
|
721
|
+
/** Current display value */
|
|
722
|
+
content: (Run | Hyperlink)[];
|
|
723
|
+
/** Field is locked */
|
|
724
|
+
fldLock?: boolean;
|
|
725
|
+
/** Field is dirty */
|
|
726
|
+
dirty?: boolean;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Complex field (w:fldChar begin/separate/end with w:instrText)
|
|
730
|
+
*/
|
|
731
|
+
interface ComplexField {
|
|
732
|
+
type: 'complexField';
|
|
733
|
+
/** Field instruction */
|
|
734
|
+
instruction: string;
|
|
735
|
+
/** Parsed field type */
|
|
736
|
+
fieldType: FieldType;
|
|
737
|
+
/** Field code runs */
|
|
738
|
+
fieldCode: Run[];
|
|
739
|
+
/** Display result runs */
|
|
740
|
+
fieldResult: Run[];
|
|
741
|
+
/** Field is locked */
|
|
742
|
+
fldLock?: boolean;
|
|
743
|
+
/** Field is dirty */
|
|
744
|
+
dirty?: boolean;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Image size specification
|
|
748
|
+
*/
|
|
749
|
+
interface ImageSize {
|
|
750
|
+
/** Width in EMUs (English Metric Units) */
|
|
751
|
+
width: number;
|
|
752
|
+
/** Height in EMUs */
|
|
753
|
+
height: number;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Image wrap type for floating images
|
|
757
|
+
*/
|
|
758
|
+
interface ImageWrap {
|
|
759
|
+
type: 'inline' | 'square' | 'tight' | 'through' | 'topAndBottom' | 'behind' | 'inFront';
|
|
760
|
+
/** Wrap text direction */
|
|
761
|
+
wrapText?: 'bothSides' | 'left' | 'right' | 'largest';
|
|
762
|
+
/** Distance from text */
|
|
763
|
+
distT?: number;
|
|
764
|
+
distB?: number;
|
|
765
|
+
distL?: number;
|
|
766
|
+
distR?: number;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Position for floating images
|
|
770
|
+
*/
|
|
771
|
+
interface ImagePosition {
|
|
772
|
+
/** Horizontal positioning */
|
|
773
|
+
horizontal: {
|
|
774
|
+
relativeTo: 'character' | 'column' | 'insideMargin' | 'leftMargin' | 'margin' | 'outsideMargin' | 'page' | 'rightMargin';
|
|
775
|
+
alignment?: 'left' | 'right' | 'center' | 'inside' | 'outside';
|
|
776
|
+
posOffset?: number;
|
|
777
|
+
};
|
|
778
|
+
/** Vertical positioning */
|
|
779
|
+
vertical: {
|
|
780
|
+
relativeTo: 'insideMargin' | 'line' | 'margin' | 'outsideMargin' | 'page' | 'paragraph' | 'topMargin' | 'bottomMargin';
|
|
781
|
+
alignment?: 'top' | 'bottom' | 'center' | 'inside' | 'outside';
|
|
782
|
+
posOffset?: number;
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Image transformation
|
|
787
|
+
*/
|
|
788
|
+
interface ImageTransform {
|
|
789
|
+
/** Rotation in degrees */
|
|
790
|
+
rotation?: number;
|
|
791
|
+
/** Flip horizontal */
|
|
792
|
+
flipH?: boolean;
|
|
793
|
+
/** Flip vertical */
|
|
794
|
+
flipV?: boolean;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Image padding/margins
|
|
798
|
+
*/
|
|
799
|
+
interface ImagePadding {
|
|
800
|
+
top?: number;
|
|
801
|
+
bottom?: number;
|
|
802
|
+
left?: number;
|
|
803
|
+
right?: number;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Embedded image (w:drawing)
|
|
807
|
+
*/
|
|
808
|
+
interface Image {
|
|
809
|
+
type: 'image';
|
|
810
|
+
/** Unique ID */
|
|
811
|
+
id?: string;
|
|
812
|
+
/** Relationship ID for the image data */
|
|
813
|
+
rId: string;
|
|
814
|
+
/** Resolved image data (base64 or blob URL) */
|
|
815
|
+
src?: string;
|
|
816
|
+
/** Image MIME type */
|
|
817
|
+
mimeType?: string;
|
|
818
|
+
/** Original filename */
|
|
819
|
+
filename?: string;
|
|
820
|
+
/** Alt text for accessibility */
|
|
821
|
+
alt?: string;
|
|
822
|
+
/** Title/description */
|
|
823
|
+
title?: string;
|
|
824
|
+
/** Image size */
|
|
825
|
+
size: ImageSize;
|
|
826
|
+
/** Original size before any transforms */
|
|
827
|
+
originalSize?: ImageSize;
|
|
828
|
+
/** Wrap settings */
|
|
829
|
+
wrap: ImageWrap;
|
|
830
|
+
/** Position for floating images */
|
|
831
|
+
position?: ImagePosition;
|
|
832
|
+
/** Image transformations */
|
|
833
|
+
transform?: ImageTransform;
|
|
834
|
+
/** Padding around image */
|
|
835
|
+
padding?: ImagePadding;
|
|
836
|
+
/** Whether this is a decorative image */
|
|
837
|
+
decorative?: boolean;
|
|
838
|
+
/** Hyperlink URL for clickable image */
|
|
839
|
+
hlinkHref?: string;
|
|
840
|
+
/** Image outline/border */
|
|
841
|
+
outline?: ShapeOutline;
|
|
842
|
+
/** Image effects */
|
|
843
|
+
effects?: {
|
|
844
|
+
brightness?: number;
|
|
845
|
+
contrast?: number;
|
|
846
|
+
saturation?: number;
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Shape types
|
|
851
|
+
*/
|
|
852
|
+
type ShapeType = 'rect' | 'roundRect' | 'ellipse' | 'triangle' | 'rtTriangle' | 'parallelogram' | 'trapezoid' | 'pentagon' | 'hexagon' | 'heptagon' | 'octagon' | 'decagon' | 'dodecagon' | 'star4' | 'star5' | 'star6' | 'star7' | 'star8' | 'star10' | 'star12' | 'star16' | 'star24' | 'star32' | 'line' | 'straightConnector1' | 'bentConnector2' | 'bentConnector3' | 'bentConnector4' | 'bentConnector5' | 'curvedConnector2' | 'curvedConnector3' | 'curvedConnector4' | 'curvedConnector5' | 'rightArrow' | 'leftArrow' | 'upArrow' | 'downArrow' | 'leftRightArrow' | 'upDownArrow' | 'quadArrow' | 'leftRightUpArrow' | 'bentArrow' | 'uturnArrow' | 'leftUpArrow' | 'bentUpArrow' | 'curvedRightArrow' | 'curvedLeftArrow' | 'curvedUpArrow' | 'curvedDownArrow' | 'stripedRightArrow' | 'notchedRightArrow' | 'homePlate' | 'chevron' | 'rightArrowCallout' | 'downArrowCallout' | 'leftArrowCallout' | 'upArrowCallout' | 'leftRightArrowCallout' | 'quadArrowCallout' | 'circularArrow' | 'flowChartProcess' | 'flowChartAlternateProcess' | 'flowChartDecision' | 'flowChartInputOutput' | 'flowChartPredefinedProcess' | 'flowChartInternalStorage' | 'flowChartDocument' | 'flowChartMultidocument' | 'flowChartTerminator' | 'flowChartPreparation' | 'flowChartManualInput' | 'flowChartManualOperation' | 'flowChartConnector' | 'flowChartOffpageConnector' | 'flowChartPunchedCard' | 'flowChartPunchedTape' | 'flowChartSummingJunction' | 'flowChartOr' | 'flowChartCollate' | 'flowChartSort' | 'flowChartExtract' | 'flowChartMerge' | 'flowChartOnlineStorage' | 'flowChartDelay' | 'flowChartMagneticTape' | 'flowChartMagneticDisk' | 'flowChartMagneticDrum' | 'flowChartDisplay' | 'wedgeRectCallout' | 'wedgeRoundRectCallout' | 'wedgeEllipseCallout' | 'cloudCallout' | 'borderCallout1' | 'borderCallout2' | 'borderCallout3' | 'accentCallout1' | 'accentCallout2' | 'accentCallout3' | 'callout1' | 'callout2' | 'callout3' | 'accentBorderCallout1' | 'accentBorderCallout2' | 'accentBorderCallout3' | 'actionButtonBlank' | 'actionButtonHome' | 'actionButtonHelp' | 'actionButtonInformation' | 'actionButtonBackPrevious' | 'actionButtonForwardNext' | 'actionButtonBeginning' | 'actionButtonEnd' | 'actionButtonReturn' | 'actionButtonDocument' | 'actionButtonSound' | 'actionButtonMovie' | 'irregularSeal1' | 'irregularSeal2' | 'frame' | 'halfFrame' | 'corner' | 'diagStripe' | 'chord' | 'arc' | 'bracketPair' | 'bracePair' | 'leftBracket' | 'rightBracket' | 'leftBrace' | 'rightBrace' | 'can' | 'cube' | 'bevel' | 'donut' | 'noSmoking' | 'blockArc' | 'foldedCorner' | 'smileyFace' | 'heart' | 'lightningBolt' | 'sun' | 'moon' | 'cloud' | 'snip1Rect' | 'snip2SameRect' | 'snip2DiagRect' | 'snipRoundRect' | 'round1Rect' | 'round2SameRect' | 'round2DiagRect' | 'plaque' | 'teardrop' | 'mathPlus' | 'mathMinus' | 'mathMultiply' | 'mathDivide' | 'mathEqual' | 'mathNotEqual' | 'gear6' | 'gear9' | 'funnel' | 'pieWedge' | 'pie' | 'leftCircularArrow' | 'leftRightCircularArrow' | 'swooshArrow' | 'textBox';
|
|
853
|
+
/**
|
|
854
|
+
* Shape fill type
|
|
855
|
+
*/
|
|
856
|
+
interface ShapeFill {
|
|
857
|
+
type: 'none' | 'solid' | 'gradient' | 'pattern' | 'picture';
|
|
858
|
+
/** Solid fill color */
|
|
859
|
+
color?: ColorValue;
|
|
860
|
+
/** Gradient stops for gradient fill */
|
|
861
|
+
gradient?: {
|
|
862
|
+
type: 'linear' | 'radial' | 'rectangular' | 'path';
|
|
863
|
+
angle?: number;
|
|
864
|
+
stops: Array<{
|
|
865
|
+
position: number;
|
|
866
|
+
color: ColorValue;
|
|
867
|
+
}>;
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Shape outline/stroke
|
|
872
|
+
*/
|
|
873
|
+
interface ShapeOutline {
|
|
874
|
+
/** Line width in EMUs */
|
|
875
|
+
width?: number;
|
|
876
|
+
/** Line color */
|
|
877
|
+
color?: ColorValue;
|
|
878
|
+
/** Line style */
|
|
879
|
+
style?: 'solid' | 'dot' | 'dash' | 'lgDash' | 'dashDot' | 'lgDashDot' | 'lgDashDotDot' | 'sysDot' | 'sysDash' | 'sysDashDot' | 'sysDashDotDot';
|
|
880
|
+
/** Line cap */
|
|
881
|
+
cap?: 'flat' | 'round' | 'square';
|
|
882
|
+
/** Line join */
|
|
883
|
+
join?: 'bevel' | 'miter' | 'round';
|
|
884
|
+
/** Head arrow */
|
|
885
|
+
headEnd?: {
|
|
886
|
+
type: 'none' | 'triangle' | 'stealth' | 'diamond' | 'oval' | 'arrow';
|
|
887
|
+
width?: 'sm' | 'med' | 'lg';
|
|
888
|
+
length?: 'sm' | 'med' | 'lg';
|
|
889
|
+
};
|
|
890
|
+
/** Tail arrow */
|
|
891
|
+
tailEnd?: {
|
|
892
|
+
type: 'none' | 'triangle' | 'stealth' | 'diamond' | 'oval' | 'arrow';
|
|
893
|
+
width?: 'sm' | 'med' | 'lg';
|
|
894
|
+
length?: 'sm' | 'med' | 'lg';
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Text body inside a shape
|
|
899
|
+
*/
|
|
900
|
+
interface ShapeTextBody {
|
|
901
|
+
/** Text direction */
|
|
902
|
+
vertical?: boolean;
|
|
903
|
+
/** Rotation */
|
|
904
|
+
rotation?: number;
|
|
905
|
+
/** Anchor/vertical alignment */
|
|
906
|
+
anchor?: 'top' | 'middle' | 'bottom' | 'distributed' | 'justified';
|
|
907
|
+
/** Anchor center */
|
|
908
|
+
anchorCenter?: boolean;
|
|
909
|
+
/** Auto fit */
|
|
910
|
+
autoFit?: 'none' | 'normal' | 'shape';
|
|
911
|
+
/** Text margins */
|
|
912
|
+
margins?: {
|
|
913
|
+
top?: number;
|
|
914
|
+
bottom?: number;
|
|
915
|
+
left?: number;
|
|
916
|
+
right?: number;
|
|
917
|
+
};
|
|
918
|
+
/** Paragraphs inside the shape */
|
|
919
|
+
content: Paragraph[];
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Shape/drawing object (wps:wsp)
|
|
923
|
+
*/
|
|
924
|
+
interface Shape {
|
|
925
|
+
type: 'shape';
|
|
926
|
+
/** Shape type preset */
|
|
927
|
+
shapeType: ShapeType;
|
|
928
|
+
/** Unique ID */
|
|
929
|
+
id?: string;
|
|
930
|
+
/** Name */
|
|
931
|
+
name?: string;
|
|
932
|
+
/** Size in EMUs */
|
|
933
|
+
size: ImageSize;
|
|
934
|
+
/** Position for floating shapes */
|
|
935
|
+
position?: ImagePosition;
|
|
936
|
+
/** Wrap settings */
|
|
937
|
+
wrap?: ImageWrap;
|
|
938
|
+
/** Fill */
|
|
939
|
+
fill?: ShapeFill;
|
|
940
|
+
/** Outline/stroke */
|
|
941
|
+
outline?: ShapeOutline;
|
|
942
|
+
/** Transform */
|
|
943
|
+
transform?: ImageTransform;
|
|
944
|
+
/** Text content inside the shape */
|
|
945
|
+
textBody?: ShapeTextBody;
|
|
946
|
+
/** Custom geometry points */
|
|
947
|
+
customGeometry?: string;
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Table cell
|
|
951
|
+
*/
|
|
952
|
+
interface TableCell {
|
|
953
|
+
type: 'tableCell';
|
|
954
|
+
/** Cell formatting */
|
|
955
|
+
formatting?: TableCellFormatting;
|
|
956
|
+
/** Cell-level tracked property changes (w:tcPrChange) */
|
|
957
|
+
propertyChanges?: TableCellPropertyChange[];
|
|
958
|
+
/** Tracked structural changes (cell insert/delete/merge) */
|
|
959
|
+
structuralChange?: TableStructuralChangeInfo;
|
|
960
|
+
/** Cell content (paragraphs, tables, etc.) */
|
|
961
|
+
content: (Paragraph | Table)[];
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Table row
|
|
965
|
+
*/
|
|
966
|
+
interface TableRow {
|
|
967
|
+
type: 'tableRow';
|
|
968
|
+
/** Row formatting */
|
|
969
|
+
formatting?: TableRowFormatting;
|
|
970
|
+
/** Row-level tracked property changes (w:trPrChange) */
|
|
971
|
+
propertyChanges?: TableRowPropertyChange[];
|
|
972
|
+
/** Tracked structural changes (row insert/delete) */
|
|
973
|
+
structuralChange?: TableStructuralChangeInfo;
|
|
974
|
+
/** Cells in this row */
|
|
975
|
+
cells: TableCell[];
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Table (w:tbl)
|
|
979
|
+
*/
|
|
980
|
+
interface Table {
|
|
981
|
+
type: 'table';
|
|
982
|
+
/** Table formatting */
|
|
983
|
+
formatting?: TableFormatting;
|
|
984
|
+
/** Table-level tracked property changes (w:tblPrChange) */
|
|
985
|
+
propertyChanges?: TablePropertyChange[];
|
|
986
|
+
/** Column widths in twips */
|
|
987
|
+
columnWidths?: number[];
|
|
988
|
+
/** Table rows */
|
|
989
|
+
rows: TableRow[];
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* A comment (w:comment) from comments.xml
|
|
993
|
+
*/
|
|
994
|
+
interface Comment {
|
|
995
|
+
/** Comment ID (matches commentRangeStart/End) */
|
|
996
|
+
id: number;
|
|
997
|
+
/** Author name */
|
|
998
|
+
author: string;
|
|
999
|
+
/** Author initials */
|
|
1000
|
+
initials?: string;
|
|
1001
|
+
/** Date */
|
|
1002
|
+
date?: string;
|
|
1003
|
+
/** Comment content (paragraphs) */
|
|
1004
|
+
content: Paragraph[];
|
|
1005
|
+
/** Parent comment ID (for replies) */
|
|
1006
|
+
parentId?: number;
|
|
1007
|
+
/** Whether the comment is resolved/done */
|
|
1008
|
+
done?: boolean;
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Comment range start marker in paragraph content
|
|
1012
|
+
*/
|
|
1013
|
+
interface CommentRangeStart {
|
|
1014
|
+
type: 'commentRangeStart';
|
|
1015
|
+
id: number;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Comment range end marker in paragraph content
|
|
1019
|
+
*/
|
|
1020
|
+
interface CommentRangeEnd {
|
|
1021
|
+
type: 'commentRangeEnd';
|
|
1022
|
+
id: number;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Math equation content (m:oMath or m:oMathPara)
|
|
1026
|
+
*/
|
|
1027
|
+
interface MathEquation {
|
|
1028
|
+
type: 'mathEquation';
|
|
1029
|
+
/** Whether this is a block (oMathPara) or inline (oMath) equation */
|
|
1030
|
+
display: 'inline' | 'block';
|
|
1031
|
+
/** Raw OMML XML for round-trip preservation */
|
|
1032
|
+
ommlXml: string;
|
|
1033
|
+
/** Plain text representation for accessibility/fallback */
|
|
1034
|
+
plainText?: string;
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Tracked change metadata (w:ins, w:del attributes)
|
|
1038
|
+
*/
|
|
1039
|
+
interface TrackedChangeInfo {
|
|
1040
|
+
/** Revision ID */
|
|
1041
|
+
id: number;
|
|
1042
|
+
/** Author who made the change */
|
|
1043
|
+
author: string;
|
|
1044
|
+
/** Date of the change */
|
|
1045
|
+
date?: string;
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Generic tracked property-change wrapper metadata (w:*PrChange)
|
|
1049
|
+
*/
|
|
1050
|
+
interface PropertyChangeInfo extends TrackedChangeInfo {
|
|
1051
|
+
/** Optional revision session ID */
|
|
1052
|
+
rsid?: string;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Insertion wrapper (w:ins) — runs inserted by tracked changes
|
|
1056
|
+
*/
|
|
1057
|
+
interface Insertion {
|
|
1058
|
+
type: 'insertion';
|
|
1059
|
+
/** Tracked change metadata */
|
|
1060
|
+
info: TrackedChangeInfo;
|
|
1061
|
+
/** Inserted content */
|
|
1062
|
+
content: (Run | Hyperlink)[];
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Deletion wrapper (w:del) — runs deleted by tracked changes
|
|
1066
|
+
*/
|
|
1067
|
+
interface Deletion {
|
|
1068
|
+
type: 'deletion';
|
|
1069
|
+
/** Tracked change metadata */
|
|
1070
|
+
info: TrackedChangeInfo;
|
|
1071
|
+
/** Deleted content */
|
|
1072
|
+
content: (Run | Hyperlink)[];
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Move-from wrapper (w:moveFrom) — content moved away from this position
|
|
1076
|
+
*/
|
|
1077
|
+
interface MoveFrom {
|
|
1078
|
+
type: 'moveFrom';
|
|
1079
|
+
/** Tracked change metadata */
|
|
1080
|
+
info: TrackedChangeInfo;
|
|
1081
|
+
/** Moved content */
|
|
1082
|
+
content: (Run | Hyperlink)[];
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Move-to wrapper (w:moveTo) — content moved into this position
|
|
1086
|
+
*/
|
|
1087
|
+
interface MoveTo {
|
|
1088
|
+
type: 'moveTo';
|
|
1089
|
+
/** Tracked change metadata */
|
|
1090
|
+
info: TrackedChangeInfo;
|
|
1091
|
+
/** Moved content */
|
|
1092
|
+
content: (Run | Hyperlink)[];
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Move-from range start marker (w:moveFromRangeStart) — ECMA-376 §17.13.5.22
|
|
1096
|
+
* Pairs with moveFromRangeEnd to delimit the source of a move in the document.
|
|
1097
|
+
*/
|
|
1098
|
+
interface MoveFromRangeStart {
|
|
1099
|
+
type: 'moveFromRangeStart';
|
|
1100
|
+
id: number;
|
|
1101
|
+
name: string;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Move-from range end marker (w:moveFromRangeEnd)
|
|
1105
|
+
*/
|
|
1106
|
+
interface MoveFromRangeEnd {
|
|
1107
|
+
type: 'moveFromRangeEnd';
|
|
1108
|
+
id: number;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Move-to range start marker (w:moveToRangeStart) — ECMA-376 §17.13.5.24
|
|
1112
|
+
* Pairs with moveToRangeEnd to delimit the destination of a move.
|
|
1113
|
+
*/
|
|
1114
|
+
interface MoveToRangeStart {
|
|
1115
|
+
type: 'moveToRangeStart';
|
|
1116
|
+
id: number;
|
|
1117
|
+
name: string;
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Move-to range end marker (w:moveToRangeEnd)
|
|
1121
|
+
*/
|
|
1122
|
+
interface MoveToRangeEnd {
|
|
1123
|
+
type: 'moveToRangeEnd';
|
|
1124
|
+
id: number;
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Run property change (w:rPrChange)
|
|
1128
|
+
*/
|
|
1129
|
+
interface RunPropertyChange {
|
|
1130
|
+
type: 'runPropertyChange';
|
|
1131
|
+
/** Tracked change metadata */
|
|
1132
|
+
info: PropertyChangeInfo;
|
|
1133
|
+
/** Run properties before the tracked change */
|
|
1134
|
+
previousFormatting?: TextFormatting;
|
|
1135
|
+
/** Run properties after the tracked change (editor model convenience) */
|
|
1136
|
+
currentFormatting?: TextFormatting;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Paragraph property change (w:pPrChange)
|
|
1140
|
+
*/
|
|
1141
|
+
interface ParagraphPropertyChange {
|
|
1142
|
+
type: 'paragraphPropertyChange';
|
|
1143
|
+
/** Tracked change metadata */
|
|
1144
|
+
info: PropertyChangeInfo;
|
|
1145
|
+
/** Paragraph properties before the tracked change */
|
|
1146
|
+
previousFormatting?: ParagraphFormatting;
|
|
1147
|
+
/** Paragraph properties after the tracked change (editor model convenience) */
|
|
1148
|
+
currentFormatting?: ParagraphFormatting;
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Table property change (w:tblPrChange)
|
|
1152
|
+
*/
|
|
1153
|
+
interface TablePropertyChange {
|
|
1154
|
+
type: 'tablePropertyChange';
|
|
1155
|
+
/** Tracked change metadata */
|
|
1156
|
+
info: PropertyChangeInfo;
|
|
1157
|
+
/** Table properties before the tracked change */
|
|
1158
|
+
previousFormatting?: TableFormatting;
|
|
1159
|
+
/** Table properties after the tracked change (editor model convenience) */
|
|
1160
|
+
currentFormatting?: TableFormatting;
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Table row property change (w:trPrChange)
|
|
1164
|
+
*/
|
|
1165
|
+
interface TableRowPropertyChange {
|
|
1166
|
+
type: 'tableRowPropertyChange';
|
|
1167
|
+
/** Tracked change metadata */
|
|
1168
|
+
info: PropertyChangeInfo;
|
|
1169
|
+
/** Row properties before the tracked change */
|
|
1170
|
+
previousFormatting?: TableRowFormatting;
|
|
1171
|
+
/** Row properties after the tracked change (editor model convenience) */
|
|
1172
|
+
currentFormatting?: TableRowFormatting;
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Table cell property change (w:tcPrChange)
|
|
1176
|
+
*/
|
|
1177
|
+
interface TableCellPropertyChange {
|
|
1178
|
+
type: 'tableCellPropertyChange';
|
|
1179
|
+
/** Tracked change metadata */
|
|
1180
|
+
info: PropertyChangeInfo;
|
|
1181
|
+
/** Cell properties before the tracked change */
|
|
1182
|
+
previousFormatting?: TableCellFormatting;
|
|
1183
|
+
/** Cell properties after the tracked change (editor model convenience) */
|
|
1184
|
+
currentFormatting?: TableCellFormatting;
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Table structural tracked change metadata (row/cell insert/delete/merge)
|
|
1188
|
+
*/
|
|
1189
|
+
interface TableStructuralChangeInfo {
|
|
1190
|
+
type: 'tableRowInsertion' | 'tableRowDeletion' | 'tableCellInsertion' | 'tableCellDeletion' | 'tableCellMerge';
|
|
1191
|
+
/** Tracked change metadata */
|
|
1192
|
+
info: TrackedChangeInfo;
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* SDT type (content control type)
|
|
1196
|
+
*/
|
|
1197
|
+
type SdtType = 'richText' | 'plainText' | 'date' | 'dropdown' | 'comboBox' | 'checkbox' | 'picture' | 'buildingBlockGallery' | 'group' | 'unknown';
|
|
1198
|
+
/**
|
|
1199
|
+
* SDT properties (w:sdtPr)
|
|
1200
|
+
*/
|
|
1201
|
+
interface SdtProperties {
|
|
1202
|
+
/** SDT type */
|
|
1203
|
+
sdtType: SdtType;
|
|
1204
|
+
/** Alias (friendly name) */
|
|
1205
|
+
alias?: string;
|
|
1206
|
+
/** Tag (developer identifier) */
|
|
1207
|
+
tag?: string;
|
|
1208
|
+
/** Lock content editing */
|
|
1209
|
+
lock?: 'sdtLocked' | 'contentLocked' | 'sdtContentLocked' | 'unlocked';
|
|
1210
|
+
/** Placeholder text */
|
|
1211
|
+
placeholder?: string;
|
|
1212
|
+
/** Whether showing placeholder */
|
|
1213
|
+
showingPlaceholder?: boolean;
|
|
1214
|
+
/** Date format for date controls */
|
|
1215
|
+
dateFormat?: string;
|
|
1216
|
+
/** Dropdown/combobox list items */
|
|
1217
|
+
listItems?: {
|
|
1218
|
+
displayText: string;
|
|
1219
|
+
value: string;
|
|
1220
|
+
}[];
|
|
1221
|
+
/** Checkbox checked state */
|
|
1222
|
+
checked?: boolean;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Inline SDT (content control within a paragraph)
|
|
1226
|
+
*/
|
|
1227
|
+
interface InlineSdt {
|
|
1228
|
+
type: 'inlineSdt';
|
|
1229
|
+
/** SDT properties */
|
|
1230
|
+
properties: SdtProperties;
|
|
1231
|
+
/** Content runs inside the control */
|
|
1232
|
+
content: (Run | Hyperlink)[];
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Block-level SDT (content control wrapping paragraphs/tables)
|
|
1236
|
+
*/
|
|
1237
|
+
interface BlockSdt {
|
|
1238
|
+
type: 'blockSdt';
|
|
1239
|
+
/** SDT properties */
|
|
1240
|
+
properties: SdtProperties;
|
|
1241
|
+
/** Block content inside the control */
|
|
1242
|
+
content: (Paragraph | Table)[];
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Paragraph content types
|
|
1246
|
+
*/
|
|
1247
|
+
type ParagraphContent = Run | Hyperlink | BookmarkStart | BookmarkEnd | SimpleField | ComplexField | InlineSdt | CommentRangeStart | CommentRangeEnd | Insertion | Deletion | MoveFrom | MoveTo | MoveFromRangeStart | MoveFromRangeEnd | MoveToRangeStart | MoveToRangeEnd | MathEquation;
|
|
1248
|
+
/**
|
|
1249
|
+
* Paragraph (w:p)
|
|
1250
|
+
*/
|
|
1251
|
+
interface Paragraph {
|
|
1252
|
+
type: 'paragraph';
|
|
1253
|
+
/** Unique paragraph ID */
|
|
1254
|
+
paraId?: string;
|
|
1255
|
+
/** Text ID */
|
|
1256
|
+
textId?: string;
|
|
1257
|
+
/** Paragraph formatting */
|
|
1258
|
+
formatting?: ParagraphFormatting;
|
|
1259
|
+
/** Paragraph-level tracked property changes (w:pPrChange) */
|
|
1260
|
+
propertyChanges?: ParagraphPropertyChange[];
|
|
1261
|
+
/** Paragraph content */
|
|
1262
|
+
content: ParagraphContent[];
|
|
1263
|
+
/** Computed list rendering (if this is a list item) */
|
|
1264
|
+
listRendering?: ListRendering;
|
|
1265
|
+
/** Section properties (if this paragraph ends a section) */
|
|
1266
|
+
sectionProperties?: SectionProperties;
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Header/footer type
|
|
1270
|
+
*/
|
|
1271
|
+
type HeaderFooterType = 'default' | 'first' | 'even';
|
|
1272
|
+
/**
|
|
1273
|
+
* Header or footer reference
|
|
1274
|
+
*/
|
|
1275
|
+
interface HeaderReference {
|
|
1276
|
+
type: HeaderFooterType;
|
|
1277
|
+
rId: string;
|
|
1278
|
+
}
|
|
1279
|
+
interface FooterReference {
|
|
1280
|
+
type: HeaderFooterType;
|
|
1281
|
+
rId: string;
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Header or footer content
|
|
1285
|
+
*/
|
|
1286
|
+
interface HeaderFooter {
|
|
1287
|
+
type: 'header' | 'footer';
|
|
1288
|
+
/** Header/footer type */
|
|
1289
|
+
hdrFtrType: HeaderFooterType;
|
|
1290
|
+
/** Content (paragraphs, tables, etc.) */
|
|
1291
|
+
content: (Paragraph | Table)[];
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Footnote position
|
|
1295
|
+
*/
|
|
1296
|
+
type FootnotePosition = 'pageBottom' | 'beneathText' | 'sectEnd' | 'docEnd';
|
|
1297
|
+
/**
|
|
1298
|
+
* Endnote position
|
|
1299
|
+
*/
|
|
1300
|
+
type EndnotePosition = 'sectEnd' | 'docEnd';
|
|
1301
|
+
/**
|
|
1302
|
+
* Number restart type
|
|
1303
|
+
*/
|
|
1304
|
+
type NoteNumberRestart = 'continuous' | 'eachSect' | 'eachPage';
|
|
1305
|
+
/**
|
|
1306
|
+
* Footnote properties
|
|
1307
|
+
*/
|
|
1308
|
+
interface FootnoteProperties {
|
|
1309
|
+
position?: FootnotePosition;
|
|
1310
|
+
numFmt?: NumberFormat;
|
|
1311
|
+
numStart?: number;
|
|
1312
|
+
numRestart?: NoteNumberRestart;
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Endnote properties
|
|
1316
|
+
*/
|
|
1317
|
+
interface EndnoteProperties {
|
|
1318
|
+
position?: EndnotePosition;
|
|
1319
|
+
numFmt?: NumberFormat;
|
|
1320
|
+
numStart?: number;
|
|
1321
|
+
numRestart?: NoteNumberRestart;
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Footnote (w:footnote)
|
|
1325
|
+
*/
|
|
1326
|
+
interface Footnote {
|
|
1327
|
+
type: 'footnote';
|
|
1328
|
+
/** Footnote ID */
|
|
1329
|
+
id: number;
|
|
1330
|
+
/** Special footnote type */
|
|
1331
|
+
noteType?: 'normal' | 'separator' | 'continuationSeparator' | 'continuationNotice';
|
|
1332
|
+
/** Content */
|
|
1333
|
+
content: Paragraph[];
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Endnote (w:endnote)
|
|
1337
|
+
*/
|
|
1338
|
+
interface Endnote {
|
|
1339
|
+
type: 'endnote';
|
|
1340
|
+
/** Endnote ID */
|
|
1341
|
+
id: number;
|
|
1342
|
+
/** Special endnote type */
|
|
1343
|
+
noteType?: 'normal' | 'separator' | 'continuationSeparator' | 'continuationNotice';
|
|
1344
|
+
/** Content */
|
|
1345
|
+
content: Paragraph[];
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Page orientation
|
|
1349
|
+
*/
|
|
1350
|
+
type PageOrientation = 'portrait' | 'landscape';
|
|
1351
|
+
/**
|
|
1352
|
+
* Section start type
|
|
1353
|
+
*/
|
|
1354
|
+
type SectionStart = 'continuous' | 'nextPage' | 'oddPage' | 'evenPage' | 'nextColumn';
|
|
1355
|
+
/**
|
|
1356
|
+
* Vertical alignment
|
|
1357
|
+
*/
|
|
1358
|
+
type VerticalAlign = 'top' | 'center' | 'both' | 'bottom';
|
|
1359
|
+
/**
|
|
1360
|
+
* Line number restart type
|
|
1361
|
+
*/
|
|
1362
|
+
type LineNumberRestart = 'continuous' | 'newPage' | 'newSection';
|
|
1363
|
+
/**
|
|
1364
|
+
* Column definition
|
|
1365
|
+
*/
|
|
1366
|
+
interface Column {
|
|
1367
|
+
/** Column width in twips */
|
|
1368
|
+
width?: number;
|
|
1369
|
+
/** Space after column in twips */
|
|
1370
|
+
space?: number;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Section properties (w:sectPr)
|
|
1374
|
+
*/
|
|
1375
|
+
interface SectionProperties {
|
|
1376
|
+
/** Page width in twips */
|
|
1377
|
+
pageWidth?: number;
|
|
1378
|
+
/** Page height in twips */
|
|
1379
|
+
pageHeight?: number;
|
|
1380
|
+
/** Page orientation */
|
|
1381
|
+
orientation?: PageOrientation;
|
|
1382
|
+
/** Top margin in twips */
|
|
1383
|
+
marginTop?: number;
|
|
1384
|
+
/** Bottom margin in twips */
|
|
1385
|
+
marginBottom?: number;
|
|
1386
|
+
/** Left margin in twips */
|
|
1387
|
+
marginLeft?: number;
|
|
1388
|
+
/** Right margin in twips */
|
|
1389
|
+
marginRight?: number;
|
|
1390
|
+
/** Header distance from top in twips */
|
|
1391
|
+
headerDistance?: number;
|
|
1392
|
+
/** Footer distance from bottom in twips */
|
|
1393
|
+
footerDistance?: number;
|
|
1394
|
+
/** Gutter margin in twips */
|
|
1395
|
+
gutter?: number;
|
|
1396
|
+
/** Number of columns */
|
|
1397
|
+
columnCount?: number;
|
|
1398
|
+
/** Space between columns in twips */
|
|
1399
|
+
columnSpace?: number;
|
|
1400
|
+
/** Equal width columns */
|
|
1401
|
+
equalWidth?: boolean;
|
|
1402
|
+
/** Separator line between columns */
|
|
1403
|
+
separator?: boolean;
|
|
1404
|
+
/** Individual column definitions */
|
|
1405
|
+
columns?: Column[];
|
|
1406
|
+
/** Section start type */
|
|
1407
|
+
sectionStart?: SectionStart;
|
|
1408
|
+
/** Vertical alignment of text */
|
|
1409
|
+
verticalAlign?: VerticalAlign;
|
|
1410
|
+
/** Right-to-left section */
|
|
1411
|
+
bidi?: boolean;
|
|
1412
|
+
/** Header references */
|
|
1413
|
+
headerReferences?: HeaderReference[];
|
|
1414
|
+
/** Footer references */
|
|
1415
|
+
footerReferences?: FooterReference[];
|
|
1416
|
+
/** Different first page header/footer */
|
|
1417
|
+
titlePg?: boolean;
|
|
1418
|
+
/** Different odd/even page headers/footers */
|
|
1419
|
+
evenAndOddHeaders?: boolean;
|
|
1420
|
+
/** Line numbering settings */
|
|
1421
|
+
lineNumbers?: {
|
|
1422
|
+
start?: number;
|
|
1423
|
+
countBy?: number;
|
|
1424
|
+
distance?: number;
|
|
1425
|
+
restart?: LineNumberRestart;
|
|
1426
|
+
};
|
|
1427
|
+
/** Page borders */
|
|
1428
|
+
pageBorders?: {
|
|
1429
|
+
top?: BorderSpec;
|
|
1430
|
+
bottom?: BorderSpec;
|
|
1431
|
+
left?: BorderSpec;
|
|
1432
|
+
right?: BorderSpec;
|
|
1433
|
+
/** Display setting */
|
|
1434
|
+
display?: 'allPages' | 'firstPage' | 'notFirstPage';
|
|
1435
|
+
/** Offset from */
|
|
1436
|
+
offsetFrom?: 'page' | 'text';
|
|
1437
|
+
/** Z-order */
|
|
1438
|
+
zOrder?: 'front' | 'back';
|
|
1439
|
+
};
|
|
1440
|
+
/** Page background */
|
|
1441
|
+
background?: {
|
|
1442
|
+
color?: ColorValue;
|
|
1443
|
+
themeColor?: ThemeColorSlot;
|
|
1444
|
+
themeTint?: string;
|
|
1445
|
+
themeShade?: string;
|
|
1446
|
+
};
|
|
1447
|
+
/** Footnote properties for this section */
|
|
1448
|
+
footnotePr?: FootnoteProperties;
|
|
1449
|
+
/** Endnote properties for this section */
|
|
1450
|
+
endnotePr?: EndnoteProperties;
|
|
1451
|
+
/** Document grid */
|
|
1452
|
+
docGrid?: {
|
|
1453
|
+
type?: 'default' | 'lines' | 'linesAndChars' | 'snapToChars';
|
|
1454
|
+
linePitch?: number;
|
|
1455
|
+
charSpace?: number;
|
|
1456
|
+
};
|
|
1457
|
+
/** First page paper source */
|
|
1458
|
+
paperSrcFirst?: number;
|
|
1459
|
+
/** Other pages paper source */
|
|
1460
|
+
paperSrcOther?: number;
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Block-level content types
|
|
1464
|
+
*/
|
|
1465
|
+
type BlockContent = Paragraph | Table | BlockSdt;
|
|
1466
|
+
/**
|
|
1467
|
+
* Section (implicit or explicit based on sectPr)
|
|
1468
|
+
*/
|
|
1469
|
+
interface Section {
|
|
1470
|
+
/** Section properties */
|
|
1471
|
+
properties: SectionProperties;
|
|
1472
|
+
/** Content in this section */
|
|
1473
|
+
content: BlockContent[];
|
|
1474
|
+
/** Headers for this section */
|
|
1475
|
+
headers?: Map<HeaderFooterType, HeaderFooter>;
|
|
1476
|
+
/** Footers for this section */
|
|
1477
|
+
footers?: Map<HeaderFooterType, HeaderFooter>;
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Document body (w:body)
|
|
1481
|
+
*/
|
|
1482
|
+
interface DocumentBody {
|
|
1483
|
+
/** All content (paragraphs, tables) */
|
|
1484
|
+
content: BlockContent[];
|
|
1485
|
+
/** Sections (derived from sectPr in paragraphs and final sectPr) */
|
|
1486
|
+
sections?: Section[];
|
|
1487
|
+
/** Final section properties (from body's sectPr) */
|
|
1488
|
+
finalSectionProperties?: SectionProperties;
|
|
1489
|
+
/** Comments from comments.xml */
|
|
1490
|
+
comments?: Comment[];
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Styles, Theme, Font Table, Relationships & Media Types
|
|
1495
|
+
*
|
|
1496
|
+
* Types for document-level definitions that don't form the content tree.
|
|
1497
|
+
*/
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* Style type
|
|
1501
|
+
*/
|
|
1502
|
+
type StyleType = 'paragraph' | 'character' | 'numbering' | 'table';
|
|
1503
|
+
/**
|
|
1504
|
+
* Style definition
|
|
1505
|
+
*/
|
|
1506
|
+
interface Style {
|
|
1507
|
+
/** Style ID */
|
|
1508
|
+
styleId: string;
|
|
1509
|
+
/** Style type */
|
|
1510
|
+
type: StyleType;
|
|
1511
|
+
/** Display name */
|
|
1512
|
+
name?: string;
|
|
1513
|
+
/** Based on style ID */
|
|
1514
|
+
basedOn?: string;
|
|
1515
|
+
/** Next style after Enter (for paragraph styles) */
|
|
1516
|
+
next?: string;
|
|
1517
|
+
/** Linked style (paragraph/character pair) */
|
|
1518
|
+
link?: string;
|
|
1519
|
+
/** UI sort priority */
|
|
1520
|
+
uiPriority?: number;
|
|
1521
|
+
/** Hidden from UI */
|
|
1522
|
+
hidden?: boolean;
|
|
1523
|
+
/** Semi-hidden from UI */
|
|
1524
|
+
semiHidden?: boolean;
|
|
1525
|
+
/** Unhide when used */
|
|
1526
|
+
unhideWhenUsed?: boolean;
|
|
1527
|
+
/** Quick format in gallery */
|
|
1528
|
+
qFormat?: boolean;
|
|
1529
|
+
/** Is default style */
|
|
1530
|
+
default?: boolean;
|
|
1531
|
+
/** Personal style (custom) */
|
|
1532
|
+
personal?: boolean;
|
|
1533
|
+
/** Paragraph properties (for paragraph/table styles) */
|
|
1534
|
+
pPr?: ParagraphFormatting;
|
|
1535
|
+
/** Run properties */
|
|
1536
|
+
rPr?: TextFormatting;
|
|
1537
|
+
/** Table properties (for table styles) */
|
|
1538
|
+
tblPr?: TableFormatting;
|
|
1539
|
+
/** Table row properties */
|
|
1540
|
+
trPr?: TableRowFormatting;
|
|
1541
|
+
/** Table cell properties */
|
|
1542
|
+
tcPr?: TableCellFormatting;
|
|
1543
|
+
/** Conditional table style parts */
|
|
1544
|
+
tblStylePr?: Array<{
|
|
1545
|
+
type: 'band1Horz' | 'band1Vert' | 'band2Horz' | 'band2Vert' | 'firstCol' | 'firstRow' | 'lastCol' | 'lastRow' | 'neCell' | 'nwCell' | 'seCell' | 'swCell';
|
|
1546
|
+
pPr?: ParagraphFormatting;
|
|
1547
|
+
rPr?: TextFormatting;
|
|
1548
|
+
tblPr?: TableFormatting;
|
|
1549
|
+
trPr?: TableRowFormatting;
|
|
1550
|
+
tcPr?: TableCellFormatting;
|
|
1551
|
+
}>;
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Document defaults (w:docDefaults)
|
|
1555
|
+
*/
|
|
1556
|
+
interface DocDefaults {
|
|
1557
|
+
/** Default run properties */
|
|
1558
|
+
rPr?: TextFormatting;
|
|
1559
|
+
/** Default paragraph properties */
|
|
1560
|
+
pPr?: ParagraphFormatting;
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Style definitions from styles.xml
|
|
1564
|
+
*/
|
|
1565
|
+
interface StyleDefinitions {
|
|
1566
|
+
/** Document defaults */
|
|
1567
|
+
docDefaults?: DocDefaults;
|
|
1568
|
+
/** Latent styles */
|
|
1569
|
+
latentStyles?: {
|
|
1570
|
+
defLockedState?: boolean;
|
|
1571
|
+
defUIPriority?: number;
|
|
1572
|
+
defSemiHidden?: boolean;
|
|
1573
|
+
defUnhideWhenUsed?: boolean;
|
|
1574
|
+
defQFormat?: boolean;
|
|
1575
|
+
count?: number;
|
|
1576
|
+
};
|
|
1577
|
+
/** Style definitions */
|
|
1578
|
+
styles: Style[];
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* Theme color scheme (a:clrScheme)
|
|
1582
|
+
*/
|
|
1583
|
+
interface ThemeColorScheme {
|
|
1584
|
+
/** Dark 1 color (usually black) */
|
|
1585
|
+
dk1?: string;
|
|
1586
|
+
/** Light 1 color (usually white) */
|
|
1587
|
+
lt1?: string;
|
|
1588
|
+
/** Dark 2 color */
|
|
1589
|
+
dk2?: string;
|
|
1590
|
+
/** Light 2 color */
|
|
1591
|
+
lt2?: string;
|
|
1592
|
+
/** Accent colors 1-6 */
|
|
1593
|
+
accent1?: string;
|
|
1594
|
+
accent2?: string;
|
|
1595
|
+
accent3?: string;
|
|
1596
|
+
accent4?: string;
|
|
1597
|
+
accent5?: string;
|
|
1598
|
+
accent6?: string;
|
|
1599
|
+
/** Hyperlink color */
|
|
1600
|
+
hlink?: string;
|
|
1601
|
+
/** Followed hyperlink color */
|
|
1602
|
+
folHlink?: string;
|
|
1603
|
+
}
|
|
1604
|
+
/**
|
|
1605
|
+
* Theme font (with script variants)
|
|
1606
|
+
*/
|
|
1607
|
+
interface ThemeFont {
|
|
1608
|
+
/** Latin font */
|
|
1609
|
+
latin?: string;
|
|
1610
|
+
/** East Asian font */
|
|
1611
|
+
ea?: string;
|
|
1612
|
+
/** Complex script font */
|
|
1613
|
+
cs?: string;
|
|
1614
|
+
/** Script-specific fonts */
|
|
1615
|
+
fonts?: Record<string, string>;
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Theme font scheme (a:fontScheme)
|
|
1619
|
+
*/
|
|
1620
|
+
interface ThemeFontScheme {
|
|
1621
|
+
/** Major font (headings) */
|
|
1622
|
+
majorFont?: ThemeFont;
|
|
1623
|
+
/** Minor font (body text) */
|
|
1624
|
+
minorFont?: ThemeFont;
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Theme (from theme1.xml)
|
|
1628
|
+
*/
|
|
1629
|
+
interface Theme {
|
|
1630
|
+
/** Theme name */
|
|
1631
|
+
name?: string;
|
|
1632
|
+
/** Color scheme */
|
|
1633
|
+
colorScheme?: ThemeColorScheme;
|
|
1634
|
+
/** Font scheme */
|
|
1635
|
+
fontScheme?: ThemeFontScheme;
|
|
1636
|
+
/** Format scheme (fills, lines, effects) - simplified */
|
|
1637
|
+
formatScheme?: {
|
|
1638
|
+
name?: string;
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Font info from fontTable.xml
|
|
1643
|
+
*/
|
|
1644
|
+
interface FontInfo {
|
|
1645
|
+
/** Font name */
|
|
1646
|
+
name: string;
|
|
1647
|
+
/** Alternate names */
|
|
1648
|
+
altName?: string;
|
|
1649
|
+
/** Panose-1 classification */
|
|
1650
|
+
panose1?: string;
|
|
1651
|
+
/** Character set */
|
|
1652
|
+
charset?: string;
|
|
1653
|
+
/** Font family type */
|
|
1654
|
+
family?: 'decorative' | 'modern' | 'roman' | 'script' | 'swiss' | 'auto';
|
|
1655
|
+
/** Pitch (fixed or variable) */
|
|
1656
|
+
pitch?: 'default' | 'fixed' | 'variable';
|
|
1657
|
+
/** Signature */
|
|
1658
|
+
sig?: {
|
|
1659
|
+
usb0?: string;
|
|
1660
|
+
usb1?: string;
|
|
1661
|
+
usb2?: string;
|
|
1662
|
+
usb3?: string;
|
|
1663
|
+
csb0?: string;
|
|
1664
|
+
csb1?: string;
|
|
1665
|
+
};
|
|
1666
|
+
/** Embedded font data reference */
|
|
1667
|
+
embedRegular?: string;
|
|
1668
|
+
embedBold?: string;
|
|
1669
|
+
embedItalic?: string;
|
|
1670
|
+
embedBoldItalic?: string;
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* Font table from fontTable.xml
|
|
1674
|
+
*/
|
|
1675
|
+
interface FontTable {
|
|
1676
|
+
fonts: FontInfo[];
|
|
1677
|
+
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Relationship type
|
|
1680
|
+
*/
|
|
1681
|
+
type RelationshipType = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/header' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart' | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData' | string;
|
|
1682
|
+
/**
|
|
1683
|
+
* Relationship entry
|
|
1684
|
+
*/
|
|
1685
|
+
interface Relationship {
|
|
1686
|
+
/** Relationship ID (e.g., "rId1") */
|
|
1687
|
+
id: string;
|
|
1688
|
+
/** Relationship type URI */
|
|
1689
|
+
type: RelationshipType;
|
|
1690
|
+
/** Target path or URL */
|
|
1691
|
+
target: string;
|
|
1692
|
+
/** Target mode */
|
|
1693
|
+
targetMode?: 'External' | 'Internal';
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Relationship map (keyed by rId)
|
|
1697
|
+
*/
|
|
1698
|
+
type RelationshipMap = Map<string, Relationship>;
|
|
1699
|
+
/**
|
|
1700
|
+
* Media file from word/media/
|
|
1701
|
+
*/
|
|
1702
|
+
interface MediaFile {
|
|
1703
|
+
/** File path in ZIP */
|
|
1704
|
+
path: string;
|
|
1705
|
+
/** Original filename */
|
|
1706
|
+
filename?: string;
|
|
1707
|
+
/** MIME type */
|
|
1708
|
+
mimeType: string;
|
|
1709
|
+
/** Binary data */
|
|
1710
|
+
data: ArrayBuffer;
|
|
1711
|
+
/** Base64 encoded data for rendering */
|
|
1712
|
+
base64?: string;
|
|
1713
|
+
/** Data URL for direct use in src attributes */
|
|
1714
|
+
dataUrl?: string;
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
/**
|
|
1718
|
+
* Comprehensive TypeScript types for full DOCX document representation
|
|
1719
|
+
*
|
|
1720
|
+
* This barrel file re-exports all types from the split modules.
|
|
1721
|
+
* Existing imports from './types/document' continue to work unchanged.
|
|
1722
|
+
*
|
|
1723
|
+
* Module structure:
|
|
1724
|
+
* - colors.ts — Color primitives, borders, shading
|
|
1725
|
+
* - formatting.ts — Text, paragraph, and table formatting properties
|
|
1726
|
+
* - lists.ts — Numbering and list definitions
|
|
1727
|
+
* - content.ts — Content model (runs, images, shapes, tables, paragraphs, sections)
|
|
1728
|
+
* - styles.ts — Styles, theme, fonts, relationships, media
|
|
1729
|
+
*/
|
|
1730
|
+
|
|
1731
|
+
/**
|
|
1732
|
+
* Complete DOCX package structure
|
|
1733
|
+
*/
|
|
1734
|
+
interface DocxPackage {
|
|
1735
|
+
/** Document body */
|
|
1736
|
+
document: DocumentBody;
|
|
1737
|
+
/** Style definitions */
|
|
1738
|
+
styles?: StyleDefinitions;
|
|
1739
|
+
/** Theme */
|
|
1740
|
+
theme?: Theme;
|
|
1741
|
+
/** Numbering definitions */
|
|
1742
|
+
numbering?: NumberingDefinitions;
|
|
1743
|
+
/** Font table */
|
|
1744
|
+
fontTable?: FontTable;
|
|
1745
|
+
/** Footnotes */
|
|
1746
|
+
footnotes?: Footnote[];
|
|
1747
|
+
/** Endnotes */
|
|
1748
|
+
endnotes?: Endnote[];
|
|
1749
|
+
/** Headers by relationship ID */
|
|
1750
|
+
headers?: Map<string, HeaderFooter>;
|
|
1751
|
+
/** Footers by relationship ID */
|
|
1752
|
+
footers?: Map<string, HeaderFooter>;
|
|
1753
|
+
/** Document relationships */
|
|
1754
|
+
relationships?: RelationshipMap;
|
|
1755
|
+
/** Media files */
|
|
1756
|
+
media?: Map<string, MediaFile>;
|
|
1757
|
+
/** Document properties */
|
|
1758
|
+
properties?: {
|
|
1759
|
+
title?: string;
|
|
1760
|
+
subject?: string;
|
|
1761
|
+
creator?: string;
|
|
1762
|
+
keywords?: string;
|
|
1763
|
+
description?: string;
|
|
1764
|
+
lastModifiedBy?: string;
|
|
1765
|
+
revision?: number;
|
|
1766
|
+
created?: Date;
|
|
1767
|
+
modified?: Date;
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Complete parsed DOCX document
|
|
1772
|
+
*/
|
|
1773
|
+
interface Document {
|
|
1774
|
+
/** DOCX package with all parsed content */
|
|
1775
|
+
package: DocxPackage;
|
|
1776
|
+
/** Original ArrayBuffer for round-trip */
|
|
1777
|
+
originalBuffer?: ArrayBuffer;
|
|
1778
|
+
/** Detected template variables ({{...}}) */
|
|
1779
|
+
templateVariables?: string[];
|
|
1780
|
+
/** Parsing warnings/errors */
|
|
1781
|
+
warnings?: string[];
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
/**
|
|
1785
|
+
* Types for @eigenpal/docx-editor-agents
|
|
1786
|
+
*/
|
|
1787
|
+
interface HeadingBlock {
|
|
1788
|
+
type: 'heading';
|
|
1789
|
+
index: number;
|
|
1790
|
+
/** Stable Word `w14:paraId`. Use this as the anchor for live-editor operations. */
|
|
1791
|
+
paraId?: string;
|
|
1792
|
+
level: number;
|
|
1793
|
+
text: string;
|
|
1794
|
+
}
|
|
1795
|
+
interface ParagraphBlock {
|
|
1796
|
+
type: 'paragraph';
|
|
1797
|
+
index: number;
|
|
1798
|
+
/** Stable Word `w14:paraId`. Use this as the anchor for live-editor operations. */
|
|
1799
|
+
paraId?: string;
|
|
1800
|
+
text: string;
|
|
1801
|
+
}
|
|
1802
|
+
interface TableBlock {
|
|
1803
|
+
type: 'table';
|
|
1804
|
+
index: number;
|
|
1805
|
+
rows: string[][];
|
|
1806
|
+
/** Per-cell paraIds, parallel to `rows`. cells[r][c] is the first paraId in that cell. */
|
|
1807
|
+
cellParaIds?: (string | undefined)[][];
|
|
1808
|
+
}
|
|
1809
|
+
interface ListItemBlock {
|
|
1810
|
+
type: 'list-item';
|
|
1811
|
+
index: number;
|
|
1812
|
+
/** Stable Word `w14:paraId`. Use this as the anchor for live-editor operations. */
|
|
1813
|
+
paraId?: string;
|
|
1814
|
+
text: string;
|
|
1815
|
+
listLevel: number;
|
|
1816
|
+
listType: 'bullet' | 'number';
|
|
1817
|
+
}
|
|
1818
|
+
type ContentBlock = HeadingBlock | ParagraphBlock | TableBlock | ListItemBlock;
|
|
1819
|
+
interface GetContentOptions {
|
|
1820
|
+
fromIndex?: number;
|
|
1821
|
+
toIndex?: number;
|
|
1822
|
+
/** Annotate tracked changes inline. Default: true */
|
|
1823
|
+
includeTrackedChanges?: boolean;
|
|
1824
|
+
/** Annotate comments inline. Default: true */
|
|
1825
|
+
includeCommentAnchors?: boolean;
|
|
1826
|
+
}
|
|
1827
|
+
interface ReviewChange {
|
|
1828
|
+
id: number;
|
|
1829
|
+
type: 'insertion' | 'deletion' | 'moveFrom' | 'moveTo';
|
|
1830
|
+
author: string;
|
|
1831
|
+
date: string | null;
|
|
1832
|
+
text: string;
|
|
1833
|
+
context: string;
|
|
1834
|
+
paragraphIndex: number;
|
|
1835
|
+
}
|
|
1836
|
+
interface ReviewCommentReply {
|
|
1837
|
+
id: number;
|
|
1838
|
+
author: string;
|
|
1839
|
+
date: string | null;
|
|
1840
|
+
text: string;
|
|
1841
|
+
}
|
|
1842
|
+
interface ReviewComment {
|
|
1843
|
+
id: number;
|
|
1844
|
+
author: string;
|
|
1845
|
+
date: string | null;
|
|
1846
|
+
text: string;
|
|
1847
|
+
anchoredText: string;
|
|
1848
|
+
paragraphIndex: number;
|
|
1849
|
+
replies: ReviewCommentReply[];
|
|
1850
|
+
done: boolean;
|
|
1851
|
+
}
|
|
1852
|
+
interface ChangeFilter {
|
|
1853
|
+
author?: string;
|
|
1854
|
+
type?: 'insertion' | 'deletion' | 'moveFrom' | 'moveTo';
|
|
1855
|
+
}
|
|
1856
|
+
interface CommentFilter {
|
|
1857
|
+
author?: string;
|
|
1858
|
+
done?: boolean;
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Live-editor (bridge) action options — anchored by Word `w14:paraId`.
|
|
1862
|
+
* Stable across edits; the agent gets paraIds from `read_document` / `find_text`.
|
|
1863
|
+
*/
|
|
1864
|
+
interface AddCommentByParaIdOptions {
|
|
1865
|
+
paraId: string;
|
|
1866
|
+
text: string;
|
|
1867
|
+
author?: string;
|
|
1868
|
+
/** Optional: anchor to a specific phrase within the paragraph (must be unique). */
|
|
1869
|
+
search?: string;
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Headless / DocxReviewer action options — anchored by ordinal paragraph index.
|
|
1873
|
+
* Used by the static-document review pipeline.
|
|
1874
|
+
*/
|
|
1875
|
+
interface AddCommentOptions {
|
|
1876
|
+
paragraphIndex: number;
|
|
1877
|
+
text: string;
|
|
1878
|
+
author?: string;
|
|
1879
|
+
/** Optional: anchor to specific text. Omit to anchor whole paragraph. */
|
|
1880
|
+
search?: string;
|
|
1881
|
+
}
|
|
1882
|
+
interface ReplyOptions {
|
|
1883
|
+
text: string;
|
|
1884
|
+
author?: string;
|
|
1885
|
+
}
|
|
1886
|
+
/**
|
|
1887
|
+
* Live-editor change. Pass `replaceWith: ''` to delete; pass `search: ''` to
|
|
1888
|
+
* insert at end of paragraph; pass both non-empty for a replacement.
|
|
1889
|
+
*/
|
|
1890
|
+
interface ProposeChangeOptions {
|
|
1891
|
+
paraId: string;
|
|
1892
|
+
search: string;
|
|
1893
|
+
replaceWith: string;
|
|
1894
|
+
author?: string;
|
|
1895
|
+
}
|
|
1896
|
+
interface ProposeReplacementOptions {
|
|
1897
|
+
paragraphIndex: number;
|
|
1898
|
+
search: string;
|
|
1899
|
+
replaceWith: string;
|
|
1900
|
+
author?: string;
|
|
1901
|
+
}
|
|
1902
|
+
interface ProposeInsertionOptions {
|
|
1903
|
+
paragraphIndex: number;
|
|
1904
|
+
insertText: string;
|
|
1905
|
+
author?: string;
|
|
1906
|
+
position?: 'before' | 'after';
|
|
1907
|
+
search?: string;
|
|
1908
|
+
}
|
|
1909
|
+
interface ProposeDeletionOptions {
|
|
1910
|
+
paragraphIndex: number;
|
|
1911
|
+
search: string;
|
|
1912
|
+
author?: string;
|
|
1913
|
+
}
|
|
1914
|
+
/** Per-match handle returned by `findText` — pass `paraId` + `match` back as `search`. */
|
|
1915
|
+
interface FoundMatch {
|
|
1916
|
+
paraId: string;
|
|
1917
|
+
match: string;
|
|
1918
|
+
before: string;
|
|
1919
|
+
after: string;
|
|
1920
|
+
}
|
|
1921
|
+
/** Snapshot of the user's current selection / cursor. */
|
|
1922
|
+
interface SelectionInfo {
|
|
1923
|
+
paraId: string | null;
|
|
1924
|
+
selectedText: string;
|
|
1925
|
+
paragraphText: string;
|
|
1926
|
+
before: string;
|
|
1927
|
+
after: string;
|
|
1928
|
+
}
|
|
1929
|
+
/**
|
|
1930
|
+
* Character formatting marks the agent can apply.
|
|
1931
|
+
*
|
|
1932
|
+
* Mirrors Word JS API `Range.font.*`. A `false` value clears that mark in the
|
|
1933
|
+
* range; a missing key leaves it untouched. `color.themeColor` follows ECMA-376
|
|
1934
|
+
* theme color values (e.g. `'accent1'`, `'text1'`) and resolves at render time.
|
|
1935
|
+
*/
|
|
1936
|
+
interface CharacterFormatting {
|
|
1937
|
+
bold?: boolean;
|
|
1938
|
+
italic?: boolean;
|
|
1939
|
+
underline?: boolean | {
|
|
1940
|
+
style?: string;
|
|
1941
|
+
};
|
|
1942
|
+
strike?: boolean;
|
|
1943
|
+
color?: {
|
|
1944
|
+
rgb?: string;
|
|
1945
|
+
themeColor?: string;
|
|
1946
|
+
};
|
|
1947
|
+
highlight?: string;
|
|
1948
|
+
fontSize?: number;
|
|
1949
|
+
fontFamily?: {
|
|
1950
|
+
ascii?: string;
|
|
1951
|
+
hAnsi?: string;
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
/**
|
|
1955
|
+
* Apply character formatting to a range. `paraId` is required; if `search`
|
|
1956
|
+
* is provided, the formatting only applies to that phrase within the
|
|
1957
|
+
* paragraph (must match exactly once). Otherwise it applies to the whole
|
|
1958
|
+
* paragraph's text.
|
|
1959
|
+
*/
|
|
1960
|
+
interface ApplyFormattingOptions {
|
|
1961
|
+
paraId: string;
|
|
1962
|
+
search?: string;
|
|
1963
|
+
marks: CharacterFormatting;
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* Apply a paragraph style by `styleId` (e.g. `'Heading1'`, `'Title'`,
|
|
1967
|
+
* `'Quote'`). The styleId must exist in the document's style definitions
|
|
1968
|
+
* — unknown ids are no-ops.
|
|
1969
|
+
*/
|
|
1970
|
+
interface SetParagraphStyleOptions {
|
|
1971
|
+
paraId: string;
|
|
1972
|
+
styleId: string;
|
|
1973
|
+
}
|
|
1974
|
+
/** A single paragraph anchored on a page (returned by `getPage` / `getPages`). */
|
|
1975
|
+
interface PageParagraph {
|
|
1976
|
+
paraId: string;
|
|
1977
|
+
text: string;
|
|
1978
|
+
/** True for headings, list items, and other styled blocks. */
|
|
1979
|
+
styleId?: string;
|
|
1980
|
+
}
|
|
1981
|
+
/** What the agent sees when reading one or more pages. */
|
|
1982
|
+
interface PageContent {
|
|
1983
|
+
/** 1-indexed page number. */
|
|
1984
|
+
pageNumber: number;
|
|
1985
|
+
/** Plain text of the page, formatted as `[paraId] text` lines. */
|
|
1986
|
+
text: string;
|
|
1987
|
+
/** Paragraphs on the page, in document order. */
|
|
1988
|
+
paragraphs: PageParagraph[];
|
|
1989
|
+
}
|
|
1990
|
+
/**
|
|
1991
|
+
* Snapshot of what the user is looking at — pass this to your agent's system
|
|
1992
|
+
* prompt so it knows the current selection / page without an extra
|
|
1993
|
+
* `read_selection` round-trip.
|
|
1994
|
+
*/
|
|
1995
|
+
interface AgentContextSnapshot {
|
|
1996
|
+
/** User's current selection or cursor (null if editor isn't focused). */
|
|
1997
|
+
selection: SelectionInfo | null;
|
|
1998
|
+
/** 1-indexed page the cursor / selection is on. 0 if unknown. */
|
|
1999
|
+
currentPage: number;
|
|
2000
|
+
/** Total number of pages currently rendered. */
|
|
2001
|
+
totalPages: number;
|
|
2002
|
+
}
|
|
2003
|
+
interface BatchReviewOptions {
|
|
2004
|
+
accept?: number[];
|
|
2005
|
+
reject?: number[];
|
|
2006
|
+
comments?: AddCommentOptions[];
|
|
2007
|
+
replies?: (ReplyOptions & {
|
|
2008
|
+
commentId: number;
|
|
2009
|
+
})[];
|
|
2010
|
+
proposals?: ProposeReplacementOptions[];
|
|
2011
|
+
}
|
|
2012
|
+
interface BatchError {
|
|
2013
|
+
operation: string;
|
|
2014
|
+
id?: number;
|
|
2015
|
+
search?: string;
|
|
2016
|
+
error: string;
|
|
2017
|
+
}
|
|
2018
|
+
interface BatchResult {
|
|
2019
|
+
accepted: number;
|
|
2020
|
+
rejected: number;
|
|
2021
|
+
commentsAdded: number;
|
|
2022
|
+
repliesAdded: number;
|
|
2023
|
+
proposalsAdded: number;
|
|
2024
|
+
errors: BatchError[];
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
/**
|
|
2028
|
+
* DocxReviewer — Word-like API for AI document review.
|
|
2029
|
+
*
|
|
2030
|
+
* @example
|
|
2031
|
+
* ```ts
|
|
2032
|
+
* const reviewer = await DocxReviewer.fromBuffer(buffer, 'AI Reviewer');
|
|
2033
|
+
* const text = reviewer.getContentAsText();
|
|
2034
|
+
* reviewer.addComment(5, 'Fix this paragraph.');
|
|
2035
|
+
* reviewer.replace(5, '$50k', '$500k');
|
|
2036
|
+
* const output = await reviewer.toBuffer();
|
|
2037
|
+
* ```
|
|
2038
|
+
*/
|
|
2039
|
+
|
|
2040
|
+
declare class DocxReviewer {
|
|
2041
|
+
private doc;
|
|
2042
|
+
/** Default author for comments and tracked changes. Set once, used everywhere. */
|
|
2043
|
+
readonly author: string;
|
|
2044
|
+
/**
|
|
2045
|
+
* Create a reviewer from a parsed Document.
|
|
2046
|
+
* @param document - Parsed Document from @eigenpal/docx-core
|
|
2047
|
+
* @param author - Default author name for comments and changes. (default: 'AI')
|
|
2048
|
+
* @param originalBuffer - Original DOCX buffer, needed for toBuffer()
|
|
2049
|
+
*/
|
|
2050
|
+
constructor(document: Document, author?: string, originalBuffer?: ArrayBuffer);
|
|
2051
|
+
/**
|
|
2052
|
+
* Create a reviewer from a DOCX file buffer.
|
|
2053
|
+
* @param buffer - ArrayBuffer of the DOCX file
|
|
2054
|
+
* @param author - Default author name for comments and changes. (default: 'AI')
|
|
2055
|
+
*/
|
|
2056
|
+
static fromBuffer(buffer: ArrayBuffer, author?: string): Promise<DocxReviewer>;
|
|
2057
|
+
private get body();
|
|
2058
|
+
private resolveAuthor;
|
|
2059
|
+
/** Get document content as structured blocks (headings, paragraphs, tables, lists). */
|
|
2060
|
+
getContent(options?: GetContentOptions): ContentBlock[];
|
|
2061
|
+
/**
|
|
2062
|
+
* Get document content as plain text for LLM prompts.
|
|
2063
|
+
* Each paragraph is prefixed with its index: `[0] text`, `[1] text`, etc.
|
|
2064
|
+
* Table cells include position: `[5] (table, row 1, col 2) cell text`.
|
|
2065
|
+
* Avoids JSON quote-escaping issues — LLMs can copy text verbatim.
|
|
2066
|
+
*/
|
|
2067
|
+
getContentAsText(options?: GetContentOptions): string;
|
|
2068
|
+
/** Get all tracked changes in the document. */
|
|
2069
|
+
getChanges(filter?: ChangeFilter): ReviewChange[];
|
|
2070
|
+
/** Get all comments with their replies. */
|
|
2071
|
+
getComments(filter?: CommentFilter): ReviewComment[];
|
|
2072
|
+
/**
|
|
2073
|
+
* Add a comment on a paragraph.
|
|
2074
|
+
* @param paragraphIndex - Index of the paragraph to comment on
|
|
2075
|
+
* @param text - Comment text
|
|
2076
|
+
* @returns The new comment ID
|
|
2077
|
+
*/
|
|
2078
|
+
addComment(paragraphIndex: number, text: string): number;
|
|
2079
|
+
/**
|
|
2080
|
+
* Add a comment with full options (custom author, anchored to specific text).
|
|
2081
|
+
* @param options - Comment options
|
|
2082
|
+
* @returns The new comment ID
|
|
2083
|
+
*/
|
|
2084
|
+
addComment(options: AddCommentOptions): number;
|
|
2085
|
+
/**
|
|
2086
|
+
* Reply to an existing comment.
|
|
2087
|
+
* @param commentId - ID of the comment to reply to
|
|
2088
|
+
* @param text - Reply text
|
|
2089
|
+
* @returns The new reply comment ID
|
|
2090
|
+
*/
|
|
2091
|
+
replyTo(commentId: number, text: string): number;
|
|
2092
|
+
/** Reply to an existing comment with full options. */
|
|
2093
|
+
replyTo(commentId: number, options: ReplyOptions): number;
|
|
2094
|
+
/**
|
|
2095
|
+
* Remove a comment by ID. Removing a top-level comment also removes its
|
|
2096
|
+
* replies and the anchored range markers. Removing a reply only removes
|
|
2097
|
+
* that reply.
|
|
2098
|
+
* @param commentId - ID of the comment to remove
|
|
2099
|
+
*/
|
|
2100
|
+
removeComment(commentId: number): void;
|
|
2101
|
+
/**
|
|
2102
|
+
* Replace text in a paragraph. Creates a tracked change (deletion + insertion).
|
|
2103
|
+
* @param paragraphIndex - Index of the paragraph
|
|
2104
|
+
* @param search - Short phrase to find within the paragraph
|
|
2105
|
+
* @param replaceWith - Replacement text
|
|
2106
|
+
*/
|
|
2107
|
+
replace(paragraphIndex: number, search: string, replaceWith: string): void;
|
|
2108
|
+
/** Replace text with full options. */
|
|
2109
|
+
replace(options: ProposeReplacementOptions): void;
|
|
2110
|
+
/** @deprecated Use replace() instead. */
|
|
2111
|
+
proposeReplacement(options: ProposeReplacementOptions): void;
|
|
2112
|
+
/** Insert text as a tracked change. */
|
|
2113
|
+
proposeInsertion(options: ProposeInsertionOptions): void;
|
|
2114
|
+
/** Delete text as a tracked change. */
|
|
2115
|
+
proposeDeletion(options: ProposeDeletionOptions): void;
|
|
2116
|
+
/** Accept a tracked change by its revision ID. */
|
|
2117
|
+
acceptChange(id: number): void;
|
|
2118
|
+
/** Reject a tracked change by its revision ID. */
|
|
2119
|
+
rejectChange(id: number): void;
|
|
2120
|
+
/** Accept all tracked changes. Returns count accepted. */
|
|
2121
|
+
acceptAll(): number;
|
|
2122
|
+
/** Reject all tracked changes. Returns count rejected. */
|
|
2123
|
+
rejectAll(): number;
|
|
2124
|
+
/**
|
|
2125
|
+
* Apply multiple review operations in one call.
|
|
2126
|
+
* Uses the reviewer's default author. Individual failures are collected, not thrown.
|
|
2127
|
+
*/
|
|
2128
|
+
applyReview(ops: BatchReviewOptions): BatchResult;
|
|
2129
|
+
/** Get the modified Document model. */
|
|
2130
|
+
toDocument(): Document;
|
|
2131
|
+
/** Serialize back to a DOCX buffer. Requires the original buffer. */
|
|
2132
|
+
toBuffer(): Promise<ArrayBuffer>;
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
/**
|
|
2136
|
+
* useAgentChat — React hook that wires agent tools to a live DocxEditor.
|
|
2137
|
+
*
|
|
2138
|
+
* @example
|
|
2139
|
+
* ```tsx
|
|
2140
|
+
* import { useAgentChat } from '@eigenpal/docx-editor-agents/bridge';
|
|
2141
|
+
*
|
|
2142
|
+
* const { executeToolCall, toolSchemas } = useAgentChat({ editorRef, author: 'Assistant' });
|
|
2143
|
+
*
|
|
2144
|
+
* // Pass toolSchemas to your AI provider, execute tool calls on the client
|
|
2145
|
+
* const result = executeToolCall('add_comment', { paragraphIndex: 3, text: 'Fix this.' });
|
|
2146
|
+
* ```
|
|
2147
|
+
*/
|
|
2148
|
+
|
|
2149
|
+
interface UseAgentChatOptions {
|
|
2150
|
+
/** Reference to the DocxEditor (must match EditorRefLike interface). */
|
|
2151
|
+
editorRef: React.RefObject<EditorRefLike | null>;
|
|
2152
|
+
/** Default author name for comments and changes. Default: 'AI' */
|
|
2153
|
+
author?: string;
|
|
2154
|
+
}
|
|
2155
|
+
interface UseAgentChatReturn {
|
|
2156
|
+
/** Execute a tool call through the bridge. */
|
|
2157
|
+
executeToolCall: (toolName: string, input: Record<string, unknown>) => AgentToolResult;
|
|
2158
|
+
/** Tool schemas in OpenAI function calling format. Pass to your AI provider. */
|
|
2159
|
+
toolSchemas: ReturnType<typeof getToolSchemas>;
|
|
2160
|
+
}
|
|
2161
|
+
/**
|
|
2162
|
+
* Hook that creates an EditorBridge and provides tool execution.
|
|
2163
|
+
*/
|
|
2164
|
+
declare function useAgentChat(options: UseAgentChatOptions): UseAgentChatReturn;
|
|
2165
|
+
|
|
2166
|
+
/**
|
|
2167
|
+
* Reviewer bridge — wraps a `DocxReviewer` (static document) in the same
|
|
2168
|
+
* `EditorBridge` interface the live editor exposes. Lets the same MCP server
|
|
2169
|
+
* / agent tools operate on a parsed-from-disk DOCX without a running editor.
|
|
2170
|
+
*
|
|
2171
|
+
* Trade-offs vs. the live bridge:
|
|
2172
|
+
* - `getSelection()` always returns `null` (no user, no selection).
|
|
2173
|
+
* - `scrollTo()` is a no-op that returns `true` (the doc isn't being viewed).
|
|
2174
|
+
* - `onSelectionChange` listeners never fire (returned unsubscribers are no-ops).
|
|
2175
|
+
* - `onContentChange` fires after every successful mutation through this bridge,
|
|
2176
|
+
* so MCP clients still get notifications when the agent is the only writer.
|
|
2177
|
+
* - paraId resolution maps to `paragraphIndex` by walking the document body
|
|
2178
|
+
* once. None of the reviewer's mutators (`addComment`, `proposeChange`,
|
|
2179
|
+
* `replyTo`, `resolveComment`) shift top-level indices, so the map is
|
|
2180
|
+
* cached for the bridge's lifetime.
|
|
2181
|
+
*
|
|
2182
|
+
* After the agent finishes mutating, call `reviewer.toBuffer()` to serialize
|
|
2183
|
+
* back to DOCX. The bridge does NOT do that automatically — the host decides
|
|
2184
|
+
* when to flush.
|
|
2185
|
+
*/
|
|
2186
|
+
|
|
2187
|
+
/**
|
|
2188
|
+
* Create an EditorBridge backed by a DocxReviewer. The agent (or MCP client)
|
|
2189
|
+
* can read, comment, propose changes, etc., against a parsed DOCX file on
|
|
2190
|
+
* disk. Call `reviewer.toBuffer()` afterwards to get the modified DOCX.
|
|
2191
|
+
*
|
|
2192
|
+
* @param reviewer - A DocxReviewer instance. The bridge mutates it in place.
|
|
2193
|
+
*/
|
|
2194
|
+
declare function createReviewerBridge(reviewer: DocxReviewer): EditorBridge;
|
|
2195
|
+
|
|
2196
|
+
/**
|
|
2197
|
+
* Minimal DocxEditorRef interface — only the methods the bridge needs.
|
|
2198
|
+
* This avoids importing the full React package at type level.
|
|
2199
|
+
*/
|
|
2200
|
+
interface EditorRefLike {
|
|
2201
|
+
getDocument(): unknown | null;
|
|
2202
|
+
getEditorRef(): {
|
|
2203
|
+
getDocument(): unknown | null;
|
|
2204
|
+
} | null;
|
|
2205
|
+
addComment(options: {
|
|
2206
|
+
paraId: string;
|
|
2207
|
+
text: string;
|
|
2208
|
+
author: string;
|
|
2209
|
+
search?: string;
|
|
2210
|
+
}): number | null;
|
|
2211
|
+
replyToComment(commentId: number, text: string, author: string): number | null;
|
|
2212
|
+
resolveComment(commentId: number): void;
|
|
2213
|
+
proposeChange(options: {
|
|
2214
|
+
paraId: string;
|
|
2215
|
+
search: string;
|
|
2216
|
+
replaceWith: string;
|
|
2217
|
+
author: string;
|
|
2218
|
+
}): boolean;
|
|
2219
|
+
scrollToParaId(paraId: string): boolean;
|
|
2220
|
+
findInDocument(query: string, options?: {
|
|
2221
|
+
caseSensitive?: boolean;
|
|
2222
|
+
limit?: number;
|
|
2223
|
+
}): FoundMatch[];
|
|
2224
|
+
getSelectionInfo(): SelectionInfo | null;
|
|
2225
|
+
getComments(): Array<{
|
|
2226
|
+
id: number;
|
|
2227
|
+
author: string;
|
|
2228
|
+
date?: string;
|
|
2229
|
+
parentId?: number;
|
|
2230
|
+
content: unknown[];
|
|
2231
|
+
done?: boolean;
|
|
2232
|
+
}>;
|
|
2233
|
+
/** Apply character formatting to a paragraph or sub-range. Returns false on missing paraId / ambiguous search. */
|
|
2234
|
+
applyFormatting(options: {
|
|
2235
|
+
paraId: string;
|
|
2236
|
+
search?: string;
|
|
2237
|
+
marks: CharacterFormatting;
|
|
2238
|
+
}): boolean;
|
|
2239
|
+
/** Apply a paragraph style by styleId. Returns false if paraId is unknown. */
|
|
2240
|
+
setParagraphStyle(options: {
|
|
2241
|
+
paraId: string;
|
|
2242
|
+
styleId: string;
|
|
2243
|
+
}): boolean;
|
|
2244
|
+
/** Read a single page's paragraphs (1-indexed). Returns null if the page does not exist. */
|
|
2245
|
+
getPageContent(pageNumber: number): PageContent | null;
|
|
2246
|
+
/** Total number of pages currently rendered. */
|
|
2247
|
+
getTotalPages(): number;
|
|
2248
|
+
/** 1-indexed page the user's cursor / selection is on. 0 if unknown. */
|
|
2249
|
+
getCurrentPage(): number;
|
|
2250
|
+
onContentChange(listener: (doc: unknown) => void): () => void;
|
|
2251
|
+
onSelectionChange(listener: (selection: unknown) => void): () => void;
|
|
2252
|
+
}
|
|
2253
|
+
interface EditorBridge {
|
|
2254
|
+
/** Get document content as paraId-tagged text lines for LLM prompts. */
|
|
2255
|
+
getContentAsText(options?: GetContentOptions): string;
|
|
2256
|
+
/** Get document content as structured blocks (each paragraph carries its `paraId`). */
|
|
2257
|
+
getContent(options?: GetContentOptions): ContentBlock[];
|
|
2258
|
+
/** Get all comments in the document. */
|
|
2259
|
+
getComments(filter?: CommentFilter): ReviewComment[];
|
|
2260
|
+
/** Get all tracked changes in the document. */
|
|
2261
|
+
getChanges(filter?: ChangeFilter): ReviewChange[];
|
|
2262
|
+
/** Locate text in the document. Returns one handle per matching paragraph. */
|
|
2263
|
+
findText(query: string, options?: {
|
|
2264
|
+
caseSensitive?: boolean;
|
|
2265
|
+
limit?: number;
|
|
2266
|
+
}): FoundMatch[];
|
|
2267
|
+
/** Read the user's current cursor / selection. */
|
|
2268
|
+
getSelection(): SelectionInfo | null;
|
|
2269
|
+
/** Add a comment, anchored to a paragraph by paraId. */
|
|
2270
|
+
addComment(options: AddCommentByParaIdOptions): number | null;
|
|
2271
|
+
/** Reply to an existing comment. Returns the reply ID or null. */
|
|
2272
|
+
replyTo(commentId: number, options: ReplyOptions): number | null;
|
|
2273
|
+
/** Resolve a comment (mark as done). */
|
|
2274
|
+
resolveComment(commentId: number): void;
|
|
2275
|
+
/** Suggest a tracked change. `replaceWith=''` deletes; `search=''` inserts at paragraph end. */
|
|
2276
|
+
proposeChange(options: ProposeChangeOptions): boolean;
|
|
2277
|
+
/**
|
|
2278
|
+
* Apply character formatting (bold / italic / color / size / font / etc.)
|
|
2279
|
+
* to a paragraph, or to a unique phrase within it. This is a direct edit —
|
|
2280
|
+
* not a tracked change.
|
|
2281
|
+
*/
|
|
2282
|
+
applyFormatting(options: ApplyFormattingOptions): boolean;
|
|
2283
|
+
/**
|
|
2284
|
+
* Apply a paragraph style by styleId (e.g. `'Heading1'`, `'Quote'`).
|
|
2285
|
+
* Direct edit, not a tracked change.
|
|
2286
|
+
*/
|
|
2287
|
+
setParagraphStyle(options: SetParagraphStyleOptions): boolean;
|
|
2288
|
+
/** Read a single page (1-indexed). Returns null if the page does not exist. */
|
|
2289
|
+
getPage(pageNumber: number): PageContent | null;
|
|
2290
|
+
/** Read a range of pages (1-indexed, inclusive). Out-of-range pages are skipped. */
|
|
2291
|
+
getPages(options: {
|
|
2292
|
+
from: number;
|
|
2293
|
+
to: number;
|
|
2294
|
+
}): PageContent[];
|
|
2295
|
+
/** Total number of pages currently rendered in the editor. */
|
|
2296
|
+
getTotalPages(): number;
|
|
2297
|
+
/** 1-indexed page the user's cursor / selection is on. 0 if unknown. */
|
|
2298
|
+
getCurrentPage(): number;
|
|
2299
|
+
/** Scroll the editor to a paragraph by paraId. */
|
|
2300
|
+
scrollTo(paraId: string): boolean;
|
|
2301
|
+
/** Subscribe to document content changes. Returns an unsubscribe function. */
|
|
2302
|
+
onContentChange(listener: (event: ContentChangeEvent) => void): () => void;
|
|
2303
|
+
/** Subscribe to selection changes (cursor moves / selection changes). Returns an unsubscribe function. */
|
|
2304
|
+
onSelectionChange(listener: (event: SelectionChangeEvent) => void): () => void;
|
|
2305
|
+
}
|
|
2306
|
+
/** Event payload for `onContentChange`. */
|
|
2307
|
+
interface ContentChangeEvent {
|
|
2308
|
+
/** Total comments in the document after the change. */
|
|
2309
|
+
commentCount: number;
|
|
2310
|
+
/** Total tracked changes after the change. */
|
|
2311
|
+
changeCount: number;
|
|
2312
|
+
/** Snapshot of all current comments. */
|
|
2313
|
+
comments: ReviewComment[];
|
|
2314
|
+
/** Snapshot of all current tracked changes. */
|
|
2315
|
+
changes: ReviewChange[];
|
|
2316
|
+
}
|
|
2317
|
+
/** Event payload for `onSelectionChange`. */
|
|
2318
|
+
type SelectionChangeEvent = SelectionInfo | null;
|
|
2319
|
+
/**
|
|
2320
|
+
* Create an EditorBridge from a DocxEditorRef.
|
|
2321
|
+
*
|
|
2322
|
+
* @param editorRef - A DocxEditorRef (or anything matching EditorRefLike)
|
|
2323
|
+
* @param author - Default author name for comments and changes. (default: 'AI')
|
|
2324
|
+
*/
|
|
2325
|
+
declare function createEditorBridge(editorRef: EditorRefLike, author?: string): EditorBridge;
|
|
2326
|
+
|
|
2327
|
+
/**
|
|
2328
|
+
* Agent tool type definitions.
|
|
2329
|
+
*/
|
|
2330
|
+
|
|
2331
|
+
interface AgentToolDefinition<TInput = Record<string, unknown>> {
|
|
2332
|
+
/** Tool name (used in tool_use blocks) */
|
|
2333
|
+
name: string;
|
|
2334
|
+
/**
|
|
2335
|
+
* Friendly UI label for the tool. Shown in the agent panel's timeline
|
|
2336
|
+
* (e.g. "Reading document"). Falls back to a sentence-case version of
|
|
2337
|
+
* `name` if omitted, so consumer-defined tools render readably without
|
|
2338
|
+
* specifying this.
|
|
2339
|
+
*/
|
|
2340
|
+
displayName?: string;
|
|
2341
|
+
/** Human-readable description for the LLM */
|
|
2342
|
+
description: string;
|
|
2343
|
+
/** JSON Schema for the input parameters */
|
|
2344
|
+
inputSchema: Record<string, unknown>;
|
|
2345
|
+
/** Handler — receives parsed input + bridge, returns result */
|
|
2346
|
+
handler: (input: TInput, bridge: EditorBridge) => AgentToolResult;
|
|
2347
|
+
}
|
|
2348
|
+
interface AgentToolResult {
|
|
2349
|
+
success: boolean;
|
|
2350
|
+
data?: unknown;
|
|
2351
|
+
error?: string;
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
/**
|
|
2355
|
+
* Agent tool definitions and execution.
|
|
2356
|
+
*
|
|
2357
|
+
* Tools use OpenAI function-calling format. The pattern mirrors Word's JS API:
|
|
2358
|
+
* locate first (`read_document` / `find_text` / `read_selection` return paraId
|
|
2359
|
+
* handles), then mutate (`comment` / `suggest_change` / `reply_comment` /
|
|
2360
|
+
* `resolve_comment` / `scroll`). paraId anchors are stable across edits.
|
|
2361
|
+
*/
|
|
2362
|
+
|
|
2363
|
+
/** All built-in agent tools. */
|
|
2364
|
+
declare const agentTools: AgentToolDefinition<any>[];
|
|
2365
|
+
/**
|
|
2366
|
+
* Execute a tool call against an EditorBridge.
|
|
2367
|
+
* Returns the result (never throws).
|
|
2368
|
+
*/
|
|
2369
|
+
declare function executeToolCall(toolName: string, input: Record<string, unknown>, bridge: EditorBridge): AgentToolResult;
|
|
2370
|
+
/**
|
|
2371
|
+
* Friendly UI label for a tool — sourced from the registry's `displayName`,
|
|
2372
|
+
* falling back to a sentence-case version of the snake_case name. Used by
|
|
2373
|
+
* `<AgentTimeline>` and any other UI that lists running / completed tools.
|
|
2374
|
+
*
|
|
2375
|
+
* @example getToolDisplayName('add_comment') // → 'Adding comment'
|
|
2376
|
+
* @example getToolDisplayName('fetch_clause_template') // → 'Fetch clause template'
|
|
2377
|
+
*/
|
|
2378
|
+
declare function getToolDisplayName(name: string): string;
|
|
2379
|
+
/**
|
|
2380
|
+
* Get tool schemas in OpenAI function-calling format. Works directly
|
|
2381
|
+
* with the OpenAI SDK and Anthropic's tools API. For Vercel AI SDK,
|
|
2382
|
+
* LangChain, or other agent runtimes, transform this output to that
|
|
2383
|
+
* runtime's required shape — see `examples/agent-chat-demo/` for a
|
|
2384
|
+
* Vercel AI SDK example. The package stays runtime-agnostic.
|
|
2385
|
+
*/
|
|
2386
|
+
declare function getToolSchemas(): {
|
|
2387
|
+
type: "function";
|
|
2388
|
+
function: {
|
|
2389
|
+
name: string;
|
|
2390
|
+
description: string;
|
|
2391
|
+
parameters: Record<string, unknown>;
|
|
2392
|
+
};
|
|
2393
|
+
}[];
|
|
2394
|
+
|
|
2395
|
+
export { type AgentToolDefinition as A, type BatchError as B, type ContentBlock as C, DocxReviewer as D, type EditorRefLike as E, type FoundMatch as F, type GetContentOptions as G, type ProposeChangeOptions as P, type ReviewComment as R, type SelectionInfo as S, type UseAgentChatOptions as U, type AgentToolResult as a, type AgentContextSnapshot as b, type UseAgentChatReturn as c, getToolDisplayName as d, type CommentFilter as e, type ChangeFilter as f, getToolSchemas as g, type ReviewChange as h, type AddCommentByParaIdOptions as i, type ReplyOptions as j, type ApplyFormattingOptions as k, type SetParagraphStyleOptions as l, type PageContent as m, type ContentChangeEvent as n, type SelectionChangeEvent as o, type BatchResult as p, type BatchReviewOptions as q, agentTools as r, createReviewerBridge as s, executeToolCall as t, useAgentChat as u, type EditorBridge as v, createEditorBridge as w };
|