@stll/docx-core 0.43.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
- import { $r as NumberingDefinitions, Bi as HeadingOutlineLevel, Bn as RunContent, Bt as HeaderFooterType, C as Relationship, Cn as Paragraph, D as StyleDefinitions, Dn as ParagraphPropertyChange, Gn as Section, It as Footnote, Kn as SectionProperties, Ot as Endnote, S as MediaFile, Sr as TrackedChangeInfo, St as DocumentBody, Tn as ParagraphMarkChange, Ut as INSERTION_SEAM_POLICIES, Wr as AbstractNumbering, a as DocumentSettings, ei as NumberingInstance, fi as TableCellFormatting, ft as Comment, g as ExhaustiveFields, gr as TableRow, i as Document, it as BlockContent, oi as ParagraphFormatting, or as TabContent, pi as TableFormatting, s as DocxPackage, sr as Table, st as BookmarkEnd, ut as BreakContent, vi as TableRowFormatting, wn as ParagraphContent, xi as TextFormatting, zn as Run, zt as HeaderFooter } from "../document-Ca6wPoTu.js";
1
+ import { Bt as HeaderFooter, C as Relationship, Ct as DocumentBody, D as StyleDefinitions, Dn as ParagraphContent, En as Paragraph, Er as TrackedChangeInfo, Jr as AbstractNumbering, Lt as Footnote, On as ParagraphMarkChange, S as MediaFile, Si as TableRowFormatting, Ti as TextFormatting, Un as Run, Vt as HeaderFooterType, Wi as HeadingOutlineLevel, Wn as RunContent, Wt as INSERTION_SEAM_POLICIES, Xn as SectionProperties, Yn as Section, Zn as SectionPropertyChange, _i as TableFormatting, a as DocumentSettings, an as KeptCut, at as BlockContent, br as TableRow, ct as BookmarkEnd, dr as Table, dt as BreakContent, g as ExhaustiveFields, gi as TableCellFormatting, i as Document, ii as NumberingInstance, jn as ParagraphPropertyChange, kt as Endnote, pt as Comment, qn as SdtProperties, ri as NumberingDefinitions, s as DocxPackage, st as BlockSdt, ui as ParagraphFormatting, ur as TabContent } from "../document-f4_h6JMT.js";
2
+ import { a as DeepReadonly, n as PreservedChild, o as RecordField } from "../preservedMarkup-BWpGhchw.js";
2
3
  import { Result, TaggedErrorClass } from "better-result";
3
4
  /** JSON-safe map presence, including an explicitly undefined section map. */
4
5
  type SectionMapState = {
@@ -31,6 +32,22 @@ type SectionViewChange = {
31
32
  /**
32
33
  * The operation schema this module reads and writes.
33
34
  *
35
+ * Version 18 adds `comments` and `newCommentIds` to `insertContent`: a
36
+ * pasted copy of a standing comment's anchors takes a fresh comment id and a
37
+ * copy of the thread the paste carries, or is left out without one.
38
+ * Version 17 adds the `containerStart` insertion point: paragraphs or a table
39
+ * before the first block of a block list, whatever kind that block is.
40
+ * Version 16 adds `createdSince` to `restoreCommentState`: a restoration
41
+ * rebased over concurrent comment creations keeps them.
42
+ * Version 15 adds paragraph insertion beside tables and exact empty block
43
+ * replacements. Older envelopes receive an unsupportedSchema refusal; old
44
+ * operation payloads retain their meaning, with no automatic schema rewrite.
45
+ * Version 14 restores section-view topology in story lifecycle inverses.
46
+ * Older envelopes receive an unsupportedSchema refusal.
47
+ * Version 12 adds `setContentControl`, which sets a block-level content
48
+ * control's properties by its id.
49
+ * Version 11 records, as a sequenced format's effect, the run a direct
50
+ * format cut (`setRunProps` effect).
34
51
  * Version 9 adds exact, JSON-safe package resource replacement for clipboard imports.
35
52
  * Version 8 adds semantic table edits and exact whole-table restoration.
36
53
  * Version 7 adds lossless own-undefined operation snapshot presence and
@@ -53,7 +70,7 @@ type SectionViewChange = {
53
70
  * and paragraph operations, and the review operations `setParagraphReview`,
54
71
  * `replaceInline` and `resolveRevision`.
55
72
  */
56
- export declare const DOCUMENT_OP_SCHEMA_VERSION = 10;
73
+ export declare const DOCUMENT_OP_SCHEMA_VERSION = 18;
57
74
  /**
58
75
  * The main story has a fixed address; other editable parts use their stable
59
76
  * relationship id or note id. Comment bodies are not yet editable stories.
@@ -221,6 +238,7 @@ export declare const DOCUMENT_OP_TYPES: Readonly<{
221
238
  readonly DELETE_NUMBERING_INSTANCE: "deleteNumberingInstance";
222
239
  readonly SET_SECTION_ENDPOINT: "setSectionEndpoint";
223
240
  readonly SET_PACKAGE_RESOURCES: "setPackageResources";
241
+ readonly SET_CONTENT_CONTROL: "setContentControl";
224
242
  }>;
225
243
  /** One of {@link DOCUMENT_OP_TYPES}. */
226
244
  type DocumentOpType = (typeof DOCUMENT_OP_TYPES)[keyof typeof DOCUMENT_OP_TYPES];
@@ -230,8 +248,11 @@ type DocumentOpType = (typeof DOCUMENT_OP_TYPES)[keyof typeof DOCUMENT_OP_TYPES]
230
248
  * `runProps` is either {@link INHERIT_RUN_PROPS} or the exact property set the
231
249
  * text carries. When the set differs from the run at the position, the text
232
250
  * becomes a run of its own and that run is split around it; `newIds` names
233
- * the ids of the second half when the run carries some. The run decides where
234
- * the text goes, so `at.zeroWidthBefore` is not read.
251
+ * the ids of the second half when the run carries some. The text goes in
252
+ * exactly at the gap `at` names: after the zero-width leaves
253
+ * `at.zeroWidthBefore` counts (all of them when it is absent) and before the
254
+ * rest. It joins the run holding the leaf before that gap, else the one
255
+ * holding the leaf after it, whatever kind of leaf either is.
235
256
  *
236
257
  * With `revision`, the text is a tracked insertion: it is wrapped in an
237
258
  * `Insertion` carrying the stamp, cutting the records around it down to a
@@ -261,6 +282,15 @@ type InsertTextOp = {
261
282
  * {@link InsertTextOp}. It is refused inside tracked-removed content, and
262
283
  * when it holds a comment boundary or reference, which no tracked change can
263
284
  * hold.
285
+ *
286
+ * A comment owns one range. A comment anchor of the slice whose kind its
287
+ * comment already has standing in the document is a copy: when `comments`
288
+ * carries that comment's thread and the slice holds the comment's range (or
289
+ * point) whole, the thread's anchors take the ids `newCommentIds` lists and
290
+ * the thread is copied under them; otherwise those anchors are left out. An
291
+ * anchor completing a comment's range goes in as it is, a repeated one is
292
+ * left out, and a carried thread none of whose anchors stand joins the
293
+ * records unless they hold it. A thread it adds belongs to its suggestion.
264
294
  */
265
295
  type InsertContentOp = {
266
296
  type: typeof DOCUMENT_OP_TYPES.INSERT_CONTENT;
@@ -269,6 +299,17 @@ type InsertContentOp = {
269
299
  seamPolicy?: typeof INSERTION_SEAM_POLICIES.MERGE_PLAIN_RUNS;
270
300
  newIds?: NewIds;
271
301
  revision?: RevisionStamp;
302
+ /**
303
+ * The comment threads the slice carries, as a paste copies them: each
304
+ * root names, by its id, anchors of the slice; replies follow their root.
305
+ * Their paragraphs need ids the package does not use.
306
+ */
307
+ comments?: readonly Comment[];
308
+ /**
309
+ * Fresh comment ids for the carried threads a paste copies, one per
310
+ * comment of each copied thread, in carried order. Unused ones are left.
311
+ */
312
+ newCommentIds?: readonly number[];
272
313
  };
273
314
  /**
274
315
  * Remove what lies between two positions of one paragraph: its units and the
@@ -288,10 +329,12 @@ type InsertContentOp = {
288
329
  * already inside a deletion or moved away is left as it is; content inside an
289
330
  * insertion or a move gets a deletion nested inside that record; everything
290
331
  * else is wrapped in a `Deletion` carrying the stamp, an inline content
291
- * control the range covers whole going in with its content. A range holding
292
- * a comment boundary or reference is refused, since no tracked change can
293
- * hold one; `planTrackedDeletion` plans the deletions around them. A tracked
294
- * deletion joins nothing, so `join` must be absent.
332
+ * control the range covers whole going in with its content. A record the
333
+ * range covers whole goes in with the comment anchors it holds, and accepting
334
+ * the deletion removes them, as the direct deletion does. A range holding a
335
+ * bare comment boundary or reference is refused, since no tracked change
336
+ * takes one in; `planTrackedDeletion` plans the deletions around them. A
337
+ * tracked deletion joins nothing, so `join` must be absent.
295
338
  */
296
339
  type DeleteRangeOp = {
297
340
  type: typeof DOCUMENT_OP_TYPES.DELETE_RANGE;
@@ -317,11 +360,19 @@ type SplitInlineOp = {
317
360
  * already run across it. Merged records must be alike in everything but
318
361
  * their content and ids; the first's ids stand for both. Absent
319
362
  * `zeroWidthBefore` is `0`.
363
+ *
364
+ * With `ifAlike`, the join is the seam of an edit rather than a record it
365
+ * restores: records that are not alike, that carry ids the merge would
366
+ * retire, or that a run already runs across, and a position where no
367
+ * records meet are left as they are, and the operation changes nothing. Typing joins its run to alike runs this
368
+ * way, so the join still applies, or keeps out, where a concurrent edit has
369
+ * changed the records beside it.
320
370
  */
321
371
  type JoinInlineOp = {
322
372
  type: typeof DOCUMENT_OP_TYPES.JOIN_INLINE;
323
373
  at: TextPosition;
324
374
  depth: number;
375
+ ifAlike?: true;
325
376
  };
326
377
  /** Whether a tracked run patch appends an independently rejectable review. */
327
378
  export declare const PROPERTY_REVIEW_POLICIES: Readonly<{
@@ -339,6 +390,9 @@ export declare const PROPERTY_REVIEW_POLICIES: Readonly<{
339
390
  * levels once the patch is applied, as {@link JoinInlineOp} does; the inverse
340
391
  * of a patch that cut runs uses them.
341
392
  *
393
+ * Under `propertyReview: "append"`, a run patched back to the formatting its
394
+ * pending change started from keeps no pending change.
395
+ *
342
396
  * With `revision`, every run the patch changes records a tracked property
343
397
  * change (`w:rPrChange`) whose previous formatting is the run's own property
344
398
  * set before the patch. A run already carrying one keeps it, and with it the
@@ -346,6 +400,8 @@ export declare const PROPERTY_REVIEW_POLICIES: Readonly<{
346
400
  * and `joinEnd` must be absent.
347
401
  * `propertyReview: "append"` coalesces an editor action into one pending review.
348
402
  * It retains the first baseline and records the latest formatter's metadata.
403
+ * A suggestion's patch of a run whose pending change is not that suggestion's
404
+ * is refused: rejecting the suggestion would discard the other change too.
349
405
  */
350
406
  type SetRunPropsOp = {
351
407
  type: typeof DOCUMENT_OP_TYPES.SET_RUN_PROPS;
@@ -486,7 +542,11 @@ type BlockInsertionPoint = {
486
542
  blockId: string;
487
543
  };
488
544
  /**
489
- * Insert paragraphs beside an existing paragraph, with pre-minted ids.
545
+ * Insert paragraphs beside an existing paragraph or table, or at the start of
546
+ * a block list, with pre-minted ids. A table is addressed by a paragraph of
547
+ * its own, and a list by a paragraph it holds, as in TableInsertionPoint.
548
+ * Tracked table-side insertion refuses an earlier pending first-paragraph
549
+ * source owner in the same containing block list.
490
550
  * Section-bearing paragraphs are refused. With `revision`, each inserted
491
551
  * paragraph receives an inserted mark and its content an insertion wrapper.
492
552
  * A tracked insertion after a paragraph no paragraph follows marks the
@@ -499,9 +559,11 @@ type BlockInsertionPoint = {
499
559
  type InsertBlocksOp = {
500
560
  type: typeof DOCUMENT_OP_TYPES.INSERT_BLOCKS;
501
561
  story: OpStory;
502
- at: BlockInsertionPoint;
562
+ at: TableInsertionPoint;
503
563
  blocks: readonly Paragraph[];
504
564
  revision?: RevisionStamp;
565
+ /** With `revision`, the insertion is the destination of a move: `w:moveTo`. */
566
+ move?: true;
505
567
  newIds?: NewIds;
506
568
  };
507
569
  /**
@@ -522,10 +584,16 @@ type DeleteBlocksOp = {
522
584
  story: OpStory;
523
585
  blockIds: readonly string[];
524
586
  revision?: RevisionStamp;
587
+ /** With `revision`, the deletion is the source of a move: `w:moveFrom`. */
588
+ move?: true;
525
589
  newIds?: NewIds;
526
590
  };
527
591
  /**
528
- * Replace a run of adjacent paragraphs with other paragraphs.
592
+ * Replace a run of adjacent paragraphs with other paragraphs, or remove it.
593
+ * An empty replacement must preserve the containing story/cell invariants;
594
+ * its inverse inserts the exact captured paragraphs at the surviving boundary.
595
+ * Container-final marks and owned empty formatting refuse when that insertion
596
+ * cannot restore the capture exactly.
529
597
  *
530
598
  * `expected` is the paragraphs as they stand: they are found by `paraId` and
531
599
  * compared structurally (without the fields a relayout recomputes), so a
@@ -734,6 +802,24 @@ type PackageResourceMapChange<Value> = {
734
802
  next: PackageResourcePresence;
735
803
  entries: readonly PackageResourceEntryChange<Value>[];
736
804
  };
805
+ /**
806
+ * Set one content control's properties exactly: its value (`w:lastValue`,
807
+ * `w14:checked`, `w:fullDate`), placeholder state and binding. The control is
808
+ * addressed by its `w:sdtPr/w:id`, block-level or inline, in one story.
809
+ * `expected` is what its properties are now and `properties` what they become;
810
+ * the inverse swaps the two. The control's id and type do not change, and its
811
+ * content is edited by the text operations. `blockIds` names the paragraphs
812
+ * the control holds (block-level) or sits in (inline), in document order: the
813
+ * blocks a concurrent change conflicts with.
814
+ */
815
+ type SetContentControlOp = {
816
+ type: typeof DOCUMENT_OP_TYPES.SET_CONTENT_CONTROL;
817
+ story: OpStory;
818
+ controlId: number;
819
+ blockIds: readonly string[];
820
+ expected: SdtProperties;
821
+ properties: SdtProperties;
822
+ };
737
823
  /** Replace merged definitions and change keyed package entries, refusing stale package data. */
738
824
  type SetPackageResourcesOp = {
739
825
  type: typeof DOCUMENT_OP_TYPES.SET_PACKAGE_RESOURCES;
@@ -766,15 +852,37 @@ type SetSectionEndpointOp = {
766
852
  sectionMetadata?: SectionViewState;
767
853
  };
768
854
  /**
769
- * Insert a table before or after a paragraph. Tracking records each row,
770
- * cell content and cell-ending paragraph mark. At a container's end,
771
- * `terminal` moves the source content into a new preceding paragraph while
772
- * retaining the source id and fields on the untracked final paragraph.
855
+ * Where a table goes: beside a paragraph, or beside the innermost table
856
+ * holding the paragraph `blockId` names, in the block list holding that
857
+ * table, touching it, where no paragraph stands on that side to name; or,
858
+ * with `containerStart`, before the first block of the block list (a story,
859
+ * cell, note, text box or block content control) that holds the paragraph
860
+ * `blockId` names directly, whatever kind that first block is: the one place
861
+ * no paragraph or table names when the list starts with a block that holds
862
+ * no paragraph, such as an empty content control. Every container ends with
863
+ * a paragraph, so one is always there to name the list by.
864
+ */
865
+ type TableInsertionPoint = BlockInsertionPoint | {
866
+ type: "beforeTable";
867
+ blockId: string;
868
+ } | {
869
+ type: "afterTable";
870
+ blockId: string;
871
+ } | {
872
+ type: "containerStart";
873
+ blockId: string;
874
+ };
875
+ /**
876
+ * Insert a table before or after a paragraph, or beside a table. Tracking
877
+ * records each row, cell content and cell-ending paragraph mark. At a
878
+ * container's end, `terminal` moves the source content into a new preceding
879
+ * paragraph while retaining the source id and fields on the untracked final
880
+ * paragraph.
773
881
  */
774
882
  type InsertTableOp = {
775
883
  type: typeof DOCUMENT_OP_TYPES.INSERT_TABLE;
776
884
  story: OpStory;
777
- at: BlockInsertionPoint;
885
+ at: TableInsertionPoint;
778
886
  table: Table;
779
887
  revision?: RevisionStamp;
780
888
  newIds?: NewIds;
@@ -842,33 +950,39 @@ type SetSectionPropsOp = {
842
950
  patch: FormattingPatch<SectionProperties>;
843
951
  };
844
952
  /** JSON-safe lifecycle deltas: omitted fields are unowned, null restores absence. */
845
- type StoryParts = {
953
+ type StoryPartFields = {
846
954
  /** Owned fields whose source explicitly had an undefined own property. */
847
955
  undefinedFields?: readonly ({
848
956
  target: "body";
849
957
  keys: readonly (keyof NonNullable<StoryParts["body"]>)[];
850
958
  } | {
851
959
  target: "package";
852
- keys: readonly (keyof Omit<StoryParts, "body" | "sections" | "undefinedFields">)[];
960
+ keys: readonly (keyof Omit<StoryParts, "body" | "sections" | "sectionView" | "undefinedFields">)[];
853
961
  } | {
854
962
  target: "section";
855
963
  index: number;
856
964
  keys: readonly (keyof Omit<NonNullable<StoryParts["sections"]>[number], "index">)[];
857
965
  })[];
858
- body?: { [Key in keyof Omit<DocumentBody, "sections">]?: Key extends "content" ? DocumentBody[Key] : Exclude<DocumentBody[Key], undefined> | null; };
859
- /** Section contents remain derived from the body's content and are never duplicated. */
860
- sections?: readonly {
861
- index: number;
862
- properties?: Section["properties"];
863
- headers?: readonly (readonly [HeaderFooterType, HeaderFooter])[] | null;
864
- footers?: readonly (readonly [HeaderFooterType, HeaderFooter])[] | null;
865
- }[];
966
+ body?: { [Key in Exclude<RecordField<DocumentBody>, "sections">]?: Key extends "content" ? DocumentBody[Key] : Exclude<DocumentBody[Key], undefined> | null; };
866
967
  headers?: readonly (readonly [string, HeaderFooter])[] | null;
867
968
  footers?: readonly (readonly [string, HeaderFooter])[] | null;
868
969
  footnotes?: readonly Footnote[] | null;
869
970
  endnotes?: readonly Endnote[] | null;
870
971
  settings?: DocumentSettings | null;
871
972
  };
973
+ /** Section contents stay derived; a complete view and narrow metadata never overlap. */
974
+ type StoryParts = StoryPartFields & ({
975
+ sectionView?: never;
976
+ sections?: readonly {
977
+ index: number;
978
+ properties?: Section["properties"];
979
+ headers?: readonly (readonly [HeaderFooterType, HeaderFooter])[] | null;
980
+ footers?: readonly (readonly [HeaderFooterType, HeaderFooter])[] | null;
981
+ }[];
982
+ } | {
983
+ sectionView: SectionViewState;
984
+ sections?: never;
985
+ });
872
986
  /** Exact stale-checked lifecycle inverse; unrelated package parts stay untouched. */
873
987
  type RestoreStoryPartsOp = {
874
988
  type: typeof DOCUMENT_OP_TYPES.RESTORE_STORY_PARTS;
@@ -882,11 +996,16 @@ type TableEditTarget = {
882
996
  revision?: RevisionStamp;
883
997
  newIds?: NewIds;
884
998
  };
885
- /** Insert before column (including the final boundary); fresh ids are in row order. */
999
+ /**
1000
+ * Insert `count` adjacent columns (one when absent), each `width` wide,
1001
+ * before column (including the final boundary); fresh ids are in reading
1002
+ * order, row by row. Tracked, the columns share one grid change.
1003
+ */
886
1004
  type InsertColumnOp = TableEditTarget & {
887
1005
  type: typeof DOCUMENT_OP_TYPES.INSERT_COLUMN;
888
1006
  column: number;
889
1007
  width: number;
1008
+ count?: number;
890
1009
  newBlockIds: readonly string[];
891
1010
  };
892
1011
  type DeleteColumnOp = TableEditTarget & {
@@ -963,7 +1082,8 @@ type UpdateCommentContentOp = {
963
1082
  type: typeof DOCUMENT_OP_TYPES.UPDATE_COMMENT_CONTENT;
964
1083
  id: number;
965
1084
  content: readonly Paragraph[];
966
- patch?: FormattingPatch<Pick<Comment, "author" | "initials" | "date">>;
1085
+ /** `suggestionId: null` adopts a proposed comment as an ordinary one. */
1086
+ patch?: FormattingPatch<Pick<Comment, "author" | "initials" | "date" | "suggestionId">>;
967
1087
  };
968
1088
  type SetCommentResolutionOp = {
969
1089
  type: typeof DOCUMENT_OP_TYPES.SET_COMMENT_RESOLUTION;
@@ -975,6 +1095,27 @@ type DeleteCommentOp = {
975
1095
  id: number;
976
1096
  scope: "thread" | "reply";
977
1097
  };
1098
+ /**
1099
+ * A comment range marker standing between blocks rather than in a paragraph,
1100
+ * addressed by the nearest block of its own block list that holds a
1101
+ * paragraph: the nearest such block after it, or before it when none follows.
1102
+ */
1103
+ type CommentBoundaryAnchor = {
1104
+ story: OpStory;
1105
+ /** That block's first paragraph after the marker, or its last before it. */
1106
+ blockId: string;
1107
+ /** How many block lists that paragraph's own list lies below the marker's. */
1108
+ depth: number;
1109
+ /** Whether the marker stands before or after that block. */
1110
+ side: "before" | "after";
1111
+ /** How many blocks, other markers of the same comments aside, stand between the two. */
1112
+ gap: number;
1113
+ node: Extract<BlockContent, {
1114
+ type: "commentRangeStart";
1115
+ } | {
1116
+ type: "commentRangeEnd";
1117
+ }>;
1118
+ };
978
1119
  /** Exact owned comment records and the paragraph fragments containing their anchors. */
979
1120
  type CommentState = {
980
1121
  relationshipPresence: "absent" | "undefined" | "present";
@@ -993,6 +1134,12 @@ type CommentState = {
993
1134
  blockId: string;
994
1135
  content: readonly ParagraphContent[];
995
1136
  }[];
1137
+ /**
1138
+ * The owned markers standing between blocks, in document order; absent
1139
+ * when there are none. Each one's addressing paragraph is also one of
1140
+ * `anchors`, so an edit to it conflicts with the restoration.
1141
+ */
1142
+ boundaries?: readonly CommentBoundaryAnchor[];
996
1143
  };
997
1144
  type RestoreCommentStateOp = {
998
1145
  type: typeof DOCUMENT_OP_TYPES.RESTORE_COMMENT_STATE;
@@ -1001,10 +1148,17 @@ type RestoreCommentStateOp = {
1001
1148
  scaffoldIds: NewIds;
1002
1149
  expected: CommentState;
1003
1150
  state: CommentState;
1151
+ /**
1152
+ * Comments created concurrently since the restoration was captured, in the
1153
+ * order they were created: it applies as if they were absent, then each
1154
+ * takes its place again before the first comment with a greater id, as its
1155
+ * creation does. Absent when there are none.
1156
+ */
1157
+ createdSince?: readonly number[];
1004
1158
  };
1005
1159
  type CommentOp = CreateCommentOp | UpdateCommentContentOp | SetCommentResolutionOp | DeleteCommentOp | RestoreCommentStateOp;
1006
1160
  /** A schema-version-10 document operation. */
1007
- type DocumentOp = (CommentOp | CreateHeaderFooterOp | RemoveHeaderFooterOp | AddNoteOp | RemoveNoteOp | SetSectionPropsOp | RestoreStoryPartsOp | DeleteBlocksOp | InsertTableOp | DeleteTableOp | SetContainerBlocksOp | InsertBlocksOp | InsertTextOp | InsertContentOp | DeleteRangeOp | SplitInlineOp | JoinInlineOp | SetRunPropsOp | SetParagraphPropsOp | SplitBlockOp | JoinBlocksOp | ReplaceBlocksOp | SetParagraphReviewOp | ReplaceInlineOp | ResolveRevisionOp | SetRevisionInfoOp | InsertRowOp | DeleteRowOp | SetTableRowsOp | TableEditOp | SetTableOp | CreateNumberingInstanceOp | DeleteNumberingInstanceOp | SetSectionEndpointOp | SetPackageResourcesOp) & {
1161
+ type DocumentOp = (CommentOp | CreateHeaderFooterOp | RemoveHeaderFooterOp | AddNoteOp | RemoveNoteOp | SetSectionPropsOp | RestoreStoryPartsOp | DeleteBlocksOp | InsertTableOp | DeleteTableOp | SetContainerBlocksOp | InsertBlocksOp | InsertTextOp | InsertContentOp | DeleteRangeOp | SplitInlineOp | JoinInlineOp | SetRunPropsOp | SetParagraphPropsOp | SplitBlockOp | JoinBlocksOp | ReplaceBlocksOp | SetParagraphReviewOp | ReplaceInlineOp | ResolveRevisionOp | SetRevisionInfoOp | InsertRowOp | DeleteRowOp | SetTableRowsOp | TableEditOp | SetTableOp | CreateNumberingInstanceOp | DeleteNumberingInstanceOp | SetSectionEndpointOp | SetPackageResourcesOp | SetContentControlOp) & {
1008
1162
  /** Own undefined fields recorded by the operation capture boundary. */
1009
1163
  undefinedFields?: readonly (readonly string[])[];
1010
1164
  };
@@ -1024,6 +1178,34 @@ type TouchedBlocks = {
1024
1178
  modified: readonly string[];
1025
1179
  inserted: readonly string[];
1026
1180
  removed: readonly string[];
1181
+ /**
1182
+ * Removed paragraphs whose content an edit joined into another paragraph,
1183
+ * each with the paragraph that holds it now. A join keeps the second
1184
+ * paragraph's id (a paragraph mark that goes leaves the one after it); a
1185
+ * host holding a removed id re-anchors on its survivor.
1186
+ */
1187
+ absorbed?: readonly ParagraphAbsorption[];
1188
+ /**
1189
+ * Tracked changes a resolution joined into the alike change they met, the
1190
+ * pieces of one change rejoining where what stood between them went, each
1191
+ * with the change that holds their content now and keeps its id. A host
1192
+ * holding an absorbed revision id decides the survivor instead.
1193
+ */
1194
+ absorbedRevisions?: readonly RevisionAbsorption[];
1195
+ };
1196
+ /** A tracked change a resolution joined into another, and the one it joined. */
1197
+ type RevisionAbsorption = {
1198
+ /** The id no record carries any more. */
1199
+ absorbed: number;
1200
+ /** The id of the change that holds its content now. */
1201
+ survivor: number;
1202
+ };
1203
+ /** A paragraph an edit joined into another, and the paragraph it joined. */
1204
+ type ParagraphAbsorption = {
1205
+ /** The removed paragraph's id. */
1206
+ absorbed: string;
1207
+ /** The id of the paragraph that holds its content now. */
1208
+ survivor: string;
1027
1209
  };
1028
1210
  /** What applying operations produced: the document, its inverse, and the blocks it changed. */
1029
1211
  type DocumentEdit = {
@@ -1032,8 +1214,132 @@ type DocumentEdit = {
1032
1214
  inverse: readonly DocumentOp[];
1033
1215
  touched: TouchedBlocks;
1034
1216
  };
1217
+ type DocumentEditEffects = Pick<DocumentEdit, "inverse" | "touched">;
1218
+ /** Effects of edits made in turn, with their final document. */
1219
+ export declare const combineEditEffects: (final: Document, edits: readonly DocumentEditEffects[]) => DocumentEdit;
1035
1220
  /** Edits made in turn, starting from `document`, as one edit. */
1036
1221
  export declare const combineEdits: (document: Document, edits: readonly DocumentEdit[]) => DocumentEdit;
1222
+ /** Every `paraId` of every paragraph in a value, nested ones included, in document order. */
1223
+ export declare const paragraphIdsIn: (value: unknown) => string[];
1224
+ /** Every paragraph id of a package, each story walked once. */
1225
+ export declare const packageParagraphIds: (pkg: DocxPackage) => string[];
1226
+ /**
1227
+ * The key two spellings of one id share. `ST_LongHexNumber` is hex, so
1228
+ * `0000abcd` and `0000ABCD` are the same id; every lookup and comparison of
1229
+ * paragraph ids goes through this.
1230
+ */
1231
+ export declare const idKey: (id: string) => string;
1232
+ /** A paragraph id's spelling for its number. */
1233
+ export declare const formatParaId: (id: number) => string;
1234
+ export declare const ID_LEASE_KINDS: Readonly<{
1235
+ readonly PARAGRAPH: "paragraph";
1236
+ readonly REVISION: "revision";
1237
+ readonly CONTROL: "control";
1238
+ readonly COMMENT: "comment";
1239
+ }>;
1240
+ type IdLeaseKind = (typeof ID_LEASE_KINDS)[keyof typeof ID_LEASE_KINDS];
1241
+ /**
1242
+ * One past the largest id of each kind: a paragraph id stays below
1243
+ * 0x80000000, and `w:id` is a signed 32-bit integer.
1244
+ */
1245
+ export declare const ID_KIND_LIMITS: Readonly<Record<IdLeaseKind, number>>;
1246
+ /** Ids from `start` up to, not including, `end`. */
1247
+ type IdRange = {
1248
+ readonly start: number;
1249
+ readonly end: number;
1250
+ };
1251
+ /** One leased range of one id kind. */
1252
+ type IdBlock = IdRange & {
1253
+ readonly kind: IdLeaseKind;
1254
+ };
1255
+ /** The ids one author may still mint: disjoint blocks, ascending per kind. */
1256
+ type IdLease = {
1257
+ readonly blocks: readonly IdBlock[];
1258
+ };
1259
+ /** Whether `lease` holds `id` of `kind`. */
1260
+ export declare const idLeaseHolds: (lease: IdLease, kind: IdLeaseKind, id: number) => boolean;
1261
+ /** How many ids of `kind` the lease still holds. */
1262
+ export declare const idLeaseRemaining: (lease: IdLease, kind: IdLeaseKind) => number;
1263
+ /** The ids of each kind a document holds anywhere in its package. */
1264
+ type LeasedIdCensus = Readonly<Record<IdLeaseKind, ReadonlySet<number>>>;
1265
+ /** Every paragraph, revision, content-control and comment id of a document. */
1266
+ export declare const leasedIdCensus: (document: Document) => LeasedIdCensus;
1267
+ /** One id of one kind. */
1268
+ type LeasedId = {
1269
+ readonly kind: IdLeaseKind;
1270
+ readonly id: number;
1271
+ };
1272
+ /** The ids `after` holds that `before` does not, by kind and then by id. */
1273
+ export declare const introducedIds: (before: LeasedIdCensus, after: LeasedIdCensus) => LeasedId[];
1274
+ /** The IDs introduced between package versions, in the same order as the census difference. */
1275
+ export declare const introducedDocumentIds: ({ before, after }: {
1276
+ before: Document;
1277
+ after: Document;
1278
+ }) => LeasedId[];
1279
+ /**
1280
+ * `lease` without any id at or below the highest of `ids` it holds, per kind:
1281
+ * an author mints upward through its lease and never mints an id twice, so an
1282
+ * id it minted and later removed cannot meet another author's restoration of it.
1283
+ */
1284
+ export declare const trimIdLease: (lease: IdLease, ids: readonly LeasedId[]) => IdLease;
1285
+ type FreshLeasedIdsOptions = {
1286
+ lease: IdLease | undefined;
1287
+ kind: IdLeaseKind;
1288
+ count: number;
1289
+ /** Whether an id is already in use and cannot be minted. */
1290
+ taken: (id: number) => boolean;
1291
+ /** The lowest candidate, 1 by default. */
1292
+ from?: number;
1293
+ };
1294
+ /**
1295
+ * Up to `count` ids of `kind` that `taken` refuses, lowest first, from the
1296
+ * lease, or from the whole space without one. Fewer come back only when the
1297
+ * lease or the space has no more: the caller refuses the edit, never wraps.
1298
+ */
1299
+ export declare const freshLeasedIds: ({ lease, kind, count, taken, from }: FreshLeasedIdsOptions) => number[];
1300
+ /** A place between two leaves. */
1301
+ type Gap = {
1302
+ offset: number;
1303
+ zeroWidthBefore: number;
1304
+ };
1305
+ /** A node of a paragraph's content tree: a paragraph child or a run child. */
1306
+ type InlineNode = ParagraphContent | RunContent;
1307
+ /** Comment anchors are preserved by planned deletion and cannot be wrapped. */
1308
+ declare const COMMENT_ANCHOR_TYPES: {
1309
+ readonly commentRangeStart: true;
1310
+ readonly commentRangeEnd: true;
1311
+ readonly commentReference: true;
1312
+ };
1313
+ type CommentAnchorCarrier = Extract<InlineNode, {
1314
+ type: keyof typeof COMMENT_ANCHOR_TYPES;
1315
+ }>;
1316
+ /** Whether a leaf carries an anchor rather than content covered by its range. */
1317
+ export declare const isCommentAnchorCarrierType: (type: string) => boolean;
1318
+ /** The zero-width leaves at an offset, in document order. */
1319
+ export declare const zeroWidthLeavesAt: (items: readonly InlineNode[], offset: number) => InlineNode[];
1320
+ /**
1321
+ * The gap an insertion defaults to: before the first zero-width leaf at the
1322
+ * offset that opens a range, so a marker opening there stays with what
1323
+ * follows it and every other one with what precedes it.
1324
+ */
1325
+ export declare const defaultInsertionGap: (items: readonly InlineNode[], offset: number) => Gap;
1326
+ /**
1327
+ * The stretch of a paragraph's content the given revisions hold: from the
1328
+ * first leaf inside one of their tracked wrappers to the last, or `undefined`
1329
+ * when none is there.
1330
+ */
1331
+ export declare const revisionSpan: (items: readonly InlineNode[], revisionIds: ReadonlySet<number>) => {
1332
+ from: number;
1333
+ to: number;
1334
+ } | undefined;
1335
+ /** Source leaf coordinates without the ancestry needed by edit planning. */
1336
+ export declare const inlineLeafSpans: (items: readonly InlineNode[]) => {
1337
+ node: InlineNode;
1338
+ before: Gap;
1339
+ after: Gap;
1340
+ }[];
1341
+ /** Gaps in document order: by offset, then by the zero-width leaves before them. */
1342
+ export declare const compareGaps: (left: Gap, right: Gap) => number;
1037
1343
  declare const DocumentOpRefusalBase: TaggedErrorClass<"DocumentOpRefusal">;
1038
1344
  /**
1039
1345
  * Why an operation was not applied. A refused operation changes nothing: the
@@ -1046,8 +1352,6 @@ export declare const DOCUMENT_OP_REFUSAL_REASONS: Readonly<{
1046
1352
  readonly BLOCK_NOT_FOUND: "blockNotFound";
1047
1353
  /** A raw operation is missing required fields or supplies their wrong shape. */
1048
1354
  readonly INVALID_OPERATION: "invalidOperation";
1049
- /** Removing a column would leave a row with no active cells. */
1050
- readonly TABLE_ROW_EMPTY: "tableRowEmpty";
1051
1355
  /** The requested topology edit changes nothing. */
1052
1356
  readonly NO_CHANGE: "noChange";
1053
1357
  /** Removed content carries anchors or review records that require coordinated resolution. */
@@ -1075,7 +1379,8 @@ export declare const DOCUMENT_OP_REFUSAL_REASONS: Readonly<{
1075
1379
  /**
1076
1380
  * The operation would move or remove a section break (joining a paragraph
1077
1381
  * that ends a section, replacing paragraphs across or at one); that is a
1078
- * section operation.
1382
+ * section operation. Or it would put one inside a table cell, where no
1383
+ * section ends.
1079
1384
  */
1080
1385
  readonly SECTION_BOUNDARY: "sectionBoundary";
1081
1386
  /** Direct text would land inside tracked-deleted or moved-away content. */
@@ -1109,19 +1414,93 @@ export declare const DOCUMENT_OP_REFUSAL_REASONS: Readonly<{
1109
1414
  /** A replacement names no paragraph to replace, or none to put in its place. */
1110
1415
  readonly EMPTY_BLOCK_LIST: "emptyBlockList";
1111
1416
  /**
1112
- * The operation would record a tracked change over one the target already
1113
- * carries (a paragraph mark, a split that would drop a paragraph's property
1114
- * change), or would give a tracked split a mark of its own.
1417
+ * The operation would give a tracked split a mark or property change of
1418
+ * its own, or would put a pasted paragraph's review over the review the
1419
+ * destination already carries.
1115
1420
  */
1116
1421
  readonly REVISION_CONFLICT: "revisionConflict";
1422
+ /**
1423
+ * The operation cannot preserve an existing table, row, cell or grid
1424
+ * review, or would overwrite one of the same kind. Resolve it before
1425
+ * changing the table.
1426
+ */
1427
+ readonly PENDING_TABLE_CHANGE: "pendingTableChange";
1428
+ /**
1429
+ * A suggestion would fold into a run's pending property change that is not
1430
+ * its own. A run holds one property change and a suggestion is resolved by
1431
+ * its id: rejecting it would discard the other change with its own.
1432
+ */
1433
+ readonly PENDING_RUN_PROPERTY_CHANGE: "pendingRunPropertyChange";
1434
+ /**
1435
+ * A suggestion would fold into a paragraph's pending property change that
1436
+ * is not its own, for the same reason as
1437
+ * {@link DOCUMENT_OP_REFUSAL_REASONS.PENDING_RUN_PROPERTY_CHANGE}; or a
1438
+ * tracked insertion after a container's final paragraph would take over
1439
+ * the mark of one whose properties carry a pending change.
1440
+ */
1441
+ readonly PENDING_PARAGRAPH_PROPERTY_CHANGE: "pendingParagraphPropertyChange";
1442
+ /**
1443
+ * A tracked join would run a paragraph, through one whose own mark is
1444
+ * already going, into the table after it while that table's first row or
1445
+ * cell has a pending insertion and cannot receive what runs in.
1446
+ */
1447
+ readonly JOIN_INTO_PENDING_TABLE: "joinIntoPendingTable";
1117
1448
  /** The operation would put a mark on a paragraph that ends its story body or table cell. */
1118
1449
  readonly CONTAINER_FINAL_MARK: "containerFinalMark";
1450
+ /**
1451
+ * A paragraph break inside an inline content control: the control lives in
1452
+ * one paragraph, so the break has no form.
1453
+ */
1454
+ readonly INSIDE_INLINE_CONTROL: "insideInlineControl";
1119
1455
  /**
1120
1456
  * No tracked change can record the edit, or no resolution op can carry it
1121
1457
  * out yet: comment boundaries in a tracked range, the paragraph mark's run
1122
1458
  * properties, a join at a section break, a record inside a field.
1123
1459
  */
1124
1460
  readonly UNTRACKABLE: "untrackable";
1461
+ /**
1462
+ * A tracked paragraph would take over the mark of a paragraph whose break
1463
+ * is pending deletion or moving away. No placement of that record keeps
1464
+ * both laws: accepting equals the direct edit, and rejecting the insertion
1465
+ * alone gives the original back.
1466
+ */
1467
+ readonly PENDING_BREAK_TAKEOVER: "pendingBreakTakeover";
1468
+ /**
1469
+ * A tracked operation would record a change of a paragraph mark whose
1470
+ * break is pending deletion (deleted, moving away, or added and then
1471
+ * deleted), which holds one such record: joining or deleting through it,
1472
+ * putting a table or row against it, or, after a container's final
1473
+ * paragraph, taking it over, since the container's new final paragraph
1474
+ * keeps no record a pending change moves to it.
1475
+ */
1476
+ readonly PENDING_PARAGRAPH_MARK_DELETION: "pendingParagraphMarkDeletion";
1477
+ /**
1478
+ * As {@link DOCUMENT_OP_REFUSAL_REASONS.PENDING_PARAGRAPH_MARK_DELETION},
1479
+ * for a paragraph mark whose break is pending insertion (inserted or moved
1480
+ * here) and not deleted since.
1481
+ */
1482
+ readonly PENDING_PARAGRAPH_MARK_INSERTION: "pendingParagraphMarkInsertion";
1483
+ /**
1484
+ * A paragraph the operation would edit separately joins the next one
1485
+ * through a mark pending deletion (deleted or moving away): accepting that
1486
+ * deletion gives the joined paragraph the next paragraph's properties, so
1487
+ * the edit would land on another paragraph or merge two named ones.
1488
+ */
1489
+ readonly PENDING_PARAGRAPH_JOIN: "pendingParagraphJoin";
1490
+ /**
1491
+ * A tracked column insertion in a table whose columns already carry a
1492
+ * pending change. A table records one previous grid (`w:tblGridChange`), so
1493
+ * a second insertion could not be rejected alone: the columns of one change
1494
+ * go in one operation (`InsertColumnOp.count`).
1495
+ */
1496
+ readonly PENDING_GRID_CHANGE: "pendingGridChange";
1497
+ /**
1498
+ * A suggested link change would leave a piece of a link holding only
1499
+ * bookmark or comment markers, or would copy content that names a record of
1500
+ * its own (preserved run markup, a marker inside a copied text box, or a
1501
+ * note holding a tracked change, comment or bookmark).
1502
+ */
1503
+ readonly UNRECORDABLE_LINK_SUGGESTION: "unrecordableLinkSuggestion";
1125
1504
  /** Seed contract: a main-story paragraph has no `paraId`. */
1126
1505
  readonly MISSING_BLOCK_ID: "missingBlockId";
1127
1506
  /** Seed contract: two paragraphs in the package carry one id. */
@@ -1140,41 +1519,21 @@ export declare class DocumentOpRefusal extends DocumentOpRefusalBase<{
1140
1519
  message: string;
1141
1520
  reason: DocumentOpRefusalReason;
1142
1521
  opType: DocumentOpType | undefined;
1522
+ /** Paragraph-mark revision that would move text across a standing range boundary. */
1523
+ blockedParagraphMarkRevisionId?: number;
1143
1524
  }> {}
1144
- /** A place between two leaves. */
1145
- type Gap = {
1146
- offset: number;
1147
- zeroWidthBefore: number;
1148
- };
1149
- /** A node of a paragraph's content tree: a paragraph child or a run child. */
1150
- type InlineNode = ParagraphContent | RunContent;
1151
- /** Comment anchors are preserved by planned deletion and cannot be wrapped. */
1152
- declare const COMMENT_ANCHOR_TYPES: {
1153
- readonly commentRangeStart: true;
1154
- readonly commentRangeEnd: true;
1155
- readonly commentReference: true;
1156
- };
1157
- type CommentAnchorCarrier = Extract<InlineNode, {
1158
- type: keyof typeof COMMENT_ANCHOR_TYPES;
1159
- }>;
1160
- /** Whether a leaf carries an anchor rather than content covered by its range. */
1161
- export declare const isCommentAnchorCarrierType: (type: string) => boolean;
1162
- /** The zero-width leaves at an offset, in document order. */
1163
- export declare const zeroWidthLeavesAt: (items: readonly InlineNode[], offset: number) => InlineNode[];
1164
1525
  /**
1165
- * The gap an insertion defaults to: before the first zero-width leaf at the
1166
- * offset that opens a range, so a marker opening there stays with what
1167
- * follows it and every other one with what precedes it.
1168
- */
1169
- export declare const defaultInsertionGap: (items: readonly InlineNode[], offset: number) => Gap;
1170
- /** Source leaf coordinates without the ancestry needed by edit planning. */
1171
- export declare const inlineLeafSpans: (items: readonly InlineNode[]) => {
1172
- node: InlineNode;
1173
- before: Gap;
1174
- after: Gap;
1175
- }[];
1176
- /** Gaps in document order: by offset, then by the zero-width leaves before them. */
1177
- export declare const compareGaps: (left: Gap, right: Gap) => number;
1526
+ * What a run of a story's blocks adds to the document's comment anchors, as
1527
+ * {@link commentDocumentIssue} reads them: each anchor's kind and id in
1528
+ * document order, those of the run's own blocks, then those of the text
1529
+ * boxes inside them. A range marker between blocks attaches to a paragraph
1530
+ * beside it, which may lie outside the run, so the sequence also marks which
1531
+ * markers wait for the run's first paragraph and which are held past its
1532
+ * last, or that it has no paragraph. Two runs alike here leave the issue as
1533
+ * it was when one replaces the other in the same story, whatever blocks
1534
+ * surround it.
1535
+ */
1536
+ export declare const commentAnchorSequence: (blocks: readonly BlockContent[]) => string[];
1178
1537
  type CommentExhaustionInput = {
1179
1538
  type: "document";
1180
1539
  document: Document;
@@ -1184,22 +1543,38 @@ type CommentExhaustionInput = {
1184
1543
  anchorKind: Comment["anchorKind"];
1185
1544
  survivingNonCarrierContent: boolean;
1186
1545
  };
1187
- /** Whether a statically ranged comment currently covers no document content. */
1546
+ /** Whether a known range lost its content or a known point lost its anchor. */
1188
1547
  export declare const isCommentExhausted: (input: CommentExhaustionInput) => boolean;
1189
1548
  /** Comment definitions whose root remains covered or projected, with replies. */
1190
1549
  export declare const survivingComments: (document: Document, projectedRootIds?: ReadonlySet<number>) => Comment[];
1191
1550
  /** Remove each supplied root and its recursive replies, preserving input order. */
1192
1551
  export declare const withoutCommentThreads: (comments: readonly Comment[], removedRootIds: ReadonlySet<number>) => Comment[];
1552
+ /**
1553
+ * Root comments without any owned source anchor. Loaded packages may carry
1554
+ * them; they stay preserved as read-only entries rather than refusing the
1555
+ * document, and no comment operation may create or target one.
1556
+ */
1557
+ export declare const orphanRootCommentIds: (document: Document) => Set<number>;
1193
1558
  /**
1194
1559
  * Shared loaded-comment activation contract; legacy parentId revision associations stay explicit.
1195
1560
  * `allowedOrphans` names unanchored root comments the caller accepts ("all" for a loaded package).
1196
1561
  */
1197
1562
  export declare const commentDocumentIssue: (document: Document, allowedOrphans?: ReadonlySet<number> | "all") => string | undefined;
1198
- /** Allocate from the package's annotation domains without a hidden mutable counter. */
1199
- export declare const freshCommentId: (document: Document) => Result<number, DocumentOpRefusal>;
1563
+ /**
1564
+ * Allocate from the package's annotation domains without a hidden mutable
1565
+ * counter: one past every annotation id, the lowest free one once the
1566
+ * highest id is taken, or, for an author holding a lease, the lowest leased
1567
+ * comment id no annotation carries.
1568
+ */
1569
+ export declare const freshCommentId: (document: Document, lease?: IdLease) => Result<number, DocumentOpRefusal>;
1200
1570
  /** Reconcile modeled comment and numbering parts with their document relationships. */
1201
1571
  export declare const reconcileDocumentPartRelationships: (document: Document) => Document;
1202
1572
  type CopyOriginAncestorList = NonNullable<BookmarkEnd["copyOriginAncestors"]>;
1573
+ /**
1574
+ * Whether a copy of `node` carries copy ancestry: true of bookmark and move
1575
+ * range boundaries, false of comment boundaries and anything else.
1576
+ */
1577
+ export declare const recordsCopyOrigin: (node: InlineNode) => boolean;
1203
1578
  export declare const isCopyOriginAncestors: (value: unknown) => value is CopyOriginAncestorList;
1204
1579
  export declare const shiftCopyOriginAncestors: (origins: CopyOriginAncestorList | undefined, insertedOrdinal: number) => CopyOriginAncestorList | undefined;
1205
1580
  export declare const addCopyOriginAncestor: (origins: CopyOriginAncestorList | undefined, addedOrdinal: number) => CopyOriginAncestorList | undefined;
@@ -1211,23 +1586,206 @@ type RejectedCopyOriginAncestors = {
1211
1586
  copyOriginAncestors?: CopyOriginAncestorList;
1212
1587
  };
1213
1588
  export declare const rejectCopyOriginAncestors: (origins: CopyOriginAncestorList | undefined, removedAddedAncestors: number) => RejectedCopyOriginAncestors;
1589
+ /** Tracked insertions, deletions and moves. */
1590
+ type TrackedWrapper = Extract<InlineNode, {
1591
+ type: "insertion" | "deletion" | "moveFrom" | "moveTo";
1592
+ }>;
1593
+ /** The review fields a paragraph states, each only when present. */
1594
+ export declare const reviewFieldsOf: (paragraph: ParagraphReviewFields) => ParagraphReviewFields;
1595
+ type SeamJoins = NonNullable<TrackedWrapper["resolutionJoins"]>;
1596
+ /**
1597
+ * Kept markers a change's joins name in review history version 1: the
1598
+ * revision they were kept from and how many boundaries they are, nearest
1599
+ * the seam (all of those standing there when no count is given).
1600
+ */
1601
+ type VersionOneKeptMarkers = {
1602
+ keptFrom: string;
1603
+ keptCount?: number;
1604
+ };
1605
+ /**
1606
+ * What review history version 1 wrote on a change about kept markers: those
1607
+ * its own joins name (`change`), and those each of its deferred seam groups
1608
+ * names, by the group's place in `deferredRemove`.
1609
+ */
1610
+ type VersionOneKept = {
1611
+ change?: VersionOneKeptMarkers;
1612
+ groups: readonly (VersionOneKeptMarkers | undefined)[];
1613
+ };
1614
+ /** {@link withKeptCutsFromChanges} over a paragraph's content. */
1615
+ export declare const paragraphKeptCutsFromChanges: (content: readonly ParagraphContent[], writtenOnChange: (joins: SeamJoins) => VersionOneKept | undefined) => ParagraphContent[];
1616
+ /**
1617
+ * Whether `cut` is a well-formed kept cut: exactly its fields, kept from a
1618
+ * dated revision, naming one side as its piece if any. The contract and the
1619
+ * review history reader share it.
1620
+ */
1621
+ export declare const isKeptCut: (cut: unknown) => cut is KeptCut;
1622
+ type NoteDeletionOpsOptions = {
1623
+ /** The document before the tracked edit. */
1624
+ before: Document;
1625
+ /** The document the tracked edit left. */
1626
+ after: Document;
1627
+ /** The edit's stamp: the notes whose last live reference it deleted follow it. */
1628
+ stamp: RevisionStamp;
1629
+ /** Ids the note records may take; those `after` holds are passed over. */
1630
+ revisionIds: readonly number[];
1631
+ };
1632
+ /** The operations deleting notes with their references, and the revision ids their records took. */
1633
+ type NoteDeletion = {
1634
+ ops: readonly DocumentOp[];
1635
+ revisions: readonly number[];
1636
+ };
1637
+ /**
1638
+ * The operations deleting the notes whose last live reference, in any
1639
+ * story, a tracked edit deleted: each note's text and paragraph marks,
1640
+ * deleted by the reference deletion's author at its date, as the reference
1641
+ * implementation records it. Rejecting the reference's deletion gives the
1642
+ * note its text back, and accepting it removes the note. A suggestion stays
1643
+ * its author's until it is accepted, so it deletes no note.
1644
+ *
1645
+ * The edit itself leaves the notes alone, so an operation touches only the
1646
+ * paragraphs it names; a compiler emitting the edit appends these.
1647
+ */
1648
+ export declare const noteDeletionOps: ({ before, after, stamp, revisionIds }: NoteDeletionOpsOptions) => Result<NoteDeletion, DocumentOpRefusal>;
1214
1649
  export declare const noteUsesCustomMark: (document: Document, note: Footnote | Endnote) => boolean;
1650
+ type WithParagraphCopiesOptions = {
1651
+ document: Document;
1652
+ story: OpStory;
1653
+ /**
1654
+ * Each paragraph of the story, at any depth or in a text box drawn there,
1655
+ * and the copy that takes its place.
1656
+ */
1657
+ copies: ReadonlyMap<Paragraph, Paragraph>;
1658
+ };
1659
+ /**
1660
+ * `document` with paragraphs of `story`, at any depth, replaced by copies
1661
+ * that hold the same value under every field, in its section views too. A
1662
+ * copy may differ only in what is kept for it outside its fields, which the
1663
+ * contract never reads, so the result meets the contract when `document` is
1664
+ * known to.
1665
+ */
1666
+ export declare const withParagraphCopies: ({ document, story, copies }: WithParagraphCopiesOptions) => Document;
1667
+ type WithParagraphRenderingsOptions = {
1668
+ document: Document;
1669
+ story: OpStory;
1670
+ /**
1671
+ * Each paragraph of the story, at any depth or in a text box drawn there,
1672
+ * and its list rendering normalized.
1673
+ */
1674
+ renderings: ReadonlyMap<Paragraph, Paragraph>;
1675
+ };
1676
+ /**
1677
+ * `document` with paragraphs of `story` replaced by ones whose list rendering
1678
+ * was normalized: each may differ from the paragraph it replaces only in its
1679
+ * list rendering and the formatting fields that rendering derives, which the
1680
+ * contract never reads, so the result meets the contract when `document` is
1681
+ * known to. A rendering depends on where its paragraph stands, so a paragraph
1682
+ * the story holds at more than one place has no one rendering: then the
1683
+ * result is undefined, and the caller replaces the story's blocks by place.
1684
+ */
1685
+ export declare const withParagraphRenderings: ({ document, story, renderings }: WithParagraphRenderingsOptions) => Document | undefined;
1686
+ /** Capture only fields owned by the lifecycle delta; absent values survive JSON as null. */
1687
+ export declare const captureStoryParts: (document: Document, owned: StoryParts) => StoryParts;
1215
1688
  export declare const sectionPropertiesAt: (document: Document, sectionIndex: number) => SectionProperties | undefined;
1216
- export declare const sameStory: (left: OpStory, right: OpStory) => boolean;
1217
- export declare const findStoryBody: (document: Document, story: OpStory) => DocumentBody | undefined;
1218
- export declare const storyBody: (document: Document, story: OpStory) => DocumentBody;
1689
+ /**
1690
+ * A text box's `w:txbxContent`: a story drawn in a paragraph of another
1691
+ * story. Its paragraphs share the package's paragraph id space, so an
1692
+ * operation names them through the story that draws the box (see
1693
+ * `textBoxRouting.ts`); this address exists only while an operation is
1694
+ * applied to the box's own body.
1695
+ */
1696
+ type TextBoxStory = {
1697
+ readonly kind: "textBox";
1698
+ /** The story whose paragraph draws the box. */
1699
+ readonly host: StoryAddress;
1700
+ /** That paragraph's `w14:paraId`. */
1701
+ readonly blockId: string;
1702
+ /** Which of the paragraph's text boxes, in leaf order. */
1703
+ readonly index: number;
1704
+ };
1705
+ /** A package story, or a text box inside one. */
1706
+ type StoryAddress = OpStory | TextBoxStory;
1219
1707
  export declare const documentStories: (document: Document) => OpStory[];
1708
+ /**
1709
+ * Whether `story` lacks the paragraph a story ends with: the one a caret goes
1710
+ * in and a reader shows after a final table. The body, headers, footers and
1711
+ * notes end with one (a table cell already reads the paragraph it implies);
1712
+ * a story that ends in a table or holds no paragraph gains an empty one. A
1713
+ * separator note is left as read.
1714
+ */
1715
+ export declare const storyLacksClosingParagraph: (document: Document, story: OpStory) => boolean;
1716
+ type ReplaceStoryBodyOptions = {
1717
+ document: Document;
1718
+ story: StoryAddress;
1719
+ body: DocumentBody;
1720
+ };
1721
+ export declare const replaceStoryBody: ({ document, story, body }: ReplaceStoryBodyOptions) => Document;
1722
+ /** One step from a block list down to a block list nested in one of its blocks. */
1723
+ type BlockListStep = {
1724
+ kind: "tableCell";
1725
+ block: number;
1726
+ row: number;
1727
+ cell: number;
1728
+ } | {
1729
+ kind: "blockSdt";
1730
+ block: number;
1731
+ } | {
1732
+ kind: "blockCustomXml";
1733
+ block: number;
1734
+ };
1735
+ /** Where a paragraph sits: the block list that holds it, and its index there. */
1736
+ type ParagraphLocation = {
1737
+ list: readonly BlockListStep[];
1738
+ index: number;
1739
+ paragraph: Paragraph;
1740
+ };
1741
+ /** Every paragraph of a story's block tree, in document order. */
1742
+ export declare const storyParagraphs: (body: DocumentBody) => ParagraphLocation[];
1220
1743
  /**
1221
1744
  * A body holding other blocks, its section view derived from them. A view
1222
1745
  * that does not line up with the blocks (a different section count) is left
1223
1746
  * for {@link sectionsInStep} to report.
1224
1747
  */
1225
1748
  export declare const withBodyContent: (body: DocumentBody, content: BlockContent[]) => DocumentBody;
1749
+ /** The paragraph and its physical siblings, within the same body, wrapper or cell. */
1750
+ export declare const locateParagraphInBlockList: (body: DocumentBody, blockId: string) => {
1751
+ paragraph: Paragraph;
1752
+ blocks: readonly BlockContent[];
1753
+ index: number;
1754
+ } | undefined;
1755
+ /**
1756
+ * The content of each text box drawn in `story`, at any depth, a box before
1757
+ * the boxes drawn in it.
1758
+ */
1759
+ export declare const textBoxContentsIn: (document: Document, story: OpStory) => readonly (readonly BlockContent[])[];
1760
+ type CloseTextBoxesOptions = {
1761
+ document: Document;
1762
+ story: OpStory;
1763
+ /** A new empty paragraph, with an id of its own. */
1764
+ closing: () => Paragraph;
1765
+ };
1766
+ /**
1767
+ * `document` with an empty paragraph after the blocks of each text box drawn
1768
+ * in `story`, nested ones included, that end without one: a text box is a
1769
+ * container, and a container ends with a paragraph.
1770
+ */
1771
+ export declare const withTextBoxesClosed: ({ document, story, closing }: CloseTextBoxesOptions) => Document;
1772
+ /** A story's own paragraphs, then those of each text box drawn in it. */
1773
+ export declare const paragraphsThroughTextBoxes: (document: Document, story: OpStory) => ParagraphLocation[];
1774
+ /**
1775
+ * The paragraph `blockId` names in `story` and its physical siblings: one of
1776
+ * the story's own, or one in a text box drawn there.
1777
+ */
1778
+ export declare const locateParagraphThroughTextBoxes: (document: Document, story: OpStory, blockId: string) => ReturnType<typeof locateParagraphInBlockList>;
1779
+ /** The innermost block-level control holding a paragraph, and every paragraph it holds. */
1780
+ export declare const blockControlHolding: (blocks: readonly BlockContent[], blockId: string) => {
1781
+ control: BlockSdt;
1782
+ paragraphs: Paragraph[];
1783
+ } | undefined;
1226
1784
  /**
1227
1785
  * The zero-width items a paragraph can hold, and whether each is content its
1228
1786
  * mark must not take away. None is. A range boundary is a position, not
1229
- * content: a paragraph that goes leaves it where the paragraph was
1230
- * (`paragraphRemains` in `rangeBoundaries.ts`), so it keeps no blank
1787
+ * content: a paragraph that goes hands it to the nearest paragraph that
1788
+ * stays (`paragraphRemains` in `rangeBoundaries.ts`), so it keeps no blank
1231
1789
  * paragraph standing. A comment reference remains one logical offset unit,
1232
1790
  * but moves as an anchor when its paragraph goes. A cached page break and a
1233
1791
  * note's own marker mark nothing a reader placed.
@@ -1263,6 +1821,13 @@ export declare const paragraphContentVerdict: ({ width, zeroWidthItems }: {
1263
1821
  }) => ParagraphContentVerdict;
1264
1822
  /** The number of logical units in a paragraph: its largest valid offset. */
1265
1823
  export declare const paragraphLength: (paragraph: Paragraph) => number;
1824
+ /** A comment reference and the offset of the unit it takes. */
1825
+ type CommentReferenceOffset = {
1826
+ id: number;
1827
+ offset: number;
1828
+ };
1829
+ /** Where each comment reference of a paragraph stands, in document order. */
1830
+ export declare const commentReferenceOffsets: (paragraph: Paragraph) => CommentReferenceOffset[];
1266
1831
  /** The character a unit that is not run text stands for in {@link paragraphLogicalText}. */
1267
1832
  export declare const OBJECT_REPLACEMENT_CHARACTER = "";
1268
1833
  /**
@@ -1272,37 +1837,46 @@ export declare const OBJECT_REPLACEMENT_CHARACTER = "";
1272
1837
  */
1273
1838
  export declare const paragraphLogicalText: (paragraph: Paragraph) => string;
1274
1839
  /** The single structural outcome of resolving a paragraph mark. */
1275
- export declare const paragraphMarkOutcome: ({ follows, holdsContent, markWasAdded, containerStillEndsWithParagraph, followingTableCanReceiveRunIn, needsFollowingCommentHost, tableRemovalIsTrackable, removedSectionProperties, precedingSectionOwner, followingHasSectionProperties }: {
1276
- follows: "paragraph" | "table" | "nothing";
1840
+ export declare const paragraphMarkOutcome: ({ follows, holdsContent, markWasAdded, containerStillEndsWithParagraph, followingTableCanReceiveRunIn, holdsContentOnceAccepted, followingBlockCanReceiveRunIn, needsFollowingCommentHost, tableRemovalIsTrackable, emptyInsertedTableBoundary, precededByBlock }: {
1841
+ /** `block` is a follower {@link isOpaqueFollower} admits. */
1842
+ follows: "paragraph" | "table" | "block" | "nothing";
1277
1843
  /** From {@link paragraphHoldsContent} or the editor's view of the same rule, never re-derived. */
1278
1844
  holdsContent: ParagraphContentVerdict;
1279
1845
  markWasAdded: boolean;
1280
1846
  /**
1281
- * Read only when nothing follows: whether the block BEFORE this paragraph,
1282
- * which becomes the container's last block once this one is removed, is a
1283
- * paragraph. Never the container's current last child, which is this one.
1847
+ * Read when nothing or a block follows. When nothing does: whether the
1848
+ * block BEFORE this paragraph, which becomes the container's last block
1849
+ * once this one is removed, is a paragraph; never the container's current
1850
+ * last child, which is this one. When a block does: whether the container's
1851
+ * last block is a paragraph.
1284
1852
  */
1285
1853
  containerStillEndsWithParagraph: boolean;
1286
1854
  followingTableCanReceiveRunIn: boolean;
1855
+ /**
1856
+ * Read when a block follows: whether the paragraph still holds content
1857
+ * once every change in it is accepted, from
1858
+ * {@link paragraphHoldsContentOnceAccepted}.
1859
+ */
1860
+ holdsContentOnceAccepted?: ParagraphContentVerdict;
1861
+ /** Read when a block follows: whether it offers a {@link paragraphBlockRunInTarget}. */
1862
+ followingBlockCanReceiveRunIn?: boolean;
1287
1863
  needsFollowingCommentHost?: boolean;
1288
1864
  tableRemovalIsTrackable?: boolean;
1289
- removedSectionProperties?: boolean;
1290
- precedingSectionOwner?: "unavailable" | "available" | "same" | "occupied";
1291
- followingHasSectionProperties?: boolean;
1292
- }) => ({
1865
+ /** Only a pending-review boundary proved free of source section/structure blockers. */
1866
+ emptyInsertedTableBoundary?: "unavailable" | "pendingReview";
1867
+ /** Whether a block stays before the paragraph to anchor what its removal leaves. */
1868
+ precededByBlock?: boolean;
1869
+ }) => {
1293
1870
  kind: "join";
1294
- } & SectionTransfer) | ({
1871
+ } | {
1295
1872
  kind: "remove";
1296
- } & SectionTransfer) | ({
1873
+ } | {
1297
1874
  kind: "run-in";
1298
- } & SectionTransfer) | ({
1875
+ } | {
1299
1876
  kind: "keep";
1300
- } & SectionTransfer) | ({
1877
+ } | {
1301
1878
  kind: "refuse";
1302
1879
  reason: "untrackable";
1303
- } & SectionTransfer);
1304
- type SectionTransfer = {
1305
- sectionDestination: "none" | "preceding" | "following";
1306
1880
  };
1307
1881
  declare const BOUNDARY_SIDES: {
1308
1882
  readonly bookmarkStart: {
@@ -1346,19 +1920,10 @@ type CommentAnchor$1 = CommentAnchorCarrier;
1346
1920
  /** A boundary a block list holds between its blocks. */
1347
1921
  type BlockBoundary = Exclude<Boundary, CommentAnchor$1>;
1348
1922
  /**
1349
- * What a paragraph that goes whole leaves where it was: every bookmark and
1350
- * move range boundary it holds, at any depth, as blocks in its place, and its
1351
- * comment anchors for the nearest paragraph that stays to take. When a
1352
- * comment needs that host, every carrier travels there together in source
1353
- * order. A comment with both anchors there becomes a point there, so the
1354
- * comment and its anchor survive the paragraph.
1923
+ * Whether a block-list entry is a range boundary standing between blocks. A
1924
+ * block list holds no comment anchor, so every boundary in it is one of these.
1355
1925
  */
1356
- export declare const paragraphRemains: (content: readonly InlineNode[]) => {
1357
- all: (Boundary | CommentAnchor$1)[];
1358
- blocks: BlockBoundary[];
1359
- comments: CommentAnchor$1[];
1360
- placement: "blocks" | "previous";
1361
- };
1926
+ export declare const isBlockBoundary: (block: BlockContent) => block is BlockBoundary;
1362
1927
  /** One range boundary in document order, as {@link planWellFormedRanges} reads it. */
1363
1928
  type BoundaryOccurrence = {
1364
1929
  /** The marker's element and id: what two copies of one boundary share. */
@@ -1368,6 +1933,18 @@ type BoundaryOccurrence = {
1368
1933
  side: "start" | "end";
1369
1934
  /** Whether a rejection kept it from removed content. */
1370
1935
  kept: boolean;
1936
+ /**
1937
+ * Whether it is a copy an added revision still owns (its
1938
+ * `copyOriginAncestors`): rejecting that revision takes it away, so it is
1939
+ * never the boundary itself.
1940
+ */
1941
+ copied: boolean;
1942
+ /**
1943
+ * Whether its kind records copies in copy ancestry, as bookmark and move
1944
+ * range boundaries do. Comment boundaries record none, so a kept one the
1945
+ * story holds otherwise is taken for a copy.
1946
+ */
1947
+ copiesMarked: boolean;
1371
1948
  /**
1372
1949
  * The date of the revision a kept boundary came from. Of a kept start and
1373
1950
  * end out of order, the one kept from the later revision moves: that edit
@@ -1387,21 +1964,37 @@ type WellFormedRangePlan = {
1387
1964
  };
1388
1965
  /**
1389
1966
  * The one rule that makes every range a rejection kept boundaries of
1390
- * well-formed, for the engine's model and the editor's document alike. A
1391
- * kept copy of a boundary the story still holds is no boundary of its own and
1392
- * goes (of several kept copies, the first stays); then, where such a range's
1393
- * end comes before its start, the half the rejection kept closes on the
1394
- * other: a kept end moves to just after the start, or else a kept start to
1395
- * just before the end. A boundary that was standing never moves, and a range
1396
- * still with more than one start or end is left as it is.
1967
+ * well-formed, for the engine's model and the editor's document alike.
1968
+ *
1969
+ * A bookmark or move range boundary that records copies never goes here,
1970
+ * whatever else the story holds: one without copy ancestry is the boundary
1971
+ * itself, and one with it goes only when its owner is rejected. Dropping
1972
+ * either because another occurrence stands would make the result depend on
1973
+ * which resolution came first, since accepting a copy leaves it standing as
1974
+ * inserting it directly does. A comment boundary records no copies, so a
1975
+ * kept one goes where the story holds it otherwise (of several kept and
1976
+ * nothing else, the first stays).
1977
+ *
1978
+ * A copy an added revision still owns that stands counts for no range's
1979
+ * order. Then, where such a range's end comes before its start, the
1980
+ * half the rejection kept closes on the other: a kept end moves to just
1981
+ * after the start, or else a kept start to just before the end. A boundary
1982
+ * that was standing never moves, and a range still with more than one start
1983
+ * or end is left as it is.
1397
1984
  */
1398
1985
  export declare const planWellFormedRanges: (occurrences: readonly BoundaryOccurrence[]) => WellFormedRangePlan;
1399
1986
  /** Capture own undefined fields before an operation enters its JSON journal. */
1400
1987
  export declare const captureDocumentOp: (op: DocumentOp) => DocumentOp;
1988
+ /**
1989
+ * The ids of the comments pending suggestions propose: every one, or those of
1990
+ * one suggestion. A reply is removed with the comment it answers.
1991
+ */
1992
+ export declare const suggestedCommentIds: (document: Document, suggestionId?: string) => number[];
1401
1993
  /**
1402
1994
  * The document as a save writes it: every pending suggestion rejected. A
1403
1995
  * suggestion is a proposal the host holds, not a change in the file, so the
1404
- * file reads as if it had never been made; ordinary tracked changes stay.
1996
+ * file reads as if it had never been made; ordinary tracked changes stay. A
1997
+ * comment a suggestion proposes is left out with it.
1405
1998
  */
1406
1999
  export declare const withoutPendingSuggestions: (document: Document) => Result<Document, DocumentOpRefusal>;
1407
2000
  /**
@@ -1409,8 +2002,65 @@ export declare const withoutPendingSuggestions: (document: Document) => Result<D
1409
2002
  * id, in document order.
1410
2003
  */
1411
2004
  export declare const suggestionRevisionInfos: (document: Document, story: OpStory, suggestionId: string) => TrackedChangeInfo[];
1412
- /** The ids of every pending suggestion in a document, in every story. */
2005
+ /**
2006
+ * The ids of every pending suggestion in a document, in every story, and of
2007
+ * every suggestion that proposes a comment.
2008
+ */
1413
2009
  export declare const pendingSuggestionIdsIn: (document: Document) => Set<string>;
2010
+ /** A document an operation produced, the operations that undo it, and what it changed. */
2011
+ type AppliedDocumentOp = {
2012
+ document: Document;
2013
+ /** Apply in order to restore the input document. */
2014
+ inverse: readonly DocumentOp[];
2015
+ touched: TouchedBlocks;
2016
+ /**
2017
+ * Newly allocated tracked revision ids, in document order: its stamp's
2018
+ * id and the new ids its other records took. Existing ids retained by a
2019
+ * folded or continued review are excluded; a direct operation reports none.
2020
+ */
2021
+ revisions: readonly number[];
2022
+ /**
2023
+ * Existing revision ids whose pending property changes the operation
2024
+ * folded its edit into, in document order: the changes now carry its
2025
+ * stamp and record the properties it set, so accepting or rejecting one
2026
+ * of them accepts or rejects the edit too. Disjoint from `revisions`; a
2027
+ * direct operation reports none.
2028
+ */
2029
+ folded: readonly number[];
2030
+ };
2031
+ /** The revision ids a tracked operation's records carry. */
2032
+ type RecordedRevisionIds = Pick<AppliedDocumentOp, "revisions" | "folded">;
2033
+ /**
2034
+ * The revision ids of operations applied in turn, as one operation's: every
2035
+ * step's new ids, and the existing ids a step folded into that no step of
2036
+ * them allocated.
2037
+ */
2038
+ export declare const combineRecordedRevisions: (steps: readonly RecordedRevisionIds[]) => RecordedRevisionIds;
2039
+ /** Apply one operation to a document that meets the seed contract. */
2040
+ export declare const applyDocumentOp: (document: Document, input: DocumentOp) => Result<AppliedDocumentOp, DocumentOpRefusal>;
2041
+ /** Apply a journal envelope only when its schema matches this reader. */
2042
+ export declare const applyDocumentOpEnvelope: (document: Document, envelope: {
2043
+ schema: number;
2044
+ op: DocumentOp;
2045
+ }) => Result<AppliedDocumentOp, DocumentOpRefusal>;
2046
+ /**
2047
+ * An inverse whose whole-part restores expect the parts they meet when the
2048
+ * inverse runs, in order, on `document`.
2049
+ *
2050
+ * A restore records the parts its operation left, and refuses as stale when
2051
+ * the document it meets holds other ones. A caller that changes the document
2052
+ * after an operation (a derivation over the whole document, such as list
2053
+ * rendering) and puts its own inverse first rebases the restores onto that
2054
+ * document, so undo meets exactly what each restore expects. The inverse is
2055
+ * returned as it is when it holds no restore, or when it does not apply.
2056
+ */
2057
+ export declare const inverseMeetingDocument: (document: Document, inverse: readonly DocumentOp[]) => readonly DocumentOp[];
2058
+ /**
2059
+ * Apply operations in order, atomically: the first refusal is returned and
2060
+ * the document is unchanged. The inverse undoes the whole list, and
2061
+ * `revisions` lists each operation's in turn.
2062
+ */
2063
+ export declare const applyDocumentOps: (document: Document, ops: readonly DocumentOp[]) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1414
2064
  type HyperlinkEditorIntent = {
1415
2065
  type: "setHyperlink";
1416
2066
  from: TextPosition;
@@ -1430,10 +2080,18 @@ type HyperlinkEditorIntent = {
1430
2080
  href: string;
1431
2081
  tooltip?: string;
1432
2082
  };
2083
+ /** Accepted-view text without changing the canonical paragraph or its offset space. */
2084
+ export declare const paragraphVisibleText: (paragraph: Paragraph) => string;
1433
2085
  type SplitParagraphIntent = {
1434
2086
  type: "splitParagraph";
1435
2087
  at: TextPosition;
1436
2088
  to?: TextPosition;
2089
+ /**
2090
+ * Which half takes the new identity: by default the first, as typing a
2091
+ * break moves the text before it to a paragraph of its own; the second
2092
+ * keeps the paragraph's identity on the text before the split.
2093
+ */
2094
+ newHalf?: SplitHalf;
1437
2095
  };
1438
2096
  /**
1439
2097
  * A row inserted into, or deleted from, the table holding `blockId`. An
@@ -1443,31 +2101,64 @@ type SplitParagraphIntent = {
1443
2101
  type TableRowIntentOperation = Omit<InsertRowOp, "revision" | "newIds"> | Omit<DeleteRowOp, "revision" | "newIds">;
1444
2102
  /**
1445
2103
  * A table inserted after the paragraph `blockId`, with an empty paragraph
1446
- * after it, as the editor inserts one; or the table holding `blockId`,
2104
+ * after it, as the editor inserts one, or between the blocks beside that
2105
+ * paragraph alone; or the table holding `blockId`,
1447
2106
  * removed, or in suggesting mode recorded as deleted. An inserted table's
1448
2107
  * paragraphs take fresh identities from the compiler.
1449
2108
  */
1450
- type TableBlockIntentOperation = Omit<DeleteTableOp, "revision" | "newIds" | "expected"> | {
2109
+ type TableBlockIntentOperation = Omit<DeleteTableOp, "revision" | "newIds" | "expected"> | ({
1451
2110
  type: typeof DOCUMENT_OP_TYPES.INSERT_TABLE;
1452
2111
  story: OpStory;
1453
2112
  blockId: string;
1454
2113
  table: Table;
1455
2114
  /**
1456
- * Where the table goes against the anchor paragraph: after it (the
2115
+ * Where the table goes against the anchor: after it (the
1457
2116
  * default, as from a caret), or before it, as from a selection of the
1458
2117
  * whole story, which the editor fills at the story's start.
1459
2118
  */
1460
2119
  side?: "after" | "before";
2120
+ } & ({
2121
+ /** Existing callers default to a paragraph anchor. */
2122
+ anchor?: "paragraph";
1461
2123
  /**
1462
2124
  * An empty paragraph ahead of the table as well, as the editor writes
1463
2125
  * a table it inserts after another, so the two never touch.
1464
2126
  */
1465
2127
  separated?: boolean;
1466
- };
2128
+ /**
2129
+ * The empty paragraph after the table: written, as the editor gives
2130
+ * the caret a place after a table it inserts (the default), or left
2131
+ * out, for a table that goes between blocks already standing on both
2132
+ * sides of it.
2133
+ */
2134
+ paragraphAfter?: "empty" | "none";
2135
+ } | {
2136
+ /** Beside the innermost table holding blockId, without added paragraphs. */
2137
+ anchor: "table";
2138
+ separated?: never;
2139
+ paragraphAfter?: never;
2140
+ } | {
2141
+ /**
2142
+ * Before the first block of the block list holding blockId, without
2143
+ * added paragraphs: where no paragraph or table names the place.
2144
+ */
2145
+ anchor: "containerStart";
2146
+ side?: never;
2147
+ separated?: never;
2148
+ paragraphAfter?: never;
2149
+ }));
1467
2150
  /** Positions use canonical physical offsets, including retained deleted content. */
1468
2151
  type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
1469
2152
  type: "table";
1470
2153
  operation: TableIntentOperation;
2154
+ /**
2155
+ * What each cell an inserted column creates holds, in row order: the
2156
+ * compiler writes it into the new cells after the column, as text
2157
+ * typed there, so a suggestion records it as inserted. A cell past
2158
+ * the list, or given no paragraphs, stays empty. Only a column
2159
+ * insertion takes it.
2160
+ */
2161
+ cellContent?: readonly (readonly Paragraph[])[];
1471
2162
  } | {
1472
2163
  type: "tableRow";
1473
2164
  operation: TableRowIntentOperation;
@@ -1476,14 +2167,32 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
1476
2167
  operation: TableBlockIntentOperation;
1477
2168
  } | {
1478
2169
  /**
1479
- * Whole paragraphs beside a paragraph, which keeps its identity: the
1480
- * compiler gives each a fresh id, and a suggestion records each as
1481
- * inserted.
2170
+ * Whole paragraphs beside a paragraph or table: the compiler gives
2171
+ * each a fresh id, and a suggestion records each as inserted. Table-side
2172
+ * suggestions refuse boundaries without a reversible review plan.
1482
2173
  */
1483
2174
  type: "insertParagraphs";
1484
2175
  story: OpStory;
1485
- at: BlockInsertionPoint;
2176
+ at: TableInsertionPoint;
1486
2177
  paragraphs: readonly Paragraph[];
2178
+ /** A suggestion records the paragraphs as a move's destination. */
2179
+ move?: true;
2180
+ /** A list instance the paragraphs' numbering names, created first. */
2181
+ newList?: NewListInstance;
2182
+ } | {
2183
+ /** Whole adjacent paragraphs removed with their marks. */
2184
+ type: "deleteParagraphs";
2185
+ story: OpStory;
2186
+ blockIds: readonly string[];
2187
+ /** A suggestion records the paragraphs as a move's source. */
2188
+ move?: true;
2189
+ /**
2190
+ * Tracked, what the deletion does with the paragraphs a pending join
2191
+ * runs into the first one (`paragraphsJoinedInto`), read as the
2192
+ * document stands when it compiles: `deleted`, they go with it, as the
2193
+ * joined paragraph they make carries its id.
2194
+ */
2195
+ joinedWords?: "deleted";
1487
2196
  } | {
1488
2197
  type: "replaceFragment";
1489
2198
  from: TextPosition;
@@ -1504,6 +2213,13 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
1504
2213
  from: TextPosition;
1505
2214
  to: TextPosition;
1506
2215
  text: string;
2216
+ /** Where each piece of the inserted text takes its authored formatting. */
2217
+ formattingSources?: readonly {
2218
+ /** Exclusive UTF-16 offset in `text`, with contiguous pieces. */
2219
+ end: number;
2220
+ at: TextPosition;
2221
+ type: "character" | "caret";
2222
+ }[];
1507
2223
  runProps?: TextFormatting;
1508
2224
  runPropsPatch?: RunPropsPatch;
1509
2225
  /**
@@ -1524,6 +2240,8 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
1524
2240
  type: "formatParagraph";
1525
2241
  at: TextPosition;
1526
2242
  patch: ParagraphPropsPatch;
2243
+ /** A list instance the patch's numbering names, created first. */
2244
+ newList?: NewListInstance;
1527
2245
  } | {
1528
2246
  type: "setList";
1529
2247
  items: readonly {
@@ -1558,10 +2276,17 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
1558
2276
  */
1559
2277
  survivor?: SplitHalf;
1560
2278
  };
2279
+ /** A numbering instance, with its abstract definition, an edit creates. */
2280
+ type NewListInstance = {
2281
+ num: NumberingInstance;
2282
+ abstractNum?: AbstractNumbering;
2283
+ };
1561
2284
  /** Revision metadata and every fresh identity are supplied before compilation. */
1562
2285
  type EditorIntentMode = {
1563
2286
  /** Identities consumed during this editor lifetime, including undone insertions. */
1564
2287
  reservedBlockIds?: ReadonlySet<string>;
2288
+ /** The only ids the compiler may mint, when the author holds a lease. */
2289
+ idLease?: IdLease;
1565
2290
  } & ({
1566
2291
  type: "editing";
1567
2292
  newIds?: NewIds;
@@ -1570,20 +2295,45 @@ type EditorIntentMode = {
1570
2295
  revision: RevisionStamp;
1571
2296
  newIds: NewIds;
1572
2297
  });
2298
+ /**
2299
+ * Where text an intent adds takes its formatting from: the caret's, as typing
2300
+ * continues the run it stands in, or the body text's, as an operation's text
2301
+ * is body text and never continues a note reference.
2302
+ */
2303
+ export declare const TYPED_TEXT_FORMATTING: Readonly<{
2304
+ readonly CARET: "caret";
2305
+ readonly BODY_TEXT: "bodyText";
2306
+ }>;
2307
+ type TypedTextFormatting = (typeof TYPED_TEXT_FORMATTING)[keyof typeof TYPED_TEXT_FORMATTING];
1573
2308
  type CompileEditorIntentOptions = {
1574
2309
  intent: EditorIntent;
1575
2310
  mode: EditorIntentMode;
2311
+ /** By default the caret's. */
2312
+ typedFormatting?: TypedTextFormatting;
2313
+ /** Source before this operation's other replacement pieces are compiled. */
2314
+ replacementFormattingDocument?: Document;
1576
2315
  /** Lowest candidate for compiler-owned pasted block IDs, including retired session IDs. */
1577
2316
  firstBlockId?: number;
1578
2317
  };
1579
2318
  type CompiledEditorIntent = {
1580
2319
  ops: DocumentOp[];
1581
2320
  selection: TextPosition;
2321
+ /**
2322
+ * What applying `ops` to the compiled document gives, when the compiler
2323
+ * already applied exactly them; a caller applies `ops` itself otherwise.
2324
+ */
2325
+ applied?: AppliedDocumentOp;
1582
2326
  };
1583
2327
  /** A split's paragraph identity is allocated with its other fresh identities. */
1584
2328
  type EditorIntentAllocation = EditorIntent | SplitParagraphIntent;
1585
- /** Cache only immutable document versions; never retain a retired version strongly. */
1586
- export declare const createEditorIntentIdAllocator: () => (document: Document, intent: EditorIntentAllocation) => {
2329
+ /**
2330
+ * Cache only immutable document versions; never retain a retired version
2331
+ * strongly. A new paragraph identity avoids `reservedBlockIds`, the ones
2332
+ * consumed elsewhere, such as an undone insertion's.
2333
+ */
2334
+ export declare const createEditorIntentIdAllocator: ({ reservedBlockIds }?: {
2335
+ reservedBlockIds?: ReadonlySet<string>;
2336
+ }) => (document: Document, requested: EditorIntentAllocation, lease?: IdLease) => {
1587
2337
  revisionId: number;
1588
2338
  newBlockId: string;
1589
2339
  newIds: {
@@ -1591,8 +2341,6 @@ export declare const createEditorIntentIdAllocator: () => (document: Document, i
1591
2341
  control: number[];
1592
2342
  };
1593
2343
  };
1594
- /** Accepted-view text without changing the canonical paragraph or its offset space. */
1595
- export declare const paragraphVisibleText: (paragraph: Paragraph) => string;
1596
2344
  /**
1597
2345
  * Right-affine translation: a visible gap follows retained deleted content at
1598
2346
  * that gap, so a new insertion never lands inside a deletion wrapper.
@@ -1605,12 +2353,70 @@ export declare const editorParagraphGroups: (document: Document, story: OpStory)
1605
2353
  paragraphs: Paragraph[];
1606
2354
  text: string;
1607
2355
  }[];
2356
+ /**
2357
+ * {@link editorParagraphGroups} of `story` and of every text box drawn in it,
2358
+ * each box grouped within its own story: a box's paragraphs are named
2359
+ * through the story drawing it, and a mark pending deletion in a box joins
2360
+ * the box's next paragraph.
2361
+ */
2362
+ export declare const editorParagraphGroupsThroughTextBoxes: (document: Document, story: OpStory) => ReturnType<typeof editorParagraphGroups>;
1608
2363
  /** One logical paragraph and visible offset for a physical canonical address. */
1609
2364
  export declare const editorPositionAtPhysicalPosition: (document: Document, at: TextPosition) => TextPosition;
1610
2365
  /** Translate an editing-view paragraph gap to its physical canonical address. */
1611
2366
  export declare const physicalPositionAtEditorOffset: (document: Document, at: TextPosition) => TextPosition;
2367
+ type JoinPropertyChangeLinkOptions = {
2368
+ /** The document before the operation that joined the paragraphs. */
2369
+ before: Document;
2370
+ /** The document after it. */
2371
+ after: Document;
2372
+ story: OpStory;
2373
+ /** The paragraph whose mark the join deletes. */
2374
+ blockId: string;
2375
+ /** The paragraph the operation set the joined properties on. */
2376
+ propertiesBlockId: string;
2377
+ };
2378
+ /**
2379
+ * The review op that makes the property change an operation left on the
2380
+ * paragraph its tracked join keeps belong to the paragraph-mark deletion the
2381
+ * operation recorded, so accepting or rejecting the join decides both.
2382
+ * `undefined` when the operation recorded no mark deletion (a mark already
2383
+ * pending deletion, an own added mark taken back), the paragraph holds no
2384
+ * change the operation made, or the change already belongs to a revision.
2385
+ */
2386
+ export declare const joinPropertyChangeLink: ({ before, after, story, blockId, propertiesBlockId }: JoinPropertyChangeLinkOptions) => SetParagraphReviewOp | undefined;
1612
2387
  /** Compile one batch; the caller applies it atomically and journals its exact inverse. */
1613
- export declare const compileEditorIntent: (document: Document, { intent, mode, firstBlockId }: CompileEditorIntentOptions) => Result<CompiledEditorIntent, DocumentOpRefusal>;
2388
+ export declare const compileEditorIntent: (document: Document, input: CompileEditorIntentOptions) => Result<CompiledEditorIntent, DocumentOpRefusal>;
2389
+ type InsertParagraphsIntent = Extract<EditorIntent, {
2390
+ type: "insertParagraphs";
2391
+ }>;
2392
+ type TrackedBatchOptions = {
2393
+ document: Document;
2394
+ count: number;
2395
+ reservedBlockIds?: ReadonlySet<string>;
2396
+ };
2397
+ type TrackedMemberOptions = {
2398
+ index: number;
2399
+ intent: InsertParagraphsIntent;
2400
+ mode: EditorIntentMode;
2401
+ };
2402
+ type TrackedInsertionCompilation = {
2403
+ type: "unsupported";
2404
+ } | {
2405
+ type: "operation";
2406
+ op: InsertBlocksOp;
2407
+ };
2408
+ type TrackedInsertionCompiler = {
2409
+ type: "unsupported";
2410
+ } | {
2411
+ type: "ready";
2412
+ compile: (options: TrackedMemberOptions) => Result<TrackedInsertionCompilation, DocumentOpRefusal>;
2413
+ };
2414
+ /**
2415
+ * Reserve the selection of fresh paragraph IDs for a private monotone run.
2416
+ * The caller uses each index once, in order, and discards the whole run if
2417
+ * any step fails or changes the original class of operations.
2418
+ */
2419
+ export declare const beginTrackedInsertionCompilation: ({ document, count, reservedBlockIds }: TrackedBatchOptions) => TrackedInsertionCompiler;
1614
2420
  type TocHeading = {
1615
2421
  blockId: string;
1616
2422
  text: string;
@@ -1634,12 +2440,89 @@ type PackageResourcesOpOptions = {
1634
2440
  };
1635
2441
  /** Describe the package resource difference as one operation carrying only changed entries. */
1636
2442
  export declare const packageResourcesOpOf: ({ before, after }: PackageResourcesOpOptions) => SetPackageResourcesOp;
2443
+ type MemberEffect = DocumentEditEffects & RecordedRevisionIds & {
2444
+ op: InsertBlocksOp;
2445
+ };
2446
+ type FallbackReason = "compiler" | "sourceShape" | "sectionView" | "memberShape" | "effectShape" | "wideSpan" | "materialization";
2447
+ type TrackedInsertionGroupResult = {
2448
+ type: "fallback";
2449
+ reason: FallbackReason;
2450
+ } | {
2451
+ type: "fallback";
2452
+ reason: "refusal";
2453
+ index: number;
2454
+ refusal: DocumentOpRefusal;
2455
+ } | {
2456
+ type: "materialized";
2457
+ document: Document;
2458
+ members: readonly MemberEffect[];
2459
+ };
2460
+ type NextMember = {
2461
+ type: "member";
2462
+ op: InsertBlocksOp;
2463
+ } | {
2464
+ type: "done";
2465
+ } | {
2466
+ type: "fallback";
2467
+ };
2468
+ type TrackedInsertionGroupOptions = {
2469
+ document: Document;
2470
+ next: (previousRevisions: readonly number[] | undefined) => NextMember;
2471
+ };
2472
+ /**
2473
+ * Attempt a precompiled journal run at one physical main-story anchor. The
2474
+ * prepared members see all prior ids and the real current source/follower.
2475
+ * Publish a document and journal effects only when the whole group succeeds.
2476
+ * Keep the source document and all emitted operations immutable during the
2477
+ * synchronous compiler callback. The caller owns its journal copies.
2478
+ */
2479
+ export declare const tryTrackedInsertionGroup: ({ document, next }: TrackedInsertionGroupOptions) => TrackedInsertionGroupResult;
2480
+ type SectionRejectPropertiesOptions = {
2481
+ live: SectionProperties;
2482
+ previousProperties: SectionProperties | undefined;
2483
+ previousReferences?: SectionPropertyChange["previousReferences"];
2484
+ };
2485
+ /**
2486
+ * Rejected section properties: the stored old sectPr wholesale, preserving
2487
+ * the live header/footer references — `EG_HdrFtrReferences` is not part of
2488
+ * the `CT_SectPrBase` payload a `w:sectPrChange` stores (ECMA-376
2489
+ * §17.13.5.32), so those children survive a native reject. An explicit
2490
+ * reference history replaces that selection, including restoring its
2491
+ * absence. The caller re-attaches whatever `propertyChanges` remain
2492
+ * unresolved.
2493
+ */
2494
+ export declare const sectionRejectProperties: ({ live, previousProperties, previousReferences }: SectionRejectPropertiesOptions) => SectionProperties;
2495
+ type ResolveSectionChangeOptions = {
2496
+ current: SectionProperties;
2497
+ decision: RevisionDecision;
2498
+ id: number;
2499
+ };
2500
+ /**
2501
+ * `current` with its change `id` resolved, the changes after it rebased onto
2502
+ * what that resolution leaves; `null` when no change of `current` is `id`.
2503
+ */
2504
+ export declare const resolveSectionChange: ({ current, decision, id }: ResolveSectionChangeOptions) => SectionProperties | null;
2505
+ /** `current` with its whole change history resolved; `null` when it has none. */
2506
+ export declare const resolveSectionChanges: (current: SectionProperties, decision: RevisionDecision) => SectionProperties | null;
2507
+ type SectionResolutionPatchOptions = {
2508
+ current: SectionProperties;
2509
+ next: SectionProperties;
2510
+ };
2511
+ /** The patch from `current` to `next`: explicit nulls remove what `next` no longer carries. */
2512
+ export declare const sectionResolutionPatch: ({ current, next }: SectionResolutionPatchOptions) => FormattingPatch<SectionProperties>;
1637
2513
  type RegisterParagraphPropertySnapshotOptions = {
1638
- paragraph: Paragraph;
2514
+ /** A paragraph, or review fields an operation gives one. */
2515
+ paragraph: Pick<Paragraph, "formatting">;
1639
2516
  snapshot: ParagraphFormatting | undefined;
1640
2517
  };
1641
2518
  /** Bind effective formatting to the authored properties a review must record. */
1642
2519
  export declare const registerParagraphPropertySnapshot: ({ paragraph, snapshot }: RegisterParagraphPropertySnapshotOptions) => void;
2520
+ /**
2521
+ * Register `paragraph`'s formatting as exactly what it states, as a rejected
2522
+ * property change restores the recorded properties: no list level or style
2523
+ * projects a value onto it.
2524
+ */
2525
+ export declare const registerStatedParagraphFormatting: (paragraph: Pick<Paragraph, "formatting">) => void;
1643
2526
  /**
1644
2527
  * The registration a paragraph's snapshot stands on, as an opaque token: the
1645
2528
  * same object while nothing registers or transfers another one for it. A pass
@@ -1647,32 +2530,18 @@ export declare const registerParagraphPropertySnapshot: ({ paragraph, snapshot }
1647
2530
  * change nothing.
1648
2531
  */
1649
2532
  export declare const paragraphPropertySnapshotToken: (paragraph: Paragraph) => object | undefined;
1650
- /** A document an operation produced, the operations that undo it, and what it changed. */
1651
- type AppliedDocumentOp = {
1652
- document: Document;
1653
- /** Apply in order to restore the input document. */
1654
- inverse: readonly DocumentOp[];
1655
- touched: TouchedBlocks;
1656
- /**
1657
- * Newly allocated tracked revision ids, in document order: its stamp's
1658
- * id and the new ids its other records took. Existing ids retained by a
1659
- * folded or continued review are excluded; a direct operation reports none.
1660
- */
1661
- revisions: readonly number[];
2533
+ type TransferParagraphPropertySnapshotOptions = {
2534
+ source: object;
2535
+ target: object;
1662
2536
  };
1663
- /** Apply one operation to a document that meets the seed contract. */
1664
- export declare const applyDocumentOp: (document: Document, input: DocumentOp) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1665
- /** Apply a journal envelope only when its schema matches this reader. */
1666
- export declare const applyDocumentOpEnvelope: (document: Document, envelope: {
1667
- schema: number;
1668
- op: DocumentOp;
1669
- }) => Result<AppliedDocumentOp, DocumentOpRefusal>;
2537
+ /** Retain paragraph-owned snapshot bindings through sanctioned model copies. */
2538
+ export declare const transferParagraphPropertySnapshot: ({ source, target }: TransferParagraphPropertySnapshotOptions) => void;
1670
2539
  /**
1671
- * Apply operations in order, atomically: the first refusal is returned and
1672
- * the document is unchanged. The inverse undoes the whole list, and
1673
- * `revisions` lists each operation's in turn.
2540
+ * Whether `paragraph`'s formatting is still the formatting an edit registered
2541
+ * as stated. A projector that infers stated properties from the effective
2542
+ * ones it projected before keeps every value such formatting holds.
1674
2543
  */
1675
- export declare const applyDocumentOps: (document: Document, ops: readonly DocumentOp[]) => Result<AppliedDocumentOp, DocumentOpRefusal>;
2544
+ export declare const paragraphStatesItsFormatting: (paragraph: Pick<Paragraph, "formatting">) => boolean;
1676
2545
  /**
1677
2546
  * Every `TextFormatting` field, named so the comparison below is total.
1678
2547
  *
@@ -1688,7 +2557,7 @@ type ComparedTextFormatting = ExhaustiveFields<TextFormatting, ComparedTextForma
1688
2557
  * Uses deep comparison of all properties to determine if runs
1689
2558
  * can be merged without losing formatting information.
1690
2559
  */
1691
- export declare function formattingEquals(a: ComparedTextFormatting | undefined, b: ComparedTextFormatting | undefined): boolean;
2560
+ export declare function formattingEquals(a: DeepReadonly<ComparedTextFormatting> | undefined, b: DeepReadonly<ComparedTextFormatting> | undefined): boolean;
1692
2561
  /**
1693
2562
  * Check if a run contains only text content
1694
2563
  * (runs with special content like images, fields, etc. should not be merged)
@@ -1732,18 +2601,10 @@ export declare const validateOpsDocument: (document: Document) => Result<Documen
1732
2601
  * removed, and its section view derived again. Nothing else changes.
1733
2602
  */
1734
2603
  export declare const normalizeForOps: (document: Document) => Document;
1735
- /** Every `paraId` of every paragraph in a value, nested ones included, in document order. */
1736
- export declare const paragraphIdsIn: (value: unknown) => string[];
1737
- /** Every paragraph id of a package, each story walked once. */
1738
- export declare const packageParagraphIds: (pkg: DocxPackage) => string[];
1739
- /**
1740
- * The key two spellings of one id share. `ST_LongHexNumber` is hex, so
1741
- * `0000abcd` and `0000ABCD` are the same id; every lookup and comparison of
1742
- * paragraph ids goes through this.
1743
- */
1744
- export declare const idKey: (id: string) => string;
2604
+ /** The author of an edit and, for a pending suggestion, the suggestion it belongs to. */
2605
+ type RevisionOwner = Pick<RevisionStamp, "author" | "suggestionId">;
1745
2606
  /** Package-aware explicit pools for every semantic comment anchor cut, including replies. */
1746
- export declare const allocateCommentAnchorIds: (document: Document, op: CreateCommentOp) => Result<NewIds, DocumentOpRefusal>;
2607
+ export declare const allocateCommentAnchorIds: (document: Document, op: CreateCommentOp, lease?: IdLease) => Result<NewIds, DocumentOpRefusal>;
1747
2608
  /**
1748
2609
  * How many `newIds.revision` entries an operation takes on a document,
1749
2610
  * besides its stamp's id: the length of the shortest list of unused ids it
@@ -1776,6 +2637,8 @@ export declare const planTrackedDeletion: (document: Document, options: PlanTrac
1776
2637
  * paragraphs require an explicit package import policy.
1777
2638
  */
1778
2639
  type PlanTrackedReplaceOptions = PlanTrackedDeletionOptions & {
2640
+ /** How the deletion carrying the edit's own id is recorded, when not as `revision`. */
2641
+ deletionRevision?: RevisionStamp;
1779
2642
  sourceContainerPolicy: "join" | "separate";
1780
2643
  seamPolicy?: Extract<DocumentOp, {
1781
2644
  type: "insertContent";
@@ -1785,11 +2648,7 @@ type PlanTrackedReplaceOptions = PlanTrackedDeletionOptions & {
1785
2648
  tail: InlineSlice;
1786
2649
  };
1787
2650
  };
1788
- /**
1789
- * Plan a tracked replacement of a same-list range: the range's tracked
1790
- * deletion followed by the replacement fragment as tracked insertions.
1791
- * All physical revision ids come from one pool for the complete batch.
1792
- */
2651
+ /** Plan a same-list range deletion followed by tracked replacement insertions. */
1793
2652
  export declare const planTrackedReplace: (document: Document, options: PlanTrackedReplaceOptions) => Result<DocumentOp[], DocumentOpRefusal>;
1794
2653
  /** A batch applies atomically, in array order, against its stated revision. */
1795
2654
  type DocumentBatch = {
@@ -1810,9 +2669,55 @@ type SequencedOpEffect = {
1810
2669
  } | {
1811
2670
  type: "joinBlocks";
1812
2671
  firstLength: number;
2672
+ } | {
2673
+ type: "insertContent";
2674
+ /**
2675
+ * Whether the insertion cut a record carrying an id (a revision or a
2676
+ * content control) in two, its second half taking a new id.
2677
+ */
2678
+ cutIdentified: boolean;
2679
+ } | {
2680
+ type: "deleteRange";
2681
+ /**
2682
+ * A direct deletion whose range held its note's own reference mark,
2683
+ * which it keeps: the gap before the mark. A point after the mark that
2684
+ * the deletion closes up to its start lands after the mark.
2685
+ */
2686
+ keptMark?: Gap;
2687
+ } | {
2688
+ type: "setRunProps";
2689
+ /**
2690
+ * The records a direct format cut at both of its ends, outermost
2691
+ * first, by the gaps before their first leaf and after their last one
2692
+ * before the format: a run, and the text the range lay inside. Where
2693
+ * a concurrent deletion holds the format's range and reaches past
2694
+ * neither end of such a record, the deletion keeps it one record. In a
2695
+ * note, `keptMark` is the gap before the note's own reference mark a
2696
+ * record holds, which a direct deletion keeps as well.
2697
+ */
2698
+ cutRecords?: readonly {
2699
+ from: Gap;
2700
+ to: Gap;
2701
+ keptMark?: Gap;
2702
+ }[];
1813
2703
  } | {
1814
2704
  type: "touchedBlocks";
2705
+ /** Paragraphs the operation changed, inserted or removed. */
1815
2706
  blockIds: readonly string[];
2707
+ /**
2708
+ * For a table structure edit, every paragraph of the table before and
2709
+ * after it: another structure edit of that table conflicts with it.
2710
+ */
2711
+ tableBlockIds?: readonly string[];
2712
+ /**
2713
+ * For a comment operation, the comments it added, removed or changed,
2714
+ * replies of a deleted thread among them, and whether it removed a
2715
+ * package relationship of the comment parts.
2716
+ */
2717
+ comments?: {
2718
+ ids: readonly number[];
2719
+ relationshipRemoved: boolean;
2720
+ };
1816
2721
  } | {
1817
2722
  type: typeof NO_SEQUENCED_EFFECT;
1818
2723
  };
@@ -1827,9 +2732,35 @@ export declare const BATCH_REJECTION_REASONS: {
1827
2732
  readonly CONFLICT: "conflict";
1828
2733
  readonly STALE_BASE: "staleBase";
1829
2734
  readonly INVALID_OPERATION: "invalidOperation";
2735
+ /** A concurrent operation restructured the table this one restructures. */
1830
2736
  readonly TABLE_REQUIRES_EXCLUSIVE_EDIT: "tableRequiresExclusiveEdit";
2737
+ /** A concurrent operation changed a paragraph this one addresses. */
2738
+ readonly BLOCK_CONFLICT: "blockConflict";
2739
+ /** A concurrent operation wrote a package part this one uses (`part`). */
2740
+ readonly PART_CONFLICT: "partConflict";
2741
+ /** The batch introduces an id its actor does not lease. */
2742
+ readonly OUTSIDE_ID_LEASE: "outsideIdLease";
1831
2743
  };
1832
2744
  type BatchRejectionReason = (typeof BATCH_REJECTION_REASONS)[keyof typeof BATCH_REJECTION_REASONS];
2745
+ /**
2746
+ * Package parts an operation reads or writes besides the paragraphs it
2747
+ * addresses. Concurrent operations conflict on a part when one writes it and
2748
+ * both name the same entry, or one names the whole part.
2749
+ */
2750
+ export declare const EXCLUSIVE_PARTS: Readonly<{
2751
+ readonly NUMBERING: "numbering";
2752
+ readonly STYLES: "styles";
2753
+ readonly RELATIONSHIPS: "relationships";
2754
+ readonly MEDIA: "media";
2755
+ readonly SECTIONS: "sections";
2756
+ readonly HEADERS_FOOTERS: "headersFooters";
2757
+ readonly NOTES: "notes";
2758
+ readonly SETTINGS: "settings";
2759
+ readonly REVISIONS: "revisions";
2760
+ readonly COMMENTS: "comments";
2761
+ }>;
2762
+ /** One of {@link EXCLUSIVE_PARTS}. */
2763
+ type ExclusivePart = (typeof EXCLUSIVE_PARTS)[keyof typeof EXCLUSIVE_PARTS];
1833
2764
  declare const BatchRejectionBase: TaggedErrorClass<"BatchRejection">;
1834
2765
  export declare class BatchRejection extends BatchRejectionBase<{
1835
2766
  message: string;
@@ -1837,6 +2768,10 @@ export declare class BatchRejection extends BatchRejectionBase<{
1837
2768
  opId?: string;
1838
2769
  opType?: DocumentOpType;
1839
2770
  overType?: DocumentOpType;
2771
+ /** The kind of the id an out-of-lease batch introduces. */
2772
+ idKind?: IdLeaseKind;
2773
+ /** The package part a part conflict names. */
2774
+ part?: ExclusivePart;
1840
2775
  }> {}
1841
2776
  export declare const BATCH_WIRE_OP_TYPES: readonly string[];
1842
2777
  /** Bound recursion and refuse values except JSON data and absent object fields. */
@@ -1852,6 +2787,57 @@ type TransformOptions = {
1852
2787
  };
1853
2788
  /** Rebase an atomic batch over an ordered journal tail. */
1854
2789
  export declare const transformBatch: (batch: DocumentBatch, over: readonly SequencedBatch[], options?: TransformOptions) => Result<DocumentBatch, BatchRejection>;
2790
+ /**
2791
+ * Where a position lands after an ordered journal tail, by paragraph identity
2792
+ * and offset, never by an editor's own coordinates. At a foreign insertion's
2793
+ * or split's own offset, `before` keeps the position ahead of what was
2794
+ * inserted and `after` moves it past. Undefined when the tail removes the
2795
+ * position's paragraph or changes it in a way an offset cannot follow.
2796
+ */
2797
+ export declare const transformPosition: (position: TextPosition, over: readonly SequencedBatch[], affinity?: "before" | "after") => TextPosition | undefined;
2798
+ type AppliedBatch = {
2799
+ document: Document;
2800
+ inverse: readonly DocumentOp[];
2801
+ effects: NonNullable<SequencedBatch["effects"]>;
2802
+ };
2803
+ /** Capture position facts before each operation, including within an atomic batch. */
2804
+ export declare const applyBatch: (document: Document, ops: readonly DocumentOp[]) => Result<AppliedBatch, DocumentOpRefusal>;
2805
+ /** How many ids one grant or renewal leases, per kind. */
2806
+ export declare const DEFAULT_ID_BLOCK_SIZES: Readonly<Record<IdLeaseKind, number>>;
2807
+ /** One block leased to one actor. */
2808
+ type IdLeaseGrant = {
2809
+ readonly actor: string;
2810
+ readonly block: IdBlock;
2811
+ };
2812
+ /** The highest id of a kind one actor's sequenced batches introduced. */
2813
+ type IdLeaseMinted = {
2814
+ readonly actor: string;
2815
+ readonly kind: IdLeaseKind;
2816
+ readonly highest: number;
2817
+ };
2818
+ /**
2819
+ * A room's lease table, part of its sequenced state: kept with the journal
2820
+ * and given back to a restarted sequencer, so each actor keeps its blocks.
2821
+ */
2822
+ type IdLeaseState = {
2823
+ readonly blockSizes: Readonly<Record<IdLeaseKind, number>>;
2824
+ /** Every block granted, in grant order. */
2825
+ readonly grants: readonly IdLeaseGrant[];
2826
+ readonly minted: readonly IdLeaseMinted[];
2827
+ };
2828
+ export declare const ID_LEASE_REFUSAL_REASONS: Readonly<{
2829
+ readonly EXHAUSTED: "exhausted";
2830
+ readonly NOT_DUE: "notDue";
2831
+ readonly INVALID_STATE: "invalidState";
2832
+ readonly UNAVAILABLE: "unavailable";
2833
+ }>;
2834
+ type IdLeaseRefusalReason = (typeof ID_LEASE_REFUSAL_REASONS)[keyof typeof ID_LEASE_REFUSAL_REASONS];
2835
+ declare const IdLeaseRefusalBase: TaggedErrorClass<"IdLeaseRefusal">;
2836
+ export declare class IdLeaseRefusal extends IdLeaseRefusalBase<{
2837
+ message: string;
2838
+ reason: IdLeaseRefusalReason;
2839
+ kind?: IdLeaseKind;
2840
+ }> {}
1855
2841
  type BatchAck = {
1856
2842
  type: "ack";
1857
2843
  opId: string;
@@ -1864,30 +2850,73 @@ type BatchReject = {
1864
2850
  headRev: number;
1865
2851
  };
1866
2852
  type BatchSubmission = BatchAck | BatchReject;
1867
- /** Deterministic append-only authority; the caller supplies delivery and storage. */
1868
- export declare const createSequencer: (document: Document) => {
2853
+ type SequencerOptions = {
2854
+ /** The room's lease table, as `idLeases` gave it before a restart. */
2855
+ idLeases?: IdLeaseState;
2856
+ };
2857
+ /**
2858
+ * Deterministic append-only authority; the caller supplies delivery and
2859
+ * storage. Every actor mints fresh ids only from the blocks the sequencer
2860
+ * leases it, and a batch introducing an id outside its actor's lease is
2861
+ * rejected, so concurrent actors never mint the same id.
2862
+ */
2863
+ export declare const createSequencer: (document: Document, options?: SequencerOptions) => {
1869
2864
  submit: (batch: DocumentBatch) => BatchSubmission;
2865
+ /** The actor's remaining lease; the first call grants one block per kind. */
2866
+ grantIdLease: (actor: string) => Result<IdLease, IdLeaseRefusal>;
2867
+ /** One more block of `kind` for an actor running low. */
2868
+ renewIdLease: (actor: string, kind: IdLeaseKind) => Result<IdBlock, IdLeaseRefusal>;
1870
2869
  readonly document: Document;
1871
2870
  readonly headRev: number;
1872
2871
  readonly broadcasts: readonly SequencedBatch[];
2872
+ /** The lease table to persist with the journal. */
2873
+ readonly idLeases: IdLeaseState;
1873
2874
  };
1874
2875
  type ClientNotice = {
1875
2876
  opId: string;
1876
2877
  reason: BatchRejection;
1877
2878
  ops: readonly DocumentOp[];
1878
2879
  };
2880
+ /**
2881
+ * How the optimistic `document` moved when the authority answered: applied in
2882
+ * order to the document before the answer, `batch.ops` give the one after it.
2883
+ * `rebased`: a foreign revision rebased over every pending local batch, or a
2884
+ * refused local batch's inverse rebased over the ones after it, so positions
2885
+ * and history can be transformed over it. `replaced`: a pending batch could not
2886
+ * be rebased, or the rebased change would not reach the replayed document, so
2887
+ * the change undoes every pending batch, applies what the authority sequenced
2888
+ * and replays the survivors; only the document is exact. When every pending
2889
+ * batch survived and the rebased change reaches a document with the same
2890
+ * paragraphs at the same lengths (the two differ only in how records are cut
2891
+ * or which tracked change holds some content), `moves` is that rebased
2892
+ * change: positions move over it exactly as over a `rebased` one.
2893
+ */
2894
+ type ClientDocumentChange = {
2895
+ type: "rebased";
2896
+ batch: SequencedBatch;
2897
+ } | {
2898
+ type: "replaced";
2899
+ batch: SequencedBatch;
2900
+ moves?: SequencedBatch;
2901
+ };
1879
2902
  /** Optimistic state with ordered authoritative replay and one causal submission in flight. */
1880
2903
  export declare const createClient: (document: Document) => {
1881
2904
  enqueue: (batch: DocumentBatch) => Result<DocumentBatch, BatchRejection>;
1882
2905
  nextSubmission: () => DocumentBatch | undefined;
1883
2906
  receiveAck: (ack: BatchAck) => void;
1884
- receiveReject: (rejection: BatchReject) => void;
1885
- receiveBroadcast: (batch: SequencedBatch) => Result<void, BatchRejection>;
2907
+ receiveReject: (rejection: BatchReject) => readonly ClientDocumentChange[];
2908
+ receiveBroadcast: (batch: SequencedBatch) => Result<readonly ClientDocumentChange[], BatchRejection>;
1886
2909
  readonly document: Document;
1887
2910
  readonly headRev: number;
1888
2911
  readonly pending: readonly DocumentBatch[];
1889
2912
  readonly notices: readonly ClientNotice[];
1890
2913
  };
2914
+ /** What an annotation adds: run formatting, or a comment's anchor. */
2915
+ export declare const BATCH_ANNOTATION_KINDS: Readonly<{
2916
+ FORMATTING: "formatting";
2917
+ COMMENT: "comment";
2918
+ }>;
2919
+ type BatchAnnotationKind = (typeof BATCH_ANNOTATION_KINDS)[keyof typeof BATCH_ANNOTATION_KINDS];
1891
2920
  /**
1892
2921
  * The execution coordinates of an operation resolved against a batch's
1893
2922
  * pre-state. Positions and table coordinates are ordered from right to left;
@@ -1895,9 +2924,14 @@ export declare const createClient: (document: Document) => {
1895
2924
  * Annotations run before moving edits, while table-shape and column edits run
1896
2925
  * after ordinary content edits. Table mutations in nested tables still run
1897
2926
  * right to left before the phase order is applied within the same table.
2927
+ *
2928
+ * Formatting moves no position, and a later write of a property replaces an
2929
+ * earlier one, so formatting annotations run first and in input order, as
2930
+ * one at a time; comment annotations follow them.
1898
2931
  */
1899
2932
  type BatchOrderAddress = {
1900
2933
  type: "annotation";
2934
+ kind: BatchAnnotationKind;
1901
2935
  position: number;
1902
2936
  inputIndex: number;
1903
2937
  } | {
@@ -1941,6 +2975,40 @@ type BatchBlockAccess<Block> = {
1941
2975
  /** Blocks the operation deletes, or merges into the block before them. */
1942
2976
  removes: readonly Block[];
1943
2977
  };
2978
+ /** A paragraph before a container's final paragraph, and whether the batch deletes it. */
2979
+ type FinalBreakCandidate<Paragraph> = {
2980
+ paragraph: Paragraph;
2981
+ deleted: boolean;
2982
+ };
2983
+ /**
2984
+ * Which paragraph settles the deletion of a container's final paragraph:
2985
+ *
2986
+ * - `kept`: the nearest one before it the batch keeps. The final paragraph
2987
+ * goes, and its break retires onto that one.
2988
+ * - `runStart`: the batch deletes every paragraph back to the container's
2989
+ * start or another block. The final paragraph stays, emptied, with the
2990
+ * properties of the run's first paragraph: applied right to left, the run
2991
+ * collapses into that one. One at a time, the final paragraph's deletion
2992
+ * runs while that paragraph still stands, and the paragraph's own deletion
2993
+ * follows it.
2994
+ * - `none`: no paragraph precedes it; it stays, emptied, as it is.
2995
+ */
2996
+ type FinalBreakCarrier<Paragraph> = {
2997
+ type: "kept";
2998
+ paragraph: Paragraph;
2999
+ } | {
3000
+ type: "runStart";
3001
+ paragraph: Paragraph;
3002
+ } | {
3003
+ type: "none";
3004
+ };
3005
+ /**
3006
+ * The carrier of a deleted final paragraph's break, from the paragraphs
3007
+ * before it in its container, nearest first, up to the container's start or
3008
+ * another block. The engine's batch and the one-at-a-time replay both read
3009
+ * it from here, so they settle the deletion on the same paragraph.
3010
+ */
3011
+ export declare const finalBreakCarrier: <Paragraph>(before: readonly FinalBreakCandidate<Paragraph>[]) => FinalBreakCarrier<Paragraph>;
1944
3012
  /**
1945
3013
  * Whether deleting a block takes it out of the document. A container (a
1946
3014
  * story, cell, note or text box) has to end with a paragraph, so deleting its
@@ -1949,7 +3017,7 @@ type BatchBlockAccess<Block> = {
1949
3017
  */
1950
3018
  export declare const deletionRemovesBlock: (deletion: {
1951
3019
  endsContainer: boolean;
1952
- hasKeptParagraphBefore: boolean;
3020
+ carrier: FinalBreakCarrier<unknown>["type"];
1953
3021
  }) => boolean;
1954
3022
  /**
1955
3023
  * A batch equals its operations applied one at a time with every operation
@@ -1971,4 +3039,54 @@ export declare const orderAddressingBeforeRemoval: <T, Block>(ordered: readonly
1971
3039
  * requested sequence, which no series of single edits produces.
1972
3040
  */
1973
3041
  export declare const groupInsertionRuns: <T>(operations: readonly T[], insertionPositionOf: (operation: T) => number | null, keepsGap?: (operation: T) => boolean) => T[][];
1974
- export type { AddNoteOp, AppliedDocumentOp, BatchBlockAccess, BatchOrderAddress, BatchRejectionReason, BlockInsertionPoint, BoundaryOccurrence, CommentAnchor, CommentExhaustionInput, CommentState, CopyOriginAncestorList, CreateCommentOp, CreateHeaderFooterOp, CreateNumberingInstanceOp, DeleteBlocksOp, DeleteColumnOp, DeleteCommentOp, DeleteNumberingInstanceOp, DeleteRangeOp, DeleteRowOp, DeleteTableOp, DocumentBatch, DocumentOp, DocumentOpEnvelope, DocumentOpRefusalReason, DocumentOpType, EditorIntent, EditorIntentMode, EmptyPropertySet, FormattingPatch, HeaderFooterStory, InlineSlice, InsertBlocksOp, InsertColumnOp, InsertContentOp, InsertRowOp, InsertTableOp, InsertTextOp, InsertedRunProps, JoinBlocksOp, JoinInlineOp, MergeCellsOp, NewIds, NoteStory, NumberingPartState, OpStory, PackageResourceEntry, PackageResourceEntryChange, PackageResourceMapChange, PackageResourceMedia, PackageResourcePart, PackageResources, ParagraphContentVerdict, ParagraphPropsPatch, ParagraphReviewFields, PlanTrackedDeletionOptions, PlanTrackedReplaceOptions, RemoveHeaderFooterOp, RemoveNoteOp, ReplaceBlocksOp, ReplaceInlineOp, ResolveRevisionOp, RestoreCommentStateOp, RestoreStoryPartsOp, RevisionDecision, RevisionStamp, RunPropsPatch, SectionEndpoint, SectionMapState, SectionPropertiesState, SectionViewEntry, SectionViewState, SequencedBatch, SetCellPropsOp, SetCommentResolutionOp, SetContainerBlocksOp, SetPackageResourcesOp, SetParagraphPropsOp, SetParagraphReviewOp, SetRowPropsOp, SetRunPropsOp, SetSectionEndpointOp, SetSectionPropsOp, SetTableGridOp, SetTableOp, SetTablePropsOp, SetTableRowsOp, SplitBlockOp, SplitCellOp, SplitHalf, SplitInlineOp, SplitParagraphFields, TableBlockIntentOperation, TableEditOp, TableIntentOperation, TableRowIntentOperation, TextPosition, TouchedBlocks, UpdateCommentContentOp, WellFormedRangePlan, ZeroWidthItem };
3042
+ /** A document with its changes resolved one way, and what could not be. */
3043
+ type ResolvedDocumentView = {
3044
+ document: Document;
3045
+ /**
3046
+ * The stories whose resolution refused, left as they were: a reader shows
3047
+ * them with their changes still in place and says so.
3048
+ */
3049
+ unresolved: readonly OpStory[];
3050
+ };
3051
+ /**
3052
+ * `document` with every revision resolved by `decision`, story by story. A
3053
+ * story the resolution of an earlier one removed (a note whose every
3054
+ * reference went) is not read again.
3055
+ */
3056
+ export declare const resolvedDocumentView: (document: Document, decision: RevisionDecision) => ResolvedDocumentView;
3057
+ type WholeParagraphReplacementOptions = {
3058
+ document: Document;
3059
+ from: TextPosition;
3060
+ to: TextPosition;
3061
+ /**
3062
+ * Who a suggesting replacement records, absent for a direct edit. A
3063
+ * suggestion retracts only its own pending insertions; a host with
3064
+ * another owner's stays with the ordinary range planner.
3065
+ */
3066
+ suggesting?: RevisionOwner | undefined;
3067
+ };
3068
+ type WholeParagraphReplacementPlan = {
3069
+ blockIds: readonly string[];
3070
+ commentIds: ReadonlySet<number>;
3071
+ };
3072
+ /**
3073
+ * Whole source hosts before a surviving paragraph can retire through range
3074
+ * deletion and joins. Their complete comment ownership needs no alignment
3075
+ * inside a surviving host. Partial first hosts, section endpoints and pending
3076
+ * removals, moves or property changes in a host stay with the ordinary range
3077
+ * planner.
3078
+ */
3079
+ export declare const planWholeParagraphReplacement: ({ document, from, to, suggesting }: WholeParagraphReplacementOptions) => Result<WholeParagraphReplacementPlan | null, DocumentOpRefusal>;
3080
+ type PreservedCommentRangeMarker = {
3081
+ type: "commentRangeStart" | "commentRangeEnd";
3082
+ id: number;
3083
+ };
3084
+ /** Read the boundaries before the named row or cell, in authored order. */
3085
+ export declare const preservedCommentRangeMarkersAt: (children: readonly PreservedChild[] | undefined, { at, childCount }: {
3086
+ at: number;
3087
+ childCount: number;
3088
+ }) => PreservedCommentRangeMarker[];
3089
+ export declare const storyBody: (document: Document, story: OpStory) => DocumentBody;
3090
+ export declare const findStoryBody: (document: Document, story: OpStory) => DocumentBody | undefined;
3091
+ export declare const sameStory: (left: OpStory, right: OpStory) => boolean;
3092
+ export type { AddNoteOp, AppliedDocumentOp, BatchAck, BatchAnnotationKind, BatchBlockAccess, BatchOrderAddress, BatchReject, BatchRejectionReason, BatchSubmission, BlockBoundary, BlockInsertionPoint, BoundaryOccurrence, ClientDocumentChange, ClientNotice, CommentAnchor, CommentExhaustionInput, CommentReferenceOffset, CommentState, CopyOriginAncestorList, CreateCommentOp, CreateHeaderFooterOp, CreateNumberingInstanceOp, DeleteBlocksOp, DeleteColumnOp, DeleteCommentOp, DeleteNumberingInstanceOp, DeleteRangeOp, DeleteRowOp, DeleteTableOp, DocumentBatch, DocumentOp, DocumentOpEnvelope, DocumentOpRefusalReason, DocumentOpType, EditorIntent, EditorIntentMode, EmptyPropertySet, ExclusivePart, FinalBreakCandidate, FinalBreakCarrier, FormattingPatch, HeaderFooterStory, IdBlock, IdLease, IdLeaseGrant, IdLeaseKind, IdLeaseMinted, IdLeaseRefusalReason, IdLeaseState, InlineSlice, InsertBlocksOp, InsertColumnOp, InsertContentOp, InsertRowOp, InsertTableOp, InsertTextOp, InsertedRunProps, JoinBlocksOp, JoinInlineOp, LeasedId, LeasedIdCensus, MergeCellsOp, NewIds, NewListInstance, NoteStory, NumberingPartState, OpStory, PackageResourceEntry, PackageResourceEntryChange, PackageResourceMapChange, PackageResourceMedia, PackageResourcePart, PackageResources, ParagraphAbsorption, ParagraphContentVerdict, ParagraphPropsPatch, ParagraphReviewFields, PlanTrackedDeletionOptions, PlanTrackedReplaceOptions, PreservedCommentRangeMarker, RecordedRevisionIds, RemoveHeaderFooterOp, RemoveNoteOp, ReplaceBlocksOp, ReplaceInlineOp, ResolveRevisionOp, ResolvedDocumentView, RestoreCommentStateOp, RestoreStoryPartsOp, RevisionAbsorption, RevisionDecision, RevisionStamp, RunPropsPatch, SectionEndpoint, SectionMapState, SectionPropertiesState, SectionViewEntry, SectionViewState, SequencedBatch, SequencerOptions, SetCellPropsOp, SetCommentResolutionOp, SetContainerBlocksOp, SetContentControlOp, SetPackageResourcesOp, SetParagraphPropsOp, SetParagraphReviewOp, SetRowPropsOp, SetRunPropsOp, SetSectionEndpointOp, SetSectionPropsOp, SetTableGridOp, SetTableOp, SetTablePropsOp, SetTableRowsOp, SplitBlockOp, SplitCellOp, SplitHalf, SplitInlineOp, SplitParagraphFields, StoryParts, TableBlockIntentOperation, TableEditOp, TableInsertionPoint, TableIntentOperation, TableRowIntentOperation, TextPosition, TouchedBlocks, UpdateCommentContentOp, VersionOneKept, VersionOneKeptMarkers, WellFormedRangePlan, ZeroWidthItem };