@docx-editor.dev/core 2.17.0 → 2.18.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 (107) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +2 -2
  3. package/dist/automation.cjs +1 -1
  4. package/dist/automation.d.ts +35 -8
  5. package/dist/automation.js +1 -1
  6. package/dist/binding.cjs +1 -1
  7. package/dist/binding.d.ts +9 -11
  8. package/dist/binding.js +1 -1
  9. package/dist/chunk-2ZEU42EA.js +2 -0
  10. package/dist/chunk-4DB7ZFQN.js +1 -0
  11. package/dist/chunk-4KMSEFIG.js +3 -0
  12. package/dist/chunk-72BDQFHY.js +18 -0
  13. package/dist/chunk-77DD4EBC.cjs +11 -0
  14. package/dist/chunk-BEOPUDAB.js +5 -0
  15. package/dist/chunk-CG7CP632.cjs +1 -0
  16. package/dist/chunk-CJCFEXTA.js +11 -0
  17. package/dist/chunk-DQS4KZUX.js +4 -0
  18. package/dist/chunk-FZ2BIMCY.cjs +2 -0
  19. package/dist/chunk-GUPITGJQ.cjs +2 -0
  20. package/dist/chunk-KDYD5TAW.cjs +1 -0
  21. package/dist/chunk-LQ6XWTKQ.cjs +18 -0
  22. package/dist/chunk-MDP5SNK4.cjs +3 -0
  23. package/dist/chunk-MRPPCGCX.cjs +20 -0
  24. package/dist/chunk-MSIFK7TJ.js +1 -0
  25. package/dist/chunk-NJONXJJY.cjs +4 -0
  26. package/dist/chunk-OODFC5R2.js +1 -0
  27. package/dist/chunk-P6VGDI57.js +2 -0
  28. package/dist/{chunk-UIB2MDE3.cjs → chunk-PBM6WERF.cjs} +1 -1
  29. package/dist/chunk-QBMAXYN7.js +20 -0
  30. package/dist/chunk-SUEX3CL7.cjs +5 -0
  31. package/dist/{chunk-UXAWPVH6.js → chunk-THCGTV53.js} +1 -1
  32. package/dist/{chunk-NO7U62I2.cjs → chunk-YVYEJBLL.cjs} +1 -1
  33. package/dist/chunk-ZKQX2PNF.cjs +1 -0
  34. package/dist/{chunk-XXLS6O6B.js → chunk-ZMM5RNM6.js} +1 -1
  35. package/dist/collaboration/replication.cjs +1 -1
  36. package/dist/collaboration/replication.d.ts +2 -4
  37. package/dist/collaboration/replication.js +1 -1
  38. package/dist/collaboration.cjs +1 -1
  39. package/dist/collaboration.d.ts +4 -6
  40. package/dist/collaboration.js +1 -1
  41. package/dist/contracts/editor.d.ts +9 -8
  42. package/dist/contracts/modules.d.ts +7 -9
  43. package/dist/{custom-node-writes-ClTkWM7s.d.ts → custom-node-writes-BqIv94ei.d.ts} +14 -2
  44. package/dist/document-protection-BL5zp8cU.d.ts +19 -0
  45. package/dist/{editor-BlerWPyk.d.ts → editor-WXbTSXx1.d.ts} +14 -7
  46. package/dist/editor.cjs +1 -1
  47. package/dist/editor.css +1 -1
  48. package/dist/editor.d.ts +271 -30
  49. package/dist/editor.js +1 -1
  50. package/dist/export.cjs +2 -2
  51. package/dist/export.d.ts +15 -12
  52. package/dist/export.js +2 -2
  53. package/dist/{failure-BnGjoXf0.d.ts → failure-DNNmwsgD.d.ts} +1 -1
  54. package/dist/{font-resolver-DtADJcLL.d.ts → font-resolver-BSrKnTeR.d.ts} +5 -3
  55. package/dist/harfbuzz.wasm +0 -0
  56. package/dist/{headless-document-view-BDSeMGoK.d.ts → headless-document-view-C4ttQJ5H.d.ts} +11 -3
  57. package/dist/{index-D51bUVBE.d.ts → index-C3As-Xxp.d.ts} +133 -19
  58. package/dist/index.cjs +1 -1
  59. package/dist/index.d.ts +18 -19
  60. package/dist/index.js +1 -1
  61. package/dist/{layout-shaping-rTElghj2.d.ts → layout-shaping-Dqu3JW3p.d.ts} +1 -1
  62. package/dist/layout.cjs +1 -1
  63. package/dist/layout.d.ts +23 -20
  64. package/dist/layout.js +1 -1
  65. package/dist/{note-properties-D5_fXW9K.d.ts → note-properties-RjYgbmXe.d.ts} +2 -2
  66. package/dist/{omml-equation-C9AJfWy5.d.ts → omml-equation-hcP9AUFX.d.ts} +1 -1
  67. package/dist/output.cjs +1 -1
  68. package/dist/output.d.ts +16 -6
  69. package/dist/output.js +1 -1
  70. package/dist/{protocol-K-Djpjjw.d.ts → protocol-OdRd17KZ.d.ts} +172 -7
  71. package/dist/{review-items-CiliAz8H.d.ts → review-items-CJz-kAW8.d.ts} +2 -2
  72. package/dist/{review-paragraph-order-BlSnyg9a.d.ts → review-paragraph-order--jLHXIcd.d.ts} +3 -3
  73. package/dist/{revision-projection-JiDclAFU.d.ts → revision-projection-BIHO_qvw.d.ts} +1 -1
  74. package/dist/{semantic-cell-selection-C-VsxNee.d.ts → semantic-cell-selection-lCYAVCCF.d.ts} +6 -24
  75. package/dist/{semantic-interaction-2vPh96Ey.d.ts → semantic-interaction-0vQXcMZk.d.ts} +2 -19
  76. package/dist/{semantic-paint-BEjYcsPK.d.ts → semantic-paint-BSan4pBk.d.ts} +10 -2
  77. package/dist/{semantic-records-Bc-MGXbM.d.ts → semantic-records-ZcYuB4-H.d.ts} +59 -13
  78. package/dist/store.cjs +1 -1
  79. package/dist/store.d.ts +49 -42
  80. package/dist/store.js +1 -1
  81. package/dist/{tree-op-types-C71G7rIv.d.ts → tree-op-types-DbdM7fJV.d.ts} +84 -4
  82. package/dist/{tree-package-fragment-DRJkmfTW.d.ts → tree-package-fragment-1pdDnhZ_.d.ts} +491 -23
  83. package/dist/{tree-session-contract-Cp5W25RC.d.ts → tree-session-contract-Cgn6fQ-M.d.ts} +34 -9
  84. package/package.json +4 -4
  85. package/dist/chunk-27YEILW4.cjs +0 -20
  86. package/dist/chunk-4RDCLCLB.js +0 -2
  87. package/dist/chunk-7QG5FJ4X.js +0 -1
  88. package/dist/chunk-BML3CNUT.js +0 -2
  89. package/dist/chunk-CHRMIA3I.js +0 -20
  90. package/dist/chunk-FRRMJK2G.js +0 -5
  91. package/dist/chunk-G5GLQ4SX.cjs +0 -1
  92. package/dist/chunk-JP253KIZ.cjs +0 -2
  93. package/dist/chunk-JROG4U3Z.cjs +0 -21
  94. package/dist/chunk-MBXGQN6J.js +0 -1
  95. package/dist/chunk-MDMM3XVQ.js +0 -11
  96. package/dist/chunk-NPZX5O23.cjs +0 -2
  97. package/dist/chunk-OISZDVXT.cjs +0 -5
  98. package/dist/chunk-PRNYSOQL.cjs +0 -1
  99. package/dist/chunk-RXPOTTQQ.js +0 -21
  100. package/dist/chunk-T7JERNXT.cjs +0 -2
  101. package/dist/chunk-TDMGSCCL.cjs +0 -1
  102. package/dist/chunk-VYQTZIYH.js +0 -1
  103. package/dist/chunk-W7GY2IJC.js +0 -2
  104. package/dist/chunk-ZFBNCHRP.cjs +0 -11
  105. package/dist/hf-references-kSSFMq9X.d.ts +0 -70
  106. package/dist/tree-store-BRfhZceK.d.ts +0 -416
  107. /package/dist/{dist-OSUJGKTK.js → dist-PKZR6RSH.js} +0 -0
@@ -1,70 +0,0 @@
1
- import { O as OoxmlPart, a as OoxmlNode, c as OoxmlElement, b as OoxmlPackage } from './tree-op-types-C71G7rIv.js';
2
-
3
- /** `w:headerReference w:type` vocabulary (ECMA-376 §17.10.5): default, first page, even pages. */
4
- type HeaderFooterVariant = 'default' | 'first' | 'even';
5
- /** Header vs footer region kind for chrome and lifecycle ops. */
6
- type HeaderFooterKind = 'header' | 'footer';
7
- /**
8
- * A section's resolved header and footer parts, by variant.
9
- *
10
- * The `even` variant is only honoured when `w:evenAndOddHeaders` is set in settings.xml —
11
- * without it Word ignores an authored even header, and so does this.
12
- */
13
- interface HeaderFooterParts {
14
- readonly headers: ReadonlyMap<HeaderFooterVariant, OoxmlPart>;
15
- readonly footers: ReadonlyMap<HeaderFooterVariant, OoxmlPart>;
16
- /** `w:evenAndOddHeaders` in settings.xml — without it the `even` variant is ignored. */
17
- readonly evenAndOddHeaders: boolean;
18
- /** Whether this section enables first-page header/footer furniture (`w:titlePg`). */
19
- readonly titlePage: boolean;
20
- }
21
- /**
22
- * One resolved furniture slot with enough metadata for "Same as previous" chrome.
23
- *
24
- * `inherited: true` means this section has no declared reference for the slot and the
25
- * part comes from a predecessor. The first section never reports inherited — omitting a
26
- * ref there is blank furniture, not inheritance from a later section.
27
- */
28
- interface HeaderFooterSlotMeta {
29
- readonly part: OoxmlPart;
30
- readonly partName: string;
31
- readonly rId: string;
32
- readonly inherited: boolean;
33
- }
34
- /** Per-section resolution including declared-vs-inherited metadata. */
35
- interface HeaderFooterSectionResolution {
36
- readonly headers: ReadonlyMap<HeaderFooterVariant, HeaderFooterSlotMeta>;
37
- readonly footers: ReadonlyMap<HeaderFooterVariant, HeaderFooterSlotMeta>;
38
- readonly evenAndOddHeaders: boolean;
39
- readonly titlePage: boolean;
40
- }
41
- /**
42
- * `w:sectPr` nodes in section order, aligned with layout's `enumerateDocumentSections`.
43
- *
44
- * `null` means a section with no `w:sectPr` node (Word defaults, inherits HF from previous).
45
- * Paragraph-level breaks first; the final entry covers remaining blocks (body-level or null).
46
- */
47
- declare function collectSectionPropertyNodes(root: OoxmlNode): Array<OoxmlElement | null>;
48
- /**
49
- * Resolve header/footer parts for every section with declared-vs-inherited metadata.
50
- *
51
- * Index aligns with `enumerateDocumentSections` in the layout package. Existing merged
52
- * maps stay available via {@link resolveHeaderFooterPartsBySection}.
53
- */
54
- declare function resolveHeaderFooterResolutionBySection(pkg: OoxmlPackage): readonly HeaderFooterSectionResolution[];
55
- /**
56
- * Resolve header/footer parts for every section, applying OOXML inheritance.
57
- *
58
- * Index aligns with `enumerateDocumentSections` in the layout package.
59
- */
60
- declare function resolveHeaderFooterPartsBySection(pkg: OoxmlPackage): readonly HeaderFooterParts[];
61
- /**
62
- * Resolve the main-document header/footer references to their parts, gated by the
63
- * settings the section actually declares.
64
- *
65
- * Returns the FINAL section's effective parts (after inheritance). Multi-section hosts
66
- * should prefer `resolveHeaderFooterPartsBySection`.
67
- */
68
- declare function resolveHeaderFooterParts(pkg: OoxmlPackage): HeaderFooterParts;
69
-
70
- export { type HeaderFooterVariant as H, type HeaderFooterParts as a, type HeaderFooterSectionResolution as b, type HeaderFooterKind as c, type HeaderFooterSlotMeta as d, collectSectionPropertyNodes as e, resolveHeaderFooterPartsBySection as f, resolveHeaderFooterResolutionBySection as g, resolveHeaderFooterParts as r };
@@ -1,416 +0,0 @@
1
- import { a as OoxmlNode, h as OoxmlParagraphNode, i as OoxmlNoteNode, j as OoxmlContinuationSeparatorNode, k as OoxmlEndnotesNode, l as OoxmlFootnotesNode, m as OoxmlNoteRefNode, n as OoxmlNoteReferenceNode, o as OoxmlSeparatorNode, I as ImpactClass, O as OoxmlPart, b as OoxmlPackage, T as TreeDocOp, p as TreeOpRejection } from './tree-op-types-C71G7rIv.js';
2
-
3
- /** UTF-16 placeholder for one atomic note unit in `paragraphTextOf` / segments. */
4
- declare const NOTE_ATOM_CHAR = "\uFFFC";
5
- /** Signed 32-bit Word-compatible note id range (positive allocation only). */
6
- declare const NOTE_ID_MIN = 1;
7
- /** Largest note id Word accepts — signed 32-bit. */
8
- declare const NOTE_ID_MAX = 2147483647;
9
- /** Reserved separator / continuation ids — never allocated for normal notes. */
10
- declare const NOTE_SEPARATOR_ID = -1;
11
- /** Reserved id of the continuation-separator entry. Never allocated to a real note. */
12
- declare const NOTE_CONTINUATION_SEPARATOR_ID = 0;
13
- /** Which notes part a note lives in. Decides both placement and numbering rules. */
14
- type NoteKind = 'footnote' | 'endnote';
15
- /** Authored `ST_FtnEdn` including explicit `normal`. Absent means Word default (normal). */
16
- /**
17
- * What a note entry IS.
18
- *
19
- * Only `normal` is a note a reader sees. The others are the furniture Word stores in the same
20
- * part — the rules and notices drawn around the note area — reached by reserved ids.
21
- */
22
- type NoteType = 'normal' | 'separator' | 'continuationSeparator' | 'continuationNotice';
23
- /** Parse a signed decimal note id; reject non-integers and out-of-int32 values. */
24
- declare function parseNoteId(raw: string | undefined): number | null;
25
- /**
26
- * Canonical `EditorScope { kind: 'note'; id }` encoding.
27
- *
28
- * Footnote id `1` and endnote id `1` coexist, so the kind is part of the string:
29
- * `footnote:2` / `endnote:-1`. Do not invent a parallel scope union arm.
30
- */
31
- declare function formatNoteScopeId(noteKind: NoteKind, noteId: number): string;
32
- /**
33
- * Parse {@link formatNoteScopeId}. Returns `null` for malformed / out-of-range ids.
34
- */
35
- declare function parseNoteScopeId(id: string): {
36
- readonly noteKind: NoteKind;
37
- readonly noteId: number;
38
- } | null;
39
- /** Whether a node is a `w:footnotes` part root. */
40
- declare function isFootnotesNode(node: OoxmlNode): node is OoxmlFootnotesNode;
41
- /** Whether a node is a `w:endnotes` part root. */
42
- declare function isEndnotesNode(node: OoxmlNode): node is OoxmlEndnotesNode;
43
- /** Whether a node is a `w:footnote` or `w:endnote` body. */
44
- declare function isNoteNode(node: OoxmlNode): node is OoxmlNoteNode;
45
- /** Whether a node is a body-side `w:footnoteReference` / `w:endnoteReference`. */
46
- declare function isNoteReferenceNode(node: OoxmlNode): node is OoxmlNoteReferenceNode;
47
- /** Whether a node is the `w:footnoteRef` / `w:endnoteRef` mark inside a note's own body. */
48
- declare function isNoteRefNode(node: OoxmlNode): node is OoxmlNoteRefNode;
49
- /** Whether a node is the `w:separator` rule drawn above the note area. */
50
- declare function isSeparatorNode(node: OoxmlNode): node is OoxmlSeparatorNode;
51
- /** Whether a node is the `w:continuationSeparator` rule used on continuation pages. */
52
- declare function isContinuationSeparatorNode(node: OoxmlNode): node is OoxmlContinuationSeparatorNode;
53
- /** Typed or generic `w:footnote` / `w:endnote`. */
54
- declare function noteKindOf(node: OoxmlNode): NoteKind | null;
55
- /** Authored `@w:id` on a note or noteReference when parseable. */
56
- declare function noteIdOf(node: OoxmlNode): number | null;
57
- /** Authored `@w:type` (`ST_FtnEdn`) when present and schema-legal; else `undefined`. */
58
- declare function noteTypeOf(node: OoxmlNode): NoteType | undefined;
59
- /** Whether a note is a normal (body) note — absent type and explicit `normal` both count. */
60
- declare function isNormalNote(node: OoxmlNode): boolean;
61
- /** Typed or generic footnote/endnote reference kind. */
62
- declare function noteReferenceKindOf(node: OoxmlNode): NoteKind | null;
63
- /** Typed or generic `w:footnoteRef` / `w:endnoteRef`. */
64
- declare function noteRefKindOf(node: OoxmlNode): NoteKind | null;
65
- /**
66
- * Read `@w:customMarkFollows` on a note reference.
67
- * Returns `undefined` when absent; otherwise the OOXML on/off interpretation.
68
- */
69
- declare function customMarkFollows(node: OoxmlNode): boolean | undefined;
70
- /** Model text contributed by one atomic note unit. */
71
- declare function noteAtomText(): typeof NOTE_ATOM_CHAR;
72
- /**
73
- * True when a run-inner node is a typed note atom that contributes one UTF-16 unit.
74
- * Demoted/malformed known locals stay generic and contribute nothing.
75
- */
76
- declare function isNoteAtomNode(node: OoxmlNode): boolean;
77
- /**
78
- * One atomic note span inside a paragraph for caret / delete / selection.
79
- *
80
- * Each typed note atom is a single-node span (`removeNodeIds` = that node).
81
- */
82
- interface AtomicNoteSpan {
83
- readonly kind: 'noteReference' | 'noteRef' | 'separator' | 'continuationSeparator';
84
- readonly node: OoxmlNode;
85
- readonly runId: string;
86
- readonly removeNodeIds: readonly string[];
87
- }
88
- /**
89
- * Collect typed note atoms in document order (one segment each).
90
- *
91
- * Walks the same paragraph-inline surface as `segmentsOf` / `walkParagraphInline`:
92
- * hyperlinks and content controls flatten; only direct run children contribute atoms.
93
- * A demoted run-inner SDT husk stays opaque — no phantom addressable hit.
94
- */
95
- declare function atomicNoteSpansOf(paragraph: OoxmlParagraphNode): readonly AtomicNoteSpan[];
96
- /** Cap on notes scanned when allocating / indexing a notes part. */
97
- declare const MAX_NOTES_PER_PART = 10000;
98
- /**
99
- * Allocate the next positive signed 32-bit note id for a notes-part root.
100
- *
101
- * Solo: `max(existing)+1`, the dense sequence Word writes. `null` on exhaustion, so the
102
- * caller refuses rather than wrapping onto an id a note already holds.
103
- *
104
- * With a collaboration actor bound — explicit argument, or the open store transaction — the
105
- * id is the next unused value in that actor's stripe. Two peers each adding their first
106
- * footnote from one snapshot otherwise both mint `w:id="1"`: the merge keeps both bodies
107
- * under one id, both `w:footnoteReference` marks resolve to the first, and one author's note
108
- * becomes unreachable.
109
- *
110
- * The reserved ids stay reserved either way. `0` (continuation separator) is seeded as used,
111
- * so a residue of 0 advances one class instead of taking Word's furniture, and a stripe walk
112
- * only ever climbs from a non-negative residue, so `-1` (separator) is unreachable.
113
- */
114
- declare function allocateNoteId(notesRoot: OoxmlNode, actorId?: string): number | null;
115
- /** Collect note bodies from a footnotes/endnotes root, bounded. */
116
- declare function notesOf(root: OoxmlNode): readonly OoxmlNoteNode[];
117
- /** Find a typed note by id inside a notes-part root. */
118
- declare function findNoteById(root: OoxmlNode, noteId: number): OoxmlNoteNode | undefined;
119
-
120
- /** A selection the caller wants restored when an entry is undone or redone. */
121
- /** A selection captured with a transaction, so undo restores where the caret was. */
122
- interface SelectionMark {
123
- readonly paragraphId: string;
124
- readonly start: number;
125
- readonly end: number;
126
- }
127
- /**
128
- * Which editable story a ModelChange came from.
129
- *
130
- * Mirrors `EditorScope` for body and header/footer — `{ kind: 'headerFooter'; rId }` —
131
- * so package-aware mutation and the public scope contract stay one vocabulary. Body
132
- * commits omit `rId`; header/footer commits carry the relationship id that addressed
133
- * the part. Notes parts use `{ kind: 'notesPart'; noteKind }` (one store per part).
134
- */
135
- /** Which story a transaction targets: the body, a header/footer part, or a notes part. */
136
- type TreeStoryRef = {
137
- readonly kind: 'body';
138
- readonly partName: string;
139
- } | {
140
- readonly kind: 'headerFooter';
141
- readonly partName: string;
142
- readonly rId: string;
143
- } | {
144
- readonly kind: 'notesPart';
145
- readonly partName: string;
146
- readonly noteKind: 'footnote' | 'endnote';
147
- };
148
- /**
149
- * What one committed transaction changed: the revision, the ids touched, and the impact class.
150
- *
151
- * The ids are what let layout and paint re-do only the affected blocks instead of the document.
152
- */
153
- interface TreeModelChange {
154
- readonly change: 'model-change';
155
- readonly fromRevision: number;
156
- readonly toRevision: number;
157
- readonly commitId: string;
158
- readonly origin: string;
159
- /** Stable collaboration actor attribution, when the caller supplied it. */
160
- readonly actorId?: string;
161
- /** Stable collaboration operation identity, when the caller supplied it. */
162
- readonly operationId?: string;
163
- readonly dirty: readonly string[];
164
- readonly created: readonly string[];
165
- readonly deleted: readonly string[];
166
- readonly splitJoin: readonly ({
167
- readonly split: {
168
- readonly from: string;
169
- readonly tail: string;
170
- };
171
- } | {
172
- readonly join: {
173
- readonly kept: string;
174
- readonly removed: string;
175
- };
176
- })[];
177
- readonly dependencyKeys: readonly string[];
178
- /** The widest impact among the transaction's ops — what layout must scope to. */
179
- readonly impact: ImpactClass;
180
- /**
181
- * Story that published this change. Absent on body-only store publishes that predate
182
- * package-aware targeting; `TreePackageStore` always sets it.
183
- */
184
- readonly story?: TreeStoryRef;
185
- /**
186
- * Committed collapsed caret for this transaction, when one exists.
187
- * Matches history `selectionAfter` when that mark is collapsed; absent for explicit
188
- * null, non-collapsed explicit selection, or when no caret was committed.
189
- */
190
- readonly caret?: SelectionMark;
191
- }
192
- /** Whether a transaction committed, or the typed reason it was refused. */
193
- type TransactResult = {
194
- readonly ok: true;
195
- readonly change: TreeModelChange | null;
196
- } | {
197
- readonly ok: false;
198
- readonly reason: TreeOpRejection;
199
- readonly detail?: string;
200
- };
201
- /** What a transaction body is handed: the working tree, and the means to stage ops against it. */
202
- interface TransactionContext {
203
- /** Stage one op against the STORY part. Returns false once the transaction has failed. */
204
- apply(op: TreeDocOp): boolean;
205
- /**
206
- * Stage one op against a named part.
207
- *
208
- * A comment body lives in `comments.xml` and is edited by the same ops that edit the story,
209
- * so this is `apply` with the target named rather than a second vocabulary.
210
- */
211
- applyTo(partName: string, op: TreeDocOp): boolean;
212
- /**
213
- * Stage a whole-package edit: a new part, a relationship, a content-type override.
214
- *
215
- * The edit is a pure function of the working package, so a rejected transaction discards it
216
- * with everything else. Returning the SAME package is a no-op, not a failure — a primitive
217
- * that finds nothing to do says so that way.
218
- */
219
- applyPackage(edit: (pkg: OoxmlPackage) => OoxmlPackage): boolean;
220
- /** The selection to restore when this entry is undone. */
221
- selectionBefore(selection: SelectionMark | null): void;
222
- /** The selection to restore when this entry is redone. */
223
- selectionAfter(selection: SelectionMark | null): void;
224
- }
225
- /** How one transaction behaves: its story scope, its attribution, and its selection marks. */
226
- interface TransactOptions {
227
- readonly origin?: string;
228
- /** Stable actor attribution for collaboration and audit correlation. */
229
- readonly actorId?: string;
230
- /** Stable constituent identity for collaboration duplicate correlation. */
231
- readonly operationId?: string;
232
- /**
233
- * Whether this transaction enters the legacy snapshot undo stack.
234
- *
235
- * Collaboration commits set this to false because their actor-local undo authority is the
236
- * CRDT undo manager. Omitted preserves the ordinary non-collaborative history behavior.
237
- */
238
- readonly recordsHistory?: boolean;
239
- /**
240
- * A COMMAND is one user intent that may need several ops (a toolbar click applying a
241
- * property across a multi-run selection). It is still exactly one history entry, which is
242
- * the same rule a plain transaction follows — the option exists to say so explicitly at
243
- * the call site rather than leaving it implied.
244
- */
245
- readonly scope?: 'transaction' | 'command';
246
- /**
247
- * Floor on the published impact. Header/footer story edits use `global` so every page
248
- * sharing the part invalidates rather than keeping stale furniture.
249
- */
250
- readonly minimumImpact?: ImpactClass;
251
- /** Story identity stamped onto the published ModelChange (package-aware targeting). */
252
- readonly story?: TreeStoryRef;
253
- }
254
- interface HistoryEntry {
255
- /**
256
- * The whole package as it was, not just the story part.
257
- *
258
- * Affordable for the same reason a part snapshot was: parts are immutable and deep-frozen, so
259
- * a package snapshot is a Map of references and every part the transaction did not touch is
260
- * object-identical to the one before it. Undo stays a pointer swap, and it now reverses every
261
- * part one intent wrote rather than only the story.
262
- */
263
- readonly pkg: OoxmlPackage;
264
- readonly revision: number;
265
- readonly selectionBefore: SelectionMark | null;
266
- readonly selectionAfter: SelectionMark | null;
267
- }
268
- /** How a store is constructed: its limits, its history depth, and its identity source. */
269
- interface TreeDocumentStoreOptions {
270
- /** Bound on retained history entries. Oldest entries drop first. */
271
- readonly historyLimit?: number;
272
- /**
273
- * The document's `settings.xml`, for a store built from a PART rather than a package.
274
- *
275
- * Forms protection lives one part up from the op, and a store built from a part gets a
276
- * synthetic one-part package that cannot see it — so `w:documentProtection w:edit="forms"`
277
- * was enforced in the body and nowhere else, and a header, a footer or a note accepted every
278
- * write a protected document is supposed to refuse. Read through a getter, not captured: a
279
- * document can gain or lose protection while its stories stay open.
280
- */
281
- readonly settingsPart?: () => OoxmlPart | null | undefined;
282
- }
283
- /**
284
- * Opaque document+history checkpoint for package-coordinator rollback.
285
- * Used when a story mutation may promote to a package undo unit (note-ref cascade).
286
- */
287
- /** A restorable point in history — one entry of the intent-scoped undo stack. */
288
- interface TreeDocumentCheckpoint {
289
- /**
290
- * The whole package, not one part. The store owns the package so a transaction spanning
291
- * several parts is one publication — a checkpoint of only the story part could not roll
292
- * back the comment or numbering part the same transaction wrote.
293
- */
294
- readonly pkg: OoxmlPackage;
295
- readonly revision: number;
296
- readonly undoStack: readonly HistoryEntry[];
297
- readonly redoStack: readonly HistoryEntry[];
298
- readonly composition: {
299
- readonly entry: HistoryEntry;
300
- readonly committed: boolean;
301
- } | null;
302
- }
303
- /**
304
- * The document store: one transaction is one atomic publication and one history entry.
305
- *
306
- * `apply` STAGES ops against a working part and nothing is visible until `transact` returns, so a
307
- * batch rejected halfway leaves the revision, the tree, the indexes and every subscriber exactly
308
- * as they were. That all-or-nothing property is what lets a caller compose ops without having to
309
- * reason about partial application.
310
- */
311
- declare class TreeDocumentStore {
312
- private current;
313
- /** The part `apply` targets and `part` returns: the story this store is editing. */
314
- private readonly storyPartName;
315
- private rev;
316
- private commitCounter;
317
- private readonly undoStack;
318
- private readonly redoStack;
319
- private readonly subscribers;
320
- private readonly historyLimit;
321
- /** See {@link TreeDocumentStoreOptions.settingsPart}. */
322
- private readonly settingsPartOverride;
323
- /** Package-aware story tag applied to publishes (including undo/redo). */
324
- private storyRef;
325
- /** Open composition, if any. While set, transactions extend one entry (task 5.5). */
326
- private composition;
327
- /**
328
- * Open a store over a package, editing the named story part.
329
- *
330
- * A bare part is accepted and wrapped in a single-part package, so callers that never open a
331
- * real package — tests, headless tooling — are unaffected by the widening.
332
- */
333
- constructor(source: OoxmlPart | OoxmlPackage, storyPartNameOrOptions?: string | TreeDocumentStoreOptions, maybeOptions?: TreeDocumentStoreOptions);
334
- /**
335
- * Stamp story identity onto subsequent publishes for this store (including undo/redo).
336
- * Used by the package coordinator so history navigation keeps the same scope tag.
337
- */
338
- setStoryRef(story: TreeStoryRef | null): void;
339
- /** The story part being edited. Unchanged for every caller that predates the widening. */
340
- get part(): OoxmlPart;
341
- /** Every part, including the ones a multi-part transaction wrote. */
342
- get package(): OoxmlPackage;
343
- get revision(): number;
344
- get canUndo(): boolean;
345
- get canRedo(): boolean;
346
- /** Retained entries — the unit `undo()` reverses, so tests can assert grouping. */
347
- get historyDepth(): number;
348
- get compositionActive(): boolean;
349
- /**
350
- * Replace the package OUTSIDE the transaction and history lanes.
351
- *
352
- * For package writes that are not a user intent and publish no revision: grafting
353
- * `numbering.xml` into a document that never had one, which the caller performs as a
354
- * precondition of the list op that follows. Those edits were previously kept in a package
355
- * variable beside the store, which meant two owners of one value and, predictably, two
356
- * values — a graft written to one and a save read from the other.
357
- *
358
- * Deliberately narrow and deliberately awkward to reach for: anything a user did belongs in
359
- * `transact`, where it gets a revision, an undo entry and the invariant checks.
360
- */
361
- graftPackage(edit: (pkg: OoxmlPackage) => OoxmlPackage): void;
362
- /**
363
- * Replace the current part without recording history, but advance the revision so
364
- * revision-keyed projections cannot survive a package snapshot install.
365
- */
366
- replacePart(part: OoxmlPart): void;
367
- /**
368
- * Snapshot part, revision, and undo/redo stacks so the package coordinator can roll
369
- * back a story transaction that fails after commit (e.g. note-reference cascade) or
370
- * discard a local history entry when promoting to a package undo unit.
371
- */
372
- checkpoint(): TreeDocumentCheckpoint;
373
- /** Full restore — part, revision, history stacks, and composition. */
374
- restoreCheckpoint(checkpoint: TreeDocumentCheckpoint): void;
375
- /**
376
- * Restore undo/redo stacks only, keeping the current part and revision.
377
- * Used when a story mutation is promoted to a package history pointer so the local
378
- * orphan entry does not steal a later undo.
379
- */
380
- restoreHistoryStacks(checkpoint: TreeDocumentCheckpoint): void;
381
- subscribe(listener: (change: TreeModelChange) => void): () => void;
382
- /**
383
- * Run one atomic transaction.
384
- *
385
- * Ops are staged against a working copy. On the first rejection the whole transaction is
386
- * abandoned: no revision, no history entry, no notification. On success exactly one
387
- * revision is published and exactly one history entry is recorded — unless a composition
388
- * is open, in which case the entry already exists and this transaction joins it.
389
- */
390
- transact(build: (ctx: TransactionContext) => void, options?: TransactOptions): TransactResult;
391
- private commitTransaction;
392
- /**
393
- * Open one history entry for an IME composition.
394
- *
395
- * Everything committed until `endComposition` collapses into this single entry, which is
396
- * what makes a composed word one undo step rather than one per intermediate transaction.
397
- */
398
- beginComposition(selectionBefore?: SelectionMark | null): void;
399
- /** Close the composition, recording its entry only if anything actually committed. */
400
- endComposition(): void;
401
- /**
402
- * Cancel an open composition without recording an entry, leaving whatever it committed
403
- * in place. An IME cancel is not an undo request; the caller decides what to revert.
404
- */
405
- cancelComposition(): void;
406
- undo(): TreeModelChange | null;
407
- redo(): TreeModelChange | null;
408
- /** The selection to restore for the entry `undo()` would reverse next. */
409
- selectionForUndo(): SelectionMark | null;
410
- /** The selection to restore for the entry `redo()` would reapply next. */
411
- selectionForRedo(): SelectionMark | null;
412
- private pushUndo;
413
- private publish;
414
- }
415
-
416
- export { type AtomicNoteSpan as A, isSeparatorNode as B, noteAtomText as C, noteIdOf as D, noteKindOf as E, noteRefKindOf as F, noteReferenceKindOf as G, noteTypeOf as H, notesOf as I, parseNoteId as J, parseNoteScopeId as K, MAX_NOTES_PER_PART as M, type NoteKind as N, type SelectionMark as S, type TreeModelChange as T, TreeDocumentStore as a, type TreeStoryRef as b, type TransactionContext as c, type TransactOptions as d, type TreeDocumentCheckpoint as e, NOTE_ATOM_CHAR as f, NOTE_CONTINUATION_SEPARATOR_ID as g, NOTE_ID_MAX as h, NOTE_ID_MIN as i, NOTE_SEPARATOR_ID as j, type NoteType as k, type TreeDocumentStoreOptions as l, type TransactResult as m, allocateNoteId as n, atomicNoteSpansOf as o, customMarkFollows as p, findNoteById as q, formatNoteScopeId as r, isContinuationSeparatorNode as s, isEndnotesNode as t, isFootnotesNode as u, isNormalNote as v, isNoteAtomNode as w, isNoteNode as x, isNoteRefNode as y, isNoteReferenceNode as z };
File without changes