wordinweb 0.1.22 → 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 +21 -2
- package/dist/chunk-XGTWJMDG.js +38208 -0
- package/dist/chunk-XGTWJMDG.js.map +1 -0
- package/dist/collab.d.ts +1281 -0
- package/dist/collab.js +4909 -0
- package/dist/collab.js.map +1 -0
- package/dist/index-C2J9egkh.d.ts +4314 -0
- package/dist/index.d.ts +2 -2401
- package/dist/index.js +13 -35778
- package/dist/index.js.map +1 -1
- package/package.json +13 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,2401 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Minimal, fast XML parser producing a lightweight element tree.
|
|
5
|
-
*
|
|
6
|
-
* OOXML parts are machine-generated, namespace-prefixed, well-formed XML with
|
|
7
|
-
* no DTDs. This parser handles exactly that subset: elements, attributes,
|
|
8
|
-
* text, CDATA, comments, processing instructions, and the built-in + numeric
|
|
9
|
-
* character entities. Namespace prefixes are kept verbatim (`w:p`), and
|
|
10
|
-
* lookups match on either the full name or the local name, which is robust
|
|
11
|
-
* for every mainstream producer (Word, LibreOffice, Google Docs export).
|
|
12
|
-
*/
|
|
13
|
-
interface XmlElement {
|
|
14
|
-
name: string;
|
|
15
|
-
attrs: Record<string, string>;
|
|
16
|
-
children: XmlElement[];
|
|
17
|
-
/** Concatenated character data directly inside this element. */
|
|
18
|
-
text: string;
|
|
19
|
-
/** Editor placeholder retained in memory but omitted from XML while empty. */
|
|
20
|
-
omitWhenEmpty?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Typed document model produced by the parser and consumed by the layout
|
|
25
|
-
* engine. All lengths are CSS px (see units.ts) unless a field name says
|
|
26
|
-
* otherwise. Property bags are Partial-style: `undefined` means "not set at
|
|
27
|
-
* this level" so the style-inheritance merge can distinguish absence from an
|
|
28
|
-
* explicit value.
|
|
29
|
-
*
|
|
30
|
-
* Model nodes keep `src` references to the XML elements they were parsed
|
|
31
|
-
* from: the XML tree is the source of truth for editing — commands mutate it
|
|
32
|
-
* and the model is re-derived, which preserves round-trip fidelity for
|
|
33
|
-
* everything untouched.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
type BorderStyle = "none" | "single" | "double" | "dotted" | "dashed" | "thick" | "wave" | "dotDash" | "dotDotDash" | "thinThickSmallGap" | "triple";
|
|
37
|
-
interface Border {
|
|
38
|
-
style: BorderStyle;
|
|
39
|
-
/** Stroke width in px. */
|
|
40
|
-
width: number;
|
|
41
|
-
/** CSS color. */
|
|
42
|
-
color: string;
|
|
43
|
-
/** Gap between border and content in px (w:space, points in OOXML). */
|
|
44
|
-
space: number;
|
|
45
|
-
/** Declared stroke width in px BEFORE the 0.75px paint floor (w:sz/8 pt).
|
|
46
|
-
* Word's LAYOUT math (table row border share) uses this true width — a
|
|
47
|
-
* sz-4 rule contributes 0.5pt, not the floored 0.5625pt (phase23 p66:
|
|
48
|
-
* 45 rows drift 2.5px down without it). */
|
|
49
|
-
rawWidth?: number;
|
|
50
|
-
}
|
|
51
|
-
interface ParagraphBorders {
|
|
52
|
-
top?: Border;
|
|
53
|
-
bottom?: Border;
|
|
54
|
-
left?: Border;
|
|
55
|
-
right?: Border;
|
|
56
|
-
/** Drawn between consecutive paragraphs that both specify it. */
|
|
57
|
-
between?: Border;
|
|
58
|
-
}
|
|
59
|
-
type LineSpacingRule = "auto" | "atLeast" | "exact";
|
|
60
|
-
interface LineSpacing {
|
|
61
|
-
rule: LineSpacingRule;
|
|
62
|
-
/**
|
|
63
|
-
* For "auto": multiple of single line height (240ths in OOXML, stored here
|
|
64
|
-
* as the multiplier, e.g. 1.15). For atLeast/exact: px.
|
|
65
|
-
*/
|
|
66
|
-
value: number;
|
|
67
|
-
}
|
|
68
|
-
type Alignment = "left" | "center" | "right" | "justify";
|
|
69
|
-
interface TabStop {
|
|
70
|
-
/** px from the left text edge */
|
|
71
|
-
pos: number;
|
|
72
|
-
align: "left" | "center" | "right" | "decimal" | "bar";
|
|
73
|
-
leader: "none" | "dot" | "hyphen" | "underscore" | "middleDot";
|
|
74
|
-
/** w:val="clear": removes the inherited stop at this pos when tab lists
|
|
75
|
-
* merge down the style chain (never a live stop itself). */
|
|
76
|
-
clear?: boolean;
|
|
77
|
-
}
|
|
78
|
-
interface RunProps {
|
|
79
|
-
bold?: boolean;
|
|
80
|
-
italic?: boolean;
|
|
81
|
-
underline?: string;
|
|
82
|
-
strike?: boolean;
|
|
83
|
-
doubleStrike?: boolean;
|
|
84
|
-
/** Resolved primary font family name (ascii/hAnsi, theme-resolved). */
|
|
85
|
-
font?: string;
|
|
86
|
-
/** East Asian font (rFonts w:eastAsia): used for CJK codepoints. */
|
|
87
|
-
fontEastAsia?: string;
|
|
88
|
-
/** hAnsi font (rFonts w:hAnsi, theme-resolved): Word uses this channel for
|
|
89
|
-
* non-ASCII, non-CJK, non-complex characters (curly quotes, ≤, dashes). A
|
|
90
|
-
* run that declares only w:ascii leaves it inherited from the style chain. */
|
|
91
|
-
fontHAnsi?: string;
|
|
92
|
-
/** Complex-script font (rFonts w:cs): used for RTL/complex runs. */
|
|
93
|
-
fontComplex?: string;
|
|
94
|
-
/** w:rtl — this run's text is right-to-left (Arabic/Hebrew). */
|
|
95
|
-
rtl?: boolean;
|
|
96
|
-
/** Font size in px. */
|
|
97
|
-
size?: number;
|
|
98
|
-
/** CSS color; "auto" resolved to inherit/black by renderer. */
|
|
99
|
-
color?: string;
|
|
100
|
-
highlight?: string;
|
|
101
|
-
/** Character shading fill (w:shd). */
|
|
102
|
-
shading?: string;
|
|
103
|
-
/** Run border (w:bdr): a box painted around the run. Word merges adjacent
|
|
104
|
-
* runs with identical borders into one box; a run wrapping across lines
|
|
105
|
-
* closes the box on every line segment. */
|
|
106
|
-
border?: Border;
|
|
107
|
-
verticalAlign?: "baseline" | "superscript" | "subscript";
|
|
108
|
-
caps?: boolean;
|
|
109
|
-
smallCaps?: boolean;
|
|
110
|
-
/** Letter spacing px (w:spacing, twips in OOXML). */
|
|
111
|
-
letterSpacing?: number;
|
|
112
|
-
/** Minimum font size in px at which w:kern enables pair kerning; null is
|
|
113
|
-
* the explicit w:kern=0 override. */
|
|
114
|
-
kerningThreshold?: number | null;
|
|
115
|
-
/** Paint-only letter spacing when layout advances intentionally differ. */
|
|
116
|
-
paintLetterSpacing?: number;
|
|
117
|
-
/** w:w horizontal character scaling as a fraction (1.5 = 150%). */
|
|
118
|
-
textScale?: number;
|
|
119
|
-
/** w:fitText target width in px: the run's advances scale so its text
|
|
120
|
-
* occupies exactly this width (resolved to textScale at layout time). */
|
|
121
|
-
fitText?: number;
|
|
122
|
-
/** w:position baseline shift in px, positive = raised. */
|
|
123
|
-
raise?: number;
|
|
124
|
-
/** w:outline — hollow stroked glyphs. */
|
|
125
|
-
outline?: boolean;
|
|
126
|
-
/** w:emboss / w:imprint — Word triple-draws offset copies. */
|
|
127
|
-
emboss?: boolean;
|
|
128
|
-
imprint?: boolean;
|
|
129
|
-
vanish?: boolean;
|
|
130
|
-
/** Character style id (w:rStyle). */
|
|
131
|
-
styleId?: string;
|
|
132
|
-
lang?: string;
|
|
133
|
-
}
|
|
134
|
-
interface NumberingRef {
|
|
135
|
-
numId: number;
|
|
136
|
-
ilvl: number;
|
|
137
|
-
}
|
|
138
|
-
interface ParaProps {
|
|
139
|
-
styleId?: string;
|
|
140
|
-
alignment?: Alignment;
|
|
141
|
-
/** The exact OOXML w:jc value when it is a "justify" flavor whose behavior
|
|
142
|
-
* differs from plain "both": `distribute` also stretches the LAST line, and
|
|
143
|
-
* the Arabic `*Kashida` levels elongate glyphs (kashida) so lines pack fewer
|
|
144
|
-
* words and — at medium/high — wrap to more lines. Absent for plain "both".
|
|
145
|
-
* `alignment` stays "justify" for all of these. */
|
|
146
|
-
justifyKind?: "distribute" | "lowKashida" | "mediumKashida" | "highKashida";
|
|
147
|
-
/** w:bidi — right-to-left paragraph: lines assemble RTL and default
|
|
148
|
-
* alignment flips to the right edge. */
|
|
149
|
-
bidi?: boolean;
|
|
150
|
-
/** px */
|
|
151
|
-
indentLeft?: number;
|
|
152
|
-
indentRight?: number;
|
|
153
|
-
/** Positive px; mutually exclusive with hanging in effect. */
|
|
154
|
-
indentFirstLine?: number;
|
|
155
|
-
/** Positive px hanging indent. */
|
|
156
|
-
indentHanging?: number;
|
|
157
|
-
spacingBefore?: number;
|
|
158
|
-
spacingAfter?: number;
|
|
159
|
-
/** w:beforeAutospacing/afterAutospacing: HTML-style automatic paragraph
|
|
160
|
-
* spacing — Word ignores the literal before/after and inserts one blank
|
|
161
|
-
* line's worth of space. */
|
|
162
|
-
beforeAutospacing?: boolean;
|
|
163
|
-
afterAutospacing?: boolean;
|
|
164
|
-
/** Word's default when absent is auto/1.0 via docDefaults. */
|
|
165
|
-
lineSpacing?: LineSpacing;
|
|
166
|
-
/** w:snapToGrid: whether this paragraph's lines use the section docGrid. */
|
|
167
|
-
snapToGrid?: boolean;
|
|
168
|
-
contextualSpacing?: boolean;
|
|
169
|
-
keepNext?: boolean;
|
|
170
|
-
/** w:framePr w:dropCap: the paragraph is a drop-cap letter frame. */
|
|
171
|
-
dropCap?: {
|
|
172
|
-
mode: "drop" | "margin";
|
|
173
|
-
lines: number;
|
|
174
|
-
hSpace: number;
|
|
175
|
-
pageAnchored?: boolean;
|
|
176
|
-
};
|
|
177
|
-
/** w:framePr positioned text frame (absolute-positioned paragraph the body
|
|
178
|
-
* text wraps around). Geometry in px. Individual attributes are optional so a
|
|
179
|
-
* framePr merges attribute-by-attribute across the style cascade (a direct
|
|
180
|
-
* framePr that sets only h/x/y keeps the style framePr's width/anchor — IEEE
|
|
181
|
-
* authors); the engine normalizes defaults at layout time. */
|
|
182
|
-
frame?: {
|
|
183
|
-
w?: number;
|
|
184
|
-
h?: number;
|
|
185
|
-
hRule?: "auto" | "atLeast" | "exact";
|
|
186
|
-
x?: number;
|
|
187
|
-
y?: number;
|
|
188
|
-
hAnchor?: "page" | "margin" | "text" | "column";
|
|
189
|
-
vAnchor?: "page" | "margin" | "text" | "paragraph";
|
|
190
|
-
xAlign?: "left" | "center" | "right" | "inside" | "outside";
|
|
191
|
-
yAlign?: "top" | "center" | "bottom" | "inside" | "outside" | "inline";
|
|
192
|
-
wrap?: "around" | "auto" | "notBeside" | "through" | "tight" | "none";
|
|
193
|
-
/** w:hSpace / w:vSpace: horizontal/vertical margin around the frame (px). */
|
|
194
|
-
hSpace?: number;
|
|
195
|
-
vSpace?: number;
|
|
196
|
-
};
|
|
197
|
-
keepLines?: boolean;
|
|
198
|
-
pageBreakBefore?: boolean;
|
|
199
|
-
widowControl?: boolean;
|
|
200
|
-
borders?: ParagraphBorders;
|
|
201
|
-
/** Paragraph shading fill as CSS color. */
|
|
202
|
-
shading?: string;
|
|
203
|
-
numbering?: NumberingRef | null;
|
|
204
|
-
/** A numPr that carries ilvl but no numId (Heading3 basedOn Heading2)
|
|
205
|
-
* overrides only the list LEVEL, keeping the inherited numId; the style
|
|
206
|
-
* chain applies it to `numbering` on merge. */
|
|
207
|
-
numberingLevelOverride?: number;
|
|
208
|
-
tabs?: TabStop[];
|
|
209
|
-
outlineLevel?: number;
|
|
210
|
-
/** Run props declared on pPr/rPr — apply to the paragraph mark & numbering label. */
|
|
211
|
-
markRunProps?: RunProps;
|
|
212
|
-
/**
|
|
213
|
-
* styleId of the enclosing table (set on cell paragraphs at parse time).
|
|
214
|
-
* A table style's own pPr layers between docDefaults and the paragraph
|
|
215
|
-
* style, e.g. TableGrid's `spacing after=0 line=240` overrides docDefaults'
|
|
216
|
-
* `after=200 line=276` so list cells lay out compactly.
|
|
217
|
-
*/
|
|
218
|
-
tableStyleId?: string;
|
|
219
|
-
/**
|
|
220
|
-
* Grid position of the enclosing cell plus the table's tblLook (set on cell
|
|
221
|
-
* paragraphs at parse time, like tableStyleId). Lets run/paragraph
|
|
222
|
-
* resolution layer the applicable w:tblStylePr conditional formats (e.g.
|
|
223
|
-
* firstRow bold + white) between the table style's own rPr and the
|
|
224
|
-
* paragraph style chain.
|
|
225
|
-
*/
|
|
226
|
-
tableCellCond?: {
|
|
227
|
-
look?: TableLook;
|
|
228
|
-
rowIdx: number;
|
|
229
|
-
nRows: number;
|
|
230
|
-
colStart: number;
|
|
231
|
-
colSpan: number;
|
|
232
|
-
nCols: number;
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
interface TextContent {
|
|
236
|
-
kind: "text";
|
|
237
|
-
text: string;
|
|
238
|
-
/** Source w:t element inside the run, when this text came verbatim from one. */
|
|
239
|
-
srcT?: XmlElement;
|
|
240
|
-
/** When this text is the glyph of a modern checkbox content control, the
|
|
241
|
-
* source `w14:checkbox` element (in the enclosing w:sdt's sdtPr). Its
|
|
242
|
-
* presence makes the glyph a click-to-toggle target rather than plain text. */
|
|
243
|
-
checkbox?: XmlElement;
|
|
244
|
-
}
|
|
245
|
-
interface BreakContent {
|
|
246
|
-
kind: "break";
|
|
247
|
-
breakType: "line" | "page" | "column";
|
|
248
|
-
}
|
|
249
|
-
interface TabContent {
|
|
250
|
-
kind: "tab";
|
|
251
|
-
}
|
|
252
|
-
interface PTabContent {
|
|
253
|
-
kind: "ptab";
|
|
254
|
-
/** Absolute-position tab: jump to left/center/right of the base. */
|
|
255
|
-
alignment: "left" | "center" | "right";
|
|
256
|
-
relativeTo: "margin" | "indent";
|
|
257
|
-
}
|
|
258
|
-
interface ImageContent {
|
|
259
|
-
kind: "image";
|
|
260
|
-
/** Part path of the image inside the package. */
|
|
261
|
-
part: string;
|
|
262
|
-
width: number;
|
|
263
|
-
height: number;
|
|
264
|
-
/** True when the drawing is floating (wp:anchor); v1 lays it out inline. */
|
|
265
|
-
anchored?: boolean;
|
|
266
|
-
/** a:srcRect crop, fractions of the source bitmap. */
|
|
267
|
-
crop?: {
|
|
268
|
-
l: number;
|
|
269
|
-
t: number;
|
|
270
|
-
r: number;
|
|
271
|
-
b: number;
|
|
272
|
-
};
|
|
273
|
-
/** a:xfrm rotation, degrees clockwise. */
|
|
274
|
-
rotation?: number;
|
|
275
|
-
/** a:ln picture outline (Word draws it just outside the image). */
|
|
276
|
-
border?: {
|
|
277
|
-
color: string;
|
|
278
|
-
width: number;
|
|
279
|
-
};
|
|
280
|
-
/** Source w:drawing (or pict) element, for resize/move editing. */
|
|
281
|
-
srcDrawing?: XmlElement;
|
|
282
|
-
/** Native Office 3D model shown through its saved poster raster. */
|
|
283
|
-
model3D?: Model3DReference;
|
|
284
|
-
/** Word online-video metadata shown through its saved poster raster. */
|
|
285
|
-
webVideo?: WebVideoReference;
|
|
286
|
-
/** Embedded OLE package activated as a safe download in the browser. */
|
|
287
|
-
embeddedObject?: EmbeddedObjectReference;
|
|
288
|
-
}
|
|
289
|
-
interface Model3DReference {
|
|
290
|
-
part: string;
|
|
291
|
-
posterPart: string;
|
|
292
|
-
/** Native Office model orientation, in degrees around the X/Y/Z axes. */
|
|
293
|
-
rotation?: {
|
|
294
|
-
x: number;
|
|
295
|
-
y: number;
|
|
296
|
-
z: number;
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
interface WebVideoReference {
|
|
300
|
-
url: string;
|
|
301
|
-
embeddedHtml: string;
|
|
302
|
-
width: number;
|
|
303
|
-
height: number;
|
|
304
|
-
}
|
|
305
|
-
interface EmbeddedObjectReference {
|
|
306
|
-
part: string;
|
|
307
|
-
filename: string;
|
|
308
|
-
progId: string;
|
|
309
|
-
}
|
|
310
|
-
/** OMML equation node (subset: runs, scripts, fractions, radicals). */
|
|
311
|
-
type MathNode = {
|
|
312
|
-
t: "run";
|
|
313
|
-
text: string;
|
|
314
|
-
normal?: boolean;
|
|
315
|
-
/** m:func function name (cos, log, …): Word kerns a thin space on
|
|
316
|
-
* both sides of the name. */
|
|
317
|
-
fname?: boolean;
|
|
318
|
-
} | {
|
|
319
|
-
t: "sup" | "sub";
|
|
320
|
-
base: MathNode[];
|
|
321
|
-
script: MathNode[];
|
|
322
|
-
} | {
|
|
323
|
-
t: "frac";
|
|
324
|
-
num: MathNode[];
|
|
325
|
-
den: MathNode[];
|
|
326
|
-
bar?: boolean;
|
|
327
|
-
}
|
|
328
|
-
/** Radical; deg is the optional m:deg index (∛), absent when m:degHide. */
|
|
329
|
-
| {
|
|
330
|
-
t: "rad";
|
|
331
|
-
e: MathNode[];
|
|
332
|
-
deg?: MathNode[];
|
|
333
|
-
}
|
|
334
|
-
/** n-ary operator (sum/integral); chr defaults to the integral sign. */
|
|
335
|
-
| {
|
|
336
|
-
t: "nary";
|
|
337
|
-
chr: string;
|
|
338
|
-
sub: MathNode[];
|
|
339
|
-
sup: MathNode[];
|
|
340
|
-
e: MathNode[];
|
|
341
|
-
}
|
|
342
|
-
/** Delimiters grown to the content height; beg/end default to parens.
|
|
343
|
-
* An empty beg/end string means that side has no delimiter (cases "{"). */
|
|
344
|
-
| {
|
|
345
|
-
t: "dlm";
|
|
346
|
-
beg: string;
|
|
347
|
-
end: string;
|
|
348
|
-
e: MathNode[][];
|
|
349
|
-
}
|
|
350
|
-
/** Matrix: rows x cells. */
|
|
351
|
-
| {
|
|
352
|
-
t: "mat";
|
|
353
|
-
rows: MathNode[][][];
|
|
354
|
-
}
|
|
355
|
-
/** m:eqArr equation array (cases/piecewise rows). */
|
|
356
|
-
| {
|
|
357
|
-
t: "eqarr";
|
|
358
|
-
rows: MathNode[][];
|
|
359
|
-
}
|
|
360
|
-
/** m:acc combining accent (hat/bar/vector) over the base. */
|
|
361
|
-
| {
|
|
362
|
-
t: "acc";
|
|
363
|
-
chr: string;
|
|
364
|
-
e: MathNode[];
|
|
365
|
-
}
|
|
366
|
-
/** m:groupChr horizontal group character (over/under brace). */
|
|
367
|
-
| {
|
|
368
|
-
t: "grp";
|
|
369
|
-
chr: string;
|
|
370
|
-
pos: "top" | "bot";
|
|
371
|
-
vertJc: "top" | "bot";
|
|
372
|
-
e: MathNode[];
|
|
373
|
-
}
|
|
374
|
-
/** m:limLow / m:limUpp limit stacked under/over a text operator. */
|
|
375
|
-
| {
|
|
376
|
-
t: "lim";
|
|
377
|
-
pos: "low" | "upp";
|
|
378
|
-
e: MathNode[];
|
|
379
|
-
lim: MathNode[];
|
|
380
|
-
};
|
|
381
|
-
interface MathContent {
|
|
382
|
-
kind: "math";
|
|
383
|
-
nodes: MathNode[];
|
|
384
|
-
/** Source m:oMath element (math editing). */
|
|
385
|
-
src?: XmlElement;
|
|
386
|
-
/** Display equation (wrapped in m:oMathPara): centered on its own line with
|
|
387
|
-
* display-style layout - larger n-ary operators with limits stacked
|
|
388
|
-
* above/below, and full-size fraction numerators/denominators. */
|
|
389
|
-
display?: boolean;
|
|
390
|
-
/** Display group with several direct equations. Word leaves a small
|
|
391
|
-
* advance after script clusters in these grouped displays. */
|
|
392
|
-
multiEquationDisplay?: boolean;
|
|
393
|
-
/** m:oMathParaPr/m:jc - display-equation justification. Absent: the
|
|
394
|
-
* document default (settings m:mathPr/m:defJc, itself "centerGroup" when
|
|
395
|
-
* unset). */
|
|
396
|
-
jc?: "left" | "right" | "center" | "centerGroup";
|
|
397
|
-
}
|
|
398
|
-
interface FieldContent {
|
|
399
|
-
kind: "field";
|
|
400
|
-
/** Raw field instruction, e.g. ` PAGE \\* MERGEFORMAT `. */
|
|
401
|
-
instruction: string;
|
|
402
|
-
/** Last cached result text from the file, used for unsupported fields. */
|
|
403
|
-
cachedResult: string;
|
|
404
|
-
/** When this field is a legacy FORMCHECKBOX, the source `w:checkBox` element
|
|
405
|
-
* (in the fldChar begin's w:ffData). Its presence makes the rendered ballot
|
|
406
|
-
* box a click-to-toggle target; the glyph derives from its w:checked child. */
|
|
407
|
-
checkbox?: XmlElement;
|
|
408
|
-
}
|
|
409
|
-
/** What an anchored shape's coordinates are measured from. "char" (relH=
|
|
410
|
-
* "character") measures from the anchor run's pen position; "line" (relV=
|
|
411
|
-
* "line") from the top of the line holding the anchor — both resolved from
|
|
412
|
-
* the anchor paragraph's first-pass layout. */
|
|
413
|
-
type AnchorRel = "page" | "margin" | "text" | "column" | "char" | "line";
|
|
414
|
-
interface ShapeLine {
|
|
415
|
-
type: "line";
|
|
416
|
-
x1: number;
|
|
417
|
-
y1: number;
|
|
418
|
-
x2: number;
|
|
419
|
-
y2: number;
|
|
420
|
-
color: string;
|
|
421
|
-
/** Stroke weight px. */
|
|
422
|
-
weight: number;
|
|
423
|
-
hRel: AnchorRel;
|
|
424
|
-
vRel: AnchorRel;
|
|
425
|
-
}
|
|
426
|
-
interface ShapeTextbox {
|
|
427
|
-
type: "textbox";
|
|
428
|
-
x: number;
|
|
429
|
-
y: number;
|
|
430
|
-
width: number;
|
|
431
|
-
height: number;
|
|
432
|
-
hRel: AnchorRel;
|
|
433
|
-
vRel: AnchorRel;
|
|
434
|
-
blocks: Block[];
|
|
435
|
-
/** Background fill (CSS color) painted behind the text. */
|
|
436
|
-
fill?: string;
|
|
437
|
-
/** Outline. */
|
|
438
|
-
stroke?: {
|
|
439
|
-
color: string;
|
|
440
|
-
weight: number;
|
|
441
|
-
};
|
|
442
|
-
/** Alignment-based positioning (mso-position-horizontal/vertical). */
|
|
443
|
-
hAlign?: "left" | "center" | "right";
|
|
444
|
-
vAlign?: "top" | "center" | "bottom";
|
|
445
|
-
/** Percent-of-base geometry, 0..1 (mso-*-percent / wp14 pct offsets).
|
|
446
|
-
* Bases: pctWidthRel/pctHeightRel say page vs margin. */
|
|
447
|
-
pctX?: number;
|
|
448
|
-
pctY?: number;
|
|
449
|
-
pctWidth?: number;
|
|
450
|
-
pctHeight?: number;
|
|
451
|
-
pctWidthRel?: "page" | "margin";
|
|
452
|
-
pctHeightRel?: "page" | "margin";
|
|
453
|
-
/** Vertical anchoring of the text INSIDE the box (v-text-anchor). */
|
|
454
|
-
textAnchor?: "top" | "middle" | "bottom";
|
|
455
|
-
/** How body text flows around a DrawingML textbox (wp:wrap*). */
|
|
456
|
-
wrap?: WrapMode;
|
|
457
|
-
/** behindDoc: paint under the body text, never displace it. */
|
|
458
|
-
behind?: boolean;
|
|
459
|
-
/** wp:anchor @allowOverlap="0": Word shifts this shape clear of earlier
|
|
460
|
-
* overlapping floats rather than letting them overlap. Default true. */
|
|
461
|
-
allowOverlap?: boolean;
|
|
462
|
-
/** Wrap distances px (wp:anchor distT/B/L/R). */
|
|
463
|
-
dist?: {
|
|
464
|
-
t: number;
|
|
465
|
-
b: number;
|
|
466
|
-
l: number;
|
|
467
|
-
r: number;
|
|
468
|
-
};
|
|
469
|
-
/** a:xfrm rotation, degrees clockwise (rotates the whole box). */
|
|
470
|
-
rotation?: number;
|
|
471
|
-
/** Text insets px (bodyPr lIns/tIns/rIns/bIns); default 9.6/4.8. For
|
|
472
|
-
* non-rect preset geometries these INCLUDE the geometry's text-rectangle
|
|
473
|
-
* insets (ellipse: inscribed rect; diamond: middle-half rect). */
|
|
474
|
-
insets?: {
|
|
475
|
-
l: number;
|
|
476
|
-
t: number;
|
|
477
|
-
r: number;
|
|
478
|
-
b: number;
|
|
479
|
-
};
|
|
480
|
-
/** Non-rect preset geometry: paint this outline (in a viewW x viewH space
|
|
481
|
-
* scaled to the shape box) instead of a rectangle. */
|
|
482
|
-
geom?: {
|
|
483
|
-
d: string;
|
|
484
|
-
viewW: number;
|
|
485
|
-
viewH: number;
|
|
486
|
-
};
|
|
487
|
-
/** bodyPr a:noAutofit: the box does NOT grow with its text — Word hides
|
|
488
|
-
* whole lines that stick out past the shape bottom (phase23 p12 ovals:
|
|
489
|
-
* "Was 0 / B" visible, the wrapped tail rows hidden). */
|
|
490
|
-
clipText?: boolean;
|
|
491
|
-
/** bodyPr a:spAutoFit: the box grows in height to exactly fit its laid text
|
|
492
|
-
* plus the top/bottom insets (the stored cy is only Word's last cached
|
|
493
|
-
* value). Width is fixed. */
|
|
494
|
-
autofitHeight?: boolean;
|
|
495
|
-
/** Linked text-box chain id (wps:txbx/@id or wps:linkedTxbx/@id): boxes with
|
|
496
|
-
* the same id form one story. The seq-0 box (wps:txbx) holds the content;
|
|
497
|
-
* later boxes (wps:linkedTxbx, chainSeq>0) are empty sinks that continue the
|
|
498
|
-
* overflow. */
|
|
499
|
-
chainId?: string;
|
|
500
|
-
/** Position in the linked chain (0 = the content box). */
|
|
501
|
-
chainSeq?: number;
|
|
502
|
-
/** Source w:drawing element, attached at parse time so the shape's fill can
|
|
503
|
-
* be an interactive hit target (select the shape instead of the body text
|
|
504
|
-
* behind it). */
|
|
505
|
-
srcDrawing?: XmlElement;
|
|
506
|
-
/** Header/footer-owned textbox whose text is edited as an independent story. */
|
|
507
|
-
textboxStory?: boolean;
|
|
508
|
-
/** DrawingML WordArt, including the identity textNoShape preset. */
|
|
509
|
-
wordArt?: boolean;
|
|
510
|
-
/** bodyPr a:prstTxWarp preset name (textArchUp, textWave1, textChevron,
|
|
511
|
-
* textCirclePour, …): the shape's text is bent onto the preset's envelope
|
|
512
|
-
* rather than flowed as ordinary lines. "textNoShape" (no warp) is dropped. */
|
|
513
|
-
warp?: string;
|
|
514
|
-
}
|
|
515
|
-
/** WordArt (VML v:textpath, e.g. a "CONFIDENTIAL" watermark): text scaled to
|
|
516
|
-
* fill a box, optionally rotated, painted semi-transparent behind the body. */
|
|
517
|
-
interface ShapeWordArt {
|
|
518
|
-
type: "wordart";
|
|
519
|
-
text: string;
|
|
520
|
-
fontFamily: string;
|
|
521
|
-
bold?: boolean;
|
|
522
|
-
italic?: boolean;
|
|
523
|
-
/** CSS fill color. */
|
|
524
|
-
fill: string;
|
|
525
|
-
/** 0..1 alpha. */
|
|
526
|
-
opacity: number;
|
|
527
|
-
x: number;
|
|
528
|
-
y: number;
|
|
529
|
-
width: number;
|
|
530
|
-
height: number;
|
|
531
|
-
hRel: AnchorRel;
|
|
532
|
-
vRel: AnchorRel;
|
|
533
|
-
hAlign?: "left" | "center" | "right";
|
|
534
|
-
vAlign?: "top" | "center" | "bottom";
|
|
535
|
-
/** Clockwise degrees. */
|
|
536
|
-
rotation: number;
|
|
537
|
-
behind?: boolean;
|
|
538
|
-
/** The source v:textpath font-size (px). */
|
|
539
|
-
fontSize?: number;
|
|
540
|
-
/** The referenced v:shapetype has a malformed text-guide path (missing
|
|
541
|
-
* coordinates), so Word collapses its horizontal glyph outlines into a thin
|
|
542
|
-
* vertical band instead of painting a box-filling watermark. */
|
|
543
|
-
noFit?: boolean;
|
|
544
|
-
/** Source VML shape element (v:shape / v:rect) for interactive editing:
|
|
545
|
-
* the v:textpath string, fill/opacity, and rotation live under it. */
|
|
546
|
-
src?: XmlElement;
|
|
547
|
-
}
|
|
548
|
-
interface ShapeArt {
|
|
549
|
-
type: "art";
|
|
550
|
-
srcDrawing?: XmlElement;
|
|
551
|
-
/** A freehand stroke, selectable by the Draw ribbon's stroke eraser. */
|
|
552
|
-
ink?: boolean;
|
|
553
|
-
x: number;
|
|
554
|
-
y: number;
|
|
555
|
-
/** Percent-of-page offsets (wp14:pctPos*Offset), 0..1. */
|
|
556
|
-
pctX?: number;
|
|
557
|
-
pctY?: number;
|
|
558
|
-
width: number;
|
|
559
|
-
height: number;
|
|
560
|
-
hRel: AnchorRel;
|
|
561
|
-
vRel: AnchorRel;
|
|
562
|
-
hAlign?: "left" | "center" | "right";
|
|
563
|
-
vAlign?: "top" | "center" | "bottom";
|
|
564
|
-
behind?: boolean;
|
|
565
|
-
/** a:xfrm rotation, degrees clockwise. */
|
|
566
|
-
rotation?: number;
|
|
567
|
-
lines: DrawingLine[];
|
|
568
|
-
images: DrawingImage[];
|
|
569
|
-
paths: DrawingPath[];
|
|
570
|
-
/** Positioned text bodies inside the group (wps textboxes, dsp:sp txBody). */
|
|
571
|
-
texts?: DrawingTextShape[];
|
|
572
|
-
}
|
|
573
|
-
/** How text interacts with a floating image. */
|
|
574
|
-
type WrapMode = "square" | "topAndBottom" | "none";
|
|
575
|
-
interface ShapeImage {
|
|
576
|
-
type: "image";
|
|
577
|
-
part: string;
|
|
578
|
-
/** Offset from the anchor origin, px. */
|
|
579
|
-
x: number;
|
|
580
|
-
y: number;
|
|
581
|
-
width: number;
|
|
582
|
-
height: number;
|
|
583
|
-
hRel: AnchorRel;
|
|
584
|
-
vRel: AnchorRel;
|
|
585
|
-
/** Horizontal alignment when the file uses wp:align instead of an offset. */
|
|
586
|
-
hAlign?: "left" | "center" | "right";
|
|
587
|
-
/** Vertical alignment keyword (VML mso-position-vertical; watermarks center). */
|
|
588
|
-
vAlign?: "top" | "center" | "bottom";
|
|
589
|
-
wrap: WrapMode;
|
|
590
|
-
/** behindDoc anchors render under the text and never displace it. */
|
|
591
|
-
behind?: boolean;
|
|
592
|
-
/** Wrap distances px (wp:anchor distT/B/L/R); text clears the image by these. */
|
|
593
|
-
dist?: {
|
|
594
|
-
t: number;
|
|
595
|
-
b: number;
|
|
596
|
-
l: number;
|
|
597
|
-
r: number;
|
|
598
|
-
};
|
|
599
|
-
crop?: {
|
|
600
|
-
l: number;
|
|
601
|
-
t: number;
|
|
602
|
-
r: number;
|
|
603
|
-
b: number;
|
|
604
|
-
};
|
|
605
|
-
rotation?: number;
|
|
606
|
-
/** Watermark "washout" recolor (VML v:imagedata gain/blacklevel, 0..1). */
|
|
607
|
-
washout?: {
|
|
608
|
-
gain: number;
|
|
609
|
-
blacklevel: number;
|
|
610
|
-
};
|
|
611
|
-
/** Source w:drawing element (editing). */
|
|
612
|
-
srcDrawing?: XmlElement;
|
|
613
|
-
model3D?: Model3DReference;
|
|
614
|
-
webVideo?: WebVideoReference;
|
|
615
|
-
embeddedObject?: EmbeddedObjectReference;
|
|
616
|
-
}
|
|
617
|
-
type Shape = (ShapeLine | ShapeTextbox | ShapeImage | ShapeArt | ShapeWordArt) & {
|
|
618
|
-
/** wp:anchor relativeHeight, used for object stacking order. */
|
|
619
|
-
z?: number;
|
|
620
|
-
};
|
|
621
|
-
/**
|
|
622
|
-
* Floating/anchored object: does not occupy inline space; positioned against
|
|
623
|
-
* page/margin/paragraph during layout. (How classic pleading paper draws its
|
|
624
|
-
* margin line numbers and vertical rules.)
|
|
625
|
-
*/
|
|
626
|
-
interface AnchorContent {
|
|
627
|
-
kind: "anchor";
|
|
628
|
-
shape: Shape;
|
|
629
|
-
}
|
|
630
|
-
/** A stroked segment inside a composite drawing, px relative to its box. */
|
|
631
|
-
interface DrawingLine {
|
|
632
|
-
x1: number;
|
|
633
|
-
y1: number;
|
|
634
|
-
x2: number;
|
|
635
|
-
y2: number;
|
|
636
|
-
color: string;
|
|
637
|
-
weight: number;
|
|
638
|
-
style?: "single" | "dotted" | "dashed";
|
|
639
|
-
}
|
|
640
|
-
interface DrawingImage {
|
|
641
|
-
part: string;
|
|
642
|
-
x: number;
|
|
643
|
-
y: number;
|
|
644
|
-
width: number;
|
|
645
|
-
height: number;
|
|
646
|
-
crop?: {
|
|
647
|
-
l: number;
|
|
648
|
-
t: number;
|
|
649
|
-
r: number;
|
|
650
|
-
b: number;
|
|
651
|
-
};
|
|
652
|
-
rotation?: number;
|
|
653
|
-
/** a:ln picture outline (Word draws it just outside the image). */
|
|
654
|
-
border?: {
|
|
655
|
-
color: string;
|
|
656
|
-
width: number;
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* Composite inline drawing (DrawingML groups): vector lines + placed images
|
|
661
|
-
* inside a width×height box that flows like an image.
|
|
662
|
-
*/
|
|
663
|
-
interface DrawingContent {
|
|
664
|
-
kind: "drawing";
|
|
665
|
-
width: number;
|
|
666
|
-
height: number;
|
|
667
|
-
lines: DrawingLine[];
|
|
668
|
-
images: DrawingImage[];
|
|
669
|
-
/** Native ChartML chart data resolved from the related chart part. */
|
|
670
|
-
chart?: ChartData;
|
|
671
|
-
/** Native SmartArt diagram data resolved from its diagram parts. */
|
|
672
|
-
smartArt?: SmartArtData;
|
|
673
|
-
/** Freeform vector shapes (a:custGeom), as SVG path data. */
|
|
674
|
-
paths?: DrawingPath[];
|
|
675
|
-
/** An INLINE wps text box (wp:inline wps:txbx): a fixed-extent box that
|
|
676
|
-
* flows in the text (occupying its width x height like an inline image) and
|
|
677
|
-
* carries a fill/border + its own block content. Distinct from the floating
|
|
678
|
-
* ShapeTextbox, which is absolutely placed via a wp:anchor. */
|
|
679
|
-
textbox?: {
|
|
680
|
-
blocks: Block[];
|
|
681
|
-
fill?: string;
|
|
682
|
-
stroke?: {
|
|
683
|
-
color: string;
|
|
684
|
-
weight: number;
|
|
685
|
-
};
|
|
686
|
-
insets?: {
|
|
687
|
-
l: number;
|
|
688
|
-
t: number;
|
|
689
|
-
r: number;
|
|
690
|
-
b: number;
|
|
691
|
-
};
|
|
692
|
-
textAnchor?: "top" | "middle" | "bottom";
|
|
693
|
-
};
|
|
694
|
-
/** Source w:drawing element (select/move as a group). */
|
|
695
|
-
srcDrawing?: XmlElement;
|
|
696
|
-
/** Positioned text bodies inside the drawing (multi-textbox groups and
|
|
697
|
-
* SmartArt cached-drawing shapes). Painted above lines/paths. */
|
|
698
|
-
texts?: DrawingTextShape[];
|
|
699
|
-
}
|
|
700
|
-
type ChartType = "column" | "bar" | "line" | "pie";
|
|
701
|
-
interface ChartSeries {
|
|
702
|
-
name: string;
|
|
703
|
-
values: number[];
|
|
704
|
-
}
|
|
705
|
-
interface ChartData {
|
|
706
|
-
type: ChartType;
|
|
707
|
-
title?: string;
|
|
708
|
-
categories: string[];
|
|
709
|
-
series: ChartSeries[];
|
|
710
|
-
}
|
|
711
|
-
type SmartArtLayout = "process" | "cycle" | "hierarchy" | "list";
|
|
712
|
-
interface SmartArtData {
|
|
713
|
-
layout: SmartArtLayout;
|
|
714
|
-
items: string[];
|
|
715
|
-
}
|
|
716
|
-
/** A text body positioned inside a composite drawing (a wps textbox in a
|
|
717
|
-
* group, or a SmartArt dsp:sp txBody), px relative to the drawing's box. */
|
|
718
|
-
interface DrawingTextShape {
|
|
719
|
-
x: number;
|
|
720
|
-
y: number;
|
|
721
|
-
width: number;
|
|
722
|
-
height: number;
|
|
723
|
-
blocks: Block[];
|
|
724
|
-
/** Background fill painted behind the text box. */
|
|
725
|
-
fill?: string;
|
|
726
|
-
/** Outline. */
|
|
727
|
-
stroke?: {
|
|
728
|
-
color: string;
|
|
729
|
-
weight: number;
|
|
730
|
-
};
|
|
731
|
-
/** Text insets px (bodyPr lIns/tIns/rIns/bIns). */
|
|
732
|
-
insets: {
|
|
733
|
-
l: number;
|
|
734
|
-
t: number;
|
|
735
|
-
r: number;
|
|
736
|
-
b: number;
|
|
737
|
-
};
|
|
738
|
-
/** Vertical anchoring of the text inside the box (bodyPr anchor). */
|
|
739
|
-
textAnchor?: "top" | "middle" | "bottom";
|
|
740
|
-
/** DrawingML cached text paint-only baseline adjustment in px. */
|
|
741
|
-
paintOffsetY?: number;
|
|
742
|
-
}
|
|
743
|
-
interface DrawingPath {
|
|
744
|
-
/** Position/size inside the drawing, px. */
|
|
745
|
-
x: number;
|
|
746
|
-
y: number;
|
|
747
|
-
width: number;
|
|
748
|
-
height: number;
|
|
749
|
-
/** SVG path in the `viewW x viewH` source coordinate space. */
|
|
750
|
-
d: string;
|
|
751
|
-
viewW: number;
|
|
752
|
-
viewH: number;
|
|
753
|
-
fill?: string;
|
|
754
|
-
stroke?: {
|
|
755
|
-
color: string;
|
|
756
|
-
width: number;
|
|
757
|
-
opacity?: number;
|
|
758
|
-
};
|
|
759
|
-
/** Zero-based visible SmartArt node this path paints. */
|
|
760
|
-
smartArtNodeIndex?: number;
|
|
761
|
-
}
|
|
762
|
-
/**
|
|
763
|
-
* Footnote/endnote reference mark. In body text (w:footnoteReference /
|
|
764
|
-
* w:endnoteReference) `id` points into the notes part. Inside a note body,
|
|
765
|
-
* w:footnoteRef / w:endnoteRef render the note's own mark: `self` is true and
|
|
766
|
-
* `id` is meaningless.
|
|
767
|
-
*/
|
|
768
|
-
interface NoteRefContent {
|
|
769
|
-
kind: "noteRef";
|
|
770
|
-
noteType: "footnote" | "endnote";
|
|
771
|
-
id: number;
|
|
772
|
-
self?: boolean;
|
|
773
|
-
/** The document supplies the visible mark in the following run content. */
|
|
774
|
-
customMarkFollows?: boolean;
|
|
775
|
-
}
|
|
776
|
-
/** w:ruby — an East-Asian ruby (furigana) cluster: an annotation run (w:rt)
|
|
777
|
-
* riding above a base run (w:rubyBase). Both sides render as their own runs;
|
|
778
|
-
* the annotation is centered over the base and raised above its baseline. */
|
|
779
|
-
interface RubyContent {
|
|
780
|
-
kind: "ruby";
|
|
781
|
-
base: Run;
|
|
782
|
-
rt: Run;
|
|
783
|
-
/** w:rubyPr/w:hpsRaise — annotation baseline raise above the base baseline,
|
|
784
|
-
* half-points. */
|
|
785
|
-
hpsRaise?: number;
|
|
786
|
-
/** w:rubyPr/w:rubyAlign — how the annotation distributes over the base. */
|
|
787
|
-
align?: "center" | "distributeLetter" | "distributeSpace" | "left" | "right" | "rightVertical";
|
|
788
|
-
}
|
|
789
|
-
type RunContent = MathContent | TextContent | BreakContent | TabContent | PTabContent | ImageContent | FieldContent | AnchorContent | DrawingContent | NoteRefContent | RubyContent;
|
|
790
|
-
interface Run {
|
|
791
|
-
type: "run";
|
|
792
|
-
props: RunProps;
|
|
793
|
-
content: RunContent[];
|
|
794
|
-
/** Source w:r element. */
|
|
795
|
-
src?: XmlElement;
|
|
796
|
-
/** Element whose children array contains src (w:p, w:hyperlink, …). */
|
|
797
|
-
srcParent?: XmlElement;
|
|
798
|
-
}
|
|
799
|
-
interface Hyperlink {
|
|
800
|
-
type: "hyperlink";
|
|
801
|
-
href?: string;
|
|
802
|
-
anchor?: string;
|
|
803
|
-
runs: Run[];
|
|
804
|
-
}
|
|
805
|
-
type ParaChild = Run | Hyperlink;
|
|
806
|
-
interface Paragraph {
|
|
807
|
-
type: "paragraph";
|
|
808
|
-
props: ParaProps;
|
|
809
|
-
children: ParaChild[];
|
|
810
|
-
/** Section break attached to this paragraph's pPr (ends a section). */
|
|
811
|
-
sectionBreak?: SectionProps;
|
|
812
|
-
/** w:bookmarkStart names in this paragraph (PAGEREF targets). */
|
|
813
|
-
bookmarks?: string[];
|
|
814
|
-
/** Final revision view: the paragraph mark AND all content are tracked
|
|
815
|
-
* deletions — the paragraph does not exist (no line, no numbering). */
|
|
816
|
-
revisionHidden?: boolean;
|
|
817
|
-
/** Source w:p element. */
|
|
818
|
-
src?: XmlElement;
|
|
819
|
-
}
|
|
820
|
-
interface TableCellProps {
|
|
821
|
-
/** Preferred width px (from tcW when dxa). */
|
|
822
|
-
width?: number;
|
|
823
|
-
/** The source explicitly declares tcW type="auto" (distinct from no tcW). */
|
|
824
|
-
widthAuto?: boolean;
|
|
825
|
-
gridSpan: number;
|
|
826
|
-
vMerge?: "restart" | "continue";
|
|
827
|
-
borders?: {
|
|
828
|
-
top?: Border;
|
|
829
|
-
bottom?: Border;
|
|
830
|
-
left?: Border;
|
|
831
|
-
right?: Border;
|
|
832
|
-
tl2br?: Border;
|
|
833
|
-
tr2bl?: Border;
|
|
834
|
-
};
|
|
835
|
-
shading?: string;
|
|
836
|
-
/** Cell margins px. */
|
|
837
|
-
margins?: {
|
|
838
|
-
top?: number;
|
|
839
|
-
right?: number;
|
|
840
|
-
bottom?: number;
|
|
841
|
-
left?: number;
|
|
842
|
-
};
|
|
843
|
-
verticalAlign?: "top" | "center" | "bottom";
|
|
844
|
-
textDirection?: "btLr" | "tbRl";
|
|
845
|
-
}
|
|
846
|
-
interface TableCell {
|
|
847
|
-
props: TableCellProps;
|
|
848
|
-
blocks: Block[];
|
|
849
|
-
}
|
|
850
|
-
interface TableRowProps {
|
|
851
|
-
/** px; undefined = auto */
|
|
852
|
-
height?: number;
|
|
853
|
-
heightRule?: "auto" | "atLeast" | "exact";
|
|
854
|
-
cantSplit?: boolean;
|
|
855
|
-
/** Repeat as header row on each page. */
|
|
856
|
-
tblHeader?: boolean;
|
|
857
|
-
}
|
|
858
|
-
interface TableRow {
|
|
859
|
-
props: TableRowProps;
|
|
860
|
-
cells: TableCell[];
|
|
861
|
-
}
|
|
862
|
-
interface TableProps {
|
|
863
|
-
styleId?: string;
|
|
864
|
-
/** px table indent from left margin. */
|
|
865
|
-
indent?: number;
|
|
866
|
-
alignment?: Alignment;
|
|
867
|
-
/** w:bidiVisual — RTL table: column order reverses and the table hugs the
|
|
868
|
-
* right margin. */
|
|
869
|
-
bidiVisual?: boolean;
|
|
870
|
-
borders?: {
|
|
871
|
-
top?: Border;
|
|
872
|
-
bottom?: Border;
|
|
873
|
-
left?: Border;
|
|
874
|
-
right?: Border;
|
|
875
|
-
insideH?: Border;
|
|
876
|
-
insideV?: Border;
|
|
877
|
-
};
|
|
878
|
-
/** Default cell margins px. */
|
|
879
|
-
cellMargins?: {
|
|
880
|
-
top?: number;
|
|
881
|
-
right?: number;
|
|
882
|
-
bottom?: number;
|
|
883
|
-
left?: number;
|
|
884
|
-
};
|
|
885
|
-
/** w:tblCellSpacing px — old-style separated cell borders: every cell gets
|
|
886
|
-
* its own border box inset by this much from the grid slot on all sides
|
|
887
|
-
* (adjacent cells end up 2x apart), and the table outline is a separate box
|
|
888
|
-
* around everything. */
|
|
889
|
-
cellSpacing?: number;
|
|
890
|
-
/** w:tblpPr — floating table: absolutely positioned against page/margin/
|
|
891
|
-
* column, painted over an opaque white sheet, with body text (including
|
|
892
|
-
* text EARLIER in the flow on the same page) wrapping square around it. */
|
|
893
|
-
floating?: {
|
|
894
|
-
hAnchor: "page" | "margin" | "text";
|
|
895
|
-
vAnchor: "page" | "margin" | "text";
|
|
896
|
-
/** tblpX/tblpY px (absent when an alignment keyword is used). */
|
|
897
|
-
x?: number;
|
|
898
|
-
y?: number;
|
|
899
|
-
xAlign?: "left" | "center" | "right";
|
|
900
|
-
yAlign?: "top" | "center" | "bottom";
|
|
901
|
-
/** Wrap distances px (leftFromText, …). */
|
|
902
|
-
dist: {
|
|
903
|
-
l: number;
|
|
904
|
-
r: number;
|
|
905
|
-
t: number;
|
|
906
|
-
b: number;
|
|
907
|
-
};
|
|
908
|
-
/** w:tblOverlap "never": shift clear of earlier floating tables. */
|
|
909
|
-
allowOverlap: boolean;
|
|
910
|
-
};
|
|
911
|
-
/** Preferred total width px (tblW dxa) or undefined for auto. */
|
|
912
|
-
width?: number;
|
|
913
|
-
/** Preferred total width as a fraction of available width (tblW pct). */
|
|
914
|
-
widthPct?: number;
|
|
915
|
-
layout?: "fixed" | "autofit";
|
|
916
|
-
/** w:tblLook flags controlling which conditional formats apply. */
|
|
917
|
-
tblLook?: TableLook;
|
|
918
|
-
}
|
|
919
|
-
/** w:tblLook flags controlling which conditional table-style formats apply. */
|
|
920
|
-
interface TableLook {
|
|
921
|
-
firstRow: boolean;
|
|
922
|
-
lastRow: boolean;
|
|
923
|
-
firstColumn: boolean;
|
|
924
|
-
lastColumn: boolean;
|
|
925
|
-
noHBand: boolean;
|
|
926
|
-
noVBand: boolean;
|
|
927
|
-
}
|
|
928
|
-
interface Table {
|
|
929
|
-
type: "table";
|
|
930
|
-
props: TableProps;
|
|
931
|
-
/** Column grid widths px (tblGrid). */
|
|
932
|
-
grid: number[];
|
|
933
|
-
rows: TableRow[];
|
|
934
|
-
/** Source w:tbl element. */
|
|
935
|
-
src?: XmlElement;
|
|
936
|
-
}
|
|
937
|
-
type Block = Paragraph | Table;
|
|
938
|
-
interface HeaderFooterRefs {
|
|
939
|
-
default?: string;
|
|
940
|
-
first?: string;
|
|
941
|
-
even?: string;
|
|
942
|
-
}
|
|
943
|
-
interface ColumnSpec {
|
|
944
|
-
count: number;
|
|
945
|
-
/** Space between columns px. */
|
|
946
|
-
space: number;
|
|
947
|
-
/** Explicit widths px when equalWidth=false. */
|
|
948
|
-
widths?: number[];
|
|
949
|
-
/** Per-column trailing space px (w:col w:space), when explicit w:col
|
|
950
|
-
* entries are present. spaces[i] separates column i from column i+1. */
|
|
951
|
-
spaces?: number[];
|
|
952
|
-
/** w:cols w:sep: paint a vertical rule centered in each inter-column gap. */
|
|
953
|
-
sep?: boolean;
|
|
954
|
-
}
|
|
955
|
-
interface SectionProps {
|
|
956
|
-
pageWidth: number;
|
|
957
|
-
pageHeight: number;
|
|
958
|
-
marginTop: number;
|
|
959
|
-
marginRight: number;
|
|
960
|
-
marginBottom: number;
|
|
961
|
-
marginLeft: number;
|
|
962
|
-
/** Distance of header top from page top, px (w:headerReference distance). */
|
|
963
|
-
headerDistance: number;
|
|
964
|
-
footerDistance: number;
|
|
965
|
-
gutter: number;
|
|
966
|
-
headerRefs: HeaderFooterRefs;
|
|
967
|
-
footerRefs: HeaderFooterRefs;
|
|
968
|
-
/** Different first-page header/footer enabled. */
|
|
969
|
-
titlePage: boolean;
|
|
970
|
-
/** Page numbering restart value, if set. */
|
|
971
|
-
pageNumberStart?: number;
|
|
972
|
-
pageNumberFormat?: string;
|
|
973
|
-
columns: ColumnSpec;
|
|
974
|
-
/** w:docGrid type=lines/linesAndChars: minimum single-line height (px) that
|
|
975
|
-
* the line-spacing multiplier is applied over. Word snaps every line's font
|
|
976
|
-
* height up to this grid pitch (CJK documents). */
|
|
977
|
-
docGridLinePitch?: number;
|
|
978
|
-
/** Present w:docGrid type; omitted w:type means "default". */
|
|
979
|
-
docGridType?: "default" | "lines" | "linesAndChars" | "snapToChars";
|
|
980
|
-
/** w:docGrid type="charsAndLines": a combined char+line grid that (in compat
|
|
981
|
-
* 15) keeps natural East-Asian line pitch. Drives the CJK line-height
|
|
982
|
-
* correction during measurement. */
|
|
983
|
-
docGridCharGrid?: boolean;
|
|
984
|
-
type?: "nextPage" | "continuous" | "evenPage" | "oddPage" | "nextColumn";
|
|
985
|
-
/** Vertical alignment of page content. */
|
|
986
|
-
vAlign?: "top" | "center" | "both" | "bottom";
|
|
987
|
-
/** w:pgBorders. Offsets (border.space, px) measure from text or page edge. */
|
|
988
|
-
pageBorders?: {
|
|
989
|
-
top?: Border;
|
|
990
|
-
bottom?: Border;
|
|
991
|
-
left?: Border;
|
|
992
|
-
right?: Border;
|
|
993
|
-
offsetFrom: "text" | "page";
|
|
994
|
-
};
|
|
995
|
-
/** w:lnNumType: margin line numbering. distance px from the text edge. */
|
|
996
|
-
lineNumbering?: {
|
|
997
|
-
countBy: number;
|
|
998
|
-
start: number;
|
|
999
|
-
distance: number;
|
|
1000
|
-
restart: "continuous" | "newPage" | "newSection";
|
|
1001
|
-
};
|
|
1002
|
-
/** Footnote/endnote mark numbering (w:footnotePr / w:endnotePr). */
|
|
1003
|
-
footnoteNumFmt?: string;
|
|
1004
|
-
footnoteNumStart?: number;
|
|
1005
|
-
endnoteNumFmt?: string;
|
|
1006
|
-
endnoteNumStart?: number;
|
|
1007
|
-
/** w:textDirection tbRl: the whole section flows as East-Asian vertical
|
|
1008
|
-
* writing — lines run top-to-bottom, progressing right-to-left. */
|
|
1009
|
-
textDirection?: "tbRl";
|
|
1010
|
-
}
|
|
1011
|
-
interface Section {
|
|
1012
|
-
props: SectionProps;
|
|
1013
|
-
blocks: Block[];
|
|
1014
|
-
}
|
|
1015
|
-
/** A review comment from word/comments.xml. */
|
|
1016
|
-
interface DocComment {
|
|
1017
|
-
id: string;
|
|
1018
|
-
author: string;
|
|
1019
|
-
initials?: string;
|
|
1020
|
-
/** ISO timestamp from w:date, verbatim. */
|
|
1021
|
-
date?: string;
|
|
1022
|
-
/** Plain text of the comment body (paragraphs joined with newlines). */
|
|
1023
|
-
text: string;
|
|
1024
|
-
/** w14:paraId of the comment's last body paragraph (threading key). */
|
|
1025
|
-
paraId?: string;
|
|
1026
|
-
/** Parent comment id when this comment is a reply (commentsExtended). */
|
|
1027
|
-
parentId?: string;
|
|
1028
|
-
}
|
|
1029
|
-
interface HeaderFooter {
|
|
1030
|
-
blocks: Block[];
|
|
1031
|
-
}
|
|
1032
|
-
/** One w:tblStylePr conditional-formatting block (firstRow, band1Horz, …). */
|
|
1033
|
-
interface TableCondFormat {
|
|
1034
|
-
/** Cell shading fill as CSS color. */
|
|
1035
|
-
shd?: string;
|
|
1036
|
-
/** Conditional cell borders. */
|
|
1037
|
-
borders?: {
|
|
1038
|
-
top?: Border;
|
|
1039
|
-
bottom?: Border;
|
|
1040
|
-
left?: Border;
|
|
1041
|
-
right?: Border;
|
|
1042
|
-
insideH?: Border;
|
|
1043
|
-
insideV?: Border;
|
|
1044
|
-
};
|
|
1045
|
-
/** Conditional run bold (firstRow/firstCol headers). */
|
|
1046
|
-
bold?: boolean;
|
|
1047
|
-
/** Full conditional run props (w:tblStylePr > w:rPr). */
|
|
1048
|
-
rPr?: RunProps;
|
|
1049
|
-
}
|
|
1050
|
-
type TableCondType = "wholeTable" | "band1Vert" | "band2Vert" | "band1Horz" | "band2Horz" | "firstRow" | "lastRow" | "firstCol" | "lastCol" | "nwCell" | "neCell" | "swCell" | "seCell";
|
|
1051
|
-
interface Style {
|
|
1052
|
-
id: string;
|
|
1053
|
-
type: "paragraph" | "character" | "table" | "numbering";
|
|
1054
|
-
name?: string;
|
|
1055
|
-
basedOn?: string;
|
|
1056
|
-
isDefault?: boolean;
|
|
1057
|
-
pPr?: ParaProps;
|
|
1058
|
-
rPr?: RunProps;
|
|
1059
|
-
tblPr?: TableProps;
|
|
1060
|
-
/** w:tblStylePr conditional formats, by type (table styles only). */
|
|
1061
|
-
condFormats?: Map<TableCondType, TableCondFormat>;
|
|
1062
|
-
/** w:tblStyleRowBandSize / ColBandSize (default 1). */
|
|
1063
|
-
rowBandSize?: number;
|
|
1064
|
-
colBandSize?: number;
|
|
1065
|
-
}
|
|
1066
|
-
interface Styles {
|
|
1067
|
-
byId: Map<string, Style>;
|
|
1068
|
-
defaultParagraphStyle?: string;
|
|
1069
|
-
defaultRPr: RunProps;
|
|
1070
|
-
defaultPPr: ParaProps;
|
|
1071
|
-
}
|
|
1072
|
-
interface NumberingLevel {
|
|
1073
|
-
ilvl: number;
|
|
1074
|
-
start: number;
|
|
1075
|
-
format: string;
|
|
1076
|
-
/** Template like "%1." */
|
|
1077
|
-
text: string;
|
|
1078
|
-
alignment: Alignment;
|
|
1079
|
-
/** Paragraph props contributed by the level (indents). */
|
|
1080
|
-
pPr?: ParaProps;
|
|
1081
|
-
rPr?: RunProps;
|
|
1082
|
-
suffix: "tab" | "space" | "nothing";
|
|
1083
|
-
restartAfter?: number;
|
|
1084
|
-
}
|
|
1085
|
-
interface AbstractNum {
|
|
1086
|
-
id: number;
|
|
1087
|
-
levels: Map<number, NumberingLevel>;
|
|
1088
|
-
numStyleLink?: string;
|
|
1089
|
-
}
|
|
1090
|
-
interface NumInstance {
|
|
1091
|
-
numId: number;
|
|
1092
|
-
abstractNumId: number;
|
|
1093
|
-
overrides: Map<number, {
|
|
1094
|
-
startOverride?: number;
|
|
1095
|
-
level?: NumberingLevel;
|
|
1096
|
-
}>;
|
|
1097
|
-
}
|
|
1098
|
-
interface Numbering {
|
|
1099
|
-
abstract: Map<number, AbstractNum>;
|
|
1100
|
-
instances: Map<number, NumInstance>;
|
|
1101
|
-
}
|
|
1102
|
-
interface Theme {
|
|
1103
|
-
majorFont: string;
|
|
1104
|
-
minorFont: string;
|
|
1105
|
-
majorBidiFont?: string;
|
|
1106
|
-
minorBidiFont?: string;
|
|
1107
|
-
/** East Asian faces from theme <a:ea> (fontScheme major/minorFont). Word's
|
|
1108
|
-
* eastAsiaTheme="minor/majorEastAsia" resolves through these, NOT the Latin
|
|
1109
|
-
* minor/major font — routing a CJK run's theme reference to the Latin face
|
|
1110
|
-
* (Calibri) leaves East Asian text in a glyphless Latin font. */
|
|
1111
|
-
majorEastAsiaFont?: string;
|
|
1112
|
-
minorEastAsiaFont?: string;
|
|
1113
|
-
colors: Map<string, string>;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
/** A read-only view over the OPC (zip) package inside a .docx file. */
|
|
1117
|
-
declare class Package {
|
|
1118
|
-
private files;
|
|
1119
|
-
constructor(data: Uint8Array);
|
|
1120
|
-
static from(data: ArrayBuffer | Uint8Array): Package;
|
|
1121
|
-
has(name: string): boolean;
|
|
1122
|
-
binary(name: string): Uint8Array | undefined;
|
|
1123
|
-
text(name: string): string | undefined;
|
|
1124
|
-
names(): string[];
|
|
1125
|
-
/** Raw entry map (shared, do not mutate) — used for write-back. */
|
|
1126
|
-
raw(): Record<string, Uint8Array>;
|
|
1127
|
-
/** OPC part names never start with '/' inside the zip; tolerate both. */
|
|
1128
|
-
private normalize;
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
interface Relationship {
|
|
1132
|
-
id: string;
|
|
1133
|
-
type: string;
|
|
1134
|
-
target: string;
|
|
1135
|
-
external: boolean;
|
|
1136
|
-
}
|
|
1137
|
-
type Relationships = Map<string, Relationship>;
|
|
1138
|
-
|
|
1139
|
-
/**
|
|
1140
|
-
* A fully parsed .docx: sections of blocks, styles, numbering, theme, and
|
|
1141
|
-
* header/footer parts, with helpers to resolve effective formatting.
|
|
1142
|
-
*/
|
|
1143
|
-
declare class DocxDocument {
|
|
1144
|
-
/** Changes whenever refresh() rebuilds the parsed model. Plain in-place text
|
|
1145
|
-
* edits can keep this stable so incremental layout reuses model-only caches. */
|
|
1146
|
-
private _modelVersion;
|
|
1147
|
-
private _packageResourceVersion;
|
|
1148
|
-
get modelVersion(): number;
|
|
1149
|
-
/** Invalidate layout derived from related parts such as ChartML. */
|
|
1150
|
-
markPackageResourceChanged(): void;
|
|
1151
|
-
readonly pkg: Package;
|
|
1152
|
-
readonly theme: Theme;
|
|
1153
|
-
styles: Styles;
|
|
1154
|
-
numbering: Numbering;
|
|
1155
|
-
sections: Section[];
|
|
1156
|
-
/** Header/footer parts keyed by relationship id from document.xml.rels. */
|
|
1157
|
-
readonly headers: Map<string, HeaderFooter>;
|
|
1158
|
-
readonly footers: Map<string, HeaderFooter>;
|
|
1159
|
-
/** Note content by note id (render-only; sources stripped). */
|
|
1160
|
-
readonly footnotes: Map<number, Block[]>;
|
|
1161
|
-
readonly endnotes: Map<number, Block[]>;
|
|
1162
|
-
/** The separator paragraph controls the gap between its rule and the first
|
|
1163
|
-
* footnote. */
|
|
1164
|
-
readonly footnoteSeparator: Block[];
|
|
1165
|
-
/** `_Ref` cross-reference bookmark ranges (name → captured runs). REF
|
|
1166
|
-
* fields re-render the referenced text from these — Word recomputes REF on
|
|
1167
|
-
* open, so the cached field result in the file is stale. */
|
|
1168
|
-
refBookmarks: Map<string, Run[]>;
|
|
1169
|
-
readonly documentRels: Relationships;
|
|
1170
|
-
/** settings.xml w:evenAndOddHeaders — enables the "even" header/footer variants. */
|
|
1171
|
-
readonly evenAndOddHeaders: boolean;
|
|
1172
|
-
/** settings.xml w:mirrorMargins — facing-page (book fold) margins: even
|
|
1173
|
-
* (verso) pages swap the left/right margins and place the gutter on the
|
|
1174
|
-
* inside (right) edge so the binding margin stays on the inner side of
|
|
1175
|
-
* each spread. */
|
|
1176
|
-
readonly mirrorMargins: boolean;
|
|
1177
|
-
/** settings.xml w:defaultTabStop in px (Word default 0.5"). */
|
|
1178
|
-
readonly defaultTabStop: number;
|
|
1179
|
-
/** settings.xml w:compat compatibilityMode (12=Word2007, 14=Word2010,
|
|
1180
|
-
* 15=Word2013+). Word 2013 (mode 15) introduced suppressing a paragraph's
|
|
1181
|
-
* space-before when it lands at the top of a page; mode 14 and earlier keep
|
|
1182
|
-
* it (nccih: a Heading1/2 after a page break sits at margin + its before).
|
|
1183
|
-
* Absent → treated as current (15). */
|
|
1184
|
-
readonly compatibilityMode: number;
|
|
1185
|
-
/** settings.xml m:mathPr/m:defJc — default justification for display
|
|
1186
|
-
* equations whose m:oMathParaPr carries no explicit m:jc (Word default:
|
|
1187
|
-
* centerGroup — the rows of a broken equation left-align to each other and
|
|
1188
|
-
* the group is centered in the column). */
|
|
1189
|
-
readonly mathDefJc: "left" | "right" | "center" | "centerGroup";
|
|
1190
|
-
/** settings.xml m:mathPr/m:wrapIndent in px (Word default 1440tw = 1"):
|
|
1191
|
-
* indent of auto-wrapped display-equation continuation rows from the
|
|
1192
|
-
* equation group's left edge (dense p13: the "+Dc(...)" continuations sit
|
|
1193
|
-
* exactly 72pt right of the explicit rows). */
|
|
1194
|
-
readonly mathWrapIndent: number;
|
|
1195
|
-
/** Review comments from word/comments.xml (empty when the part is absent).
|
|
1196
|
-
* Re-derived from the retained comments XML on every refresh(). */
|
|
1197
|
-
comments: DocComment[];
|
|
1198
|
-
/** Retained comments.xml tree (editing + save round-trip), when present. */
|
|
1199
|
-
private commentsPart;
|
|
1200
|
-
private commentsRoot;
|
|
1201
|
-
/** Retained commentsExtended.xml tree (comment threading), when present. */
|
|
1202
|
-
private commentsExtPart;
|
|
1203
|
-
private commentsExtRoot;
|
|
1204
|
-
private commentsExtDirty;
|
|
1205
|
-
/** Conditional table formats per table style id, keyed by the Styles object
|
|
1206
|
-
* so re-parsing styles.xml (edits) naturally invalidates the cache. */
|
|
1207
|
-
private tableCondCache;
|
|
1208
|
-
/** Retained styles.xml tree (built-in style injection + save). */
|
|
1209
|
-
private stylesPart;
|
|
1210
|
-
private stylesRoot;
|
|
1211
|
-
/** Retained numbering.xml tree (list creation + save round-trip). */
|
|
1212
|
-
private numberingPart;
|
|
1213
|
-
private numberingRoot;
|
|
1214
|
-
private numberingDirty;
|
|
1215
|
-
/** Retained footnotes.xml tree (footnote insertion + save round-trip). */
|
|
1216
|
-
private footnotesPart;
|
|
1217
|
-
private footnotesRoot;
|
|
1218
|
-
private footnotesDirty;
|
|
1219
|
-
private footnotesRels;
|
|
1220
|
-
/** Serialize retained optional parts only once actually mutated, keeping
|
|
1221
|
-
* untouched parts byte-identical through save(). */
|
|
1222
|
-
private stylesDirty;
|
|
1223
|
-
private commentsDirty;
|
|
1224
|
-
/** Retained XML roots — source of truth for editing and save(). */
|
|
1225
|
-
private readonly docPart;
|
|
1226
|
-
/** Retained settings.xml tree. A synthetic empty root keeps history root
|
|
1227
|
-
* indices stable for documents that did not originally contain the part. */
|
|
1228
|
-
private readonly settingsPart;
|
|
1229
|
-
private readonly settingsRoot;
|
|
1230
|
-
private settingsDirty;
|
|
1231
|
-
/** Parsed document.xml root (read-only outside the class; the layout engine
|
|
1232
|
-
* scans it for incremental-reuse eligibility, tests walk it). */
|
|
1233
|
-
readonly docRoot: XmlElement;
|
|
1234
|
-
private readonly hfParts;
|
|
1235
|
-
private readonly ctxBase;
|
|
1236
|
-
/** Tracked-changes display mode; refresh() re-derives after changes. */
|
|
1237
|
-
revisionView: "final" | "markup";
|
|
1238
|
-
private readonly relsPath;
|
|
1239
|
-
private relsRoot;
|
|
1240
|
-
private contentTypesRoot;
|
|
1241
|
-
/** Canonical XML as first parsed from each always-modeled package part.
|
|
1242
|
-
* If the retained tree still matches on save, keep the part's original
|
|
1243
|
-
* bytes instead of replacing producer formatting such as CRLF line ends. */
|
|
1244
|
-
private readonly originalModeledXml;
|
|
1245
|
-
private nextDocPrId;
|
|
1246
|
-
/** Transient layout state: set by the engine while laying out a docGrid
|
|
1247
|
-
* type="charsAndLines" section so line measurement can give East-Asian
|
|
1248
|
-
* glyphs their true (uninflated) grid line height. Off outside such a
|
|
1249
|
-
* section. Safe as document-scoped mutable state because layout is
|
|
1250
|
-
* single-threaded and sequential per section. */
|
|
1251
|
-
charGridEa: boolean;
|
|
1252
|
-
private constructor();
|
|
1253
|
-
/** Resolve content controls mapped to standard package core properties.
|
|
1254
|
-
* Word refreshes these bindings on open, so the serialized sdtContent can
|
|
1255
|
-
* be stale even though the visible value comes from docProps/core.xml. */
|
|
1256
|
-
private hydrateCorePropertyControls;
|
|
1257
|
-
/** Repair only objects emitted by older WordInWeb builds that Word rejects. */
|
|
1258
|
-
private repairLegacyWordInWebObjects;
|
|
1259
|
-
/**
|
|
1260
|
-
* Re-derive the document model from the retained XML trees. Called after
|
|
1261
|
-
* edit commands mutate the XML.
|
|
1262
|
-
*/
|
|
1263
|
-
/** Switch tracked-changes display and re-derive the model. */
|
|
1264
|
-
setRevisionView(view: "final" | "markup"): void;
|
|
1265
|
-
/** Invalidated on refresh; see layoutGlobalSig. */
|
|
1266
|
-
private _layoutGlobalSig;
|
|
1267
|
-
/** Signature of everything OUTSIDE a paragraph's own XML that affects how it
|
|
1268
|
-
* breaks into lines: style + numbering definitions, doc-level layout scalars,
|
|
1269
|
-
* and the tracked-changes view mode. The line-break cache (layout/inline.ts)
|
|
1270
|
-
* combines this with a paragraph's own content signature so a style/numbering/
|
|
1271
|
-
* settings edit invalidates cached breaks even though the paragraph XML is
|
|
1272
|
-
* unchanged. Memoized until the next refresh() (styles/numbering trees are
|
|
1273
|
-
* stable across a plain text edit). */
|
|
1274
|
-
layoutGlobalSig(): string;
|
|
1275
|
-
refresh(): void;
|
|
1276
|
-
/** Reparse the two sibling body-story paragraphs created by Enter without
|
|
1277
|
-
* rebuilding the complete document model. Paragraphs nested in table cells
|
|
1278
|
-
* are included because legal documents spend most of their body inside
|
|
1279
|
-
* tables; revisions, bookmarks, fields, and section breaks use refresh(). */
|
|
1280
|
-
reparseDirectBodyParagraphSplit(beforeSource: XmlElement, afterSource: XmlElement): {
|
|
1281
|
-
before: Paragraph;
|
|
1282
|
-
after: Paragraph;
|
|
1283
|
-
} | null;
|
|
1284
|
-
/** Insert a new paragraph immediately before a retained body paragraph
|
|
1285
|
-
* without rebuilding the complete document model. Used by Enter at the
|
|
1286
|
-
* exact paragraph start, where the existing paragraph itself is unchanged. */
|
|
1287
|
-
insertDirectBodyParagraphBefore(referenceSource: XmlElement, insertedSource: XmlElement): Paragraph | null;
|
|
1288
|
-
/** Reparse a body paragraph plus several new siblings created by
|
|
1289
|
-
* click-and-type without rebuilding the complete document model. */
|
|
1290
|
-
reparseDirectBodyParagraphSplits(beforeSource: XmlElement, afterSources: XmlElement[]): Paragraph[] | null;
|
|
1291
|
-
/** Reparse one retained body-story paragraph after a structural edit that
|
|
1292
|
-
* leaves its surrounding block list unchanged, such as inserting ink. */
|
|
1293
|
-
reparseBodyParagraph(source: XmlElement): Paragraph | null;
|
|
1294
|
-
/** Reparse two sibling body-story paragraphs after Backspace/Delete merged
|
|
1295
|
-
* their XML into one. Keeps the parsed model generation stable so long
|
|
1296
|
-
* documents can use incremental layout instead of repaginating in full. */
|
|
1297
|
-
reparseDirectBodyParagraphMerge(beforeSource: XmlElement, afterSource: XmlElement, survivorSource: XmlElement): Paragraph | null;
|
|
1298
|
-
private deriveComments;
|
|
1299
|
-
/** Retained comments tree for edit commands (null when the doc has none). */
|
|
1300
|
-
/**
|
|
1301
|
-
* Retained comments tree. With create=true, a missing comments.xml part is
|
|
1302
|
-
* created and registered (content type + document relationship) so newly
|
|
1303
|
-
* added comments serialize and round-trip through Word.
|
|
1304
|
-
*/
|
|
1305
|
-
commentsTree(create?: boolean): XmlElement | null;
|
|
1306
|
-
/**
|
|
1307
|
-
* Make sure a paragraph style is usable: Word ships built-in definitions
|
|
1308
|
-
* for Heading 1-6/Title even when a file doesn't declare them, so applying
|
|
1309
|
-
* one to such a file must inject a standard definition (otherwise the
|
|
1310
|
-
* paragraph would reference an undefined style and render as Normal).
|
|
1311
|
-
*/
|
|
1312
|
-
ensureParagraphStyle(styleId: string): boolean;
|
|
1313
|
-
/**
|
|
1314
|
-
* Retained numbering tree. With create=true, a missing numbering.xml part
|
|
1315
|
-
* is created and registered (content type + document relationship) so list
|
|
1316
|
-
* definitions added by editing serialize and round-trip.
|
|
1317
|
-
*/
|
|
1318
|
-
numberingTree(create?: boolean): XmlElement | null;
|
|
1319
|
-
markNumberingChanged(): void;
|
|
1320
|
-
/**
|
|
1321
|
-
* Retained footnotes tree. With create=true, a missing footnotes.xml part
|
|
1322
|
-
* is created and registered (with Word's required separator footnotes) so
|
|
1323
|
-
* inserted footnotes serialize and round-trip.
|
|
1324
|
-
*/
|
|
1325
|
-
footnotesTree(create?: boolean): XmlElement | null;
|
|
1326
|
-
/**
|
|
1327
|
-
* Create an empty header/footer part (with a default-type reference in
|
|
1328
|
-
* every sectPr) when the document has none - Word does this implicitly the
|
|
1329
|
-
* first time you edit the header area. Returns the part's root.
|
|
1330
|
-
*/
|
|
1331
|
-
ensureHfPart(kind: "header" | "footer"): XmlElement;
|
|
1332
|
-
markFootnotesChanged(): void;
|
|
1333
|
-
/** Called by comment edit commands after mutating the comments tree. */
|
|
1334
|
-
markCommentsChanged(): void;
|
|
1335
|
-
/**
|
|
1336
|
-
* Retained commentsExtended tree (threading). With create=true, a missing
|
|
1337
|
-
* part is created and registered (content type + document relationship) so
|
|
1338
|
-
* Word picks up reply threading.
|
|
1339
|
-
*/
|
|
1340
|
-
commentsExtendedTree(create?: boolean): XmlElement | null;
|
|
1341
|
-
markCommentsExtendedChanged(): void;
|
|
1342
|
-
/**
|
|
1343
|
-
* The w:t elements covered by each comment's range, in document order.
|
|
1344
|
-
* Point comments (a bare commentReference with no range) anchor to the
|
|
1345
|
-
* nearest preceding w:t.
|
|
1346
|
-
*/
|
|
1347
|
-
commentAnchors(): Map<string, XmlElement[]>;
|
|
1348
|
-
/** Flag the footnotes part dirty when `t` lives inside it, so save()
|
|
1349
|
-
* re-serializes footnotes.xml. Called by the editor after a text edit; a
|
|
1350
|
-
* no-op for body/header/footer targets. */
|
|
1351
|
-
markDirtyIfFootnote(t: XmlElement): void;
|
|
1352
|
-
/** The mutable XML roots (document body, related modeled parts, settings).
|
|
1353
|
-
* settingsRoot is always second and always present so its history snapshot
|
|
1354
|
-
* index stays stable even when optional related roots are created later. */
|
|
1355
|
-
editableRoots(): XmlElement[];
|
|
1356
|
-
/** Toggle the document-global facing-page margin mode in settings.xml. */
|
|
1357
|
-
setMirrorMargins(enabled: boolean): void;
|
|
1358
|
-
/**
|
|
1359
|
-
* Find the parent element of `target` in any modeled XML tree (document
|
|
1360
|
-
* body, headers, footers). Linear scan — documents are small and this only
|
|
1361
|
-
* runs on structural edits (Enter, paragraph merge).
|
|
1362
|
-
*/
|
|
1363
|
-
/** XML roots that can carry tracked changes: body, headers/footers, footnotes. */
|
|
1364
|
-
revisionRoots(): XmlElement[];
|
|
1365
|
-
findParentOf(target: XmlElement): XmlElement | undefined;
|
|
1366
|
-
/**
|
|
1367
|
-
* Serialize the (possibly edited) document back to .docx bytes. Only the
|
|
1368
|
-
* XML parts we model are re-serialized; every other part round-trips
|
|
1369
|
-
* byte-for-byte.
|
|
1370
|
-
*/
|
|
1371
|
-
private rememberOriginalXml;
|
|
1372
|
-
private writeModeledXml;
|
|
1373
|
-
/**
|
|
1374
|
-
* Canonicalize producer shorthand that Google Docs otherwise interprets as
|
|
1375
|
-
* a fixed, few-twip table. Word treats `tblW="100%"` plus a placeholder
|
|
1376
|
-
* grid as autofit; Google needs the standard pct value and a usable cached
|
|
1377
|
-
* grid. The cached widths follow the same content-dominant shape and do not
|
|
1378
|
-
* change Word's autofit result.
|
|
1379
|
-
*/
|
|
1380
|
-
private normalizePercentageTableGrids;
|
|
1381
|
-
save(): Uint8Array;
|
|
1382
|
-
/** Fresh unique docPr id for inserted drawings. */
|
|
1383
|
-
nextDrawingId(): number;
|
|
1384
|
-
/** Next unused revision id (w:id on w:ins/w:del). Seeded once past the
|
|
1385
|
-
* highest id already present in any editable root so a document that
|
|
1386
|
-
* already has tracked changes never collides. */
|
|
1387
|
-
private revIdCounter;
|
|
1388
|
-
nextRevisionId(): number;
|
|
1389
|
-
/**
|
|
1390
|
-
* Add image bytes as a new media part + relationship (+ content-type
|
|
1391
|
-
* default). Returns the relationship id for use in a w:drawing.
|
|
1392
|
-
*/
|
|
1393
|
-
private ensureRelsRoot;
|
|
1394
|
-
/** Register an external hyperlink relationship and return its rId. */
|
|
1395
|
-
addHyperlinkRel(url: string): string;
|
|
1396
|
-
/** Retarget an existing external relationship (hyperlink href edit). */
|
|
1397
|
-
setRelTarget(relId: string, url: string): boolean;
|
|
1398
|
-
addImageResource(bytes: Uint8Array, ext: string): string;
|
|
1399
|
-
/** Add a GLB model part and its Office 2019 model3d relationship. */
|
|
1400
|
-
addModel3DResource(bytes: Uint8Array): {
|
|
1401
|
-
relId: string;
|
|
1402
|
-
part: string;
|
|
1403
|
-
};
|
|
1404
|
-
/** Add an OLE package part used by a Word w:object. */
|
|
1405
|
-
addEmbeddedObjectResource(bytes: Uint8Array): {
|
|
1406
|
-
relId: string;
|
|
1407
|
-
part: string;
|
|
1408
|
-
};
|
|
1409
|
-
/** Add a DOCX package embedded as an activatable Word.Document.12 object. */
|
|
1410
|
-
addEmbeddedWordDocumentResource(bytes: Uint8Array): {
|
|
1411
|
-
relId: string;
|
|
1412
|
-
part: string;
|
|
1413
|
-
};
|
|
1414
|
-
/** Add a native ChartML part and its embedded editable workbook. */
|
|
1415
|
-
addChartResource(chartXml: string, workbook: Uint8Array): {
|
|
1416
|
-
relId: string;
|
|
1417
|
-
part: string;
|
|
1418
|
-
};
|
|
1419
|
-
/** Add the SmartArt data/layout/style/color parts and its cached diagram drawing. */
|
|
1420
|
-
addSmartArtResources(layoutXml: string, styleXml: string, colorsXml: string, drawingXml: string, dataXml: (drawingRelId: string) => string): {
|
|
1421
|
-
dataRelId: string;
|
|
1422
|
-
layoutRelId: string;
|
|
1423
|
-
styleRelId: string;
|
|
1424
|
-
colorsRelId: string;
|
|
1425
|
-
drawingRelId: string;
|
|
1426
|
-
};
|
|
1427
|
-
static load(data: ArrayBuffer | Uint8Array): DocxDocument;
|
|
1428
|
-
media(part: string): Uint8Array | undefined;
|
|
1429
|
-
/** Effective paragraph properties: docDefaults → table style → style chain → direct. */
|
|
1430
|
-
effectiveParaProps(para: Paragraph): ParaProps;
|
|
1431
|
-
/**
|
|
1432
|
-
* Run props contributed by the enclosing table style's conditional
|
|
1433
|
-
* w:tblStylePr blocks for this paragraph's cell (undefined when the
|
|
1434
|
-
* paragraph isn't in a styled table cell or nothing applies).
|
|
1435
|
-
*/
|
|
1436
|
-
private tableCondRPr;
|
|
1437
|
-
/** Effective run properties for a run inside a paragraph. */
|
|
1438
|
-
effectiveRunProps(para: Paragraph, runProps: RunProps): RunProps;
|
|
1439
|
-
numberingLevel(numId: number, ilvl: number): NumberingLevel | undefined;
|
|
1440
|
-
numberingInstance(numId: number): NumInstance | undefined;
|
|
1441
|
-
private findDocumentPart;
|
|
1442
|
-
private readXmlOptional;
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
/** Maps a rendered text item back to its source XML for editing. */
|
|
1446
|
-
interface TextSource {
|
|
1447
|
-
run: Run;
|
|
1448
|
-
/** Source w:t; null when the text is synthetic (fields, symbols). */
|
|
1449
|
-
t: XmlElement | null;
|
|
1450
|
-
/** Char offset of this item's first character within t's text. */
|
|
1451
|
-
offset: number;
|
|
1452
|
-
}
|
|
1453
|
-
/**
|
|
1454
|
-
* Layout output: pages of absolutely positioned primitives (px, page-relative).
|
|
1455
|
-
* The renderer maps these 1:1 to DOM/canvas/SVG — no further layout happens
|
|
1456
|
-
* downstream, which is what guarantees pagination fidelity.
|
|
1457
|
-
*/
|
|
1458
|
-
interface FontSpec {
|
|
1459
|
-
family: string;
|
|
1460
|
-
size: number;
|
|
1461
|
-
bold: boolean;
|
|
1462
|
-
italic: boolean;
|
|
1463
|
-
/** Pair kerning is active because the run met its w:kern size threshold. */
|
|
1464
|
-
kerning?: boolean;
|
|
1465
|
-
/** Optional PAINT-only family tried before `family` in the CSS stack, without
|
|
1466
|
-
* affecting metrics or width lookups (keyed by `family`). Used for CJK: the
|
|
1467
|
-
* line-pitch profile stays keyed by the macOS substitute face while the real
|
|
1468
|
-
* Windows glyphs (MS Mincho, Microsoft JhengHei, …) paint when available. */
|
|
1469
|
-
paintFamily?: string;
|
|
1470
|
-
/** PAINT-only vertical nudge (CSS px, positive = down) applied to the glyphs
|
|
1471
|
-
* without touching layout metrics or advances. Used when a substitute face
|
|
1472
|
-
* (Latha for Word's Tamil Vijaya) sits on a different baseline than the face
|
|
1473
|
-
* Word rasterized; the shift lands the glyphs on Word's baseline. */
|
|
1474
|
-
paintDY?: number;
|
|
1475
|
-
}
|
|
1476
|
-
interface PathItem {
|
|
1477
|
-
kind: "path";
|
|
1478
|
-
x: number;
|
|
1479
|
-
y: number;
|
|
1480
|
-
width: number;
|
|
1481
|
-
height: number;
|
|
1482
|
-
/** SVG path data in a `viewW x viewH` coordinate space. */
|
|
1483
|
-
d: string;
|
|
1484
|
-
viewW: number;
|
|
1485
|
-
viewH: number;
|
|
1486
|
-
fill?: string;
|
|
1487
|
-
stroke?: {
|
|
1488
|
-
color: string;
|
|
1489
|
-
width: number;
|
|
1490
|
-
opacity?: number;
|
|
1491
|
-
};
|
|
1492
|
-
rotate?: {
|
|
1493
|
-
deg: number;
|
|
1494
|
-
ox: number;
|
|
1495
|
-
oy: number;
|
|
1496
|
-
};
|
|
1497
|
-
/** Paint under / over the body text (anchored-shape layering). */
|
|
1498
|
-
behind?: boolean;
|
|
1499
|
-
front?: boolean;
|
|
1500
|
-
z?: number;
|
|
1501
|
-
}
|
|
1502
|
-
interface TextItem {
|
|
1503
|
-
kind: "text";
|
|
1504
|
-
x: number;
|
|
1505
|
-
/** Baseline y. */
|
|
1506
|
-
baseline: number;
|
|
1507
|
-
width: number;
|
|
1508
|
-
text: string;
|
|
1509
|
-
props: RunProps;
|
|
1510
|
-
font: FontSpec;
|
|
1511
|
-
/** Footnote/endnote id referenced by this run (registration happens when
|
|
1512
|
-
* the item lands on a real page - split table rows carry it across). */
|
|
1513
|
-
noteId?: number;
|
|
1514
|
-
/** Vertical stretch for tall delimiter glyphs (Word's glyph variants). */
|
|
1515
|
-
mathScaleY?: number;
|
|
1516
|
-
/** Horizontal stretch for wide brace glyphs (Word's over/under brace
|
|
1517
|
-
* variants), applied about the glyph box's horizontal center. */
|
|
1518
|
-
mathScaleX?: number;
|
|
1519
|
-
/** Stretch anchor above the baseline, px. */
|
|
1520
|
-
mathScaleAnchor?: number;
|
|
1521
|
-
/** Line box for selection/highlight backgrounds. */
|
|
1522
|
-
lineTop: number;
|
|
1523
|
-
lineHeight: number;
|
|
1524
|
-
/** Exact glyph box for baseline-shifted runs (superscript/subscript):
|
|
1525
|
-
* the renderer anchors these instead of bottoming on the line box. */
|
|
1526
|
-
glyphTop?: number;
|
|
1527
|
-
glyphBoxH?: number;
|
|
1528
|
-
/** Small-caps reduced segment: the base run font that must supply the
|
|
1529
|
-
* strut so the painted baseline matches neighboring full-size spans (the
|
|
1530
|
-
* renderer sizes the outer span with this font and shrinks the text via
|
|
1531
|
-
* a baseline-aligned inner span). */
|
|
1532
|
-
strutFont?: FontSpec;
|
|
1533
|
-
/** PAGEREF bookmark name: the final pass rewrites this item's text with
|
|
1534
|
-
* the bookmark's page number (Word recomputes PAGEREF on open; the docx
|
|
1535
|
-
* cached result is stale in real TOCs). */
|
|
1536
|
-
pageRef?: string;
|
|
1537
|
-
/** DOCX bookmarks that begin on this text item. */
|
|
1538
|
-
bookmarks?: string[];
|
|
1539
|
-
/** Source m:oMath element when this text is a piece of an equation. */
|
|
1540
|
-
mathSrc?: XmlElement;
|
|
1541
|
-
href?: string;
|
|
1542
|
-
/** Present for editable text (absent on numbering labels etc.). */
|
|
1543
|
-
src?: TextSource;
|
|
1544
|
-
/** Source drawing when this text belongs to an independently editable
|
|
1545
|
-
* text-box story. */
|
|
1546
|
-
textboxStory?: XmlElement;
|
|
1547
|
-
/** Rotate about a point (px, relative to this item's top-left). */
|
|
1548
|
-
rotate?: {
|
|
1549
|
-
deg: number;
|
|
1550
|
-
ox: number;
|
|
1551
|
-
oy: number;
|
|
1552
|
-
};
|
|
1553
|
-
/** Paint under the body text (behindDoc textbox content). */
|
|
1554
|
-
behind?: boolean;
|
|
1555
|
-
/** Paint over the body text (non-behindDoc anchored shape content: Word
|
|
1556
|
-
* layers in-front shapes above the text layer). */
|
|
1557
|
-
front?: boolean;
|
|
1558
|
-
z?: number;
|
|
1559
|
-
/** Right-to-left run: renderer sets direction:rtl so the browser shapes and
|
|
1560
|
-
* orders the (Arabic/Hebrew) glyphs within the span box. */
|
|
1561
|
-
rtl?: boolean;
|
|
1562
|
-
/** Ordinal of the source paragraph within its cell/frame. Set only for
|
|
1563
|
-
* widow-controlled paragraphs; row splitting uses it to scope Word's
|
|
1564
|
-
* widow/orphan rules to the paragraph straddling the cut. */
|
|
1565
|
-
paraSeq?: number;
|
|
1566
|
-
/** Editor-only: maximum caret x for this item — a trailing hanging space
|
|
1567
|
-
* confined to its table cell pins the caret at the cell's content edge
|
|
1568
|
-
* (Word behavior) while the span keeps its true hanging layout x. */
|
|
1569
|
-
caretClampX?: number;
|
|
1570
|
-
}
|
|
1571
|
-
interface RectItem {
|
|
1572
|
-
kind: "rect";
|
|
1573
|
-
x: number;
|
|
1574
|
-
y: number;
|
|
1575
|
-
width: number;
|
|
1576
|
-
height: number;
|
|
1577
|
-
fill: string;
|
|
1578
|
-
/** Semantic paint provenance used by render-layer comparison. */
|
|
1579
|
-
role?: "table-fill";
|
|
1580
|
-
/** Rotate about a point (px, relative to this item's top-left). */
|
|
1581
|
-
rotate?: {
|
|
1582
|
-
deg: number;
|
|
1583
|
-
ox: number;
|
|
1584
|
-
oy: number;
|
|
1585
|
-
};
|
|
1586
|
-
behind?: boolean;
|
|
1587
|
-
/** Paint over the body text (non-behindDoc anchored shape fill). */
|
|
1588
|
-
front?: boolean;
|
|
1589
|
-
z?: number;
|
|
1590
|
-
}
|
|
1591
|
-
interface LineEdgeItem {
|
|
1592
|
-
kind: "edge";
|
|
1593
|
-
x1: number;
|
|
1594
|
-
y1: number;
|
|
1595
|
-
x2: number;
|
|
1596
|
-
y2: number;
|
|
1597
|
-
border: Border;
|
|
1598
|
-
/** Semantic paint provenance used by render-layer comparison. */
|
|
1599
|
-
role?: "table-rule";
|
|
1600
|
-
/** Rotate about a point (px, relative to this item's top-left). */
|
|
1601
|
-
rotate?: {
|
|
1602
|
-
deg: number;
|
|
1603
|
-
ox: number;
|
|
1604
|
-
oy: number;
|
|
1605
|
-
};
|
|
1606
|
-
/** Paint over the body text (non-behindDoc anchored shape border). */
|
|
1607
|
-
front?: boolean;
|
|
1608
|
-
/** Paint below the body text (behindDoc anchored shape border). */
|
|
1609
|
-
behind?: boolean;
|
|
1610
|
-
z?: number;
|
|
1611
|
-
}
|
|
1612
|
-
interface ImageItem {
|
|
1613
|
-
kind: "image";
|
|
1614
|
-
x: number;
|
|
1615
|
-
y: number;
|
|
1616
|
-
width: number;
|
|
1617
|
-
height: number;
|
|
1618
|
-
/** Package part path; renderer resolves bytes via DocxDocument.media(). */
|
|
1619
|
-
part: string;
|
|
1620
|
-
/** a:srcRect crop (fractions) and a:xfrm rotation (degrees). */
|
|
1621
|
-
crop?: {
|
|
1622
|
-
l: number;
|
|
1623
|
-
t: number;
|
|
1624
|
-
r: number;
|
|
1625
|
-
b: number;
|
|
1626
|
-
};
|
|
1627
|
-
rotation?: number;
|
|
1628
|
-
/** Whole-group rotation about an external origin. */
|
|
1629
|
-
rotate?: {
|
|
1630
|
-
deg: number;
|
|
1631
|
-
ox: number;
|
|
1632
|
-
oy: number;
|
|
1633
|
-
};
|
|
1634
|
-
/** Picture-watermark "washout" (VML v:imagedata gain/blacklevel, 0..1
|
|
1635
|
-
* fractions). Per-channel linear recolor, measured against Word's PDF of
|
|
1636
|
-
* probe2-picture-watermark (gain 0.3, blacklevel 0.35: source 32 -> 215,
|
|
1637
|
-
* 74 -> 227, 135 -> 246, 210 -> clamped 255):
|
|
1638
|
-
* out = in * gain + 255 * (blacklevel * (1 + gain) + (1 - gain) / 2) */
|
|
1639
|
-
washout?: {
|
|
1640
|
-
gain: number;
|
|
1641
|
-
blacklevel: number;
|
|
1642
|
-
};
|
|
1643
|
-
/** a:ln picture outline, drawn just outside the image (Word hairline). */
|
|
1644
|
-
border?: {
|
|
1645
|
-
color: string;
|
|
1646
|
-
width: number;
|
|
1647
|
-
};
|
|
1648
|
-
/** behindDoc: paint under the text layer. */
|
|
1649
|
-
behind?: boolean;
|
|
1650
|
-
/** wrapNone + !behindDoc ("in front of text"): paint ABOVE the text layer
|
|
1651
|
-
* (Word's z-order; without this, later-emitted text spans cover the image
|
|
1652
|
-
* and it neither shows in front nor receives clicks/drags). */
|
|
1653
|
-
front?: boolean;
|
|
1654
|
-
z?: number;
|
|
1655
|
-
/** Source w:drawing element (for interactive resize/move). */
|
|
1656
|
-
src?: XmlElement;
|
|
1657
|
-
model3D?: Model3DReference;
|
|
1658
|
-
webVideo?: WebVideoReference;
|
|
1659
|
-
embeddedObject?: EmbeddedObjectReference;
|
|
1660
|
-
}
|
|
1661
|
-
interface ChartItem {
|
|
1662
|
-
kind: "chart";
|
|
1663
|
-
x: number;
|
|
1664
|
-
y: number;
|
|
1665
|
-
width: number;
|
|
1666
|
-
height: number;
|
|
1667
|
-
data: ChartData;
|
|
1668
|
-
}
|
|
1669
|
-
/** Interactive resize zone over a table boundary (column or row). */
|
|
1670
|
-
interface DrawingHitItem {
|
|
1671
|
-
kind: "drawingHit";
|
|
1672
|
-
x: number;
|
|
1673
|
-
y: number;
|
|
1674
|
-
width: number;
|
|
1675
|
-
height: number;
|
|
1676
|
-
/** Source w:drawing element (select/move the whole drawing). */
|
|
1677
|
-
src: XmlElement;
|
|
1678
|
-
/** Anchored drawings drag by offset; inline ones re-anchor into text. */
|
|
1679
|
-
anchored: boolean;
|
|
1680
|
-
/** Freehand stroke that may be removed with the Draw ribbon's eraser. */
|
|
1681
|
-
ink?: boolean;
|
|
1682
|
-
/** Native SmartArt diagram selection target. */
|
|
1683
|
-
smartArt?: boolean;
|
|
1684
|
-
/** Node hit boxes inside the SmartArt drawing, relative to this item. */
|
|
1685
|
-
smartArtNodes?: Array<{
|
|
1686
|
-
index: number;
|
|
1687
|
-
x: number;
|
|
1688
|
-
y: number;
|
|
1689
|
-
width: number;
|
|
1690
|
-
height: number;
|
|
1691
|
-
}>;
|
|
1692
|
-
chartData?: ChartData;
|
|
1693
|
-
smartArtData?: SmartArtData;
|
|
1694
|
-
/** A shape fill hit that sits UNDER the shape's own text spans (same z): a
|
|
1695
|
-
* click on bare fill selects or drags the shape, while clicks on its text
|
|
1696
|
-
* glyphs still reach the text editor. */
|
|
1697
|
-
belowText?: boolean;
|
|
1698
|
-
/** Keep a behindDoc drawing target under the body text. */
|
|
1699
|
-
behind?: boolean;
|
|
1700
|
-
/** The drawing owns an independently editable text-box story. */
|
|
1701
|
-
textboxStory?: boolean;
|
|
1702
|
-
rotate?: {
|
|
1703
|
-
deg: number;
|
|
1704
|
-
ox: number;
|
|
1705
|
-
oy: number;
|
|
1706
|
-
};
|
|
1707
|
-
z?: number;
|
|
1708
|
-
}
|
|
1709
|
-
interface GripItem {
|
|
1710
|
-
kind: "grip";
|
|
1711
|
-
/** "col": vertical zone at x spanning y1..y2. "row": horizontal zone at y1
|
|
1712
|
-
* spanning x..x2. "move": table bounds x..x2, y1..y2. */
|
|
1713
|
-
axis: "col" | "row" | "move";
|
|
1714
|
-
x: number;
|
|
1715
|
-
y1: number;
|
|
1716
|
-
y2: number;
|
|
1717
|
-
/** Right edge for row grips. */
|
|
1718
|
-
x2?: number;
|
|
1719
|
-
/** Source w:tbl element. */
|
|
1720
|
-
tbl: XmlElement;
|
|
1721
|
-
/** col: boundary 1..n (n = right edge). row: row index above the boundary. */
|
|
1722
|
-
boundary: number;
|
|
1723
|
-
/** Laid-out height of the row above (row grips), px. */
|
|
1724
|
-
rowHeightPx?: number;
|
|
1725
|
-
/** Rendered column widths px (col grips) — resize works in this space. */
|
|
1726
|
-
renderedWidths?: number[];
|
|
1727
|
-
}
|
|
1728
|
-
/** WordArt/watermark text scaled to fill a box, rotated about its center. */
|
|
1729
|
-
interface WordArtItem {
|
|
1730
|
-
kind: "wordart";
|
|
1731
|
-
/** Box top-left, px. */
|
|
1732
|
-
x: number;
|
|
1733
|
-
y: number;
|
|
1734
|
-
width: number;
|
|
1735
|
-
height: number;
|
|
1736
|
-
text: string;
|
|
1737
|
-
fontFamily: string;
|
|
1738
|
-
bold?: boolean;
|
|
1739
|
-
italic?: boolean;
|
|
1740
|
-
fill: string;
|
|
1741
|
-
opacity: number;
|
|
1742
|
-
/** Clockwise degrees. */
|
|
1743
|
-
rotation: number;
|
|
1744
|
-
behind?: boolean;
|
|
1745
|
-
/** Source v:textpath font-size (px). */
|
|
1746
|
-
fontSize?: number;
|
|
1747
|
-
/** Malformed shapetype guide path: Word collapses the fitted glyph outlines
|
|
1748
|
-
* into a thin vertical band. */
|
|
1749
|
-
noFit?: boolean;
|
|
1750
|
-
/** Source VML shape element (v:shape / v:rect), for interactive select/edit. */
|
|
1751
|
-
src?: XmlElement;
|
|
1752
|
-
}
|
|
1753
|
-
/** DrawingML a:prstTxWarp text: the shape's single text line bent onto a
|
|
1754
|
-
* preset envelope (arch/wave/chevron/circle-pour), filling the shape box. */
|
|
1755
|
-
interface WarpTextItem {
|
|
1756
|
-
kind: "warptext";
|
|
1757
|
-
/** Shape box top-left, px. */
|
|
1758
|
-
x: number;
|
|
1759
|
-
y: number;
|
|
1760
|
-
width: number;
|
|
1761
|
-
height: number;
|
|
1762
|
-
text: string;
|
|
1763
|
-
fontFamily: string;
|
|
1764
|
-
/** Run font size px (the text's natural size; presets that don't fill the
|
|
1765
|
-
* box — textArchUp — ride the text at this size). */
|
|
1766
|
-
fontSize: number;
|
|
1767
|
-
bold?: boolean;
|
|
1768
|
-
italic?: boolean;
|
|
1769
|
-
/** CSS text color. */
|
|
1770
|
-
fill: string;
|
|
1771
|
-
/** Preset name (textArchUp, textWave1, textChevron, textCirclePour, …). */
|
|
1772
|
-
warp: string;
|
|
1773
|
-
rotate?: {
|
|
1774
|
-
deg: number;
|
|
1775
|
-
ox: number;
|
|
1776
|
-
oy: number;
|
|
1777
|
-
};
|
|
1778
|
-
behind?: boolean;
|
|
1779
|
-
front?: boolean;
|
|
1780
|
-
z?: number;
|
|
1781
|
-
}
|
|
1782
|
-
type PageItem = TextItem | PathItem | RectItem | LineEdgeItem | ImageItem | ChartItem | DrawingHitItem | GripItem | WordArtItem | WarpTextItem;
|
|
1783
|
-
interface LaidOutPage {
|
|
1784
|
-
width: number;
|
|
1785
|
-
height: number;
|
|
1786
|
-
/** 1-based physical index. */
|
|
1787
|
-
index: number;
|
|
1788
|
-
/** Display page number after pgNumType.start is applied. */
|
|
1789
|
-
number: number;
|
|
1790
|
-
items: PageItem[];
|
|
1791
|
-
/** Body box (for header/footer editing chrome). */
|
|
1792
|
-
bodyTop: number;
|
|
1793
|
-
bodyBottom: number;
|
|
1794
|
-
/** Items from this index on belong to the header/footer parts. */
|
|
1795
|
-
hfStart: number;
|
|
1796
|
-
/** Column geometry for editor hit-testing. A page can contain more than one
|
|
1797
|
-
* band when a continuous section changes the column layout mid-page. */
|
|
1798
|
-
columnBands: Array<{
|
|
1799
|
-
top: number;
|
|
1800
|
-
colXs: number[];
|
|
1801
|
-
colWidths: number[];
|
|
1802
|
-
}>;
|
|
1803
|
-
}
|
|
1804
|
-
interface LayoutResult {
|
|
1805
|
-
pages: LaidOutPage[];
|
|
1806
|
-
totalPages: number;
|
|
1807
|
-
/** Opaque incremental-reuse state (engine-internal); pass a previous result
|
|
1808
|
-
* back as LayoutOptions.prev to enable incremental relayout. Not part of the
|
|
1809
|
-
* rendered output and ignored by the equivalence harness. */
|
|
1810
|
-
_incr?: unknown;
|
|
1811
|
-
/** Internal marker: unchanged pages in this result retain exact object
|
|
1812
|
-
* identity from the previous layout, so the DOM diff can use identity
|
|
1813
|
-
* instead of structurally walking a dense changed page. */
|
|
1814
|
-
_incremental?: boolean;
|
|
1815
|
-
/** Exclusive global page index through which an incremental render may run
|
|
1816
|
-
* pageEq before the page containing the exact dirty text source. */
|
|
1817
|
-
_incrementalStructuralPrefixEnd?: number;
|
|
1818
|
-
/** Opaque page state used to refresh headers/footers without repaginating
|
|
1819
|
-
* the body when their measured geometry is unchanged. */
|
|
1820
|
-
_hf?: unknown;
|
|
1821
|
-
}
|
|
1822
|
-
|
|
1823
|
-
interface FontMetrics {
|
|
1824
|
-
/** px above baseline (raw font ascent - anchors CSS glyph boxes). */
|
|
1825
|
-
ascent: number;
|
|
1826
|
-
/** px below baseline, raw (positive - anchors CSS glyph boxes). */
|
|
1827
|
-
descent: number;
|
|
1828
|
-
/** Natural single-spaced line height px (what Word calls single spacing). */
|
|
1829
|
-
lineHeight: number;
|
|
1830
|
-
/** Word's below-baseline share of lineHeight (quantized); use for
|
|
1831
|
-
* baseline placement. Falls back to `descent` when absent. */
|
|
1832
|
-
lineDescent?: number;
|
|
1833
|
-
}
|
|
1834
|
-
interface TextMeasurer {
|
|
1835
|
-
width(text: string, font: FontSpec, letterSpacing?: number): number;
|
|
1836
|
-
metrics(font: FontSpec): FontMetrics;
|
|
1837
|
-
/** The browser's own font box (fontBoundingBoxAscent/Descent) for the
|
|
1838
|
-
* resolved first face of this font's CSS stack, when the host can know it.
|
|
1839
|
-
* Used to anchor paint-routed CJK spans: the DOM renderer centers glyphs
|
|
1840
|
-
* by the browser strut, which differs from the engine's calibrated line
|
|
1841
|
-
* profile (Hiragino/PingFang) whenever the real Windows face paints. */
|
|
1842
|
-
paintBox?(font: FontSpec): {
|
|
1843
|
-
ascent: number;
|
|
1844
|
-
descent: number;
|
|
1845
|
-
} | undefined;
|
|
1846
|
-
/** Ink extents (actualBoundingBox*) of `text` in the RESOLVED paint face,
|
|
1847
|
-
* px above/below the baseline. The radical join needs the √ glyph's real
|
|
1848
|
-
* ink — which face paints it (real Cambria Math vs the STIX substitute)
|
|
1849
|
-
* changes the extents, so a baked table can't cover both. */
|
|
1850
|
-
inkBox?(text: string, font: FontSpec): {
|
|
1851
|
-
ascent: number;
|
|
1852
|
-
descent: number;
|
|
1853
|
-
} | undefined;
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
interface LayoutOptions {
|
|
1857
|
-
measurer?: TextMeasurer;
|
|
1858
|
-
/** Previous layout result (from an earlier layoutDocument call on the same
|
|
1859
|
-
* document). Enables incremental relayout: pages whose input blocks and
|
|
1860
|
-
* lead-in state are unchanged are reused instead of re-laid. The engine falls
|
|
1861
|
-
* back to a full layout whenever it cannot prove reuse is byte-identical. */
|
|
1862
|
-
prev?: LayoutResult;
|
|
1863
|
-
/** The top-level block XML element (w:p / w:tbl) the editor mutated IN PLACE
|
|
1864
|
-
* since `prev` — the paragraph the caret sits in for a single-character
|
|
1865
|
-
* type/delete. Lets the incremental scan skip re-hashing every block: it
|
|
1866
|
-
* re-hashes only the hinted block and its two neighbours and reuses prev's
|
|
1867
|
-
* per-block signatures for the rest. Purely an optimisation — the fast path
|
|
1868
|
-
* is gated on block identity/count and neighbour-signature checks, so a stale
|
|
1869
|
-
* or wrong hint falls through to the full block scan. */
|
|
1870
|
-
dirtyHint?: XmlElement;
|
|
1871
|
-
/** Exact retained text element changed by a local edit. Used only to bound
|
|
1872
|
-
* structural page comparison before the first actually dirty page. */
|
|
1873
|
-
dirtySource?: XmlElement;
|
|
1874
|
-
}
|
|
1875
|
-
declare function layoutDocument(doc: DocxDocument, options?: LayoutOptions): LayoutResult;
|
|
1876
|
-
|
|
1877
|
-
interface RenderOptions {
|
|
1878
|
-
/** Zoom factor (1 = 100%). */
|
|
1879
|
-
zoom?: number;
|
|
1880
|
-
/** Gap between pages, px. */
|
|
1881
|
-
pageGap?: number;
|
|
1882
|
-
/** Page drop shadow / chrome. */
|
|
1883
|
-
pageShadow?: boolean;
|
|
1884
|
-
/** Materialize interactive affordances (table resize grips). */
|
|
1885
|
-
interactive?: boolean;
|
|
1886
|
-
/** Keep only nearby page contents mounted. Page shells always remain so
|
|
1887
|
-
* scroll geometry is unchanged. Intended for long interactive documents. */
|
|
1888
|
-
virtualize?: boolean;
|
|
1889
|
-
/** Called after the mounted page window changes so editor chrome can be
|
|
1890
|
-
* restored on newly-mounted pages. */
|
|
1891
|
-
onViewportChange?: () => void;
|
|
1892
|
-
/** Show review comments (highlight + margin balloons). Default true. */
|
|
1893
|
-
comments?: boolean;
|
|
1894
|
-
/** Called when the user deletes a comment from its balloon. The balloon
|
|
1895
|
-
* shows a delete button only when this is provided. */
|
|
1896
|
-
onDeleteComment?: (id: string) => void;
|
|
1897
|
-
/** Called when the user submits a reply from a balloon's reply box. The
|
|
1898
|
-
* reply box only renders when this is provided. */
|
|
1899
|
-
onReplyComment?: (id: string, text: string) => void;
|
|
1900
|
-
}
|
|
1901
|
-
interface TextBinding {
|
|
1902
|
-
el: HTMLElement;
|
|
1903
|
-
item: TextItem;
|
|
1904
|
-
}
|
|
1905
|
-
interface GripBinding {
|
|
1906
|
-
el: HTMLElement;
|
|
1907
|
-
item: GripItem;
|
|
1908
|
-
}
|
|
1909
|
-
interface ImageBinding {
|
|
1910
|
-
el: HTMLElement;
|
|
1911
|
-
item: ImageItem;
|
|
1912
|
-
}
|
|
1913
|
-
interface DrawingBinding {
|
|
1914
|
-
el: HTMLElement;
|
|
1915
|
-
item: DrawingHitItem;
|
|
1916
|
-
}
|
|
1917
|
-
interface WordArtBinding {
|
|
1918
|
-
el: HTMLElement;
|
|
1919
|
-
item: WordArtItem;
|
|
1920
|
-
}
|
|
1921
|
-
interface RenderHandle {
|
|
1922
|
-
/** Root element containing all pages. */
|
|
1923
|
-
root: HTMLElement;
|
|
1924
|
-
/** Rendered text elements in paint order, for selection mapping. */
|
|
1925
|
-
bindings: TextBinding[];
|
|
1926
|
-
/** Mounted text bindings indexed by their retained source w:t element. */
|
|
1927
|
-
bindingsByText: Map<XmlElement, TextBinding[]>;
|
|
1928
|
-
/** Table resize grips (only when options.interactive). */
|
|
1929
|
-
grips: GripBinding[];
|
|
1930
|
-
/** Rendered images, for interactive select/resize/move. */
|
|
1931
|
-
images: ImageBinding[];
|
|
1932
|
-
/** Transparent hit targets over vector drawings/icons (select/move). */
|
|
1933
|
-
drawings: DrawingBinding[];
|
|
1934
|
-
/** WordArt / text watermarks, for interactive select/edit. */
|
|
1935
|
-
wordarts: WordArtBinding[];
|
|
1936
|
-
/** Revoke object URLs etc. */
|
|
1937
|
-
destroy: () => void;
|
|
1938
|
-
/** Temporarily mount every page, returning a function that restores the
|
|
1939
|
-
* viewport window. Used by the synchronous print-clone path. */
|
|
1940
|
-
materializeAll?: () => () => void;
|
|
1941
|
-
/** Recompute the mounted page window after an external scroll/resize. */
|
|
1942
|
-
updateViewport?: () => void;
|
|
1943
|
-
/** Per-page render records, retained so the next render can reuse the DOM of
|
|
1944
|
-
* pages whose layout is unchanged (see renderToDom's `prev` parameter). */
|
|
1945
|
-
_pages?: PageRender[];
|
|
1946
|
-
/** Whether this render drew the comments overlay. Comment highlights live
|
|
1947
|
-
* INSIDE page surfaces, so the next render must sweep them out of any page
|
|
1948
|
-
* DOM it adopts before re-running the overlay. */
|
|
1949
|
-
_hadComments?: boolean;
|
|
1950
|
-
/** Zoom this render painted at — adoption is only valid at the same zoom. */
|
|
1951
|
-
_zoom?: number;
|
|
1952
|
-
/** Whether this handle keeps only a viewport-sized page window mounted. */
|
|
1953
|
-
_virtualized?: boolean;
|
|
1954
|
-
/** Parsed-model generation whose source bindings this handle owns. */
|
|
1955
|
-
_modelVersion?: number;
|
|
1956
|
-
/** Remove viewport listeners before this handle is replaced. */
|
|
1957
|
-
_stopVirtualizer?: () => void;
|
|
1958
|
-
}
|
|
1959
|
-
/** One page's DOM element plus the editor bindings it owns and the object URLs
|
|
1960
|
-
* it created. Retained on the handle so an incremental re-render can adopt an
|
|
1961
|
-
* unchanged page wholesale instead of tearing it down and rebuilding it. */
|
|
1962
|
-
interface PageRender {
|
|
1963
|
-
el: HTMLElement;
|
|
1964
|
-
page: LaidOutPage;
|
|
1965
|
-
bindings: TextBinding[];
|
|
1966
|
-
grips: GripBinding[];
|
|
1967
|
-
images: ImageBinding[];
|
|
1968
|
-
drawings: DrawingBinding[];
|
|
1969
|
-
wordarts: WordArtBinding[];
|
|
1970
|
-
urls: string[];
|
|
1971
|
-
mounted: boolean;
|
|
1972
|
-
}
|
|
1973
|
-
declare function renderToDom(doc: DocxDocument, layout: LayoutResult, container: HTMLElement, options?: RenderOptions, prev?: RenderHandle): RenderHandle;
|
|
1974
|
-
/**
|
|
1975
|
-
* Print the rendered pages (browser print -> paper or PDF): clones the page
|
|
1976
|
-
* DOM into a hidden same-origin iframe sized to the document's page, strips
|
|
1977
|
-
* screen chrome (shadows, gaps), and invokes the print dialog.
|
|
1978
|
-
*/
|
|
1979
|
-
declare function printPages(root: HTMLElement, pageWidthPx: number, pageHeightPx: number): void;
|
|
1980
|
-
|
|
1981
|
-
interface RunFormatPatch {
|
|
1982
|
-
bold?: boolean;
|
|
1983
|
-
italic?: boolean;
|
|
1984
|
-
underline?: boolean;
|
|
1985
|
-
strike?: boolean;
|
|
1986
|
-
/** "#RRGGBB"; null removes the direct color. */
|
|
1987
|
-
color?: string | null;
|
|
1988
|
-
/** Word highlight name ("yellow", "cyan", …); null removes. */
|
|
1989
|
-
highlight?: string | null;
|
|
1990
|
-
/** Font size in points. */
|
|
1991
|
-
fontSizePt?: number;
|
|
1992
|
-
fontFamily?: string;
|
|
1993
|
-
/** Superscript/subscript; null returns the run to the baseline. */
|
|
1994
|
-
verticalAlign?: "superscript" | "subscript" | null;
|
|
1995
|
-
/** Remove all direct character formatting (and character style). */
|
|
1996
|
-
clear?: boolean;
|
|
1997
|
-
}
|
|
1998
|
-
interface SelectionFormat {
|
|
1999
|
-
bold: boolean;
|
|
2000
|
-
italic: boolean;
|
|
2001
|
-
underline: boolean;
|
|
2002
|
-
strike: boolean;
|
|
2003
|
-
/** Common font size in points, if uniform. */
|
|
2004
|
-
fontSizePt?: number;
|
|
2005
|
-
color?: string;
|
|
2006
|
-
highlight?: string;
|
|
2007
|
-
fontFamily?: string;
|
|
2008
|
-
verticalAlign?: "superscript" | "subscript";
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
|
-
type ShapePreset = "line" | "verticalLine" | "rectangle" | "roundedRectangle" | "ellipse" | "diamond" | "textBox";
|
|
2012
|
-
type WordArtPreset = "plain" | "archUp" | "archDown" | "wave" | "chevron";
|
|
2013
|
-
type DrawingLineDash = "solid" | "dashed" | "dotted";
|
|
2014
|
-
type DrawingTool = {
|
|
2015
|
-
kind?: "pen";
|
|
2016
|
-
color: string;
|
|
2017
|
-
width: number;
|
|
2018
|
-
} | {
|
|
2019
|
-
kind: "highlighter";
|
|
2020
|
-
color: string;
|
|
2021
|
-
width: number;
|
|
2022
|
-
} | {
|
|
2023
|
-
kind: "eraser";
|
|
2024
|
-
size: number;
|
|
2025
|
-
} | {
|
|
2026
|
-
kind: "lasso";
|
|
2027
|
-
};
|
|
2028
|
-
|
|
2029
|
-
interface SmartArtTextFormat {
|
|
2030
|
-
fontFamily: string;
|
|
2031
|
-
fontSizePt: number;
|
|
2032
|
-
color: string;
|
|
2033
|
-
bold: boolean;
|
|
2034
|
-
italic: boolean;
|
|
2035
|
-
alignment: "left" | "center" | "right";
|
|
2036
|
-
}
|
|
2037
|
-
|
|
2038
|
-
type ObjectArrangeAction = "alignLeft" | "alignCenter" | "alignRight" | "alignTop" | "alignMiddle" | "alignBottom" | "rotateLeft" | "rotateRight" | "bringToFront" | "sendToBack";
|
|
2039
|
-
type SelectedObjectKind = "shape" | "line" | "smartArt" | "chart" | "image" | "model3d";
|
|
2040
|
-
type SelectedObjectCommand = "altText" | "editText" | "fill" | "outline" | "lineStyle" | "rotate" | "size" | "position" | "wrapInline" | "wrapSquare" | "wrapTopAndBottom" | "wrapFront" | "wrapBehind" | "bringForward" | "sendBackward" | "reset3d" | "delete";
|
|
2041
|
-
|
|
2042
|
-
type ParagraphAlignment = "left" | "center" | "right" | "justify";
|
|
2043
|
-
interface PageLayoutPatch {
|
|
2044
|
-
/** Margins in inches. */
|
|
2045
|
-
margins?: {
|
|
2046
|
-
top?: number;
|
|
2047
|
-
right?: number;
|
|
2048
|
-
bottom?: number;
|
|
2049
|
-
left?: number;
|
|
2050
|
-
};
|
|
2051
|
-
/** Document-global facing-page mode (settings.xml w:mirrorMargins). */
|
|
2052
|
-
mirrorMargins?: boolean;
|
|
2053
|
-
/** Page size in inches (before orientation). */
|
|
2054
|
-
size?: {
|
|
2055
|
-
width: number;
|
|
2056
|
-
height: number;
|
|
2057
|
-
};
|
|
2058
|
-
orientation?: "portrait" | "landscape";
|
|
2059
|
-
/** Equal-width text columns (1 removes w:cols). */
|
|
2060
|
-
columns?: number;
|
|
2061
|
-
/** Draw a vertical rule between text columns. Used with columns > 1. */
|
|
2062
|
-
columnSeparator?: boolean;
|
|
2063
|
-
/** Box page border (null removes). sz in eighth-points, color hex. */
|
|
2064
|
-
pageBorders?: {
|
|
2065
|
-
sz?: number;
|
|
2066
|
-
color?: string;
|
|
2067
|
-
offsetFrom?: "text" | "page";
|
|
2068
|
-
} | null;
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
/**
|
|
2072
|
-
* Table manipulation: add/remove rows and columns relative to the cell
|
|
2073
|
-
* containing the caret. Mutates source XML; callers checkpoint + relayout.
|
|
2074
|
-
*
|
|
2075
|
-
* v1 scope: column operations refuse tables using gridSpan (merged cells)
|
|
2076
|
-
* rather than corrupt them.
|
|
2077
|
-
*/
|
|
2078
|
-
type TableOp = "rowAbove" | "rowBelow" | "deleteRow" | "colLeft" | "colRight" | "deleteCol" | "deleteTable" | "mergeRight" | "mergeDown" | "splitCell" | {
|
|
2079
|
-
kind: "cellShading";
|
|
2080
|
-
fill: string | null;
|
|
2081
|
-
} | {
|
|
2082
|
-
kind: "cellVAlign";
|
|
2083
|
-
v: "top" | "center" | "bottom";
|
|
2084
|
-
};
|
|
2085
|
-
|
|
2086
|
-
type ParagraphDividerStyle = "single" | "double" | "dotted" | "dashed" | "thinThickSmallGap";
|
|
2087
|
-
interface ParagraphDivider {
|
|
2088
|
-
style: ParagraphDividerStyle;
|
|
2089
|
-
color: string;
|
|
2090
|
-
widthPt: number;
|
|
2091
|
-
spacePt: number;
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2094
|
-
interface CoverPageContent {
|
|
2095
|
-
title: string;
|
|
2096
|
-
subtitle?: string;
|
|
2097
|
-
author?: string;
|
|
2098
|
-
}
|
|
2099
|
-
interface LineNumberingPatch {
|
|
2100
|
-
/** Turn margin line numbering on/off for the target section(s). */
|
|
2101
|
-
enabled: boolean;
|
|
2102
|
-
/** Number every Nth line (1/5/10). Default 1 when first enabled. */
|
|
2103
|
-
countBy?: number;
|
|
2104
|
-
/** When the count resets. Default newPage when first enabled. */
|
|
2105
|
-
restart?: "continuous" | "newPage" | "newSection";
|
|
2106
|
-
/** First line number. Default 1. */
|
|
2107
|
-
start?: number;
|
|
2108
|
-
}
|
|
2109
|
-
|
|
2110
|
-
interface MissingFont {
|
|
2111
|
-
/** The face the document asked for (first name in the item's stack). */
|
|
2112
|
-
family: string;
|
|
2113
|
-
/** A short sample of text that will render in a substitute. */
|
|
2114
|
-
sample: string;
|
|
2115
|
-
}
|
|
2116
|
-
|
|
2117
|
-
interface ToolbarMenuSelectOption {
|
|
2118
|
-
value: string;
|
|
2119
|
-
label: React.ReactNode;
|
|
2120
|
-
group?: string;
|
|
2121
|
-
disabled?: boolean;
|
|
2122
|
-
fontFamily?: string;
|
|
2123
|
-
}
|
|
2124
|
-
interface ToolbarMenuSelectProps {
|
|
2125
|
-
value: string;
|
|
2126
|
-
options: ToolbarMenuSelectOption[];
|
|
2127
|
-
onChange: (value: string) => void;
|
|
2128
|
-
placeholder?: React.ReactNode;
|
|
2129
|
-
title?: string;
|
|
2130
|
-
ariaLabel?: string;
|
|
2131
|
-
triggerAriaLabel?: string;
|
|
2132
|
-
width?: number | string;
|
|
2133
|
-
menuWidth?: number;
|
|
2134
|
-
className?: string;
|
|
2135
|
-
style?: React.CSSProperties;
|
|
2136
|
-
}
|
|
2137
|
-
/** CSS-overridable replacement for visible native selects. An inert,
|
|
2138
|
-
* transparent select is kept as an event bridge for existing integrations;
|
|
2139
|
-
* every user-facing part is a button/listbox rendered by us. */
|
|
2140
|
-
declare function ToolbarMenuSelect({ value, options, onChange, placeholder, title, ariaLabel, triggerAriaLabel, width, menuWidth, className, style, }: ToolbarMenuSelectProps): react.JSX.Element;
|
|
2141
|
-
/** Toolbar control groups a host can disable via the `features` prop. */
|
|
2142
|
-
type ToolbarFeature = "history" | "styles" | "font" | "size" | "format" | "color" | "highlight" | "alignment" | "indent" | "spacing" | "link" | "lists" | "table" | "image" | "icon" | "screenshot" | "model3D" | "media" | "object" | "chart" | "smartArt" | "comment" | "footnote" | "bookmark" | "crossReference" | "dateTime" | "field" | "equation" | "symbol" | "shape" | "divider" | "textBox" | "wordArt" | "drawing" | "arrange" | "dropCap" | "headerFooter" | "coverPage" | "pageNumber" | "break" | "layout" | "help" | "download";
|
|
2143
|
-
type ToolbarMode = "simple" | "advanced";
|
|
2144
|
-
interface DocxToolbarProps {
|
|
2145
|
-
api: DocxViewApi | null;
|
|
2146
|
-
onSave?: (bytes: Uint8Array) => void;
|
|
2147
|
-
/** Simple shows basic Home editing; advanced adds the Insert, Draw, and Layout ribbons. */
|
|
2148
|
-
mode?: ToolbarMode;
|
|
2149
|
-
/** Per-group overrides; every group defaults to enabled. */
|
|
2150
|
-
features?: Partial<Record<ToolbarFeature, boolean>>;
|
|
2151
|
-
/** Extra class on the toolbar root (e.g. a scope for CSS-variable overrides). */
|
|
2152
|
-
className?: string;
|
|
2153
|
-
/** Inline overrides merged onto the toolbar root; wins over the defaults. */
|
|
2154
|
-
style?: React.CSSProperties;
|
|
2155
|
-
}
|
|
2156
|
-
declare function DocxToolbar({ api, onSave, mode, features, className, style, }: DocxToolbarProps): react.JSX.Element;
|
|
2157
|
-
|
|
2158
|
-
interface DocxViewApi {
|
|
2159
|
-
/** Apply character formatting to the current browser selection. */
|
|
2160
|
-
applyFormat(patch: RunFormatPatch): void;
|
|
2161
|
-
/** Create a review comment on the current selection. False if no selection. */
|
|
2162
|
-
addComment(text: string): boolean;
|
|
2163
|
-
/** Insert a footnote at the caret. False without a caret. */
|
|
2164
|
-
addFootnote(text: string): boolean;
|
|
2165
|
-
/** Insert a dynamic page-number field at the caret (body, header or footer). */
|
|
2166
|
-
insertPageNumber(kind?: "page" | "pageOfTotal"): boolean;
|
|
2167
|
-
/** Insert any Word field instruction supported by the renderer. */
|
|
2168
|
-
insertField(instruction: string, cachedResult?: string): boolean;
|
|
2169
|
-
/** Insert a live DATE or TIME field with an optional Word date picture. */
|
|
2170
|
-
insertDateTime(kind: "date" | "time", picture?: string): boolean;
|
|
2171
|
-
/** Named bookmarks in document order. */
|
|
2172
|
-
listBookmarks(): string[];
|
|
2173
|
-
/** Add a bookmark around the selection, or a zero-length bookmark at the caret. */
|
|
2174
|
-
addBookmark(name: string): boolean;
|
|
2175
|
-
/** Insert a live text or page reference to a bookmark. */
|
|
2176
|
-
insertCrossReference(bookmark: string, kind: "text" | "page"): boolean;
|
|
2177
|
-
/** Insert an editable inline equation from WordInWeb's linear math syntax. */
|
|
2178
|
-
insertEquation(linear: string): boolean;
|
|
2179
|
-
/** Insert a Unicode symbol through the normal undo/suggestion-aware typing path. */
|
|
2180
|
-
insertSymbol(symbol: string): boolean;
|
|
2181
|
-
/** Insert a floating editable DrawingML shape at the caret. */
|
|
2182
|
-
insertShape(preset: ShapePreset, text?: string, lineStyle?: {
|
|
2183
|
-
color: string;
|
|
2184
|
-
width: number;
|
|
2185
|
-
dash: DrawingLineDash;
|
|
2186
|
-
}): boolean;
|
|
2187
|
-
/** Insert editable DrawingML WordArt at the caret. */
|
|
2188
|
-
insertWordArt(text: string, preset?: WordArtPreset): boolean;
|
|
2189
|
-
/** Insert a native editable ChartML chart at the caret. */
|
|
2190
|
-
insertChart(data: ChartData): boolean;
|
|
2191
|
-
/** Replace the selected native chart's type and data. */
|
|
2192
|
-
updateSelectedChart(data: ChartData): boolean;
|
|
2193
|
-
/** Data for the selected native chart, or null when another object is selected. */
|
|
2194
|
-
getSelectedChart(): ChartData | null;
|
|
2195
|
-
/** Insert a native editable SmartArt diagram at the caret. */
|
|
2196
|
-
insertSmartArt(data: SmartArtData): boolean;
|
|
2197
|
-
/** Replace the selected native SmartArt diagram's layout and node text. */
|
|
2198
|
-
updateSelectedSmartArt(data: SmartArtData): boolean;
|
|
2199
|
-
/** Data for the selected native SmartArt diagram, or null when another object is selected. */
|
|
2200
|
-
getSelectedSmartArt(): SmartArtData | null;
|
|
2201
|
-
/** Text formatting for the selected SmartArt node, or the first node when the group is selected. */
|
|
2202
|
-
getSelectedSmartArtTextFormat(): SmartArtTextFormat | null;
|
|
2203
|
-
/** Format the selected SmartArt node, or every node when the group is selected. */
|
|
2204
|
-
setSelectedSmartArtTextFormat(patch: Partial<SmartArtTextFormat>): boolean;
|
|
2205
|
-
/** Insert a native Office 3D model with an optional custom poster image. */
|
|
2206
|
-
insertModel3D(file: Blob, poster?: Blob): Promise<boolean>;
|
|
2207
|
-
/** Insert Word online-video metadata with a browser-safe poster. */
|
|
2208
|
-
insertOnlineVideo(url: string): Promise<boolean>;
|
|
2209
|
-
/** Embed an arbitrary file as a native OLE Package object. */
|
|
2210
|
-
insertEmbeddedObject(file: Blob, filename?: string): Promise<boolean>;
|
|
2211
|
-
/** Activate a freehand pen, or return to selection mode with null. */
|
|
2212
|
-
setDrawingTool(tool: DrawingTool | null): void;
|
|
2213
|
-
/** Current freehand pen, or null while in selection mode. */
|
|
2214
|
-
getDrawingTool(): DrawingTool | null;
|
|
2215
|
-
/** Align, rotate, or reorder the selected image, shape, or ink group. */
|
|
2216
|
-
arrangeObject(action: ObjectArrangeAction): boolean;
|
|
2217
|
-
/** True while an image, shape, or ink group is selected. */
|
|
2218
|
-
hasSelectedObject(): boolean;
|
|
2219
|
-
/** Kind of the selected object, used by contextual formatting controls. */
|
|
2220
|
-
getSelectedObjectContext(): {
|
|
2221
|
-
kind: SelectedObjectKind;
|
|
2222
|
-
canEditText: boolean;
|
|
2223
|
-
smartArtNodeSelected?: boolean;
|
|
2224
|
-
smartArtNodeIndex?: number;
|
|
2225
|
-
} | null;
|
|
2226
|
-
/** Run a formatting command against the current selected object. */
|
|
2227
|
-
runSelectedObjectCommand(command: SelectedObjectCommand): boolean;
|
|
2228
|
-
undo(): void;
|
|
2229
|
-
redo(): void;
|
|
2230
|
-
canUndo(): boolean;
|
|
2231
|
-
canRedo(): boolean;
|
|
2232
|
-
/** Insert a rows×cols table at the caret's paragraph. */
|
|
2233
|
-
insertTable(rows: number, cols: number): void;
|
|
2234
|
-
/** Row/column/table operations on the table containing the caret. */
|
|
2235
|
-
tableOp(op: TableOp): void;
|
|
2236
|
-
/** Current table-cell fill, undefined when the caret is outside a table. */
|
|
2237
|
-
getTableCellFill(): string | null | undefined;
|
|
2238
|
-
/** Insert an image file at the caret (inline, natural size clamped to column). */
|
|
2239
|
-
insertImage(file: Blob): Promise<void>;
|
|
2240
|
-
/** Capture a screen, window, or browser tab and insert the current frame as a PNG picture. */
|
|
2241
|
-
insertScreenshot(): Promise<ScreenshotInsertResult>;
|
|
2242
|
-
/** Align the paragraph(s) under the caret or selection. */
|
|
2243
|
-
setAlignment(align: ParagraphAlignment): void;
|
|
2244
|
-
/** Apply a named paragraph style (null clears back to Normal). */
|
|
2245
|
-
setParagraphStyle(styleId: string | null): void;
|
|
2246
|
-
/** Toggle bulleted/numbered list on the paragraph(s) under the selection. */
|
|
2247
|
-
toggleList(kind: "bullet" | "number"): void;
|
|
2248
|
-
/** Current list kind at the caret ("bullet" | "number" | null). */
|
|
2249
|
-
getListType(): "bullet" | "number" | null;
|
|
2250
|
-
/** Link the selection to a URL; null removes the link at the caret. */
|
|
2251
|
-
setLink(url: string | null): void;
|
|
2252
|
-
/** URL of the hyperlink at the caret/selection, or null. */
|
|
2253
|
-
getLinkAt(): string | null;
|
|
2254
|
-
/** Step paragraph indent by half an inch (Word's indent buttons). */
|
|
2255
|
-
adjustIndent(direction: 1 | -1): void;
|
|
2256
|
-
/** Line spacing multiple or exact point height, and/or space before/after (points). */
|
|
2257
|
-
setParagraphSpacing(patch: {
|
|
2258
|
-
lineMultiple?: number;
|
|
2259
|
-
exactLinePt?: number;
|
|
2260
|
-
beforePt?: number | null;
|
|
2261
|
-
afterPt?: number | null;
|
|
2262
|
-
}): void;
|
|
2263
|
-
/** Create, customize, or remove the bottom-border divider on the selected paragraph(s). */
|
|
2264
|
-
setParagraphDivider(divider: ParagraphDivider | null): boolean;
|
|
2265
|
-
/** Direct bottom-border divider on the caret paragraph. */
|
|
2266
|
-
getParagraphDivider(): ParagraphDivider | null;
|
|
2267
|
-
/** Apply or remove a native Word drop cap on the caret paragraph. */
|
|
2268
|
-
setDropCap(mode: "drop" | "margin" | null, lines?: number): boolean;
|
|
2269
|
-
/** Remove direct character formatting from the selection. */
|
|
2270
|
-
clearFormatting(): void;
|
|
2271
|
-
/** Change the selection's case. */
|
|
2272
|
-
changeCase(mode: "upper" | "lower" | "title"): void;
|
|
2273
|
-
/** Find matches for a query; selects the first and returns the count. */
|
|
2274
|
-
find(query: string, opts?: {
|
|
2275
|
-
matchCase?: boolean;
|
|
2276
|
-
}): number;
|
|
2277
|
-
/** Select the next/previous match; returns 1-based index or 0. */
|
|
2278
|
-
findStep(delta: 1 | -1): number;
|
|
2279
|
-
/** Replace the current match; returns remaining match count. */
|
|
2280
|
-
replaceCurrent(replacement: string): number;
|
|
2281
|
-
/** Replace every match; returns how many were replaced. */
|
|
2282
|
-
replaceAll(query: string, replacement: string): number;
|
|
2283
|
-
/** Paragraph styles for the style menu (declared + Word built-ins). */
|
|
2284
|
-
listParagraphStyles(): {
|
|
2285
|
-
id: string;
|
|
2286
|
-
name: string;
|
|
2287
|
-
}[];
|
|
2288
|
-
/** pStyle id of the caret paragraph (null = Normal). */
|
|
2289
|
-
getParagraphStyleId(): string | null;
|
|
2290
|
-
/** Change margins / page size / orientation (inches). */
|
|
2291
|
-
setPageLayout(patch: PageLayoutPatch, scope?: "document" | "section"): void;
|
|
2292
|
-
/** One-based logical section containing the caret or selection. */
|
|
2293
|
-
getSectionContext(): {
|
|
2294
|
-
index: number;
|
|
2295
|
-
count: number;
|
|
2296
|
-
} | null;
|
|
2297
|
-
/** Insert a page/column break or a section break at the caret. */
|
|
2298
|
-
insertBreak(kind: "page" | "column" | "sectionNextPage" | "sectionContinuous"): boolean;
|
|
2299
|
-
/** Insert a full blank page at the caret (two consecutive page breaks). */
|
|
2300
|
-
insertBlankPage(): boolean;
|
|
2301
|
-
/** Insert an editable cover page before the current document. */
|
|
2302
|
-
insertCoverPage(content: CoverPageContent): boolean;
|
|
2303
|
-
/** Toggle/configure margin line numbers (Word's Layout > Line Numbers).
|
|
2304
|
-
* scope "section" targets the caret's section; "document" every section. */
|
|
2305
|
-
setLineNumbering(patch: LineNumberingPatch, scope?: "document" | "section"): void;
|
|
2306
|
-
/** Current line-numbering settings for the caret's section, or null (off). */
|
|
2307
|
-
getLineNumbering(): {
|
|
2308
|
-
countBy: number;
|
|
2309
|
-
restart: "continuous" | "newPage" | "newSection";
|
|
2310
|
-
start: number;
|
|
2311
|
-
} | null;
|
|
2312
|
-
/** Leave header/footer editing mode. */
|
|
2313
|
-
closeHeaderFooter(): void;
|
|
2314
|
-
/** Enter and, if needed, create the header or footer on the caret's page. */
|
|
2315
|
-
openHeaderFooter(kind: "header" | "footer"): boolean;
|
|
2316
|
-
/** Effective formatting of the current selection (toolbar state), or null. */
|
|
2317
|
-
getSelectionFormat(): SelectionFormat | null;
|
|
2318
|
-
/** Print the rendered pages (browser print dialog / save as PDF). */
|
|
2319
|
-
print(): void;
|
|
2320
|
-
/** Serialize the (edited) document back to .docx bytes. */
|
|
2321
|
-
save(): Uint8Array;
|
|
2322
|
-
/** Page count after the latest layout. */
|
|
2323
|
-
pageCount(): number;
|
|
2324
|
-
/**
|
|
2325
|
-
* Suggesting mode: when on, edits record as OOXML tracked changes (w:ins /
|
|
2326
|
-
* w:del) instead of mutating text directly, and the view switches to markup
|
|
2327
|
-
* so the suggestion shows live. `author` stamps the revision (defaults to the
|
|
2328
|
-
* commentAuthor prop). Turning it off restores the prior revision view.
|
|
2329
|
-
*/
|
|
2330
|
-
setSuggesting(on: boolean, author?: string): void;
|
|
2331
|
-
isSuggesting(): boolean;
|
|
2332
|
-
/** Accept the tracked change at the caret (keep insertion / apply deletion). */
|
|
2333
|
-
acceptRevisionAtCaret(): boolean;
|
|
2334
|
-
/** Reject the tracked change at the caret (drop insertion / restore deletion). */
|
|
2335
|
-
rejectRevisionAtCaret(): boolean;
|
|
2336
|
-
/** How many tracked changes (suggestions) the document currently holds. */
|
|
2337
|
-
revisionCount(): number;
|
|
2338
|
-
/** Accept every tracked change (one undo step). Returns how many applied. */
|
|
2339
|
-
acceptAllRevisions(): number;
|
|
2340
|
-
/** Reject every tracked change (one undo step). Returns how many applied. */
|
|
2341
|
-
rejectAllRevisions(): number;
|
|
2342
|
-
document: DocxDocument;
|
|
2343
|
-
}
|
|
2344
|
-
type ScreenshotInsertResult = "inserted" | "unsupported" | "cancelled" | "error" | "no-caret";
|
|
2345
|
-
interface DocxViewProps {
|
|
2346
|
-
/** The document: raw bytes, a File/Blob, or a URL to fetch. */
|
|
2347
|
-
source: ArrayBuffer | Uint8Array | Blob | string;
|
|
2348
|
-
/** Zoom factor, 1 = 100%. */
|
|
2349
|
-
zoom?: number;
|
|
2350
|
-
/**
|
|
2351
|
-
* Fit-to-width (Google-Docs mobile behavior): when the page is wider than the
|
|
2352
|
-
* viewport, auto-scale down so it fits with a small gutter and never scrolls
|
|
2353
|
-
* horizontally. The computed scale drives the real `zoom` (crisp text, not a
|
|
2354
|
-
* blurry transform) and is capped at `zoom`, so a wide desktop viewport is
|
|
2355
|
-
* unchanged. Recomputed on container resize. Default true.
|
|
2356
|
-
*/
|
|
2357
|
-
fitWidth?: boolean;
|
|
2358
|
-
/**
|
|
2359
|
-
* Container width (px) at or below which the chrome switches to its compact
|
|
2360
|
-
* phone/tablet treatment — the comment rail collapses to tap-to-open cards so
|
|
2361
|
-
* balloons never force horizontal scroll. Default 820.
|
|
2362
|
-
*/
|
|
2363
|
-
narrowWidth?: number;
|
|
2364
|
-
/**
|
|
2365
|
-
* Enable editing commands (selection-based formatting, save-back).
|
|
2366
|
-
* Default false: pure render-only viewer.
|
|
2367
|
-
*/
|
|
2368
|
-
editable?: boolean;
|
|
2369
|
-
className?: string;
|
|
2370
|
-
style?: React.CSSProperties;
|
|
2371
|
-
onLoad?: (info: {
|
|
2372
|
-
pageCount: number;
|
|
2373
|
-
document: DocxDocument;
|
|
2374
|
-
}) => void;
|
|
2375
|
-
/** Fires whenever editing changes the rendered page count. */
|
|
2376
|
-
onPageCountChange?: (pageCount: number) => void;
|
|
2377
|
-
/** Fires when the document is ready; the api is only usable while mounted. */
|
|
2378
|
-
onReady?: (api: DocxViewApi) => void;
|
|
2379
|
-
onError?: (error: Error) => void;
|
|
2380
|
-
/** Author name stamped on comment replies (default "You"). */
|
|
2381
|
-
commentAuthor?: string;
|
|
2382
|
-
/** Render review comments (range highlights + margin balloons). Default true. */
|
|
2383
|
-
showComments?: boolean;
|
|
2384
|
-
/** Tracked-changes display: "final" (default) or "markup". */
|
|
2385
|
-
revisions?: "final" | "markup";
|
|
2386
|
-
/** Fires after render with document-requested font faces the browser cannot
|
|
2387
|
-
* render (unavailable, or lacking the document's script) — the page is
|
|
2388
|
-
* silently substituting and may differ from Word. Empty array = all good. */
|
|
2389
|
-
onMissingFonts?: (missing: MissingFont[]) => void;
|
|
2390
|
-
}
|
|
2391
|
-
/**
|
|
2392
|
-
* High-fidelity paginated DOCX viewer (and, with `editable`, editor).
|
|
2393
|
-
*
|
|
2394
|
-
* ```tsx
|
|
2395
|
-
* <DocxView source="/report.docx" /> // render-only
|
|
2396
|
-
* <DocxView source="/report.docx" editable onReady={setApi} /> // editing
|
|
2397
|
-
* ```
|
|
2398
|
-
*/
|
|
2399
|
-
declare function DocxView({ source, zoom, fitWidth, narrowWidth, editable, className, style, onLoad, onPageCountChange, onReady, onError, commentAuthor, showComments, revisions, onMissingFonts, }: DocxViewProps): react.JSX.Element;
|
|
2400
|
-
|
|
2401
|
-
export { type CoverPageContent, DocxDocument, DocxToolbar, type DocxToolbarProps, DocxView, type DocxViewApi, type DocxViewProps, type DrawingTool, type LineNumberingPatch, type PageLayoutPatch, type ParagraphAlignment, type RunFormatPatch, type ScreenshotInsertResult, type SelectionFormat, type ShapePreset, type ToolbarFeature, ToolbarMenuSelect, type ToolbarMenuSelectOption, type ToolbarMenuSelectProps, type ToolbarMode, layoutDocument, printPages, renderToDom };
|
|
1
|
+
import 'react';
|
|
2
|
+
export { i as COLLAB_IMAGE_EXTS, j as CoverPageContent, D as DocxDocument, k as DocxToolbar, l as DocxToolbarProps, n as DocxView, d as DocxViewApi, o as DocxViewProps, p as DrawingTool, q as INSERT_COMMANDS, r as ImageInsertResult, t as InsertCommandSpec, u as LineNumberingPatch, v as PageLayoutPatch, w as ParagraphAlignment, x as RunFormatPatch, y as ScreenshotInsertResult, z as SelectionFormat, A as ShapePreset, T as ToolbarFeature, B as ToolbarMenuSelect, E as ToolbarMenuSelectOption, F as ToolbarMenuSelectProps, c as ToolbarMode, G as layoutDocument, H as printPages, J as renderToDom } from './index-C2J9egkh.js';
|