@json-to-office/core-docx 0.38.0 → 1.0.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.
Files changed (163) hide show
  1. package/dist/components/highcharts.d.ts +16 -6
  2. package/dist/components/highcharts.d.ts.map +1 -1
  3. package/dist/components/index.d.ts +8 -14
  4. package/dist/components/index.d.ts.map +1 -1
  5. package/dist/components/visual.d.ts +60 -18
  6. package/dist/components/visual.d.ts.map +1 -1
  7. package/dist/core/collectTocHeadings.d.ts +15 -1
  8. package/dist/core/collectTocHeadings.d.ts.map +1 -1
  9. package/dist/core/componentTransform.d.ts +30 -0
  10. package/dist/core/componentTransform.d.ts.map +1 -0
  11. package/dist/core/desugarExternals.d.ts +35 -0
  12. package/dist/core/desugarExternals.d.ts.map +1 -0
  13. package/dist/core/flattenVisuals.d.ts.map +1 -1
  14. package/dist/core/generateFromIr.d.ts +78 -0
  15. package/dist/core/generateFromIr.d.ts.map +1 -0
  16. package/dist/core/generationContext.d.ts +2 -2
  17. package/dist/core/generationContext.d.ts.map +1 -1
  18. package/dist/core/generator.d.ts +48 -39
  19. package/dist/core/generator.d.ts.map +1 -1
  20. package/dist/core/imageResources.d.ts +35 -0
  21. package/dist/core/imageResources.d.ts.map +1 -0
  22. package/dist/core/index.d.ts +4 -5
  23. package/dist/core/index.d.ts.map +1 -1
  24. package/dist/core/layout.d.ts +15 -3
  25. package/dist/core/layout.d.ts.map +1 -1
  26. package/dist/core/markdownList.d.ts +21 -0
  27. package/dist/core/markdownList.d.ts.map +1 -0
  28. package/dist/core/prerasterizeVisuals.d.ts +2 -3
  29. package/dist/core/prerasterizeVisuals.d.ts.map +1 -1
  30. package/dist/core/sectionBookmarks.d.ts +15 -40
  31. package/dist/core/sectionBookmarks.d.ts.map +1 -1
  32. package/dist/core/tableModel.d.ts +188 -0
  33. package/dist/core/tableModel.d.ts.map +1 -0
  34. package/dist/core/tocField.d.ts +70 -0
  35. package/dist/core/tocField.d.ts.map +1 -0
  36. package/dist/index.d.ts +7 -6
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +8060 -7269
  39. package/dist/index.js.map +1 -1
  40. package/dist/ir/compiler.d.ts +49 -0
  41. package/dist/ir/compiler.d.ts.map +1 -0
  42. package/dist/ir/debug.d.ts +15 -0
  43. package/dist/ir/debug.d.ts.map +1 -0
  44. package/dist/ir/features.d.ts +19 -0
  45. package/dist/ir/features.d.ts.map +1 -0
  46. package/dist/ir/index.d.ts +16 -0
  47. package/dist/ir/index.d.ts.map +1 -0
  48. package/dist/ir/inline.d.ts +126 -0
  49. package/dist/ir/inline.d.ts.map +1 -0
  50. package/dist/ir/types.d.ts +774 -0
  51. package/dist/ir/types.d.ts.map +1 -0
  52. package/dist/ir/units.d.ts +57 -0
  53. package/dist/ir/units.d.ts.map +1 -0
  54. package/dist/ir/validation.d.ts +19 -0
  55. package/dist/ir/validation.d.ts.map +1 -0
  56. package/dist/plugin/createDocumentGenerator.d.ts +10 -3
  57. package/dist/plugin/createDocumentGenerator.d.ts.map +1 -1
  58. package/dist/plugin/example/index.d.ts.map +1 -1
  59. package/dist/plugin/example/index.js +8083 -7149
  60. package/dist/plugin/example/index.js.map +1 -1
  61. package/dist/plugin/index.d.ts +1 -1
  62. package/dist/plugin/index.d.ts.map +1 -1
  63. package/dist/plugin/schema.d.ts.map +1 -1
  64. package/dist/plugin/types.d.ts +13 -26
  65. package/dist/plugin/types.d.ts.map +1 -1
  66. package/dist/renderers/docxjs/emit.d.ts +41 -0
  67. package/dist/renderers/docxjs/emit.d.ts.map +1 -0
  68. package/dist/renderers/docxjs/index.d.ts +22 -0
  69. package/dist/renderers/docxjs/index.d.ts.map +1 -0
  70. package/dist/renderers/docxjs/styles.d.ts +12 -0
  71. package/dist/renderers/docxjs/styles.d.ts.map +1 -0
  72. package/dist/renderers/office-open/emit.d.ts +63 -0
  73. package/dist/renderers/office-open/emit.d.ts.map +1 -0
  74. package/dist/renderers/office-open/index.d.ts +25 -0
  75. package/dist/renderers/office-open/index.d.ts.map +1 -0
  76. package/dist/renderers/office-open/styles.d.ts +13 -0
  77. package/dist/renderers/office-open/styles.d.ts.map +1 -0
  78. package/dist/renderers/registry.d.ts +15 -0
  79. package/dist/renderers/registry.d.ts.map +1 -0
  80. package/dist/renderers/types.d.ts +35 -0
  81. package/dist/renderers/types.d.ts.map +1 -0
  82. package/dist/styles/themeToStyles.d.ts +12 -0
  83. package/dist/styles/themeToStyles.d.ts.map +1 -0
  84. package/dist/styles/utils/borderUtils.d.ts +13 -6
  85. package/dist/styles/utils/borderUtils.d.ts.map +1 -1
  86. package/dist/styles/utils/layoutUtils.d.ts +10 -14
  87. package/dist/styles/utils/layoutUtils.d.ts.map +1 -1
  88. package/dist/styles/utils/styleHelpers.d.ts +6 -2
  89. package/dist/styles/utils/styleHelpers.d.ts.map +1 -1
  90. package/dist/themes/overrides.d.ts +0 -2
  91. package/dist/themes/overrides.d.ts.map +1 -1
  92. package/dist/tsconfig.tsbuildinfo +1 -1
  93. package/dist/types/index.d.ts +18 -4
  94. package/dist/types/index.d.ts.map +1 -1
  95. package/dist/utils/bookmarkRegistry.d.ts +13 -77
  96. package/dist/utils/bookmarkRegistry.d.ts.map +1 -1
  97. package/dist/utils/commentRegistry.d.ts +5 -43
  98. package/dist/utils/commentRegistry.d.ts.map +1 -1
  99. package/dist/utils/exampleRunner.d.ts.map +1 -1
  100. package/dist/utils/imageUtils.d.ts +23 -19
  101. package/dist/utils/imageUtils.d.ts.map +1 -1
  102. package/dist/utils/numberingConfig.d.ts +7 -87
  103. package/dist/utils/numberingConfig.d.ts.map +1 -1
  104. package/dist/utils/packageDocument.d.ts +0 -3
  105. package/dist/utils/packageDocument.d.ts.map +1 -1
  106. package/dist/utils/revisionUtils.d.ts +6 -67
  107. package/dist/utils/revisionUtils.d.ts.map +1 -1
  108. package/dist/utils/warningsDocument.d.ts.map +1 -1
  109. package/package.json +12 -4
  110. package/dist/cache/index.d.ts +0 -7
  111. package/dist/cache/index.d.ts.map +0 -1
  112. package/dist/cache/key-generator.d.ts +0 -34
  113. package/dist/cache/key-generator.d.ts.map +0 -1
  114. package/dist/components/columns.d.ts +0 -12
  115. package/dist/components/columns.d.ts.map +0 -1
  116. package/dist/components/heading.d.ts +0 -12
  117. package/dist/components/heading.d.ts.map +0 -1
  118. package/dist/components/image.d.ts +0 -12
  119. package/dist/components/image.d.ts.map +0 -1
  120. package/dist/components/list.d.ts +0 -12
  121. package/dist/components/list.d.ts.map +0 -1
  122. package/dist/components/paragraph.d.ts +0 -12
  123. package/dist/components/paragraph.d.ts.map +0 -1
  124. package/dist/components/section.d.ts +0 -12
  125. package/dist/components/section.d.ts.map +0 -1
  126. package/dist/components/statistic.d.ts +0 -12
  127. package/dist/components/statistic.d.ts.map +0 -1
  128. package/dist/components/table.d.ts +0 -13
  129. package/dist/components/table.d.ts.map +0 -1
  130. package/dist/components/text-box.d.ts +0 -9
  131. package/dist/components/text-box.d.ts.map +0 -1
  132. package/dist/components/toc/index.d.ts +0 -30
  133. package/dist/components/toc/index.d.ts.map +0 -1
  134. package/dist/core/cached-render.d.ts +0 -92
  135. package/dist/core/cached-render.d.ts.map +0 -1
  136. package/dist/core/content.d.ts +0 -319
  137. package/dist/core/content.d.ts.map +0 -1
  138. package/dist/core/render.d.ts +0 -48
  139. package/dist/core/render.d.ts.map +0 -1
  140. package/dist/styles/themeToDocxAdapter.d.ts +0 -22
  141. package/dist/styles/themeToDocxAdapter.d.ts.map +0 -1
  142. package/dist/styles/utils/cellUtils.d.ts +0 -55
  143. package/dist/styles/utils/cellUtils.d.ts.map +0 -1
  144. package/dist/utils/alignmentUtils.d.ts +0 -10
  145. package/dist/utils/alignmentUtils.d.ts.map +0 -1
  146. package/dist/utils/commentAnchors.d.ts +0 -39
  147. package/dist/utils/commentAnchors.d.ts.map +0 -1
  148. package/dist/utils/componentAnnotations.d.ts +0 -23
  149. package/dist/utils/componentAnnotations.d.ts.map +0 -1
  150. package/dist/utils/docxImagePositioning.d.ts +0 -19
  151. package/dist/utils/docxImagePositioning.d.ts.map +0 -1
  152. package/dist/utils/noteRegistry.d.ts +0 -43
  153. package/dist/utils/noteRegistry.d.ts.map +0 -1
  154. package/dist/utils/noteResolver.d.ts +0 -31
  155. package/dist/utils/noteResolver.d.ts.map +0 -1
  156. package/dist/utils/numberedItemsRegistry.d.ts +0 -38
  157. package/dist/utils/numberedItemsRegistry.d.ts.map +0 -1
  158. package/dist/utils/placeholderImage.d.ts +0 -31
  159. package/dist/utils/placeholderImage.d.ts.map +0 -1
  160. package/dist/utils/placeholderProcessor.d.ts +0 -58
  161. package/dist/utils/placeholderProcessor.d.ts.map +0 -1
  162. package/dist/utils/textParser.d.ts +0 -117
  163. package/dist/utils/textParser.d.ts.map +0 -1
@@ -0,0 +1,774 @@
1
+ /**
2
+ * DocxIR — the renderer-neutral description of a finished Word document.
3
+ *
4
+ * Plain data only: no docx.js objects, no functions, no raw OOXML, no
5
+ * backend-specific shapes. A renderer adapter is the only thing that turns
6
+ * these nodes into a library call.
7
+ *
8
+ * By the time a document reaches this form, all of the following have happened
9
+ * upstream (see `docs/architecture/office-renderer-ir.md`):
10
+ *
11
+ * - schema validation and structural conflict checks
12
+ * - custom-component expansion
13
+ * - theme resolution — every colour here is an explicit hex value
14
+ * - component defaults
15
+ * - font resolution/substitution, including synthesized weight aliases
16
+ * - the inline text mini-language: `**bold**`, `[text](url)`, `[@ref]`,
17
+ * `[^note]`, `{PAGE}` and friends are already inline nodes, not markup
18
+ * - section and column layout resolution
19
+ * - authoring-only expansion: `statistic`, `visual` and `highcharts` are gone,
20
+ * replaced by the paragraphs and images they mean
21
+ *
22
+ * Units — stated in every property name, never implied:
23
+ *
24
+ * | Concern | Unit |
25
+ * | --- | --- |
26
+ * | page size, margins, indents, tab stops, spacing, table widths | twips (1/1440 in) |
27
+ * | font size | half-points |
28
+ * | drawing offsets and extents | EMU (1/914400 in) |
29
+ * | image intrinsic size | pixels |
30
+ * | border width | eighths of a point |
31
+ * | character tracking | twentieths of a point |
32
+ * | timestamps | ISO 8601 strings |
33
+ */
34
+ /** Twips per inch. */
35
+ export declare const TWIPS_PER_INCH = 1440;
36
+ /** Twips per point. */
37
+ export declare const TWIPS_PER_POINT = 20;
38
+ /** English Metric Units per inch. */
39
+ export declare const EMU_PER_INCH = 914400;
40
+ /** English Metric Units per twip. */
41
+ export declare const EMU_PER_TWIP: number;
42
+ export declare const DOCX_IR_SCHEMA_VERSION = 1;
43
+ export interface DocxIR {
44
+ schemaVersion: typeof DOCX_IR_SCHEMA_VERSION;
45
+ metadata: DocxIrMetadata;
46
+ settings: DocxIrSettings;
47
+ /** Resolved paragraph and character styles, in registration order. */
48
+ styles: DocxIrStyles;
49
+ /** Numbering definitions referenced by list paragraphs. */
50
+ numbering: DocxIrNumbering[];
51
+ /** Deduplicated binary assets, in first-use order. */
52
+ resources: DocxIrResource[];
53
+ sections: DocxIrSection[];
54
+ /** Comment bodies, referenced by id from comment range nodes. */
55
+ comments: DocxIrComment[];
56
+ footnotes: DocxIrNote[];
57
+ endnotes: DocxIrNote[];
58
+ }
59
+ export interface DocxIrMetadata {
60
+ title?: string;
61
+ subject?: string;
62
+ author?: string;
63
+ description?: string;
64
+ keywords?: string;
65
+ lastModifiedBy?: string;
66
+ /** ISO 8601. Pinned by deterministic generation. */
67
+ createdAt?: string;
68
+ modifiedAt?: string;
69
+ /** Custom document properties, in declaration order. */
70
+ custom?: DocxIrCustomProperty[];
71
+ }
72
+ export interface DocxIrCustomProperty {
73
+ name: string;
74
+ value: string;
75
+ }
76
+ export interface DocxIrSettings {
77
+ /** Default proofing language (BCP-47). */
78
+ language?: string;
79
+ /** Ask the reader to refresh fields on open. */
80
+ updateFields: boolean;
81
+ /** Turn on Word's track-changes mode in the produced document. */
82
+ trackRevisions: boolean;
83
+ /** Words the proofer should skip, applied as `w:noProof` on matching runs. */
84
+ noProofWords?: string[];
85
+ }
86
+ export interface DocxIrStyles {
87
+ /** Formatting every paragraph and run starts from — `w:docDefaults`. */
88
+ defaults: DocxIrStyleDefaults;
89
+ paragraph: DocxIrParagraphStyle[];
90
+ character: DocxIrCharacterStyle[];
91
+ /**
92
+ * Overrides for styles Word defines itself.
93
+ *
94
+ * A backend ships its own definitions for these, carrying Word's defaults
95
+ * rather than the document's theme — a note in a Georgia document would
96
+ * otherwise set in Calibri. Naming the slot rather than the style id keeps
97
+ * the two backends' built-in vocabularies from leaking into the IR.
98
+ */
99
+ builtIn?: DocxIrBuiltInStyles;
100
+ }
101
+ export interface DocxIrBuiltInStyle {
102
+ run?: DocxIrRunFormatting;
103
+ paragraph?: DocxIrParagraphFormatting;
104
+ }
105
+ export interface DocxIrBuiltInStyles {
106
+ footnoteText?: DocxIrBuiltInStyle;
107
+ footnoteReference?: DocxIrBuiltInStyle;
108
+ endnoteText?: DocxIrBuiltInStyle;
109
+ endnoteReference?: DocxIrBuiltInStyle;
110
+ }
111
+ export interface DocxIrStyleDefaults {
112
+ run: DocxIrRunFormatting;
113
+ paragraph: DocxIrParagraphFormatting;
114
+ }
115
+ export interface DocxIrParagraphStyle {
116
+ /** Style id as referenced by `DocxIrParagraph.styleId`. */
117
+ id: string;
118
+ /** Display name, which is what a TOC `\t` switch matches on. */
119
+ name: string;
120
+ basedOn?: string;
121
+ next?: string;
122
+ /** 0-8; present only when the style participates in the outline. */
123
+ outlineLevel?: number;
124
+ quickFormat?: boolean;
125
+ run?: DocxIrRunFormatting;
126
+ paragraph?: DocxIrParagraphFormatting;
127
+ }
128
+ export interface DocxIrCharacterStyle {
129
+ id: string;
130
+ name: string;
131
+ basedOn?: string;
132
+ run: DocxIrRunFormatting;
133
+ }
134
+ export interface DocxIrNumbering {
135
+ /** Reference name used by `DocxIrParagraph.numbering.reference`. */
136
+ reference: string;
137
+ levels: DocxIrNumberingLevel[];
138
+ }
139
+ export interface DocxIrNumberingLevel {
140
+ /** 0-based. */
141
+ level: number;
142
+ /** OOXML `numFmt`, e.g. `decimal`, `bullet`, `lowerRoman`. */
143
+ format: string;
144
+ /** OOXML `lvlText`, e.g. `%1.` or `•`. */
145
+ text: string;
146
+ start?: number;
147
+ alignment?: DocxIrAlignment;
148
+ /** What follows the marker before the text. */
149
+ suffix?: 'tab' | 'space' | 'nothing';
150
+ indent?: DocxIrIndent;
151
+ /** Formatting of the marker glyph itself. */
152
+ run?: DocxIrRunFormatting;
153
+ /** Bind this level to a paragraph style, so Word's numbering UI follows. */
154
+ paragraphStyleId?: string;
155
+ }
156
+ /**
157
+ * A binary asset.
158
+ *
159
+ * Images are held as bytes because a DOCX embeds them by value; the identity
160
+ * used for deduplication and for debug snapshots is the content hash.
161
+ */
162
+ export interface DocxIrResource {
163
+ /** Deterministic: `res${n}` in first-use order. */
164
+ id: string;
165
+ kind: 'image';
166
+ mediaType: string;
167
+ bytes: Uint8Array;
168
+ byteLength: number;
169
+ /** Lowercase hex SHA-256 of `bytes`. */
170
+ sha256: string;
171
+ intrinsic?: DocxIrPixelSize;
172
+ /**
173
+ * Raster fallback for a vector image.
174
+ *
175
+ * Word before 2016 draws the fallback rather than the SVG, so a vector
176
+ * resource carries one. It is a resource in its own right, referenced here.
177
+ */
178
+ fallbackResourceId?: string;
179
+ }
180
+ export interface DocxIrPixelSize {
181
+ widthPx: number;
182
+ heightPx: number;
183
+ }
184
+ export type DocxIrAlignment = 'left' | 'center' | 'right' | 'justified' | 'start' | 'end';
185
+ export type DocxIrVerticalAlign = 'top' | 'center' | 'bottom';
186
+ /**
187
+ * A resolved colour: bare 6-digit hex without `#`, never a theme token.
188
+ *
189
+ * Case is preserved rather than normalised. OOXML reads hex case-insensitively,
190
+ * so normalising would change nothing a reader can see while changing the bytes
191
+ * of every document that ever stated a colour in lower case.
192
+ */
193
+ export interface DocxIrColor {
194
+ hex: string;
195
+ }
196
+ export interface DocxIrIndent {
197
+ leftTwips?: number;
198
+ rightTwips?: number;
199
+ firstLineTwips?: number;
200
+ hangingTwips?: number;
201
+ }
202
+ export interface DocxIrSpacing {
203
+ beforeTwips?: number;
204
+ afterTwips?: number;
205
+ /** Line height in twips, with `lineRule` deciding how it is applied. */
206
+ lineTwips?: number;
207
+ lineRule?: 'auto' | 'exact' | 'atLeast';
208
+ }
209
+ export interface DocxIrTabStop {
210
+ positionTwips: number;
211
+ type: 'left' | 'center' | 'right' | 'decimal' | 'bar' | 'clear';
212
+ leader?: 'none' | 'dot' | 'hyphen' | 'underscore' | 'middleDot';
213
+ }
214
+ export interface DocxIrBorder {
215
+ style: string;
216
+ color?: DocxIrColor;
217
+ /** Eighths of a point, which is the OOXML unit for `w:sz` on a border. */
218
+ sizeEighthPoints?: number;
219
+ /** Points, which is the OOXML unit for `w:space` on a border. */
220
+ spacePoints?: number;
221
+ }
222
+ export interface DocxIrBorders {
223
+ top?: DocxIrBorder;
224
+ bottom?: DocxIrBorder;
225
+ left?: DocxIrBorder;
226
+ right?: DocxIrBorder;
227
+ insideHorizontal?: DocxIrBorder;
228
+ insideVertical?: DocxIrBorder;
229
+ /** `w:between` — the rule drawn between consecutive paragraphs sharing it. */
230
+ between?: DocxIrBorder;
231
+ }
232
+ export interface DocxIrShading {
233
+ fill: DocxIrColor;
234
+ pattern?: string;
235
+ color?: DocxIrColor;
236
+ }
237
+ export interface DocxIrRunFormatting {
238
+ /** Post-substitution family, possibly a synthesized weight alias. */
239
+ fontFamily?: string;
240
+ /** Half-points. */
241
+ sizeHalfPoints?: number;
242
+ color?: DocxIrColor;
243
+ bold?: boolean;
244
+ italic?: boolean;
245
+ underline?: DocxIrUnderline;
246
+ strike?: boolean;
247
+ doubleStrike?: boolean;
248
+ superScript?: boolean;
249
+ subScript?: boolean;
250
+ smallCaps?: boolean;
251
+ allCaps?: boolean;
252
+ highlight?: string;
253
+ shading?: DocxIrShading;
254
+ /** Horizontal scale, percent. */
255
+ scalePercent?: number;
256
+ /** Tracking, in twentieths of a point; negative condenses. */
257
+ characterSpacingTwentieths?: number;
258
+ /** BCP-47. */
259
+ language?: string;
260
+ /** Exclude from proofing. */
261
+ noProof?: boolean;
262
+ }
263
+ export interface DocxIrUnderline {
264
+ type: string;
265
+ color?: DocxIrColor;
266
+ }
267
+ export interface DocxIrParagraphFormatting {
268
+ alignment?: DocxIrAlignment;
269
+ spacing?: DocxIrSpacing;
270
+ indent?: DocxIrIndent;
271
+ tabStops?: DocxIrTabStop[];
272
+ keepNext?: boolean;
273
+ keepLines?: boolean;
274
+ pageBreakBefore?: boolean;
275
+ widowControl?: boolean;
276
+ borders?: DocxIrBorders;
277
+ shading?: DocxIrShading;
278
+ /** 0-8. Set explicitly when a paragraph should join the outline. */
279
+ outlineLevel?: number;
280
+ bidirectional?: boolean;
281
+ }
282
+ export type DocxIrInline = DocxIrTextRun | DocxIrLineBreak | DocxIrPageBreakRun | DocxIrColumnBreakRun | DocxIrTabRun | DocxIrImageRun | DocxIrHyperlink | DocxIrBookmarkStart | DocxIrBookmarkEnd | DocxIrFieldRun | DocxIrNoteReference | DocxIrCommentRangeStart | DocxIrCommentRangeEnd | DocxIrCommentReference | DocxIrRevisionRange | DocxIrShapeRun;
283
+ /**
284
+ * A native text box: a shape holding paragraphs.
285
+ *
286
+ * Distinct from the one-cell table a text box usually becomes. A shape carries
287
+ * an absolute size in the file, so it has no autofit and no lazy percentage
288
+ * width, and it draws one uniform outline rather than four sides — which is why
289
+ * a text box only becomes one when the author asks.
290
+ */
291
+ export interface DocxIrShapeRun {
292
+ kind: 'shape';
293
+ widthPx: number;
294
+ heightPx: number;
295
+ children: DocxIrParagraph[];
296
+ fill?: DocxIrColor;
297
+ outline?: {
298
+ color: DocxIrColor;
299
+ widthEmu?: number;
300
+ };
301
+ /** Text insets, in EMU like every other DrawingML length. */
302
+ insetsEmu?: {
303
+ top?: number;
304
+ bottom?: number;
305
+ left?: number;
306
+ right?: number;
307
+ };
308
+ /** Absent makes it an inline drawing rather than an anchored one. */
309
+ floating?: DocxIrFloating;
310
+ }
311
+ export interface DocxIrTextRun {
312
+ kind: 'text';
313
+ text: string;
314
+ formatting?: DocxIrRunFormatting;
315
+ /** Character style applied on top of `formatting`. */
316
+ styleId?: string;
317
+ }
318
+ export interface DocxIrLineBreak {
319
+ kind: 'lineBreak';
320
+ /** `textWrapping` is a plain newline; the others clear a floating object. */
321
+ clear?: 'none' | 'left' | 'right' | 'all';
322
+ }
323
+ export interface DocxIrPageBreakRun {
324
+ kind: 'pageBreak';
325
+ }
326
+ export interface DocxIrColumnBreakRun {
327
+ kind: 'columnBreak';
328
+ }
329
+ /**
330
+ * A tab, as its own run.
331
+ *
332
+ * A tab character inside `<w:t>` is dropped by Word and paragraph tab stops
333
+ * only bind to real tab runs — and the run carries formatting like any other,
334
+ * because the space it advances through is drawn in that font.
335
+ */
336
+ export interface DocxIrTabRun {
337
+ kind: 'tab';
338
+ formatting?: DocxIrRunFormatting;
339
+ }
340
+ /**
341
+ * An image placed inline in a paragraph.
342
+ *
343
+ * Floating placement lives on the paragraph, not here: OOXML anchors a floating
344
+ * drawing to a paragraph, and modelling it on the run would misdescribe that.
345
+ */
346
+ export interface DocxIrImageRun {
347
+ kind: 'image';
348
+ resourceId: string;
349
+ widthEmu: number;
350
+ heightEmu: number;
351
+ altText?: string;
352
+ /** Present when the drawing is anchored rather than inline. */
353
+ floating?: DocxIrFloating;
354
+ }
355
+ export interface DocxIrHyperlink {
356
+ kind: 'hyperlink';
357
+ target: DocxIrHyperlinkTarget;
358
+ children: DocxIrInline[];
359
+ }
360
+ export type DocxIrHyperlinkTarget = {
361
+ kind: 'external';
362
+ url: string;
363
+ } | {
364
+ kind: 'bookmark';
365
+ anchor: string;
366
+ };
367
+ /**
368
+ * Bookmark boundaries.
369
+ *
370
+ * Emitted as explicit paired nodes with compiler-allocated ids rather than a
371
+ * wrapper, because a bookmark range can legitimately cross paragraph and even
372
+ * table boundaries.
373
+ */
374
+ export interface DocxIrBookmarkStart {
375
+ kind: 'bookmarkStart';
376
+ id: number;
377
+ name: string;
378
+ }
379
+ export interface DocxIrBookmarkEnd {
380
+ kind: 'bookmarkEnd';
381
+ id: number;
382
+ }
383
+ /**
384
+ * A Word field.
385
+ *
386
+ * `cachedText` is what a reader shows before it refreshes the field — headless
387
+ * converters never refresh, so caching is the difference between a rendered
388
+ * value and a blank.
389
+ */
390
+ export interface DocxIrFieldRun {
391
+ kind: 'field';
392
+ /** Field instruction, e.g. `PAGE`, `NUMPAGES`, `REF _Ref123 \\r \\h`. */
393
+ instruction: string;
394
+ cachedText?: string;
395
+ formatting?: DocxIrRunFormatting;
396
+ }
397
+ export interface DocxIrNoteReference {
398
+ kind: 'noteReference';
399
+ noteKind: 'footnote' | 'endnote';
400
+ /** Matches an entry in `DocxIR.footnotes` / `DocxIR.endnotes`. */
401
+ id: number;
402
+ }
403
+ export interface DocxIrCommentRangeStart {
404
+ kind: 'commentRangeStart';
405
+ id: number;
406
+ }
407
+ export interface DocxIrCommentRangeEnd {
408
+ kind: 'commentRangeEnd';
409
+ id: number;
410
+ }
411
+ export interface DocxIrCommentReference {
412
+ kind: 'commentReference';
413
+ id: number;
414
+ }
415
+ /**
416
+ * Inserted or deleted content.
417
+ *
418
+ * A range rather than a run flag, because a revision covers a span and its
419
+ * `id`/`author`/`date` belong to the span, not to each run inside it.
420
+ */
421
+ export interface DocxIrRevisionRange {
422
+ kind: 'revision';
423
+ type: 'insert' | 'delete';
424
+ id: number;
425
+ author: string;
426
+ /** ISO 8601. */
427
+ date: string;
428
+ children: DocxIrInline[];
429
+ }
430
+ export interface DocxIrFloating {
431
+ /**
432
+ * Where the drawing sits on each axis.
433
+ *
434
+ * Both are optional because an author may float an image purely to change
435
+ * how text wraps around it, stating no position at all; the anchor then
436
+ * keeps whatever position its container gives it.
437
+ */
438
+ horizontal?: DocxIrFloatingPosition;
439
+ vertical?: DocxIrFloatingPosition;
440
+ /** Distance kept clear of surrounding text, in EMU. */
441
+ margins?: DocxIrFloatingMargins;
442
+ wrap?: DocxIrTextWrap;
443
+ /** Always emitted: some backends otherwise derive it from the height. */
444
+ zIndex: number;
445
+ behindDocument?: boolean;
446
+ allowOverlap?: boolean;
447
+ /** Keep the anchor with the paragraph it is attached to. */
448
+ lockAnchor?: boolean;
449
+ /** Position the drawing inside its table cell rather than the page. */
450
+ layoutInCell?: boolean;
451
+ }
452
+ export interface DocxIrFloatingPosition {
453
+ /**
454
+ * OOXML's `relativeFrom`. Absent when the author named a frame of reference
455
+ * OOXML has no element for, in which case the backend's own default applies.
456
+ */
457
+ relativeTo?: string;
458
+ /** Offset in EMU. Mutually exclusive with `align`. */
459
+ offsetEmu?: number;
460
+ align?: string;
461
+ }
462
+ export interface DocxIrFloatingMargins {
463
+ topEmu?: number;
464
+ bottomEmu?: number;
465
+ leftEmu?: number;
466
+ rightEmu?: number;
467
+ }
468
+ export interface DocxIrTextWrap {
469
+ /**
470
+ * OOXML's own vocabulary.
471
+ *
472
+ * `tight` is reachable only from the authoring values `around` and `through`,
473
+ * which have no OOXML equivalent of their own; asking for `tight` directly is
474
+ * rejected at compile time because it needs polygon geometry no backend here
475
+ * emits.
476
+ */
477
+ type: 'none' | 'square' | 'tight' | 'topAndBottom';
478
+ side?: 'bothSides' | 'left' | 'right' | 'largest';
479
+ }
480
+ export type DocxIrBlock = DocxIrParagraph | DocxIrTable | DocxIrTableOfContents;
481
+ export interface DocxIrParagraph {
482
+ kind: 'paragraph';
483
+ /** Deterministic, path-derived: e.g. `s0.b3`, `s0.b3.r1.c0.b0`. */
484
+ id: string;
485
+ /** IR path for diagnostics: e.g. `sections[0].children[3]`. */
486
+ path: string;
487
+ children: DocxIrInline[];
488
+ styleId?: string;
489
+ formatting?: DocxIrParagraphFormatting;
490
+ numbering?: DocxIrParagraphNumbering;
491
+ /** Revision applied to the paragraph mark itself. */
492
+ markRevision?: DocxIrParagraphMarkRevision;
493
+ /** Anchor for a floating drawing carried by this paragraph's runs. */
494
+ frame?: DocxIrFrame;
495
+ }
496
+ /**
497
+ * A paragraph's place in a numbering sequence.
498
+ *
499
+ * `none` is not "no numbering stated" — that is expressed by leaving the whole
500
+ * field out. It is an explicit detachment (OOXML `numId 0`), which is how a
501
+ * single heading opts out of a numbering its style applies.
502
+ */
503
+ export type DocxIrParagraphNumbering = {
504
+ none: true;
505
+ } | {
506
+ none?: false;
507
+ reference: string;
508
+ /** 0-based. */
509
+ level: number;
510
+ };
511
+ export interface DocxIrParagraphMarkRevision {
512
+ type: 'insert' | 'delete';
513
+ id: number;
514
+ author: string;
515
+ date: string;
516
+ }
517
+ /**
518
+ * A text frame: a paragraph positioned as a floating box.
519
+ *
520
+ * Distinct from `DocxIrFloating`, which positions a drawing. A frame positions
521
+ * the paragraph itself.
522
+ */
523
+ export interface DocxIrFrame {
524
+ widthTwips: number;
525
+ heightTwips: number;
526
+ anchorHorizontal: string;
527
+ anchorVertical: string;
528
+ xTwips?: number;
529
+ yTwips?: number;
530
+ xAlign?: string;
531
+ yAlign?: string;
532
+ wrap?: string;
533
+ rule?: 'auto' | 'exact' | 'atLeast';
534
+ /** Keep the frame with the paragraph it is anchored to. */
535
+ anchorLock?: boolean;
536
+ }
537
+ export interface DocxIrTable {
538
+ kind: 'table';
539
+ id: string;
540
+ path: string;
541
+ rows: DocxIrTableRow[];
542
+ columnGrid: DocxIrColumnGrid;
543
+ width: DocxIrTableWidth;
544
+ /** Fixed layout is what the pipeline has always produced. */
545
+ layout: 'fixed' | 'autofit';
546
+ borders?: DocxIrBorders;
547
+ alignment?: DocxIrAlignment;
548
+ /** Default cell margins in twips. */
549
+ cellMargins?: DocxIrCellMargins;
550
+ /** Keep the whole table on one page where the format allows. */
551
+ keepInOnePage?: boolean;
552
+ /** Float the table out of the text flow. */
553
+ floating?: DocxIrTableFloating;
554
+ }
555
+ /**
556
+ * The table's column grid (`w:tblGrid`).
557
+ *
558
+ * `twips` is the real OOXML unit. `percent` is what the pipeline writes when no
559
+ * column states a width: the grid then carries a percentage per column rather
560
+ * than a width, which Word tolerates because the table itself is sized in
561
+ * percent.
562
+ */
563
+ export interface DocxIrColumnGrid {
564
+ unit: 'twips' | 'percent';
565
+ values: number[];
566
+ }
567
+ export type DocxIrTableWidth = {
568
+ kind: 'twips';
569
+ value: number;
570
+ } | {
571
+ kind: 'percent';
572
+ value: number;
573
+ } | {
574
+ kind: 'auto';
575
+ };
576
+ export interface DocxIrCellMargins {
577
+ topTwips?: number;
578
+ bottomTwips?: number;
579
+ leftTwips?: number;
580
+ rightTwips?: number;
581
+ }
582
+ export interface DocxIrTableRow {
583
+ cells: DocxIrTableCell[];
584
+ /** Row height in twips. */
585
+ heightTwips?: number;
586
+ heightRule?: 'auto' | 'exact' | 'atLeast';
587
+ /** Repeat this row at the top of each page the table spans. */
588
+ isHeader?: boolean;
589
+ cantSplit?: boolean;
590
+ /**
591
+ * A revision on the row.
592
+ *
593
+ * Word needs both this and a matching revision on every run inside, or
594
+ * accepting a deletion leaves an empty row behind.
595
+ */
596
+ revision?: DocxIrParagraphMarkRevision;
597
+ }
598
+ export interface DocxIrTableCell {
599
+ /** Cells hold blocks, so a cell can contain a paragraph, image or table. */
600
+ children: DocxIrBlock[];
601
+ columnSpan?: number;
602
+ /** `restart` begins a vertical merge, `continue` extends it. */
603
+ rowSpan?: 'restart' | 'continue';
604
+ widthTwips?: number;
605
+ verticalAlign?: DocxIrVerticalAlign;
606
+ borders?: DocxIrBorders;
607
+ shading?: DocxIrShading;
608
+ margins?: DocxIrCellMargins;
609
+ /** Rotate the cell's text. */
610
+ textDirection?: string;
611
+ }
612
+ export interface DocxIrTableFloating {
613
+ horizontalAnchor?: string;
614
+ verticalAnchor?: string;
615
+ absoluteHorizontalPositionTwips?: number;
616
+ absoluteVerticalPositionTwips?: number;
617
+ relativeHorizontalPosition?: string;
618
+ relativeVerticalPosition?: string;
619
+ topFromTextTwips?: number;
620
+ bottomFromTextTwips?: number;
621
+ leftFromTextTwips?: number;
622
+ rightFromTextTwips?: number;
623
+ overlap?: 'never' | 'overlap';
624
+ }
625
+ export interface DocxIrTableOfContents {
626
+ kind: 'toc';
627
+ id: string;
628
+ path: string;
629
+ /** Heading outline levels to include, inclusive. */
630
+ headingRange?: {
631
+ from: number;
632
+ to: number;
633
+ };
634
+ /** Additional paragraph styles, by display name, with their outline level. */
635
+ styleLevels?: Array<{
636
+ styleName: string;
637
+ level: number;
638
+ }>;
639
+ /** Restrict the TOC to a bookmarked region. */
640
+ bookmarkScope?: string;
641
+ hyperlink?: boolean;
642
+ /** The field's alias, shown while the entries are collapsed. */
643
+ alias?: string;
644
+ /**
645
+ * Outline level ranges whose entries omit a page number.
646
+ *
647
+ * Ranges rather than a level list because that is what OOXML's `\n` switch
648
+ * takes, and because the levels omitted are always contiguous blocks either
649
+ * side of the range that keeps its numbers.
650
+ */
651
+ omitPageNumbersForLevels?: Array<{
652
+ from: number;
653
+ to: number;
654
+ }>;
655
+ /** Separator between entry text and page number. */
656
+ entrySeparator?: string;
657
+ /**
658
+ * Entries baked in so a reader that never refreshes fields still shows a
659
+ * table of contents. Headless converters never refresh.
660
+ */
661
+ cachedEntries?: DocxIrTocEntry[];
662
+ }
663
+ export interface DocxIrTocEntry {
664
+ text: string;
665
+ level: number;
666
+ /**
667
+ * The bookmark the entry links to, when one is known.
668
+ *
669
+ * A cached entry does not need one: Word rebuilds the links the moment it
670
+ * refreshes the field, and a reader that never refreshes shows the text
671
+ * without following it anywhere.
672
+ */
673
+ bookmark?: string;
674
+ }
675
+ export interface DocxIrSection {
676
+ id: string;
677
+ path: string;
678
+ children: DocxIrBlock[];
679
+ properties: DocxIrSectionProperties;
680
+ headers?: DocxIrHeaderFooterSet;
681
+ footers?: DocxIrHeaderFooterSet;
682
+ /**
683
+ * A bookmark covering this section's content.
684
+ *
685
+ * OOXML has no notion of a bookmarked section, so a section that something
686
+ * can point at — a table of contents scoped to it, an internal link — is a
687
+ * bookmark range around its content. One authored section can be split into
688
+ * several layout sections, which is why `opens` and `closes` are separate:
689
+ * the range starts in the first and ends in the last, and they share an id.
690
+ */
691
+ bookmark?: DocxIrSectionBookmark;
692
+ }
693
+ export interface DocxIrSectionBookmark {
694
+ id: number;
695
+ name: string;
696
+ opens: boolean;
697
+ closes: boolean;
698
+ }
699
+ export interface DocxIrSectionProperties {
700
+ page: DocxIrPageSetup;
701
+ columns?: DocxIrColumns;
702
+ /** Where this section starts relative to the previous one. */
703
+ type?: 'nextPage' | 'nextColumn' | 'continuous' | 'evenPage' | 'oddPage';
704
+ pageNumbers?: DocxIrPageNumbering;
705
+ borders?: DocxIrPageBorders;
706
+ /** Distinct first-page header/footer. */
707
+ titlePage?: boolean;
708
+ }
709
+ export interface DocxIrPageSetup {
710
+ widthTwips: number;
711
+ heightTwips: number;
712
+ orientation: 'portrait' | 'landscape';
713
+ /**
714
+ * OOXML `w:pgSz/@w:code` — the paper code a printer driver keys off.
715
+ * Present only for a named size; a custom width/height has none.
716
+ */
717
+ code?: number;
718
+ margins: DocxIrPageMargins;
719
+ }
720
+ export interface DocxIrPageMargins {
721
+ topTwips: number;
722
+ bottomTwips: number;
723
+ leftTwips: number;
724
+ rightTwips: number;
725
+ headerTwips?: number;
726
+ footerTwips?: number;
727
+ gutterTwips?: number;
728
+ }
729
+ export interface DocxIrColumns {
730
+ count: number;
731
+ spaceTwips?: number;
732
+ separator?: boolean;
733
+ equalWidth?: boolean;
734
+ /** Explicit per-column widths; length matches `count` when present. */
735
+ widths?: Array<{
736
+ widthTwips: number;
737
+ spaceTwips?: number;
738
+ }>;
739
+ }
740
+ export interface DocxIrPageNumbering {
741
+ start?: number;
742
+ formatType?: string;
743
+ }
744
+ export interface DocxIrPageBorders {
745
+ display?: string;
746
+ offsetFrom?: 'page' | 'text';
747
+ borders?: DocxIrBorders;
748
+ }
749
+ export interface DocxIrHeaderFooterSet {
750
+ default?: DocxIrHeaderFooter;
751
+ first?: DocxIrHeaderFooter;
752
+ even?: DocxIrHeaderFooter;
753
+ }
754
+ export interface DocxIrHeaderFooter {
755
+ /** Deterministic: `header:s0:default`. */
756
+ id: string;
757
+ children: DocxIrBlock[];
758
+ }
759
+ export interface DocxIrComment {
760
+ id: number;
761
+ author: string;
762
+ initials?: string;
763
+ /** ISO 8601. */
764
+ date: string;
765
+ children: DocxIrBlock[];
766
+ /** Threading: the comment this one replies to. */
767
+ parentId?: number;
768
+ resolved?: boolean;
769
+ }
770
+ export interface DocxIrNote {
771
+ id: number;
772
+ children: DocxIrBlock[];
773
+ }
774
+ //# sourceMappingURL=types.d.ts.map