@stll/docx-core 0.31.0 → 0.32.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 { $t as ParagraphMarkChange, Br as TableCellFormatting, Dr as NumberingDefinitions, Fn as Table, Kr as TableRowFormatting, M as BlockContent, Or as NumberingInstance, Pn as TabContent, Pr as ParagraphFormatting, Qt as ParagraphContent, R as BreakContent, Vr as TableFormatting, Wn as TableRow, X as DocumentBody, Yr as TextFormatting, Zt as Paragraph, _t as INSERTION_SEAM_POLICIES, bn as SectionProperties, c as ExhaustiveFields, i as DocumentSettings, mn as RunContent, mt as HeaderFooterType, nt as Endnote, o as DocxPackage, pn as Run, pt as HeaderFooter, r as Document, tn as ParagraphPropertyChange, ut as Footnote, vr as AbstractNumbering, yn as Section } from "../document-w6pPLpob.js";
1
+ import { $t as ParagraphMarkChange, Br as TableCellFormatting, Dr as NumberingDefinitions, Fn as Table, Kr as TableRowFormatting, M as BlockContent, Or as NumberingInstance, Pn as TabContent, Pr as ParagraphFormatting, Qt as ParagraphContent, R as BreakContent, Vr as TableFormatting, Wn as TableRow, X as DocumentBody, Yr as TextFormatting, Zt as Paragraph, _t as INSERTION_SEAM_POLICIES, bn as SectionProperties, c as ExhaustiveFields, h as Relationship, i as DocumentSettings, m as MediaFile, mi as HeadingOutlineLevel, mn as RunContent, mt as HeaderFooterType, nt as Endnote, o as DocxPackage, pn as Run, pt as HeaderFooter, r as Document, tn as ParagraphPropertyChange, ut as Footnote, vr as AbstractNumbering, y as StyleDefinitions, yn as Section } from "../document-C73n0FqK.js";
2
2
  import { Result } from "better-result";
3
3
  //#region src/ops/noteMarks.d.ts
4
4
  declare const noteUsesCustomMark: (document: Document, note: Footnote | Endnote) => boolean;
@@ -35,6 +35,7 @@ type SectionViewChange = {
35
35
  /**
36
36
  * The operation schema this module reads and writes.
37
37
  *
38
+ * Version 9 adds exact, JSON-safe package resource replacement for clipboard imports.
38
39
  * Version 8 adds semantic table edits and exact whole-table restoration.
39
40
  * Version 7 adds lossless own-undefined operation snapshot presence and
40
41
  * explicit revision-boundary provenance. An explicit undefined patch value now
@@ -56,7 +57,7 @@ type SectionViewChange = {
56
57
  * and paragraph operations, and the review operations `setParagraphReview`,
57
58
  * `replaceInline` and `resolveRevision`.
58
59
  */
59
- declare const DOCUMENT_OP_SCHEMA_VERSION = 8;
60
+ declare const DOCUMENT_OP_SCHEMA_VERSION = 9;
60
61
  /**
61
62
  * The main story has a fixed address; other editable parts use their stable
62
63
  * relationship id or note id. Comment bodies are not yet editable stories.
@@ -171,7 +172,7 @@ declare const SECTION_BOUNDARY_POLICIES: Readonly<{
171
172
  readonly REMOVE: "remove";
172
173
  readonly REPLACE: "replace";
173
174
  }>;
174
- /** The operation kinds of schema version 8. */
175
+ /** The operation kinds of schema version 9. */
175
176
  declare const DOCUMENT_OP_TYPES: Readonly<{
176
177
  readonly CREATE_HEADER_FOOTER: "createHeaderFooter";
177
178
  readonly REMOVE_HEADER_FOOTER: "removeHeaderFooter";
@@ -212,6 +213,7 @@ declare const DOCUMENT_OP_TYPES: Readonly<{
212
213
  readonly CREATE_NUMBERING_INSTANCE: "createNumberingInstance";
213
214
  readonly DELETE_NUMBERING_INSTANCE: "deleteNumberingInstance";
214
215
  readonly SET_SECTION_ENDPOINT: "setSectionEndpoint";
216
+ readonly SET_PACKAGE_RESOURCES: "setPackageResources";
215
217
  }>;
216
218
  /** One of {@link DOCUMENT_OP_TYPES}. */
217
219
  type DocumentOpType = (typeof DOCUMENT_OP_TYPES)[keyof typeof DOCUMENT_OP_TYPES];
@@ -676,6 +678,50 @@ type DeleteNumberingInstanceOp = {
676
678
  expected?: NumberingPartState;
677
679
  restore?: NumberingPartState;
678
680
  };
681
+ /** Presence is explicit so inverses restore omitted and undefined package fields exactly. */
682
+ type PackageResourcePart<Value> = {
683
+ type: "omitted";
684
+ } | {
685
+ type: "undefined";
686
+ } | {
687
+ type: "present";
688
+ value: Value;
689
+ };
690
+ /** JSON-safe media bytes, rather than an ArrayBuffer that JSON discards. */
691
+ type PackageResourceMedia = Omit<MediaFile, "data"> & {
692
+ data: readonly number[];
693
+ };
694
+ /** Package definitions captured before and after an explicit clipboard import. */
695
+ type PackageResources = {
696
+ styles: PackageResourcePart<StyleDefinitions>;
697
+ numbering: PackageResourcePart<NumberingDefinitions>;
698
+ };
699
+ type PackageResourcePresence = PackageResourcePart<unknown>["type"];
700
+ type PackageResourceEntry<Value> = {
701
+ type: "absent";
702
+ } | {
703
+ type: "present";
704
+ value: Value;
705
+ };
706
+ type PackageResourceEntryChange<Value> = {
707
+ key: string;
708
+ expected: PackageResourceEntry<Value>;
709
+ next: PackageResourceEntry<Value>;
710
+ };
711
+ /** Keyed changes to a package map; entries the operation leaves alone are not carried. */
712
+ type PackageResourceMapChange<Value> = {
713
+ expected: PackageResourcePresence;
714
+ next: PackageResourcePresence;
715
+ entries: readonly PackageResourceEntryChange<Value>[];
716
+ };
717
+ /** Replace merged definitions and change keyed package entries, refusing stale package data. */
718
+ type SetPackageResourcesOp = {
719
+ type: typeof DOCUMENT_OP_TYPES.SET_PACKAGE_RESOURCES;
720
+ expected: PackageResources;
721
+ resources: PackageResources;
722
+ relationships: PackageResourceMapChange<Relationship>;
723
+ media: PackageResourceMapChange<PackageResourceMedia>;
724
+ };
679
725
  /** A section endpoint is either a paragraph's sectPr or the body's final sectPr. */
680
726
  type SectionEndpoint = {
681
727
  type: "paragraph";
@@ -855,8 +901,8 @@ type TableEditOp = InsertColumnOp | DeleteColumnOp | MergeCellsOp | SplitCellOp
855
901
  type TableIntentOperation = { [Kind in TableEditOp["type"]]: Omit<Extract<TableEditOp, {
856
902
  type: Kind;
857
903
  }>, "revision" | "newIds" | "newBlockIds">; }[TableEditOp["type"]];
858
- /** A schema-version-8 document operation. */
859
- type DocumentOp = (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) & {
904
+ /** A schema-version-9 document operation. */
905
+ type DocumentOp = (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) & {
860
906
  /** Own undefined fields recorded by the operation capture boundary. */
861
907
  undefinedFields?: readonly (readonly string[])[];
862
908
  };
@@ -1011,91 +1057,51 @@ declare const documentStories: (document: Document) => OpStory[];
1011
1057
  /** Capture own undefined fields before an operation enters its JSON journal. */
1012
1058
  declare const captureDocumentOp: (op: DocumentOp) => DocumentOp;
1013
1059
  //#endregion
1014
- //#region src/ops/apply.d.ts
1015
- /** A document an operation produced, the operations that undo it, and what it changed. */
1016
- type AppliedDocumentOp = {
1017
- document: Document;
1018
- /** Apply in order to restore the input document. */
1019
- inverse: readonly DocumentOp[];
1020
- touched: TouchedBlocks;
1021
- /**
1022
- * Newly allocated tracked revision ids, in document order: its stamp's
1023
- * id and the new ids its other records took. Existing ids retained by a
1024
- * folded or continued review are excluded; a direct operation reports none.
1025
- */
1026
- revisions: readonly number[];
1060
+ //#region src/ops/leaves.d.ts
1061
+ /** A place between two leaves. */
1062
+ type Gap = {
1063
+ offset: number;
1064
+ zeroWidthBefore: number;
1027
1065
  };
1028
- /** Apply one operation to a document that meets the seed contract. */
1029
- declare const applyDocumentOp: (document: Document, input: DocumentOp) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1030
- /** Apply a journal envelope only when its schema matches this reader. */
1031
- declare const applyDocumentOpEnvelope: (document: Document, envelope: {
1032
- schema: number;
1033
- op: DocumentOp;
1034
- }) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1066
+ /** A node of a paragraph's content tree: a paragraph child or a run child. */
1067
+ type InlineNode = ParagraphContent | RunContent;
1068
+ /** The zero-width leaves at an offset, in document order. */
1069
+ declare const zeroWidthLeavesAt: (items: readonly InlineNode[], offset: number) => InlineNode[];
1035
1070
  /**
1036
- * Apply operations in order, atomically: the first refusal is returned and
1037
- * the document is unchanged. The inverse undoes the whole list, and
1038
- * `revisions` lists each operation's in turn.
1071
+ * The gap an insertion defaults to: before the first zero-width leaf at the
1072
+ * offset that opens a range, so a marker opening there stays with what
1073
+ * follows it and every other one with what precedes it.
1039
1074
  */
1040
- declare const applyDocumentOps: (document: Document, ops: readonly DocumentOp[]) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1075
+ declare const defaultInsertionGap: (items: readonly InlineNode[], offset: number) => Gap;
1076
+ /** Source leaf coordinates without the ancestry needed by edit planning. */
1077
+ declare const inlineLeafSpans: (items: readonly InlineNode[]) => {
1078
+ node: InlineNode;
1079
+ before: Gap;
1080
+ after: Gap;
1081
+ }[];
1082
+ /** Gaps in document order: by offset, then by the zero-width leaves before them. */
1083
+ declare const compareGaps: (left: Gap, right: Gap) => number;
1041
1084
  //#endregion
1042
- //#region src/ops/runMerge.d.ts
1043
- /**
1044
- * Every `TextFormatting` field, named so the comparison below is total.
1045
- *
1046
- * A field this comparison forgets is a field one of two merged runs loses,
1047
- * silently and at parse time. Naming them turns a field added to the model
1048
- * without a comparison into a compile error rather than a fidelity defect.
1049
- */
1050
- type ComparedTextFormattingField = "bold" | "boldCs" | "italic" | "italicCs" | "underline" | "strike" | "doubleStrike" | "vertAlign" | "smallCaps" | "allCaps" | "hidden" | "noProof" | "color" | "highlight" | "shading" | "fontSize" | "fontSizeCs" | "fontFamily" | "language" | "spacing" | "position" | "scale" | "kerning" | "effect" | "emphasisMark" | "emboss" | "imprint" | "outline" | "shadow" | "rtl" | "cs" | "styleId" | "preserved";
1051
- type ComparedTextFormatting = ExhaustiveFields<TextFormatting, ComparedTextFormattingField>;
1052
- /**
1053
- * Check if two TextFormatting objects are equivalent
1054
- *
1055
- * Uses deep comparison of all properties to determine if runs
1056
- * can be merged without losing formatting information.
1057
- */
1058
- declare function formattingEquals(a: ComparedTextFormatting | undefined, b: ComparedTextFormatting | undefined): boolean;
1059
- /**
1060
- * Check if a run contains only text content
1061
- * (runs with special content like images, fields, etc. should not be merged)
1062
- */
1063
- declare function isTextOnlyRun(run: Run): boolean;
1064
- /**
1065
- * Every `Run` field, named by what a merge does with it.
1066
- *
1067
- * The merged run is the survivor spread whole, so a field added to the model
1068
- * is carried over from one side by default. Naming each one here forces the
1069
- * next field to state whether that default is right before it can compile.
1070
- */
1071
- type MergeDecidedRunField =
1072
- /** Identical for every run. */
1073
- "type" |
1074
- /** Concatenated; see {@link mergeRunContent}. */
1075
- "content" |
1076
- /** Must be equal, and the survivor keeps it. */
1077
- "formatting" |
1078
- /** Must be equal, and the survivor keeps it. */
1079
- "preservedAttributes" |
1080
- /** Refuses the merge outright; see {@link canMergeRun}. */
1081
- "propertyChanges";
1082
- type MergeDecidedRun = ExhaustiveFields<Run, MergeDecidedRunField>;
1083
- /**
1084
- * May two adjacent runs become one?
1085
- *
1086
- * Every consolidation site asks this one question, because a merge that any
1087
- * one site decides differently is a merge the next parse undoes. A run holds
1088
- * three records a merged run can hold only one of: its typed formatting, the
1089
- * attributes `w:r` carried that the model has no field for, and the `w:rPr`
1090
- * children no reader took a value from. Merging two runs that disagree on any
1091
- * of them discards the loser's copy, which is how both runs' `w:rsid*` used to
1092
- * vanish at parse time — before the editor, before any gate could see it.
1093
- */
1094
- declare function runsMergeable(a: MergeDecidedRun, b: MergeDecidedRun): boolean;
1095
- /**
1096
- * Merge the content of two runs into a single content array
1097
- */
1098
- declare function mergeRunContent(content1: RunContent[], content2: RunContent[]): RunContent[];
1085
+ //#region src/ops/hyperlinkIntent.d.ts
1086
+ type HyperlinkEditorIntent = {
1087
+ type: "setHyperlink";
1088
+ from: TextPosition;
1089
+ to: TextPosition;
1090
+ href: string;
1091
+ tooltip?: string;
1092
+ } | {
1093
+ type: "removeHyperlink";
1094
+ from: TextPosition;
1095
+ to: TextPosition;
1096
+ hyperlinkStyleId?: string;
1097
+ } | {
1098
+ type: "insertHyperlink";
1099
+ from: TextPosition;
1100
+ to: TextPosition;
1101
+ text: string;
1102
+ href: string;
1103
+ tooltip?: string;
1104
+ };
1099
1105
  //#endregion
1100
1106
  //#region src/ops/editorIntent.d.ts
1101
1107
  type SplitParagraphIntent = {
@@ -1104,9 +1110,24 @@ type SplitParagraphIntent = {
1104
1110
  to?: TextPosition;
1105
1111
  };
1106
1112
  /** Positions use canonical physical offsets, including retained deleted content. */
1107
- type EditorIntent = {
1113
+ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
1108
1114
  type: "table";
1109
1115
  operation: TableIntentOperation;
1116
+ } | {
1117
+ type: "replaceFragment";
1118
+ from: TextPosition;
1119
+ to: TextPosition;
1120
+ paragraphs: readonly Paragraph[];
1121
+ openStart: 0 | 1;
1122
+ openEnd: 0 | 1;
1123
+ } | {
1124
+ type: "moveFragment";
1125
+ from: TextPosition;
1126
+ to: TextPosition;
1127
+ target: TextPosition;
1128
+ paragraphs: readonly Paragraph[];
1129
+ openStart: 0 | 1;
1130
+ openEnd: 0 | 1;
1110
1131
  } | {
1111
1132
  type: "replaceText";
1112
1133
  from: TextPosition;
@@ -1154,16 +1175,21 @@ type EditorIntent = {
1154
1175
  };
1155
1176
  /** Revision metadata and every fresh identity are supplied before compilation. */
1156
1177
  type EditorIntentMode = {
1178
+ /** Identities consumed during this editor lifetime, including undone insertions. */
1179
+ reservedBlockIds?: ReadonlySet<string>;
1180
+ } & ({
1157
1181
  type: "editing";
1158
1182
  newIds?: NewIds;
1159
1183
  } | {
1160
1184
  type: "suggesting";
1161
1185
  revision: RevisionStamp;
1162
1186
  newIds: NewIds;
1163
- };
1187
+ });
1164
1188
  type CompileEditorIntentOptions = {
1165
1189
  intent: EditorIntent;
1166
1190
  mode: EditorIntentMode;
1191
+ /** Lowest candidate for compiler-owned pasted block IDs, including retired session IDs. */
1192
+ firstBlockId?: number;
1167
1193
  };
1168
1194
  type CompiledEditorIntent = {
1169
1195
  ops: DocumentOp[];
@@ -1195,7 +1221,120 @@ declare const editorParagraphGroups: (document: Document, story: OpStory) => {
1195
1221
  text: string;
1196
1222
  }[];
1197
1223
  /** Compile one batch; the caller applies it atomically and journals its exact inverse. */
1198
- declare const compileEditorIntent: (document: Document, { intent, mode }: CompileEditorIntentOptions) => Result<CompiledEditorIntent, DocumentOpRefusal>;
1224
+ declare const compileEditorIntent: (document: Document, { intent, mode, firstBlockId }: CompileEditorIntentOptions) => Result<CompiledEditorIntent, DocumentOpRefusal>;
1225
+ //#endregion
1226
+ //#region src/ops/tocIntent.d.ts
1227
+ type TocHeading = {
1228
+ blockId: string;
1229
+ text: string;
1230
+ /** Zero-based OOXML outline level, from 0 through 8. */
1231
+ level: HeadingOutlineLevel;
1232
+ styleId?: string;
1233
+ };
1234
+ type GenerateTOCIntent = {
1235
+ type: "generateTOC";
1236
+ at: TextPosition;
1237
+ title: string;
1238
+ headings: readonly TocHeading[];
1239
+ titleStyleId?: string;
1240
+ tabPosition: number;
1241
+ };
1242
+ /** Map original endpoints through the bookmark wrappers emitted by TOC compilation. */
1243
+ declare const mapTocBookmarkPosition: (position: TextPosition, ops: readonly DocumentOp[]) => TextPosition;
1244
+ //#endregion
1245
+ //#region src/ops/packageResources.d.ts
1246
+ type PackageResourcesOpOptions = {
1247
+ before: Document;
1248
+ after: Document;
1249
+ };
1250
+ /** Describe the package resource difference as one operation carrying only changed entries. */
1251
+ declare const packageResourcesOpOf: ({ before, after }: PackageResourcesOpOptions) => SetPackageResourcesOp;
1252
+ //#endregion
1253
+ //#region src/ops/apply.d.ts
1254
+ /** A document an operation produced, the operations that undo it, and what it changed. */
1255
+ type AppliedDocumentOp = {
1256
+ document: Document;
1257
+ /** Apply in order to restore the input document. */
1258
+ inverse: readonly DocumentOp[];
1259
+ touched: TouchedBlocks;
1260
+ /**
1261
+ * Newly allocated tracked revision ids, in document order: its stamp's
1262
+ * id and the new ids its other records took. Existing ids retained by a
1263
+ * folded or continued review are excluded; a direct operation reports none.
1264
+ */
1265
+ revisions: readonly number[];
1266
+ };
1267
+ /** Apply one operation to a document that meets the seed contract. */
1268
+ declare const applyDocumentOp: (document: Document, input: DocumentOp) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1269
+ /** Apply a journal envelope only when its schema matches this reader. */
1270
+ declare const applyDocumentOpEnvelope: (document: Document, envelope: {
1271
+ schema: number;
1272
+ op: DocumentOp;
1273
+ }) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1274
+ /**
1275
+ * Apply operations in order, atomically: the first refusal is returned and
1276
+ * the document is unchanged. The inverse undoes the whole list, and
1277
+ * `revisions` lists each operation's in turn.
1278
+ */
1279
+ declare const applyDocumentOps: (document: Document, ops: readonly DocumentOp[]) => Result<AppliedDocumentOp, DocumentOpRefusal>;
1280
+ //#endregion
1281
+ //#region src/ops/runMerge.d.ts
1282
+ /**
1283
+ * Every `TextFormatting` field, named so the comparison below is total.
1284
+ *
1285
+ * A field this comparison forgets is a field one of two merged runs loses,
1286
+ * silently and at parse time. Naming them turns a field added to the model
1287
+ * without a comparison into a compile error rather than a fidelity defect.
1288
+ */
1289
+ type ComparedTextFormattingField = "bold" | "boldCs" | "italic" | "italicCs" | "underline" | "strike" | "doubleStrike" | "vertAlign" | "smallCaps" | "allCaps" | "hidden" | "noProof" | "color" | "highlight" | "shading" | "fontSize" | "fontSizeCs" | "fontFamily" | "language" | "spacing" | "position" | "scale" | "kerning" | "effect" | "emphasisMark" | "emboss" | "imprint" | "outline" | "shadow" | "rtl" | "cs" | "styleId" | "preserved";
1290
+ type ComparedTextFormatting = ExhaustiveFields<TextFormatting, ComparedTextFormattingField>;
1291
+ /**
1292
+ * Check if two TextFormatting objects are equivalent
1293
+ *
1294
+ * Uses deep comparison of all properties to determine if runs
1295
+ * can be merged without losing formatting information.
1296
+ */
1297
+ declare function formattingEquals(a: ComparedTextFormatting | undefined, b: ComparedTextFormatting | undefined): boolean;
1298
+ /**
1299
+ * Check if a run contains only text content
1300
+ * (runs with special content like images, fields, etc. should not be merged)
1301
+ */
1302
+ declare function isTextOnlyRun(run: Run): boolean;
1303
+ /**
1304
+ * Every `Run` field, named by what a merge does with it.
1305
+ *
1306
+ * The merged run is the survivor spread whole, so a field added to the model
1307
+ * is carried over from one side by default. Naming each one here forces the
1308
+ * next field to state whether that default is right before it can compile.
1309
+ */
1310
+ type MergeDecidedRunField =
1311
+ /** Identical for every run. */
1312
+ "type" |
1313
+ /** Concatenated; see {@link mergeRunContent}. */
1314
+ "content" |
1315
+ /** Must be equal, and the survivor keeps it. */
1316
+ "formatting" |
1317
+ /** Must be equal, and the survivor keeps it. */
1318
+ "preservedAttributes" |
1319
+ /** Refuses the merge outright; see {@link canMergeRun}. */
1320
+ "propertyChanges";
1321
+ type MergeDecidedRun = ExhaustiveFields<Run, MergeDecidedRunField>;
1322
+ /**
1323
+ * May two adjacent runs become one?
1324
+ *
1325
+ * Every consolidation site asks this one question, because a merge that any
1326
+ * one site decides differently is a merge the next parse undoes. A run holds
1327
+ * three records a merged run can hold only one of: its typed formatting, the
1328
+ * attributes `w:r` carried that the model has no field for, and the `w:rPr`
1329
+ * children no reader took a value from. Merging two runs that disagree on any
1330
+ * of them discards the loser's copy, which is how both runs' `w:rsid*` used to
1331
+ * vanish at parse time — before the editor, before any gate could see it.
1332
+ */
1333
+ declare function runsMergeable(a: MergeDecidedRun, b: MergeDecidedRun): boolean;
1334
+ /**
1335
+ * Merge the content of two runs into a single content array
1336
+ */
1337
+ declare function mergeRunContent(content1: RunContent[], content2: RunContent[]): RunContent[];
1199
1338
  //#endregion
1200
1339
  //#region src/ops/contract.d.ts
1201
1340
  declare const DocumentOpsContractError_base: import("better-result").TaggedErrorClass<"DocumentOpsContractError">;
@@ -1227,6 +1366,12 @@ declare const paragraphLogicalText: (paragraph: Paragraph) => string;
1227
1366
  //#region src/ops/ids.d.ts
1228
1367
  /** Every paragraph id of a package, each story walked once. */
1229
1368
  declare const packageParagraphIds: (pkg: DocxPackage) => string[];
1369
+ /**
1370
+ * The key two spellings of one id share. `ST_LongHexNumber` is hex, so
1371
+ * `0000abcd` and `0000ABCD` are the same id; every lookup and comparison of
1372
+ * paragraph ids goes through this.
1373
+ */
1374
+ declare const idKey: (id: string) => string;
1230
1375
  //#endregion
1231
1376
  //#region src/ops/plan.d.ts
1232
1377
  /**
@@ -1258,10 +1403,12 @@ declare const planTrackedDeletion: (document: Document, options: PlanTrackedDele
1258
1403
  * paragraph, and the inline tail inserted into the retained original paragraph.
1259
1404
  * Each new paragraph's own fields apply to it, including when it takes the
1260
1405
  * source prefix. The last fragment keeps the original survivor's identity.
1261
- * Closed inline slices are required; review and content-control ids in the
1262
- * fragment, and section-bearing paragraphs, are unsupported.
1406
+ * Closed inline slices are required. Imported review and content-control ids
1407
+ * must already be distinct from destination identities; section-bearing
1408
+ * paragraphs require an explicit package import policy.
1263
1409
  */
1264
1410
  type PlanTrackedReplaceOptions = PlanTrackedDeletionOptions & {
1411
+ sourceContainerPolicy: "join" | "separate";
1265
1412
  seamPolicy?: Extract<DocumentOp, {
1266
1413
  type: "insertContent";
1267
1414
  }>["seamPolicy"];
@@ -1382,4 +1529,4 @@ declare const createClient: (document: Document) => {
1382
1529
  readonly notices: readonly ClientNotice[];
1383
1530
  };
1384
1531
  //#endregion
1385
- export { type AddNoteOp, type AppliedDocumentOp, BATCH_REJECTION_REASONS, BATCH_WIRE_OP_TYPES, BatchRejection, type BatchRejectionReason, type BlockInsertionPoint, type CreateHeaderFooterOp, type CreateNumberingInstanceOp, DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_SCHEMA_VERSION, DOCUMENT_OP_TYPES, type DeleteBlocksOp, type DeleteColumnOp, 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 ParagraphPropsPatch, type ParagraphReviewFields, type PlanTrackedDeletionOptions, type PlanTrackedReplaceOptions, REVISION_DECISIONS, type RemoveHeaderFooterOp, type RemoveNoteOp, type ReplaceBlocksOp, type ReplaceInlineOp, type ResolveRevisionOp, 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 SetContainerBlocksOp, 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, applyDocumentOp, applyDocumentOpEnvelope, applyDocumentOps, captureDocumentOp, combineEdits, compileEditorIntent, createClient, createEditorIntentIdAllocator, createSequencer, documentStories, editorParagraphGroups, findStoryBody, formattingEquals, isTextOnlyRun, mergeRunContent, normalizeForOps, noteUsesCustomMark, packageParagraphIds, paragraphLength, paragraphLogicalText, paragraphVisibleText, parseDocumentBatch, physicalOffsetAtVisibleOffset, planTrackedDeletion, planTrackedReplace, revisionIdDemand, runsMergeable, sameStory, sectionPropertiesAt, storyBody, toOpEnvelope, transformBatch, validateDocumentBatch, validateOpsDocument, validateSequencedBatch };
1532
+ export { type AddNoteOp, type AppliedDocumentOp, BATCH_REJECTION_REASONS, BATCH_WIRE_OP_TYPES, BatchRejection, type BatchRejectionReason, type BlockInsertionPoint, type CreateHeaderFooterOp, type CreateNumberingInstanceOp, DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_SCHEMA_VERSION, DOCUMENT_OP_TYPES, type DeleteBlocksOp, type DeleteColumnOp, 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 RestoreStoryPartsOp, type RevisionDecision, type RevisionStamp, type RunPropsPatch, SPLIT_HALVES, type SectionEndpoint, type SectionMapState, type SectionPropertiesState, type SectionViewEntry, type SectionViewState, type SequencedBatch, type SetCellPropsOp, 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, applyDocumentOp, applyDocumentOpEnvelope, applyDocumentOps, captureDocumentOp, combineEdits, compareGaps, compileEditorIntent, createClient, createEditorIntentIdAllocator, createSequencer, defaultInsertionGap, documentStories, editorParagraphGroups, findStoryBody, formattingEquals, idKey, inlineLeafSpans, isTextOnlyRun, mapTocBookmarkPosition, mergeRunContent, normalizeForOps, noteUsesCustomMark, packageParagraphIds, packageResourcesOpOf, paragraphLength, paragraphLogicalText, paragraphVisibleText, parseDocumentBatch, physicalOffsetAtVisibleOffset, planTrackedDeletion, planTrackedReplace, revisionIdDemand, runsMergeable, sameStory, sectionPropertiesAt, storyBody, toOpEnvelope, transformBatch, validateDocumentBatch, validateOpsDocument, validateSequencedBatch, zeroWidthLeavesAt };