@docx-editor.dev/core 2.14.1 → 2.15.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 (133) hide show
  1. package/README.md +42 -0
  2. package/dist/automation.cjs +1 -1
  3. package/dist/automation.d.ts +6 -5
  4. package/dist/automation.js +1 -1
  5. package/dist/binding.cjs +1 -1
  6. package/dist/binding.d.ts +16 -10
  7. package/dist/binding.js +1 -1
  8. package/dist/chunk-24APKZAN.cjs +11 -0
  9. package/dist/chunk-2YH4MSHX.cjs +2 -0
  10. package/dist/chunk-5Y7AADI6.js +1 -0
  11. package/dist/chunk-AREFLNUP.js +11 -0
  12. package/dist/chunk-AS7YZNQE.cjs +2 -0
  13. package/dist/chunk-AVGCKH6A.cjs +20 -0
  14. package/dist/chunk-CDYVDQRI.cjs +5 -0
  15. package/dist/chunk-FGBADUSK.cjs +1 -0
  16. package/dist/chunk-HOEWFH5U.cjs +1 -0
  17. package/dist/chunk-KFELX7CN.js +2 -0
  18. package/dist/{chunk-OKEDGR65.js → chunk-KXPVOPR5.js} +1 -1
  19. package/dist/chunk-LGFKIF4M.cjs +1 -0
  20. package/dist/chunk-M52QXFKI.js +1 -0
  21. package/dist/chunk-MNUKSXRO.js +1 -0
  22. package/dist/chunk-PBOIGBDO.js +2 -0
  23. package/dist/chunk-PMHGONET.cjs +1 -0
  24. package/dist/chunk-PXKZUTHX.cjs +2 -0
  25. package/dist/chunk-Q4AB7E4O.cjs +1 -0
  26. package/dist/chunk-QJYH6AYD.js +1 -0
  27. package/dist/chunk-QRC37MWG.cjs +20 -0
  28. package/dist/chunk-RJSB6RJ7.js +20 -0
  29. package/dist/chunk-SB54HLFJ.js +20 -0
  30. package/dist/chunk-VP7SDFCM.js +1 -0
  31. package/dist/chunk-XCESLTJL.js +2 -0
  32. package/dist/{chunk-KIAP7PFQ.cjs → chunk-YL4Q5LZP.cjs} +1 -1
  33. package/dist/chunk-Z4527AXR.js +5 -0
  34. package/dist/collaboration/replication.cjs +1 -1
  35. package/dist/collaboration/replication.d.ts +4 -3
  36. package/dist/collaboration/replication.js +1 -1
  37. package/dist/collaboration.d.ts +4 -3
  38. package/dist/contracts/editor.d.ts +7 -7
  39. package/dist/contracts/interaction.d.ts +7 -7
  40. package/dist/contracts/modules.d.ts +8 -7
  41. package/dist/{custom-node-writes-DntmaAVW.d.ts → custom-node-writes-C9ArIlJh.d.ts} +2 -2
  42. package/dist/{editor-a6VvsfYU.d.ts → editor-sRxrFJd8.d.ts} +29 -21
  43. package/dist/editor.cjs +1 -1
  44. package/dist/editor.d.ts +27 -58
  45. package/dist/editor.js +1 -1
  46. package/dist/export.cjs +2 -0
  47. package/dist/export.d.ts +337 -0
  48. package/dist/export.js +2 -0
  49. package/dist/font-resolver-BYEHQGTw.d.ts +251 -0
  50. package/dist/headless-document-view-DELC4E5v.d.ts +134 -0
  51. package/dist/hf-references-DTrHkktY.d.ts +70 -0
  52. package/dist/{index-C5ZnSRkF.d.ts → index-C3Gvq4jN.d.ts} +55 -246
  53. package/dist/index.cjs +1 -1
  54. package/dist/index.d.ts +18 -16
  55. package/dist/index.js +1 -1
  56. package/dist/{shaped-measurer-CFPnXFs9.d.cts → layout-shaping-DoGR5cf8.d.ts} +86 -12
  57. package/dist/layout.cjs +1 -1
  58. package/dist/layout.d.ts +1106 -729
  59. package/dist/layout.js +1 -1
  60. package/dist/{note-properties-CDFiNXcD.d.ts → note-properties-DSe8igrz.d.ts} +2 -2
  61. package/dist/{omml-equation-BY49UOIF.d.ts → omml-equation-BpRmfDAf.d.ts} +1 -1
  62. package/dist/output.cjs +1 -1
  63. package/dist/output.d.ts +6 -6
  64. package/dist/output.js +1 -1
  65. package/dist/{protocol-gOY5GA8K.d.cts → protocol-DZzKxH5r.d.ts} +18 -12
  66. package/dist/{review-items-CCS1h93f.d.ts → review-items-DYRx187i.d.ts} +2 -2
  67. package/dist/{review-reads-BjZYeMd4.d.ts → review-reads-LbGUdNzn.d.ts} +22 -25
  68. package/dist/{revision-projection-BeXVrSSV.d.ts → revision-projection-DHRJH48u.d.ts} +1 -1
  69. package/dist/{semantic-cell-selection-BK91NCCG.d.ts → semantic-cell-selection-BXVWCBYm.d.ts} +4 -4
  70. package/dist/{semantic-interaction-BmQ7h2cq.d.ts → semantic-interaction-DZsDmPg5.d.ts} +1 -1
  71. package/dist/{semantic-paint-WJD2KeG1.d.ts → semantic-paint-f7SqN4oW.d.ts} +2 -2
  72. package/dist/{semantic-records-BpozY7-j.d.cts → semantic-records-EIdwId-a.d.ts} +301 -205
  73. package/dist/store.cjs +1 -1
  74. package/dist/store.d.ts +15 -65
  75. package/dist/store.js +1 -1
  76. package/dist/{tree-op-types-D6HzlPR4.d.ts → tree-op-types-egdarvH_.d.ts} +7 -3
  77. package/dist/{tree-package-fragment-CWFjgH6a.d.ts → tree-package-fragment-DjkH4ESI.d.ts} +4 -70
  78. package/dist/{tree-session-contract-B2HfGt79.d.ts → tree-session-contract-CGOOgPjW.d.ts} +29 -23
  79. package/dist/{tree-store-APgWx6qn.d.ts → tree-store-DKJB0IcA.d.ts} +2 -2
  80. package/package.json +7 -2
  81. package/dist/automation.d.cts +0 -82
  82. package/dist/binding.d.cts +0 -153
  83. package/dist/chunk-2PIHW2QM.cjs +0 -1
  84. package/dist/chunk-2QTY5S6T.js +0 -1
  85. package/dist/chunk-4Z5MODAE.cjs +0 -2
  86. package/dist/chunk-5TKAPFZT.cjs +0 -2
  87. package/dist/chunk-DRQHIQ4R.cjs +0 -1
  88. package/dist/chunk-F2K6SDHA.cjs +0 -20
  89. package/dist/chunk-FBA57EUJ.js +0 -2
  90. package/dist/chunk-KTAQ7BRQ.js +0 -20
  91. package/dist/chunk-LBAHXZCU.cjs +0 -5
  92. package/dist/chunk-MCDUQYWP.js +0 -5
  93. package/dist/chunk-MQP26KCF.js +0 -1
  94. package/dist/chunk-NDJGSR6M.cjs +0 -19
  95. package/dist/chunk-NJNFJPGB.cjs +0 -11
  96. package/dist/chunk-O5M4CR4P.cjs +0 -2
  97. package/dist/chunk-UKUOZXUD.js +0 -19
  98. package/dist/chunk-VQ4R5LTU.js +0 -2
  99. package/dist/chunk-ZBEJHJN2.js +0 -11
  100. package/dist/chunk-ZVTW7RGD.js +0 -2
  101. package/dist/collaboration/replication.d.cts +0 -216
  102. package/dist/collaboration.d.cts +0 -176
  103. package/dist/contracts/document.d.cts +0 -273
  104. package/dist/contracts/editor.d.cts +0 -10
  105. package/dist/contracts/interaction.d.cts +0 -10
  106. package/dist/contracts/modules.d.cts +0 -130
  107. package/dist/contracts/types.d.cts +0 -562
  108. package/dist/custom-node-writes-C46r3_5O.d.cts +0 -310
  109. package/dist/document-properties-D6Ahr8D6.d.cts +0 -28
  110. package/dist/document-properties-D6Ahr8D6.d.ts +0 -28
  111. package/dist/editor-AJ06hyyg.d.cts +0 -1994
  112. package/dist/editor.d.cts +0 -393
  113. package/dist/failure-BnGjoXf0.d.cts +0 -64
  114. package/dist/index-Cbw4lkOt.d.cts +0 -3391
  115. package/dist/index.d.cts +0 -23
  116. package/dist/layout.d.cts +0 -2486
  117. package/dist/note-properties-Y6qYh2Hv.d.cts +0 -67
  118. package/dist/omml-equation-DB8d-jCq.d.cts +0 -84
  119. package/dist/output.d.cts +0 -74
  120. package/dist/protocol-BsmQgblT.d.ts +0 -1358
  121. package/dist/review-items-CaAkgi5s.d.cts +0 -360
  122. package/dist/review-reads-DEsV0OOW.d.cts +0 -163
  123. package/dist/revision-projection-DXbrfNGD.d.cts +0 -156
  124. package/dist/semantic-cell-selection-BMhku3B1.d.cts +0 -451
  125. package/dist/semantic-interaction-DUAnxbgf.d.cts +0 -160
  126. package/dist/semantic-paint-DufNL1Zr.d.cts +0 -247
  127. package/dist/semantic-records-92UnKeU_.d.ts +0 -2821
  128. package/dist/shaped-measurer-BWbindlI.d.ts +0 -168
  129. package/dist/store.d.cts +0 -2500
  130. package/dist/tree-op-types-BUulYD5y.d.cts +0 -3099
  131. package/dist/tree-package-fragment-Dhyw7oPm.d.cts +0 -732
  132. package/dist/tree-session-contract-BY9xd7s_.d.cts +0 -613
  133. package/dist/tree-store-DEEQ9wz_.d.cts +0 -416
@@ -1,562 +0,0 @@
1
- /**
2
- * Shared types for the `@docx-editor.dev/core` contract. Type-only, zero runtime.
3
- *
4
- * `@docx-editor.dev/core/contracts/types` re-exports this module verbatim, through
5
- * `types-barrel.ts`. There is no `@docx-editor.dev/core/types` subpath.
6
- */
7
- /** Which paragraph-level reads the selection disagrees about. @public */
8
- interface ParagraphDisagreements {
9
- readonly alignment: boolean;
10
- readonly spaceBeforePt: boolean;
11
- readonly spaceAfterPt: boolean;
12
- readonly lineSpacing: boolean;
13
- readonly tabStops: boolean;
14
- }
15
- /**
16
- * The five paragraph flags a Paragraph dialog shows as checkboxes.
17
- *
18
- * `contextualSpacing` is Word's "Don't add space between paragraphs of the same style";
19
- * the rest are its Pagination block. `null` means the selection disagrees.
20
- *
21
- * @public
22
- */
23
- interface ParagraphFlags {
24
- readonly contextualSpacing: boolean | null;
25
- readonly keepNext: boolean | null;
26
- readonly keepLines: boolean | null;
27
- readonly widowControl: boolean | null;
28
- readonly pageBreakBefore: boolean | null;
29
- }
30
- /**
31
- * Every field of the Paragraph dialog, as `setParagraphFormat` takes it.
32
- *
33
- * An omitted field is left as authored. `null` REMOVES a setting so the style supplies it
34
- * again — not the same as a zero, which blocks the cascade.
35
- *
36
- * @public
37
- */
38
- interface ParagraphFormatCommand {
39
- alignment?: 'left' | 'center' | 'right' | 'justify';
40
- spaceBeforePt?: number | null;
41
- spaceAfterPt?: number | null;
42
- lineSpacing?: {
43
- rule: 'multiple' | 'exact' | 'atLeast';
44
- value: number;
45
- } | null;
46
- indentLeftTwips?: number | null;
47
- indentRightTwips?: number | null;
48
- /** ONE signed first-line offset: negative is a hanging indent. */
49
- indentFirstLineTwips?: number | null;
50
- contextualSpacing?: boolean;
51
- keepNext?: boolean;
52
- keepLines?: boolean;
53
- widowControl?: boolean;
54
- pageBreakBefore?: boolean;
55
- /**
56
- * Replace the paragraph's custom tab stops. An empty list CLEARS them, which is what
57
- * "Clear All" does; omit the field to leave them as authored.
58
- */
59
- tabStops?: readonly ParagraphTabStop[];
60
- }
61
- /** One custom tab stop, as a command states it. @public */
62
- interface ParagraphTabStop {
63
- readonly positionTwips: number;
64
- readonly alignment: 'left' | 'center' | 'right' | 'decimal' | 'bar';
65
- readonly leader?: 'none' | 'dot' | 'hyphen' | 'underscore' | 'heavy' | 'middleDot';
66
- }
67
- /** Ownership token for one retained selection highlight. @public */
68
- type SelectionPin = symbol;
69
- /**
70
- * The LLM- and JSON-facing address for a piece of a document.
71
- *
72
- * `paraId` is the 8-hex `w14:paraId`, matched case-insensitively. `search` is a
73
- * phrase that must match EXACTLY ONCE inside that paragraph; ambiguous or
74
- * missing matches fail with `'ambiguous'` / `'notFound'` rather than falling
75
- * back to first-match.
76
- *
77
- * Offset-based addressing was tried and abandoned: an agent cannot compute a
78
- * character offset it has not seen, and offsets do not survive concurrent
79
- * edits. Do not reintroduce `{ blockId, offset }`.
80
- */
81
- interface DocAnchor {
82
- paraId: string;
83
- search?: string;
84
- /** Opt-in disambiguation. Omit to require uniqueness. */
85
- occurrence?: number;
86
- }
87
- /** Structural addressing for content the paraId map cannot reach. */
88
- interface DocLocation {
89
- container: ContainerRef;
90
- /** Block indices, descending into tables and content controls. */
91
- path: number[];
92
- offset?: number;
93
- }
94
- /**
95
- * Which STORY a location belongs to.
96
- *
97
- * The body is one container; every header, footer and note is another. A path alone is
98
- * ambiguous without it, because block index 0 exists in every story a document has.
99
- */
100
- type ContainerRef = {
101
- part: 'body';
102
- } | {
103
- part: 'header' | 'footer';
104
- rId: string;
105
- } | {
106
- part: 'footnote' | 'endnote';
107
- noteId: number;
108
- };
109
- /**
110
- * Anything an operation can be pointed at: a paragraph-relative {@link DocAnchor}, a structural
111
- * {@link DocLocation}, or a {@link DocRange} spanning two of them.
112
- */
113
- type DocTarget = DocAnchor | DocLocation | DocRange;
114
- /** A span between two positions. The endpoints may be addressed either way, independently. */
115
- interface DocRange {
116
- from: DocAnchor | DocLocation;
117
- to: DocAnchor | DocLocation;
118
- }
119
- /**
120
- * Every write returns this rather than `boolean`.
121
- *
122
- * A bare boolean cannot distinguish "no-op" from "target not found" from
123
- * "content control is locked", and the editor layer already throws eight
124
- * distinct ContentControl error classes that a boolean would flatten.
125
- */
126
- type ExecResult = {
127
- ok: true;
128
- changed: boolean;
129
- } | {
130
- ok: false;
131
- code: ExecErrorCode;
132
- reason: string;
133
- target?: DocTarget;
134
- };
135
- /**
136
- * Why a write was refused, as a value to branch on.
137
- *
138
- * Deliberately finer-grained than a boolean: "no-op", "target not found" and "content control is
139
- * locked" are different outcomes, and a caller retrying the first should not retry the third.
140
- */
141
- type ExecErrorCode = 'notFound' | 'ambiguous' | 'locked' | 'bound' | 'typeMismatch' | 'kindMismatch' | 'outOfBounds' | 'unsupported' | 'invalidArgs';
142
- /**
143
- * A parsed .docx.
144
- *
145
- * NOT JSON-round-trippable: it holds `Map`s and `Date`s, plus an internal
146
- * side-table of verbatim XML used for lossless round-tripping. Use `toJSON` /
147
- * `fromJSON` before sending it over JSON-RPC or handing it to a model.
148
- */
149
- interface DocxDocument {
150
- readonly body: DocumentBody;
151
- readonly styles: StyleDefinitions;
152
- readonly theme?: Theme;
153
- readonly comments: readonly DocComment[];
154
- readonly revisions: readonly Revision[];
155
- }
156
- /** The main story: its blocks in reading order, plus the sections derived from them. */
157
- interface DocumentBody {
158
- readonly content: readonly Block[];
159
- /**
160
- * Derived, not stored: recomputed on read from section-break markers and
161
- * section inheritance. Never treat it as a spreadable field.
162
- */
163
- readonly sections: readonly Section[];
164
- }
165
- /** The JSON-safe projection of a document. */
166
- interface DocxDocumentJSON {
167
- readonly [key: string]: unknown;
168
- }
169
- /** One section: the page it lays out on, and the header/footer stories it declares. */
170
- interface Section {
171
- readonly properties: SectionProperties;
172
- readonly headers: HeaderFooterSet;
173
- readonly footers: HeaderFooterSet;
174
- }
175
- /**
176
- * A section's three header (or footer) variants, each a relationship id.
177
- *
178
- * All optional: a variant a section does not declare inherits the previous section's, and one
179
- * absent everywhere means the document simply has none.
180
- */
181
- interface HeaderFooterSet {
182
- readonly default?: string;
183
- readonly first?: string;
184
- readonly even?: string;
185
- }
186
- /** Anything that can sit at block level in a story. Discriminate on `kind`. */
187
- type Block = Paragraph | Table | ContentControl;
188
- /** One paragraph: its runs, the style it names, and its list membership. */
189
- interface Paragraph {
190
- readonly kind: 'paragraph';
191
- /** `w14:paraId`. The stable handle `DocAnchor` addresses. */
192
- readonly paraId?: string;
193
- readonly runs: readonly Run[];
194
- readonly styleId?: string;
195
- readonly numbering?: NumberingRef;
196
- }
197
- /** A stretch of text sharing one set of character properties. */
198
- interface Run {
199
- readonly text: string;
200
- readonly formatting?: RunFormatting;
201
- /** Set when the run carries a tracked change. Unique only within its part. */
202
- readonly revisionId?: number;
203
- }
204
- /**
205
- * Character formatting, and — at selection level — the paragraph properties a toolbar reads
206
- * alongside it.
207
- *
208
- * One type serves both roles so a toolbar reads alignment, style and script state from the same
209
- * object as bold and italic. On a {@link Run} the selection-level fields stay absent: a run has
210
- * no alignment or paragraph style of its own.
211
- */
212
- interface RunFormatting {
213
- readonly bold?: boolean;
214
- readonly italic?: boolean;
215
- readonly underline?: boolean;
216
- readonly strike?: boolean;
217
- readonly color?: ColorValue;
218
- readonly highlight?: string;
219
- readonly fontFamily?: string;
220
- readonly fontSizePt?: number;
221
- readonly superscript?: boolean;
222
- readonly subscript?: boolean;
223
- /** Paragraph alignment at the selection. `both` is OOXML's spelling of justify. */
224
- readonly alignment?: 'left' | 'center' | 'right' | 'both';
225
- /** Paragraph style id (`w:pStyle`) at the selection. */
226
- readonly styleId?: string;
227
- /**
228
- * Line spacing at the selection, in the unit its rule implies — LINES for `multiple`,
229
- * points for `exact` and `atLeast`. The same vocabulary `setLineSpacing` takes, so a
230
- * control can show what it reads and send back what it shows. Absent when the
231
- * selection's paragraphs disagree or state no line spacing.
232
- */
233
- readonly lineSpacing?: {
234
- readonly rule: 'multiple' | 'exact' | 'atLeast';
235
- readonly value: number;
236
- };
237
- /**
238
- * Space above and below the paragraph at the selection, in points.
239
- *
240
- * The measurement the cascade STATES — `w:docDefaults`, the style chain and direct
241
- * formatting resolved together — not the gap the page finally draws. The two differ for a
242
- * paragraph carrying `w:beforeAutospacing`, where Word substitutes its own value and
243
- * ignores the measurement, and again where two paragraphs collapse their adjacent spacing.
244
- * Absent when the selection's paragraphs disagree or no level states it.
245
- */
246
- readonly spaceBeforePt?: number;
247
- readonly spaceAfterPt?: number;
248
- /**
249
- * The paragraph flags the Paragraph dialog shows as checkboxes.
250
- *
251
- * Each is `true`, `false`, or `null` when the selection's paragraphs disagree — a
252
- * checkbox needs all three. Read through the cascade, so a flag a STYLE sets reads as on,
253
- * which is what the box has to show over a paragraph the page is visibly keeping with the
254
- * next. Absent on a `Run`, like every other selection-level field here.
255
- */
256
- readonly paragraphFlags?: ParagraphFlags;
257
- /**
258
- * Which paragraph-level fields above are absent because the selection DISAGREES, as
259
- * opposed to because nothing states them.
260
- *
261
- * A `null`/absent value alone cannot tell those apart, and both readings have shipped as
262
- * bugs: a disagreement rendered as a concrete value is uncorrectable, because the value
263
- * that would fix it is the one already on screen; an absent value rendered as "mixed"
264
- * tells a single paragraph it disagrees with itself.
265
- */
266
- readonly disagrees?: ParagraphDisagreements;
267
- /**
268
- * The paragraph's custom tab stops at the selection, cascade included. Absent when the
269
- * selection disagrees or the paragraphs have none.
270
- */
271
- readonly tabStops?: readonly ParagraphTabStop[];
272
- /**
273
- * The EFFECTIVE paragraph indent at the selection — cascade and numbering merge
274
- * included, so a numbered item that authors no `w:ind` reports the indent its list
275
- * definition gives it. Absent when nothing is loaded, or when the selection is inside a
276
- * table (see {@link IndentFormatting}).
277
- */
278
- readonly indent?: IndentFormatting;
279
- }
280
- /**
281
- * Indent at the selection, in twips.
282
- *
283
- * Unlike every other field here, this does NOT go absent when the selection's paragraphs
284
- * disagree. A ruler has to draw its handles somewhere, and Word draws them at the FIRST
285
- * selected paragraph's values — Select All is the commonest indent gesture, and hiding the
286
- * handles for it would be worse than showing one paragraph's truth. The values are
287
- * therefore always the first touched paragraph's, and {@link mixed} records per field
288
- * whether the rest agree.
289
- *
290
- * `firstLine` is ONE SIGNED offset: negative is a hanging indent. OOXML spells it as two
291
- * mutually exclusive attributes and this collapses them hanging-wins (§17.3.1.12), which
292
- * is the model Word itself keeps.
293
- *
294
- * Absent inside a table. The value would be correct there, but it is measured from the
295
- * cell's content edge while a ruler is drawn against the page's margin, and the ruler does
296
- * not know the cell.
297
- */
298
- interface IndentFormatting {
299
- /** Left indent, signed. Negative pulls text into the margin, as Word allows. */
300
- readonly left: number;
301
- /** Right indent, signed. */
302
- readonly right: number;
303
- /** First-line offset from {@link left}, signed. Negative is a hanging indent. */
304
- readonly firstLine: number;
305
- /** Per field, whether the selection's paragraphs disagree about it. */
306
- readonly mixed: {
307
- readonly left: boolean;
308
- readonly right: boolean;
309
- readonly firstLine: boolean;
310
- };
311
- }
312
- /** A table: its rows, and the table style they resolve through. */
313
- interface Table {
314
- readonly kind: 'table';
315
- readonly rows: readonly TableRow[];
316
- readonly styleId?: string;
317
- }
318
- /** One table row. Cell count may vary between rows: `colSpan` and vertical merges reshape it. */
319
- interface TableRow {
320
- readonly cells: readonly TableCell[];
321
- }
322
- /**
323
- * One cell. Its `content` is ordinary blocks, so a cell may hold paragraphs, nested tables and
324
- * content controls alike.
325
- */
326
- interface TableCell {
327
- readonly content: readonly Block[];
328
- /** Vertical merge span. Absent means 1. */
329
- readonly rowSpan?: number;
330
- /** `w:gridSpan`. Absent means 1. */
331
- readonly colSpan?: number;
332
- }
333
- /** Structured document tag (`w:sdt`). */
334
- interface ContentControl {
335
- readonly kind: 'contentControl';
336
- readonly id: string;
337
- readonly tag?: string;
338
- readonly alias?: string;
339
- readonly controlType: ContentControlType;
340
- readonly locked?: boolean;
341
- readonly content: readonly Block[];
342
- }
343
- /** Which kind of control a `w:sdt` is, and therefore what a value written into it must be. */
344
- type ContentControlType = 'richText' | 'plainText' | 'checkbox' | 'dropdown' | 'comboBox' | 'date' | 'picture' | 'repeatingSection';
345
- /**
346
- * The control kinds an insertion can author.
347
- *
348
- * A NARROWING of {@link ContentControlType}, not a separate vocabulary: a kind read off an
349
- * existing control can be handed straight back to `insertContentControl`. Three kinds are
350
- * absent because an insertion would have to invent what they carry — a checkbox needs its two
351
- * declared glyph states, a picture needs an image part, and a repeating section is a container
352
- * whose items have their own verbs. Reading still answers the wider type; a document may hold
353
- * kinds this cannot create.
354
- *
355
- * `dropDownList` is the same kind as `dropdown`, spelt as OOXML spells it. Both are accepted,
356
- * so a type read off a control can be handed back without translating it — and the OOXML
357
- * spelling is the one the automation protocol takes, so a caller who uses both surfaces can
358
- * write that one everywhere.
359
- */
360
- type InsertableContentControlType = Extract<ContentControlType, 'richText' | 'plainText' | 'dropdown' | 'comboBox' | 'date'> | 'dropDownList';
361
- /**
362
- * Narrows a content-control query. Fields combine with AND; an empty filter matches every
363
- * control.
364
- */
365
- interface ContentControlFilter {
366
- readonly tag?: string;
367
- readonly alias?: string;
368
- readonly controlType?: ContentControlType;
369
- }
370
- /**
371
- * A position in one story: a paragraph and a UTF-16 offset inside it.
372
- *
373
- * The same offset space the ops and the caret use, so an anchor read here can be handed
374
- * straight back to a selection without re-deriving anything.
375
- */
376
- interface DocAnchorRange {
377
- /** Canonical part name of the story the range lives in, e.g. `/word/document.xml`. */
378
- readonly part: string;
379
- readonly startParagraphId: string;
380
- readonly startOffset: number;
381
- /** May sit in a later paragraph: the range markers are independent elements. */
382
- readonly endParagraphId: string;
383
- readonly endOffset: number;
384
- }
385
- /**
386
- * One comment or reply, as `comments.xml` records it.
387
- *
388
- * A reply is a comment with a `parentId`; OOXML gives replies no separate element, so the thread
389
- * is reconstructed from that link rather than from nesting.
390
- */
391
- interface DocComment {
392
- readonly id: string;
393
- readonly author: string;
394
- /**
395
- * OPTIONAL, because `CT_Comment` makes `@w:date` optional and files omit it. A comment
396
- * with no date is a comment, not a defect, and fabricating one is a content change.
397
- */
398
- readonly date?: string;
399
- readonly text: string;
400
- readonly parentId?: string;
401
- readonly resolved?: boolean;
402
- /**
403
- * Where the comment is anchored, absent when the file gave it no usable range.
404
- *
405
- * A comment lives in `comments.xml` and is placed by markers in a STORY, so the story is
406
- * part of the address: a comment anchored in a header belongs to a part the body never saw.
407
- */
408
- readonly anchor?: DocAnchorRange;
409
- /**
410
- * True when the file gave this comment no usable range — a reference with no markers, or a
411
- * start with no end. Reported rather than dropped: a reviewer's remark vanishing silently
412
- * is worse than one that says it lost its text.
413
- */
414
- readonly orphaned?: boolean;
415
- }
416
- /**
417
- * What kind of decision a revision represents.
418
- *
419
- * Wider than insert/delete/format, and it has to be. `w:moveFrom`/`w:moveTo` are not a
420
- * deletion and an insertion — resolving one half alone duplicates or loses the content;
421
- * `w:pPr/w:rPr/w:ins|w:del` decorates no characters at all and merges paragraphs when
422
- * resolved; a row or cell revision is structural. A reviewer shown only three kinds is a
423
- * reviewer who never learns about the rest.
424
- */
425
- type RevisionType = 'insert' | 'delete'
426
- /** A deletion and an insertion that are one edit: text typed over a selection. */
427
- | 'replace' | 'moveFrom' | 'moveTo'
428
- /** `w:rPrChange` / `w:pPrChange` — the words are unchanged, their formatting is not. */
429
- | 'format'
430
- /** `w:pPr/w:rPr/w:ins|w:del` — a paragraph split or merge. */
431
- | 'paragraphMark'
432
- /** A row, cell, section or grid revision. */
433
- | 'structural';
434
- /**
435
- * One tracked change.
436
- *
437
- * Addressing needs BOTH `id` and `part`: `@w:id` is unique only within a part, so an id alone
438
- * names two revisions in any package that has a header or a comments part.
439
- */
440
- interface Revision {
441
- /** Numeric, and unique only WITHIN a part. Pair with `part` to address one. */
442
- readonly id: number;
443
- readonly type: RevisionType;
444
- readonly author: string;
445
- /**
446
- * OPTIONAL. `CT_TrackChange` requires `@w:id` and `@w:author` and makes `@w:date`
447
- * optional, and producers that omit it are ordinary. Requiring it here forced either a
448
- * fabricated date — a content change — or dropping the revision from the list.
449
- */
450
- readonly date?: string;
451
- /**
452
- * REQUIRED, and a canonical PART NAME rather than a three-value enum.
453
- *
454
- * `@w:id` is unique only within a part, so an address without one names two revisions in a
455
- * package that has both. The enum could not express the parts revisions actually occur in:
456
- * `header3.xml`, `footer1.xml`, `comments.xml`, and `styles.xml`, which carries
457
- * `w:pPrChange` inside style definitions with ids that collide with `document.xml`.
458
- */
459
- readonly part: string;
460
- }
461
- /** `w:sectPr`: the page a section lays out on. Twips throughout, as the file stores them. */
462
- interface SectionProperties {
463
- readonly pageSize: {
464
- widthTwips: number;
465
- heightTwips: number;
466
- };
467
- readonly margins: PageMargins;
468
- readonly columns?: {
469
- count: number;
470
- gapTwips: number;
471
- };
472
- /** `w:titlePg` — whether the section's first page takes the `first` header/footer variant. */
473
- readonly titlePage?: boolean;
474
- }
475
- /** Page margins in twips. */
476
- interface PageMargins {
477
- readonly topTwips: number;
478
- readonly rightTwips: number;
479
- readonly bottomTwips: number;
480
- readonly leftTwips: number;
481
- }
482
- /**
483
- * `styles.xml`, split by the three style families that address separately.
484
- *
485
- * Keyed by style ID rather than by the name a reader sees, because the ID is what a paragraph or
486
- * run actually references.
487
- */
488
- interface StyleDefinitions {
489
- readonly paragraph: ReadonlyMap<string, StyleDefinition>;
490
- readonly character: ReadonlyMap<string, StyleDefinition>;
491
- readonly table: ReadonlyMap<string, StyleDefinition>;
492
- }
493
- /** One style: the ID content references, the name a reader sees, and its inheritance link. */
494
- interface StyleDefinition {
495
- readonly id: string;
496
- readonly name: string;
497
- /** `w:basedOn` — the style this one inherits from. Absent at the root of a chain. */
498
- readonly basedOn?: string;
499
- }
500
- /** A paragraph's list membership: which `numbering.xml` definition, and at which level. */
501
- interface NumberingRef {
502
- readonly numId: string;
503
- /** Zero-based. OOXML numbering has nine levels, 0 through 8. */
504
- readonly level: number;
505
- }
506
- /**
507
- * A colour as the FILE expresses it, not as a resolved RGB string.
508
- *
509
- * A theme colour stays a theme reference — slot plus tint or shade — so that changing the theme
510
- * repaints the document the way Word does. Flattening to hex at read time would freeze the
511
- * resolved value and break that link. `auto` is Word's "let the renderer decide", usually black
512
- * on white.
513
- */
514
- type ColorValue = {
515
- readonly kind: 'hex';
516
- readonly value: string;
517
- } | {
518
- readonly kind: 'theme';
519
- readonly slot: string;
520
- readonly tint?: number;
521
- readonly shade?: number;
522
- } | {
523
- readonly kind: 'auto';
524
- };
525
- /** `theme1.xml` — what a {@link ColorValue} of kind `theme` resolves against. */
526
- interface Theme {
527
- readonly colorScheme: ThemeColorScheme;
528
- readonly fontScheme?: Record<string, string>;
529
- }
530
- /** Theme colour slots (`accent1`, `dk1`, `lt2`, …) to hex. */
531
- type ThemeColorScheme = Readonly<Record<string, string>>;
532
- /** A watermark, which OOXML expresses as either text or an image — never both meaningfully. */
533
- interface Watermark {
534
- readonly text?: string;
535
- readonly imageData?: Uint8Array;
536
- }
537
- /** A size in EMUs, the unit DrawingML stores extents in. 914400 EMU = 1 inch. */
538
- interface Extent {
539
- readonly widthEmu: number;
540
- readonly heightEmu: number;
541
- }
542
- /** A font the document names, and whether its bytes travel inside the package. */
543
- interface FontDefinition {
544
- readonly family: string;
545
- readonly embedded: boolean;
546
- }
547
- /** An axis-aligned rectangle in points, the unit layout works in throughout. */
548
- interface Rect {
549
- readonly x: number;
550
- readonly y: number;
551
- readonly width: number;
552
- readonly height: number;
553
- }
554
- /** A position in points. */
555
- interface Point {
556
- readonly x: number;
557
- readonly y: number;
558
- }
559
- /** What every subscription returns. Calling it twice is safe. */
560
- type Unsubscribe = () => void;
561
-
562
- export type { Block, ColorValue, ContainerRef, ContentControl, ContentControlFilter, ContentControlType, DocAnchor, DocAnchorRange, DocComment, DocLocation, DocRange, DocTarget, DocumentBody, DocxDocument, DocxDocumentJSON, ExecErrorCode, ExecResult, Extent, FontDefinition, HeaderFooterSet, IndentFormatting, InsertableContentControlType, NumberingRef, PageMargins, Paragraph, ParagraphDisagreements, ParagraphFlags, ParagraphFormatCommand, ParagraphTabStop, Point, Rect, Revision, RevisionType, Run, RunFormatting, Section, SectionProperties, SelectionPin, StyleDefinition, StyleDefinitions, Table, TableCell, TableRow, Theme, ThemeColorScheme, Unsubscribe, Watermark };