@stll/docx-core 0.23.0 → 0.25.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.
@@ -1,21 +1,184 @@
1
- //#region src/model/colors.d.ts
1
+ import { n as PreservedChild, r as PreservedMarkup, t as PreservedAttribute } from "./preservedMarkup-G8XjWhs2.js";
2
+ //#region src/model/borderStyle.gen.d.ts
3
+ /**
4
+ * GENERATED FILE — do not edit.
5
+ *
6
+ * The `ST_Border` enumeration, in schema order, derived from
7
+ * `specifications/generated/docx-transitional-schema.gen.json` by
8
+ * `scripts/generate-border-styles.ts`. Regenerate with:
9
+ *
10
+ * bun run generate:border-styles
11
+ *
12
+ * The first 27 members are line styles; the rest are the page-border art
13
+ * glyphs `w:pgBorders` may name. `nil` and `none` are distinct: `none`
14
+ * cancels a border inherited from the container, `nil` states no border. Read
15
+ * either through `isBorderNone`/`isBorderNil` in `./borderStyle`, never by
16
+ * comparing the string.
17
+ */
18
+ /** Every `ST_Border` member, in schema order. */
19
+ declare const BORDER_STYLES: readonly ["nil", "none", "single", "thick", "double", "dotted", "dashed", "dotDash", "dotDotDash", "triple", "thinThickSmallGap", "thickThinSmallGap", "thinThickThinSmallGap", "thinThickMediumGap", "thickThinMediumGap", "thinThickThinMediumGap", "thinThickLargeGap", "thickThinLargeGap", "thinThickThinLargeGap", "wave", "doubleWave", "dashSmallGap", "dashDotStroked", "threeDEmboss", "threeDEngrave", "outset", "inset", "apples", "archedScallops", "babyPacifier", "babyRattle", "balloons3Colors", "balloonsHotAir", "basicBlackDashes", "basicBlackDots", "basicBlackSquares", "basicThinLines", "basicWhiteDashes", "basicWhiteDots", "basicWhiteSquares", "basicWideInline", "basicWideMidline", "basicWideOutline", "bats", "birds", "birdsFlight", "cabins", "cakeSlice", "candyCorn", "celticKnotwork", "certificateBanner", "chainLink", "champagneBottle", "checkedBarBlack", "checkedBarColor", "checkered", "christmasTree", "circlesLines", "circlesRectangles", "classicalWave", "clocks", "compass", "confetti", "confettiGrays", "confettiOutline", "confettiStreamers", "confettiWhite", "cornerTriangles", "couponCutoutDashes", "couponCutoutDots", "crazyMaze", "creaturesButterfly", "creaturesFish", "creaturesInsects", "creaturesLadyBug", "crossStitch", "cup", "decoArch", "decoArchColor", "decoBlocks", "diamondsGray", "doubleD", "doubleDiamonds", "earth1", "earth2", "earth3", "eclipsingSquares1", "eclipsingSquares2", "eggsBlack", "fans", "film", "firecrackers", "flowersBlockPrint", "flowersDaisies", "flowersModern1", "flowersModern2", "flowersPansy", "flowersRedRose", "flowersRoses", "flowersTeacup", "flowersTiny", "gems", "gingerbreadMan", "gradient", "handmade1", "handmade2", "heartBalloon", "heartGray", "hearts", "heebieJeebies", "holly", "houseFunky", "hypnotic", "iceCreamCones", "lightBulb", "lightning1", "lightning2", "mapPins", "mapleLeaf", "mapleMuffins", "marquee", "marqueeToothed", "moons", "mosaic", "musicNotes", "northwest", "ovals", "packages", "palmsBlack", "palmsColor", "paperClips", "papyrus", "partyFavor", "partyGlass", "pencils", "people", "peopleWaving", "peopleHats", "poinsettias", "postageStamp", "pumpkin1", "pushPinNote2", "pushPinNote1", "pyramids", "pyramidsAbove", "quadrants", "rings", "safari", "sawtooth", "sawtoothGray", "scaredCat", "seattle", "shadowedSquares", "sharksTeeth", "shorebirdTracks", "skyrocket", "snowflakeFancy", "snowflakes", "sombrero", "southwest", "stars", "starsTop", "stars3d", "starsBlack", "starsShadowed", "sun", "swirligig", "tornPaper", "tornPaperBlack", "trees", "triangleParty", "triangles", "triangle1", "triangle2", "triangleCircle1", "triangleCircle2", "shapes1", "shapes2", "twistedLines1", "twistedLines2", "vine", "waveline", "weavingAngles", "weavingBraid", "weavingRibbon", "weavingStrips", "whiteFlowers", "woodwork", "xIllusions", "zanyTriangles", "zigZag", "zigZagStitch", "custom"];
20
+ /** `w:val` on `CT_Border`: a border style the schema declares. */
21
+ type BorderStyle = (typeof BORDER_STYLES)[number];
22
+ //#endregion
23
+ //#region src/model/borderStyle.d.ts
24
+ /**
25
+ * A `w:val` the schema does not declare, kept exactly as the file spelled it.
26
+ *
27
+ * Refusing the border instead would drop an authored edge that Word renders,
28
+ * and collapsing it to a default would rewrite the document on open. The
29
+ * parser reports it through `ParseContext` so the normalisation is visible,
30
+ * and the serializer writes `raw` back unchanged.
31
+ */
32
+ type UnrecognisedBorderStyle = {
33
+ readonly kind: "unrecognised";
34
+ readonly raw: string;
35
+ };
36
+ /** What `BorderSpec.style` holds: an `ST_Border` member, or the raw token. */
37
+ type BorderStyleValue = BorderStyle | UnrecognisedBorderStyle;
38
+ /** Whether the schema declares this token. */
39
+ declare const isBorderStyle: (value: string) => value is BorderStyle;
40
+ /** Read a `w:val` into the model, keeping an undeclared token verbatim. */
41
+ declare const borderStyleFrom: (value: string) => BorderStyleValue;
42
+ /** The token to write back, whether or not the schema declares it. */
43
+ declare const borderStyleToken: (style: BorderStyleValue) => string;
44
+ /** `none`: the author cancelled a border inherited from the container. */
45
+ declare const isBorderNone: (style: BorderStyleValue | undefined) => boolean;
46
+ /** `nil`: the author stated no border. */
47
+ declare const isBorderNil: (style: BorderStyleValue | undefined) => boolean;
48
+ /**
49
+ * Whether the edge paints nothing, by either reserved member.
50
+ *
51
+ * This is what a renderer, a measurer and a collapse rule want: the two
52
+ * members differ in what they do to an inherited border, not in what they
53
+ * draw. Which one was written still matters on the way back out, which is why
54
+ * the value keeps it.
55
+ */
56
+ declare const statesNoBorder: (style: BorderStyleValue | undefined) => boolean;
57
+ //#endregion
58
+ //#region src/model/themeColor.gen.d.ts
2
59
  /**
3
- * Color & Styling Primitives
60
+ * GENERATED FILE — do not edit.
4
61
  *
5
- * Basic types used throughout OOXML for colors, borders, and shading.
62
+ * The colour enumerations a theme reference passes through.
63
+ *
64
+ * Derived from `specifications/generated/docx-transitional-schema.gen.json`.
65
+ * Regenerate with:
66
+ *
67
+ * bun run generate:theme-colors
6
68
  */
7
69
  /**
8
- * Theme color slots from theme1.xml
70
+ * `ST_ThemeColor`: every token a WordprocessingML `w:themeColor`,
71
+ * `w:themeFill` or `w:clrSchemeMapping` value may carry.
72
+ *
73
+ * Spelled in full words (`dark1`, `hyperlink`), unlike the DrawingML slot
74
+ * names below. `none` is a reserved member that cancels an inherited theme
75
+ * colour rather than naming one.
76
+ */
77
+ declare const THEME_COLORS: readonly ["dark1", "light1", "dark2", "light2", "accent1", "accent2", "accent3", "accent4", "accent5", "accent6", "hyperlink", "followedHyperlink", "none", "background1", "text1", "background2", "text2"];
78
+ type ThemeColor = "dark1" | "light1" | "dark2" | "light2" | "accent1" | "accent2" | "accent3" | "accent4" | "accent5" | "accent6" | "hyperlink" | "followedHyperlink" | "none" | "background1" | "text1" | "background2" | "text2";
79
+ type SchemeColorSlot = "dk1" | "lt1" | "dk2" | "lt2" | "accent1" | "accent2" | "accent3" | "accent4" | "accent5" | "accent6" | "hlink" | "folHlink";
80
+ type SchemeColorValue = "bg1" | "tx1" | "bg2" | "tx2" | "accent1" | "accent2" | "accent3" | "accent4" | "accent5" | "accent6" | "hlink" | "folHlink" | "phClr" | "dk1" | "lt1" | "dk2" | "lt2";
81
+ //#endregion
82
+ //#region src/model/themeColor.d.ts
83
+ /**
84
+ * The `a:schemeClr/@val` spelling of each theme colour.
85
+ *
86
+ * DrawingML keeps the mapped colours as their own tokens (`bg1`, `tx1`) rather
87
+ * than resolving them, so the two vocabularies differ only in spelling. `none`
88
+ * has no DrawingML equivalent: a scheme reference that paints nothing is
89
+ * written by omitting the fill, not by naming a colour.
90
+ */
91
+ declare const SCHEME_COLOR_VALUE_BY_THEME_COLOR: {
92
+ readonly dark1: "dk1";
93
+ readonly light1: "lt1";
94
+ readonly dark2: "dk2";
95
+ readonly light2: "lt2";
96
+ readonly accent1: "accent1";
97
+ readonly accent2: "accent2";
98
+ readonly accent3: "accent3";
99
+ readonly accent4: "accent4";
100
+ readonly accent5: "accent5";
101
+ readonly accent6: "accent6";
102
+ readonly hyperlink: "hlink";
103
+ readonly followedHyperlink: "folHlink";
104
+ readonly none: null;
105
+ readonly background1: "bg1";
106
+ readonly text1: "tx1";
107
+ readonly background2: "bg2";
108
+ readonly text2: "tx2";
109
+ };
110
+ /**
111
+ * The inverse: how an `a:schemeClr/@val` reads as a WordprocessingML theme
112
+ * colour. `phClr` is the placeholder a style definition resolves against its
113
+ * instantiating context, which no `w:themeColor` can name.
114
+ */
115
+ declare const THEME_COLOR_BY_SCHEME_COLOR_VALUE: {
116
+ readonly bg1: "background1";
117
+ readonly tx1: "text1";
118
+ readonly bg2: "background2";
119
+ readonly tx2: "text2";
120
+ readonly accent1: "accent1";
121
+ readonly accent2: "accent2";
122
+ readonly accent3: "accent3";
123
+ readonly accent4: "accent4";
124
+ readonly accent5: "accent5";
125
+ readonly accent6: "accent6";
126
+ readonly hlink: "hyperlink";
127
+ readonly folHlink: "followedHyperlink";
128
+ readonly phClr: null;
129
+ readonly dk1: "dark1";
130
+ readonly lt1: "light1";
131
+ readonly dk2: "dark2";
132
+ readonly lt2: "light2";
133
+ };
134
+ /**
135
+ * A `w:themeColor` token outside `ST_ThemeColor`, kept as written.
136
+ *
137
+ * Narrowing used to drop such a token, which also dropped the attribute the
138
+ * next time the element was written. Capturing it keeps the save leg lossless
139
+ * while leaving the painter free to ignore a colour it cannot resolve — the
140
+ * treatment `w:val` on `CT_Border` already gets for a style outside
141
+ * `ST_Border`.
142
+ */
143
+ type UnrecognisedThemeColor = {
144
+ readonly kind: "unrecognised";
145
+ readonly raw: string;
146
+ };
147
+ /** What a theme-colour attribute parses to: a schema token, or the raw text. */
148
+ type ThemeColorValue = ThemeColor | UnrecognisedThemeColor;
149
+ declare const isThemeColor: (value: string) => value is ThemeColor;
150
+ declare const isSchemeColorValue: (value: string) => value is SchemeColorValue;
151
+ /**
152
+ * Read an attribute as a theme colour, or `undefined` when it is absent.
153
+ *
154
+ * An unrecognised token is captured rather than refused; the caller decides
155
+ * whether to report it.
9
156
  */
10
- type ThemeColorSlot = "dk1" | "lt1" | "dk2" | "lt2" | "accent1" | "accent2" | "accent3" | "accent4" | "accent5" | "accent6" | "hlink" | "folHlink" | "background1" | "text1" | "background2" | "text2";
157
+ declare const readThemeColor: (raw: string | null | undefined) => ThemeColorValue | undefined;
158
+ /** The token to write back, whether or not the schema enumerates it. */
159
+ declare const themeColorToken: (value: ThemeColorValue) => string;
160
+ /** The schema token, or `undefined` for one the model only carries verbatim. */
161
+ declare const knownThemeColor: (value: ThemeColorValue) => ThemeColor | undefined;
162
+ /**
163
+ * The theme slot a reference paints with, or `undefined` when it names none.
164
+ *
165
+ * `undefined` covers both `none`, which cancels an inherited theme colour, and
166
+ * a token the schema does not enumerate.
167
+ */
168
+ declare const themeColorSlot: (value: ThemeColorValue) => SchemeColorSlot | undefined;
169
+ //#endregion
170
+ //#region src/model/colors.d.ts
11
171
  /**
12
172
  * Color value - can be direct RGB, theme reference, or auto
13
173
  */
14
174
  type ColorValue = {
15
175
  /** RGB hex value without # (e.g., "FF0000") */
16
176
  rgb?: string;
17
- /** Theme color slot reference */
18
- themeColor?: ThemeColorSlot;
177
+ /**
178
+ * `w:themeColor`/`w:themeFill` as written: an `ST_ThemeColor` token, or a
179
+ * token outside it captured verbatim. `themeColorSlot` resolves either.
180
+ */
181
+ themeColor?: ThemeColorValue;
19
182
  /** Tint modifier (0-255 as hex string, e.g., "80") - makes color lighter */
20
183
  themeTint?: string;
21
184
  /** Shade modifier (0-255 as hex string) - makes color darker */
@@ -23,13 +186,16 @@ type ColorValue = {
23
186
  /** Auto color - context-dependent (usually black for text) */
24
187
  auto?: boolean;
25
188
  };
26
- type KnownBorderStyle = "none" | "single" | "double" | "dotted" | "dashed" | "thick" | "triple" | "thinThickSmallGap" | "thickThinSmallGap" | "thinThickMediumGap" | "thickThinMediumGap" | "thinThickLargeGap" | "thickThinLargeGap" | "wave" | "doubleWave" | "dashSmallGap" | "dashDotStroked" | "threeDEmboss" | "threeDEngrave" | "outset" | "inset" | "nil";
27
189
  /**
28
190
  * Border specification for any border (paragraph, table, page)
29
191
  */
30
192
  type BorderSpec = {
31
- /** Border style. Unknown OOXML styles are preserved for fallback rendering. */
32
- style: string;
193
+ /**
194
+ * `w:val`: an `ST_Border` member, or the raw token when the file wrote one
195
+ * the schema does not declare. Ask `statesNoBorder`/`isBorderNone`/
196
+ * `isBorderNil` rather than comparing it; `nil` and `none` are not synonyms.
197
+ */
198
+ style: BorderStyleValue;
33
199
  /** Color of the border */
34
200
  color?: ColorValue;
35
201
  /** Width in eighths of a point (1/8 pt) */
@@ -53,6 +219,15 @@ type BorderSpec = {
53
219
  bottomLeftArtRelationshipId?: string;
54
220
  /** Custom page-border art relationship id for the bottom-right corner. */
55
221
  bottomRightArtRelationshipId?: string;
222
+ /**
223
+ * `CT_Border` attributes this record has no field for.
224
+ *
225
+ * The remainder rides the record that holds the element's modelled fields,
226
+ * the rule `attributeRemainder.ts` states for `w:p` and `w:tr`, applied one
227
+ * level down: a border is an attribute bag, so an attribute folio does not
228
+ * read is lost the moment any other attribute makes the element modelled.
229
+ */
230
+ preservedAttributes?: PreservedAttribute[];
56
231
  };
57
232
  /**
58
233
  * Shading/background properties
@@ -64,7 +239,281 @@ type ShadingProperties = {
64
239
  fill?: ColorValue;
65
240
  /** Shading pattern type */
66
241
  pattern?: "clear" | "solid" | "horzStripe" | "vertStripe" | "reverseDiagStripe" | "diagStripe" | "horzCross" | "diagCross" | "thinHorzStripe" | "thinVertStripe" | "thinReverseDiagStripe" | "thinDiagStripe" | "thinHorzCross" | "thinDiagCross" | "pct5" | "pct10" | "pct12" | "pct15" | "pct20" | "pct25" | "pct30" | "pct35" | "pct37" | "pct40" | "pct45" | "pct50" | "pct55" | "pct60" | "pct62" | "pct65" | "pct70" | "pct75" | "pct80" | "pct85" | "pct87" | "pct90" | "pct95" | "nil";
242
+ /** `CT_Shd` attributes this record has no field for; see {@link BorderSpec}. */
243
+ preservedAttributes?: PreservedAttribute[];
244
+ };
245
+ //#endregion
246
+ //#region src/model/ooxmlEnumerations.gen.d.ts
247
+ /**
248
+ * GENERATED FILE — do not edit.
249
+ *
250
+ * The model enumerations that mirror an OOXML simple type, member for
251
+ * member, so a token the format declares cannot go unspelled.
252
+ *
253
+ * Derived from `specifications/generated/docx-transitional-schema.gen.json`.
254
+ * Regenerate with:
255
+ *
256
+ * bun run generate:ooxml-enumerations
257
+ */
258
+ /**
259
+ * `ST_Jc`: every token a `w:jc/@w:val` may carry.
260
+ *
261
+ * `start` and `end` are the direction-aware alignments, distinct from
262
+ * `left` and `right`: in a right-to-left paragraph `start` sits at the
263
+ * right margin. They are members in their own right, not spellings of
264
+ * `left` and `right`, and the layout resolves them against the
265
+ * paragraph's direction. `numTab` aligns to the list number's tab stop.
266
+ */
267
+ declare const PARAGRAPH_ALIGNMENTS: readonly ["start", "center", "end", "both", "mediumKashida", "distribute", "numTab", "highKashida", "lowKashida", "thaiDistribute", "left", "right"];
268
+ type ParagraphAlignment = "start" | "center" | "end" | "both" | "mediumKashida" | "distribute" | "numTab" | "highKashida" | "lowKashida" | "thaiDistribute" | "left" | "right";
269
+ /**
270
+ * `ST_TabJc`: every token a `w:tab/@w:val` may carry.
271
+ *
272
+ * `start` and `end` are the direction-aware members, the same distinction
273
+ * `ST_Jc` draws; `clear` removes an inherited stop rather than declaring
274
+ * one, and `num` is the stop a numbered paragraph's text hangs from.
275
+ */
276
+ declare const TAB_STOP_ALIGNMENTS: readonly ["clear", "start", "center", "end", "decimal", "bar", "num", "left", "right"];
277
+ type TabStopAlignment = "clear" | "start" | "center" | "end" | "decimal" | "bar" | "num" | "left" | "right";
278
+ /**
279
+ * `ST_JcTable`: every token a table's or a row's `w:jc/@w:val` may carry.
280
+ *
281
+ * A narrower vocabulary than `ST_Jc`: a table is placed, not justified, so
282
+ * there is no `both`. `start` and `end` are the direction-aware members,
283
+ * the same distinction `ST_Jc` draws, resolved against the table's own
284
+ * `w:bidiVisual` rather than a paragraph's direction.
285
+ */
286
+ declare const TABLE_ALIGNMENTS: readonly ["center", "end", "left", "right", "start"];
287
+ type TableAlignment = "center" | "end" | "left" | "right" | "start";
288
+ /**
289
+ * `ST_TextDirection`: every token a `w:textDirection/@w:val` may carry, on
290
+ * a table cell, a section or a paragraph.
291
+ *
292
+ * Twelve tokens for six flows: each flow has a short spelling and a long one
293
+ * naming the character and line progressions in full.
294
+ * {@link TEXT_DIRECTION_FLOWS} is the six, and
295
+ * {@link TEXT_DIRECTION_FLOW_BY_TOKEN} pairs each token with its flow.
296
+ */
297
+ declare const TEXT_DIRECTIONS: readonly ["tb", "rl", "lr", "tbV", "rlV", "lrV", "btLr", "lrTb", "lrTbV", "tbLrV", "tbRl", "tbRlV"];
298
+ type TextDirection = "tb" | "rl" | "lr" | "tbV" | "rlV" | "lrV" | "btLr" | "lrTb" | "lrTbV" | "tbLrV" | "tbRl" | "tbRlV";
299
+ /**
300
+ * The six text flows `ST_TextDirection` names, spelled the Strict way.
301
+ *
302
+ * Strict's `ST_TextDirection` (ECMA-376 Part 1 §17.18.93) enumerates exactly
303
+ * these six; Transitional adds a second spelling of each (Part 4 §14.11.7).
304
+ * Rendering is decided per flow, so a cell written `tbRl` and its Strict twin
305
+ * written `rl` paint the same.
306
+ */
307
+ declare const TEXT_DIRECTION_FLOWS: readonly ["tb", "rl", "lr", "tbV", "rlV", "lrV"];
308
+ type TextDirectionFlow = "tb" | "rl" | "lr" | "tbV" | "rlV" | "lrV";
309
+ /**
310
+ * The flow each `ST_TextDirection` token names.
311
+ *
312
+ * ECMA-376 Part 4 §14.11.7 gives each Transitional-only token as semantically
313
+ * equivalent to a Strict one: `btLr` to `lr`, `lrTb` to `tb`, `lrTbV`
314
+ * to `tbV`, `tbLrV` to `lrV`, `tbRl` to `rl` and `tbRlV` to `rlV`.
315
+ * A reader keeps the token as authored and a writer writes it back; only
316
+ * rendering goes through the flow.
317
+ */
318
+ declare const TEXT_DIRECTION_FLOW_BY_TOKEN: {
319
+ readonly tb: "tb";
320
+ readonly rl: "rl";
321
+ readonly lr: "lr";
322
+ readonly tbV: "tbV";
323
+ readonly rlV: "rlV";
324
+ readonly lrV: "lrV";
325
+ readonly btLr: "lr";
326
+ readonly lrTb: "tb";
327
+ readonly lrTbV: "tbV";
328
+ readonly tbLrV: "lrV";
329
+ readonly tbRl: "rl";
330
+ readonly tbRlV: "rlV";
331
+ };
332
+ /**
333
+ * `ST_NumberFormat`: every token a `w:numFmt/@w:val` may carry, on a
334
+ * numbering level, a note's properties or a section's page numbers.
335
+ *
336
+ * `custom` counts by the token list in the sibling `@w:format` rather
337
+ * than by a vocabulary of its own; `none` prints no counter at all.
338
+ */
339
+ declare const NUMBER_FORMATS: readonly ["decimal", "upperRoman", "lowerRoman", "upperLetter", "lowerLetter", "ordinal", "cardinalText", "ordinalText", "hex", "chicago", "ideographDigital", "japaneseCounting", "aiueo", "iroha", "decimalFullWidth", "decimalHalfWidth", "japaneseLegal", "japaneseDigitalTenThousand", "decimalEnclosedCircle", "decimalFullWidth2", "aiueoFullWidth", "irohaFullWidth", "decimalZero", "bullet", "ganada", "chosung", "decimalEnclosedFullstop", "decimalEnclosedParen", "decimalEnclosedCircleChinese", "ideographEnclosedCircle", "ideographTraditional", "ideographZodiac", "ideographZodiacTraditional", "taiwaneseCounting", "ideographLegalTraditional", "taiwaneseCountingThousand", "taiwaneseDigital", "chineseCounting", "chineseLegalSimplified", "chineseCountingThousand", "koreanDigital", "koreanCounting", "koreanLegal", "koreanDigital2", "vietnameseCounting", "russianLower", "russianUpper", "none", "numberInDash", "hebrew1", "hebrew2", "arabicAlpha", "arabicAbjad", "hindiVowels", "hindiConsonants", "hindiNumbers", "hindiCounting", "thaiLetters", "thaiNumbers", "thaiCounting", "bahtText", "dollarText", "custom"];
340
+ type NumberFormat = "decimal" | "upperRoman" | "lowerRoman" | "upperLetter" | "lowerLetter" | "ordinal" | "cardinalText" | "ordinalText" | "hex" | "chicago" | "ideographDigital" | "japaneseCounting" | "aiueo" | "iroha" | "decimalFullWidth" | "decimalHalfWidth" | "japaneseLegal" | "japaneseDigitalTenThousand" | "decimalEnclosedCircle" | "decimalFullWidth2" | "aiueoFullWidth" | "irohaFullWidth" | "decimalZero" | "bullet" | "ganada" | "chosung" | "decimalEnclosedFullstop" | "decimalEnclosedParen" | "decimalEnclosedCircleChinese" | "ideographEnclosedCircle" | "ideographTraditional" | "ideographZodiac" | "ideographZodiacTraditional" | "taiwaneseCounting" | "ideographLegalTraditional" | "taiwaneseCountingThousand" | "taiwaneseDigital" | "chineseCounting" | "chineseLegalSimplified" | "chineseCountingThousand" | "koreanDigital" | "koreanCounting" | "koreanLegal" | "koreanDigital2" | "vietnameseCounting" | "russianLower" | "russianUpper" | "none" | "numberInDash" | "hebrew1" | "hebrew2" | "arabicAlpha" | "arabicAbjad" | "hindiVowels" | "hindiConsonants" | "hindiNumbers" | "hindiCounting" | "thaiLetters" | "thaiNumbers" | "thaiCounting" | "bahtText" | "dollarText" | "custom";
341
+ //#endregion
342
+ //#region src/model/outlineLevel.d.ts
343
+ /**
344
+ * `w:outlineLvl`: nine heading levels and one reserved "not a heading".
345
+ *
346
+ * ECMA-376 17.3.1.20 gives `w:val` the range 0..9 "where 9 specifically
347
+ * indicates that there is no outline level specifically applied to this
348
+ * paragraph". Nine is therefore a sentinel, not a tenth level, and a model
349
+ * that stores the raw number lets every consumer decide that for itself: the
350
+ * PDF outline nested a `TOC Heading` nine deep, the TOC listed it, and the
351
+ * lint could not see the mistake because the comparison was against
352
+ * `undefined` rather than against the literal.
353
+ *
354
+ * The union removes the decision. `9` has no representation as a heading, an
355
+ * out-of-range value has none at all, and absence stays absence — a paragraph
356
+ * that states no level inherits one, which is a third state neither arm may
357
+ * stand in for.
358
+ */
359
+ /** The `w:outlineLvl w:val` values that name a heading, zero-based. */
360
+ declare const HEADING_OUTLINE_LEVELS: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8];
361
+ /** A zero-based heading level: `heading 1` is 0, `heading 9` is 8. */
362
+ type HeadingOutlineLevel = (typeof HEADING_OUTLINE_LEVELS)[number];
363
+ /** What a stated `w:outlineLvl` says. Absence is the field being absent. */
364
+ type OutlineLevel = {
365
+ readonly kind: "bodyText";
366
+ } | {
367
+ readonly kind: "heading";
368
+ readonly level: HeadingOutlineLevel;
67
369
  };
370
+ /** The reserved `w:outlineLvl w:val="9"`: outlined as body text, not as a heading. */
371
+ declare const BODY_TEXT_OUTLINE_LEVEL: OutlineLevel;
372
+ /**
373
+ * The one reader over a stated `w:outlineLvl w:val`.
374
+ *
375
+ * `undefined` is a value outside 0..9, which the format does not define. The
376
+ * Rust kernel rejects those outright (`MAXIMUM_OUTLINE_LEVEL`); the TypeScript
377
+ * parse boundary drops them and warns instead, because a corpus document that
378
+ * Word opens must still open here.
379
+ */
380
+ declare const outlineLevelFromStatedValue: (value: number) => OutlineLevel | undefined;
381
+ /** The heading arm for a zero-based level, or undefined outside 0..8. */
382
+ declare const headingOutlineLevel: (level: number) => OutlineLevel | undefined;
383
+ /** The `w:val` to write for a stated outline level. */
384
+ declare const outlineLevelStatedValue: (outlineLevel: OutlineLevel) => number;
385
+ /**
386
+ * The zero-based heading level a stated outline level names, or undefined when
387
+ * it names none. Body text and an absent level answer the same thing, which is
388
+ * what every heading consumer wants; the two are distinguished only where the
389
+ * cascade still has a tier left to ask.
390
+ */
391
+ declare const headingLevelOf: (outlineLevel: OutlineLevel | null | undefined) => HeadingOutlineLevel | undefined;
392
+ //#endregion
393
+ //#region src/model/paragraphNumbering.d.ts
394
+ /**
395
+ * `w:numPr`: what a tier states about a paragraph's numbering, and what the
396
+ * cascade resolves that to.
397
+ *
398
+ * Two facts shape the types, and the old `{ numId?: number; ilvl?: number }`
399
+ * pair expressed neither.
400
+ *
401
+ * **`w:numId` and `w:ilvl` inherit independently** (ECMA-376 17.3.1.19). A tier
402
+ * that states only the level keeps the id it inherits, which is what Word
403
+ * writes whenever a styled list paragraph is demoted, so a direct `w:numPr` is
404
+ * a partial override rather than a whole replacement. That is the `levelOnly`
405
+ * arm, and it is why the override type has three arms and not two.
406
+ *
407
+ * **`w:numId w:val="0"` is reserved** (17.9.18): it names no `w:num`, it
408
+ * switches numbering off, and on a style it cancels the numbering the style
409
+ * would otherwise inherit through `w:basedOn`. It is the `none` arm, and a
410
+ * `reference` therefore cannot carry it — which is the whole point, because
411
+ * the sentinel used to read as "this paragraph is in list 0" in the layout and
412
+ * marker tiers while the sanctioned reader said it was in no list at all.
413
+ */
414
+ /** The reserved `w:numId` value that means "no numbering". */
415
+ declare const NO_NUMBERING_NUM_ID = 0;
416
+ /**
417
+ * Whether a `w:numId` names a numbering definition to resolve.
418
+ *
419
+ * Still the reader for the raw ids the numbering part itself carries
420
+ * (`w:num@numId`, a style's own reference before it is read into the union).
421
+ * A paragraph's numbering no longer goes through it: after
422
+ * {@link paragraphNumberingFromSlots} the sentinel has no representation.
423
+ */
424
+ declare const isNumberingReference: (numId: number | undefined) => numId is number;
425
+ declare const PARAGRAPH_NUMBERING_REFERENCE: unique symbol;
426
+ /** A non-reserved numbering reference minted by {@link paragraphNumberingReference}. */
427
+ type ParagraphNumberingReference = {
428
+ readonly kind: "reference";
429
+ readonly numId: number;
430
+ readonly ilvl?: number;
431
+ readonly [PARAGRAPH_NUMBERING_REFERENCE]: true;
432
+ };
433
+ /**
434
+ * What one tier's `<w:numPr>` states. The field being absent is the fourth
435
+ * state and means the tier states nothing at all.
436
+ */
437
+ type ParagraphNumberingOverride = {
438
+ readonly kind: "none";
439
+ } | ParagraphNumberingReference | {
440
+ readonly kind: "levelOnly";
441
+ readonly ilvl: number;
442
+ };
443
+ /** Numbering after the cascade: what actually renders. */
444
+ type ResolvedParagraphNumbering = {
445
+ readonly kind: "none";
446
+ } | (ParagraphNumberingReference & {
447
+ readonly ilvl: number;
448
+ });
449
+ /** The arm a `w:numId w:val="0"` reads as, and the arm a cascade cancels to. */
450
+ declare const NO_PARAGRAPH_NUMBERING: {
451
+ readonly kind: "none";
452
+ };
453
+ /**
454
+ * The two slots a `<w:numPr>` carries, as read off the element.
455
+ *
456
+ * An absent `w:ilvl` and `w:ilvl="0"` mean the same level but are different
457
+ * bytes, so `ilvl` stays optional inside `reference`: collapsing it turns an
458
+ * untouched save into a document that states something its source did not.
459
+ */
460
+ type ParagraphNumberingSlots = {
461
+ numId?: number;
462
+ ilvl?: number;
463
+ };
464
+ type ParagraphNumberingReferenceOptions<NumId extends number, Level extends number | undefined> = {
465
+ numId: Exclude<NumId, typeof NO_NUMBERING_NUM_ID>;
466
+ ilvl?: Level | undefined;
467
+ };
468
+ type ParagraphNumberingReferenceResult<Level extends number | undefined> = ParagraphNumberingReference & (Level extends number ? {
469
+ readonly ilvl: Level;
470
+ } : unknown);
471
+ /** Mint a reference after excluding the reserved id from the model. */
472
+ declare const paragraphNumberingReference: <const NumId extends number, const Level extends number | undefined = undefined>({ numId, ilvl }: ParagraphNumberingReferenceOptions<NumId, Level>) => ParagraphNumberingReferenceResult<Level>;
473
+ /**
474
+ * The one mapping from a `<w:numPr>`'s two slots onto the union.
475
+ *
476
+ * `undefined` is an element that states neither slot, which states nothing.
477
+ * Every parse boundary goes through this, which is what stops the reserved id
478
+ * reaching the model at all.
479
+ */
480
+ declare const paragraphNumberingFromSlots: ({ numId, ilvl }: {
481
+ numId?: number | undefined;
482
+ ilvl?: number | undefined;
483
+ }) => ParagraphNumberingOverride | undefined;
484
+ /**
485
+ * The slots to write back for a stated override, so the emit has one owner
486
+ * too. `none` writes the reserved id, because deleting the element would
487
+ * uncover the tier below and hand the paragraph its numbering back.
488
+ */
489
+ declare const paragraphNumberingSlots: (numbering: ParagraphNumberingOverride) => ParagraphNumberingSlots;
490
+ /**
491
+ * Fold one tier over the tier beneath it, direct over style.
492
+ *
493
+ * This is ECMA-376 17.3.1.19's independent inheritance written once. Before
494
+ * the union it was four object spreads in three languages, each of them a
495
+ * comment saying what the spread happened to do.
496
+ */
497
+ declare const mergeParagraphNumbering: (inherited: ParagraphNumberingOverride | undefined, stated: ParagraphNumberingOverride | undefined) => ParagraphNumberingOverride | undefined;
498
+ /**
499
+ * Collapse a stated override to what renders.
500
+ *
501
+ * A `levelOnly` that nothing supplied an id for numbers nothing, the same as a
502
+ * cancellation does, which is why the resolved type has two arms.
503
+ */
504
+ declare const resolveParagraphNumbering: (numbering: ParagraphNumberingOverride | undefined) => ResolvedParagraphNumbering;
505
+ /** The level a stated override renders at, absent `w:ilvl` read as zero. */
506
+ declare const paragraphNumberingLevel: (numbering: ParagraphNumberingOverride | undefined) => number | undefined;
507
+ /** The numbering definition a stated override names, or undefined for none. */
508
+ declare const paragraphNumberingReferenceId: (numbering: ParagraphNumberingOverride | undefined) => number | undefined;
509
+ /**
510
+ * Whether two stated overrides say the same thing, byte for byte: an absent
511
+ * `w:ilvl` is not a stated `w:val="0"` here, which is what keeps an untouched
512
+ * save from stating something its source did not.
513
+ */
514
+ declare const sameStatedParagraphNumbering: (left: ParagraphNumberingOverride | undefined, right: ParagraphNumberingOverride | undefined) => boolean;
515
+ /** Whether two stated overrides render the same, an absent `w:ilvl` read as zero. */
516
+ declare const sameEffectiveParagraphNumbering: (left: ParagraphNumberingOverride | undefined, right: ParagraphNumberingOverride | undefined) => boolean;
68
517
  //#endregion
69
518
  //#region src/model/formatting.d.ts
70
519
  /**
@@ -166,11 +615,23 @@ type TextFormatting = {
166
615
  cs?: boolean;
167
616
  /** Character style ID (w:rStyle) */
168
617
  styleId?: string;
618
+ /**
619
+ * The `w:rPr` children folio does not model, in the order the schema
620
+ * declares them.
621
+ *
622
+ * The sink records a capture's schema ordinal rather than a count of
623
+ * modelled siblings, because the writer puts every child at the place the
624
+ * declared list gives its name; see `containerChildren.ts`. One field serves
625
+ * all four owners of a run property set — a run, the paragraph mark, and the
626
+ * snapshot inside either one's `w:rPrChange` — because one reader fills it
627
+ * and one writer empties it.
628
+ *
629
+ * It belongs to the element that was parsed, and to no other. A style's
630
+ * captured bytes are not a run's direct formatting, so style resolution and
631
+ * `mergeTextFormatting` drop it rather than inheriting it.
632
+ */
633
+ preserved?: PreservedMarkup;
169
634
  };
170
- /**
171
- * Tab stop alignment
172
- */
173
- type TabStopAlignment = "left" | "center" | "right" | "decimal" | "bar" | "clear" | "num";
174
635
  /**
175
636
  * Tab leader character
176
637
  */
@@ -185,15 +646,13 @@ type TabStop = {
185
646
  alignment: TabStopAlignment;
186
647
  /** Leader character */
187
648
  leader?: TabLeader;
649
+ /** `CT_TabStop` attributes this record has no field for; see {@link BorderSpec}. */
650
+ preservedAttributes?: PreservedAttribute[];
188
651
  };
189
652
  /**
190
653
  * Line spacing rule
191
654
  */
192
655
  type LineSpacingRule = "auto" | "exact" | "atLeast";
193
- /**
194
- * Paragraph alignment/justification
195
- */
196
- type ParagraphAlignment = "left" | "center" | "right" | "both" | "distribute" | "mediumKashida" | "highKashida" | "lowKashida" | "thaiDistribute";
197
656
  /**
198
657
  * Complete paragraph formatting properties (w:pPr)
199
658
  */
@@ -226,6 +685,16 @@ type ParagraphFormatting = {
226
685
  afterAutospacing?: boolean;
227
686
  /** Which spacing sides came from this paragraph's own pPr. */
228
687
  spacingExplicit?: SpacingExplicit;
688
+ /**
689
+ * `w:spacing` attributes this model has no field for: `w:beforeLines` and
690
+ * `w:afterLines`, which count lines where the modelled pair counts twips.
691
+ *
692
+ * The remainder rides the record that holds the element's modelled fields.
693
+ * For `w:framePr` and `w:shd` that record is the element's own; `w:spacing`
694
+ * and `w:ind` were flattened into this one, so this is theirs, one
695
+ * remainder per flattened element rather than one for the set.
696
+ */
697
+ spacingPreservedAttributes?: PreservedAttribute[];
229
698
  /** Left indent in twips (w:ind/@w:left) */
230
699
  indentLeft?: number;
231
700
  /** Right indent in twips (w:ind/@w:right) */
@@ -234,6 +703,13 @@ type ParagraphFormatting = {
234
703
  indentFirstLine?: number;
235
704
  /** Whether first line is hanging indent */
236
705
  hangingIndent?: boolean;
706
+ /**
707
+ * `w:ind` attributes this model has no field for: the six character-unit
708
+ * spellings, from `w:leftChars` to `w:firstLineChars`, which count
709
+ * characters where the modelled attributes count twips. See
710
+ * {@link ParagraphFormatting.spacingPreservedAttributes}.
711
+ */
712
+ indentPreservedAttributes?: PreservedAttribute[];
237
713
  /** Paragraph borders (w:pBdr) */
238
714
  borders?: {
239
715
  top?: BorderSpec;
@@ -257,13 +733,13 @@ type ParagraphFormatting = {
257
733
  pageBreakBefore?: boolean;
258
734
  /** Contextual spacing — suppress space between paragraphs of the same style (w:contextualSpacing) */
259
735
  contextualSpacing?: boolean;
260
- /** Numbering properties (w:numPr) */
261
- numPr?: {
262
- /** Numbering definition ID (w:numId) */
263
- numId?: number;
264
- /** List level (0-8) (w:ilvl) */
265
- ilvl?: number;
266
- };
736
+ /**
737
+ * The stated `w:numPr` (17.3.1.19). Absent means the tier states nothing and
738
+ * inherits whatever the tier below it states; {@link ParagraphNumberingOverride}
739
+ * carries the rest, so neither the reserved `w:numId w:val="0"` nor a level
740
+ * stated without an id has a spelling any consumer has to recognise.
741
+ */
742
+ numPr?: ParagraphNumberingOverride;
267
743
  /**
268
744
  * When `numPr` was resolved from the paragraph STYLE's pPr rather than the
269
745
  * paragraph's own `<w:numPr>`, this records the style-sourced value. The
@@ -273,10 +749,7 @@ type ParagraphFormatting = {
273
749
  * do not) and break the document on save/reload. Cleared the moment the
274
750
  * user changes the numbering (values diverge).
275
751
  */
276
- numPrFromStyle?: {
277
- numId?: number;
278
- ilvl?: number;
279
- };
752
+ numPrFromStyle?: ParagraphNumberingOverride;
280
753
  /**
281
754
  * The `w:numberingChange` inside the paragraph's `w:numPr`, verbatim.
282
755
  *
@@ -287,8 +760,12 @@ type ParagraphFormatting = {
287
760
  * it travels as markup rather than as a parsed shape.
288
761
  */
289
762
  numberingChangeXml?: string;
290
- /** Outline level 0-9 (w:outlineLvl) */
291
- outlineLevel?: number;
763
+ /**
764
+ * The stated `w:outlineLvl` (17.3.1.20). Absent means the paragraph states
765
+ * none and inherits one; {@link OutlineLevel} carries the rest, so the
766
+ * reserved `w:val="9"` cannot be mistaken for a tenth heading level.
767
+ */
768
+ outlineLevel?: OutlineLevel;
292
769
  /** Paragraph style ID (w:pStyle) */
293
770
  styleId?: string;
294
771
  /** Text frame properties (w:framePr) */
@@ -306,6 +783,8 @@ type ParagraphFormatting = {
306
783
  xAlign?: "left" | "center" | "right" | "inside" | "outside";
307
784
  yAlign?: "top" | "center" | "bottom" | "inside" | "outside" | "inline";
308
785
  wrap?: "around" | "auto" | "none" | "notBeside" | "through" | "tight";
786
+ /** `CT_FramePr` attributes this record has no field for; see {@link BorderSpec}. */
787
+ preservedAttributes?: PreservedAttribute[];
309
788
  };
310
789
  /** Suppress line numbers (w:suppressLineNumbers) */
311
790
  suppressLineNumbers?: boolean;
@@ -318,6 +797,24 @@ type ParagraphFormatting = {
318
797
  * and the next paragraph should render inline on the same line.
319
798
  */
320
799
  runInWithNext?: boolean;
800
+ /**
801
+ * The `w:pPr` children folio does not model, in the order the schema
802
+ * declares them.
803
+ *
804
+ * The sink records a capture's schema ordinal rather than a count of
805
+ * modelled siblings, because the writer puts every child at the place the
806
+ * declared list gives its name; see `containerChildren.ts`. One field serves
807
+ * all four owners of a paragraph property set — a paragraph, a style, a
808
+ * numbering level, and the `CT_PPrBase` snapshot inside `w:pPrChange` —
809
+ * because one reader fills it and one writer empties it.
810
+ *
811
+ * It belongs to the element that was parsed, and to no other. A style's
812
+ * captured bytes are not a paragraph's direct formatting, so style
813
+ * resolution and `mergeParagraphFormatting` drop it rather than inheriting
814
+ * it: writing an inherited value back as direct formatting would outrank the
815
+ * tier it came from.
816
+ */
817
+ preserved?: PreservedMarkup;
321
818
  };
322
819
  /**
323
820
  * Table width type
@@ -405,14 +902,33 @@ type FloatingTableProperties = {
405
902
  leftFromText?: number;
406
903
  rightFromText?: number;
407
904
  };
905
+ /**
906
+ * The grid a reviewer replaced, as `w:tblGridChange` records it.
907
+ *
908
+ * `CT_TblGridChange` holds a `w:tblGrid` of its own, and that grid holds its
909
+ * own `w:gridCol` children: a container nested in one of its own kind. It is a
910
+ * snapshot rather than a description — nothing in the live column widths
911
+ * derives it — so it is modelled as what it is, a count of columns each with
912
+ * the width it stated.
913
+ *
914
+ * `w:w` is optional on a `w:gridCol`, and a column that stated no width is not
915
+ * a column of width zero: `undefined` is what says the snapshot recorded a
916
+ * column and no measure for it.
917
+ */
918
+ type TableGridChange = {
919
+ /** `@w:id`: a physical revision id, re-minted on every save. */
920
+ id: number;
921
+ /** One entry per `w:gridCol`, in source order. */
922
+ columnWidths: readonly (number | undefined)[];
923
+ };
408
924
  /**
409
925
  * Table formatting properties (w:tblPr)
410
926
  */
411
927
  type TableFormatting = {
412
928
  /** Table width */
413
929
  width?: TableMeasurement;
414
- /** Table justification */
415
- justification?: "left" | "center" | "right";
930
+ /** Table placement (`w:tblPr/w:jc`) */
931
+ justification?: TableAlignment;
416
932
  /** Cell spacing */
417
933
  cellSpacing?: TableMeasurement;
418
934
  /** Table indent from left margin */
@@ -435,26 +951,34 @@ type TableFormatting = {
435
951
  floating?: FloatingTableProperties;
436
952
  /** Right to left table */
437
953
  bidi?: boolean;
954
+ /** Accessibility caption (`w:tblCaption`), authored in Word's alt-text dialog. */
955
+ caption?: string;
956
+ /** Long description (`w:tblDescription`), the caption's companion. */
957
+ description?: string;
958
+ /** Rows per band of the table style's row banding (`w:tblStyleRowBandSize`). */
959
+ rowBandSize?: number;
960
+ /** Columns per band (`w:tblStyleColBandSize`). */
961
+ columnBandSize?: number;
962
+ /** The `w:tblPr` children no reader took a typed value from. */
963
+ preserved?: PreservedMarkup;
438
964
  /**
439
965
  * The table's `w:tblGrid`, verbatim.
440
966
  *
441
967
  * The grid is a sibling of `w:tblPr` rather than a child of it, but it is
442
968
  * the table's own property set that travels through the editable model, so
443
969
  * it rides along here. It is replayed only while the column widths still
444
- * agree with it; {@link gridChangeXml} carries the part of it that a rebuild
970
+ * agree with it; {@link gridChange} carries the part of it that a rebuild
445
971
  * must not drop.
446
972
  */
447
973
  gridSourceXml?: string;
448
974
  /**
449
- * The grid's `w:tblGridChange`, verbatim.
975
+ * The grid's `w:tblGridChange`.
450
976
  *
451
977
  * It records the grid as it stood before a reviewer resized a column, so it
452
978
  * is history: nothing in the current model derives it, and rebuilding the
453
- * grid from the column widths would accept the revision silently. The
454
- * element is a snapshot of columns rather than a description of them, so it
455
- * travels as markup rather than as a parsed shape.
979
+ * grid from the column widths would accept the revision silently.
456
980
  */
457
- gridChangeXml?: string;
981
+ gridChange?: TableGridChange;
458
982
  /**
459
983
  * The element this formatting was parsed from, verbatim.
460
984
  *
@@ -471,6 +995,8 @@ type TableFormatting = {
471
995
  */
472
996
  sourceXml?: string;
473
997
  };
998
+ /** Table properties a row may override in `w:tblPrEx`. */
999
+ type TablePropertyExceptionFormatting = Pick<TableFormatting, "width" | "justification" | "cellSpacing" | "indent" | "borders" | "shading" | "layout" | "cellMargins" | "look" | "preserved" | "sourceXml">;
474
1000
  /**
475
1001
  * Table row formatting properties (w:trPr)
476
1002
  */
@@ -491,12 +1017,14 @@ type TableRowFormatting = {
491
1017
  header?: boolean;
492
1018
  /** Allow row to break across pages */
493
1019
  cantSplit?: boolean;
494
- /** Row justification */
495
- justification?: "left" | "center" | "right";
1020
+ /** Row placement (`w:trPr/w:jc`) */
1021
+ justification?: TableAlignment;
496
1022
  /** Hidden row */
497
1023
  hidden?: boolean;
498
1024
  /** Conditional format style */
499
1025
  conditionalFormat?: ConditionalFormatStyle;
1026
+ /** The `w:trPr` children no reader took a typed value from. */
1027
+ preserved?: PreservedMarkup;
500
1028
  /**
501
1029
  * The element this formatting was parsed from, verbatim.
502
1030
  *
@@ -556,8 +1084,8 @@ type TableCellFormatting = {
556
1084
  shading?: ShadingProperties;
557
1085
  /** Vertical alignment */
558
1086
  verticalAlign?: "top" | "center" | "bottom";
559
- /** Text direction */
560
- textDirection?: "lr" | "lrV" | "rl" | "rlV" | "tb" | "tbV" | "tbRl" | "tbRlV" | "btLr";
1087
+ /** Text direction (`w:textDirection`) */
1088
+ textDirection?: TextDirection;
561
1089
  /** Grid span (horizontal merge) */
562
1090
  gridSpan?: number;
563
1091
  /** Vertical merge */
@@ -570,6 +1098,8 @@ type TableCellFormatting = {
570
1098
  hideMark?: boolean;
571
1099
  /** Conditional format style */
572
1100
  conditionalFormat?: ConditionalFormatStyle;
1101
+ /** The `w:tcPr` children no reader took a typed value from. */
1102
+ preserved?: PreservedMarkup;
573
1103
  /**
574
1104
  * The element this formatting was parsed from, verbatim.
575
1105
  *
@@ -589,29 +1119,63 @@ type TableCellFormatting = {
589
1119
  //#endregion
590
1120
  //#region src/model/lists.d.ts
591
1121
  /**
592
- * Number format type
1122
+ * What the marker renderer counts in: folio's own vocabulary, not the format's.
1123
+ *
1124
+ * It is `ST_NumberFormat` plus the zero-padded widths a `custom` format
1125
+ * resolves to. Those three used to sit in {@link NumberFormat} itself, which
1126
+ * meant the model held tokens `w:numFmt/@w:val` does not declare and a save
1127
+ * could write one; they belong here, on the render side, where nothing is
1128
+ * serialized.
593
1129
  */
594
- type NumberFormat = "decimal" | "upperRoman" | "lowerRoman" | "upperLetter" | "lowerLetter" | "ordinal" | "cardinalText" | "ordinalText" | "hex" | "chicago" | "ideographDigital" | "japaneseCounting" | "aiueo" | "iroha" | "decimalFullWidth" | "decimalHalfWidth" | "japaneseLegal" | "japaneseDigitalTenThousand" | "decimalEnclosedCircle" | "decimalFullWidth2" | "aiueoFullWidth" | "irohaFullWidth" | "decimalZero" | "decimalZero3" | "decimalZero4" | "decimalZero5" | "bullet" | "ganada" | "chosung" | "decimalEnclosedFullstop" | "decimalEnclosedParen" | "decimalEnclosedCircleChinese" | "ideographEnclosedCircle" | "ideographTraditional" | "ideographZodiac" | "ideographZodiacTraditional" | "taiwaneseCounting" | "ideographLegalTraditional" | "taiwaneseCountingThousand" | "taiwaneseDigital" | "chineseCounting" | "chineseLegalSimplified" | "chineseCountingThousand" | "koreanDigital" | "koreanCounting" | "koreanLegal" | "koreanDigital2" | "vietnameseCounting" | "russianLower" | "russianUpper" | "none" | "numberInDash" | "hebrew1" | "hebrew2" | "arabicAlpha" | "arabicAbjad" | "hindiVowels" | "hindiConsonants" | "hindiNumbers" | "hindiCounting" | "thaiLetters" | "thaiNumbers" | "thaiCounting";
1130
+ declare const COUNTER_FORMATS: readonly ["decimal", "upperRoman", "lowerRoman", "upperLetter", "lowerLetter", "ordinal", "cardinalText", "ordinalText", "hex", "chicago", "ideographDigital", "japaneseCounting", "aiueo", "iroha", "decimalFullWidth", "decimalHalfWidth", "japaneseLegal", "japaneseDigitalTenThousand", "decimalEnclosedCircle", "decimalFullWidth2", "aiueoFullWidth", "irohaFullWidth", "decimalZero", "bullet", "ganada", "chosung", "decimalEnclosedFullstop", "decimalEnclosedParen", "decimalEnclosedCircleChinese", "ideographEnclosedCircle", "ideographTraditional", "ideographZodiac", "ideographZodiacTraditional", "taiwaneseCounting", "ideographLegalTraditional", "taiwaneseCountingThousand", "taiwaneseDigital", "chineseCounting", "chineseLegalSimplified", "chineseCountingThousand", "koreanDigital", "koreanCounting", "koreanLegal", "koreanDigital2", "vietnameseCounting", "russianLower", "russianUpper", "none", "numberInDash", "hebrew1", "hebrew2", "arabicAlpha", "arabicAbjad", "hindiVowels", "hindiConsonants", "hindiNumbers", "hindiCounting", "thaiLetters", "thaiNumbers", "thaiCounting", "bahtText", "dollarText", "custom", "decimalZero3", "decimalZero4", "decimalZero5"];
1131
+ type CounterFormat = (typeof COUNTER_FORMATS)[number];
595
1132
  /**
596
1133
  * Multi-level suffix (what follows the number)
597
1134
  */
598
1135
  type LevelSuffix = "tab" | "space" | "nothing";
1136
+ /**
1137
+ * `w:legacy`: the Word 6.0 numbering geometry a level asks for.
1138
+ *
1139
+ * `legacy` is the element's own `w:legacy` attribute rather than a `w:val`, so
1140
+ * an absent flag and an explicit `w:legacy="0"` are different states and the
1141
+ * element is recorded by presence.
1142
+ */
1143
+ type LevelLegacy = {
1144
+ legacy?: boolean;
1145
+ legacySpace?: number;
1146
+ legacyIndent?: number;
1147
+ };
599
1148
  /**
600
1149
  * List level definition
601
1150
  */
602
1151
  type ListLevel = {
603
1152
  /** Level index (0-8) */
604
1153
  ilvl: number;
1154
+ /** `w:tplc`: the template code Word keys the level's gallery entry by. */
1155
+ tplc?: string;
1156
+ /** `w:tentative`: the level is defined but no paragraph has used it yet. */
1157
+ tentative?: boolean;
605
1158
  /** Starting number */
606
1159
  start?: number;
607
- /** Number format */
1160
+ /** Number format (`w:numFmt/@w:val`) */
608
1161
  numFmt: NumberFormat;
1162
+ /**
1163
+ * `w:numFmt/@w:format`: the token list a `custom` format counts by, as
1164
+ * written. Meaningless for any other `numFmt`, and absent there.
1165
+ */
1166
+ numFmtFormat?: string;
609
1167
  /** Level text (e.g., "%1." or "•") */
610
1168
  lvlText: string;
1169
+ /** `w:lvlText@w:null`: the marker is a null character rather than the text. */
1170
+ lvlTextNull?: boolean;
611
1171
  /** Justification */
612
- lvlJc?: "left" | "center" | "right";
1172
+ lvlJc?: ParagraphAlignment;
613
1173
  /** Suffix after number */
614
1174
  suffix?: LevelSuffix;
1175
+ /** `w:pStyle`: the paragraph style this level numbers. */
1176
+ pStyle?: string;
1177
+ /** `w:lvlPicBulletId`: the `w:numPicBullet` this level draws its bullet from. */
1178
+ lvlPicBulletId?: number;
615
1179
  /** Paragraph properties for this level */
616
1180
  pPr?: ParagraphFormatting;
617
1181
  /** Run properties for the number/bullet */
@@ -621,11 +1185,11 @@ type ListLevel = {
621
1185
  /** Is legal numbering style */
622
1186
  isLgl?: boolean;
623
1187
  /** Legacy settings */
624
- legacy?: {
625
- legacy?: boolean;
626
- legacySpace?: number;
627
- legacyIndent?: number;
628
- };
1188
+ legacy?: LevelLegacy;
1189
+ /** Children of `w:lvl` the model has no field for, in source position. */
1190
+ preserved?: PreservedMarkup;
1191
+ /** Attributes of `w:lvl` the model has no field for. */
1192
+ preservedAttributes?: PreservedAttribute[];
629
1193
  };
630
1194
  /**
631
1195
  * Abstract numbering definition (w:abstractNum)
@@ -633,8 +1197,18 @@ type ListLevel = {
633
1197
  type AbstractNumbering = {
634
1198
  /** Abstract numbering ID */
635
1199
  abstractNumId: number;
1200
+ /**
1201
+ * `w:nsid`: the identity Word keys this template by across documents.
1202
+ *
1203
+ * Together with `tmpl` it is how a list carried between documents is
1204
+ * recognised as the same list, so a rebuild that dropped it turned every
1205
+ * template into a new one.
1206
+ */
1207
+ nsid?: string;
636
1208
  /** Multi-level type */
637
1209
  multiLevelType?: "hybridMultilevel" | "multilevel" | "singleLevel";
1210
+ /** `w:tmpl`: the gallery template this definition was created from. */
1211
+ tmpl?: string;
638
1212
  /** Numbering style link */
639
1213
  numStyleLink?: string;
640
1214
  /** Style link */
@@ -643,6 +1217,20 @@ type AbstractNumbering = {
643
1217
  levels: ListLevel[];
644
1218
  /** Name */
645
1219
  name?: string;
1220
+ /** Children of `w:abstractNum` the model has no field for, in source position. */
1221
+ preserved?: PreservedMarkup;
1222
+ /** Attributes of `w:abstractNum` the model has no field for. */
1223
+ preservedAttributes?: PreservedAttribute[];
1224
+ };
1225
+ /** One `w:lvlOverride`: what a concrete instance changes about one level. */
1226
+ type LevelOverride = {
1227
+ ilvl: number;
1228
+ startOverride?: number;
1229
+ lvl?: ListLevel;
1230
+ /** Children of `w:lvlOverride` the model has no field for, in source position. */
1231
+ preserved?: PreservedMarkup;
1232
+ /** Attributes of `w:lvlOverride` the model has no field for. */
1233
+ preservedAttributes?: PreservedAttribute[];
646
1234
  };
647
1235
  /**
648
1236
  * Numbering instance (w:num)
@@ -653,11 +1241,11 @@ type NumberingInstance = {
653
1241
  /** Reference to abstract numbering */
654
1242
  abstractNumId: number;
655
1243
  /** Level overrides */
656
- levelOverrides?: {
657
- ilvl: number;
658
- startOverride?: number;
659
- lvl?: ListLevel;
660
- }[];
1244
+ levelOverrides?: LevelOverride[];
1245
+ /** Children of `w:num` the model has no field for, in source position. */
1246
+ preserved?: PreservedMarkup;
1247
+ /** Attributes of `w:num` the model has no field for. */
1248
+ preservedAttributes?: PreservedAttribute[];
661
1249
  };
662
1250
  /** Typography from numbering-level `w:rPr` that applies to the marker glyphs. */
663
1251
  type ListMarkerFormatting = Pick<TextFormatting, "fontFamily" | "fontSize" | "fontSizeCs" | "bold" | "boldCs" | "italic" | "italicCs" | "rtl" | "cs">;
@@ -677,8 +1265,8 @@ type ListRendering = {
677
1265
  isBullet: boolean;
678
1266
  /** Whether this level uses legal numbering (parent placeholders render decimal). */
679
1267
  isLegal?: boolean;
680
- /** Number format type (decimal, lowerRoman, upperRoman, etc.) */
681
- numFmt?: NumberFormat;
1268
+ /** What the marker counts in (decimal, lowerRoman, a custom pad width, …). */
1269
+ numFmt?: CounterFormat;
682
1270
  /** Whether the list marker is hidden (w:vanish on level rPr) */
683
1271
  markerHidden?: boolean;
684
1272
  /** Canonical numbering-level marker typography, in OOXML units. */
@@ -697,8 +1285,8 @@ type ListRendering = {
697
1285
  * adds one space glyph; `nothing` lets body text butt against the marker.
698
1286
  */
699
1287
  markerSuffix?: LevelSuffix;
700
- /** Number format for each level from 0 through this paragraph's level. */
701
- levelNumFmts?: NumberFormat[];
1288
+ /** What each level from 0 through this paragraph's counts in. */
1289
+ levelNumFmts?: CounterFormat[];
702
1290
  /**
703
1291
  * `w:start` for each level from 0 through this paragraph's level. Layout
704
1292
  * seeds each level's counter from it, so a list whose definition starts at
@@ -733,8 +1321,136 @@ type NumberingDefinitions = {
733
1321
  abstractNums: AbstractNumbering[];
734
1322
  /** Numbering instances */
735
1323
  nums: NumberingInstance[];
1324
+ /** Children of `w:numbering` the model has no field for, in source position. */
1325
+ preserved?: PreservedMarkup;
1326
+ /** Attributes of `w:numbering` the model has no field for. */
1327
+ preservedAttributes?: PreservedAttribute[];
1328
+ };
1329
+ //#endregion
1330
+ //#region src/model/preview.d.ts
1331
+ /**
1332
+ * How a drawing with no image data is drawn, without drawing it.
1333
+ *
1334
+ * A `w:drawing` whose graphic is a diagram carries no `a:blip`, so there is no
1335
+ * image to resolve and the model has nothing to say the drawing looks like.
1336
+ * Rasterising a placeholder at parse time answers that, at the cost of holding
1337
+ * a megapixel PNG — megabytes per drawing — for the life of the document,
1338
+ * whether or not anything ever paints it.
1339
+ *
1340
+ * A descriptor says the same thing as a list of flat rectangles in the
1341
+ * drawing's own coordinate space. It is hundreds of bytes against megabytes,
1342
+ * and it is what a renderer draws: no picture is built at parse time or at
1343
+ * paint time, so a backend with vector operators draws vectors.
1344
+ */
1345
+ /** One flat rectangle of a preview, in the coordinate space of {@link PreviewDescriptor.extent}. */
1346
+ type PreviewShape = {
1347
+ readonly x: number;
1348
+ readonly y: number;
1349
+ readonly width: number;
1350
+ readonly height: number;
1351
+ /** Six hexadecimal digits, no leading `#`, as `a:srgbClr@val` spells it. */
1352
+ readonly color: string;
1353
+ };
1354
+ /**
1355
+ * Discriminated on `kind` rather than shaped as a diagram record: chart frames
1356
+ * and OLE previews are the same problem and will want the same field, and a
1357
+ * `kind` now is cheaper than migrating a bare `diagram` later.
1358
+ */
1359
+ type PreviewDescriptor = {
1360
+ readonly kind: "diagram";
1361
+ /**
1362
+ * The drawing's extent, in the units `shapes` coordinates use (EMU).
1363
+ *
1364
+ * Held here rather than read from the owning `Image.size` so a descriptor
1365
+ * that reaches a renderer alone still maps its shapes onto the box it is
1366
+ * drawn in.
1367
+ */
1368
+ readonly extent: {
1369
+ readonly width: number;
1370
+ readonly height: number;
1371
+ };
1372
+ /** Already clipped to the shape cap, in paint order. */
1373
+ readonly shapes: readonly PreviewShape[];
736
1374
  };
737
1375
  //#endregion
1376
+ //#region src/model/relationshipId.d.ts
1377
+ /**
1378
+ * A relationship reference that names something.
1379
+ *
1380
+ * A reference in the body (`r:embed` on an `a:blip`, `r:id` on a
1381
+ * `v:imagedata`) is a key into the owning part's relationships. A drawing that
1382
+ * carries none is common: a chart, an OLE frame, an anchor with no
1383
+ * `a:graphic`, and every preview folio draws for markup it cannot project.
1384
+ * Absence has one spelling, `undefined`, so it can never reach a relationship
1385
+ * lookup as a key or be written back as `r:embed=""`.
1386
+ *
1387
+ * The brand is what makes that a property of the type rather than a rule
1388
+ * producers are asked to remember. The empty string is not a `RelationshipId`,
1389
+ * so a field typed as one cannot hold the second spelling of absence, and a
1390
+ * reference read off the source becomes one only through
1391
+ * {@link relationshipIdOf}.
1392
+ */
1393
+ type RelationshipId = string & {
1394
+ readonly __brand: "folio.relationshipId";
1395
+ };
1396
+ /**
1397
+ * The relationship a reference names, or `undefined` when it names none.
1398
+ *
1399
+ * Takes what a reader hands back (a missing attribute, an attribute present
1400
+ * and empty, a reference) and answers in the one spelling the model has for
1401
+ * absence.
1402
+ */
1403
+ declare const relationshipIdOf: (value: string | null | undefined) => RelationshipId | undefined;
1404
+ /**
1405
+ * The id a save gives a part it added, from the ordinal it allocated.
1406
+ *
1407
+ * A mint is not a read, so it has no absent case to report: `rId` followed by
1408
+ * a number names something by construction, and a build where it does not is
1409
+ * one where the refinement has stopped describing the type.
1410
+ */
1411
+ declare const mintRelationshipId: (ordinal: number) => RelationshipId;
1412
+ //#endregion
1413
+ //#region src/model/presetLineDash.gen.d.ts
1414
+ /**
1415
+ * GENERATED FILE — do not edit.
1416
+ *
1417
+ * The `ST_PresetLineDashVal` enumeration, in schema order, derived from
1418
+ * `specifications/generated/docx-transitional-schema.gen.json` by
1419
+ * `scripts/generate-preset-line-dash.ts`. Regenerate with:
1420
+ *
1421
+ * bun run generate:preset-line-dash
1422
+ *
1423
+ * It is the dash vocabulary of `a:ln/a:prstDash@val`, and only that: the
1424
+ * spellings it shares with CSS `border-style` (`solid`, `dash`, `dot`)
1425
+ * name different patterns there. Read it through `./presetLineDash`.
1426
+ */
1427
+ /** Every `ST_PresetLineDashVal` member, in schema order. */
1428
+ declare const PRESET_LINE_DASH_VALS: readonly ["solid", "dot", "dash", "lgDash", "dashDot", "lgDashDot", "lgDashDotDot", "sysDash", "sysDot", "sysDashDot", "sysDashDotDot"];
1429
+ /** `a:prstDash@val`: a preset dash the schema declares. */
1430
+ type PresetLineDashVal = (typeof PRESET_LINE_DASH_VALS)[number];
1431
+ //#endregion
1432
+ //#region src/model/presetLineDash.d.ts
1433
+ /**
1434
+ * A `@val` the schema does not declare, kept exactly as the file spelled it.
1435
+ *
1436
+ * Dropping the dash would repaint an authored outline as a plain line, and
1437
+ * reading it as `solid` would rewrite the document on open. The parser reports
1438
+ * it through `ParseContext` so the normalisation is visible, and the
1439
+ * serializer writes `raw` back unchanged.
1440
+ */
1441
+ type UnrecognisedPresetLineDash = {
1442
+ readonly kind: "unrecognised";
1443
+ readonly raw: string;
1444
+ };
1445
+ /** What `ShapeOutline.dash` holds: a schema member, or the raw token. */
1446
+ type PresetLineDashValue = PresetLineDashVal | UnrecognisedPresetLineDash;
1447
+ /** Whether the schema declares this token. */
1448
+ declare const isPresetLineDashVal: (value: string) => value is PresetLineDashVal;
1449
+ /** Read a `@val` into the model, keeping an undeclared token verbatim. */
1450
+ declare const presetLineDashFrom: (value: string) => PresetLineDashValue;
1451
+ /** The token to write back, whether or not the schema declares it. */
1452
+ declare const presetLineDashToken: (dash: PresetLineDashValue) => string;
1453
+ //#endregion
738
1454
  //#region src/model/content.d.ts
739
1455
  /**
740
1456
  * Plain text content
@@ -794,9 +1510,9 @@ type FieldCharContent = {
794
1510
  type: "fieldChar";
795
1511
  /** Field character type */
796
1512
  charType: "begin" | "separate" | "end";
797
- /** Field is locked */
1513
+ /** `@w:fldLock`: absent states nothing, `false` is an explicit unlock. */
798
1514
  fldLock?: boolean;
799
- /** Field is dirty (needs update) */
1515
+ /** `@w:dirty`: absent states nothing, `false` explicitly forbids a recompute. */
800
1516
  dirty?: boolean;
801
1517
  /**
802
1518
  * Cached display value from a child `<w:numberingChange w:original="…"/>`.
@@ -831,6 +1547,27 @@ type NoBreakHyphenContent = {
831
1547
  type RenderedPageBreakContent = {
832
1548
  type: "renderedPageBreak";
833
1549
  };
1550
+ /**
1551
+ * A run child folio does not model, kept byte-for-byte at its source position.
1552
+ *
1553
+ * Dropping one is worse than a loss. The parser's keep rule asks the source
1554
+ * element whether a run carried a payload while the serializer writes the
1555
+ * model, so an unmodelled child makes the two disagree for exactly one save:
1556
+ * save 1 writes a run with nothing in it, the next parse drops that run, and
1557
+ * save 2 differs from save 1. Holding the markup in the model is what makes
1558
+ * parse∘serialize a fixed point for the whole class at once.
1559
+ */
1560
+ type PreservedXmlContent = {
1561
+ type: "preservedXml";
1562
+ /** Replayable markup for one run child, as `captureVerbatimXml` wrote it. */
1563
+ xml: string;
1564
+ /**
1565
+ * The visible text the markup contributes, empty when it shows nothing.
1566
+ * `w:ruby` is the case that matters: its `w:rubyBase` is the text a reader
1567
+ * sees, so text extraction, markdown and layout would otherwise lose a word.
1568
+ */
1569
+ text: string;
1570
+ };
834
1571
  /** Raw XML handling modes for drawings that Folio cannot model completely. */
835
1572
  declare const DRAWING_RAW_XML_MODES: {
836
1573
  readonly PRESERVE_ONLY: "preserveOnly";
@@ -878,7 +1615,7 @@ type ShapeContent = {
878
1615
  /**
879
1616
  * All possible run content types
880
1617
  */
881
- type RunContent = TextContent | TabContent | BreakContent | SymbolContent | NoteReferenceContent | FieldCharContent | InstrTextContent | SoftHyphenContent | NoBreakHyphenContent | RenderedPageBreakContent | DrawingContent | ShapeContent;
1618
+ type RunContent = TextContent | TabContent | BreakContent | SymbolContent | NoteReferenceContent | FieldCharContent | InstrTextContent | SoftHyphenContent | NoBreakHyphenContent | RenderedPageBreakContent | PreservedXmlContent | DrawingContent | ShapeContent;
882
1619
  /**
883
1620
  * A run is a contiguous region of text with the same formatting
884
1621
  */
@@ -890,6 +1627,15 @@ type Run = {
890
1627
  propertyChanges?: RunPropertyChange[];
891
1628
  /** Run content (text, tabs, breaks, etc.) */
892
1629
  content: RunContent[];
1630
+ /**
1631
+ * Attributes `w:r` carried that this record has no field for.
1632
+ *
1633
+ * `CT_R` declares `w:rsidR`, `w:rsidDel` and `w:rsidRPr`, and folio rebuilt
1634
+ * every run without them. The remainder survives a save; the editor has no
1635
+ * run record to carry it on, which the container contract states and the
1636
+ * census records as `editorProjection`.
1637
+ */
1638
+ preservedAttributes?: PreservedAttribute[];
893
1639
  };
894
1640
  /**
895
1641
  * Hyperlink (w:hyperlink)
@@ -910,8 +1656,22 @@ type Hyperlink = {
910
1656
  history?: boolean;
911
1657
  /** Document location */
912
1658
  docLocation?: string;
913
- /** Child runs */
914
- children: (Run | BookmarkStart | BookmarkEnd)[];
1659
+ /**
1660
+ * The link's content: runs, bookmark boundaries, the transparent wrappers,
1661
+ * and markup folio does not model kept where the source put it.
1662
+ *
1663
+ * `CT_Hyperlink` is `EG_PContent`, so a link may hold a permission range, a
1664
+ * proofing error or a custom-XML revision range between its runs. The
1665
+ * capture is a member of this union rather than a sink beside it for the
1666
+ * reason `PreservedInline` gives: position inside the link is what decides
1667
+ * whether the markup goes with the link when the link moves.
1668
+ *
1669
+ * `EG_PContent` also declares `w:bdo`, `w:dir`, `w:smartTag` and the
1670
+ * run-level `w:customXml`, so an author may write `w:hyperlink > w:bdo`.
1671
+ * That is the parse leg only: the editor carries a wrapper as a mark and the
1672
+ * save leg writes the canonical order, wrapper outside the link.
1673
+ */
1674
+ children: (Run | BookmarkStart | BookmarkEnd | InlineWrapper | PreservedInline)[];
915
1675
  };
916
1676
  /**
917
1677
  * Which side of a `w:customXml` element a range marker was displaced to
@@ -964,6 +1724,29 @@ type BookmarkStart = {
964
1724
  type BookmarkEnd = {
965
1725
  type: "bookmarkEnd";
966
1726
  } & MarkupRangeMarker;
1727
+ /**
1728
+ * A bookmark marker standing between a container's own children.
1729
+ *
1730
+ * `CT_Tbl` declares `w:bookmarkStart`/`w:bookmarkEnd` beside its rows and
1731
+ * `CT_Row` beside its cells, and neither a row nor a cell is what the marker
1732
+ * is, so there is no union member for it to be: this is the sink's shape, with
1733
+ * `index` counting the modelled siblings that preceded it. What it is *not* is
1734
+ * the sink itself. The verbatim sink keeps bytes, and bytes are invisible to
1735
+ * the passes that pair a start with its end, so a table- or row-level bookmark
1736
+ * captured that way takes its partner down with it. The marker stays typed;
1737
+ * only its position is an index.
1738
+ *
1739
+ * The index drifts when a column or a row is inserted or deleted around it,
1740
+ * which is the same honest cost {@link TableRow.preserved} carries and the
1741
+ * reason {@link BlockContent} admits the marker as a member wherever it can.
1742
+ */
1743
+ type PositionedBookmarkMarker = {
1744
+ /** Modelled siblings (rows for a table, cells for a row) that preceded it. */
1745
+ index: number;
1746
+ marker: BookmarkStart | BookmarkEnd;
1747
+ /** Row- or cell-level controls whose content held this marker. */
1748
+ contentControls?: SdtProperties[];
1749
+ };
967
1750
  /**
968
1751
  * Known field types
969
1752
  */
@@ -977,11 +1760,17 @@ type SimpleField = {
977
1760
  instruction: string;
978
1761
  /** Parsed field type */
979
1762
  fieldType: FieldType;
980
- /** Current display value */
981
- content: (Run | Hyperlink)[];
982
- /** Field is locked */
1763
+ /**
1764
+ * The field's cached display, the transparent wrappers around it, and any
1765
+ * markup folio does not model between the runs that carry it.
1766
+ * `CT_SimpleField` is `EG_PContent` plus `w:fldData`, so everything
1767
+ * `EG_PContent` admits can sit here, `w:bdo` / `w:dir` / `w:smartTag` /
1768
+ * `w:customXml` among them.
1769
+ */
1770
+ content: (Run | Hyperlink | InlineWrapper | PreservedInline)[];
1771
+ /** `@w:fldLock`: absent states nothing, `false` is an explicit unlock. */
983
1772
  fldLock?: boolean;
984
- /** Field is dirty */
1773
+ /** `@w:dirty`: absent states nothing, `false` explicitly forbids a recompute. */
985
1774
  dirty?: boolean;
986
1775
  };
987
1776
  /**
@@ -1004,9 +1793,9 @@ type ComplexField = {
1004
1793
  * formatting lives on the field run (eigenpal/docx-editor#909).
1005
1794
  */
1006
1795
  formatting?: TextFormatting;
1007
- /** Field is locked */
1796
+ /** `@w:fldLock`: absent states nothing, `false` is an explicit unlock. */
1008
1797
  fldLock?: boolean;
1009
- /** Field is dirty */
1798
+ /** `@w:dirty`: absent states nothing, `false` explicitly forbids a recompute. */
1010
1799
  dirty?: boolean;
1011
1800
  };
1012
1801
  type Field = SimpleField | ComplexField;
@@ -1019,6 +1808,66 @@ type ImageSize = {
1019
1808
  /** Height in EMUs */
1020
1809
  height: number;
1021
1810
  };
1811
+ /**
1812
+ * The four wrap insets, in EMU. Tri-state per key: absent is the element having
1813
+ * stated none, which OOXML reads as zero only once no other carrier states one.
1814
+ */
1815
+ type WrapDistances = {
1816
+ distT?: number;
1817
+ distB?: number;
1818
+ distL?: number;
1819
+ distR?: number;
1820
+ };
1821
+ /**
1822
+ * The element each wrap inset was authored on.
1823
+ *
1824
+ * `CT_Inline`, `CT_Anchor` and every `EG_WrapType` member but `wp:wrapNone`
1825
+ * declare their own insets, and OOXML reads the wrap child's where it states
1826
+ * one and the drawing's otherwise. Two records rather than one, so a rebuild
1827
+ * writes each inset back on the element that stated it instead of collecting
1828
+ * them all onto the drawing.
1829
+ */
1830
+ type WrapDistanceSlots = {
1831
+ /** `wp:inline`, or `wp:anchor` for a floating drawing. */
1832
+ drawing?: WrapDistances;
1833
+ /** The `wp:wrap*` child of an anchor. */
1834
+ wrapChild?: WrapDistances;
1835
+ };
1836
+ /**
1837
+ * The element each `wp:effectExtent` was authored on.
1838
+ *
1839
+ * `CT_Inline` and `CT_Anchor` declare one, and so do `CT_WrapSquare` and
1840
+ * `CT_WrapTopBottom`. The drawing's is the object's own effect reservation,
1841
+ * which is what {@link ImagePadding} holds; the wrap child's is the reservation
1842
+ * the text flow is computed against, a second value with a second owner. Two
1843
+ * records rather than one, so a rebuild writes each back on the element that
1844
+ * stated it instead of collecting both onto the drawing.
1845
+ */
1846
+ type EffectExtentSlots = {
1847
+ /** `wp:inline`, or `wp:anchor` for a floating drawing. */
1848
+ drawing?: ImagePadding;
1849
+ /** The `wp:wrapSquare` or `wp:wrapTopAndBottom` child of an anchor. */
1850
+ wrapChild?: ImagePadding;
1851
+ };
1852
+ /** A point on a wrap polygon. */
1853
+ type WrapPolygonPoint = {
1854
+ x: number;
1855
+ y: number;
1856
+ };
1857
+ /**
1858
+ * `CT_WrapPath`: the outline text flows around a tight or through wrap.
1859
+ *
1860
+ * The coordinates are the type's own relative space (a 21600-unit box over the
1861
+ * drawing's extent), not EMU, and are kept exactly as authored.
1862
+ */
1863
+ type ImageWrapPolygon = {
1864
+ /** `@edited`: absent states nothing, `false` is an explicit "generated". */
1865
+ edited?: boolean;
1866
+ /** `wp:start`, which `CT_WrapPath` requires. */
1867
+ start: WrapPolygonPoint;
1868
+ /** `wp:lineTo` in document order; `CT_WrapPath` requires at least two. */
1869
+ lineTo: WrapPolygonPoint[];
1870
+ };
1022
1871
  /**
1023
1872
  * Image wrap type for floating images
1024
1873
  */
@@ -1026,11 +1875,61 @@ type ImageWrap = {
1026
1875
  type: "inline" | "square" | "tight" | "through" | "topAndBottom" | "behind" | "inFront";
1027
1876
  /** Wrap text direction */
1028
1877
  wrapText?: "bothSides" | "left" | "right" | "largest";
1029
- /** Distance from text */
1878
+ /** The inset in force: the wrap child's where it stated one, the drawing's otherwise. */
1030
1879
  distT?: number;
1031
1880
  distB?: number;
1032
1881
  distL?: number;
1033
1882
  distR?: number;
1883
+ /** Which element stated each of the insets above. */
1884
+ distanceSlots?: WrapDistanceSlots;
1885
+ /** Which element stated a `wp:effectExtent`; the drawing's is the one in force. */
1886
+ effectExtentSlots?: EffectExtentSlots;
1887
+ /** `wp:wrapPolygon`, which `wp:wrapTight` and `wp:wrapThrough` require. */
1888
+ polygon?: ImageWrapPolygon;
1889
+ };
1890
+ /**
1891
+ * The three authored strings every `CT_NonVisualDrawingProps` carries:
1892
+ * `wp:docPr`, `pic:cNvPr` and `wps:cNvPr` each have their own set, and they are
1893
+ * the object's accessible name and alt text rather than folio's to mint.
1894
+ */
1895
+ type NonVisualDrawingNames = {
1896
+ /** `@name`, schema-required, so `""` means the object was never named. */
1897
+ name?: string;
1898
+ /** `@descr`: alt text, accessibility content. */
1899
+ alt?: string;
1900
+ /** `@title`. */
1901
+ title?: string;
1902
+ };
1903
+ /**
1904
+ * `wp:anchor`'s own attributes, and the `wp:simplePos` offsets beside them.
1905
+ *
1906
+ * A picture, a shape and a text box are the same `CT_Anchor` with a different
1907
+ * graphic inside, so they share one record: a serializer that owned only the
1908
+ * picture wrote constants for the other two, and two pictures a document
1909
+ * deliberately stacked came back on one layer.
1910
+ *
1911
+ * Tri-state per attribute. Absent is the author having stated nothing, and a
1912
+ * rebuild then writes OOXML's own default for the five `CT_Anchor` requires
1913
+ * rather than a value folio chose.
1914
+ */
1915
+ type DrawingAnchor = {
1916
+ /** `@simplePos`: position from `wp:simplePos` rather than `positionH`/`positionV`. */
1917
+ useSimplePosition?: boolean;
1918
+ /** `wp:simplePos` itself, in EMUs. */
1919
+ simplePosition?: {
1920
+ x: number;
1921
+ y: number;
1922
+ };
1923
+ /** `@relativeHeight`: z-order among the anchors on a page. */
1924
+ relativeHeight?: number;
1925
+ /** `@locked`: the anchor may not be moved. */
1926
+ locked?: boolean;
1927
+ /** `@layoutInCell`: an anchor in a table cell is confined to the cell. */
1928
+ layoutInCell?: boolean;
1929
+ /** `@allowOverlap`: anchored objects may overlap one another. */
1930
+ allowOverlap?: boolean;
1931
+ /** `@hidden`: not `wp:docPr@hidden`, which hides the drawing itself. */
1932
+ hidden?: boolean;
1034
1933
  };
1035
1934
  /**
1036
1935
  * Position for floating images
@@ -1095,6 +1994,14 @@ type ImageFrameLocks = {
1095
1994
  noMove?: boolean;
1096
1995
  noResize?: boolean;
1097
1996
  };
1997
+ /**
1998
+ * A `wp:docPr` link as authored. `rId` is the target it named, so comparing it
1999
+ * with the model's tells a retargeted link from an untouched one.
2000
+ */
2001
+ type ImageDocPrLink = {
2002
+ xml: string;
2003
+ rId?: string;
2004
+ };
1098
2005
  /**
1099
2006
  * Embedded image (w:drawing)
1100
2007
  */
@@ -1105,14 +2012,27 @@ type Image = {
1105
2012
  /**
1106
2013
  * Relationship id for the image data, absent when the drawing carries none.
1107
2014
  *
1108
- * A `w:drawing` whose graphic is not a picture — a chart, a diagram, an OLE
1109
- * frame — and one with no `a:graphic` at all have no `a:blip`, so there is no
1110
- * id to record. Absence is spelled `undefined` rather than `""` so it can
1111
- * never reach a relationship lookup as a key.
2015
+ * A `w:drawing` whose graphic is not a picture (a chart, a diagram, an OLE
2016
+ * frame) and one with no `a:graphic` at all have no `a:blip`, so there is no
2017
+ * id to record. So has no preview folio draws for markup it cannot project.
2018
+ * Absence is spelled `undefined` and only `undefined`, which {@link
2019
+ * RelationshipId} makes true of the type rather than of its producers: the
2020
+ * empty string is not one, so it can never reach a relationship lookup as a
2021
+ * key or be written back as `r:embed=""`.
1112
2022
  */
1113
- rId?: string;
2023
+ rId?: RelationshipId;
1114
2024
  /** Resolved image data (base64 or blob URL) */
1115
2025
  src?: string;
2026
+ /**
2027
+ * Present when the drawing has no image data and is drawn from a description.
2028
+ *
2029
+ * `src` keeps its meaning — resolved image data — and is not set alongside
2030
+ * this. The two are mutually exclusive in practice; they are not modelled as
2031
+ * a union because `Image` has thirty other fields and a union over the whole
2032
+ * record would churn every consumer. A drawing with neither is the existing
2033
+ * "nothing to paint" case and stays valid.
2034
+ */
2035
+ preview?: PreviewDescriptor;
1116
2036
  /** Image MIME type */
1117
2037
  mimeType?: string;
1118
2038
  /** Original filename */
@@ -1123,6 +2043,16 @@ type Image = {
1123
2043
  alt?: string;
1124
2044
  /** Authored non-visual drawing title (`wp:docPr@title`) */
1125
2045
  title?: string;
2046
+ /**
2047
+ * `pic:cNvPr`'s own name, alt text and title.
2048
+ *
2049
+ * The drawing's are `docPrName`, `alt` and `title` above, off `wp:docPr`. A
2050
+ * reader names the object from whichever of the two it is looking at, so
2051
+ * folding them together loses whichever the source did not repeat, and a
2052
+ * rebuild that wrote the media filename here renamed a picture the author
2053
+ * had named.
2054
+ */
2055
+ pictureNames?: NonVisualDrawingNames;
1126
2056
  /** Image size */
1127
2057
  size: ImageSize;
1128
2058
  /** Original size before any transforms */
@@ -1144,20 +2074,8 @@ type Image = {
1144
2074
  * fully opaque. Mirrors eigenpal docx-editor #424.
1145
2075
  */
1146
2076
  opacity?: number;
1147
- /**
1148
- * `wp:anchor layoutInCell` — when true (OOXML default), an anchored image
1149
- * inside a table cell is constrained to the cell. When false, the image
1150
- * escapes the cell into the page area. Round-tripped on save so the
1151
- * author's intent survives; undefined means "use the spec default".
1152
- */
1153
- layoutInCell?: boolean;
1154
- /**
1155
- * `wp:anchor allowOverlap` — when true (OOXML default), anchored objects
1156
- * may overlap; when false, Word repositions them to avoid collisions. We
1157
- * don't currently reposition, but we round-trip the flag so saving
1158
- * preserves the author's intent; undefined means "use the spec default".
1159
- */
1160
- allowOverlap?: boolean;
2077
+ /** `wp:anchor`'s own attributes; see {@link DrawingAnchor}. */
2078
+ anchor?: DrawingAnchor;
1161
2079
  /**
1162
2080
  * The image carries no information a reader needs, so assistive technology
1163
2081
  * skips it. Word writes this as an extension on `wp:docPr`
@@ -1182,6 +2100,14 @@ type Image = {
1182
2100
  hlinkHref?: string;
1183
2101
  /** Relationship ID for the clickable image hyperlink */
1184
2102
  hlinkRId?: string;
2103
+ /**
2104
+ * `a:hlinkClick` as authored. `hlinkRId` names the click target the editor
2105
+ * edits; the rest of `CT_Hyperlink` has no model, so the element replays
2106
+ * while `rId` says the two agree.
2107
+ */
2108
+ hlinkClickSource?: ImageDocPrLink;
2109
+ /** `a:hlinkHover` as authored; the model holds nothing of it. */
2110
+ hlinkHoverXml?: string;
1185
2111
  /** Image outline/border */
1186
2112
  outline?: ShapeOutline;
1187
2113
  /** Image effects */
@@ -1235,8 +2161,14 @@ type ShapeOutline = {
1235
2161
  width?: number;
1236
2162
  /** Line color */
1237
2163
  color?: ColorValue;
1238
- /** Line style */
1239
- style?: "solid" | "dot" | "dash" | "lgDash" | "dashDot" | "lgDashDot" | "lgDashDotDot" | "sysDot" | "sysDash" | "sysDashDot" | "sysDashDotDot";
2164
+ /**
2165
+ * `a:prstDash@val`: the preset dash pattern, in DrawingML's own vocabulary.
2166
+ *
2167
+ * Not a CSS `border-style`, though `solid`, `dash` and `dot` are spelled the
2168
+ * same in both. `a:custDash` is a different element and is not modelled; an
2169
+ * outline that carries one replays through {@link ShapeOutline.rawXml}.
2170
+ */
2171
+ dash?: PresetLineDashValue;
1240
2172
  /** Line cap */
1241
2173
  cap?: "flat" | "round" | "square";
1242
2174
  /** Line join */
@@ -1304,12 +2236,20 @@ type Shape = {
1304
2236
  alt?: string;
1305
2237
  /** Authored non-visual drawing title (`wp:docPr@title` / `wps:cNvPr@title`) */
1306
2238
  title?: string;
2239
+ /**
2240
+ * `wps:cNvPr`'s own name, alt text and title, where the source wrote a set
2241
+ * separate from `wp:docPr`'s. A rebuild wrote no `wps:cNvPr` at all, so a
2242
+ * shape named inside the graphic lost that name on every edit.
2243
+ */
2244
+ shapeNames?: NonVisualDrawingNames;
1307
2245
  /** Size in EMUs */
1308
2246
  size: ImageSize;
1309
2247
  /** Position for floating shapes */
1310
2248
  position?: ImagePosition;
1311
2249
  /** Wrap settings */
1312
2250
  wrap?: ImageWrap;
2251
+ /** `wp:anchor`'s own attributes; see {@link DrawingAnchor}. */
2252
+ anchor?: DrawingAnchor;
1313
2253
  /** Fill */
1314
2254
  fill?: ShapeFill;
1315
2255
  /** Outline/stroke */
@@ -1340,6 +2280,8 @@ type TextBox = {
1340
2280
  position?: ImagePosition;
1341
2281
  /** Wrap settings */
1342
2282
  wrap?: ImageWrap;
2283
+ /** `wp:anchor`'s own attributes; see {@link DrawingAnchor}. */
2284
+ anchor?: DrawingAnchor;
1343
2285
  /** Fill */
1344
2286
  fill?: ShapeFill;
1345
2287
  /** Outline */
@@ -1375,8 +2317,39 @@ type TableCell = {
1375
2317
  propertyChanges?: TableCellPropertyChange[];
1376
2318
  /** Tracked structural changes (cell insert/delete/merge) */
1377
2319
  structuralChange?: TableStructuralChangeInfo;
1378
- /** Cell content (paragraphs, tables, etc.) */
1379
- content: (Paragraph | Table)[];
2320
+ /**
2321
+ * Cell content.
2322
+ *
2323
+ * Derived from {@link BlockContent} rather than listed, so a new block kind
2324
+ * cannot land without a decision here; `BlockSdt` is excluded because folio
2325
+ * unwraps a `w:sdt` inside a cell into its `sdtContent` children rather
2326
+ * than modelling the wrapper, and keeping the branch out of the cell keeps
2327
+ * the model's recursion out of every table.
2328
+ */
2329
+ content: TableCellBlock[];
2330
+ /**
2331
+ * The cell-level content controls (`CT_SdtCell`) this cell sits inside,
2332
+ * outermost first.
2333
+ *
2334
+ * See {@link TableRow.contentControls}: a cell-level control is the same
2335
+ * shape one level down, and the two share the serializer that re-opens the
2336
+ * wrapper.
2337
+ */
2338
+ contentControls?: SdtProperties[];
2339
+ };
2340
+ /**
2341
+ * A table or row child the verbatim sink kept, including the content-control
2342
+ * stack that owned it when it was read.
2343
+ *
2344
+ * The position alone cannot distinguish a marker just outside a control from
2345
+ * one at the start or end of its `w:sdtContent`. Carrying the stack keeps the
2346
+ * marker inside its authored wrapper and prevents one control from being
2347
+ * rebuilt as two wrappers around the children on either side of it.
2348
+ */
2349
+ type TablePreservedMarkup = {
2350
+ children?: (PreservedChild & {
2351
+ contentControls?: SdtProperties[];
2352
+ })[];
1380
2353
  };
1381
2354
  /**
1382
2355
  * Table row
@@ -1385,12 +2358,80 @@ type TableRow = {
1385
2358
  type: "tableRow";
1386
2359
  /** Row formatting */
1387
2360
  formatting?: TableRowFormatting;
2361
+ /**
2362
+ * The table properties this row overrides (`w:tblPrEx`).
2363
+ *
2364
+ * `CT_TblPrEx` is the middle of `CT_TblPrBase` — width, justification, cell
2365
+ * spacing, indent, borders, shading, layout, cell margins and the look — so
2366
+ * it is the table's own property set narrowed to what a row may restate, and
2367
+ * it travels in the same shape. Word writes one when a table is built by
2368
+ * merging two, and a consumer reads it in place of the table's for this row
2369
+ * alone, so losing it silently restyles the row.
2370
+ *
2371
+ * It is not `formatting`: that is `w:trPr`, the row's own geometry, and the
2372
+ * two are different elements in different places in `CT_Row`.
2373
+ */
2374
+ tablePropertyExceptions?: TablePropertyExceptionFormatting;
1388
2375
  /** Row-level tracked property changes (w:trPrChange) */
1389
2376
  propertyChanges?: TableRowPropertyChange[];
2377
+ /** Tracked changes to the property exceptions (w:tblPrExChange) */
2378
+ tablePropertyExceptionChanges?: TablePropertyExceptionChange[];
1390
2379
  /** Tracked structural changes (row insert/delete) */
1391
2380
  structuralChange?: TableStructuralChangeInfo;
1392
2381
  /** Cells in this row */
1393
2382
  cells: TableCell[];
2383
+ /**
2384
+ * Row markup `cells` cannot hold, with its position among them.
2385
+ *
2386
+ * `CT_Row` declares a permission range, a proofing error, a custom-XML
2387
+ * revision range and the row-level move and comment ranges beside its
2388
+ * cells, and none of them is a cell. This is the sink case rather than the
2389
+ * union case the inline levels use: the row models one kind of child, so
2390
+ * there is no member to be, and `index` counts the cells that preceded the
2391
+ * capture.
2392
+ */
2393
+ preserved?: TablePreservedMarkup;
2394
+ /**
2395
+ * Attributes `w:tr` carried that this record has no field for.
2396
+ *
2397
+ * `CT_Row` declares `w:rsidR`, `w:rsidDel`, `w:rsidTr` and `w:rsidRPr`. The
2398
+ * remainder follows the record the same way a paragraph's does: a row the
2399
+ * editor creates has none, and a row split off another does not inherit one.
2400
+ */
2401
+ preservedAttributes?: PreservedAttribute[];
2402
+ /**
2403
+ * Bookmark markers `w:tr` held beside its cells, with their position.
2404
+ *
2405
+ * Word writes a bookmark that selects whole rows this way. See
2406
+ * {@link PositionedBookmarkMarker} for why these stay typed instead of
2407
+ * joining {@link TableRow.preserved}.
2408
+ */
2409
+ bookmarks?: PositionedBookmarkMarker[];
2410
+ /**
2411
+ * The row-level content controls (`CT_SdtRow`) this row sits inside,
2412
+ * outermost first.
2413
+ *
2414
+ * `CT_SdtRow` is transparent: what it holds is ordinary rows, and the
2415
+ * control adds a tag, an alias, a lock, a data binding and an end mark. So
2416
+ * the control is recorded *on* the rows it wrapped rather than as a member
2417
+ * between them — a member would need a node of its own in a table whose
2418
+ * children are rows, and an index would drift the moment a row moved.
2419
+ *
2420
+ * **A control may hold several rows, and then each of them carries the same
2421
+ * record.** `CT_SdtContentRow` admits `w:tr*`; across 5299 public packages
2422
+ * every one of the 23 row-level controls held exactly one row, and the same
2423
+ * for all 329 cell-level ones. The serializer rebuilds a multi-row wrapper
2424
+ * by grouping consecutive rows that name the same control, so the schema's
2425
+ * case survives without a `TableRowGroup` member that the ProseMirror table
2426
+ * schema could not carry. The cost is stated where the grouping is: two
2427
+ * adjacent rows in two separate but identically spelled controls come back
2428
+ * as one.
2429
+ *
2430
+ * The list is a stack because a control may hold a control: a repeating
2431
+ * section whose row is itself bound. Outermost first, as the source wrote
2432
+ * them.
2433
+ */
2434
+ contentControls?: SdtProperties[];
1394
2435
  };
1395
2436
  /**
1396
2437
  * Table (w:tbl)
@@ -1405,7 +2446,28 @@ type Table = {
1405
2446
  columnWidths?: number[];
1406
2447
  /** Table rows */
1407
2448
  rows: TableRow[];
1408
- } & BlockRangeMarkerCapture;
2449
+ /**
2450
+ * Table markup `rows` cannot hold, with its position among them.
2451
+ *
2452
+ * `CT_Tbl` declares a permission range, a proofing error, the table-level
2453
+ * comment and move ranges and the eight custom-XML revision ranges beside
2454
+ * `w:tr`, and none of them is a row. The row sink one level down has the
2455
+ * same shape for the same reason: the table models one kind of child, so
2456
+ * there is no union member to be, and `index` counts the rows that preceded
2457
+ * the capture. `w:tblPr` and `w:tblGrid` precede every row in the content
2458
+ * model and are read and written elsewhere, so they are not in the sink and
2459
+ * the index counts rows only.
2460
+ */
2461
+ preserved?: TablePreservedMarkup;
2462
+ /**
2463
+ * Bookmark markers `w:tbl` held beside its rows, with their position.
2464
+ *
2465
+ * Word writes a bookmark that selects a whole table this way. See
2466
+ * {@link PositionedBookmarkMarker} for why these stay typed instead of
2467
+ * joining {@link Table.preserved}.
2468
+ */
2469
+ bookmarks?: PositionedBookmarkMarker[];
2470
+ };
1409
2471
  /**
1410
2472
  * A comment (w:comment) from comments.xml
1411
2473
  */
@@ -1426,6 +2488,14 @@ type Comment = {
1426
2488
  parentId?: number;
1427
2489
  /** Whether the comment is resolved/done */
1428
2490
  done?: boolean;
2491
+ /**
2492
+ * Body markup `content` cannot hold: a table, an equation, a content
2493
+ * control, a bookmark or range marker, a tracked-change wrapper. The
2494
+ * schema lets a comment body hold everything a document body can, and a
2495
+ * reviewer's words disappearing on save is not an acceptable simplification
2496
+ * of that.
2497
+ */
2498
+ preserved?: PreservedMarkup;
1429
2499
  };
1430
2500
  /**
1431
2501
  * Comment range start marker in paragraph content
@@ -1512,8 +2582,18 @@ type PropertyChangeInfo = {
1512
2582
  /** Optional revision session ID */
1513
2583
  rsid?: string;
1514
2584
  } & TrackedChangeInfo;
1515
- /** Inline content that may sit inside a run-level tracked-change wrapper. */
1516
- type TrackedRunContent = Run | Hyperlink | BookmarkStart | BookmarkEnd | SimpleField | ComplexField | MathEquation | TrackedRunChange;
2585
+ /**
2586
+ * Inline content that may sit inside a run-level tracked-change wrapper.
2587
+ *
2588
+ * The transparent wrappers belong here. A `w:bdo` / `w:dir` states how its
2589
+ * content is laid out and a `w:sdt` states what its content is bound to;
2590
+ * neither says anything about the revision, so a revision that holds one
2591
+ * holds it as content. Modelling it otherwise forces the parser to lift the
2592
+ * wrapper out to a sibling, which takes the wrapped text out of the revision
2593
+ * with it: the text is then neither inserted nor deleted, and accepting and
2594
+ * rejecting the revision both keep it.
2595
+ */
2596
+ type TrackedRunContent = Run | Hyperlink | BookmarkStart | BookmarkEnd | SimpleField | ComplexField | InlineSdt | InlineWrapper | MathEquation | PreservedInline | TrackedRunChange;
1517
2597
  /**
1518
2598
  * Insertion wrapper (w:ins) — runs inserted by tracked changes
1519
2599
  */
@@ -1571,19 +2651,61 @@ declare const BIDI_CONTROLS: {
1571
2651
  };
1572
2652
  type BidiControl = (typeof BIDI_CONTROLS)[keyof typeof BIDI_CONTROLS];
1573
2653
  /**
1574
- * A bidirectional embedding or override (w:dir, w:bdo) — ECMA-376 §17.3.2.8, §17.3.2.3.
2654
+ * A transparent inline wrapper, discriminated by what kind of wrapper it is.
2655
+ *
2656
+ * Transparent means it says something about its content without constraining
2657
+ * it: it nests, it may hold anything paragraph content may hold, and dropping
2658
+ * it changes what the reader sees or what the markup states rather than what
2659
+ * the text is.
2660
+ *
2661
+ * The discriminant is what keeps the kinds apart structurally: a smart tag
2662
+ * cannot carry a bidirectional `control`, and a bidirectional wrapper cannot
2663
+ * carry an `element`, because neither branch declares the other's field.
1575
2664
  *
1576
- * A transparent inline wrapper: it changes how its content is laid out and
1577
- * nothing else, so it nests, it may hold anything paragraph content may hold,
1578
- * and dropping it changes what the reader sees rather than only what the file
1579
- * says.
2665
+ * `smartTag` and `customXml` declare the same three slots because their
2666
+ * content models do, and they are written out rather than shared through a
2667
+ * helper so that the published type says what each kind carries without
2668
+ * naming a second one. They stay separate kinds because they are separate
2669
+ * elements: a smart tag is Word's own recognizer markup and a custom-XML
2670
+ * wrapper is a mapping into a caller's schema.
2671
+ *
2672
+ * - `bidi` is `w:dir` / `w:bdo` — ECMA-376 §17.3.2.8, §17.3.2.3.
2673
+ * - `smartTag` is `w:smartTag` — §17.5.1.9.
2674
+ * - `customXml` is the run-level `w:customXml` — §17.5.1.6.
1580
2675
  */
1581
- type BidiWrapper = {
1582
- type: "bidiWrapper";
2676
+ type InlineWrapper = {
2677
+ type: "inlineWrapper";
2678
+ kind: "bidi";
1583
2679
  control: BidiControl;
1584
2680
  /** `w:val`; absent in the source means the wrapper states no direction. */
1585
2681
  direction?: "ltr" | "rtl";
1586
2682
  content: ParagraphContent[];
2683
+ } | {
2684
+ type: "inlineWrapper";
2685
+ kind: "smartTag";
2686
+ /** `w:element`: the local name of the tagged element. */
2687
+ element: string;
2688
+ /** `w:uri`; absent means the tag names no namespace. */
2689
+ uri?: string;
2690
+ /**
2691
+ * `w:smartTagPr` verbatim: an attribute bag (`w:attr` children) whose
2692
+ * meaning belongs to the producer that wrote it, so folio replays the
2693
+ * bytes rather than modelling them. See
2694
+ * `docs/verbatim-markup-trust-boundary.md` for what that obliges a
2695
+ * writer that builds a document from scratch to check.
2696
+ */
2697
+ propertiesXml?: string;
2698
+ content: ParagraphContent[];
2699
+ } | {
2700
+ type: "inlineWrapper";
2701
+ kind: "customXml";
2702
+ /** `w:element`: the local name of the tagged element. */
2703
+ element: string;
2704
+ /** `w:uri`; absent means the tag names no namespace. */
2705
+ uri?: string;
2706
+ /** `w:customXmlPr` verbatim; see the `smartTag` branch. */
2707
+ propertiesXml?: string;
2708
+ content: ParagraphContent[];
1587
2709
  };
1588
2710
  /**
1589
2711
  * Move-from range start marker (w:moveFromRangeStart) — ECMA-376 §17.13.5.22
@@ -1651,6 +2773,22 @@ type TablePropertyChange = {
1651
2773
  /** Table properties after the tracked change (editor model convenience) */
1652
2774
  currentFormatting?: TableFormatting;
1653
2775
  };
2776
+ /**
2777
+ * Table property exception change (w:tblPrExChange)
2778
+ *
2779
+ * Its own type rather than a `TablePropertyChange`: it carries the row-legal
2780
+ * subset and is written as a different element in a different container. A
2781
+ * shared discriminator would let one reach the other's serializer.
2782
+ */
2783
+ type TablePropertyExceptionChange = {
2784
+ type: "tablePropertyExceptionChange";
2785
+ /** Tracked change metadata */
2786
+ info: PropertyChangeInfo;
2787
+ /** Property exceptions before the tracked change */
2788
+ previousFormatting?: TablePropertyExceptionFormatting;
2789
+ /** Property exceptions after the tracked change (editor model convenience) */
2790
+ currentFormatting?: TablePropertyExceptionFormatting;
2791
+ };
1654
2792
  /**
1655
2793
  * Table row property change (w:trPrChange)
1656
2794
  */
@@ -1674,6 +2812,16 @@ type TableCellPropertyChange = {
1674
2812
  previousFormatting?: TableCellFormatting;
1675
2813
  /** Cell properties after the tracked change (editor model convenience) */
1676
2814
  currentFormatting?: TableCellFormatting;
2815
+ /**
2816
+ * The cell's own insertion, deletion or merge as the snapshot recorded it.
2817
+ *
2818
+ * `CT_TcPrInner` is `CT_TcPrBase` plus `EG_CellMarkupElements`, so the
2819
+ * `w:tcPr` inside a `w:tcPrChange` may carry `w:cellIns`, `w:cellDel` or
2820
+ * `w:cellMerge` — "before this property change, the cell stood inserted".
2821
+ * It is not the cell's current revision, which is
2822
+ * {@link TableCell.structuralChange}, so it rides the change that recorded it.
2823
+ */
2824
+ previousStructuralChange?: TableStructuralChangeInfo;
1677
2825
  };
1678
2826
  /**
1679
2827
  * Section property change (w:sectPrChange)
@@ -1692,6 +2840,36 @@ type SectionPropertyChange = {
1692
2840
  /** Section properties after the tracked change (editor model convenience) */
1693
2841
  currentProperties?: SectionProperties;
1694
2842
  };
2843
+ /**
2844
+ * Every tracked property revision the model carries: a change element that
2845
+ * stores the complete previous property set beside a {@link PropertyChangeInfo},
2846
+ * so accepting it drops the record and rejecting it restores the set.
2847
+ *
2848
+ * Structural revisions ({@link TrackedRunChange}, {@link ParagraphMarkChange},
2849
+ * {@link TableStructuralChangeInfo}) are deliberately outside it: they add or
2850
+ * remove content rather than restate properties, and they resolve by moving
2851
+ * content rather than by restoring a snapshot.
2852
+ */
2853
+ type PropertyChange = RunPropertyChange | ParagraphPropertyChange | SectionPropertyChange | TablePropertyChange | TablePropertyExceptionChange | TableRowPropertyChange | TableCellPropertyChange;
2854
+ /** One of {@link PROPERTY_REVISION_KINDS}. */
2855
+ type PropertyRevisionKind = PropertyChange["type"];
2856
+ /**
2857
+ * Runtime census of {@link PropertyChange}'s discriminators.
2858
+ *
2859
+ * It is the one place the set is written down. Every consumer that resolves,
2860
+ * lists or compares a property revision is total over it
2861
+ * (`satisfies Record<PropertyRevisionKind, …>`), so a revision the model gains
2862
+ * is a compile error at each of those sites rather than a branch nobody wrote.
2863
+ */
2864
+ declare const PROPERTY_REVISION_KINDS: Readonly<{
2865
+ readonly runPropertyChange: "runPropertyChange";
2866
+ readonly paragraphPropertyChange: "paragraphPropertyChange";
2867
+ readonly sectionPropertyChange: "sectionPropertyChange";
2868
+ readonly tablePropertyChange: "tablePropertyChange";
2869
+ readonly tablePropertyExceptionChange: "tablePropertyExceptionChange";
2870
+ readonly tableRowPropertyChange: "tableRowPropertyChange";
2871
+ readonly tableCellPropertyChange: "tableCellPropertyChange";
2872
+ }>;
1695
2873
  /**
1696
2874
  * Table structural tracked change metadata (row/cell insert/delete/merge)
1697
2875
  */
@@ -1715,16 +2893,16 @@ type SdtType = "richText" | "plainText" | "date" | "dropdown" | "comboBox" | "ch
1715
2893
  /**
1716
2894
  * SDT properties (`w:sdtPr`).
1717
2895
  *
1718
- * Modeled fields are a read-only projection for downstream tooling
1719
- * (tag/alias addressing, template extraction). They are NOT the
1720
- * serialization source: the original `<w:sdtPr>` is captured verbatim in
1721
- * `rawPropertiesXml` and replayed on save, which preserves element order
1722
- * (`CT_SdtPr` is an `xsd:sequence`), avoids double-emission, and keeps
1723
- * unmodeled features (`w:dataBinding`, `w15:repeatingSection`, `@lastValue`,
1724
- * `w:sdtEndPr`) lossless.
2896
+ * The modelled fields are the addressing and interaction surface: a tag, an
2897
+ * alias, a lock, the value a user picked. Everything else the schema declares
2898
+ * — the control-kind element, `w:dataBinding`, `w:label`, `w:tabIndex`,
2899
+ * `w:temporary`, `w:rPr` — and every extension-namespace child a producer
2900
+ * writes are in {@link SdtProperties.preserved}, at the ordinal `CT_SdtPr`'s
2901
+ * sequence gives them. Together the two are the whole element: the serializer
2902
+ * writes both halves and nothing replays the source's bytes whole.
1725
2903
  */
1726
2904
  type SdtProperties = {
1727
- /** SDT type (projection; round-trip uses `rawPropertiesXml`). */
2905
+ /** SDT type (a projection of the control-kind element the set holds). */
1728
2906
  sdtType: SdtType;
1729
2907
  /** Numeric id (`w:id/@w:val`). */
1730
2908
  id?: number;
@@ -1766,13 +2944,25 @@ type SdtProperties = {
1766
2944
  /** Checkbox checked state (`w14:checkbox/w14:checked`). */
1767
2945
  checked?: boolean;
1768
2946
  /**
1769
- * Verbatim `<w:sdtPr>…</w:sdtPr>` captured at parse time. Replayed on
1770
- * serialize so unmodeled OOXML features (data binding, repeating sections,
1771
- * `@lastValue`, custom XML mappings) survive round-trip.
2947
+ * The `w:sdtPr` children folio does not model, at their schema ordinal.
2948
+ *
2949
+ * `CT_SdtPr` is an `xsd:sequence`, so the ordinal is the child's position
2950
+ * in it rather than a count of modelled siblings: the count is a mirror of
2951
+ * whichever properties folio models today and it moves under the capture
2952
+ * the moment one more of them is modelled.
1772
2953
  */
1773
- rawPropertiesXml?: string;
2954
+ preserved?: PreservedMarkup;
1774
2955
  /** Verbatim `<w:sdtEndPr>…</w:sdtEndPr>` captured at parse time. */
1775
2956
  rawEndPropertiesXml?: string;
2957
+ /**
2958
+ * `w:sdtEndPr` as a record, beside the bytes above rather than instead of
2959
+ * them.
2960
+ *
2961
+ * The capture is replayed while it exists, and a control folio *rebuilds* —
2962
+ * one an edit touched, one a full repack writes — has no bytes to replay,
2963
+ * so before this the end mark simply disappeared from the saved control.
2964
+ */
2965
+ endProperties?: SdtEndProperties;
1776
2966
  /**
1777
2967
  * Verbatim XML for any non-content direct children of `<w:sdt>` that
1778
2968
  * appear BEFORE `<w:sdtContent>` — MS-OE376 §2.5.2.30 documents 16
@@ -1786,20 +2976,41 @@ type SdtProperties = {
1786
2976
  /** Verbatim XML for non-content sdt children that appear AFTER `<w:sdtContent>`. */
1787
2977
  rawSdtChildrenAfterContent?: string;
1788
2978
  };
2979
+ /**
2980
+ * `w:sdtEndPr`: what the control's end-of-content mark carries.
2981
+ *
2982
+ * `CT_SdtEndPr` declares `w:rPr` and nothing else, so the record's presence is
2983
+ * the element's and its one field is those run properties. `<w:sdtEndPr/>`
2984
+ * with no `w:rPr` is what Word writes for most controls and says something an
2985
+ * absent element does not, which is why presence is the record rather than a
2986
+ * flag on {@link SdtProperties}.
2987
+ */
2988
+ type SdtEndProperties = {
2989
+ /** `w:sdtEndPr/w:rPr`, absent when the element declared none. */
2990
+ runProperties?: TextFormatting;
2991
+ };
1789
2992
  /**
1790
2993
  * Inline SDT (content control within a paragraph).
1791
2994
  *
1792
2995
  * OOXML allows runs, hyperlinks, simple/complex fields, nested SDTs,
1793
- * tracked insertions/deletions/moves, and math at this level. All of them must survive
1794
- * parse → edit → save so docProps-bound fields and reviewed template
1795
- * content do not lose their wrapper on round-trip.
2996
+ * tracked insertions/deletions/moves, the bidirectional controls, and math at
2997
+ * this level. All of them must survive parse → edit → save so docProps-bound
2998
+ * fields and reviewed template content do not lose their wrapper on round-trip.
2999
+ *
3000
+ * The bookmark boundaries belong here for the reason the revision wrapper's
3001
+ * do: `CT_SdtContentRun` reaches them through
3002
+ * `EG_RunLevelElts > EG_RangeMarkupElements`, and a marker lifted out to a
3003
+ * sibling of the control is a bookmark whose extent has changed. A range that
3004
+ * covered the control's content ends up covering the control and whatever
3005
+ * follows it, so a `REF` field or a link to the bookmark resolves to the
3006
+ * wrong text.
1796
3007
  */
1797
3008
  type InlineSdt = {
1798
3009
  type: "inlineSdt";
1799
3010
  /** SDT properties */
1800
3011
  properties: SdtProperties;
1801
3012
  /** Inline content held inside the control */
1802
- content: (Run | Hyperlink | SimpleField | ComplexField | InlineSdt | Insertion | Deletion | MoveFrom | MoveTo | MathEquation)[];
3013
+ content: (Run | Hyperlink | BookmarkStart | BookmarkEnd | SimpleField | ComplexField | InlineSdt | InlineWrapper | Insertion | Deletion | MoveFrom | MoveTo | MathEquation | PreservedInline)[];
1803
3014
  };
1804
3015
  /**
1805
3016
  * Block-level SDT (content control wrapping paragraphs/tables).
@@ -1810,15 +3021,42 @@ type InlineSdt = {
1810
3021
  */
1811
3022
  type BlockSdt = {
1812
3023
  type: "blockSdt";
1813
- /** SDT properties (raw XML in `properties.rawPropertiesXml` round-trips losslessly). */
3024
+ /** SDT properties; `properties.preserved` carries what the model does not. */
1814
3025
  properties: SdtProperties;
1815
3026
  /** Block content inside the control. */
1816
3027
  content: BlockContent[];
1817
- } & BlockRangeMarkerCapture;
3028
+ };
1818
3029
  /**
1819
3030
  * Paragraph content types
1820
3031
  */
1821
- type ParagraphContent = Run | Hyperlink | BookmarkStart | BookmarkEnd | SimpleField | ComplexField | InlineSdt | CommentRangeStart | CommentRangeEnd | CommentReference | Insertion | Deletion | MoveFrom | MoveTo | MoveFromRangeStart | MoveFromRangeEnd | MoveToRangeStart | MoveToRangeEnd | BidiWrapper | MathEquation;
3032
+ /**
3033
+ * Inline-level markup folio does not model, kept at its source position.
3034
+ *
3035
+ * The run-level twin is `PreservedXmlContent` and the block-level one is
3036
+ * `PreservedBlock`; this is the level between them. A paragraph, a run-level
3037
+ * tracked-change wrapper, a bidirectional wrapper and an inline content
3038
+ * control all admit `w:permStart`, `w:proofErr`, `w:customXml` and the eight
3039
+ * custom-XML revision ranges, none of which is a run and none of which folio
3040
+ * models. Inside a tracked-change wrapper the position is the point: markup
3041
+ * lifted out of a `w:ins` is markup the reviewer no longer accepts or rejects
3042
+ * along with the change, so the capture is a member of the wrapper's own
3043
+ * content union rather than a sibling beside it.
3044
+ *
3045
+ * Opaque, so it holds no fields and no comment anchors; `text` is what the
3046
+ * markup puts on the line, which is empty for everything except a transparent
3047
+ * wrapper such as `w:customXml`.
3048
+ */
3049
+ type PreservedInline = {
3050
+ type: "preservedInline";
3051
+ /** Replayable markup for one child, as `captureVerbatimXml` wrote it. */
3052
+ xml: string;
3053
+ /** The visible text the markup contributes, empty when it shows nothing. */
3054
+ text: string;
3055
+ };
3056
+ /**
3057
+ * Paragraph content types
3058
+ */
3059
+ type ParagraphContent = Run | Hyperlink | BookmarkStart | BookmarkEnd | SimpleField | ComplexField | InlineSdt | CommentRangeStart | CommentRangeEnd | CommentReference | Insertion | Deletion | MoveFrom | MoveTo | MoveFromRangeStart | MoveFromRangeEnd | MoveToRangeStart | MoveToRangeEnd | InlineWrapper | MathEquation | PreservedInline;
1822
3060
  /**
1823
3061
  * The kinds a paragraph-mark tracked change can be (ECMA-376 §17.13.5).
1824
3062
  *
@@ -1870,7 +3108,19 @@ type Paragraph = {
1870
3108
  renderedPageBreakBefore?: boolean;
1871
3109
  /** Section properties (if this paragraph ends a section) */
1872
3110
  sectionProperties?: SectionProperties;
1873
- } & BlockRangeMarkerCapture;
3111
+ /**
3112
+ * Attributes `w:p` carried that this record has no field for.
3113
+ *
3114
+ * Word writes a revision-session id (`w:rsidR` and its family) on nearly
3115
+ * every paragraph, and a rebuild that dropped it rewrote the document's
3116
+ * revision history. The remainder follows the record: a paragraph the
3117
+ * editor creates from scratch has none, and when an edit splits one in two
3118
+ * the half that keeps the authored identity keeps the remainder, because a
3119
+ * revision id inherited from a neighbour is a claim about history nobody
3120
+ * made.
3121
+ */
3122
+ preservedAttributes?: PreservedAttribute[];
3123
+ };
1874
3124
  /**
1875
3125
  * Header/footer type
1876
3126
  */
@@ -2044,7 +3294,7 @@ type Footnote = {
2044
3294
  * work in notes the same as they do in the main body. Mirrors the
2045
3295
  * shape upstream eigenpal/docx-editor#678 fixed for the same case.
2046
3296
  */
2047
- content: (Paragraph | Table | BlockSdt)[];
3297
+ content: BlockContent[];
2048
3298
  };
2049
3299
  /**
2050
3300
  * Endnote (w:endnote)
@@ -2059,7 +3309,7 @@ type Endnote = {
2059
3309
  * Content. Like `Footnote.content`, may carry block-level `<w:sdt>`
2060
3310
  * preserved as `BlockSdt` so SDT round-trip works inside endnotes.
2061
3311
  */
2062
- content: (Paragraph | Table | BlockSdt)[];
3312
+ content: BlockContent[];
2063
3313
  };
2064
3314
  /**
2065
3315
  * Page orientation
@@ -2089,7 +3339,6 @@ type Column = {
2089
3339
  /**
2090
3340
  * Section properties (w:sectPr)
2091
3341
  */
2092
- type SectionTextDirection = "lrTb" | "tbRl" | "btLr" | "lrTbV" | "tbRlV" | "tbLrV" | "tb" | "rl" | "lr" | "tbV" | "rlV" | "lrV";
2093
3342
  type SectionProperties = {
2094
3343
  /** Page width in twips */
2095
3344
  pageWidth?: number;
@@ -2125,8 +3374,8 @@ type SectionProperties = {
2125
3374
  sectionStart?: SectionStart;
2126
3375
  /** Vertical alignment of text */
2127
3376
  verticalAlign?: VerticalAlign;
2128
- /** Section text direction */
2129
- textDirection?: SectionTextDirection;
3377
+ /** Section text direction (`w:sectPr/w:textDirection`) */
3378
+ textDirection?: TextDirection;
2130
3379
  /** Right-to-left section */
2131
3380
  bidi?: boolean;
2132
3381
  /** Header references */
@@ -2167,7 +3416,7 @@ type SectionProperties = {
2167
3416
  /** Page background */
2168
3417
  background?: {
2169
3418
  color?: ColorValue;
2170
- themeColor?: ThemeColorSlot;
3419
+ themeColor?: ThemeColorValue;
2171
3420
  themeTint?: string;
2172
3421
  themeShade?: string;
2173
3422
  };
@@ -2197,27 +3446,59 @@ type SectionProperties = {
2197
3446
  printerSettingsRelationshipId?: string;
2198
3447
  /** Section-level tracked property changes (w:sectPrChange) */
2199
3448
  propertyChanges?: SectionPropertyChange[];
3449
+ /** The `w:sectPr` children no reader took a typed value from. */
3450
+ preserved?: PreservedMarkup;
3451
+ /**
3452
+ * Attributes `w:sectPr` carried that this record has no field for.
3453
+ *
3454
+ * `AG_SectPrAttributes` declares `w:rsidR`, `w:rsidDel`, `w:rsidRPr` and
3455
+ * `w:rsidSect`, on the body's section properties and on a paragraph's alike.
3456
+ * The record travels through the editor whole, so the remainder does too.
3457
+ */
3458
+ preservedAttributes?: PreservedAttribute[];
2200
3459
  };
2201
3460
  /**
2202
- * Range markers captured verbatim from between two blocks.
3461
+ * A block-level child folio does not model, kept where it stood.
3462
+ *
3463
+ * `w:body`, `w:tc`, `w:hdr`, `w:ftr`, an SDT's content and a footnote all
3464
+ * admit more than paragraphs, tables and content controls: `w:permStart` is
3465
+ * the whole of a document-protection range, `w:altChunk` is an entire imported
3466
+ * document, `m:oMathPara` is a display equation, and a comment or move range
3467
+ * may open between two blocks. Position is their meaning, so the capture is a
3468
+ * block in its own right rather than a field riding on a neighbour: it sits
3469
+ * between the same two siblings in the model, in the editor and in the saved
3470
+ * part, and nothing has to keep an index honest as the blocks around it move.
2203
3471
  *
2204
- * `w:permStart`, `w:customXml*Range*`, and a comment or move range that opens
2205
- * or closes between blocks are all legal children of `w:body`, `w:tc` and a
2206
- * header. folio has no model for most of them, and their position is the whole
2207
- * of their meaning: a protected range that spans three paragraphs is defined
2208
- * by where its `w:permStart` sits. So they ride on the block they precede or
2209
- * follow and are replayed there.
3472
+ * Being opaque, it holds no text, no fields and no comment anchors; a walker
3473
+ * looking for any of those may skip it, and every walker that rebuilds block
3474
+ * content must write it back.
2210
3475
  */
2211
- type BlockRangeMarkerCapture = {
2212
- /** Markup that stood immediately before this block. */
2213
- rawMarkersBefore?: string;
2214
- /** Markup that stood after this block, which only the last block can carry. */
2215
- rawMarkersAfter?: string;
3476
+ type PreservedBlock = {
3477
+ type: "preservedBlock";
3478
+ /** Replayable markup for one child, as `captureVerbatimXml` wrote it. */
3479
+ xml: string;
2216
3480
  };
2217
3481
  /**
2218
3482
  * Block-level content types
3483
+ *
3484
+ * `BookmarkStart` and `BookmarkEnd` are members here as well as in
3485
+ * {@link ParagraphContent}, because `CT_Body`, `CT_Tc` and
3486
+ * `CT_SdtContentBlock` each declare them beside their blocks and Word writes
3487
+ * them there: `_GoBack` on the body, a form field's range on the cell, a
3488
+ * table-of-contents range around the blocks it covers. The marker is the same
3489
+ * element at either level, so it is the same model type, read and written by
3490
+ * the same parser and serializer.
3491
+ *
3492
+ * It is a member rather than a capture for a reason the two levels share.
3493
+ * A bookmark is a pair, and folio's pairing passes — `collectPairedBookmarkIds`
3494
+ * on the way in, the boundary integrity plugin on the way back — can only see a
3495
+ * marker the model holds. Keeping the block-level half as opaque bytes leaves
3496
+ * the paragraph-level half unpaired, and an unpaired boundary is deleted: the
3497
+ * bookmark would not merely move, it would go.
2219
3498
  */
2220
- type BlockContent = Paragraph | Table | BlockSdt;
3499
+ type BlockContent = Paragraph | Table | BlockSdt | PreservedBlock | BookmarkStart | BookmarkEnd;
3500
+ /** {@link BlockContent} minus the branch folio does not model inside a cell. */
3501
+ type TableCellBlock = Exclude<BlockContent, BlockSdt>;
2221
3502
  /**
2222
3503
  * Section (implicit or explicit based on sectPr)
2223
3504
  */
@@ -2301,12 +3582,20 @@ declare const PARSE_WARNING_CODES: {
2301
3582
  readonly headerFooterTypeOutsideEnum: "header-footer-type-outside-enum";
2302
3583
  /** A value outside `ST_OnOff`'s six spellings. */
2303
3584
  readonly unrecognisedOnOffValue: "unrecognised-on-off-value";
3585
+ /** A theme-colour token outside `ST_ThemeColor`, kept but not painted. */
3586
+ readonly unrecognisedThemeColor: "unrecognised-theme-color";
2304
3587
  /** A `CT_Border` with no `w:val`, which has no border style to read. */
2305
3588
  readonly borderWithoutValue: "border-without-value";
3589
+ /** A `w:val` outside `ST_Border`, kept verbatim rather than read as a style. */
3590
+ readonly borderStyleOutsideEnum: "border-style-outside-enum";
3591
+ /** An `a:prstDash@val` outside `ST_PresetLineDashVal`, kept verbatim. */
3592
+ readonly outlineDashOutsideEnum: "outline-dash-outside-enum";
2306
3593
  /** A style set defining two styles under one id. */
2307
3594
  readonly styleSetDuplicateStyleId: "style-set-duplicate-style-id";
2308
3595
  /** A style set naming an initial paragraph style it does not contain. */
2309
3596
  readonly styleSetInitialStyleMissing: "style-set-initial-style-missing";
3597
+ /** An explicit page-break run the editable model lays out approximately. */
3598
+ readonly pageBreakProjectionApproximated: "page-break-projection-approximated";
2310
3599
  };
2311
3600
  type ParseWarningCode = (typeof PARSE_WARNING_CODES)[keyof typeof PARSE_WARNING_CODES];
2312
3601
  /** Where a warning happened, as precisely as the part can say. */
@@ -2487,6 +3776,33 @@ type Theme = {
2487
3776
  name?: string;
2488
3777
  };
2489
3778
  };
3779
+ /**
3780
+ * `w:charset`: the code page a font is encoded in, numbered and named.
3781
+ *
3782
+ * Two attributes of one element rather than two fields on the font, because
3783
+ * `w:charset` is the thing that carries both and a producer may write either.
3784
+ */
3785
+ type FontCharset = {
3786
+ /** `w:val`: the code page as a two-digit hexadecimal number. */
3787
+ val?: string;
3788
+ /** `w:characterSet`: the same set named (`ANSI_CHARSET`) rather than numbered. */
3789
+ characterSet?: string;
3790
+ };
3791
+ /**
3792
+ * One embedded face: the relationship to its binary and how to read it.
3793
+ *
3794
+ * The relationship id alone is not enough to use the face. `w:fontKey` is the
3795
+ * GUID the `.odttf` is obfuscated with, so a package that keeps the id and
3796
+ * drops the key keeps a pointer to bytes nothing can decode.
3797
+ */
3798
+ type EmbeddedFontRef = {
3799
+ /** `r:id` of the relationship to the font binary, in `word/_rels/fontTable.xml.rels`. */
3800
+ id: string;
3801
+ /** `w:fontKey`: the obfuscation GUID, e.g. `{XXXXXXXX-…}`. */
3802
+ fontKey?: string;
3803
+ /** `w:subsetted`: the embedded face carries only the glyphs the document uses. */
3804
+ subsetted?: boolean;
3805
+ };
2490
3806
  /**
2491
3807
  * Font info from fontTable.xml
2492
3808
  */
@@ -2498,7 +3814,7 @@ type FontInfo = {
2498
3814
  /** Panose-1 classification */
2499
3815
  panose1?: string;
2500
3816
  /** Character set */
2501
- charset?: string;
3817
+ charset?: FontCharset;
2502
3818
  /** Font family type */
2503
3819
  family?: "decorative" | "modern" | "roman" | "script" | "swiss" | "auto";
2504
3820
  /** Pitch (fixed or variable) */
@@ -2513,16 +3829,30 @@ type FontInfo = {
2513
3829
  csb1?: string;
2514
3830
  };
2515
3831
  /** Embedded font data reference */
2516
- embedRegular?: string;
2517
- embedBold?: string;
2518
- embedItalic?: string;
2519
- embedBoldItalic?: string;
3832
+ embedRegular?: EmbeddedFontRef;
3833
+ embedBold?: EmbeddedFontRef;
3834
+ embedItalic?: EmbeddedFontRef;
3835
+ embedBoldItalic?: EmbeddedFontRef;
3836
+ /** Children of `w:font` the model does not hold, in source position. */
3837
+ preserved?: PreservedMarkup;
3838
+ /** Attributes of `w:font` the model has no field for. */
3839
+ preservedAttributes?: PreservedAttribute[];
2520
3840
  };
2521
3841
  /**
2522
3842
  * Font table from fontTable.xml
2523
3843
  */
2524
3844
  type FontTable = {
2525
3845
  fonts: FontInfo[];
3846
+ /** Children of `w:fonts` that are not `w:font`, in source position. */
3847
+ preserved?: PreservedMarkup;
3848
+ /**
3849
+ * Attributes of `w:fonts` the model has no field for.
3850
+ *
3851
+ * Not the namespace declarations and not `mc:Ignorable`: a rebuilt part
3852
+ * binds the prefixes its own body uses and states which of them are
3853
+ * ignorable, so replaying the source's would name prefixes nothing binds.
3854
+ */
3855
+ preservedAttributes?: PreservedAttribute[];
2526
3856
  };
2527
3857
  /**
2528
3858
  * Relationship type
@@ -2718,4 +4048,4 @@ type Document = {
2718
4048
  parseWarnings?: ParseWarning[];
2719
4049
  };
2720
4050
  //#endregion
2721
- export { FieldType as $, TableRowFormatting as $n, SectionStart as $t, BlockRangeMarkerCapture as A, ListLevel as An, NoBreakHyphenContent as At, CommentReference as B, LineSpacingRule as Bn, PictureWatermark as Bt, ParseWarning as C, TrackedRunContent as Cn, MoveBookmarkMarker as Ct, BidiControl as D, normalizeRevisionId as Dn, MoveTo as Dt, BIDI_CONTROLS as E, isOoxmlSymbolCharacter as En, MoveFromRangeStart as Et, BreakContent as F, NumberingInstance as Fn, Paragraph as Ft, DocumentBody as G, TabStop as Gn, Run as Gt, DRAWING_RAW_XML_MODES as H, ParagraphFormatting as Hn, PropertyChangeInfo as Ht, Column as I, CellMargins as In, ParagraphContent as It, Endnote as J, TableCellBorders as Jn, SdtProperties as Jt, DrawingContent as K, TabStopAlignment as Kn, RunContent as Kt, Comment as L, ConditionalFormatStyle as Ln, ParagraphMarkChange as Lt, BookmarkEnd as M, ListRendering as Mn, NoteReferenceContent as Mt, BookmarkRangeMarker as N, NumberFormat as Nn, PARAGRAPH_MARK_CHANGE_KINDS as Nt, BidiWrapper as O, AbstractNumbering as On, MoveToRangeEnd as Ot, BookmarkStart as P, NumberingDefinitions as Pn, PageOrientation as Pt, FieldCharContent as Q, TableMeasurement as Qn, SectionPropertyChange as Qt, CommentRangeEnd as R, EmphasisMark as Rn, ParagraphMarkChangeKind as Rt, PARSE_WARNING_CODES as S, TrackedRunChange as Sn, MathEquation as St, ParseWarningLocation as T, Watermark as Tn, MoveFromRangeEnd as Tt, Deletion as U, SpacingExplicit as Un, REVIEW_CARRIERS as Ut, ComplexField as V, ParagraphAlignment as Vn, PositionalTab as Vt, DisplacedByCustomXml as W, TabLeader as Wn, ReviewCarrier as Wt, EndnoteProperties as X, TableFormatting as Xn, Section as Xt, EndnotePosition as Y, TableCellFormatting as Yn, SdtType as Yt, Field as Z, TableLook as Zn, SectionProperties as Zt, Theme as _, TableStructuralChangeInfo as _n, Insertion as _t, DocxPackage as a, ShapeTextBody as an, ColorValue as ar, HeaderFooterType as at, ThemeFontScheme as b, TextWatermark as bn, MAX_REVISION_ID as bt, FontInfo as c, SoftHyphenContent as cn, ThemeColorSlot as cr, Image as ct, Relationship as d, Table as dn, ImagePadding as dt, Shape as en, TableWidthType as er, FooterReference as et, RelationshipMap as f, TableCell as fn, ImagePosition as ft, StyleType as g, TableRowPropertyChange as gn, InlineSdt as gt, StyleDefinitions as h, TableRow as hn, ImageWrap as ht, DocxConformanceClass as i, ShapeOutline as in, BorderSpec as ir, HeaderFooter as it, BlockSdt as j, ListMarkerFormatting as jn, NoteNumberRestart as jt, BlockContent as k, LevelSuffix as kn, MoveToRangeStart as kt, FontTable as l, SymbolContent as ln, ImageCrop as lt, Style as m, TablePropertyChange as mn, ImageTransform as mt, Document as n, ShapeFill as nn, TextFormatting as nr, FootnotePosition as nt, ExhaustiveFields as o, ShapeType as on, KnownBorderStyle as or, HeaderReference as ot, RelationshipType as p, TableCellPropertyChange as pn, ImageSize as pt, DrawingRawXmlMode as q, TableBorders as qn, RunPropertyChange as qt, DocumentSettings as r, ShapeGeometryAdjustment as rn, UnderlineStyle as rr, FootnoteProperties as rt, DocDefaults as s, SimpleField as sn, ShadingProperties as sr, Hyperlink as st, DOCX_CONFORMANCE_CLASSES as t, ShapeContent as tn, TextEffect as tr, Footnote as tt, MediaFile as u, TabContent as un, ImageFrameLocks as ut, ThemeColorScheme as v, TextBox as vn, InstrTextContent as vt, ParseWarningCode as w, VerticalAlign as wn, MoveFrom as wt, MAX_RETAINED_PARSE_WARNINGS_PER_CODE as x, TrackedChangeInfo as xn, MarkupRangeMarker as xt, ThemeFont as y, TextContent as yn, LineNumberRestart as yt, CommentRangeStart as z, FloatingTableProperties as zn, ParagraphPropertyChange as zt };
4051
+ export { Field as $, PRESET_LINE_DASH_VALS as $n, sameEffectiveParagraphNumbering as $r, PropertyChange as $t, BlockContent as A, knownThemeColor as Ai, TablePropertyChange as An, TableGridChange as Ar, MoveFromRangeEnd as At, CommentReference as B, borderStyleFrom as Bi, TrackedRunContent as Bn, NO_PARAGRAPH_NUMBERING as Br, PROPERTY_REVISION_KINDS as Bt, MAX_RETAINED_PARSE_WARNINGS_PER_CODE as C, ShadingProperties as Ci, SymbolContent as Cn, SpacingExplicit as Cr, InstrTextContent as Ct, ParseWarningLocation as D, UnrecognisedThemeColor as Di, TableCellBlock as Dn, TableCellBorders as Dr, MathEquation as Dt, ParseWarningCode as E, ThemeColorValue as Ei, TableCell as En, TableBorders as Er, MarkupRangeMarker as Et, BreakContent as F, SchemeColorValue as Fi, TextBox as Fn, TableWidthType as Fr, NoBreakHyphenContent as Ft, DocumentBody as G, statesNoBorder as Gi, WrapPolygonPoint as Gn, isNumberingReference as Gr, ParagraphMarkChangeKind as Gt, DRAWING_RAW_XML_MODES as H, isBorderNil as Hi, Watermark as Hn, ParagraphNumberingReference as Hr, Paragraph as Ht, Column as I, THEME_COLORS as Ii, TextContent as In, TextEffect as Ir, NonVisualDrawingNames as It, DrawingRawXmlMode as J, PresetLineDashValue as Jn, paragraphNumberingLevel as Jr, PositionalTab as Jt, DrawingAnchor as K, BORDER_STYLES as Ki, isOoxmlSymbolCharacter as Kn, mergeParagraphNumbering as Kr, ParagraphPropertyChange as Kt, Comment as L, ThemeColor as Li, TextWatermark as Ln, TextFormatting as Lr, NoteNumberRestart as Lt, BookmarkEnd as M, themeColorSlot as Mi, TableRow as Mn, TableMeasurement as Mr, MoveTo as Mt, BookmarkRangeMarker as N, themeColorToken as Ni, TableRowPropertyChange as Nn, TablePropertyExceptionFormatting as Nr, MoveToRangeEnd as Nt, BIDI_CONTROLS as O, isSchemeColorValue as Oi, TableCellPropertyChange as On, TableCellFormatting as Or, MoveBookmarkMarker as Ot, BookmarkStart as P, SchemeColorSlot as Pi, TableStructuralChangeInfo as Pn, TableRowFormatting as Pr, MoveToRangeStart as Pt, EndnoteProperties as Q, presetLineDashToken as Qn, resolveParagraphNumbering as Qr, PreservedXmlContent as Qt, CommentRangeEnd as R, BorderStyleValue as Ri, TrackedChangeInfo as Rn, UnderlineStyle as Rr, NoteReferenceContent as Rt, ThemeFontScheme as S, ColorValue as Si, SoftHyphenContent as Sn, ParagraphFormatting as Sr, Insertion as St, ParseWarning as T, THEME_COLOR_BY_SCHEME_COLOR_VALUE as Ti, Table as Tn, TabStop as Tr, MAX_REVISION_ID as Tt, Deletion as U, isBorderNone as Ui, WrapDistanceSlots as Un, ParagraphNumberingSlots as Ur, ParagraphContent as Ut, ComplexField as V, borderStyleToken as Vi, VerticalAlign as Vn, ParagraphNumberingOverride as Vr, PageOrientation as Vt, DisplacedByCustomXml as W, isBorderStyle as Wi, WrapDistances as Wn, ResolvedParagraphNumbering as Wr, ParagraphMarkChange as Wt, Endnote as X, isPresetLineDashVal as Xn, paragraphNumberingReferenceId as Xr, PreservedBlock as Xt, EffectExtentSlots as Y, UnrecognisedPresetLineDash as Yn, paragraphNumberingReference as Yr, PositionedBookmarkMarker as Yt, EndnotePosition as Z, presetLineDashFrom as Zn, paragraphNumberingSlots as Zr, PreservedInline as Zt, StyleDefinitions as _, TabStopAlignment as _i, ShapeGeometryAdjustment as _n, CellMargins as _r, ImageTransform as _t, DocxPackage as a, headingOutlineLevel as ai, RunContent as an, PreviewShape as ar, FootnoteProperties as at, ThemeColorScheme as b, TextDirectionFlow as bi, ShapeType as bn, FloatingTableProperties as br, InlineSdt as bt, EmbeddedFontRef as c, NUMBER_FORMATS as ci, SdtProperties as cn, CounterFormat as cr, HeaderReference as ct, FontTable as d, ParagraphAlignment as di, SectionProperties as dn, LevelSuffix as dr, ImageCrop as dt, sameStatedParagraphNumbering as ei, PropertyChangeInfo as en, PresetLineDashVal as er, FieldCharContent as et, MediaFile as f, TABLE_ALIGNMENTS as fi, SectionPropertyChange as fn, ListLevel as fr, ImageDocPrLink as ft, Style as g, TEXT_DIRECTION_FLOW_BY_TOKEN as gi, ShapeFill as gn, NumberingInstance as gr, ImageSize as gt, RelationshipType as h, TEXT_DIRECTION_FLOWS as hi, ShapeContent as hn, NumberingDefinitions as hr, ImagePosition as ht, DocxConformanceClass as i, headingLevelOf as ii, Run as in, PreviewDescriptor as ir, FootnotePosition as it, BlockSdt as j, readThemeColor as ji, TablePropertyExceptionChange as jn, TableLook as jr, MoveFromRangeStart as jt, BidiControl as k, isThemeColor as ki, TablePreservedMarkup as kn, TableFormatting as kr, MoveFrom as kt, FontCharset as l, NumberFormat as li, SdtType as ln, LevelLegacy as lr, Hyperlink as lt, RelationshipMap as m, TEXT_DIRECTIONS as mi, Shape as mn, ListRendering as mr, ImagePadding as mt, Document as n, HeadingOutlineLevel as ni, REVIEW_CARRIERS as nn, mintRelationshipId as nr, FooterReference as nt, ExhaustiveFields as o, outlineLevelFromStatedValue as oi, RunPropertyChange as on, AbstractNumbering as or, HeaderFooter as ot, Relationship as p, TAB_STOP_ALIGNMENTS as pi, SectionStart as pn, ListMarkerFormatting as pr, ImageFrameLocks as pt, DrawingContent as q, BorderStyle as qi, normalizeRevisionId as qn, paragraphNumberingFromSlots as qr, PictureWatermark as qt, DocumentSettings as r, OutlineLevel as ri, ReviewCarrier as rn, relationshipIdOf as rr, Footnote as rt, DocDefaults as s, outlineLevelStatedValue as si, SdtEndProperties as sn, COUNTER_FORMATS as sr, HeaderFooterType as st, DOCX_CONFORMANCE_CLASSES as t, BODY_TEXT_OUTLINE_LEVEL as ti, PropertyRevisionKind as tn, RelationshipId as tr, FieldType as tt, FontInfo as u, PARAGRAPH_ALIGNMENTS as ui, Section as un, LevelOverride as ur, Image as ut, StyleType as v, TableAlignment as vi, ShapeOutline as vn, ConditionalFormatStyle as vr, ImageWrap as vt, PARSE_WARNING_CODES as w, SCHEME_COLOR_VALUE_BY_THEME_COLOR as wi, TabContent as wn, TabLeader as wr, LineNumberRestart as wt, ThemeFont as x, BorderSpec as xi, SimpleField as xn, LineSpacingRule as xr, InlineWrapper as xt, Theme as y, TextDirection as yi, ShapeTextBody as yn, EmphasisMark as yr, ImageWrapPolygon as yt, CommentRangeStart as z, UnrecognisedBorderStyle as zi, TrackedRunChange as zn, NO_NUMBERING_NUM_ID as zr, PARAGRAPH_MARK_CHANGE_KINDS as zt };