@stll/folio-core 0.66.2 → 0.67.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 (119) hide show
  1. package/dist/ai-edits/apply.js +45 -10
  2. package/dist/ai-edits/batch-claims.js +5 -3
  3. package/dist/ai-edits/clean-text.js +4 -1
  4. package/dist/ai-edits/read.js +6 -4
  5. package/dist/ai-edits/snapshot.js +24 -14
  6. package/dist/ai-edits/table-cell-mutations.js +3 -2
  7. package/dist/ai-edits/table-row-column-mutations.js +20 -6
  8. package/dist/controller/canonicalComposition.d.ts +1 -1
  9. package/dist/controller/canonicalComposition.js +76 -18
  10. package/dist/controller/canonicalInput.d.ts +0 -1
  11. package/dist/controller/canonicalInput.js +19 -1
  12. package/dist/controller/canonicalSession.js +1 -2
  13. package/dist/controller/hiddenEditorManager.d.ts +6 -0
  14. package/dist/controller/hiddenEditorManager.js +3 -1
  15. package/dist/controller/layoutPipeline.d.ts +2 -0
  16. package/dist/controller/layoutPipeline.js +7 -3
  17. package/dist/controller/layoutSession.d.ts +1 -0
  18. package/dist/display-list/build/tablePrimitives.d.ts +3 -1
  19. package/dist/display-list/build/tablePrimitives.js +29 -13
  20. package/dist/docx/chartPreview.d.ts +4 -1
  21. package/dist/docx/chartPreview.js +26 -15
  22. package/dist/docx/mainDocumentPart.d.ts +6 -0
  23. package/dist/docx/mainDocumentPart.js +65 -0
  24. package/dist/docx/packageParts.d.ts +1 -1
  25. package/dist/docx/packageParts.js +10 -4
  26. package/dist/docx/previewBudget.d.ts +6 -0
  27. package/dist/docx/previewBudget.js +7 -1
  28. package/dist/docx/rezip.js +4 -4
  29. package/dist/docx/shapeAlternateContent.js +19 -0
  30. package/dist/docx/unzip.js +2 -0
  31. package/dist/i18n/messages/ar.gen.js +1 -0
  32. package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
  33. package/dist/i18n/messages/catalogs.gen.js +17 -0
  34. package/dist/i18n/messages/cs.gen.js +1 -0
  35. package/dist/i18n/messages/de.gen.js +1 -0
  36. package/dist/i18n/messages/en.gen.js +1 -0
  37. package/dist/i18n/messages/es.gen.js +1 -0
  38. package/dist/i18n/messages/et.gen.js +1 -0
  39. package/dist/i18n/messages/fr.gen.js +1 -0
  40. package/dist/i18n/messages/he.gen.js +1 -0
  41. package/dist/i18n/messages/hi.gen.js +1 -0
  42. package/dist/i18n/messages/hu.gen.js +1 -0
  43. package/dist/i18n/messages/lt.gen.js +1 -0
  44. package/dist/i18n/messages/lv.gen.js +1 -0
  45. package/dist/i18n/messages/messages.gen.d.ts +1 -0
  46. package/dist/i18n/messages/pl.gen.js +1 -0
  47. package/dist/i18n/messages/pt-BR.gen.js +1 -0
  48. package/dist/i18n/messages/sk.gen.js +1 -0
  49. package/dist/i18n/messages/tr.gen.js +1 -0
  50. package/dist/i18n/messages/zh-CN.gen.js +1 -0
  51. package/dist/internal/wholeStoryRevisionResolution.js +57 -12
  52. package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
  53. package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
  54. package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
  55. package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
  56. package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
  57. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  58. package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
  59. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  60. package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
  61. package/dist/layout-bridge/convert/tableConversion.js +6 -2
  62. package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
  63. package/dist/layout-bridge/engine/clickToPosition.js +5 -1
  64. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  65. package/dist/layout-engine/measure/tableCellFloating.js +1 -0
  66. package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
  67. package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
  68. package/dist/layout-engine/tableLayout.js +7 -4
  69. package/dist/layout-engine/tableRowBreak.d.ts +10 -0
  70. package/dist/layout-engine/tableRowBreak.js +151 -36
  71. package/dist/layout-engine/types.d.ts +7 -2
  72. package/dist/layout-painter/previewSvg.d.ts +8 -0
  73. package/dist/layout-painter/previewSvg.js +47 -0
  74. package/dist/layout-painter/renderImage.js +2 -1
  75. package/dist/layout-painter/renderPage.d.ts +1 -0
  76. package/dist/layout-painter/renderPage.js +6 -3
  77. package/dist/layout-painter/renderParagraph.js +3 -2
  78. package/dist/layout-painter/renderTable.d.ts +5 -2
  79. package/dist/layout-painter/renderTable.js +33 -19
  80. package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
  81. package/dist/prosemirror/commands/comments.js +20 -7
  82. package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
  83. package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
  84. package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
  85. package/dist/prosemirror/commands/pastePlainText.js +13 -3
  86. package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
  87. package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
  88. package/dist/prosemirror/commentReferenceIntegrity.js +19 -4
  89. package/dist/prosemirror/conversion/fromProseDoc.js +39 -4
  90. package/dist/prosemirror/conversion/toProseDoc.js +6 -4
  91. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
  92. package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
  93. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
  94. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
  95. package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
  96. package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
  97. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
  98. package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
  99. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
  100. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
  101. package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
  102. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
  103. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
  104. package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
  105. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
  106. package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
  107. package/dist/prosemirror/extensions/nodes/TableExtension.js +87 -7
  108. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
  109. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
  110. package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
  111. package/dist/prosemirror/plugins/suggestionMode.js +175 -21
  112. package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
  113. package/dist/prosemirror/rowGridOmissions.js +21 -0
  114. package/dist/prosemirror/tableGridMutation.d.ts +19 -2
  115. package/dist/prosemirror/tableGridMutation.js +118 -15
  116. package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
  117. package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
  118. package/dist/prosemirror/validation.js +1 -1
  119. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  import { NO_NUMBERING_IDS_IN_USE } from "../docx/numberingIds.js";
2
- import { isNumberingReference } from "../docx/numberingReference.js";
2
+ import { isNumberingReference as isNumberingReference$1 } from "../docx/numberingReference.js";
3
3
  import { formattingEquals } from "../docx/runConsolidator.js";
4
4
  import { isStyleSourcedParagraphNumbering } from "../internal/paragraphFormattingSerialization.js";
5
5
  import { addTrackedDeletionMark } from "../prosemirror/addTrackedDeletionMark.js";
@@ -58,6 +58,7 @@ import { findEnclosingTableCell, findEnclosingTableRow, findOutermostTableBounda
58
58
  import { tableFromTemplate } from "./table-template.js";
59
59
  import { wordDiffSessionFromOptions } from "./word-diff.js";
60
60
  import { panic } from "better-result";
61
+ import { REVIEW_CARRIERS } from "@stll/docx-core/model";
61
62
  import { Fragment, Mark } from "prosemirror-model";
62
63
  import { TableMap } from "prosemirror-tables";
63
64
  import { canSplit } from "prosemirror-transform";
@@ -856,9 +857,16 @@ const applyTrackedInlineFormattingToRanges = ({ tr, schema, doc = tr.doc, ranges
856
857
  suggestionId
857
858
  };
858
859
  const revisionIds = [];
860
+ let fieldChange = null;
859
861
  for (const segment of segments) {
860
- const revisionId = revisionIdSeed + revisionIds.length;
861
- revisionIds.push(revisionId);
862
+ const { representation } = segment;
863
+ const insideField = fieldChange !== null && representation.role === "serialized-result" && representation.position < fieldChange.end;
864
+ const revisionId = insideField && fieldChange !== null ? fieldChange.id : revisionIdSeed + revisionIds.length;
865
+ if (!insideField) revisionIds.push(revisionId);
866
+ if (representation.role === "owner" && representation.carrierDisposition === "structured-field") fieldChange = {
867
+ id: revisionId,
868
+ end: representation.position + representation.node.nodeSize
869
+ };
862
870
  const change = {
863
871
  type: "runPropertyChange",
864
872
  info: {
@@ -1406,12 +1414,13 @@ const readNow = (item, tr) => {
1406
1414
  * properties (see `carryParagraphProperties`). Null when the paragraph stands
1407
1415
  * alone, or goes whole as a pending deletion.
1408
1416
  */
1409
- const pendingJoinSurvivor = ({ doc, paragraphPos, cleanText, noteReferences }) => {
1417
+ const pendingJoinSurvivor = ({ doc, paragraphPos, cleanText, noteReferences, removedBreakPositions }) => {
1410
1418
  const paragraph = doc.nodeAt(paragraphPos);
1411
1419
  if (paragraph?.type.name !== "paragraph" || !isDeletedPPrMark(paragraph.attrs["pPrMark"]) || isPendingDeletion(doc, paragraphPos, paragraph, cleanText)) return null;
1412
1420
  const survivor = paragraphLeftAfter({
1413
1421
  doc,
1414
- paragraphPos
1422
+ paragraphPos,
1423
+ ...removedBreakPositions ? { removedBreakPositions } : {}
1415
1424
  });
1416
1425
  const left = survivor === null ? null : doc.nodeAt(survivor);
1417
1426
  if (survivor === null || left?.type !== paragraph.type) return null;
@@ -1427,7 +1436,7 @@ const pendingJoinSurvivor = ({ doc, paragraphPos, cleanText, noteReferences }) =
1427
1436
  * suggestion is read against the document as it stands, where the join has
1428
1437
  * not run anything together yet, so it copies the paragraph it names.
1429
1438
  */
1430
- const insertionFormattingAnchor = ({ item, tr, mode, noteReferences }) => {
1439
+ const insertionFormattingAnchor = ({ item, tr, mode, noteReferences, removedBreakPositions }) => {
1431
1440
  if (mode === "suggested") return item;
1432
1441
  const position = sinceRead(tr, item).map(item.blockFrom, 1);
1433
1442
  const anchor = tr.doc.nodeAt(position);
@@ -1439,7 +1448,8 @@ const insertionFormattingAnchor = ({ item, tr, mode, noteReferences }) => {
1439
1448
  fieldResults: "text",
1440
1449
  noteReferences
1441
1450
  }).text,
1442
- noteReferences
1451
+ noteReferences,
1452
+ removedBreakPositions
1443
1453
  });
1444
1454
  const source = survivor === null ? null : tr.doc.nodeAt(survivor);
1445
1455
  return source ? {
@@ -2732,6 +2742,28 @@ const buildInsertedParagraphs = ({ item, schema, formattingFromStyle, mode, auth
2732
2742
  nextRevisionId
2733
2743
  };
2734
2744
  };
2745
+ /** The story's last block but for text boxes, which stand after their paragraph. */
2746
+ const lastBlockBeforeTextBoxes = (doc) => {
2747
+ let position = doc.content.size;
2748
+ for (let index = doc.childCount - 1; index >= 0; index--) {
2749
+ const node = doc.child(index);
2750
+ position -= node.nodeSize;
2751
+ if (node.type.name !== "textBox") return {
2752
+ node,
2753
+ position
2754
+ };
2755
+ }
2756
+ return null;
2757
+ };
2758
+ /**
2759
+ * A story that ended with a table now ends with a tracked paragraph: resolving
2760
+ * it away restores that ending, though a story otherwise keeps a final paragraph.
2761
+ */
2762
+ const markTerminalTableReviewCarrier = (tr, before) => {
2763
+ if (lastBlockBeforeTextBoxes(before)?.node.type.name !== "table") return;
2764
+ const last = lastBlockBeforeTextBoxes(tr.doc);
2765
+ if (last?.node.type.name === "paragraph" && expectParagraphAttrs(last.node).pPrMark?.kind === "ins") tr.setNodeAttribute(last.position, "reviewCarrier", REVIEW_CARRIERS.TERMINAL_TABLE);
2766
+ };
2735
2767
  const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: requestedOperations, mode = "tracked-changes", author = "AI", initials, createCommentId, revisionStamp, revisionIdSeed, wordDiff, wordDiffMode = "bounded", tableTemplates, replacementBackground = "clear", undefinedReferences, numberingIdsElsewhere }) => {
2736
2768
  seedRevisionIdsFromDoc(view.state.doc);
2737
2769
  const applied = [];
@@ -3189,7 +3221,8 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3189
3221
  item: insertion,
3190
3222
  tr,
3191
3223
  mode,
3192
- noteReferences
3224
+ noteReferences,
3225
+ removedBreakPositions: pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs)
3193
3226
  });
3194
3227
  const built = buildInsertedParagraphs({
3195
3228
  item: formatted,
@@ -3598,7 +3631,8 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3598
3631
  item,
3599
3632
  tr,
3600
3633
  mode,
3601
- noteReferences
3634
+ noteReferences,
3635
+ removedBreakPositions: pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs)
3602
3636
  });
3603
3637
  const built = buildInsertedParagraphs({
3604
3638
  item: formatted,
@@ -4589,6 +4623,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4589
4623
  });
4590
4624
  }
4591
4625
  removeRowsWithoutCellsAfterBatch(tr, emptiedRows);
4626
+ markTerminalTableReviewCarrier(tr, view.state.doc);
4592
4627
  if (tr.docChanged || deferredNoopFinalDeletions.size > 0) {
4593
4628
  const batchRevisionIds = new Set(applied.flatMap(({ revisionIds }) => revisionIds ?? []));
4594
4629
  tr = withoutRevisionsOnZeroWidthAnchors(tr, batchRevisionIds, deletedTextBoxAnchorIds);
@@ -6286,7 +6321,7 @@ const describeUndefinedParagraphStyle = ({ path, styleId, definedAs }, definitio
6286
6321
  return `${path} "${styleId}" ${definedAs === void 0 ? "names no style in this document" : `names a ${definedAs} style, not a paragraph style`} (${available}).`;
6287
6322
  };
6288
6323
  /** The `w:num` id a stated numbering names, when it names one. */
6289
- const statedNumberingInstance = (numbering) => numbering?.kind === "reference" && isNumberingReference(numbering.numId) ? numbering.numId : void 0;
6324
+ const statedNumberingInstance = (numbering) => numbering?.kind === "reference" && isNumberingReference$1(numbering.numId) ? numbering.numId : void 0;
6290
6325
  /**
6291
6326
  * Every numbering instance an operation names, with the field that names it.
6292
6327
  * Only reference variants name an instance; inheritance, cancellation and level-only do not.
@@ -46,7 +46,8 @@ const blockRolesOf = (claim) => {
46
46
  keepsParagraph: claim.keepsParagraph,
47
47
  endsContainer: claim.endsContainer,
48
48
  paragraphsBefore: claim.paragraphsBefore,
49
- retiresBreakBefore: false
49
+ retiresBreakBefore: false,
50
+ everyParagraphBeforeGoes: false
50
51
  }
51
52
  }];
52
53
  case "merge": return [{
@@ -108,7 +109,7 @@ const rolesConflict = (left, right) => {
108
109
  if (ROLE_RANK[right.kind] > ROLE_RANK[left.kind]) return rolesConflict(right, left);
109
110
  switch (left.kind) {
110
111
  case "deleteBlock": switch (right.kind) {
111
- case "paragraphProperties": return left.endsContainer && (!left.keepsParagraph || left.retiresBreakBefore);
112
+ case "paragraphProperties": return left.endsContainer && (!left.keepsParagraph || left.retiresBreakBefore || left.everyParagraphBeforeGoes);
112
113
  case "mergeNext": return false;
113
114
  default: return true;
114
115
  }
@@ -176,7 +177,8 @@ var BatchClaims = class {
176
177
  settled(role) {
177
178
  return role.kind === "deleteBlock" ? {
178
179
  ...role,
179
- retiresBreakBefore: this.retiresBreakBefore(role)
180
+ retiresBreakBefore: this.retiresBreakBefore(role),
181
+ everyParagraphBeforeGoes: role.paragraphsBefore.length > 0 && role.paragraphsBefore.every(({ block }) => (this.blocks.get(block) ?? []).some((entry) => entry.role.kind === "deleteBlock"))
180
182
  } : role;
181
183
  }
182
184
  /** `claim`'s roles, given the insertions accepted so far. */
@@ -104,7 +104,10 @@ const buildCleanBlockText = (blockNode, blockFrom, { fieldResults, noteReference
104
104
  });
105
105
  return false;
106
106
  }
107
- const atomText = fieldResults === "omitted" ? runFormattingInlineControlCharacter(node) : runFormattingInlineAtomCleanText(node);
107
+ let atomText;
108
+ if (fieldResults === "omitted") atomText = runFormattingInlineControlCharacter(node);
109
+ else if (node.type.name === "structuredField") atomText = node.textContent;
110
+ else atomText = runFormattingInlineAtomCleanText(node);
108
111
  if (atomText !== null) {
109
112
  if (isOmittedFromCleanView(node)) return false;
110
113
  const startPos = blockFrom + 1 + pos;
@@ -1,6 +1,6 @@
1
1
  import { expectRunPropertyChangeMarkAttrs, expectTrackedChangeMarkAttrs } from "../prosemirror/attrs/index.js";
2
2
  import { getFolioNodeRevisionCarriers } from "../prosemirror/revisionCarriers.js";
3
- import { expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomDisposition } from "../prosemirror/runFormattingInlineCarriers.js";
3
+ import { expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomDisposition, runFormattingInlineAtomResultText } from "../prosemirror/runFormattingInlineCarriers.js";
4
4
  import { getTableCellMergeChange } from "../prosemirror/tableCellMergeRevision.js";
5
5
  import { enclosingInsertionAncestors, trackedRevisionLayerOf } from "../prosemirror/trackedRevisionPath.js";
6
6
  import { commentAnchorIdsForNode } from "./comment-lifecycle.js";
@@ -356,8 +356,10 @@ const getCommentAnchorsFromDoc = (doc) => {
356
356
  start: bodyText.length,
357
357
  end: bodyText.length
358
358
  });
359
- if (!node.isInline || node.text === void 0) return;
360
- const text = readerTextOf(node, noteReferences);
359
+ const isStructuredField = node.type.name === "structuredField";
360
+ const fieldText = isStructuredField ? node.textContent : runFormattingInlineAtomResultText(node);
361
+ if (!node.isInline || node.text === void 0 && fieldText === null) return;
362
+ const text = node.text === void 0 ? fieldText ?? "" : readerTextOf(node, noteReferences);
361
363
  const end = bodyText.length + text.length;
362
364
  for (const mark of node.marks) {
363
365
  if (mark.type !== commentType || typeof mark.attrs["commentId"] !== "number") continue;
@@ -372,7 +374,7 @@ const getCommentAnchorsFromDoc = (doc) => {
372
374
  end
373
375
  });
374
376
  }
375
- bodyText += text;
377
+ if (!isStructuredField) bodyText += text;
376
378
  });
377
379
  return [...ranges].map(([commentId, { blockId, start, end }]) => ({
378
380
  commentId,
@@ -368,7 +368,7 @@ const STORY_TABLE_HIDDEN_SUBTREE = "hidden-subtree";
368
368
  const STORY_TABLE = "table";
369
369
  /** Shared visibility and table-role rule for both story projection walks. */
370
370
  const classifyNonTextblockStoryTableNode = (node) => {
371
- if (isHiddenTableRow(node)) return STORY_TABLE_HIDDEN_SUBTREE;
371
+ if (isHiddenTableRow(node) || node.attrs["_omittedGridSlot"]) return STORY_TABLE_HIDDEN_SUBTREE;
372
372
  return node.type.spec["tableRole"] === TABLE_ROLE_TABLE ? STORY_TABLE : STORY_TABLE_CONTAINER;
373
373
  };
374
374
  /**
@@ -704,18 +704,7 @@ const getPreviewRuns = ({ node, nodeFrom, cleanBlock, styleResolver }) => {
704
704
  const defaultStyle = getDefaultPreviewRunStyle(node, styleResolver);
705
705
  let paragraphStyleContext;
706
706
  let cleanOffset = 0;
707
- node.descendants((child, relativePosition) => {
708
- const start = nodeFrom + 1 + relativePosition;
709
- const noteReference = cleanBlock.structuralBoundaries.find((boundary) => boundary.type === "noteReference" && boundary.from === start);
710
- let text;
711
- if (noteReference !== void 0) text = cleanBlock.text.slice(noteReference.offset, noteReference.offset + noteReference.length);
712
- else text = child.isText ? child.text : runFormattingInlineAtomCleanText(child);
713
- if (text === void 0 || text === null || text.length === 0) return true;
714
- if (child.marks.some((mark) => mark.type.name === DELETION_MARK || mark.type.name === HIDDEN_MARK)) return false;
715
- while ((cleanBlock.offsets[cleanOffset] ?? Number.POSITIVE_INFINITY) < start) cleanOffset++;
716
- const lastCharacterPosition = child.isText && noteReference === void 0 ? start + text.length - 1 : start;
717
- if (cleanBlock.offsets[cleanOffset] !== start || cleanBlock.offsets[cleanOffset + text.length - 1] !== lastCharacterPosition) return false;
718
- cleanOffset += text.length;
707
+ const pushRun = (child, text) => {
719
708
  const style = getPreviewRunStyle(child.marks, defaultStyle);
720
709
  const hasAuthorshipCarrier = child.marks.some(({ type }) => type.name === RUN_FORMATTING_OVERRIDE_MARK || type.name === CHARACTER_STYLE_MARK);
721
710
  let directFormatting;
@@ -734,13 +723,34 @@ const getPreviewRuns = ({ node, nodeFrom, cleanBlock, styleResolver }) => {
734
723
  const previous = runs.at(-1);
735
724
  if (previous && samePreviewRunStyle(previous, style) && sameDirectFormatting(previous.directFormatting, directFormatting)) {
736
725
  previous.text += text;
737
- return false;
726
+ return;
738
727
  }
739
728
  runs.push({
740
729
  text,
741
730
  ...style,
742
731
  ...!isEmptyPreviewRunStyle(directFormatting) && { directFormatting }
743
732
  });
733
+ };
734
+ node.descendants((child, relativePosition) => {
735
+ const start = nodeFrom + 1 + relativePosition;
736
+ const noteReference = cleanBlock.structuralBoundaries.find((boundary) => boundary.type === "noteReference" && boundary.from === start);
737
+ let text;
738
+ if (noteReference !== void 0) text = cleanBlock.text.slice(noteReference.offset, noteReference.offset + noteReference.length);
739
+ else if (child.type.name === "structuredField") text = child.textContent;
740
+ else text = child.isText ? child.text : runFormattingInlineAtomCleanText(child);
741
+ if (text === void 0 || text === null || text.length === 0) return true;
742
+ if (child.marks.some((mark) => mark.type.name === DELETION_MARK || mark.type.name === HIDDEN_MARK)) return false;
743
+ while ((cleanBlock.offsets[cleanOffset] ?? Number.POSITIVE_INFINITY) < start) cleanOffset++;
744
+ const lastCharacterPosition = child.isText && noteReference === void 0 ? start + text.length - 1 : start;
745
+ if (cleanBlock.offsets[cleanOffset] !== start || cleanBlock.offsets[cleanOffset + text.length - 1] !== lastCharacterPosition) return false;
746
+ cleanOffset += text.length;
747
+ if (child.type.name === "structuredField") {
748
+ child.forEach((run) => {
749
+ if (run.isText && run.text) pushRun(run, run.text);
750
+ });
751
+ return false;
752
+ }
753
+ pushRun(child, text);
744
754
  return false;
745
755
  });
746
756
  if (runs.every(isUnstyledPreviewRun)) return;
@@ -22,7 +22,7 @@ const mergeTableRectangle = ({ tr, tablePosition, table, rectangle }) => {
22
22
  const cellPosition = map.map[row * map.width + column];
23
23
  if (cellPosition === void 0 || seen.has(cellPosition)) continue;
24
24
  const cell = table.nodeAt(cellPosition);
25
- if (!cell) return null;
25
+ if (!cell || cell.attrs["_omittedGridSlot"]) return null;
26
26
  seen.add(cellPosition);
27
27
  cells.push({
28
28
  position: cellPosition,
@@ -63,7 +63,7 @@ const mergeTableRectangle = ({ tr, tablePosition, table, rectangle }) => {
63
63
  const contentStart = isEmptyTableCell(merged.cell) ? absoluteMergedPosition + 1 : contentEnd;
64
64
  tr = tr.replaceWith(contentStart, contentEnd, appendedContent);
65
65
  }
66
- removeRowsWithoutCells(tr, tablePosition);
66
+ removeRowsWithoutCells(tr, tablePosition, table);
67
67
  return tr;
68
68
  };
69
69
  const mergeTopRowColwidths = (cells, mergedColspan) => {
@@ -109,6 +109,7 @@ const mergeTrackedVerticalTableCells = ({ tr, tablePosition, table, rectangle, r
109
109
  const position = map.map[row * map.width + rectangle.left];
110
110
  if (position === void 0) return null;
111
111
  const cell = table.nodeAt(position);
112
+ if (cell?.attrs["_omittedGridSlot"]) return null;
112
113
  if (!cell || !tableRectanglesEqual(map.findCell(position), {
113
114
  left: rectangle.left,
114
115
  top: row,
@@ -1,6 +1,6 @@
1
1
  import { addTrackedDeletionMark } from "../prosemirror/addTrackedDeletionMark.js";
2
2
  import { markStructuralChange } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
3
- import { markRowsEmptiedInBatch, reconcileTableGridAfterColumnInsertion, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCells, removeTableRow } from "../prosemirror/tableGridMutation.js";
3
+ import { markRowsEmptiedInBatch, omittedSlotTakingColumn, reconcileTableGridAfterColumnInsertion, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCells, removeTableRow } from "../prosemirror/tableGridMutation.js";
4
4
  import { sliceText } from "../utils/sliceText.js";
5
5
  import { stripBlockIdentityAttrs } from "./block-identity.js";
6
6
  import { findEnclosingTableCell, findEnclosingTableRow } from "./table-targets.js";
@@ -177,7 +177,7 @@ const applyTableColumnInsertion = ({ tr, insertion, cellTexts, revision }) => {
177
177
  if (insertion.columnIndex >= 0 && insertion.columnIndex <= map.width) {
178
178
  const overflow = describeUnplacedCellTexts({
179
179
  cellTexts,
180
- capacity: getInsertedPhysicalColumnRows(map, insertion.columnIndex).length,
180
+ capacity: getInsertedPhysicalColumnRows(map, table, insertion.columnIndex).length,
181
181
  target: "column"
182
182
  });
183
183
  if (overflow !== null) return {
@@ -200,6 +200,10 @@ const applyTableColumnInsertion = ({ tr, insertion, cellTexts, revision }) => {
200
200
  tr.setNodeMarkup(position, void 0, action.attrs);
201
201
  continue;
202
202
  }
203
+ if (action.type === "growOmittedSlot") {
204
+ tr.setNodeAttribute(position, "colspan", action.colspan);
205
+ continue;
206
+ }
203
207
  const cell = revision ? action.cell.type.create({
204
208
  ...action.cell.attrs,
205
209
  cellMarker: {
@@ -267,7 +271,7 @@ const applyTableColumnDeletion = ({ tr, deletion, insertedColumnCount, revision,
267
271
  previousTable: table,
268
272
  emptied: emptiedRows
269
273
  });
270
- else removeRowsWithoutCells(tr, tablePosition);
274
+ else removeRowsWithoutCells(tr, tablePosition, table);
271
275
  return applied(tr, null);
272
276
  };
273
277
  const applyTableRowDeletion = ({ tr, deletion, revision }) => {
@@ -391,11 +395,11 @@ const populateTableRow = (row, cellTexts) => {
391
395
  });
392
396
  return row.type.create(row.attrs, cells);
393
397
  };
394
- const getInsertedPhysicalColumnRows = (map, columnIndex) => {
398
+ const getInsertedPhysicalColumnRows = (map, table, columnIndex) => {
395
399
  const rows = [];
396
400
  for (let row = 0; row < map.height; row++) {
397
401
  const index = row * map.width + columnIndex;
398
- if (!(columnIndex > 0 && columnIndex < map.width && map.map[index - 1] === map.map[index])) rows.push(row);
402
+ if (!(columnIndex > 0 && columnIndex < map.width && map.map[index - 1] === map.map[index]) && omittedSlotTakingColumn(map, table, row, columnIndex) === null) rows.push(row);
399
403
  }
400
404
  return rows;
401
405
  };
@@ -423,7 +427,7 @@ const populateTableCell = (cell, text) => {
423
427
  };
424
428
  const buildTableColumnInsertionActions = ({ map, table, columnIndex, cellTexts }) => {
425
429
  if (columnIndex < 0 || columnIndex > map.width) return null;
426
- const physicalRows = getInsertedPhysicalColumnRows(map, columnIndex);
430
+ const physicalRows = getInsertedPhysicalColumnRows(map, table, columnIndex);
427
431
  if ((cellTexts?.length ?? 0) > physicalRows.length) return null;
428
432
  let referenceColumn = columnIndex > 0 ? -1 : 0;
429
433
  if (columnIsHeader(map, table, columnIndex + referenceColumn)) referenceColumn = columnIndex === 0 || columnIndex === map.width ? null : 0;
@@ -431,6 +435,15 @@ const buildTableColumnInsertionActions = ({ map, table, columnIndex, cellTexts }
431
435
  let physicalCellIndex = 0;
432
436
  for (let row = 0; row < map.height; row++) {
433
437
  const index = row * map.width + columnIndex;
438
+ const omitted = omittedSlotTakingColumn(map, table, row, columnIndex);
439
+ if (omitted !== null) {
440
+ actions.push({
441
+ type: "growOmittedSlot",
442
+ position: omitted,
443
+ colspan: (Number(table.nodeAt(omitted)?.attrs["colspan"]) || 1) + 1
444
+ });
445
+ continue;
446
+ }
434
447
  if (columnIndex > 0 && columnIndex < map.width && map.map[index - 1] === map.map[index]) {
435
448
  const position = map.map[index];
436
449
  if (position === void 0) return null;
@@ -468,6 +481,7 @@ const getTableColumnDeletionCellPositions = ({ map, table, columnIndex }) => {
468
481
  const position = map.map[row * map.width + columnIndex];
469
482
  if (position === void 0) return null;
470
483
  const cell = table.nodeAt(position);
484
+ if (cell?.attrs["_omittedGridSlot"]) continue;
471
485
  const tableRole = cell?.type.spec["tableRole"];
472
486
  if (!cell || tableRole !== "cell" && tableRole !== "header_cell" || cell.attrs["colspan"] !== 1 || cell.attrs["cellMarker"] != null) return null;
473
487
  positions.add(position);
@@ -54,7 +54,7 @@ export declare const createCanonicalComposition: (options: CompositionOptions) =
54
54
  forgetCompleted: () => void;
55
55
  readonly pendingFinal: boolean;
56
56
  authorizeLateFinal: (view: EditorView, text: string | null) => boolean;
57
- authorizeNative: (view: EditorView, completion: CompositionCompletionEvidence) => void;
57
+ authorizeNative: (view: EditorView, completion: CompositionCompletionEvidence, finalText?: string | null) => void;
58
58
  flushed: (view: EditorView) => void;
59
59
  recover: (view: EditorView) => CompositionFinish;
60
60
  cancel: (view: EditorView) => CompositionFinish;
@@ -1,26 +1,39 @@
1
1
  import { splitsSurrogatePair } from "../ai-edits/character-boundaries.js";
2
- import { RUN_IDENTITY_MARK_NAME } from "../prosemirror/runIdentity.js";
3
2
  import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
4
3
  import { setCanonicalInputTimer } from "./canonicalInputTimer.js";
5
4
  import { CanonicalSessionError } from "./canonicalSession.js";
6
5
  import { Result } from "better-result";
7
6
  import { EditorState, TextSelection } from "prosemirror-state";
8
7
  // src/controller/canonicalComposition.ts
8
+ const REVIEW_MARK_NAMES = /* @__PURE__ */ new Set(["insertion", "deletion"]);
9
+ /**
10
+ * Whether a native proposal is one plain replacement. The commit is a text
11
+ * replacement over the captured model, so this only has to tell DOM noise from a
12
+ * real change. Reading the DOM back can lose a mark with no parse rule or, through
13
+ * `insertText`, a non-inclusive one. It rebuilds a review mark from fewer attributes,
14
+ * and composed text sits in the DOM wrapper of the tracked run beside it. Gaining
15
+ * any other mark, losing an inclusive one, or another revision is a real change.
16
+ * So is a selected paragraph boundary that does not disappear exactly.
17
+ */
9
18
  const matchesNativeReplacement = ({ baseline, proposed, from, to, text }) => {
10
19
  const expected = baseline.tr.insertText(text, from, to);
11
20
  if (expected.doc.eq(proposed.doc)) return true;
12
- if (!baseline.doc.resolve(from).sameParent(baseline.doc.resolve(to))) return false;
21
+ const $from = baseline.doc.resolve(from);
22
+ const $to = baseline.doc.resolve(to);
13
23
  if (expected.doc.content.size !== proposed.doc.content.size) return false;
14
- const markType = baseline.schema.marks[RUN_IDENTITY_MARK_NAME];
15
- if (markType === void 0) return false;
16
24
  const position = expected.doc.resolve(from);
17
25
  const paragraph = position.parent;
18
26
  const start = position.start();
19
27
  const native = proposed.doc.nodeAt(start - 1);
20
28
  if (native === null || native.type !== paragraph.type) return false;
29
+ if (!$from.sameParent($to) && native.sameMarkup($to.parent)) expected.setNodeMarkup(start - 1, void 0, native.attrs, native.marks);
30
+ const composedFrom = from;
31
+ const composedTo = from + text.length;
32
+ const types = Object.values(baseline.schema.marks);
33
+ const beside = [$from.nodeBefore, $to.nodeAfter];
34
+ const corrections = [];
21
35
  let index = 0;
22
36
  let offset = 0;
23
- const missing = [];
24
37
  native.forEach((node, nodeOffset) => {
25
38
  const end = nodeOffset + node.nodeSize;
26
39
  let cursor = nodeOffset;
@@ -28,14 +41,21 @@ const matchesNativeReplacement = ({ baseline, proposed, from, to, text }) => {
28
41
  const authored = paragraph.child(index);
29
42
  const authoredEnd = offset + authored.nodeSize;
30
43
  const overlapEnd = Math.min(end, authoredEnd);
31
- if (node.isText && authored.isText && markType.isInSet(authored.marks) !== void 0 && markType.isInSet(node.marks) === void 0) {
32
- const previous = missing.at(-1);
33
- if (previous?.to === start + cursor) previous.to = start + overlapEnd;
34
- else missing.push({
35
- type: "omittedRunIdentity",
36
- from: start + cursor,
37
- to: start + overlapEnd
38
- });
44
+ if (node.isText && authored.isText) {
45
+ const rangeFrom = start + cursor;
46
+ const rangeTo = start + overlapEnd;
47
+ for (const type of types) {
48
+ const held = type.isInSet(authored.marks);
49
+ const read = type.isInSet(node.marks);
50
+ if (held && !read) {
51
+ if (type.spec.inclusive === false || (type.spec.parseDOM ?? []).length === 0) corrections.push(() => expected.removeMark(rangeFrom, rangeTo, type));
52
+ continue;
53
+ }
54
+ if (!read || !REVIEW_MARK_NAMES.has(type.name)) continue;
55
+ const sameRevision = held?.attrs["revisionId"] === read.attrs["revisionId"];
56
+ const inWrapperBeside = rangeFrom >= composedFrom && rangeTo <= composedTo && beside.some((neighbour) => type.isInSet(neighbour?.marks ?? []));
57
+ if (held ? sameRevision : inWrapperBeside) corrections.push(() => expected.addMark(rangeFrom, rangeTo, read));
58
+ }
39
59
  }
40
60
  cursor = overlapEnd;
41
61
  if (cursor === authoredEnd) {
@@ -44,7 +64,7 @@ const matchesNativeReplacement = ({ baseline, proposed, from, to, text }) => {
44
64
  }
45
65
  }
46
66
  });
47
- for (const range of missing) expected.removeMark(range.from, range.to, markType);
67
+ for (const correction of corrections) correction();
48
68
  return expected.doc.eq(proposed.doc);
49
69
  };
50
70
  /** Native IME owns the provisional view; the captured canonical projection stays unchanged. */
@@ -53,6 +73,10 @@ const createCanonicalComposition = (options) => {
53
73
  let authorizedNativeState = null;
54
74
  let completed = { type: "idle" };
55
75
  let timer;
76
+ /** The browser began again mid-composition; its proposals no longer say where. */
77
+ let restarted = false;
78
+ let acceptedUpdate = false;
79
+ let explicitFinal = null;
56
80
  const clearTimer = () => {
57
81
  if (timer !== void 0) clearTimeout(timer);
58
82
  timer = void 0;
@@ -149,6 +173,27 @@ const createCanonicalComposition = (options) => {
149
173
  semantic: "composition"
150
174
  };
151
175
  };
176
+ /**
177
+ * The browser can lose its composition range when the projection redraws a
178
+ * neighbouring node, and then starts again from a position it computes itself.
179
+ * Its final text still names what was composed, and the captured selection says
180
+ * where. A proposal that reaches the caret and holds that text is such a restart
181
+ * even when the restart event went unseen.
182
+ */
183
+ const finalInput = (pending, native) => {
184
+ const { phase, baseline } = pending;
185
+ const final = explicitFinal ?? (phase.type === "ended" ? phase.data : null);
186
+ if (!final || native.text === final) return native;
187
+ const { from, to, empty } = baseline.selection;
188
+ const atCaret = empty && native.from <= from && native.to >= from && native.text.includes(final);
189
+ if (!restarted && !atCaret) return native;
190
+ return {
191
+ from,
192
+ to,
193
+ text: final,
194
+ semantic: "composition"
195
+ };
196
+ };
152
197
  const applyNative = (view, transaction) => Result.try({
153
198
  try: () => view.state.applyTransaction(transaction),
154
199
  catch: (cause) => new CanonicalSessionError({
@@ -162,8 +207,9 @@ const createCanonicalComposition = (options) => {
162
207
  authorizedNativeState = null;
163
208
  const pending = state;
164
209
  if (pending.type === "committed") return { type: "idle" };
165
- const input = commit && pending.type === "provisional" ? replacement(pending.baseline, view.state) : null;
166
- const committedText = selectedText(pending.baseline, view.state);
210
+ const native = commit && pending.type === "provisional" ? replacement(pending.baseline, view.state) : null;
211
+ const input = native && pending.type === "provisional" ? finalInput(pending, native) : native;
212
+ const committedText = input && input !== native ? input.text : selectedText(pending.baseline, view.state);
167
213
  const proposed = view.state;
168
214
  const from = pending.baseline.selection.from;
169
215
  completed = { type: "idle" };
@@ -173,7 +219,7 @@ const createCanonicalComposition = (options) => {
173
219
  view.updateState(pending.baseline);
174
220
  }
175
221
  options.end();
176
- if (!commit || view.isDestroyed || pending.phase.type === "ended" && pending.phase.data === "" && pending.phase.completion === "provisional" && committedText === "") return { type: "cancelled" };
222
+ if (!commit || view.isDestroyed || pending.phase.type === "ended" && pending.phase.data === "" && pending.phase.completion === "provisional") return { type: "cancelled" };
177
223
  if (pending.type === "refused") return {
178
224
  type: "refused",
179
225
  text: pending.text
@@ -215,6 +261,7 @@ const createCanonicalComposition = (options) => {
215
261
  },
216
262
  matchesCancellationRange: (view, range) => {
217
263
  if (state.type === "committed" || state.view !== view) return false;
264
+ if (state.type === "refused") return true;
218
265
  const text = selectedText(state.baseline, view.state);
219
266
  if (text === null || text.length === 0) return false;
220
267
  const from = state.baseline.selection.from;
@@ -226,8 +273,13 @@ const createCanonicalComposition = (options) => {
226
273
  return view.posAtDOM(selected.startContainer, selected.startOffset) === range.from && view.posAtDOM(selected.endContainer, selected.endOffset) === range.to;
227
274
  },
228
275
  start: (view) => {
276
+ if (state.type === "provisional" && state.phase.type === "active" && acceptedUpdate) restarted = true;
229
277
  if (state.type !== "committed") return;
230
278
  if (!options.begin()) return;
279
+ restarted = false;
280
+ acceptedUpdate = false;
281
+ explicitFinal = null;
282
+ if (!view.state.selection.empty) authorizedNativeState = view.state;
231
283
  state = {
232
284
  type: "provisional",
233
285
  baseline: view.state,
@@ -287,7 +339,8 @@ const createCanonicalComposition = (options) => {
287
339
  };
288
340
  return true;
289
341
  },
290
- authorizeNative: (view, completion) => {
342
+ authorizeNative: (view, completion, finalText) => {
343
+ if (completion === "explicitFinal" && typeof finalText === "string") explicitFinal = finalText;
291
344
  authorizedNativeState = view.state;
292
345
  if (state.type !== "committed" && completion === "explicitFinal") state.phase = state.phase.type === "active" ? {
293
346
  type: "active",
@@ -359,6 +412,10 @@ const createCanonicalComposition = (options) => {
359
412
  view.updateState(state.baseline);
360
413
  return true;
361
414
  }
415
+ if (restarted) {
416
+ view.updateState(state.baseline);
417
+ return true;
418
+ }
362
419
  if (typeof transaction.getMeta("composition") !== "number" && authorizedNativeState !== view.state) {
363
420
  options.refuse("Other edits must wait until composition finishes.");
364
421
  return true;
@@ -389,6 +446,7 @@ const createCanonicalComposition = (options) => {
389
446
  options.refuse("Composition changed unsupported content; the canonical document was restored.");
390
447
  return true;
391
448
  }
449
+ acceptedUpdate = true;
392
450
  view.updateState(applied.value.state);
393
451
  return true;
394
452
  }
@@ -25,7 +25,6 @@ type CanonicalInputOptions = {
25
25
  redo: () => boolean;
26
26
  refuse: (reason: string) => void;
27
27
  };
28
- /** Native changes require a preceding, classified input event at the same state. */
29
28
  export declare const createCanonicalInputBoundary: (options: CanonicalInputOptions) => {
30
29
  reset: () => void;
31
30
  readonly isComposing: boolean;
@@ -11,6 +11,23 @@ const CANONICAL_COMPOSITION_INPUT_TYPES = [
11
11
  "deleteByComposition"
12
12
  ];
13
13
  /** Native changes require a preceding, classified input event at the same state. */
14
+ /**
15
+ * ProseMirror treats the end of one text node and the start of the next run as
16
+ * one position, so it leaves whichever the browser holds. Chromium's IME can
17
+ * resolve that caret against the start of the document, even when it reports the
18
+ * right node, until the selection is set again. A composition starts where the
19
+ * model's caret is: in the text before it, or at a paragraph's start in the first.
20
+ */
21
+ const placeCompositionCaret = (view) => {
22
+ const { selection } = view.state;
23
+ const native = view.dom.ownerDocument.getSelection();
24
+ if (!selection.empty || !native?.isCollapsed) return;
25
+ const before = view.domAtPos(selection.from, -1);
26
+ const { node, offset } = before.node.nodeType === before.node.TEXT_NODE ? before : view.domAtPos(selection.from, 1);
27
+ if (node.nodeType !== node.TEXT_NODE) return;
28
+ native.removeAllRanges();
29
+ native.collapse(node, offset);
30
+ };
14
31
  const createCanonicalInputBoundary = (options) => {
15
32
  const composition = createCanonicalComposition({
16
33
  begin: () => options.beginComposition?.() ?? true,
@@ -205,6 +222,7 @@ const createCanonicalInputBoundary = (options) => {
205
222
  compositionstart: (view) => {
206
223
  beginGesture();
207
224
  composition.start(view);
225
+ placeCompositionCaret(view);
208
226
  return false;
209
227
  },
210
228
  compositionend: (view, event) => {
@@ -246,7 +264,7 @@ const createCanonicalInputBoundary = (options) => {
246
264
  }
247
265
  const nativeFinal = view.composing && (event.inputType === "insertText" || event.inputType === "insertReplacementText");
248
266
  const nativeStillComposing = view.composing;
249
- if (nativeFinal) composition.authorizeNative(view, "explicitFinal");
267
+ if (nativeFinal) composition.authorizeNative(view, "explicitFinal", event.data);
250
268
  const recovered = composition.recover(view);
251
269
  composition.forgetCompleted();
252
270
  proposal = { type: "idle" };
@@ -967,8 +967,7 @@ var CanonicalSession = class {
967
967
  const second = secondGroup?.paragraphs.at(0);
968
968
  if (!first?.paraId || !second?.paraId) return noChange("There is no adjacent paragraph to join.");
969
969
  if (this.projection.paragraph(first.paraId)?.container !== this.projection.paragraph(second.paraId)?.container) return noChange("There is no adjacent paragraph to join.");
970
- const current = this.projection.paragraph(at.value.blockId);
971
- if (current === void 0 || at.value.offset !== (direction === "backward" ? 0 : current.text.length)) return refuse("Join requires a caret at a paragraph boundary.");
970
+ if (!isCanonicalJoinBoundary(state, direction)) return refuse("Join requires a caret at a paragraph boundary.");
972
971
  return this.prepareIntent(state, {
973
972
  type: "joinParagraphs",
974
973
  story: at.value.story,
@@ -75,6 +75,12 @@ export type HiddenEditorManagerDeps = {
75
75
  /** Document context for the API's `getDocument` (PM state -> Document). */
76
76
  getDocumentContext: () => document_d_exports.Document | null;
77
77
  onTransaction: (update: HiddenEditorTransactionUpdate) => void;
78
+ /**
79
+ * A canonical composition ended. A layout pass reads the live view, so one
80
+ * that ran during the composition painted provisional text that only a new
81
+ * pass can replace, and a cancellation publishes no commit that would ask.
82
+ */
83
+ onCanonicalCompositionEnd: () => void;
78
84
  onSelectionChange: (state: EditorState) => void;
79
85
  onKeyDown: (view: EditorView, event: KeyboardEvent) => boolean;
80
86
  onCopy?: () => void;