@docx-editor.dev/core 2.14.0 → 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,613 +0,0 @@
1
- import { S as StoryScope, a as StoryTargetRejection, b as HeaderFooterParts, c as HeaderFooterSectionResolution, I as InsertImageInput, d as ImageIntentResult, R as ReplaceImageOptions, A as ApplyImagePropertiesInput, F as FragmentPasteInput, e as FragmentPasteResult } from './tree-package-fragment-Dhyw7oPm.cjs';
2
- import { T as TreeDocOp, O as OoxmlPart, a as OoxmlNode, b as OoxmlPackage, g as OoxmlElement, y as SupportedImageMime, C as ImageDecodePort, E as RevisionAttributionInput } from './tree-op-types-BUulYD5y.cjs';
3
- import { D as DocumentTrackingSettings, I as InsertCustomNodeWrite, C as CustomNodeWriteResult, a as CustomNodeSweepOutcome, E as EmbeddedFont, B as BookmarkIndex, L as ListKind } from './custom-node-writes-C46r3_5O.cjs';
4
- import { D as DocumentProperties } from './document-properties-D6Ahr8D6.cjs';
5
- import { S as SelectionMark, b as TransactOptions, T as TreeModelChange } from './tree-store-DEEQ9wz_.cjs';
6
- import { a as ReviewItem } from './review-items-CaAkgi5s.cjs';
7
- import { Node } from 'prosemirror-model';
8
- import { CollaborationDocumentPort } from './collaboration/replication.cjs';
9
-
10
- /**
11
- * Why an edited projection could not be mapped back into tree ops.
12
- *
13
- * A refusal, not a fallback. The reverse direction never RECONSTRUCTS the tree from the
14
- * projection — it explains a difference — so a shape it cannot explain is rejected outright.
15
- * A silently-dropped edit is worse than a refused one, because only the refusal can be
16
- * reconciled.
17
- */
18
- type TreeBindingRejection = 'paragraph-count-unexplained' | 'paragraph-reordered' | 'unknown-paragraph-id' | 'unknown-content-moved' | 'unsupported-node' | 'split-not-clean' | 'join-not-clean';
19
- /**
20
- * The ops explaining one edit, or the reason it could not be explained.
21
- *
22
- * `ops` is the SMALLEST set that accounts for the difference, so anything the projection does not
23
- * model — unknown nodes, lexical form, node identities — stays carried by the tree rather than
24
- * round-tripping through the editor.
25
- */
26
- type MapResult = {
27
- readonly ok: true;
28
- readonly ops: readonly TreeDocOp[];
29
- } | {
30
- readonly ok: false;
31
- readonly reason: TreeBindingRejection;
32
- readonly detail?: string;
33
- };
34
- /** Body paragraphs of a part, in document order. */
35
- declare function bodyParagraphs(part: OoxmlPart): OoxmlNode[];
36
- /** Project one tree revision into a ProseMirror doc (task 6.1). */
37
- declare function treeToDoc(part: OoxmlPart): Node;
38
- /**
39
- * Map an edited ProseMirror doc back into typed tree ops (task 6.2), or refuse (6.3).
40
- *
41
- * Handles a paragraph count delta of 0 (in-place edits), +1 (a clean split) and -1 (a clean
42
- * join). Anything else — a reorder, a multi-paragraph paste, a structural change combined
43
- * with an edit elsewhere — is refused rather than approximated, because the approximation
44
- * is what silently loses content.
45
- */
46
- declare function docToTreeOps(part: OoxmlPart, doc: Node): MapResult;
47
- /** Whether a tree node id is still present, for reconciliation checks. */
48
- declare function partHasNode(part: OoxmlPart, nodeId: string): boolean;
49
- /**
50
- * Rebuild a projected doc from a new tree revision, reusing untouched paragraphs (task 6.4).
51
- *
52
- * A full reprojection is always CORRECT, so this only ever narrows the work: paragraphs the
53
- * change did not name are carried over by reference, which lets ProseMirror keep their node
54
- * identity and redraw nothing. When the change is structural — a paragraph created, deleted,
55
- * split or joined — positions shift in ways a per-paragraph patch cannot express, so it
56
- * falls back to a full projection rather than guessing.
57
- *
58
- * Passing `null` means "no evidence available", which also takes the full path. Reconciling
59
- * on partial evidence is how a projection silently diverges from the model.
60
- */
61
- declare function reconcileDoc(previousDoc: Node, part: OoxmlPart, change: {
62
- readonly dirty: readonly string[];
63
- readonly created: readonly string[];
64
- readonly deleted: readonly string[];
65
- readonly splitJoin: readonly unknown[];
66
- } | null): Node;
67
-
68
- /**
69
- * How a style LOOKS, for a picker to preview it in its own face — Word shows the gallery
70
- * that way, and a list of identical rows makes the user apply a style to find out what it
71
- * is. PRESENTATION ONLY: these are the few properties a one-line preview can show, not the
72
- * cascade layout resolves. Every value is already bounded here (the family against the same
73
- * shape the CSS sink enforces, the colour against six hex digits), because a picker renders
74
- * them into a style attribute and they come from an attacker-controlled `styles.xml`.
75
- */
76
- interface DocumentStylePreview {
77
- readonly fontFamily: string | null;
78
- /** Points, already halved from `w:sz`. Null when the style states no size. */
79
- readonly fontSizePt: number | null;
80
- readonly bold: boolean;
81
- readonly italic: boolean;
82
- /** RRGGBB, or null for inherited/automatic — theme colours are not resolved here. */
83
- readonly color: string | null;
84
- }
85
- /** One `w:style` definition, projected for a style picker. */
86
- interface DocumentStyleEntry {
87
- readonly styleId: string;
88
- readonly name: string;
89
- readonly type: string;
90
- readonly preview: DocumentStylePreview;
91
- }
92
-
93
- /**
94
- * The scheme slots the picker shows, in Word's column order.
95
- *
96
- * Assumes the default `w:clrSchemeMapping` (bg1→lt1, t1→dk1, ...); a settings part
97
- * that remaps them is rare and a follow-up.
98
- */
99
- declare const PICKER_SLOTS: readonly ["lt1", "dk1", "lt2", "dk2", "accent1", "accent2", "accent3", "accent4", "accent5", "accent6"];
100
- type ThemeColorSlot = (typeof PICKER_SLOTS)[number];
101
- /** One theme colour: the scheme slot and its resolved six-digit hex (no '#'). */
102
- interface DocumentThemeColorEntry {
103
- readonly slot: ThemeColorSlot;
104
- readonly hex: string;
105
- }
106
- /** The theme's font slots, for resolving `w:rFonts` theme attributes. */
107
- interface DocumentThemeFonts {
108
- /** `a:majorFont` latin typeface — headings. */
109
- readonly major: string | null;
110
- /** `a:minorFont` latin typeface — body text. */
111
- readonly minor: string | null;
112
- /** `a:majorFont` east asian typeface (`a:ea`) — headings. */
113
- readonly majorEastAsia: string | null;
114
- /** `a:minorFont` east asian typeface (`a:ea`) — body text. */
115
- readonly minorEastAsia: string | null;
116
- }
117
-
118
- /** One heading of the outline, in document order. `level` is 0-based (Heading 1 = 0). */
119
- interface DocumentOutlineEntry {
120
- /** The paragraph's text, control characters flattened, bounded to 200 characters. */
121
- readonly text: string;
122
- /** 0-based outline level: `heading 1` / `outlineLvl 0` → 0. */
123
- readonly level: number;
124
- /** The paragraph's canonical node id — the address `setSelection` navigates to. */
125
- readonly blockId: string;
126
- }
127
-
128
- /** How a search is narrowed. Both flags default to off, matching Word's initial state. */
129
- interface DocumentSearchOptions {
130
- readonly matchCase?: boolean;
131
- readonly wholeWord?: boolean;
132
- /** Override the default {@link SEARCH_MATCH_LIMIT}. Clamped to it; never raised past it. */
133
- readonly limit?: number;
134
- }
135
- /**
136
- * One occurrence of a query in the body story.
137
- *
138
- * Carries the engine's own address (`blockId` + `start`) and the positional one a find UI
139
- * needs (`paragraphIndex` / `runIndex` / `runOffset`), both derived from the SAME walk —
140
- * a caller reconstructing run boundaries itself is where an off-by-one would come from.
141
- * A match can span runs when formatting changes mid-word; the run address is where it
142
- * STARTS.
143
- */
144
- interface DocumentSearchMatch {
145
- readonly blockId: string;
146
- readonly start: number;
147
- readonly length: number;
148
- readonly paragraphIndex: number;
149
- readonly runIndex: number;
150
- readonly runOffset: number;
151
- /** The matched text as it appears in the document, control characters flattened. */
152
- readonly text: string;
153
- /** Paragraph text immediately before the match, bounded and flattened. */
154
- readonly contextBefore: string;
155
- /** Paragraph text immediately after the match, bounded and flattened. */
156
- readonly contextAfter: string;
157
- }
158
- /**
159
- * What one search answers with.
160
- *
161
- * `truncated` says the scan stopped at the cap with matches still ahead of it, so a caller
162
- * can show "2000+" honestly instead of claiming an exact total it does not have.
163
- */
164
- interface DocumentSearchResult {
165
- readonly matches: readonly DocumentSearchMatch[];
166
- readonly truncated: boolean;
167
- }
168
-
169
- interface ParagraphAnchorIndex {
170
- /** nodeId → `w14:paraId`, verbatim as authored/minted. Paragraphs without one are absent. */
171
- readonly paraIdByNode: ReadonlyMap<string, string>;
172
- /** UPPERCASED paraId → nodeId (matching is case-insensitive). The first story to claim it. */
173
- readonly nodeByParaId: ReadonlyMap<string, string>;
174
- /** nodeId → reading-order ordinal, for document-ordering DocRange endpoints. */
175
- readonly ordinalByNode: ReadonlyMap<string, number>;
176
- /**
177
- * UPPERCASED paraIds more than one story claims.
178
- *
179
- * Minting is unique per PART and the contract's uniqueness is per DOCUMENT, so an authored
180
- * file may repeat one. Resolving such an anchor to whichever story came first would be a
181
- * silent wrong answer; it is refused as ambiguous instead.
182
- */
183
- readonly ambiguousParaIds: ReadonlySet<string>;
184
- /**
185
- * nodeId → the part it was indexed from.
186
- *
187
- * The index spans every story, so a caller holding one part and a node id from another reads
188
- * an empty paragraph and draws a false conclusion from it. Carrying the part alongside the id
189
- * is what keeps the two in step.
190
- */
191
- readonly partByNode: ReadonlyMap<string, OoxmlPart>;
192
- /**
193
- * Every node claiming an ambiguous paraId. DIAGNOSTIC, never a way to pick one.
194
- *
195
- * Resolution refuses a clash outright, and this is what says which paragraphs caused it, for
196
- * a reader repairing the file. Preferring one claimant by the caller's part was tried and
197
- * reverted: every resolver call site passes the MAIN part, so the preference could only ever
198
- * land on the body twin and answer `ok` for a header paragraph the caller meant. See
199
- * `resolveDocAnchor` in `editor/anchor-resolution.ts`.
200
- */
201
- readonly claimantsByParaId: ReadonlyMap<string, readonly string[]>;
202
- }
203
-
204
- /** What a run inherits at one point of the chain — null means "nothing authored". */
205
- interface StyleRunDefaults {
206
- readonly fontFamily: string | null;
207
- readonly fontSizeHalfPoints: number | null;
208
- }
209
- /** One run property as the layout records carry it (structurally SurfaceProperty). */
210
- interface RunPropertyLike {
211
- readonly localName: string;
212
- readonly attributes?: Record<string, string>;
213
- }
214
-
215
- /**
216
- * What applying ops produced: whether it committed, and why not when it did not.
217
- *
218
- * `committed` and `rejected` are separate flags because they are not opposites — a batch of zero
219
- * ops neither commits nor is rejected.
220
- */
221
- interface TreeApplyResult {
222
- readonly committed: boolean;
223
- readonly rejected: boolean;
224
- readonly opCount: number;
225
- /** Present when the edit was refused, so a host can report WHY rather than a silent no-op. */
226
- readonly reason?: TreeBindingRejection | StoryTargetRejection | string;
227
- }
228
- /** Optional collaboration attribution for a direct tree-op transaction. */
229
- type TreeApplyOptions = Pick<TransactOptions, 'origin' | 'actorId' | 'operationId' | 'recordsHistory'>;
230
- /**
231
- * One open document: the canonical tree, and the only write path into it.
232
- *
233
- * `applyTreeOps` is that path. Every mutation is a `TreeDocOp` addressed by node id plus UTF-16
234
- * offset, applied in one transaction, which is what makes cell and nested paragraphs ordinary
235
- * rather than special cases.
236
- *
237
- * Holds the whole package, not just the body — headers, footers, notes, comments and styles are
238
- * all reachable through it, and parts the engine does not model are preserved verbatim.
239
- */
240
- interface TreeDocxSessionView {
241
- /** Whether the body holds at least one editable paragraph. */
242
- readonly editable: boolean;
243
- /** Canonical node ids of the body paragraphs, in order. */
244
- paragraphIds(): string[];
245
- /**
246
- * Canonical node ids of paragraphs in a story scope. Defaults to the body.
247
- * Header/footer scopes address the part `EditorScope { kind: 'headerFooter'; rId }` names.
248
- */
249
- paragraphIdsIn(scope?: StoryScope): string[];
250
- /** The current canonical BODY part — what layout reads for the main story. */
251
- part(): OoxmlPart;
252
- /** The current part for a story scope, or null when the target is refused. */
253
- partFor(scope: StoryScope): OoxmlPart | null;
254
- /**
255
- * The current package with every opened story store merged in. Authority for layout
256
- * resolution and save — never a swapped single-part view.
257
- */
258
- currentPackage(): OoxmlPackage;
259
- /**
260
- * Commit typed tree ops directly, as ONE transaction.
261
- *
262
- * The paginated surface has no ProseMirror doc to diff, so it addresses the model the way
263
- * the ops already do — by node id and offset — rather than round-tripping an edit through
264
- * a projection just to have it diffed back out.
265
- *
266
- * `scope` defaults to the body. Pass `{ kind: 'headerFooter', rId }` to target an existing
267
- * header/footer part; the transaction publishes one ModelChange (HF → `global` impact)
268
- * and one undo unit without swapping the body store.
269
- */
270
- applyTreeOps(ops: readonly TreeDocOp[], selectionBefore?: SelectionMark | null, selectionAfter?: SelectionMark | null, scope?: StoryScope, options?: TreeApplyOptions): TreeApplyResult;
271
- /**
272
- * Commit several stories' ops as ONE transaction and ONE undo unit.
273
- *
274
- * `applyTreeOps` addresses one story; a write that must land in the body AND note parts
275
- * together — the save-time field-result refresh — needs all-or-nothing semantics, or a
276
- * mid-sequence refusal exports a file mixing refreshed and stale values and a single undo
277
- * restores only the last part. Any refusal rolls every group back. Lifecycle ops refuse.
278
- */
279
- applyTreeOpsAtomic(groups: readonly {
280
- readonly scope: StoryScope;
281
- readonly ops: readonly TreeDocOp[];
282
- }[], options?: TreeApplyOptions): TreeApplyResult;
283
- /**
284
- * Every part that holds a story, body first, then headers, footers and note parts.
285
- *
286
- * A READ: parts come from the package, so this opens no story store and spends none of the
287
- * 64 editable-store slots. Use it for any query that must answer about the whole document
288
- * rather than about the caret — an enumeration that reads only the body reports a document
289
- * the reader is not looking at.
290
- */
291
- storyParts(): readonly OoxmlPart[];
292
- /** Body text, paragraphs joined by newlines, read from the CANONICAL tree. */
293
- bodyText(): string;
294
- /** Text of a story scope, paragraphs joined by newlines. */
295
- storyText(scope: StoryScope): string | null;
296
- /** Body-store revision (independent of header/footer store revisions). */
297
- revision(): number;
298
- /** Per-story revision, or null when the target is refused. */
299
- revisionFor(scope: StoryScope): number | null;
300
- /** Package-wide revision — bumps on any story commit (body or HF). */
301
- packageRevision(): number;
302
- canUndo(): boolean;
303
- canRedo(): boolean;
304
- /**
305
- * Undo the last entry, returning the selection to restore.
306
- *
307
- * The selection is part of the entry, not something a host can recompute: after undoing a
308
- * split the caret belongs where the user was typing, and offsets in the reverted tree do
309
- * not correspond to offsets in the one that replaced it. `null` means nothing was undone
310
- * or the entry recorded no selection.
311
- */
312
- undo(): SelectionMark | null;
313
- redo(): SelectionMark | null;
314
- beginComposition(scope?: StoryScope): void;
315
- endComposition(): void;
316
- subscribe(onChange: (change: TreeModelChange) => void): () => void;
317
- /** Narrow provider-neutral attachment over this session's canonical package store. */
318
- collaborationPort(documentId: string): CollaborationDocumentPort;
319
- /** Serialize the whole package back to DOCX bytes. */
320
- save(): Uint8Array;
321
- /**
322
- * The resolved header/footer parts of the section, by variant (phase 2).
323
- *
324
- * Returns the FINAL section's effective parts after OOXML inheritance. Prefer
325
- * `headerFooterPartsBySection` for multi-section pagination.
326
- *
327
- * Re-resolved after any package revision so an edited shared part is visible everywhere
328
- * it is attached.
329
- */
330
- headerFooterParts(): HeaderFooterParts;
331
- /**
332
- * Per-section header/footer parts after OOXML inheritance, index-aligned with
333
- * `enumerateDocumentSections`.
334
- */
335
- headerFooterPartsBySection(): readonly HeaderFooterParts[];
336
- /**
337
- * Per-section resolution with declared-vs-inherited metadata for "Same as previous"
338
- * chrome. Index-aligned with `headerFooterPartsBySection`.
339
- */
340
- headerFooterResolutionBySection(): readonly HeaderFooterSectionResolution[];
341
- /**
342
- * Font family names the document uses, from every `w:rFonts` in the CURRENT main
343
- * part plus the styles and header/footer parts — validated, deduplicated, sorted.
344
- * Memoized per package revision.
345
- */
346
- documentFonts(): readonly string[];
347
- /**
348
- * Font families the document's RENDERED text resolves to, over the story roots only:
349
- * direct run `w:rFonts` of text-bearing runs plus the style chains those runs,
350
- * paragraphs and tables actually reference — never a declaration in an unused style.
351
- * Memoized per package revision.
352
- *
353
- * The font-substitution notice reads this one: `documentFonts` reports what the
354
- * document DECLARES, and Word writes latent styles (Balloon Text naming Segoe UI)
355
- * into documents that never render a character in them.
356
- */
357
- renderedFontFamilies(): readonly string[];
358
- /**
359
- * Whether the document puts any literal character on a page, over the same roots
360
- * {@link TreeDocxSessionView.documentFonts} reads. Memoized per package revision.
361
- *
362
- * The font-substitution notice needs it: `documentFonts` reports what the document
363
- * DECLARES, and a brand-new document declares Word's Calibri default over a single
364
- * empty paragraph — a declaration with no glyph behind it.
365
- */
366
- rendersText(): boolean;
367
- /** Validated style-picker projection. A document without styles answers `[]`. */
368
- documentStyles(): readonly DocumentStyleEntry[];
369
- /** Current styles root for layout, or `null` when the package has no styles part. */
370
- stylesRoot(): OoxmlElement | null;
371
- /**
372
- * The theme part's Latin typefaces, for resolving `w:rFonts` theme references in layout.
373
- *
374
- * Memoized once: theme editing is a later slice. A document with no theme part answers
375
- * `{ major: null, minor: null }`, which leaves every theme reference on the explicit
376
- * font name beside it.
377
- */
378
- documentThemeFonts(): DocumentThemeFonts;
379
- /**
380
- * Root of the numbering part tree (`w:numbering`), for list layout. Memoized once;
381
- * `null` when the package has no numbering part. Numbering editing is a later slice.
382
- */
383
- numberingRoot(): OoxmlElement | null;
384
- /**
385
- * Root of the settings part tree (`w:settings`), for document-wide layout constants such
386
- * as `w:defaultTabStop`. Memoized once; `null` when the package has no settings part.
387
- * Settings editing is a later slice, so this is immutable for the session.
388
- */
389
- settingsRoot(): OoxmlElement | null;
390
- /**
391
- * The document's own metadata from `docProps/core.xml` and `docProps/app.xml`, for
392
- * document-property fields (TITLE, AUTHOR, SUBJECT, KEYWORDS, LASTSAVEDBY, COMMENTS). Read
393
- * once per package revision; an empty object when the parts are absent.
394
- */
395
- documentProperties(): DocumentProperties;
396
- /**
397
- * What `settings.xml` says about tracking — `w:trackRevisions`, the tracked-changes
398
- * protection, and the two do-not-track switches.
399
- *
400
- * Read from the document rather than assumed, because Word records the tracking state on
401
- * the FILE: a package that asks to be edited as tracked changes, presented as an ordinary
402
- * editable one, takes its first keystroke as an untracked edit.
403
- */
404
- trackingSettings(): DocumentTrackingSettings;
405
- /**
406
- * The theme's ten picker colours (`a:clrScheme`), in Word's column order, or `[]`
407
- * when the package has no complete scheme. Memoized once: the theme part is
408
- * immutable for the session's lifetime.
409
- */
410
- documentThemeColors(): readonly DocumentThemeColorEntry[];
411
- /**
412
- * The run formatting a paragraph's content INHERITS when it authors none: the
413
- * paragraph style's `basedOn` chain, then `w:docDefaults`, with theme `rFonts`
414
- * attributes resolved through the font scheme. `runProperties` (the span's own
415
- * authored properties) lets a theme-only run-level `w:rFonts` resolve too. This is
416
- * what lets a toolbar always show the effective font, the way Word does.
417
- */
418
- effectiveRunDefaults(paragraphId: string, runProperties?: readonly RunPropertyLike[]): StyleRunDefaults;
419
- /**
420
- * The heading outline of the BODY story, in document order: paragraphs whose
421
- * `w:pStyle` resolves to a heading through the styles part (built-in `heading N`
422
- * name, or the style's own `w:outlineLvl` 0..8). Memoized per main-part revision —
423
- * an edit can retitle, add or remove a heading, but the styles part cannot change
424
- * in-session.
425
- */
426
- documentOutline(): readonly DocumentOutlineEntry[];
427
- /**
428
- * Every pending review decision in the document, memoized per revision.
429
- *
430
- * Derived from the canonical TREE — the queue is a property of the document, and one derived
431
- * from laid-out spans empties by half whenever the reader switches to a resolved view.
432
- */
433
- reviewItems(): readonly ReviewItem[];
434
- /**
435
- * Whether the document carries review content — tracked changes or comment
436
- * anchors — regardless of any review module. Derived from store vocabulary
437
- * only (never the review model), memoized per revision: it is the free
438
- * tier's honest "this document has more than you are seeing" signal.
439
- */
440
- hasReviewContent(): boolean;
441
- /**
442
- * Reply to a comment, or add one over a revision's range. Returns the new comment's id.
443
- *
444
- * `scope` names the story the anchor lives in and defaults to the body. A header or
445
- * footer anchor written against the body store addresses a paragraph that store has
446
- * never heard of, so the transaction is refused and the reply is lost — which is what
447
- * replying to a header card did.
448
- */
449
- replyToComment(parentCommentId: string | null, anchor: {
450
- paragraphId: string;
451
- start: number;
452
- end: number;
453
- endParagraphId?: string;
454
- }, text: string, author: string,
455
- /** ISO-8601. Omitted writes no `@w:date`, because inventing one is a content change. */
456
- date?: string, scope?: StoryScope,
457
- /** Binds id allocation to one actor, so two peers cannot mint the same comment id. */
458
- actorId?: string): string | null;
459
- /**
460
- * Resolve a comment thread, or reopen it. False when the document holds no such comment.
461
- *
462
- * The same package transaction shape as a reply, and for the same reason: `@w15:done` lives in
463
- * `commentsExtended.xml`, a part a document with no thread does not have, so the state and the
464
- * part that records it commit together.
465
- */
466
- setCommentResolved(commentId: string, resolved: boolean): boolean;
467
- /**
468
- * Delete a comment thread outright — body, thread state and story markers.
469
- *
470
- * A THREAD, like resolving one: a reply whose parent is gone has nothing left to answer.
471
- * `scope` names the owning story and defaults to the body; `noteId` names one note inside a
472
- * shared notes part. False when the document holds no such comment, or when the removal was
473
- * refused.
474
- */
475
- deleteComment(commentId: string, scope?: StoryScope, noteId?: number): boolean;
476
- /**
477
- * Delete several comment objects as one package transaction and one undo unit.
478
- *
479
- * A root removes its thread; a reply removes only itself and reparents any foreign nested
480
- * descendants to its parent. Marker stripping is scoped to `scope` / `noteId`.
481
- */
482
- deleteComments(comments: readonly {
483
- readonly commentId: string;
484
- readonly parentCommentId?: string;
485
- }[], scope?: StoryScope, noteId?: number): boolean;
486
- /**
487
- * Insert a custom node, with the payload it carries, as ONE transaction.
488
- *
489
- * A package write reaching through the body store, exactly as a comment is: the customXml data
490
- * part, the node inside it and the bound `w:sdt` commit together or not at all. A control bound
491
- * to a store that was never written is a document Word offers to repair.
492
- *
493
- * Omitting the payload authors the ordinary tagged control, which is what a node small enough
494
- * to live in its `w:tag` needs.
495
- */
496
- /** `scope` names the story the paragraph is in, and defaults to the body. */
497
- insertCustomNode(write: InsertCustomNodeWrite, scope?: StoryScope): CustomNodeWriteResult;
498
- /**
499
- * Remove a custom node and, in the same transaction, the payload it bound.
500
- *
501
- * The sweep would collect the payload on the next open regardless; doing it here means a
502
- * document saved between the deletion and that open does not carry a payload for a chip that
503
- * is gone.
504
- */
505
- /**
506
- * Remove a custom node and the payload it bound. `scope` names the story holding it and
507
- * defaults to the body; a chip in a header is refused against the body store.
508
- */
509
- removeCustomNode(controlNodeId: string, scope?: StoryScope): CustomNodeWriteResult;
510
- /**
511
- * Drop every payload no control binds, in the stores whose namespaces a module claims.
512
- *
513
- * Called ON OPEN and nowhere else — see `sweepCustomNodePayloads`. Answers the ids collected,
514
- * so a host can report what a document arrived carrying.
515
- */
516
- sweepCustomNodePayloads(namespaces: readonly string[]): CustomNodeSweepOutcome;
517
- /**
518
- * Every occurrence of `query` in the BODY story, in document order, addressed in the
519
- * same offset vocabulary the tree ops and the surface selection use — so a match can be
520
- * handed straight to `setSelection` without re-deriving anything.
521
- *
522
- * Memoized one deep, keyed on the revision AND the question asked: a find panel asks the
523
- * same question on every tick, and a different query replaces the entry rather than
524
- * growing a cache the session would have to bound.
525
- */
526
- findText(query: string, options?: DocumentSearchOptions): DocumentSearchResult;
527
- /**
528
- * The faces the package EMBEDS (`word/fontTable.xml` embed relationships),
529
- * deobfuscated — the only font source that needs neither a substitute nor a network.
530
- * Extraction asserts nothing about validity; admitting a face is the font resource
531
- * lane's job. Memoized once: the font table and font parts are immutable in-session.
532
- */
533
- embeddedFonts(): readonly EmbeddedFont[];
534
- /**
535
- * The `w:numId` of a bullet or numbered list definition, creating one where the document
536
- * has none — including `numbering.xml` itself, its relationship and its content type.
537
- *
538
- * A document Word has never numbered carries no numbering part at all, so the first
539
- * bullet a user asks for has to bring the whole definition with it. An existing
540
- * definition of the same kind is reused rather than duplicated.
541
- */
542
- /**
543
- * What the owning part's relationships answer for one `r:id` under `scope` (default:
544
- * body): the authored target and whether it is external. `null` for an id the part does
545
- * not declare, or when the scoped part is not open.
546
- *
547
- * Live rather than memoized: inserting a link mints a relationship mid-session, and a
548
- * cached resolver would report the link this session just created as dangling.
549
- */
550
- relationshipTarget(relationshipId: string, scope?: StoryScope): {
551
- readonly target: string;
552
- readonly external: boolean;
553
- } | null;
554
- /**
555
- * `bookmarkName -> { paragraphId, offset }` over the main part, memoized per revision.
556
- *
557
- * What an internal hyperlink's `w:anchor` resolves through. Keyed on the store revision
558
- * because an edit can move, split or delete the paragraph a bookmark sits in.
559
- */
560
- bookmarks(): BookmarkIndex;
561
- /**
562
- * The relationship id for an external hyperlink target on the part owning `scope`
563
- * (default: body), minting one if that part has none, or `null` when the URL is refused
564
- * or the scoped part cannot be resolved.
565
- *
566
- * Lives on the PACKAGE, outside `store.transact`, like the numbering definitions: the
567
- * undoable half is the tree op that names the id. An unreferenced relationship left
568
- * behind by an undo is inert and is what Word writes anyway. Scoped inserts mint onto
569
- * the story's own `.rels` so a header/footer or note link never creates a stray body
570
- * relationship.
571
- */
572
- ensureHyperlinkRelationship(url: string, scope?: StoryScope): string | null;
573
- ensureListDefinition(kind: ListKind): string | null;
574
- /**
575
- * Declare `level` in the list definition `numId` names, with Word's default format for
576
- * that depth, or answer false.
577
- *
578
- * Word never greys Increase Indent out on a list item: demoting past the deepest level
579
- * a definition declares makes Word define the level, cycling its stock bullets and
580
- * number formats. An already-declared level answers true without changing anything.
581
- *
582
- * The declaration lives on the PACKAGE, outside the store's history — undoing the edit
583
- * that needed it restores the paragraph but leaves the level declared, which is
584
- * harmless: an unreferenced level renders nothing and Word writes files full of them.
585
- */
586
- ensureNumberingLevel(numId: string, level: number, kind: ListKind): boolean;
587
- /**
588
- * The `w14:paraId` ↔ node-id index over the full editable set of the MAIN part,
589
- * memoized per revision. Every editable paragraph carries a valid, part-unique id
590
- * (established at open, maintained by the split appliers), so every paragraph is
591
- * mapped. Header/footer paragraphs become addressable through `partFor` once their
592
- * story store is open.
593
- */
594
- paragraphAnchors(): ParagraphAnchorIndex;
595
- /** `w14:paraId` of a canonical paragraph node id, verbatim, or null. */
596
- paraIdOf(nodeId: string): string | null;
597
- /** Canonical node id for a `w14:paraId`, matched case-insensitively, or null. */
598
- nodeIdOf(paraId: string): string | null;
599
- /** Insert a validated raster image as one package undo unit (task 12). */
600
- insertImage(scope: StoryScope, input: InsertImageInput): Promise<ImageIntentResult>;
601
- /** Replace a picture drawing's embedded media in one package undo unit. */
602
- replaceImage(scope: StoryScope, drawingNodeId: string, bytes: Uint8Array, mime: SupportedImageMime, decodePort: ImageDecodePort, options: ReplaceImageOptions): Promise<ImageIntentResult>;
603
- /** Delete a picture drawing and collect orphaned media in one package undo unit. */
604
- deleteImage(scope: StoryScope, drawingNodeId: string): ImageIntentResult;
605
- /** Propose the drawing's deletion as a tracked change (`w:del`); media stays untouched. */
606
- deleteImageTracked(scope: StoryScope, drawingNodeId: string, revision: RevisionAttributionInput): ImageIntentResult;
607
- /** Apply image property tree ops plus hyperlink relationship wiring atomically. */
608
- applyImageProperties(scope: StoryScope, input: ApplyImagePropertiesInput): ImageIntentResult;
609
- /** Land a clipboard fragment (resource merge + blocks) as one package undo unit. */
610
- applyFragmentPaste(scope: StoryScope, input: FragmentPasteInput): FragmentPasteResult;
611
- }
612
-
613
- export { type DocumentStyleEntry as D, type MapResult as M, type TreeDocxSessionView as T, type TreeApplyResult as a, type TreeApplyOptions as b, type TreeBindingRejection as c, bodyParagraphs as d, docToTreeOps as e, type DocumentThemeColorEntry as f, partHasNode as p, reconcileDoc as r, treeToDoc as t };