@stll/docx-core 0.38.0 → 0.39.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,4 @@
1
- import { $r as TextFormatting, Cn as Section, Gr as TableFormatting, H as BreakContent, I as BlockContent, Jn as TableRow, Mr as NumberingInstance, Rn as TabContent, Rr as ParagraphFormatting, Sr as AbstractNumbering, W as Comment, Wr as TableCellFormatting, Xr as TableRowFormatting, _n as Run, _t as HeaderFooter, a as DocumentSettings, an as ParagraphPropertyChange, b as StyleDefinitions, et as DocumentBody, g as Relationship, h as MediaFile, i as Document, jr as NumberingDefinitions, l as ExhaustiveFields, mt as Footnote, nn as ParagraphContent, ot as Endnote, rn as ParagraphMarkChange, s as DocxPackage, tn as Paragraph, vi as HeadingOutlineLevel, vn as RunContent, vt as HeaderFooterType, wn as SectionProperties, xt as INSERTION_SEAM_POLICIES, zn as Table } from "../document-wNmygRXS.js";
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-BkGU2ctn.js";
2
2
  import { Result } from "better-result";
3
3
  //#region src/ops/types.d.ts
4
4
  /** JSON-safe map presence, including an explicitly undefined section map. */
@@ -54,12 +54,12 @@ type SectionViewChange = {
54
54
  * and paragraph operations, and the review operations `setParagraphReview`,
55
55
  * `replaceInline` and `resolveRevision`.
56
56
  */
57
- declare const DOCUMENT_OP_SCHEMA_VERSION = 10;
57
+ export declare const DOCUMENT_OP_SCHEMA_VERSION = 10;
58
58
  /**
59
59
  * The main story has a fixed address; other editable parts use their stable
60
60
  * relationship id or note id. Comment bodies are not yet editable stories.
61
61
  */
62
- declare const OP_STORIES: Readonly<{
62
+ export declare const OP_STORIES: Readonly<{
63
63
  readonly MAIN: "main";
64
64
  }>;
65
65
  /** The stable identity of an independently editable package story. */
@@ -105,7 +105,7 @@ type ParagraphPropsPatch = FormattingPatch<ParagraphFormatting>;
105
105
  * empty set. The two state the same thing; the choice is how an inverse
106
106
  * gives back a record in the spelling it had.
107
107
  */
108
- declare const EMPTY_PROPERTY_SETS: Readonly<{
108
+ export declare const EMPTY_PROPERTY_SETS: Readonly<{
109
109
  readonly OMIT: "omit";
110
110
  readonly KEEP: "keep";
111
111
  }>;
@@ -115,7 +115,7 @@ type EmptyPropertySet = (typeof EMPTY_PROPERTY_SETS)[keyof typeof EMPTY_PROPERTY
115
115
  * Inserted text takes the properties of the run it joins: the run holding the
116
116
  * unit before the position, or the one after it at the start of a paragraph.
117
117
  */
118
- declare const INHERIT_RUN_PROPS = "inherit";
118
+ export declare const INHERIT_RUN_PROPS = "inherit";
119
119
  /** The run properties inserted text carries. */
120
120
  type InsertedRunProps = typeof INHERIT_RUN_PROPS | TextFormatting;
121
121
  /**
@@ -170,7 +170,7 @@ declare const SECTION_BOUNDARY_POLICIES: Readonly<{
170
170
  readonly REPLACE: "replace";
171
171
  }>;
172
172
  /** The operation kinds of schema version 10. */
173
- declare const DOCUMENT_OP_TYPES: Readonly<{
173
+ export declare const DOCUMENT_OP_TYPES: Readonly<{
174
174
  readonly CREATE_COMMENT: "createComment";
175
175
  readonly UPDATE_COMMENT_CONTENT: "updateCommentContent";
176
176
  readonly SET_COMMENT_RESOLUTION: "setCommentResolution";
@@ -319,7 +319,7 @@ type JoinInlineOp = {
319
319
  depth: number;
320
320
  };
321
321
  /** Whether a tracked run patch appends an independently rejectable review. */
322
- declare const PROPERTY_REVIEW_POLICIES: Readonly<{
322
+ export declare const PROPERTY_REVIEW_POLICIES: Readonly<{
323
323
  readonly APPEND: "append";
324
324
  }>;
325
325
  /**
@@ -381,9 +381,9 @@ type SetParagraphPropsOp = {
381
381
  * (`w:pPr/w:rPr`) rather than to the paragraph properties a `w:pPrChange`
382
382
  * records.
383
383
  */
384
- declare const PARAGRAPH_MARK_FORMATTING_KEYS: readonly ["runProperties", "runInWithNext"];
384
+ export declare const PARAGRAPH_MARK_FORMATTING_KEYS: readonly ["runProperties", "runInWithNext"];
385
385
  /** Which half of a split, or of a join, a rule applies to. */
386
- declare const SPLIT_HALVES: Readonly<{
386
+ export declare const SPLIT_HALVES: Readonly<{
387
387
  readonly FIRST: "first";
388
388
  readonly SECOND: "second";
389
389
  }>;
@@ -570,7 +570,7 @@ type ReplaceInlineOp = {
570
570
  content: readonly ParagraphContent[];
571
571
  };
572
572
  /** What resolving a tracked change does with it. */
573
- declare const REVISION_DECISIONS: Readonly<{
573
+ export declare const REVISION_DECISIONS: Readonly<{
574
574
  readonly ACCEPT: "accept";
575
575
  readonly REJECT: "reject";
576
576
  }>;
@@ -808,11 +808,15 @@ type AddNoteOp = {
808
808
  type: typeof DOCUMENT_OP_TYPES.ADD_NOTE;
809
809
  at: TextPosition;
810
810
  note: Footnote | Endnote;
811
+ revision?: RevisionStamp;
812
+ newIds?: NewIds;
811
813
  };
812
814
  type RemoveNoteOp = {
813
815
  type: typeof DOCUMENT_OP_TYPES.REMOVE_NOTE;
814
816
  at: TextPosition;
815
817
  story: NoteStory;
818
+ revision?: RevisionStamp;
819
+ newIds?: NewIds;
816
820
  };
817
821
  type SetSectionPropsOp = {
818
822
  type: typeof DOCUMENT_OP_TYPES.SET_SECTION_PROPS;
@@ -996,7 +1000,7 @@ type DocumentOpEnvelope = {
996
1000
  op: DocumentOp;
997
1001
  };
998
1002
  /** An operation in the envelope it is journaled and sent in. */
999
- declare const toOpEnvelope: (op: DocumentOp) => DocumentOpEnvelope;
1003
+ export declare const toOpEnvelope: (op: DocumentOp) => DocumentOpEnvelope;
1000
1004
  /** The blocks an operation changed, by id. */
1001
1005
  type TouchedBlocks = {
1002
1006
  modified: readonly string[];
@@ -1013,14 +1017,14 @@ type DocumentEdit = {
1013
1017
  touched: TouchedBlocks;
1014
1018
  };
1015
1019
  /** Edits made in turn, starting from `document`, as one edit. */
1016
- declare const combineEdits: (document: Document, edits: readonly DocumentEdit[]) => DocumentEdit;
1020
+ export declare const combineEdits: (document: Document, edits: readonly DocumentEdit[]) => DocumentEdit;
1017
1021
  //#endregion
1018
1022
  //#region src/ops/refusal.d.ts
1019
1023
  /**
1020
1024
  * Why an operation was not applied. A refused operation changes nothing: the
1021
1025
  * document it was applied to is returned as it was.
1022
1026
  */
1023
- declare const DOCUMENT_OP_REFUSAL_REASONS: Readonly<{
1027
+ export declare const DOCUMENT_OP_REFUSAL_REASONS: Readonly<{
1024
1028
  /** The journal envelope uses a schema this reader does not implement. */
1025
1029
  readonly UNSUPPORTED_SCHEMA: "unsupportedSchema";
1026
1030
  /** No paragraph in the story carries the id. */
@@ -1118,7 +1122,7 @@ declare const DOCUMENT_OP_REFUSAL_REASONS: Readonly<{
1118
1122
  type DocumentOpRefusalReason = (typeof DOCUMENT_OP_REFUSAL_REASONS)[keyof typeof DOCUMENT_OP_REFUSAL_REASONS];
1119
1123
  declare const DocumentOpRefusal_base: import("better-result").TaggedErrorClass<"DocumentOpRefusal">;
1120
1124
  /** An operation the document cannot take as stated. */
1121
- declare class DocumentOpRefusal extends DocumentOpRefusal_base<{
1125
+ export declare class DocumentOpRefusal extends DocumentOpRefusal_base<{
1122
1126
  message: string;
1123
1127
  reason: DocumentOpRefusalReason;
1124
1128
  opType: DocumentOpType | undefined;
@@ -1132,45 +1136,85 @@ type Gap = {
1132
1136
  };
1133
1137
  /** A node of a paragraph's content tree: a paragraph child or a run child. */
1134
1138
  type InlineNode = ParagraphContent | RunContent;
1139
+ /** Comment anchors are preserved by planned deletion and cannot be wrapped. */
1140
+ declare const COMMENT_ANCHOR_TYPES: {
1141
+ readonly commentRangeStart: true;
1142
+ readonly commentRangeEnd: true;
1143
+ readonly commentReference: true;
1144
+ };
1145
+ type CommentAnchorCarrier = Extract<InlineNode, {
1146
+ type: keyof typeof COMMENT_ANCHOR_TYPES;
1147
+ }>;
1148
+ /** Whether a leaf carries an anchor rather than content covered by its range. */
1149
+ export declare const isCommentAnchorCarrierType: (type: string) => boolean;
1135
1150
  /** The zero-width leaves at an offset, in document order. */
1136
- declare const zeroWidthLeavesAt: (items: readonly InlineNode[], offset: number) => InlineNode[];
1151
+ export declare const zeroWidthLeavesAt: (items: readonly InlineNode[], offset: number) => InlineNode[];
1137
1152
  /**
1138
1153
  * The gap an insertion defaults to: before the first zero-width leaf at the
1139
1154
  * offset that opens a range, so a marker opening there stays with what
1140
1155
  * follows it and every other one with what precedes it.
1141
1156
  */
1142
- declare const defaultInsertionGap: (items: readonly InlineNode[], offset: number) => Gap;
1157
+ export declare const defaultInsertionGap: (items: readonly InlineNode[], offset: number) => Gap;
1143
1158
  /** Source leaf coordinates without the ancestry needed by edit planning. */
1144
- declare const inlineLeafSpans: (items: readonly InlineNode[]) => {
1159
+ export declare const inlineLeafSpans: (items: readonly InlineNode[]) => {
1145
1160
  node: InlineNode;
1146
1161
  before: Gap;
1147
1162
  after: Gap;
1148
1163
  }[];
1149
1164
  /** Gaps in document order: by offset, then by the zero-width leaves before them. */
1150
- declare const compareGaps: (left: Gap, right: Gap) => number;
1165
+ export declare const compareGaps: (left: Gap, right: Gap) => number;
1151
1166
  //#endregion
1152
1167
  //#region src/ops/comments.d.ts
1168
+ type CommentExhaustionInput = {
1169
+ type: "document";
1170
+ document: Document;
1171
+ id: number;
1172
+ } | {
1173
+ type: "coverage";
1174
+ anchorKind: Comment["anchorKind"];
1175
+ survivingNonCarrierContent: boolean;
1176
+ };
1177
+ /** Whether a statically ranged comment currently covers no document content. */
1178
+ export declare const isCommentExhausted: (input: CommentExhaustionInput) => boolean;
1179
+ /** Comment definitions whose root remains covered or projected, with replies. */
1180
+ export declare const survivingComments: (document: Document, projectedRootIds?: ReadonlySet<number>) => Comment[];
1181
+ /** Remove each supplied root and its recursive replies, preserving input order. */
1182
+ export declare const withoutCommentThreads: (comments: readonly Comment[], removedRootIds: ReadonlySet<number>) => Comment[];
1153
1183
  /**
1154
1184
  * Shared loaded-comment activation contract; legacy parentId revision associations stay explicit.
1155
1185
  * `allowedOrphans` names unanchored root comments the caller accepts ("all" for a loaded package).
1156
1186
  */
1157
- declare const commentDocumentIssue: (document: Document, allowedOrphans?: ReadonlySet<number> | "all") => string | undefined;
1187
+ export declare const commentDocumentIssue: (document: Document, allowedOrphans?: ReadonlySet<number> | "all") => string | undefined;
1158
1188
  /** Allocate from the package's annotation domains without a hidden mutable counter. */
1159
- declare const freshCommentId: (document: Document) => Result<number, DocumentOpRefusal>;
1189
+ export declare const freshCommentId: (document: Document) => Result<number, DocumentOpRefusal>;
1160
1190
  /** Reconcile modeled comment and numbering parts with their document relationships. */
1161
- declare const reconcileDocumentPartRelationships: (document: Document) => Document;
1191
+ export declare const reconcileDocumentPartRelationships: (document: Document) => Document;
1192
+ //#endregion
1193
+ //#region src/ops/copyOriginAncestors.d.ts
1194
+ type CopyOriginAncestorList = NonNullable<BookmarkEnd["copyOriginAncestors"]>;
1195
+ export declare const isCopyOriginAncestors: (value: unknown) => value is CopyOriginAncestorList;
1196
+ export declare const shiftCopyOriginAncestors: (origins: CopyOriginAncestorList | undefined, insertedOrdinal: number) => CopyOriginAncestorList | undefined;
1197
+ export declare const addCopyOriginAncestor: (origins: CopyOriginAncestorList | undefined, addedOrdinal: number) => CopyOriginAncestorList | undefined;
1198
+ export declare const acceptCopyOriginAncestors: (origins: CopyOriginAncestorList | undefined, acceptedOrdinal: number) => CopyOriginAncestorList | undefined;
1199
+ type RejectedCopyOriginAncestors = {
1200
+ type: "drop";
1201
+ } | {
1202
+ type: "retain";
1203
+ copyOriginAncestors?: CopyOriginAncestorList;
1204
+ };
1205
+ export declare const rejectCopyOriginAncestors: (origins: CopyOriginAncestorList | undefined, removedAddedAncestors: number) => RejectedCopyOriginAncestors;
1162
1206
  //#endregion
1163
1207
  //#region src/ops/noteMarks.d.ts
1164
- declare const noteUsesCustomMark: (document: Document, note: Footnote | Endnote) => boolean;
1208
+ export declare const noteUsesCustomMark: (document: Document, note: Footnote | Endnote) => boolean;
1165
1209
  //#endregion
1166
1210
  //#region src/ops/storyLifecycle.d.ts
1167
- declare const sectionPropertiesAt: (document: Document, sectionIndex: number) => SectionProperties | undefined;
1211
+ export declare const sectionPropertiesAt: (document: Document, sectionIndex: number) => SectionProperties | undefined;
1168
1212
  //#endregion
1169
1213
  //#region src/ops/stories.d.ts
1170
- declare const sameStory: (left: OpStory, right: OpStory) => boolean;
1171
- declare const findStoryBody: (document: Document, story: OpStory) => DocumentBody | undefined;
1172
- declare const storyBody: (document: Document, story: OpStory) => DocumentBody;
1173
- declare const documentStories: (document: Document) => OpStory[];
1214
+ export declare const sameStory: (left: OpStory, right: OpStory) => boolean;
1215
+ export declare const findStoryBody: (document: Document, story: OpStory) => DocumentBody | undefined;
1216
+ export declare const storyBody: (document: Document, story: OpStory) => DocumentBody;
1217
+ export declare const documentStories: (document: Document) => OpStory[];
1174
1218
  //#endregion
1175
1219
  //#region src/ops/blocks.d.ts
1176
1220
  /**
@@ -1178,11 +1222,190 @@ declare const documentStories: (document: Document) => OpStory[];
1178
1222
  * that does not line up with the blocks (a different section count) is left
1179
1223
  * for {@link sectionsInStep} to report.
1180
1224
  */
1181
- declare const withBodyContent: (body: DocumentBody, content: BlockContent[]) => DocumentBody;
1225
+ export declare const withBodyContent: (body: DocumentBody, content: BlockContent[]) => DocumentBody;
1226
+ //#endregion
1227
+ //#region src/ops/offsets.d.ts
1228
+ /**
1229
+ * The zero-width items a paragraph can hold, and whether each is content its
1230
+ * mark must not take away. None is. A range boundary is a position, not
1231
+ * content: a paragraph that goes leaves it where the paragraph was
1232
+ * (`paragraphRemains` in `rangeBoundaries.ts`), so it keeps no blank
1233
+ * paragraph standing. A comment reference remains one logical offset unit,
1234
+ * but moves as an anchor when its paragraph goes. A cached page break and a
1235
+ * note's own marker mark nothing a reader placed.
1236
+ */
1237
+ declare const ZERO_WIDTH_ITEMS_HOLD_CONTENT: {
1238
+ readonly commentReference: false;
1239
+ readonly bookmarkStart: false;
1240
+ readonly bookmarkEnd: false;
1241
+ readonly commentRangeStart: false;
1242
+ readonly commentRangeEnd: false;
1243
+ readonly moveFromRangeStart: false;
1244
+ readonly moveFromRangeEnd: false;
1245
+ readonly moveToRangeStart: false;
1246
+ readonly moveToRangeEnd: false;
1247
+ readonly renderedPageBreak: false;
1248
+ readonly noteMarker: false;
1249
+ };
1250
+ /** A zero-width item the paragraph-content rule classifies. */
1251
+ type ZeroWidthItem = keyof typeof ZERO_WIDTH_ITEMS_HOLD_CONTENT;
1252
+ declare const paragraphContentBrand: unique symbol;
1253
+ /**
1254
+ * Whether a paragraph holds content its mark must not take away. Only
1255
+ * {@link paragraphContentVerdict} makes one, so every paragraph-mark outcome,
1256
+ * in the engine and in the editor, is decided by the same rule.
1257
+ */
1258
+ type ParagraphContentVerdict = boolean & {
1259
+ readonly [paragraphContentBrand]: true;
1260
+ };
1261
+ /** The one paragraph-content rule: any width, or a zero-width item that is content. */
1262
+ export declare const paragraphContentVerdict: ({ width, zeroWidthItems }: {
1263
+ width: number;
1264
+ zeroWidthItems: Iterable<ZeroWidthItem>;
1265
+ }) => ParagraphContentVerdict;
1266
+ /** The number of logical units in a paragraph: its largest valid offset. */
1267
+ export declare const paragraphLength: (paragraph: Paragraph) => number;
1268
+ /** The character a unit that is not run text stands for in {@link paragraphLogicalText}. */
1269
+ export declare const OBJECT_REPLACEMENT_CHARACTER = "";
1270
+ /**
1271
+ * The paragraph's offset space as a string: run text as it stands and
1272
+ * {@link OBJECT_REPLACEMENT_CHARACTER} for every other unit, so index `i` of
1273
+ * the string is unit `i` of the paragraph.
1274
+ */
1275
+ export declare const paragraphLogicalText: (paragraph: Paragraph) => string;
1276
+ //#endregion
1277
+ //#region src/ops/blockDeletion.d.ts
1278
+ /** The single structural outcome of resolving a paragraph mark. */
1279
+ export declare const paragraphMarkOutcome: ({ follows, holdsContent, markWasAdded, containerStillEndsWithParagraph, followingTableCanReceiveRunIn, needsFollowingCommentHost, tableRemovalIsTrackable, removedSectionProperties, precedingSectionOwner, followingHasSectionProperties }: {
1280
+ follows: "paragraph" | "table" | "nothing";
1281
+ /** From {@link paragraphHoldsContent} or the editor's view of the same rule, never re-derived. */
1282
+ holdsContent: ParagraphContentVerdict;
1283
+ markWasAdded: boolean;
1284
+ /**
1285
+ * Read only when nothing follows: whether the block BEFORE this paragraph,
1286
+ * which becomes the container's last block once this one is removed, is a
1287
+ * paragraph. Never the container's current last child, which is this one.
1288
+ */
1289
+ containerStillEndsWithParagraph: boolean;
1290
+ followingTableCanReceiveRunIn: boolean;
1291
+ needsFollowingCommentHost?: boolean;
1292
+ tableRemovalIsTrackable?: boolean;
1293
+ removedSectionProperties?: boolean;
1294
+ precedingSectionOwner?: "unavailable" | "available" | "same" | "occupied";
1295
+ followingHasSectionProperties?: boolean;
1296
+ }) => ({
1297
+ kind: "join";
1298
+ } & SectionTransfer) | ({
1299
+ kind: "remove";
1300
+ } & SectionTransfer) | ({
1301
+ kind: "run-in";
1302
+ } & SectionTransfer) | ({
1303
+ kind: "keep";
1304
+ } & SectionTransfer) | ({
1305
+ kind: "refuse";
1306
+ reason: "untrackable";
1307
+ } & SectionTransfer);
1308
+ type SectionTransfer = {
1309
+ sectionDestination: "none" | "preceding" | "following";
1310
+ };
1311
+ //#endregion
1312
+ //#region src/ops/rangeBoundaries.d.ts
1313
+ declare const BOUNDARY_SIDES: {
1314
+ readonly bookmarkStart: {
1315
+ readonly family: "bookmark";
1316
+ readonly side: "start";
1317
+ };
1318
+ readonly bookmarkEnd: {
1319
+ readonly family: "bookmark";
1320
+ readonly side: "end";
1321
+ };
1322
+ readonly commentRangeStart: {
1323
+ readonly family: "comment";
1324
+ readonly side: "start";
1325
+ };
1326
+ readonly commentRangeEnd: {
1327
+ readonly family: "comment";
1328
+ readonly side: "end";
1329
+ };
1330
+ readonly moveFromRangeStart: {
1331
+ readonly family: "moveFrom";
1332
+ readonly side: "start";
1333
+ };
1334
+ readonly moveFromRangeEnd: {
1335
+ readonly family: "moveFrom";
1336
+ readonly side: "end";
1337
+ };
1338
+ readonly moveToRangeStart: {
1339
+ readonly family: "moveTo";
1340
+ readonly side: "start";
1341
+ };
1342
+ readonly moveToRangeEnd: {
1343
+ readonly family: "moveTo";
1344
+ readonly side: "end";
1345
+ };
1346
+ };
1347
+ type BoundaryType = keyof typeof BOUNDARY_SIDES;
1348
+ type Boundary = Extract<InlineNode, {
1349
+ type: BoundaryType;
1350
+ }>;
1351
+ type CommentAnchor$1 = CommentAnchorCarrier;
1352
+ /** A boundary a block list holds between its blocks. */
1353
+ type BlockBoundary = Exclude<Boundary, CommentAnchor$1>;
1354
+ /**
1355
+ * What a paragraph that goes whole leaves where it was: every bookmark and
1356
+ * move range boundary it holds, at any depth, as blocks in its place, and its
1357
+ * comment anchors for the nearest paragraph that stays to take. When a
1358
+ * comment needs that host, every carrier travels there together in source
1359
+ * order. A comment with both anchors there becomes a point there, so the
1360
+ * comment and its anchor survive the paragraph.
1361
+ */
1362
+ export declare const paragraphRemains: (content: readonly InlineNode[]) => {
1363
+ all: (Boundary | CommentAnchor$1)[];
1364
+ blocks: BlockBoundary[];
1365
+ comments: CommentAnchor$1[];
1366
+ placement: "blocks" | "previous";
1367
+ };
1368
+ /** One range boundary in document order, as {@link planWellFormedRanges} reads it. */
1369
+ type BoundaryOccurrence = {
1370
+ /** The marker's element and id: what two copies of one boundary share. */
1371
+ boundary: string;
1372
+ /** The range it belongs to: its family and id. */
1373
+ range: string;
1374
+ side: "start" | "end";
1375
+ /** Whether a rejection kept it from removed content. */
1376
+ kept: boolean;
1377
+ /**
1378
+ * The date of the revision a kept boundary came from. Of a kept start and
1379
+ * end out of order, the one kept from the later revision moves: that edit
1380
+ * put it out of order, and the earlier one stays where it was.
1381
+ */
1382
+ keptFrom?: string;
1383
+ };
1384
+ /** What makes kept boundaries' ranges well-formed, by index into the occurrences. */
1385
+ type WellFormedRangePlan = {
1386
+ dropped: number[];
1387
+ /** Each kept boundary that moves to just before or after the other end of its range. */
1388
+ moved: {
1389
+ moving: number;
1390
+ anchor: number;
1391
+ side: "before" | "after";
1392
+ }[];
1393
+ };
1394
+ /**
1395
+ * The one rule that makes every range a rejection kept boundaries of
1396
+ * well-formed, for the engine's model and the editor's document alike. A
1397
+ * kept copy of a boundary the story still holds is no boundary of its own and
1398
+ * goes (of several kept copies, the first stays); then, where such a range's
1399
+ * end comes before its start, the half the rejection kept closes on the
1400
+ * other: a kept end moves to just after the start, or else a kept start to
1401
+ * just before the end. A boundary that was standing never moves, and a range
1402
+ * still with more than one start or end is left as it is.
1403
+ */
1404
+ export declare const planWellFormedRanges: (occurrences: readonly BoundaryOccurrence[]) => WellFormedRangePlan;
1182
1405
  //#endregion
1183
1406
  //#region src/ops/wire.d.ts
1184
1407
  /** Capture own undefined fields before an operation enters its JSON journal. */
1185
- declare const captureDocumentOp: (op: DocumentOp) => DocumentOp;
1408
+ export declare const captureDocumentOp: (op: DocumentOp) => DocumentOp;
1186
1409
  //#endregion
1187
1410
  //#region src/ops/hyperlinkIntent.d.ts
1188
1411
  type HyperlinkEditorIntent = {
@@ -1300,7 +1523,7 @@ type CompiledEditorIntent = {
1300
1523
  /** A split's paragraph identity is allocated with its other fresh identities. */
1301
1524
  type EditorIntentAllocation = EditorIntent | SplitParagraphIntent;
1302
1525
  /** Cache only immutable document versions; never retain a retired version strongly. */
1303
- declare const createEditorIntentIdAllocator: () => (document: Document, intent: EditorIntentAllocation) => {
1526
+ export declare const createEditorIntentIdAllocator: () => (document: Document, intent: EditorIntentAllocation) => {
1304
1527
  revisionId: number;
1305
1528
  newBlockId: string;
1306
1529
  newIds: {
@@ -1309,25 +1532,25 @@ declare const createEditorIntentIdAllocator: () => (document: Document, intent:
1309
1532
  };
1310
1533
  };
1311
1534
  /** Accepted-view text without changing the canonical paragraph or its offset space. */
1312
- declare const paragraphVisibleText: (paragraph: Paragraph) => string;
1535
+ export declare const paragraphVisibleText: (paragraph: Paragraph) => string;
1313
1536
  /**
1314
1537
  * Right-affine translation: a visible gap follows retained deleted content at
1315
1538
  * that gap, so a new insertion never lands inside a deletion wrapper.
1316
1539
  * Invalid offsets remain invalid for the operation boundary to diagnose.
1317
1540
  */
1318
- declare const physicalOffsetAtVisibleOffset: (paragraph: Paragraph, offset: number) => number;
1541
+ export declare const physicalOffsetAtVisibleOffset: (paragraph: Paragraph, offset: number) => number;
1319
1542
  /** Deleted paragraph marks concatenate physical paragraphs in the editing view. */
1320
- declare const editorParagraphGroups: (document: Document, story: OpStory) => {
1543
+ export declare const editorParagraphGroups: (document: Document, story: OpStory) => {
1321
1544
  blockId: string;
1322
1545
  paragraphs: Paragraph[];
1323
1546
  text: string;
1324
1547
  }[];
1325
1548
  /** One logical paragraph and visible offset for a physical canonical address. */
1326
- declare const editorPositionAtPhysicalPosition: (document: Document, at: TextPosition) => TextPosition;
1549
+ export declare const editorPositionAtPhysicalPosition: (document: Document, at: TextPosition) => TextPosition;
1327
1550
  /** Translate an editing-view paragraph gap to its physical canonical address. */
1328
- declare const physicalPositionAtEditorOffset: (document: Document, at: TextPosition) => TextPosition;
1551
+ export declare const physicalPositionAtEditorOffset: (document: Document, at: TextPosition) => TextPosition;
1329
1552
  /** Compile one batch; the caller applies it atomically and journals its exact inverse. */
1330
- declare const compileEditorIntent: (document: Document, { intent, mode, firstBlockId }: CompileEditorIntentOptions) => Result<CompiledEditorIntent, DocumentOpRefusal>;
1553
+ export declare const compileEditorIntent: (document: Document, { intent, mode, firstBlockId }: CompileEditorIntentOptions) => Result<CompiledEditorIntent, DocumentOpRefusal>;
1331
1554
  //#endregion
1332
1555
  //#region src/ops/tocIntent.d.ts
1333
1556
  type TocHeading = {
@@ -1346,7 +1569,7 @@ type GenerateTOCIntent = {
1346
1569
  tabPosition: number;
1347
1570
  };
1348
1571
  /** Map original endpoints through the bookmark wrappers emitted by TOC compilation. */
1349
- declare const mapTocBookmarkPosition: (position: TextPosition, ops: readonly DocumentOp[]) => TextPosition;
1572
+ export declare const mapTocBookmarkPosition: (position: TextPosition, ops: readonly DocumentOp[]) => TextPosition;
1350
1573
  //#endregion
1351
1574
  //#region src/ops/packageResources.d.ts
1352
1575
  type PackageResourcesOpOptions = {
@@ -1354,7 +1577,7 @@ type PackageResourcesOpOptions = {
1354
1577
  after: Document;
1355
1578
  };
1356
1579
  /** Describe the package resource difference as one operation carrying only changed entries. */
1357
- declare const packageResourcesOpOf: ({ before, after }: PackageResourcesOpOptions) => SetPackageResourcesOp;
1580
+ export declare const packageResourcesOpOf: ({ before, after }: PackageResourcesOpOptions) => SetPackageResourcesOp;
1358
1581
  //#endregion
1359
1582
  //#region src/ops/paragraphPropertySnapshot.d.ts
1360
1583
  type RegisterParagraphPropertySnapshotOptions = {
@@ -1362,7 +1585,7 @@ type RegisterParagraphPropertySnapshotOptions = {
1362
1585
  snapshot: ParagraphFormatting | undefined;
1363
1586
  };
1364
1587
  /** Bind effective formatting to the authored properties a review must record. */
1365
- declare const registerParagraphPropertySnapshot: ({ paragraph, snapshot }: RegisterParagraphPropertySnapshotOptions) => void;
1588
+ export declare const registerParagraphPropertySnapshot: ({ paragraph, snapshot }: RegisterParagraphPropertySnapshotOptions) => void;
1366
1589
  //#endregion
1367
1590
  //#region src/ops/apply.d.ts
1368
1591
  /** A document an operation produced, the operations that undo it, and what it changed. */
@@ -1379,9 +1602,9 @@ type AppliedDocumentOp = {
1379
1602
  revisions: readonly number[];
1380
1603
  };
1381
1604
  /** Apply one operation to a document that meets the seed contract. */
1382
- declare const applyDocumentOp: (document: Document, input: DocumentOp) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1605
+ export declare const applyDocumentOp: (document: Document, input: DocumentOp) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1383
1606
  /** Apply a journal envelope only when its schema matches this reader. */
1384
- declare const applyDocumentOpEnvelope: (document: Document, envelope: {
1607
+ export declare const applyDocumentOpEnvelope: (document: Document, envelope: {
1385
1608
  schema: number;
1386
1609
  op: DocumentOp;
1387
1610
  }) => Result<AppliedDocumentOp, DocumentOpRefusal>;
@@ -1390,7 +1613,7 @@ declare const applyDocumentOpEnvelope: (document: Document, envelope: {
1390
1613
  * the document is unchanged. The inverse undoes the whole list, and
1391
1614
  * `revisions` lists each operation's in turn.
1392
1615
  */
1393
- declare const applyDocumentOps: (document: Document, ops: readonly DocumentOp[]) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1616
+ export declare const applyDocumentOps: (document: Document, ops: readonly DocumentOp[]) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1394
1617
  //#endregion
1395
1618
  //#region src/ops/runMerge.d.ts
1396
1619
  /**
@@ -1408,12 +1631,12 @@ type ComparedTextFormatting = ExhaustiveFields<TextFormatting, ComparedTextForma
1408
1631
  * Uses deep comparison of all properties to determine if runs
1409
1632
  * can be merged without losing formatting information.
1410
1633
  */
1411
- declare function formattingEquals(a: ComparedTextFormatting | undefined, b: ComparedTextFormatting | undefined): boolean;
1634
+ export declare function formattingEquals(a: ComparedTextFormatting | undefined, b: ComparedTextFormatting | undefined): boolean;
1412
1635
  /**
1413
1636
  * Check if a run contains only text content
1414
1637
  * (runs with special content like images, fields, etc. should not be merged)
1415
1638
  */
1416
- declare function isTextOnlyRun(run: Run): boolean;
1639
+ export declare function isTextOnlyRun(run: Run): boolean;
1417
1640
  /**
1418
1641
  * Every `Run` field, named by what a merge does with it.
1419
1642
  *
@@ -1444,59 +1667,49 @@ type MergeDecidedRun = ExhaustiveFields<Run, MergeDecidedRunField>;
1444
1667
  * of them discards the loser's copy, which is how both runs' `w:rsid*` used to
1445
1668
  * vanish at parse time — before the editor, before any gate could see it.
1446
1669
  */
1447
- declare function runsMergeable(a: MergeDecidedRun, b: MergeDecidedRun): boolean;
1670
+ export declare function runsMergeable(a: MergeDecidedRun, b: MergeDecidedRun): boolean;
1448
1671
  /**
1449
1672
  * Merge the content of two runs into a single content array
1450
1673
  */
1451
- declare function mergeRunContent(content1: RunContent[], content2: RunContent[]): RunContent[];
1674
+ export declare function mergeRunContent(content1: RunContent[], content2: RunContent[]): RunContent[];
1452
1675
  //#endregion
1453
1676
  //#region src/ops/contract.d.ts
1454
1677
  declare const DocumentOpsContractError_base: import("better-result").TaggedErrorClass<"DocumentOpsContractError">;
1455
1678
  /** A document that does not meet the seed contract. */
1456
- declare class DocumentOpsContractError extends DocumentOpsContractError_base<{
1679
+ export declare class DocumentOpsContractError extends DocumentOpsContractError_base<{
1457
1680
  message: string;
1458
1681
  reason: DocumentOpRefusalReason;
1459
1682
  }> {}
1460
1683
  /** Check a document against the seed contract. */
1461
- declare const validateOpsDocument: (document: Document) => Result<Document, DocumentOpsContractError>;
1684
+ export declare const validateOpsDocument: (document: Document) => Result<Document, DocumentOpsContractError>;
1462
1685
  /**
1463
1686
  * The document with every empty run and empty text node of each editable story
1464
1687
  * removed, and its section view derived again. Nothing else changes.
1465
1688
  */
1466
- declare const normalizeForOps: (document: Document) => Document;
1467
- //#endregion
1468
- //#region src/ops/offsets.d.ts
1469
- /** The number of logical units in a paragraph: its largest valid offset. */
1470
- declare const paragraphLength: (paragraph: Paragraph) => number;
1471
- /** The character a unit that is not run text stands for in {@link paragraphLogicalText}. */
1472
- declare const OBJECT_REPLACEMENT_CHARACTER = "";
1473
- /**
1474
- * The paragraph's offset space as a string: run text as it stands and
1475
- * {@link OBJECT_REPLACEMENT_CHARACTER} for every other unit, so index `i` of
1476
- * the string is unit `i` of the paragraph.
1477
- */
1478
- declare const paragraphLogicalText: (paragraph: Paragraph) => string;
1689
+ export declare const normalizeForOps: (document: Document) => Document;
1479
1690
  //#endregion
1480
1691
  //#region src/ops/ids.d.ts
1692
+ /** Every `paraId` of every paragraph in a value, nested ones included, in document order. */
1693
+ export declare const paragraphIdsIn: (value: unknown) => string[];
1481
1694
  /** Every paragraph id of a package, each story walked once. */
1482
- declare const packageParagraphIds: (pkg: DocxPackage) => string[];
1695
+ export declare const packageParagraphIds: (pkg: DocxPackage) => string[];
1483
1696
  /**
1484
1697
  * The key two spellings of one id share. `ST_LongHexNumber` is hex, so
1485
1698
  * `0000abcd` and `0000ABCD` are the same id; every lookup and comparison of
1486
1699
  * paragraph ids goes through this.
1487
1700
  */
1488
- declare const idKey: (id: string) => string;
1701
+ export declare const idKey: (id: string) => string;
1489
1702
  //#endregion
1490
1703
  //#region src/ops/plan.d.ts
1491
1704
  /** Package-aware explicit pools for every semantic comment anchor cut, including replies. */
1492
- declare const allocateCommentAnchorIds: (document: Document, op: CreateCommentOp) => Result<NewIds, DocumentOpRefusal>;
1705
+ export declare const allocateCommentAnchorIds: (document: Document, op: CreateCommentOp) => Result<NewIds, DocumentOpRefusal>;
1493
1706
  /**
1494
1707
  * How many `newIds.revision` entries an operation takes on a document,
1495
1708
  * besides its stamp's id: the length of the shortest list of unused ids it
1496
1709
  * applies with. Content-control ids are supplied freely while counting. The
1497
1710
  * refusal is the one the operation meets whatever ids it is given.
1498
1711
  */
1499
- declare const revisionIdDemand: (document: Document, op: DocumentOp) => Result<number, DocumentOpRefusal>;
1712
+ export declare const revisionIdDemand: (document: Document, op: DocumentOp) => Result<number, DocumentOpRefusal>;
1500
1713
  /** The range a tracked deletion covers, its stamp, and the ids its later pieces take. */
1501
1714
  type PlanTrackedDeletionOptions = {
1502
1715
  from: TextPosition;
@@ -1511,7 +1724,7 @@ type PlanTrackedDeletionOptions = {
1511
1724
  * Inline ranges run in reverse order, then joins run from last to first.
1512
1725
  * All physical revision ids come from one pool for the complete batch.
1513
1726
  */
1514
- declare const planTrackedDeletion: (document: Document, options: PlanTrackedDeletionOptions) => Result<DocumentOp[], DocumentOpRefusal>;
1727
+ export declare const planTrackedDeletion: (document: Document, options: PlanTrackedDeletionOptions) => Result<DocumentOp[], DocumentOpRefusal>;
1515
1728
  //#endregion
1516
1729
  //#region src/ops/rangeReplacement.d.ts
1517
1730
  /**
@@ -1538,7 +1751,7 @@ type PlanTrackedReplaceOptions = PlanTrackedDeletionOptions & {
1538
1751
  * deletion followed by the replacement fragment as tracked insertions.
1539
1752
  * All physical revision ids come from one pool for the complete batch.
1540
1753
  */
1541
- declare const planTrackedReplace: (document: Document, options: PlanTrackedReplaceOptions) => Result<DocumentOp[], DocumentOpRefusal>;
1754
+ export declare const planTrackedReplace: (document: Document, options: PlanTrackedReplaceOptions) => Result<DocumentOp[], DocumentOpRefusal>;
1542
1755
  //#endregion
1543
1756
  //#region src/ops/sequencing/envelope.d.ts
1544
1757
  /** A batch applies atomically, in array order, against its stated revision. */
@@ -1570,7 +1783,7 @@ type SequencedBatch = DocumentBatch & {
1570
1783
  revision: number;
1571
1784
  effects?: readonly SequencedOpEffect[];
1572
1785
  };
1573
- declare const BATCH_REJECTION_REASONS: {
1786
+ export declare const BATCH_REJECTION_REASONS: {
1574
1787
  readonly INVALID_BATCH: "invalidBatch";
1575
1788
  readonly UNSUPPORTED_SCHEMA: "unsupportedSchema";
1576
1789
  readonly UNSUPPORTED_PAIR: "unsupportedPair";
@@ -1581,29 +1794,29 @@ declare const BATCH_REJECTION_REASONS: {
1581
1794
  };
1582
1795
  type BatchRejectionReason = (typeof BATCH_REJECTION_REASONS)[keyof typeof BATCH_REJECTION_REASONS];
1583
1796
  declare const BatchRejection_base: import("better-result").TaggedErrorClass<"BatchRejection">;
1584
- declare class BatchRejection extends BatchRejection_base<{
1797
+ export declare class BatchRejection extends BatchRejection_base<{
1585
1798
  message: string;
1586
1799
  reason: BatchRejectionReason;
1587
1800
  opId?: string;
1588
1801
  opType?: DocumentOpType;
1589
1802
  overType?: DocumentOpType;
1590
1803
  }> {}
1591
- declare const BATCH_WIRE_OP_TYPES: readonly string[];
1804
+ export declare const BATCH_WIRE_OP_TYPES: readonly string[];
1592
1805
  /** Bound recursion and refuse values except JSON data and absent object fields. */
1593
- declare const MAX_BATCH_WIRE_BYTES: number;
1806
+ export declare const MAX_BATCH_WIRE_BYTES: number;
1594
1807
  /** Decode a JSON-shaped batch, refusing unsupported payloads before apply. */
1595
- declare const validateDocumentBatch: (value: unknown) => Result<DocumentBatch, BatchRejection>;
1808
+ export declare const validateDocumentBatch: (value: unknown) => Result<DocumentBatch, BatchRejection>;
1596
1809
  /** Validate an assigned revision and any document-dependent effect metadata. */
1597
- declare const validateSequencedBatch: (value: unknown) => Result<SequencedBatch, BatchRejection>;
1810
+ export declare const validateSequencedBatch: (value: unknown) => Result<SequencedBatch, BatchRejection>;
1598
1811
  /** Parse the wire representation without propagating parser exceptions. */
1599
- declare const parseDocumentBatch: (json: string) => Result<DocumentBatch, BatchRejection>;
1812
+ export declare const parseDocumentBatch: (json: string) => Result<DocumentBatch, BatchRejection>;
1600
1813
  //#endregion
1601
1814
  //#region src/ops/sequencing/transform.d.ts
1602
1815
  type TransformOptions = {
1603
1816
  order?: "before" | "after";
1604
1817
  };
1605
1818
  /** Rebase an atomic batch over an ordered journal tail. */
1606
- declare const transformBatch: (batch: DocumentBatch, over: readonly SequencedBatch[], options?: TransformOptions) => Result<DocumentBatch, BatchRejection>;
1819
+ export declare const transformBatch: (batch: DocumentBatch, over: readonly SequencedBatch[], options?: TransformOptions) => Result<DocumentBatch, BatchRejection>;
1607
1820
  //#endregion
1608
1821
  //#region src/ops/sequencing/sequencer.d.ts
1609
1822
  type BatchAck = {
@@ -1619,7 +1832,7 @@ type BatchReject = {
1619
1832
  };
1620
1833
  type BatchSubmission = BatchAck | BatchReject;
1621
1834
  /** Deterministic append-only authority; the caller supplies delivery and storage. */
1622
- declare const createSequencer: (document: Document) => {
1835
+ export declare const createSequencer: (document: Document) => {
1623
1836
  submit: (batch: DocumentBatch) => BatchSubmission;
1624
1837
  readonly document: Document;
1625
1838
  readonly headRev: number;
@@ -1633,7 +1846,7 @@ type ClientNotice = {
1633
1846
  ops: readonly DocumentOp[];
1634
1847
  };
1635
1848
  /** Optimistic state with ordered authoritative replay and one causal submission in flight. */
1636
- declare const createClient: (document: Document) => {
1849
+ export declare const createClient: (document: Document) => {
1637
1850
  enqueue: (batch: DocumentBatch) => Result<DocumentBatch, BatchRejection>;
1638
1851
  nextSubmission: () => DocumentBatch | undefined;
1639
1852
  receiveAck: (ack: BatchAck) => void;
@@ -1645,4 +1858,64 @@ declare const createClient: (document: Document) => {
1645
1858
  readonly notices: readonly ClientNotice[];
1646
1859
  };
1647
1860
  //#endregion
1648
- export { type AddNoteOp, type AppliedDocumentOp, BATCH_REJECTION_REASONS, BATCH_WIRE_OP_TYPES, BatchRejection, type BatchRejectionReason, type BlockInsertionPoint, type CommentAnchor, type CommentState, type CreateCommentOp, type CreateHeaderFooterOp, type CreateNumberingInstanceOp, DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_SCHEMA_VERSION, DOCUMENT_OP_TYPES, type DeleteBlocksOp, type DeleteColumnOp, type DeleteCommentOp, type DeleteNumberingInstanceOp, type DeleteRangeOp, type DeleteRowOp, type DeleteTableOp, type DocumentBatch, type DocumentOp, type DocumentOpEnvelope, DocumentOpRefusal, type DocumentOpRefusalReason, type DocumentOpType, DocumentOpsContractError, EMPTY_PROPERTY_SETS, type EditorIntent, type EditorIntentMode, type EmptyPropertySet, type FormattingPatch, type HeaderFooterStory, INHERIT_RUN_PROPS, type InlineSlice, type InsertBlocksOp, type InsertColumnOp, type InsertContentOp, type InsertRowOp, type InsertTableOp, type InsertTextOp, type InsertedRunProps, type JoinBlocksOp, type JoinInlineOp, MAX_BATCH_WIRE_BYTES, type MergeCellsOp, type NewIds, type NoteStory, type NumberingPartState, OBJECT_REPLACEMENT_CHARACTER, OP_STORIES, type OpStory, PARAGRAPH_MARK_FORMATTING_KEYS, PROPERTY_REVIEW_POLICIES, type PackageResourceEntry, type PackageResourceEntryChange, type PackageResourceMapChange, type PackageResourceMedia, type PackageResourcePart, type PackageResources, type ParagraphPropsPatch, type ParagraphReviewFields, type PlanTrackedDeletionOptions, type PlanTrackedReplaceOptions, REVISION_DECISIONS, type RemoveHeaderFooterOp, type RemoveNoteOp, type ReplaceBlocksOp, type ReplaceInlineOp, type ResolveRevisionOp, type RestoreCommentStateOp, type RestoreStoryPartsOp, type RevisionDecision, type RevisionStamp, type RunPropsPatch, SPLIT_HALVES, type SectionEndpoint, type SectionMapState, type SectionPropertiesState, type SectionViewEntry, type SectionViewState, type SequencedBatch, type SetCellPropsOp, type SetCommentResolutionOp, type SetContainerBlocksOp, type SetPackageResourcesOp, type SetParagraphPropsOp, type SetParagraphReviewOp, type SetRowPropsOp, type SetRunPropsOp, type SetSectionEndpointOp, type SetSectionPropsOp, type SetTableGridOp, type SetTableOp, type SetTablePropsOp, type SetTableRowsOp, type SplitBlockOp, type SplitCellOp, type SplitHalf, type SplitInlineOp, type SplitParagraphFields, type TableEditOp, type TableIntentOperation, type TextPosition, type TouchedBlocks, type UpdateCommentContentOp, allocateCommentAnchorIds, applyDocumentOp, applyDocumentOpEnvelope, applyDocumentOps, captureDocumentOp, combineEdits, commentDocumentIssue, compareGaps, compileEditorIntent, createClient, createEditorIntentIdAllocator, createSequencer, defaultInsertionGap, documentStories, editorParagraphGroups, editorPositionAtPhysicalPosition, findStoryBody, formattingEquals, freshCommentId, idKey, inlineLeafSpans, isTextOnlyRun, mapTocBookmarkPosition, mergeRunContent, normalizeForOps, noteUsesCustomMark, packageParagraphIds, packageResourcesOpOf, paragraphLength, paragraphLogicalText, paragraphVisibleText, parseDocumentBatch, physicalOffsetAtVisibleOffset, physicalPositionAtEditorOffset, planTrackedDeletion, planTrackedReplace, reconcileDocumentPartRelationships, registerParagraphPropertySnapshot, revisionIdDemand, runsMergeable, sameStory, sectionPropertiesAt, storyBody, toOpEnvelope, transformBatch, validateDocumentBatch, validateOpsDocument, validateSequencedBatch, withBodyContent, zeroWidthLeavesAt };
1861
+ //#region src/ops/batchOrder.d.ts
1862
+ /**
1863
+ * The execution coordinates of an operation resolved against a batch's
1864
+ * pre-state. Positions and table coordinates are ordered from right to left;
1865
+ * equal content coordinates use an explicit rank, then reverse input order.
1866
+ * Annotations run before moving edits, while table-shape and column edits run
1867
+ * after ordinary content edits. Table mutations in nested tables still run
1868
+ * right to left before the phase order is applied within the same table.
1869
+ */
1870
+ type BatchOrderAddress = {
1871
+ type: "annotation";
1872
+ position: number;
1873
+ inputIndex: number;
1874
+ } | {
1875
+ type: "content";
1876
+ position: number;
1877
+ rank: number;
1878
+ inputIndex: number;
1879
+ } | {
1880
+ type: "cell";
1881
+ tablePosition: number;
1882
+ bottom: number;
1883
+ right: number;
1884
+ inputIndex: number;
1885
+ } | {
1886
+ type: "column";
1887
+ tablePosition: number;
1888
+ columnIndex: number;
1889
+ insertion: boolean;
1890
+ inputIndex: number;
1891
+ };
1892
+ type ContentRankOperation = {
1893
+ type: string;
1894
+ position?: unknown;
1895
+ };
1896
+ /**
1897
+ * Rank content operations at one pre-batch target. A tracked split deletion
1898
+ * must retract the inserted paragraph before a table is placed after it;
1899
+ * ordinary edits stay between those two exceptional operations.
1900
+ */
1901
+ export declare const contentRank: (operation: ContentRankOperation, target: {
1902
+ hasDeletedSplit: boolean;
1903
+ }) => number;
1904
+ /** Compare two pre-batch addresses in the documented batch execution order. */
1905
+ export declare const compareBatchOrder: (left: BatchOrderAddress, right: BatchOrderAddress) => number;
1906
+ /** Order operations once from addresses captured before the batch changes the document. */
1907
+ export declare const orderBatchOperations: <T>(operations: readonly T[], addressOf: (operation: T) => BatchOrderAddress) => T[];
1908
+ /**
1909
+ * Partition an ordered batch into execution runs. Insertions at the same
1910
+ * position share a run; every other operation remains a singleton.
1911
+ *
1912
+ * An operation that `keepsGap` admits (one that writes properties and places
1913
+ * nothing in the gap) does not end a run: an equal-gap insertion after it
1914
+ * still joins the run, which runs before it. Otherwise a property write tied
1915
+ * between two insertions at one gap would split them, and they would inherit
1916
+ * their anchor's properties from different moments while landing in one
1917
+ * requested sequence, which no series of single edits produces.
1918
+ */
1919
+ export declare const groupInsertionRuns: <T>(operations: readonly T[], insertionPositionOf: (operation: T) => number | null, keepsGap?: (operation: T) => boolean) => T[][];
1920
+ //#endregion
1921
+ export type { AddNoteOp, AppliedDocumentOp, 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 };