@stll/folio-core 0.72.0 → 0.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +12 -6
  2. package/dist/ai-edits/apply.d.ts +6 -114
  3. package/dist/ai-edits/apply.js +9 -131
  4. package/dist/ai-edits/applyTypes.d.ts +85 -0
  5. package/dist/ai-edits/applyTypes.js +24 -0
  6. package/dist/ai-edits/clean-text.d.ts +7 -1
  7. package/dist/ai-edits/clean-text.js +23 -2
  8. package/dist/ai-edits/finalSectionReview.d.ts +1 -1
  9. package/dist/ai-edits/headless.d.ts +29 -147
  10. package/dist/ai-edits/headless.js +213 -1634
  11. package/dist/ai-edits/index.d.ts +3 -3
  12. package/dist/ai-edits/index.js +2 -3
  13. package/dist/ai-edits/pending-suggestions.d.ts +14 -4
  14. package/dist/ai-edits/pending-suggestions.js +183 -90
  15. package/dist/ai-edits/result-validation.js +1 -1
  16. package/dist/ai-edits/retired-comment-receipts.d.ts +1 -1
  17. package/dist/ai-edits/snapshot.js +8 -3
  18. package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
  19. package/dist/ai-edits/table-cell-mutations.js +1 -1
  20. package/dist/ai-edits/table-geometry.d.ts +1 -1
  21. package/dist/ai-edits/table-geometry.js +1 -1
  22. package/dist/ai-edits/table-row-column-mutations.d.ts +1 -1
  23. package/dist/ai-edits/table-row-column-mutations.js +1 -1
  24. package/dist/ai-edits/tableNodes.d.ts +38 -0
  25. package/dist/ai-edits/tableNodes.js +86 -0
  26. package/dist/ai-edits/tracked-batch-fidelity.d.ts +1 -1
  27. package/dist/ai-edits/undefinedReferences.d.ts +7 -0
  28. package/dist/canonical/batchCommentReferences.js +1 -0
  29. package/dist/canonical/canonicalInlineProjection.js +1 -1
  30. package/dist/canonical/canonicalPublicOperations.js +228 -64
  31. package/dist/canonical/canonicalSession.d.ts +9 -1
  32. package/dist/canonical/canonicalSession.js +95 -15
  33. package/dist/compare/compare.d.ts +1 -1
  34. package/dist/compare/inline-atoms-model.d.ts +1 -1
  35. package/dist/compare/inline-atoms.d.ts +2 -2
  36. package/dist/compare/inline-provenance-model.d.ts +1 -1
  37. package/dist/compare/inline-provenance.d.ts +2 -2
  38. package/dist/compat/eigenpal.d.ts +3 -3
  39. package/dist/compat/eigenpal.js +2 -3
  40. package/dist/controller/canonicalClipboard.d.ts +13 -3
  41. package/dist/controller/canonicalClipboard.js +185 -49
  42. package/dist/controller/canonicalClipboardResources.d.ts +9 -1
  43. package/dist/controller/canonicalClipboardResources.js +22 -2
  44. package/dist/controller/canonicalReview.d.ts +1 -1
  45. package/dist/controller/canonicalReview.js +1 -1
  46. package/dist/controller/canonicalStructure.js +1 -1
  47. package/dist/controller/canonicalWatermark.d.ts +10 -0
  48. package/dist/controller/canonicalWatermark.js +37 -0
  49. package/dist/controller/hiddenEditorApi.d.ts +1 -1
  50. package/dist/controller/hiddenEditorManager.d.ts +4 -3
  51. package/dist/controller/hiddenEditorManager.js +75 -15
  52. package/dist/document-operations-apply.d.ts +15 -0
  53. package/dist/document-operations-apply.js +280 -0
  54. package/dist/document-operations.d.ts +1 -14
  55. package/dist/document-operations.js +2 -279
  56. package/dist/docx/modelValidation.js +1 -1
  57. package/dist/docx/paragraphParser.js +2 -2
  58. package/dist/docx/paragraphPropertySource.d.ts +1 -1
  59. package/dist/docx/reviewResolutionProvenance.d.ts +3 -2
  60. package/dist/docx/reviewResolutionProvenance.js +32 -9
  61. package/dist/docx/revisionIdNormalization.js +30 -7
  62. package/dist/docx/rezip.js +1 -1
  63. package/dist/docx/serializer/borderSerializer.js +1 -1
  64. package/dist/docx/serializer/commentSerializer.js +1 -1
  65. package/dist/docx/serializer/documentSerializer.js +1 -1
  66. package/dist/docx/serializer/paragraphSerializer.js +3 -3
  67. package/dist/docx/serializer/runSerializer.js +1 -1
  68. package/dist/docx/serializer/sectionPropertiesSerializer.js +1 -1
  69. package/dist/docx/serializer/tableSerializer.js +5 -37
  70. package/dist/docx/serializer/textFormattingSerializer.js +1 -1
  71. package/dist/docx/serializer/trackedChangeAttributes.js +1 -1
  72. package/dist/docx/server/templatePlan/apply.d.ts +15 -0
  73. package/dist/docx/server/templatePlan/apply.js +600 -0
  74. package/dist/docx/server/templatePlan/blocks.d.ts +97 -0
  75. package/dist/docx/server/templatePlan/blocks.js +355 -0
  76. package/dist/docx/server/templatePlan/builders.d.ts +72 -0
  77. package/dist/docx/server/templatePlan/builders.js +237 -0
  78. package/dist/docx/server/templatePlan/emit.d.ts +118 -0
  79. package/dist/docx/server/templatePlan/emit.js +466 -0
  80. package/dist/docx/server/templatePlan/emphasis.d.ts +62 -0
  81. package/dist/docx/server/templatePlan/emphasis.js +173 -0
  82. package/dist/docx/server/templatePlan/inspect.d.ts +22 -0
  83. package/dist/docx/server/templatePlan/inspect.js +177 -0
  84. package/dist/docx/server/templatePlan/labels.d.ts +36 -0
  85. package/dist/docx/server/templatePlan/labels.js +126 -0
  86. package/dist/docx/server/templatePlan/package.d.ts +34 -0
  87. package/dist/docx/server/templatePlan/package.js +99 -0
  88. package/dist/docx/server/templatePlan/plan.d.ts +143 -0
  89. package/dist/docx/server/templatePlan/plan.js +841 -0
  90. package/dist/docx/server/templatePlan/planShape.d.ts +9 -0
  91. package/dist/docx/server/templatePlan/planShape.js +161 -0
  92. package/dist/docx/server/templatePlan/resources.d.ts +41 -0
  93. package/dist/docx/server/templatePlan/resources.js +136 -0
  94. package/dist/docx/server/templatePlan/story.d.ts +128 -0
  95. package/dist/docx/server/templatePlan/story.js +440 -0
  96. package/dist/docx/server/templatePlan/types.d.ts +406 -0
  97. package/dist/docx/server/templatePlan/types.js +28 -0
  98. package/dist/docx/server/templatePlan/verify.d.ts +40 -0
  99. package/dist/docx/server/templatePlan/verify.js +968 -0
  100. package/dist/docx/server/templatePlan/xml.d.ts +69 -0
  101. package/dist/docx/server/templatePlan/xml.js +119 -0
  102. package/dist/docx/settingsHeaderFooterUpdate.d.ts +9 -0
  103. package/dist/docx/settingsHeaderFooterUpdate.js +45 -10
  104. package/dist/docx/storyBlockReplay.js +1 -1
  105. package/dist/docx/structuralXmlPatch.js +9 -1
  106. package/dist/docx/tableGridXml.d.ts +30 -0
  107. package/dist/docx/tableGridXml.js +54 -0
  108. package/dist/docx/tableParser.js +7 -0
  109. package/dist/docx/xmlParser.js +1 -1
  110. package/dist/index.d.ts +3 -3
  111. package/dist/index.js +2 -3
  112. package/dist/internal/paragraphFormattingSerialization.js +1 -1
  113. package/dist/internal/wholeStoryRevisionResolution.js +1 -1
  114. package/dist/managers/ContextMenuManager.js +2 -1
  115. package/dist/managers/editorShortcuts.d.ts +1 -1
  116. package/dist/prosemirror/anchoredTextBoxes.d.ts +1 -1
  117. package/dist/prosemirror/canonicalCommands.d.ts +1 -1
  118. package/dist/prosemirror/canonicalSelectionRange.d.ts +1 -1
  119. package/dist/prosemirror/canonicalTableCommands.js +2 -2
  120. package/dist/prosemirror/commands/comments.js +3 -3
  121. package/dist/prosemirror/commands/contentControls.d.ts +1 -1
  122. package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
  123. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  124. package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
  125. package/dist/prosemirror/commands/sectionBreak.js +1 -1
  126. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -1
  127. package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +1 -1
  128. package/dist/prosemirror/commentRecords.d.ts +1 -1
  129. package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
  130. package/dist/prosemirror/conversion/fromProseDoc.js +1 -1
  131. package/dist/prosemirror/documentStructureCounts.d.ts +24 -0
  132. package/dist/prosemirror/documentStructureCounts.js +76 -0
  133. package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
  134. package/dist/prosemirror/extensions/StarterKit.d.ts +1 -1
  135. package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +1 -7
  136. package/dist/prosemirror/extensions/core/HistoryExtension.js +5 -13
  137. package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -1
  138. package/dist/prosemirror/extensions/core/historyCommands.d.ts +16 -0
  139. package/dist/prosemirror/extensions/core/historyCommands.js +19 -0
  140. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
  141. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +2 -35
  142. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +4 -142
  143. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +3 -87
  144. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +7 -162
  145. package/dist/prosemirror/extensions/features/pastedCellSections.d.ts +1 -1
  146. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
  147. package/dist/prosemirror/extensions/marks/markUtils.d.ts +1 -1
  148. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
  149. package/dist/prosemirror/extensions/nodes/TableExtension.js +2 -2
  150. package/dist/prosemirror/extensions/types.d.ts +1 -1
  151. package/dist/prosemirror/findReplaceSelection.d.ts +1 -1
  152. package/dist/prosemirror/hyperlinkRemoval.d.ts +1 -1
  153. package/dist/prosemirror/index.d.ts +1 -1
  154. package/dist/prosemirror/index.js +1 -1
  155. package/dist/prosemirror/insertionGaps.d.ts +1 -1
  156. package/dist/prosemirror/keptRangeBoundaries.d.ts +1 -1
  157. package/dist/prosemirror/listNumbering.d.ts +1 -1
  158. package/dist/prosemirror/lockedControls.d.ts +1 -1
  159. package/dist/prosemirror/markupViewProjection.d.ts +1 -1
  160. package/dist/prosemirror/noteReferenceOccurrences.d.ts +1 -1
  161. package/dist/prosemirror/noteReferenceReview.js +1 -1
  162. package/dist/prosemirror/paraIds.d.ts +46 -0
  163. package/dist/prosemirror/paraIds.js +152 -0
  164. package/dist/prosemirror/paragraphChangeTrackerMeta.d.ts +97 -0
  165. package/dist/prosemirror/paragraphChangeTrackerMeta.js +87 -0
  166. package/dist/prosemirror/paragraphMarkJoin.d.ts +1 -1
  167. package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -1
  168. package/dist/prosemirror/pastedCommentCopies.d.ts +1 -1
  169. package/dist/prosemirror/pastedCommentCopies.js +1 -1
  170. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
  171. package/dist/prosemirror/plugins/documentNumbering.d.ts +1 -1
  172. package/dist/prosemirror/plugins/suggestionMode.d.ts +1 -1
  173. package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
  174. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
  175. package/dist/prosemirror/rebaseParagraphRuns.d.ts +1 -1
  176. package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
  177. package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
  178. package/dist/prosemirror/replacedAnnotations.js +16 -1
  179. package/dist/prosemirror/revisionCarriers.d.ts +1 -1
  180. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
  181. package/dist/prosemirror/sectionMarkEdits.d.ts +1 -1
  182. package/dist/prosemirror/selectionBounds.d.ts +10 -0
  183. package/dist/prosemirror/selectionBounds.js +22 -0
  184. package/dist/prosemirror/storyListNumbering.d.ts +1 -1
  185. package/dist/prosemirror/tableCellPaste.d.ts +1 -1
  186. package/dist/prosemirror/tableGridMutation.d.ts +1 -1
  187. package/dist/prosemirror/textInput.d.ts +1 -1
  188. package/dist/server.d.ts +7 -2
  189. package/dist/server.js +6 -1
  190. package/dist/types/canonicalCapabilities.d.ts +8 -41
  191. package/dist/types/canonicalCapabilities.js +6 -34
  192. package/package.json +4 -4
@@ -1,19 +1,12 @@
1
- import { applyFolioAIEditOperationsInPackage, previewFolioAIEditOperationsWithResult } from "./ai-edits/apply.js";
2
1
  import { compileMarkdownTableRows } from "./ai-edits/markdownInsertion.js";
3
- import { describeModelError, findIntroducedModelErrors } from "./ai-edits/result-validation.js";
4
2
  import { TABLE_INSERTION_MODES } from "./ai-edits/tableInsertionModes.js";
5
- import { trackedBatchFidelityError } from "./ai-edits/tracked-batch-fidelity.js";
6
3
  import { LIST_KINDS } from "./docx/listNumberingInstances.js";
7
- import { NO_NUMBERING_IDS_IN_USE } from "./docx/numberingIds.js";
8
4
  import "./docx/tableParser.js";
9
- import { getSuggestions } from "./prosemirror/commands/comments.js";
10
- import { completeNumberingForDoc } from "./prosemirror/listInstanceReferences.js";
11
5
  import { outlineLevelFromAttrValue } from "./prosemirror/outlineLevelAttr.js";
12
- import { getStatedDocumentNumbering } from "./prosemirror/plugins/documentNumbering.js";
13
6
  import { HIGHLIGHT_COLOR_VALUES, LINE_SPACING_RULE_VALUES, PARAGRAPH_ALIGNMENT_VALUES } from "./types/documentEnumValues.js";
14
7
  import { TaggedError } from "better-result";
15
- import { sanitizeXmlCharacters } from "@stll/docx-core";
16
8
  import { NUMBER_FORMATS, isNumberingReference, paragraphNumberingReference } from "@stll/docx-core/model";
9
+ import { sanitizeXmlCharacters } from "@stll/docx-core";
17
10
  // src/document-operations.ts
18
11
  const FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION = 1;
19
12
  /** Direct paragraph-alignment values accepted by the operation contract. */
@@ -1386,274 +1379,4 @@ const withDistinctSuggestionIds = (batch, pending) => {
1386
1379
  })
1387
1380
  };
1388
1381
  };
1389
- const NO_COMMIT = () => {};
1390
- /** Skips reported in the order of the operations they belong to. */
1391
- const inOperationOrder = (operations, skipped) => {
1392
- const indexById = new Map(operations.map(({ id }, index) => [id, index]));
1393
- return [...skipped].sort((left, right) => (indexById.get(left.id) ?? -1) - (indexById.get(right.id) ?? -1));
1394
- };
1395
- const applyFolioDocumentOperations = (input) => applyFolioDocumentOperationsInPackage({
1396
- ...input,
1397
- numberingIdsElsewhere: NO_NUMBERING_IDS_IN_USE
1398
- });
1399
- /** {@link applyFolioDocumentOperations} for a caller holding every story. Internal. */
1400
- const applyFolioDocumentOperationsInPackage = ({ view, snapshot, batch, story = "main", author, createCommentId, createUndoHandle, revisionStamp, wordDiff, tableTemplates, replacementBackground, undefinedReferences, pendingSuggestionIds, numberingIdsElsewhere, restagesSuggestions }) => {
1401
- const validatedBatch = parseFolioDocumentOperationBatch(batch);
1402
- const parsedBatch = restagesSuggestions === true ? validatedBatch : withDistinctSuggestionIds(validatedBatch, /* @__PURE__ */ new Set([...getSuggestions(view.state).map(({ suggestionId }) => suggestionId), ...pendingSuggestionIds ?? []]));
1403
- const isAtomic = parsedBatch.atomic === true;
1404
- const beforeDoc = view.state.doc;
1405
- const packageNumbering = getStatedDocumentNumbering(view.state);
1406
- const attempt = (operations, preview) => {
1407
- const common = {
1408
- snapshot,
1409
- operations,
1410
- mode: parsedBatch.mode ?? "tracked-changes",
1411
- ...parsedBatch.existingRevisions === "refuse-cross-author" && { refuseCrossAuthorRevisions: true },
1412
- ...author !== void 0 && { author },
1413
- ...revisionStamp !== void 0 && { revisionStamp },
1414
- ...wordDiff !== void 0 && { wordDiff },
1415
- ...tableTemplates !== void 0 && { tableTemplates },
1416
- ...replacementBackground !== void 0 && { replacementBackground },
1417
- numberingIdsElsewhere,
1418
- undefinedReferences
1419
- };
1420
- if (preview) return {
1421
- ...previewFolioAIEditOperationsWithResult({
1422
- ...common,
1423
- view,
1424
- ...createCommentId !== void 0 && { createCommentId }
1425
- }, parsedBatch.dryRun && common.mode === "tracked-changes" ? "bounded" : "coarse"),
1426
- commit: NO_COMMIT
1427
- };
1428
- const held = {};
1429
- const commentIds = [];
1430
- return {
1431
- outcome: applyFolioAIEditOperationsInPackage({
1432
- ...common,
1433
- view: {
1434
- state: view.state,
1435
- dispatch: (transaction) => {
1436
- held.transaction = transaction;
1437
- }
1438
- },
1439
- ...createCommentId !== void 0 && { createCommentId: (text) => {
1440
- const id = createCommentId(text);
1441
- commentIds.push(id);
1442
- return id;
1443
- } }
1444
- }),
1445
- doc: held.transaction?.doc ?? null,
1446
- commentIds,
1447
- commit: () => {
1448
- if (held.transaction !== void 0) view.dispatch(held.transaction);
1449
- }
1450
- };
1451
- };
1452
- const introducedErrors = (run) => {
1453
- if (run.doc === null || run.outcome.applied.length === 0) return [];
1454
- const numbering = packageNumbering === void 0 ? void 0 : completeNumberingForDoc(packageNumbering ?? void 0, run.doc) ?? null;
1455
- return findIntroducedModelErrors(beforeDoc, run.doc, {
1456
- numbering,
1457
- createdCommentIds: run.commentIds,
1458
- ...author !== void 0 && { commentAuthor: author }
1459
- });
1460
- };
1461
- /**
1462
- * An attempt on the refusal path, where the applier runs on subsets of the
1463
- * batch it was not asked to apply: a throw there is one more reason to
1464
- * refuse, never a reason to fail a batch the first run could apply.
1465
- */
1466
- const checkedAttempt = (operations, preview) => {
1467
- try {
1468
- const run = attempt(operations, preview);
1469
- return {
1470
- run,
1471
- error: introducedErrors(run)[0]
1472
- };
1473
- } catch (error) {
1474
- return {
1475
- run: null,
1476
- error: {
1477
- path: "package.document",
1478
- message: `the operation could not be applied (${error instanceof Error ? error.message : String(error)}).`,
1479
- severity: "error"
1480
- }
1481
- };
1482
- }
1483
- };
1484
- /**
1485
- * Which applied operations produced the unsaveable result: each one is
1486
- * previewed alone against the unchanged story. When none fails alone, the
1487
- * failure is their combination, and every one of them is refused.
1488
- */
1489
- const refuseInvalidResult = (run, firstError) => {
1490
- const operationsById = new Map(parsedBatch.operations.map((operation) => [operation.id, operation]));
1491
- const refused = [];
1492
- for (const { id } of run.outcome.applied) {
1493
- const operation = operationsById.get(id);
1494
- if (operation === void 0) continue;
1495
- const alone = checkedAttempt([operation], true).error;
1496
- if (alone !== void 0) refused.push({
1497
- id,
1498
- reason: "invalidResult",
1499
- message: describeModelError(alone)
1500
- });
1501
- }
1502
- if (refused.length > 0) return refused;
1503
- return run.outcome.applied.map(({ id }) => ({
1504
- id,
1505
- reason: "invalidResult",
1506
- message: describeModelError(firstError)
1507
- }));
1508
- };
1509
- /**
1510
- * A fidelity failure invalidates the batch. Preserve the refusal details
1511
- * for operations already skipped by the applier or save-time validator.
1512
- */
1513
- const refuseFidelityLoss = (run, skipped = []) => {
1514
- if (run.doc === null || parsedBatch.mode === "direct" || parsedBatch.mode === "suggested") return null;
1515
- const message = trackedBatchFidelityError({
1516
- before: view.state,
1517
- after: run.doc,
1518
- createdCommentIds: run.commentIds,
1519
- retiredCommentIds: run.outcome.applied.flatMap(({ retiredCommentIds }) => retiredCommentIds ?? [])
1520
- });
1521
- if (message === null) return null;
1522
- return {
1523
- fidelityRefused: true,
1524
- outcome: {
1525
- ...run.outcome,
1526
- applied: [],
1527
- skipped: inOperationOrder(parsedBatch.operations, [
1528
- ...run.outcome.skipped,
1529
- ...skipped,
1530
- ...run.outcome.applied.map(({ id }) => ({
1531
- id,
1532
- reason: "invalidResult",
1533
- message
1534
- }))
1535
- ])
1536
- },
1537
- commit: NO_COMMIT
1538
- };
1539
- };
1540
- /** Check the held result before dispatching any operation to the caller. */
1541
- const guardedAttempt = (preview) => {
1542
- const first = attempt(parsedBatch.operations, preview);
1543
- const [firstError] = introducedErrors(first);
1544
- if (firstError === void 0) {
1545
- const fidelity = preview && !parsedBatch.dryRun ? null : refuseFidelityLoss(first);
1546
- if (fidelity !== null) return fidelity;
1547
- return {
1548
- outcome: {
1549
- ...first.outcome,
1550
- skipped: inOperationOrder(parsedBatch.operations, first.outcome.skipped)
1551
- },
1552
- commit: first.commit
1553
- };
1554
- }
1555
- const refused = refuseInvalidResult(first, firstError);
1556
- const refusedIds = new Set(refused.map(({ id }) => id));
1557
- if (isAtomic) return {
1558
- outcome: {
1559
- ...first.outcome,
1560
- applied: [],
1561
- skipped: inOperationOrder(parsedBatch.operations, [...first.outcome.skipped, ...refused])
1562
- },
1563
- commit: NO_COMMIT
1564
- };
1565
- const second = checkedAttempt(parsedBatch.operations.filter(({ id }) => !refusedIds.has(id)), preview);
1566
- if (second.run === null || second.error !== void 0) {
1567
- const reported = second.run?.outcome ?? first.outcome;
1568
- return {
1569
- outcome: {
1570
- ...reported,
1571
- applied: [],
1572
- skipped: inOperationOrder(parsedBatch.operations, [
1573
- ...reported.skipped.filter(({ id }) => !refusedIds.has(id)),
1574
- ...refused,
1575
- ...reported.applied.filter(({ id }) => !refusedIds.has(id)).map(({ id }) => ({
1576
- id,
1577
- reason: "invalidResult",
1578
- message: describeModelError(second.error ?? firstError)
1579
- }))
1580
- ])
1581
- },
1582
- commit: NO_COMMIT
1583
- };
1584
- }
1585
- const fidelity = refuseFidelityLoss(second.run, refused);
1586
- if (fidelity !== null) return fidelity;
1587
- return {
1588
- outcome: {
1589
- ...second.run.outcome,
1590
- skipped: inOperationOrder(parsedBatch.operations, [...second.run.outcome.skipped, ...refused])
1591
- },
1592
- commit: second.run.commit
1593
- };
1594
- };
1595
- const preview = () => guardedAttempt(true).outcome;
1596
- const atomicResult = (previewResult, status) => {
1597
- const skippedById = new Map(previewResult.skipped.map((operation) => [operation.id, operation]));
1598
- const skipped = parsedBatch.operations.map(({ id }) => skippedById.get(id) ?? {
1599
- id,
1600
- reason: "atomicBatchRejected"
1601
- });
1602
- return {
1603
- version: 1,
1604
- status,
1605
- applied: [],
1606
- skipped,
1607
- issues: getFolioDocumentOperationIssues(parsedBatch.operations, skipped),
1608
- receipts: [],
1609
- ...previewResult.normalizations !== void 0 && { normalizations: previewResult.normalizations },
1610
- undoHandle: null,
1611
- nextRevisionId: previewResult.nextRevisionId
1612
- };
1613
- };
1614
- if (parsedBatch.dryRun === true) {
1615
- const previewResult = preview();
1616
- if (isAtomic && previewResult.skipped.length > 0) return atomicResult(previewResult, "previewed");
1617
- return {
1618
- version: 1,
1619
- status: "previewed",
1620
- applied: previewResult.applied.map(({ id, paragraphIdentity, retiredCommentIds }) => ({
1621
- id,
1622
- ...paragraphIdentity === void 0 ? {} : { paragraphIdentity },
1623
- ...retiredCommentIds === void 0 ? {} : { retiredCommentIds }
1624
- })),
1625
- skipped: previewResult.skipped,
1626
- issues: getFolioDocumentOperationIssues(parsedBatch.operations, previewResult.skipped),
1627
- receipts: getFolioDocumentOperationReceiptsForStory({
1628
- operations: parsedBatch.operations,
1629
- applied: previewResult.applied,
1630
- story
1631
- }),
1632
- ...previewResult.normalizations !== void 0 && { normalizations: previewResult.normalizations },
1633
- undoHandle: null,
1634
- nextRevisionId: previewResult.nextRevisionId
1635
- };
1636
- }
1637
- if (isAtomic) {
1638
- const previewResult = preview();
1639
- if (previewResult.skipped.length > 0) return atomicResult(previewResult, "rejected");
1640
- }
1641
- const guarded = guardedAttempt(false);
1642
- const { heldRevisionConflict, ...result } = guarded.outcome;
1643
- if (heldRevisionConflict) return atomicResult(result, "rejected");
1644
- if (guarded.fidelityRefused === true || isAtomic && result.skipped.some(({ reason }) => reason === "invalidResult")) return atomicResult(result, "rejected");
1645
- guarded.commit();
1646
- return {
1647
- version: 1,
1648
- status: "committed",
1649
- ...result,
1650
- issues: getFolioDocumentOperationIssues(parsedBatch.operations, result.skipped),
1651
- receipts: getFolioDocumentOperationReceiptsForStory({
1652
- operations: parsedBatch.operations,
1653
- applied: result.applied,
1654
- story
1655
- }),
1656
- undoHandle: result.applied.length > 0 && createUndoHandle !== void 0 ? createUndoHandle() : null
1657
- };
1658
- };
1659
- export { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_EXISTING_REVISION_POLICIES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_LIST_NUMBER_FORMAT_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, applyFolioDocumentOperationsInPackage, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationReceiptsForStory, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, withDistinctSuggestionIds };
1382
+ export { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_EXISTING_REVISION_POLICIES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_LIST_NUMBER_FORMAT_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationReceiptsForStory, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, withDistinctSuggestionIds };
@@ -1,5 +1,5 @@
1
- import { validateDocumentModel } from "@stll/docx-core";
2
1
  import { isCanonicallyEmptyParagraphFormatting } from "@stll/docx-core/model";
2
+ import { validateDocumentModel } from "@stll/docx-core";
3
3
  // src/docx/modelValidation.ts
4
4
  var DocxModelValidationError = class extends Error {
5
5
  issues;
@@ -21,7 +21,7 @@ import { assignParagraphPropertySource } from "./paragraphPropertySource.js";
21
21
  import { preserveInlineChild, preserveRunChild, preservedInlineCapture, withLooseFieldMarkupPreserved } from "./preservedRunContent.js";
22
22
  import { standalonePreviewLedger } from "./previewBudget.js";
23
23
  import { FOLIO_REVIEW_HISTORY_NAMESPACE } from "./reviewHistoryNamespace.js";
24
- import { parseParagraphMarkResolutionJoin, parseParagraphPropertyChangeOwner, parseResolutionJoins, parseSplitResolutionPiece, versionOneKeptMarkers } from "./reviewResolutionProvenance.js";
24
+ import { legacyKeptCutPiece, parseParagraphMarkResolutionJoin, parseParagraphPropertyChangeOwner, parseResolutionJoins, parseSplitResolutionPiece, versionOneKeptMarkers } from "./reviewResolutionProvenance.js";
25
25
  import { consolidateParagraphContent } from "./runConsolidator.js";
26
26
  import { parseRun } from "./runParser.js";
27
27
  import { runHoldsPayload } from "./runPayload.js";
@@ -1394,7 +1394,7 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
1394
1394
  restoreEmptyMarkProperties(paragraph, node);
1395
1395
  const rawContent = parseParagraphContents(node, styles, theme, numbering, rels, media, options?.previews ?? standalonePreviewLedger(), "default", options?.rootXmlns ?? {});
1396
1396
  const consolidated = (content) => {
1397
- const cut = paragraphKeptCutsFromChanges(content, versionOneKeptMarkers);
1397
+ const cut = paragraphKeptCutsFromChanges(content, versionOneKeptMarkers, legacyKeptCutPiece);
1398
1398
  return options?.runConsolidation === "deferred" ? cut : consolidateParagraphContent(cut);
1399
1399
  };
1400
1400
  paragraph.content = consolidated(rawContent);
@@ -3,8 +3,8 @@ import { Comment } from "../types/content.js";
3
3
  import { document_d_exports } from "../types/document.js";
4
4
  import { ReadonlyDocument } from "../types/documentModel.js";
5
5
  import { TaggedErrorClass } from "better-result";
6
- import { Fragment, Mark, Node, NodeType } from "prosemirror-model";
7
6
  import { Transaction } from "prosemirror-state";
7
+ import { Fragment, Mark, Node, NodeType } from "prosemirror-model";
8
8
  /** Fix the facts of `paragraph`: a reader keeps them. */
9
9
  export declare const sealParagraphFacts: (paragraph: document_d_exports.Paragraph) => void;
10
10
  declare const paragraphPropertySourceEmissionFingerprint: unique symbol;
@@ -1,7 +1,7 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
  import { XmlElement } from "./xmlParser.js";
3
3
  import { TaggedErrorClass } from "better-result";
4
- import { CopyOriginAncestorList, VersionOneKept } from "@stll/docx-core/ops";
4
+ import { CopyOriginAncestorList, KeptCutPiece, VersionOneKept } from "@stll/docx-core/ops";
5
5
  /**
6
6
  * The review history version folio writes. Version 2 adds the revision a
7
7
  * paragraph property change belongs to (`folio:resolvesWith`) and records a
@@ -30,6 +30,7 @@ export declare const parseResolutionJoins: (node: XmlElement) => ResolutionJoins
30
30
  export declare const versionOneKeptMarkers: (joins: ResolutionJoins) => VersionOneKept | undefined;
31
31
  export declare const parseBoundaryJoins: (node: XmlElement) => BoundaryJoins | undefined;
32
32
  export declare const parseCopyOriginAncestors: (node: XmlElement) => CopyOriginAncestorList | undefined;
33
+ export declare const legacyKeptCutPiece: (cut: document_d_exports.KeptCut) => KeptCutPiece | undefined;
33
34
  /** The cut a kept range marker stands in (`folio:keptCut`). */
34
35
  export declare const parseKeptCut: (node: XmlElement) => document_d_exports.KeptCut | undefined;
35
36
  export declare const serializeKeptCut: (value: document_d_exports.KeptCut | undefined) => string | undefined;
@@ -42,7 +43,7 @@ export declare const serializeCopyOriginAncestors: (value: CopyOriginAncestorLis
42
43
  * and when the split whose cut a deleted mark holds was made. A missing
43
44
  * attribute carries no field.
44
45
  */
45
- export declare const parseParagraphMarkResolutionJoin: (node: XmlElement) => Pick<document_d_exports.ParagraphMarkChange, "resolutionJoin" | "survivor" | "splitDate">;
46
+ export declare const parseParagraphMarkResolutionJoin: (node: XmlElement) => Pick<document_d_exports.ParagraphMarkChange, "resolutionJoin" | "survivor" | "takenOverMark" | "splitDate">;
46
47
  export declare const serializeParagraphMarkResolutionJoin: (mark: document_d_exports.ParagraphMarkChange) => string;
47
48
  /** Captured paragraph properties compose the same envelopes into a parsed XML element. */
48
49
  export declare const paragraphMarkResolutionJoinAttributes: (mark: document_d_exports.ParagraphMarkChange) => Record<string, string>;
@@ -2,9 +2,9 @@ import "../reviewHistoryLimits.js";
2
2
  import { FOLIO_REVIEW_HISTORY_NAMESPACE } from "./reviewHistoryNamespace.js";
3
3
  import { getAttributeByNamespaceUri } from "./xmlParser.js";
4
4
  import { Result, TaggedError, panic } from "better-result";
5
- import { escapeXmlAttribute } from "@stll/docx-core";
6
5
  import { MAX_REVISION_ID } from "@stll/docx-core/model";
7
- import { isCopyOriginAncestors, isKeptCut } from "@stll/docx-core/ops";
6
+ import { isCopyOriginAncestors, isKeptCut, isKeptCutPiece } from "@stll/docx-core/ops";
7
+ import { escapeXmlAttribute } from "@stll/docx-core";
8
8
  // src/docx/reviewResolutionProvenance.ts
9
9
  const NAMESPACES = /* @__PURE__ */ new Set([FOLIO_REVIEW_HISTORY_NAMESPACE]);
10
10
  /**
@@ -67,6 +67,10 @@ const PARAGRAPH_MARK_FIELDS = {
67
67
  type: "private",
68
68
  attribute: "rejectionSurvivor"
69
69
  },
70
+ takenOverMark: {
71
+ type: "private",
72
+ attribute: "rejectionSurvivor"
73
+ },
70
74
  splitDate: {
71
75
  type: "private",
72
76
  attribute: "splitDate"
@@ -322,12 +326,29 @@ const storedKeptCut = (value) => {
322
326
  const { depth: _ignored, ...cut } = value;
323
327
  return cut;
324
328
  };
325
- const isStoredKeptCut = (value) => isKeptCut(storedKeptCut(value));
329
+ const LEGACY_KEPT_CUT_PIECES = /* @__PURE__ */ new WeakMap();
330
+ const legacyKeptCutPiece = (cut) => LEGACY_KEPT_CUT_PIECES.get(cut);
331
+ const legacyStoredKeptCut = (value) => {
332
+ if (!record(value)) return void 0;
333
+ const { piece, ...cut } = value;
334
+ return isKeptCutPiece(piece) && isKeptCut(cut) && cut.holders === void 0 ? {
335
+ cut,
336
+ piece
337
+ } : void 0;
338
+ };
339
+ const isStoredKeptCut = (value) => {
340
+ const cut = storedKeptCut(value);
341
+ return isKeptCut(cut) || legacyStoredKeptCut(cut) !== void 0;
342
+ };
326
343
  /** The cut a kept range marker stands in (`folio:keptCut`). */
327
344
  const parseKeptCut = (node) => {
328
345
  const decoded = decodeAttribute(node, "keptCut", isStoredKeptCut);
329
346
  const cut = storedKeptCut(decoded?.value);
330
- return isKeptCut(cut) ? cut : void 0;
347
+ if (isKeptCut(cut)) return cut;
348
+ const legacy = legacyStoredKeptCut(cut);
349
+ if (legacy === void 0) return void 0;
350
+ LEGACY_KEPT_CUT_PIECES.set(legacy.cut, legacy.piece);
351
+ return legacy.cut;
331
352
  };
332
353
  const serializeKeptCut = (value) => encodeAttribute({
333
354
  attribute: "keptCut",
@@ -349,7 +370,8 @@ const serializeCopyOriginAncestors = (value) => encodeAttribute({
349
370
  value,
350
371
  valid: isCopyOriginAncestors
351
372
  });
352
- const isParagraphMarkSurvivor = (value) => value === "first";
373
+ const isStoredRejectionSurvivor = (value) => record(value) && Object.keys(value).length === 1 && (value["takenOverMark"] === null || isRevisionId(value["takenOverMark"]));
374
+ const isParagraphMarkSurvivor = (value) => value === "first" || isStoredRejectionSurvivor(value);
353
375
  const isParagraphMarkSplitDate = (value) => typeof value === "string";
354
376
  /**
355
377
  * A paragraph mark's private review provenance: its rejection join depth
@@ -375,14 +397,15 @@ const parseParagraphMarkResolutionJoin = (node) => {
375
397
  });
376
398
  return {
377
399
  ...value === void 0 ? {} : { resolutionJoin: value === null ? void 0 : value },
378
- ...survivor === void 0 ? {} : { survivor },
400
+ ...survivor === void 0 ? {} : { survivor: "first" },
401
+ ...survivor === void 0 || survivor === "first" || survivor.takenOverMark === null ? {} : { takenOverMark: survivor.takenOverMark },
379
402
  ...splitDate === void 0 ? {} : { splitDate }
380
403
  };
381
404
  };
382
405
  const paragraphMarkSurvivorOptions = (mark) => ({
383
406
  attribute: PARAGRAPH_MARK_FIELDS.survivor.attribute,
384
- value: mark.survivor,
385
- valid: isParagraphMarkSurvivor
407
+ value: mark.survivor === void 0 ? void 0 : { takenOverMark: mark.takenOverMark ?? null },
408
+ valid: isStoredRejectionSurvivor
386
409
  });
387
410
  const paragraphMarkSplitDateOptions = (mark) => ({
388
411
  attribute: PARAGRAPH_MARK_FIELDS.splitDate.attribute,
@@ -490,4 +513,4 @@ const reviewProvenanceIssue = (attribute, encoded) => {
490
513
  const decoded = decodeProvenance(encoded, shape);
491
514
  return decoded.status === "dropped" ? decoded.reason : void 0;
492
515
  };
493
- export { REVIEW_HISTORY_VERSION, ReviewResolutionProvenanceError, isBoundaryJoins, isParagraphMarkResolutionJoin, isResolutionJoins, isSplitResolutionPiece, paragraphMarkResolutionJoinAttributes, parseBoundaryJoins, parseCopyOriginAncestors, parseKeptCut, parseParagraphMarkResolutionJoin, parseParagraphPropertyChangeOwner, parseResolutionJoins, parseSplitResolutionPiece, reviewProvenanceIssue, serializeBoundaryJoins, serializeCopyOriginAncestors, serializeKeptCut, serializeParagraphMarkResolutionJoin, serializeParagraphPropertyChangeOwner, serializeResolutionJoins, serializeSplitResolutionPiece, versionOneKeptMarkers };
516
+ export { REVIEW_HISTORY_VERSION, ReviewResolutionProvenanceError, isBoundaryJoins, isParagraphMarkResolutionJoin, isResolutionJoins, isSplitResolutionPiece, legacyKeptCutPiece, paragraphMarkResolutionJoinAttributes, parseBoundaryJoins, parseCopyOriginAncestors, parseKeptCut, parseParagraphMarkResolutionJoin, parseParagraphPropertyChangeOwner, parseResolutionJoins, parseSplitResolutionPiece, reviewProvenanceIssue, serializeBoundaryJoins, serializeCopyOriginAncestors, serializeKeptCut, serializeParagraphMarkResolutionJoin, serializeParagraphPropertyChangeOwner, serializeResolutionJoins, serializeSplitResolutionPiece, versionOneKeptMarkers };
@@ -1,6 +1,7 @@
1
+ import { parseParagraphMarkResolutionJoin } from "./reviewResolutionProvenance.js";
1
2
  import { WORDPROCESSINGML_NAMESPACE_URIS, findAttributeByNamespaceUri, getLocalName, getNamespaceUri } from "./xmlParser.js";
2
3
  import { TaggedError } from "better-result";
3
- import { rewriteStreamingXmlDecimalAttributes } from "@stll/docx-core/xml";
4
+ import { rewriteStreamingXmlDecimalAttributes, scanStreamingXmlElements } from "@stll/docx-core/xml";
4
5
  import { XmlResourceLimitError, assertXmlResourceLimits } from "@stll/docx-core/xml/limits";
5
6
  // src/docx/revisionIdNormalization.ts
6
7
  const RevisionIdCollisionErrorBase = TaggedError("RevisionIdCollisionError");
@@ -116,6 +117,8 @@ const revisionAttribute = (element) => {
116
117
  const normalizeRevisionIdsInXmlParts = (parts) => {
117
118
  const candidates = [...parts].filter(([, xml]) => REVISION_ELEMENT_CANDIDATE.test(xml));
118
119
  const occurrencesByPath = /* @__PURE__ */ new Map();
120
+ const paragraphMarks = /* @__PURE__ */ new Map();
121
+ const takenOverMarks = /* @__PURE__ */ new Set();
119
122
  const reserved = /* @__PURE__ */ new Set();
120
123
  for (const [path, xml] of candidates) {
121
124
  assertXmlResourceLimits({
@@ -123,10 +126,22 @@ const normalizeRevisionIdsInXmlParts = (parts) => {
123
126
  partPath: path
124
127
  });
125
128
  const ids = [];
126
- if (rewriteStreamingXmlDecimalAttributes(xml, (element) => {
129
+ const paragraphMarkProperties = /* @__PURE__ */ new WeakSet();
130
+ if (scanStreamingXmlElements(xml, ({ element, parent }) => {
131
+ if (parent?.name !== void 0 && element.name !== void 0 && getLocalName(parent.name) === "pPr" && getLocalName(element.name) === "rPr" && WORDPROCESSINGML_NAMESPACE_URIS.has(getNamespaceUri(parent) ?? "") && WORDPROCESSINGML_NAMESPACE_URIS.has(getNamespaceUri(element) ?? "")) paragraphMarkProperties.add(element);
127
132
  const identified = identifiedElement(element);
128
133
  if (identified === null) return null;
129
- if (identified.kind === ID_KINDS.revision) ids.push(identified.id);
134
+ if (identified.kind === ID_KINDS.revision) {
135
+ if (parent !== void 0 && paragraphMarkProperties.has(parent)) {
136
+ if (!paragraphMarks.has(identified.id)) paragraphMarks.set(identified.id, {
137
+ path,
138
+ ordinal: ids.length
139
+ });
140
+ const { takenOverMark } = parseParagraphMarkResolutionJoin(element);
141
+ if (takenOverMark !== void 0) takenOverMarks.add(takenOverMark);
142
+ }
143
+ ids.push(identified.id);
144
+ }
130
145
  reserved.add(identified.id);
131
146
  return null;
132
147
  }).status === "unsupported") throw new XmlResourceLimitError({
@@ -139,8 +154,12 @@ const normalizeRevisionIdsInXmlParts = (parts) => {
139
154
  }
140
155
  const repeatedPaths = /* @__PURE__ */ new Set();
141
156
  const firstSeen = /* @__PURE__ */ new Set();
142
- for (const [path, ids] of occurrencesByPath) for (const id of ids) if (firstSeen.has(id)) repeatedPaths.add(path);
143
- else firstSeen.add(id);
157
+ const repeated = /* @__PURE__ */ new Set();
158
+ for (const [path, ids] of occurrencesByPath) for (const id of ids) if (firstSeen.has(id)) {
159
+ repeatedPaths.add(path);
160
+ repeated.add(id);
161
+ } else firstSeen.add(id);
162
+ const hasPreferredDuplicate = (ids) => ids.some((id) => repeated.has(id) && takenOverMarks.has(id) && paragraphMarks.has(id));
144
163
  if (repeatedPaths.size > 0) for (const [path, xml] of parts) {
145
164
  if (occurrencesByPath.has(path) || !ANNOTATION_ELEMENT_CANDIDATE.test(xml)) continue;
146
165
  assertXmlResourceLimits({
@@ -179,14 +198,18 @@ const normalizeRevisionIdsInXmlParts = (parts) => {
179
198
  });
180
199
  seen.add(id);
181
200
  };
182
- if (!repeatedPaths.has(path) && ids.every((id) => !seen.has(id))) {
201
+ if (!repeatedPaths.has(path) && !hasPreferredDuplicate(ids) && ids.every((id) => !seen.has(id))) {
183
202
  for (const id of ids) claim(id);
184
203
  continue;
185
204
  }
205
+ let ordinal = 0;
186
206
  const rewritten = rewriteStreamingXmlDecimalAttributes(xml, (element) => {
187
207
  const attribute = revisionAttribute(element);
188
208
  if (!attribute) return null;
189
- if (!seen.has(attribute.id)) {
209
+ const preferred = takenOverMarks.has(attribute.id) ? paragraphMarks.get(attribute.id) : void 0;
210
+ const at = ordinal;
211
+ ordinal += 1;
212
+ if (!seen.has(attribute.id) && (preferred === void 0 || preferred.path === path && preferred.ordinal === at)) {
190
213
  claim(attribute.id);
191
214
  return null;
192
215
  }
@@ -44,8 +44,8 @@ import { captureVerbatimXml } from "./verbatimCapture.js";
44
44
  import { hasCanonicalWordprocessingPrefixes } from "./wordprocessingPrefixes.js";
45
45
  import { OFFICE_RELATIONSHIP_NAMESPACE_URIS, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, findAttributeByNamespaceUri, findChild, findChildByNamespaceUri, findChildrenByNamespaceUri, getAttribute, getAttributeByNamespaceUri, getChildElements, getLocalName, getNamespaceUri, matchesName, parseXml, parseXmlDocument, resolveAttributeNamespaceUri } from "./xmlParser.js";
46
46
  import { Result, TaggedError, panic } from "better-result";
47
- import { assertValidOoxmlNumericIds, escapeXmlAttribute, escapeXmlText, validateDocxPackage } from "@stll/docx-core";
48
47
  import { mintRelationshipId, numberingInstanceResolves } from "@stll/docx-core/model";
48
+ import { assertValidOoxmlNumericIds, escapeXmlAttribute, escapeXmlText, validateDocxPackage } from "@stll/docx-core";
49
49
  import { getXmlSourceRange, parseStreamingXmlWithSourceRanges } from "@stll/docx-core/xml";
50
50
  import { ZipArchive } from "@stll/docx-core/zip";
51
51
  // src/docx/rezip.ts
@@ -1,7 +1,7 @@
1
1
  import { serializePreservedAttributes } from "../attributeRemainder.js";
2
2
  import { intAttr } from "./xmlUtils.js";
3
- import { escapeXmlAttribute } from "@stll/docx-core";
4
3
  import { borderStyleToken, themeColorToken } from "@stll/docx-core/model";
4
+ import { escapeXmlAttribute } from "@stll/docx-core";
5
5
  // src/docx/serializer/borderSerializer.ts
6
6
  /**
7
7
  * Shared single-border serializer for every `CT_Border` field — table borders
@@ -7,8 +7,8 @@ import { serializeParagraph } from "./paragraphSerializer.js";
7
7
  import { serializePartElement } from "./partNamespaces.js";
8
8
  import { serializeTextFormatting } from "./textFormattingSerializer.js";
9
9
  import { Result } from "better-result";
10
- import { assertValidOoxmlNumericIds, escapeXmlAttribute } from "@stll/docx-core";
11
10
  import { COMMENT_PART_RELATIONSHIPS } from "@stll/docx-core/model";
11
+ import { assertValidOoxmlNumericIds, escapeXmlAttribute } from "@stll/docx-core";
12
12
  // src/docx/serializer/commentSerializer.ts
13
13
  /**
14
14
  * Comment Serializer
@@ -10,8 +10,8 @@ import { serializePartElement } from "./partNamespaces.js";
10
10
  import { resetAutoIdCounter } from "./runSerializer.js";
11
11
  import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
12
12
  import { serializeTable } from "./tableSerializer.js";
13
- import { escapeXmlAttribute } from "@stll/docx-core";
14
13
  import { themeColorToken } from "@stll/docx-core/model";
14
+ import { escapeXmlAttribute } from "@stll/docx-core";
15
15
  // src/docx/serializer/documentSerializer.ts
16
16
  /**
17
17
  * Document Serializer - Serialize complete document.xml
@@ -17,8 +17,8 @@ import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
17
17
  import { serializeTextFormatting } from "./textFormattingSerializer.js";
18
18
  import { serializeTrackedChangeAttributes, trackedChangeAttributeRecord } from "./trackedChangeAttributes.js";
19
19
  import { TaggedError, panic } from "better-result";
20
+ import { PARAGRAPH_MARK_CHANGE_KINDS, finalizeParagraphFormatting } from "@stll/docx-core/model";
20
21
  import { escapeXmlAttribute, escapeXmlText } from "@stll/docx-core";
21
- import { PARAGRAPH_MARK_CHANGE_KINDS, finalizeParagraphFormatting as finalizeParagraphFormatting$1 } from "@stll/docx-core/model";
22
22
  import { SEQUENCE_CHILDREN } from "@stll/docx-core/schema";
23
23
  // src/docx/serializer/paragraphSerializer.ts
24
24
  /**
@@ -883,7 +883,7 @@ function hasParagraphFormatting(paragraph) {
883
883
  * Create an empty paragraph
884
884
  */
885
885
  function createEmptyParagraph(formatting) {
886
- const finalizedFormatting = finalizeParagraphFormatting$1(formatting);
886
+ const finalizedFormatting = finalizeParagraphFormatting(formatting);
887
887
  return {
888
888
  type: "paragraph",
889
889
  ...finalizedFormatting !== void 0 ? { formatting: finalizedFormatting } : {},
@@ -894,7 +894,7 @@ function createEmptyParagraph(formatting) {
894
894
  * Create a paragraph with a single text run
895
895
  */
896
896
  function createTextParagraph(text, paragraphFormatting, textFormatting) {
897
- const finalizedFormatting = finalizeParagraphFormatting$1(paragraphFormatting);
897
+ const finalizedFormatting = finalizeParagraphFormatting(paragraphFormatting);
898
898
  return {
899
899
  type: "paragraph",
900
900
  ...finalizedFormatting !== void 0 ? { formatting: finalizedFormatting } : {},
@@ -18,8 +18,8 @@ import { serializeTextFormatting } from "./textFormattingSerializer.js";
18
18
  import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
19
19
  import { intAttr } from "./xmlUtils.js";
20
20
  import { panic } from "better-result";
21
- import { escapeXmlAttribute, escapeXmlText, isValidOoxmlNumericId, requiresXmlSpacePreserve } from "@stll/docx-core";
22
21
  import { SCHEME_COLOR_VALUE_BY_THEME_COLOR, getSingularRunPropertyChange, knownThemeColor, presetLineDashToken } from "@stll/docx-core/model";
22
+ import { escapeXmlAttribute, escapeXmlText, isValidOoxmlNumericId, requiresXmlSpacePreserve } from "@stll/docx-core";
23
23
  // src/docx/serializer/runSerializer.ts
24
24
  /**
25
25
  * Run Serializer - Serialize runs to OOXML XML
@@ -3,8 +3,8 @@ import { serializeSectionReferenceHistory } from "../sectionReferenceHistory.js"
3
3
  import { serializeBorder } from "./borderSerializer.js";
4
4
  import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
5
5
  import { intAttr } from "./xmlUtils.js";
6
- import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
7
6
  import { themeColorToken } from "@stll/docx-core/model";
7
+ import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
8
8
  import { serializeSequenceChildren } from "@stll/docx-core/schema";
9
9
  // src/docx/serializer/sectionPropertiesSerializer.ts
10
10
  const serializeHeaderReference = (ref) => `<w:headerReference w:type="${ref.type}" r:id="${escapeXmlAttribute(ref.rId)}"/>`;