@stll/docx-core 0.42.1 → 0.43.1

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,4 @@
1
- import { C as Relationship, D as StyleDefinitions, Dn as Run, Dt as HeaderFooter, Hr as NumberingInstance, Jn as TabContent, Jr as ParagraphFormatting, K as BlockContent, Mr as AbstractNumbering, Nn as Section, Oi as HeadingOutlineLevel, On as RunContent, Ot as HeaderFooterType, Pn as SectionProperties, Q as BreakContent, S as MediaFile, Vr as NumberingDefinitions, Y as BookmarkEnd, Yn as Table, a as DocumentSettings, dn as Paragraph, ei as TableCellFormatting, et as Comment, fn as ParagraphContent, g as ExhaustiveFields, gt as Endnote, hn as ParagraphPropertyChange, i as Document, ir as TableRow, jt as INSERTION_SEAM_POLICIES, li as TextFormatting, oi as TableRowFormatting, pn as ParagraphMarkChange, s as DocxPackage, ti as TableFormatting, ut as DocumentBody, wt as Footnote } from "../document-BWDHON3T.js";
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-CaGfolcU.js";
2
2
  import { Result, TaggedErrorClass } from "better-result";
3
3
  /** JSON-safe map presence, including an explicitly undefined section map. */
4
4
  type SectionMapState = {
@@ -151,7 +151,7 @@ type NewIds = {
151
151
  * of making it: the stamp's id names the first record the edit creates and
152
152
  * `newIds.revision` names the others, in document order. The id must be unused
153
153
  * in the package. A new tracked wrapper that would sit next to one with the
154
- * same author, date and initials merges into it and creates no record, so an
154
+ * same author, date, initials and suggestion merges into it and creates no record, so an
155
155
  * author's burst of typing reads as one change.
156
156
  */
157
157
  type RevisionStamp = {
@@ -160,6 +160,11 @@ type RevisionStamp = {
160
160
  /** `w:date`, as the author's client stated it. */
161
161
  date: string;
162
162
  initials?: string;
163
+ /**
164
+ * The pending suggestion the records belong to. A record of one suggestion
165
+ * never merges into a record of another, or into an ordinary tracked change.
166
+ */
167
+ suggestionId?: string;
163
168
  };
164
169
  /** The paragraph fields a split gives the new paragraph, besides its id, content and mark. */
165
170
  type SplitParagraphFields = Omit<Paragraph, "type" | "paraId" | "content" | "sectionProperties" | "pPrMark">;
@@ -196,6 +201,7 @@ export declare const DOCUMENT_OP_TYPES: Readonly<{
196
201
  readonly SET_PARAGRAPH_REVIEW: "setParagraphReview";
197
202
  readonly REPLACE_INLINE: "replaceInline";
198
203
  readonly RESOLVE_REVISION: "resolveRevision";
204
+ readonly SET_REVISION_INFO: "setRevisionInfo";
199
205
  readonly INSERT_TABLE: "insertTable";
200
206
  readonly DELETE_TABLE: "deleteTable";
201
207
  readonly SET_CONTAINER_BLOCKS: "setContainerBlocks";
@@ -483,9 +489,10 @@ type BlockInsertionPoint = {
483
489
  * Insert paragraphs beside an existing paragraph, with pre-minted ids.
484
490
  * Section-bearing paragraphs are refused. With `revision`, each inserted
485
491
  * paragraph receives an inserted mark and its content an insertion wrapper.
486
- * Tracked insertion requires a following paragraph in the same block list;
487
- * terminal insertion and insertion immediately before non-paragraph blocks
488
- * are refused as `untrackable`.
492
+ * A tracked insertion after a paragraph no paragraph follows marks the
493
+ * anchor's mark as the inserted one and gives the last new paragraph the
494
+ * anchor's former mark; it is refused as `untrackable` when the anchor's mark
495
+ * carries review records.
489
496
  * Incoming revision and content-control identities are refused in tracked
490
497
  * mode rather than nesting reviews or rewriting supplied identities.
491
498
  */
@@ -495,6 +502,8 @@ type InsertBlocksOp = {
495
502
  at: BlockInsertionPoint;
496
503
  blocks: readonly Paragraph[];
497
504
  revision?: RevisionStamp;
505
+ /** With `revision`, the insertion is the destination of a move: `w:moveTo`. */
506
+ move?: true;
498
507
  newIds?: NewIds;
499
508
  };
500
509
  /**
@@ -515,6 +524,8 @@ type DeleteBlocksOp = {
515
524
  story: OpStory;
516
525
  blockIds: readonly string[];
517
526
  revision?: RevisionStamp;
527
+ /** With `revision`, the deletion is the source of a move: `w:moveFrom`. */
528
+ move?: true;
518
529
  newIds?: NewIds;
519
530
  };
520
531
  /**
@@ -612,6 +623,18 @@ type ResolveRevisionOp = {
612
623
  revisionIds: readonly number[];
613
624
  decision: RevisionDecision;
614
625
  };
626
+ /**
627
+ * Rewrite the metadata of the revisions with these ids, keeping their content
628
+ * and their ids: every record carrying an id takes the info given for it.
629
+ * Adopting a pending suggestion as ordinary tracked changes is this, with the
630
+ * suggestion id dropped and the adopter's attribution. Its inverse writes the
631
+ * previous metadata back.
632
+ */
633
+ type SetRevisionInfoOp = {
634
+ type: typeof DOCUMENT_OP_TYPES.SET_REVISION_INFO;
635
+ story: OpStory;
636
+ infos: readonly TrackedChangeInfo[];
637
+ };
615
638
  /**
616
639
  * Insert a row at a zero-based index in the table holding `blockId`.
617
640
  * The paragraph reference selects the innermost table containing it.
@@ -944,7 +967,8 @@ type UpdateCommentContentOp = {
944
967
  type: typeof DOCUMENT_OP_TYPES.UPDATE_COMMENT_CONTENT;
945
968
  id: number;
946
969
  content: readonly Paragraph[];
947
- patch?: FormattingPatch<Pick<Comment, "author" | "initials" | "date">>;
970
+ /** `suggestionId: null` adopts a proposed comment as an ordinary one. */
971
+ patch?: FormattingPatch<Pick<Comment, "author" | "initials" | "date" | "suggestionId">>;
948
972
  };
949
973
  type SetCommentResolutionOp = {
950
974
  type: typeof DOCUMENT_OP_TYPES.SET_COMMENT_RESOLUTION;
@@ -985,7 +1009,7 @@ type RestoreCommentStateOp = {
985
1009
  };
986
1010
  type CommentOp = CreateCommentOp | UpdateCommentContentOp | SetCommentResolutionOp | DeleteCommentOp | RestoreCommentStateOp;
987
1011
  /** A schema-version-10 document operation. */
988
- 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 | InsertRowOp | DeleteRowOp | SetTableRowsOp | TableEditOp | SetTableOp | CreateNumberingInstanceOp | DeleteNumberingInstanceOp | SetSectionEndpointOp | SetPackageResourcesOp) & {
1012
+ 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) & {
989
1013
  /** Own undefined fields recorded by the operation capture boundary. */
990
1014
  undefinedFields?: readonly (readonly string[])[];
991
1015
  };
@@ -1015,6 +1039,49 @@ type DocumentEdit = {
1015
1039
  };
1016
1040
  /** Edits made in turn, starting from `document`, as one edit. */
1017
1041
  export declare const combineEdits: (document: Document, edits: readonly DocumentEdit[]) => DocumentEdit;
1042
+ /** A place between two leaves. */
1043
+ type Gap = {
1044
+ offset: number;
1045
+ zeroWidthBefore: number;
1046
+ };
1047
+ /** A node of a paragraph's content tree: a paragraph child or a run child. */
1048
+ type InlineNode = ParagraphContent | RunContent;
1049
+ /** Comment anchors are preserved by planned deletion and cannot be wrapped. */
1050
+ declare const COMMENT_ANCHOR_TYPES: {
1051
+ readonly commentRangeStart: true;
1052
+ readonly commentRangeEnd: true;
1053
+ readonly commentReference: true;
1054
+ };
1055
+ type CommentAnchorCarrier = Extract<InlineNode, {
1056
+ type: keyof typeof COMMENT_ANCHOR_TYPES;
1057
+ }>;
1058
+ /** Whether a leaf carries an anchor rather than content covered by its range. */
1059
+ export declare const isCommentAnchorCarrierType: (type: string) => boolean;
1060
+ /** The zero-width leaves at an offset, in document order. */
1061
+ export declare const zeroWidthLeavesAt: (items: readonly InlineNode[], offset: number) => InlineNode[];
1062
+ /**
1063
+ * The gap an insertion defaults to: before the first zero-width leaf at the
1064
+ * offset that opens a range, so a marker opening there stays with what
1065
+ * follows it and every other one with what precedes it.
1066
+ */
1067
+ export declare const defaultInsertionGap: (items: readonly InlineNode[], offset: number) => Gap;
1068
+ /**
1069
+ * The stretch of a paragraph's content the given revisions hold: from the
1070
+ * first leaf inside one of their tracked wrappers to the last, or `undefined`
1071
+ * when none is there.
1072
+ */
1073
+ export declare const revisionSpan: (items: readonly InlineNode[], revisionIds: ReadonlySet<number>) => {
1074
+ from: number;
1075
+ to: number;
1076
+ } | undefined;
1077
+ /** Source leaf coordinates without the ancestry needed by edit planning. */
1078
+ export declare const inlineLeafSpans: (items: readonly InlineNode[]) => {
1079
+ node: InlineNode;
1080
+ before: Gap;
1081
+ after: Gap;
1082
+ }[];
1083
+ /** Gaps in document order: by offset, then by the zero-width leaves before them. */
1084
+ export declare const compareGaps: (left: Gap, right: Gap) => number;
1018
1085
  declare const DocumentOpRefusalBase: TaggedErrorClass<"DocumentOpRefusal">;
1019
1086
  /**
1020
1087
  * Why an operation was not applied. A refused operation changes nothing: the
@@ -1122,40 +1189,6 @@ export declare class DocumentOpRefusal extends DocumentOpRefusalBase<{
1122
1189
  reason: DocumentOpRefusalReason;
1123
1190
  opType: DocumentOpType | undefined;
1124
1191
  }> {}
1125
- /** A place between two leaves. */
1126
- type Gap = {
1127
- offset: number;
1128
- zeroWidthBefore: number;
1129
- };
1130
- /** A node of a paragraph's content tree: a paragraph child or a run child. */
1131
- type InlineNode = ParagraphContent | RunContent;
1132
- /** Comment anchors are preserved by planned deletion and cannot be wrapped. */
1133
- declare const COMMENT_ANCHOR_TYPES: {
1134
- readonly commentRangeStart: true;
1135
- readonly commentRangeEnd: true;
1136
- readonly commentReference: true;
1137
- };
1138
- type CommentAnchorCarrier = Extract<InlineNode, {
1139
- type: keyof typeof COMMENT_ANCHOR_TYPES;
1140
- }>;
1141
- /** Whether a leaf carries an anchor rather than content covered by its range. */
1142
- export declare const isCommentAnchorCarrierType: (type: string) => boolean;
1143
- /** The zero-width leaves at an offset, in document order. */
1144
- export declare const zeroWidthLeavesAt: (items: readonly InlineNode[], offset: number) => InlineNode[];
1145
- /**
1146
- * The gap an insertion defaults to: before the first zero-width leaf at the
1147
- * offset that opens a range, so a marker opening there stays with what
1148
- * follows it and every other one with what precedes it.
1149
- */
1150
- export declare const defaultInsertionGap: (items: readonly InlineNode[], offset: number) => Gap;
1151
- /** Source leaf coordinates without the ancestry needed by edit planning. */
1152
- export declare const inlineLeafSpans: (items: readonly InlineNode[]) => {
1153
- node: InlineNode;
1154
- before: Gap;
1155
- after: Gap;
1156
- }[];
1157
- /** Gaps in document order: by offset, then by the zero-width leaves before them. */
1158
- export declare const compareGaps: (left: Gap, right: Gap) => number;
1159
1192
  type CommentExhaustionInput = {
1160
1193
  type: "document";
1161
1194
  document: Document;
@@ -1198,6 +1231,33 @@ export declare const sameStory: (left: OpStory, right: OpStory) => boolean;
1198
1231
  export declare const findStoryBody: (document: Document, story: OpStory) => DocumentBody | undefined;
1199
1232
  export declare const storyBody: (document: Document, story: OpStory) => DocumentBody;
1200
1233
  export declare const documentStories: (document: Document) => OpStory[];
1234
+ type ReplaceStoryBodyOptions = {
1235
+ document: Document;
1236
+ story: OpStory;
1237
+ body: DocumentBody;
1238
+ };
1239
+ export declare const replaceStoryBody: ({ document, story, body }: ReplaceStoryBodyOptions) => Document;
1240
+ /** One step from a block list down to a block list nested in one of its blocks. */
1241
+ type BlockListStep = {
1242
+ kind: "tableCell";
1243
+ block: number;
1244
+ row: number;
1245
+ cell: number;
1246
+ } | {
1247
+ kind: "blockSdt";
1248
+ block: number;
1249
+ } | {
1250
+ kind: "blockCustomXml";
1251
+ block: number;
1252
+ };
1253
+ /** Where a paragraph sits: the block list that holds it, and its index there. */
1254
+ type ParagraphLocation = {
1255
+ list: readonly BlockListStep[];
1256
+ index: number;
1257
+ paragraph: Paragraph;
1258
+ };
1259
+ /** Every paragraph of a story's block tree, in document order. */
1260
+ export declare const storyParagraphs: (body: DocumentBody) => ParagraphLocation[];
1201
1261
  /**
1202
1262
  * A body holding other blocks, its section view derived from them. A view
1203
1263
  * that does not line up with the blocks (a different section count) is left
@@ -1253,18 +1313,29 @@ export declare const OBJECT_REPLACEMENT_CHARACTER = "";
1253
1313
  */
1254
1314
  export declare const paragraphLogicalText: (paragraph: Paragraph) => string;
1255
1315
  /** The single structural outcome of resolving a paragraph mark. */
1256
- export declare const paragraphMarkOutcome: ({ follows, holdsContent, markWasAdded, containerStillEndsWithParagraph, followingTableCanReceiveRunIn, needsFollowingCommentHost, tableRemovalIsTrackable, removedSectionProperties, precedingSectionOwner, followingHasSectionProperties }: {
1257
- follows: "paragraph" | "table" | "nothing";
1316
+ export declare const paragraphMarkOutcome: ({ follows, holdsContent, markWasAdded, containerStillEndsWithParagraph, followingTableCanReceiveRunIn, holdsContentOnceAccepted, followingBlockCanReceiveRunIn, needsFollowingCommentHost, tableRemovalIsTrackable, removedSectionProperties, precedingSectionOwner, followingHasSectionProperties }: {
1317
+ /** `block` is a follower {@link isOpaqueFollower} admits. */
1318
+ follows: "paragraph" | "table" | "block" | "nothing";
1258
1319
  /** From {@link paragraphHoldsContent} or the editor's view of the same rule, never re-derived. */
1259
1320
  holdsContent: ParagraphContentVerdict;
1260
1321
  markWasAdded: boolean;
1261
1322
  /**
1262
- * Read only when nothing follows: whether the block BEFORE this paragraph,
1263
- * which becomes the container's last block once this one is removed, is a
1264
- * paragraph. Never the container's current last child, which is this one.
1323
+ * Read when nothing or a block follows. When nothing does: whether the
1324
+ * block BEFORE this paragraph, which becomes the container's last block
1325
+ * once this one is removed, is a paragraph; never the container's current
1326
+ * last child, which is this one. When a block does: whether the container's
1327
+ * last block is a paragraph.
1265
1328
  */
1266
1329
  containerStillEndsWithParagraph: boolean;
1267
1330
  followingTableCanReceiveRunIn: boolean;
1331
+ /**
1332
+ * Read when a block follows: whether the paragraph still holds content
1333
+ * once every change in it is accepted, from
1334
+ * {@link paragraphHoldsContentOnceAccepted}.
1335
+ */
1336
+ holdsContentOnceAccepted?: ParagraphContentVerdict;
1337
+ /** Read when a block follows: whether it offers a {@link paragraphBlockRunInTarget}. */
1338
+ followingBlockCanReceiveRunIn?: boolean;
1268
1339
  needsFollowingCommentHost?: boolean;
1269
1340
  tableRemovalIsTrackable?: boolean;
1270
1341
  removedSectionProperties?: boolean;
@@ -1379,6 +1450,54 @@ type WellFormedRangePlan = {
1379
1450
  export declare const planWellFormedRanges: (occurrences: readonly BoundaryOccurrence[]) => WellFormedRangePlan;
1380
1451
  /** Capture own undefined fields before an operation enters its JSON journal. */
1381
1452
  export declare const captureDocumentOp: (op: DocumentOp) => DocumentOp;
1453
+ /**
1454
+ * The ids of the comments pending suggestions propose: every one, or those of
1455
+ * one suggestion. A reply is removed with the comment it answers.
1456
+ */
1457
+ export declare const suggestedCommentIds: (document: Document, suggestionId?: string) => number[];
1458
+ /**
1459
+ * The document as a save writes it: every pending suggestion rejected. A
1460
+ * suggestion is a proposal the host holds, not a change in the file, so the
1461
+ * file reads as if it had never been made; ordinary tracked changes stay. A
1462
+ * comment a suggestion proposes is left out with it.
1463
+ */
1464
+ export declare const withoutPendingSuggestions: (document: Document) => Result<Document, DocumentOpRefusal>;
1465
+ /**
1466
+ * The revisions of one pending suggestion in a story, one info per revision
1467
+ * id, in document order.
1468
+ */
1469
+ export declare const suggestionRevisionInfos: (document: Document, story: OpStory, suggestionId: string) => TrackedChangeInfo[];
1470
+ /**
1471
+ * The ids of every pending suggestion in a document, in every story, and of
1472
+ * every suggestion that proposes a comment.
1473
+ */
1474
+ export declare const pendingSuggestionIdsIn: (document: Document) => Set<string>;
1475
+ /** A document an operation produced, the operations that undo it, and what it changed. */
1476
+ type AppliedDocumentOp = {
1477
+ document: Document;
1478
+ /** Apply in order to restore the input document. */
1479
+ inverse: readonly DocumentOp[];
1480
+ touched: TouchedBlocks;
1481
+ /**
1482
+ * Newly allocated tracked revision ids, in document order: its stamp's
1483
+ * id and the new ids its other records took. Existing ids retained by a
1484
+ * folded or continued review are excluded; a direct operation reports none.
1485
+ */
1486
+ revisions: readonly number[];
1487
+ };
1488
+ /** Apply one operation to a document that meets the seed contract. */
1489
+ export declare const applyDocumentOp: (document: Document, input: DocumentOp) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1490
+ /** Apply a journal envelope only when its schema matches this reader. */
1491
+ export declare const applyDocumentOpEnvelope: (document: Document, envelope: {
1492
+ schema: number;
1493
+ op: DocumentOp;
1494
+ }) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1495
+ /**
1496
+ * Apply operations in order, atomically: the first refusal is returned and
1497
+ * the document is unchanged. The inverse undoes the whole list, and
1498
+ * `revisions` lists each operation's in turn.
1499
+ */
1500
+ export declare const applyDocumentOps: (document: Document, ops: readonly DocumentOp[]) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1382
1501
  type HyperlinkEditorIntent = {
1383
1502
  type: "setHyperlink";
1384
1503
  from: TextPosition;
@@ -1402,11 +1521,73 @@ type SplitParagraphIntent = {
1402
1521
  type: "splitParagraph";
1403
1522
  at: TextPosition;
1404
1523
  to?: TextPosition;
1524
+ /**
1525
+ * Which half takes the new identity: by default the first, as typing a
1526
+ * break moves the text before it to a paragraph of its own; the second
1527
+ * keeps the paragraph's identity on the text before the split.
1528
+ */
1529
+ newHalf?: SplitHalf;
1530
+ };
1531
+ /**
1532
+ * A row inserted into, or deleted from, the table holding `blockId`. An
1533
+ * inserted row's paragraphs take fresh identities from the compiler; the ids
1534
+ * it arrives with are not kept.
1535
+ */
1536
+ type TableRowIntentOperation = Omit<InsertRowOp, "revision" | "newIds"> | Omit<DeleteRowOp, "revision" | "newIds">;
1537
+ /**
1538
+ * A table inserted after the paragraph `blockId`, with an empty paragraph
1539
+ * after it, as the editor inserts one; or the table holding `blockId`,
1540
+ * removed, or in suggesting mode recorded as deleted. An inserted table's
1541
+ * paragraphs take fresh identities from the compiler.
1542
+ */
1543
+ type TableBlockIntentOperation = Omit<DeleteTableOp, "revision" | "newIds" | "expected"> | {
1544
+ type: typeof DOCUMENT_OP_TYPES.INSERT_TABLE;
1545
+ story: OpStory;
1546
+ blockId: string;
1547
+ table: Table;
1548
+ /**
1549
+ * Where the table goes against the anchor paragraph: after it (the
1550
+ * default, as from a caret), or before it, as from a selection of the
1551
+ * whole story, which the editor fills at the story's start.
1552
+ */
1553
+ side?: "after" | "before";
1554
+ /**
1555
+ * An empty paragraph ahead of the table as well, as the editor writes
1556
+ * a table it inserts after another, so the two never touch.
1557
+ */
1558
+ separated?: boolean;
1405
1559
  };
1406
1560
  /** Positions use canonical physical offsets, including retained deleted content. */
1407
1561
  type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
1408
1562
  type: "table";
1409
1563
  operation: TableIntentOperation;
1564
+ } | {
1565
+ type: "tableRow";
1566
+ operation: TableRowIntentOperation;
1567
+ } | {
1568
+ type: "tableBlock";
1569
+ operation: TableBlockIntentOperation;
1570
+ } | {
1571
+ /**
1572
+ * Whole paragraphs beside a paragraph, which keeps its identity: the
1573
+ * compiler gives each a fresh id, and a suggestion records each as
1574
+ * inserted.
1575
+ */
1576
+ type: "insertParagraphs";
1577
+ story: OpStory;
1578
+ at: BlockInsertionPoint;
1579
+ paragraphs: readonly Paragraph[];
1580
+ /** A suggestion records the paragraphs as a move's destination. */
1581
+ move?: true;
1582
+ /** A list instance the paragraphs' numbering names, created first. */
1583
+ newList?: NewListInstance;
1584
+ } | {
1585
+ /** Whole adjacent paragraphs removed with their marks. */
1586
+ type: "deleteParagraphs";
1587
+ story: OpStory;
1588
+ blockIds: readonly string[];
1589
+ /** A suggestion records the paragraphs as a move's source. */
1590
+ move?: true;
1410
1591
  } | {
1411
1592
  type: "replaceFragment";
1412
1593
  from: TextPosition;
@@ -1429,6 +1610,15 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
1429
1610
  text: string;
1430
1611
  runProps?: TextFormatting;
1431
1612
  runPropsPatch?: RunPropsPatch;
1613
+ /**
1614
+ * Whether the caret at each end stood just inside the edge of an inline
1615
+ * container (a content control) that opens at `from` or closes at
1616
+ * `to`, where the source gap alone cannot tell inside from outside.
1617
+ */
1618
+ inside?: {
1619
+ start?: boolean;
1620
+ end?: boolean;
1621
+ };
1432
1622
  } | {
1433
1623
  type: "formatRun";
1434
1624
  from: TextPosition;
@@ -1438,6 +1628,8 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
1438
1628
  type: "formatParagraph";
1439
1629
  at: TextPosition;
1440
1630
  patch: ParagraphPropsPatch;
1631
+ /** A list instance the patch's numbering names, created first. */
1632
+ newList?: NewListInstance;
1441
1633
  } | {
1442
1634
  type: "setList";
1443
1635
  items: readonly {
@@ -1466,6 +1658,16 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
1466
1658
  story: OpStory;
1467
1659
  blockId: string;
1468
1660
  nextBlockId: string;
1661
+ /**
1662
+ * Which paragraph's identity a direct join keeps, by default the
1663
+ * second's; a tracked join always keeps the second.
1664
+ */
1665
+ survivor?: SplitHalf;
1666
+ };
1667
+ /** A numbering instance, with its abstract definition, an edit creates. */
1668
+ type NewListInstance = {
1669
+ num: NumberingInstance;
1670
+ abstractNum?: AbstractNumbering;
1469
1671
  };
1470
1672
  /** Revision metadata and every fresh identity are supplied before compilation. */
1471
1673
  type EditorIntentMode = {
@@ -1488,11 +1690,22 @@ type CompileEditorIntentOptions = {
1488
1690
  type CompiledEditorIntent = {
1489
1691
  ops: DocumentOp[];
1490
1692
  selection: TextPosition;
1693
+ /**
1694
+ * What applying `ops` to the compiled document gives, when the compiler
1695
+ * already applied exactly them; a caller applies `ops` itself otherwise.
1696
+ */
1697
+ applied?: AppliedDocumentOp;
1491
1698
  };
1492
1699
  /** A split's paragraph identity is allocated with its other fresh identities. */
1493
1700
  type EditorIntentAllocation = EditorIntent | SplitParagraphIntent;
1494
- /** Cache only immutable document versions; never retain a retired version strongly. */
1495
- export declare const createEditorIntentIdAllocator: () => (document: Document, intent: EditorIntentAllocation) => {
1701
+ /**
1702
+ * Cache only immutable document versions; never retain a retired version
1703
+ * strongly. A new paragraph identity avoids `reservedBlockIds`, the ones
1704
+ * consumed elsewhere, such as an undone insertion's.
1705
+ */
1706
+ export declare const createEditorIntentIdAllocator: ({ reservedBlockIds }?: {
1707
+ reservedBlockIds?: ReadonlySet<string>;
1708
+ }) => (document: Document, intent: EditorIntentAllocation) => {
1496
1709
  revisionId: number;
1497
1710
  newBlockId: string;
1498
1711
  newIds: {
@@ -1549,32 +1762,13 @@ type RegisterParagraphPropertySnapshotOptions = {
1549
1762
  };
1550
1763
  /** Bind effective formatting to the authored properties a review must record. */
1551
1764
  export declare const registerParagraphPropertySnapshot: ({ paragraph, snapshot }: RegisterParagraphPropertySnapshotOptions) => void;
1552
- /** A document an operation produced, the operations that undo it, and what it changed. */
1553
- type AppliedDocumentOp = {
1554
- document: Document;
1555
- /** Apply in order to restore the input document. */
1556
- inverse: readonly DocumentOp[];
1557
- touched: TouchedBlocks;
1558
- /**
1559
- * Newly allocated tracked revision ids, in document order: its stamp's
1560
- * id and the new ids its other records took. Existing ids retained by a
1561
- * folded or continued review are excluded; a direct operation reports none.
1562
- */
1563
- revisions: readonly number[];
1564
- };
1565
- /** Apply one operation to a document that meets the seed contract. */
1566
- export declare const applyDocumentOp: (document: Document, input: DocumentOp) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1567
- /** Apply a journal envelope only when its schema matches this reader. */
1568
- export declare const applyDocumentOpEnvelope: (document: Document, envelope: {
1569
- schema: number;
1570
- op: DocumentOp;
1571
- }) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1572
1765
  /**
1573
- * Apply operations in order, atomically: the first refusal is returned and
1574
- * the document is unchanged. The inverse undoes the whole list, and
1575
- * `revisions` lists each operation's in turn.
1766
+ * The registration a paragraph's snapshot stands on, as an opaque token: the
1767
+ * same object while nothing registers or transfers another one for it. A pass
1768
+ * that registered a snapshot can tell from it that registering again would
1769
+ * change nothing.
1576
1770
  */
1577
- export declare const applyDocumentOps: (document: Document, ops: readonly DocumentOp[]) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1771
+ export declare const paragraphPropertySnapshotToken: (paragraph: Paragraph) => object | undefined;
1578
1772
  /**
1579
1773
  * Every `TextFormatting` field, named so the comparison below is total.
1580
1774
  *
@@ -1678,6 +1872,8 @@ export declare const planTrackedDeletion: (document: Document, options: PlanTrac
1678
1872
  * paragraphs require an explicit package import policy.
1679
1873
  */
1680
1874
  type PlanTrackedReplaceOptions = PlanTrackedDeletionOptions & {
1875
+ /** How the deletion carrying the edit's own id is recorded, when not as `revision`. */
1876
+ deletionRevision?: RevisionStamp;
1681
1877
  sourceContainerPolicy: "join" | "separate";
1682
1878
  seamPolicy?: Extract<DocumentOp, {
1683
1879
  type: "insertContent";
@@ -1873,4 +2069,4 @@ export declare const orderAddressingBeforeRemoval: <T, Block>(ordered: readonly
1873
2069
  * requested sequence, which no series of single edits produces.
1874
2070
  */
1875
2071
  export declare const groupInsertionRuns: <T>(operations: readonly T[], insertionPositionOf: (operation: T) => number | null, keepsGap?: (operation: T) => boolean) => T[][];
1876
- 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, TableEditOp, TableIntentOperation, TextPosition, TouchedBlocks, UpdateCommentContentOp, WellFormedRangePlan, ZeroWidthItem };
2072
+ 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, NewListInstance, 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 };