@stll/folio-core 0.75.0 → 0.76.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 (92) hide show
  1. package/dist/ai-edits/headless.d.ts +2 -1
  2. package/dist/ai-edits/headless.js +18 -12
  3. package/dist/ai-edits/pending-suggestions.js +2 -3
  4. package/dist/ai-edits/read.js +9 -3
  5. package/dist/ai-edits/types.d.ts +9 -4
  6. package/dist/canonical/batchCommentReferences.js +2 -1
  7. package/dist/canonical/canonicalBatchReview.js +5 -8
  8. package/dist/canonical/canonicalComments.js +8 -2
  9. package/dist/canonical/canonicalCompilerRefusal.d.ts +2 -4
  10. package/dist/canonical/canonicalCompilerRefusal.js +20 -14
  11. package/dist/canonical/canonicalPublicOperations.js +203 -71
  12. package/dist/canonical/canonicalSession.js +3 -1
  13. package/dist/controller/canonicalClipboard.d.ts +1 -1
  14. package/dist/controller/canonicalClipboard.js +71 -17
  15. package/dist/controller/canonicalContentControlValue.js +7 -7
  16. package/dist/controller/canonicalReview.d.ts +21 -0
  17. package/dist/controller/canonicalReview.js +44 -9
  18. package/dist/controller/canonicalStructure.d.ts +1 -2
  19. package/dist/controller/canonicalStructure.js +51 -24
  20. package/dist/controller/fontReadiness.js +50 -23
  21. package/dist/controller/hiddenEditorManager.js +5 -20
  22. package/dist/docx/bulletMarkers.d.ts +8 -0
  23. package/dist/docx/bulletMarkers.js +9 -1
  24. package/dist/docx/canonicalSessionInput.js +25 -11
  25. package/dist/docx/ensureParaIds.d.ts +31 -0
  26. package/dist/docx/ensureParaIds.js +57 -32
  27. package/dist/docx/ensureUniqueControlIds.d.ts +13 -0
  28. package/dist/docx/ensureUniqueControlIds.js +47 -29
  29. package/dist/docx/ensureUniqueRevisionIds.d.ts +13 -0
  30. package/dist/docx/ensureUniqueRevisionIds.js +52 -29
  31. package/dist/docx/server/templatePlan/apply.js +62 -8
  32. package/dist/docx/server/templatePlan/blocks.d.ts +55 -3
  33. package/dist/docx/server/templatePlan/blocks.js +182 -6
  34. package/dist/docx/server/templatePlan/builders.d.ts +16 -1
  35. package/dist/docx/server/templatePlan/builders.js +31 -3
  36. package/dist/docx/server/templatePlan/effects.d.ts +27 -0
  37. package/dist/docx/server/templatePlan/effects.js +188 -0
  38. package/dist/docx/server/templatePlan/emit.d.ts +2 -1
  39. package/dist/docx/server/templatePlan/emit.js +44 -2
  40. package/dist/docx/server/templatePlan/inspect.js +21 -1
  41. package/dist/docx/server/templatePlan/labels.js +16 -1
  42. package/dist/docx/server/templatePlan/plan.d.ts +12 -3
  43. package/dist/docx/server/templatePlan/plan.js +36 -12
  44. package/dist/docx/server/templatePlan/planShape.js +47 -22
  45. package/dist/docx/server/templatePlan/revisions.d.ts +46 -0
  46. package/dist/docx/server/templatePlan/revisions.js +407 -0
  47. package/dist/docx/server/templatePlan/story.d.ts +15 -1
  48. package/dist/docx/server/templatePlan/story.js +50 -2
  49. package/dist/docx/server/templatePlan/types.d.ts +217 -1
  50. package/dist/docx/server/templatePlan/verify.js +117 -8
  51. package/dist/docx/server/templatePlan/xml.d.ts +3 -0
  52. package/dist/docx/server/templatePlan/xml.js +4 -1
  53. package/dist/internal/revisionResolutionStep.d.ts +2 -31
  54. package/dist/internal/revisionResolutionStep.js +2 -171
  55. package/dist/prosemirror/commands/comments.d.ts +6 -234
  56. package/dist/prosemirror/commands/comments.js +5 -2464
  57. package/dist/prosemirror/commands/index.d.ts +4 -2
  58. package/dist/prosemirror/commands/index.js +4 -2
  59. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -11
  60. package/dist/prosemirror/commands/tableCellMergeResolution.js +3 -154
  61. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +6 -8
  62. package/dist/prosemirror/hyperlinkRemoval.d.ts +11 -8
  63. package/dist/prosemirror/hyperlinkRemoval.js +24 -15
  64. package/dist/prosemirror/paraIds.d.ts +1 -14
  65. package/dist/prosemirror/paraIds.js +1 -14
  66. package/dist/prosemirror/paragraphMarkJoin.d.ts +0 -16
  67. package/dist/prosemirror/paragraphMarkJoin.js +3 -46
  68. package/dist/prosemirror/projectionReview.d.ts +49 -0
  69. package/dist/prosemirror/projectionReview.js +292 -0
  70. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -13
  71. package/dist/prosemirror/rebaseParagraphRunFormatting.js +1 -16
  72. package/dist/prosemirror/replacedAnnotations.d.ts +2 -5
  73. package/dist/prosemirror/replacedAnnotations.js +1 -10
  74. package/dist/prosemirror/revisionCarriers.d.ts +9 -1
  75. package/dist/prosemirror/revisionCarriers.js +15 -1
  76. package/dist/prosemirror/revisionRangeQueries.d.ts +32 -0
  77. package/dist/prosemirror/revisionRangeQueries.js +76 -0
  78. package/dist/prosemirror/runFormattingMarkNames.d.ts +1 -1
  79. package/dist/prosemirror/runFormattingMarkNames.js +1 -1
  80. package/dist/prosemirror/suggestionQueries.d.ts +114 -0
  81. package/dist/prosemirror/suggestionQueries.js +320 -0
  82. package/dist/prosemirror/tableGridMutation.d.ts +1 -16
  83. package/dist/prosemirror/tableGridMutation.js +1 -78
  84. package/dist/prosemirror/tableRowRevisionOwnership.d.ts +18 -0
  85. package/dist/prosemirror/tableRowRevisionOwnership.js +7 -0
  86. package/dist/prosemirror/utils/extractTrackedChanges.js +14 -4
  87. package/dist/server.d.ts +2 -2
  88. package/dist/types/canonicalCapabilities.d.ts +1 -25
  89. package/dist/types/canonicalCapabilities.js +1 -23
  90. package/package.json +2 -2
  91. package/dist/internal/headlessRevisionResolutionGuard.d.ts +0 -3
  92. package/dist/internal/headlessRevisionResolutionGuard.js +0 -18
@@ -8,11 +8,13 @@ import { getListInfo, isInList } from "../extensions/features/ListExtension.js";
8
8
  import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "../extensions/marks/HyperlinkExtension.js";
9
9
  import { clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive } from "../extensions/marks/markUtils.js";
10
10
  import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "../extensions/nodes/TableExtension.js";
11
- import { AcceptSuggestionOptions, FolioSuggestion, SuggestionAppliedAs, SuggestionKind, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark } from "./comments.js";
11
+ import { addCommentMark, findNextChange, findPreviousChange, removeCommentMark } from "../projectionReview.js";
12
+ import { findAIEditRevisionRange } from "../revisionRangeQueries.js";
13
+ import { FolioSuggestion, SuggestionAppliedAs, SuggestionKind, findSuggestionRange, getSuggestions } from "../suggestionQueries.js";
12
14
  import { CapturedTextFormatting, PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./formatPainter.js";
13
15
  import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, setUnderlineStyle, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./formatting.js";
14
16
  import { insertPageBreak } from "./pageBreak.js";
15
17
  import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, continueNumbering, decreaseIndent, decreaseListLevel, doubleSpacing, generateTableOfContents, increaseIndent, increaseListLevel, oneAndHalfSpacing, removeList, removeTabStop, restartNumbering, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setNumberingValue, setRtl, setSpaceAfter, setSpaceBefore, singleSpacing, toggleBidi, toggleBulletList, toggleNumberedList } from "./paragraph.js";
16
18
  import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice, pasteWithoutFormatting } from "./pastePlainText.js";
17
19
  import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./table.js";
18
- export { type AcceptSuggestionOptions, type BorderPreset, CLIPBOARD_READ_ERROR_EVENT, type CapturedTextFormatting, type FolioSuggestion, type GenerateTableOfContentsOptions, PAINTABLE_MARK_NAMES, type ResolvedStyleAttrs, type SuggestionAppliedAs, type SuggestionKind, type TableBorderPreset, type TableContextInfo, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addColumnLeft, addColumnRight, addCommentMark, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, buildPlainTextSlice, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, continueNumbering, createRemoveMarkCommand, createSetMarkCommand, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, doubleSpacing, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, generateTableOfContents, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getStyleId, getSuggestions, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertPageBreak, insertTable, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, oneAndHalfSpacing, pasteWithoutFormatting, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark, removeHyperlink, removeList, removeTabStop, removeTableBorders, restartNumbering, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setSpaceAfter, setSpaceBefore, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, setUnderlineStyle, singleSpacing, splitCell, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline };
20
+ export { type BorderPreset, CLIPBOARD_READ_ERROR_EVENT, type CapturedTextFormatting, type FolioSuggestion, type GenerateTableOfContentsOptions, PAINTABLE_MARK_NAMES, type ResolvedStyleAttrs, type SuggestionAppliedAs, type SuggestionKind, type TableBorderPreset, type TableContextInfo, addColumnLeft, addColumnRight, addCommentMark, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, buildPlainTextSlice, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, continueNumbering, createRemoveMarkCommand, createSetMarkCommand, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, doubleSpacing, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, generateTableOfContents, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getStyleId, getSuggestions, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertPageBreak, insertTable, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, oneAndHalfSpacing, pasteWithoutFormatting, removeCommentMark, removeHyperlink, removeList, removeTabStop, removeTableBorders, restartNumbering, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setSpaceAfter, setSpaceBefore, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, setUnderlineStyle, singleSpacing, splitCell, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline };
@@ -3,11 +3,13 @@ import { getListInfo, isInList } from "../extensions/features/ListExtension.js";
3
3
  import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "../extensions/marks/HyperlinkExtension.js";
4
4
  import { clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive } from "../extensions/marks/markUtils.js";
5
5
  import { getTableContext, isInTable as isInTableCell } from "../extensions/nodes/TableExtension.js";
6
- import { acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark } from "./comments.js";
6
+ import { addCommentMark, findNextChange, findPreviousChange, removeCommentMark } from "../projectionReview.js";
7
+ import { findAIEditRevisionRange } from "../revisionRangeQueries.js";
8
+ import { findSuggestionRange, getSuggestions } from "../suggestionQueries.js";
7
9
  import { PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./formatPainter.js";
8
10
  import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, setUnderlineStyle, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./formatting.js";
9
11
  import { insertPageBreak } from "./pageBreak.js";
10
12
  import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, continueNumbering, decreaseIndent, decreaseListLevel, doubleSpacing, generateTableOfContents, increaseIndent, increaseListLevel, oneAndHalfSpacing, removeList, removeTabStop, restartNumbering, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setNumberingValue, setRtl, setSpaceAfter, setSpaceBefore, singleSpacing, toggleBidi, toggleBulletList, toggleNumberedList } from "./paragraph.js";
11
13
  import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice, pasteWithoutFormatting } from "./pastePlainText.js";
12
14
  import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./table.js";
13
- export { CLIPBOARD_READ_ERROR_EVENT, PAINTABLE_MARK_NAMES, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addColumnLeft, addColumnRight, addCommentMark, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, buildPlainTextSlice, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, continueNumbering, createRemoveMarkCommand, createSetMarkCommand, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, doubleSpacing, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, generateTableOfContents, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getStyleId, getSuggestions, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertPageBreak, insertTable, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, oneAndHalfSpacing, pasteWithoutFormatting, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark, removeHyperlink, removeList, removeTabStop, removeTableBorders, restartNumbering, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setSpaceAfter, setSpaceBefore, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, setUnderlineStyle, singleSpacing, splitCell, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline };
15
+ export { CLIPBOARD_READ_ERROR_EVENT, PAINTABLE_MARK_NAMES, addColumnLeft, addColumnRight, addCommentMark, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, buildPlainTextSlice, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, continueNumbering, createRemoveMarkCommand, createSetMarkCommand, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, doubleSpacing, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, generateTableOfContents, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getStyleId, getSuggestions, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertPageBreak, insertTable, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, oneAndHalfSpacing, pasteWithoutFormatting, removeCommentMark, removeHyperlink, removeList, removeTabStop, removeTableBorders, restartNumbering, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setSpaceAfter, setSpaceBefore, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, setUnderlineStyle, singleSpacing, splitCell, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline };
@@ -1,18 +1,8 @@
1
1
  import { DecodedTableCellParagraphSourcePayload } from "../../docx/paragraphPropertySource.js";
2
2
  import { document_d_exports } from "../../types/document.js";
3
- import { Transaction } from "prosemirror-state";
4
3
  import { Node } from "prosemirror-model";
5
4
  export declare const tableCellContinuationPayload: (node: Node) => DecodedTableCellParagraphSourcePayload | null;
6
5
  export declare const hasMatchingCollapsedTableCellMerge: (node: Node, revisionSet: Set<number> | null) => boolean;
7
- type ResolveVisibleTableCellMergeOptions = {
8
- tr: Transaction;
9
- cellPos: number;
10
- mode: "accept" | "reject";
11
- revisionSet: ReadonlySet<number> | null;
12
- };
13
- export declare const resolveVisibleTableCellMerge: ({ tr, cellPos, mode, revisionSet }: ResolveVisibleTableCellMergeOptions) => boolean;
14
6
  export declare const tableCellContinuationCells: (cell: Node, rowspan: number) => document_d_exports.TableCell[];
15
7
  export declare const tableCellContinuationFromNode: (cell: Node) => document_d_exports.TableCell;
16
- export declare const resolveCollapsedTableCellMerge: (tr: Transaction, cellPos: number, mode: "accept" | "reject", revisionSet: Set<number> | null) => boolean;
17
- export declare const createRestoredTableCell: (origin: Node, source: document_d_exports.TableCell) => Node | null;
18
- export {};
8
+ export declare const createRestoredTableCell: (origin: Node, source: document_d_exports.TableCell) => Node | null;
@@ -1,12 +1,8 @@
1
- import { decodeTableCellParagraphSourcePayload, restoreTableCellsWithParagraphPropertySources, transportTableCellsWithParagraphPropertySources } from "../../docx/paragraphPropertySource.js";
2
- import { isTableCellMergeRevisionContinuation } from "../../docx/tableParser.js";
1
+ import { decodeTableCellParagraphSourcePayload } from "../../docx/paragraphPropertySource.js";
3
2
  import { standaloneTableCellFromProseMirror } from "../conversion/fromProseDoc.js";
4
3
  import { standaloneTableCellToProseMirror } from "../conversion/toProseDoc.js";
5
4
  import { getTableCellMergeChange } from "../tableCellMergeRevision.js";
6
- import { removeRowsWithoutCellsInRange } from "../tableGridMutation.js";
7
- import { resolvedTableMergeOriginAttrs, resolvedVisibleTableCellMergeAttrs, tableMergeFoldDecisions } from "./tableMergeFoldDecisions.js";
8
- import { Result, panic } from "better-result";
9
- import { TableMap } from "prosemirror-tables";
5
+ import { Result } from "better-result";
10
6
  // src/prosemirror/commands/tableCellMergeResolution.ts
11
7
  const tableCellContinuationPayload = (node) => {
12
8
  const value = node.attrs["_docxVMergeContinuationCells"];
@@ -19,91 +15,6 @@ const hasMatchingCollapsedTableCellMerge = (node, revisionSet) => {
19
15
  return change !== null && (revisionSet === null || revisionSet.has(change.info.id));
20
16
  });
21
17
  };
22
- const isTableCellMergeRevisionAttr = (value) => {
23
- if (typeof value !== "object" || value === null || !("kind" in value) || value.kind !== "merge" || !("info" in value)) return false;
24
- const info = value.info;
25
- return typeof info === "object" && info !== null && "revisionId" in info && typeof info.revisionId === "number";
26
- };
27
- const tableCellContext = (doc, cellPos) => {
28
- const resolved = doc.resolve(cellPos);
29
- for (let depth = resolved.depth; depth > 0; depth -= 1) {
30
- const node = resolved.node(depth);
31
- if (node.type.spec["tableRole"] !== "table") continue;
32
- const tablePos = resolved.before(depth);
33
- return {
34
- table: node,
35
- tableStart: tablePos + 1,
36
- relativeCellPos: cellPos - tablePos - 1
37
- };
38
- }
39
- return null;
40
- };
41
- const resolveVisibleTableCellMerge = ({ tr, cellPos, mode, revisionSet }) => {
42
- const cell = tr.doc.nodeAt(cellPos);
43
- const marker = cell?.attrs["cellMarker"];
44
- if (!cell || !isTableCellMergeRevisionAttr(marker)) return false;
45
- const context = tableCellContext(tr.doc, cellPos);
46
- if (!context) return false;
47
- const rectangle = TableMap.get(context.table).findCell(context.relativeCellPos);
48
- if (mode === "reject" && isTableCellMergeRevisionContinuation(marker.verticalMergeOriginal) && rectangle.top === 0) return false;
49
- const decisions = tableMergeFoldDecisions({
50
- table: context.table,
51
- mode,
52
- revisionSet
53
- });
54
- if (decisions.invalid.has(context.relativeCellPos)) return false;
55
- const folds = decisions.folds.get(context.relativeCellPos);
56
- if (folds === void 0) return panic("Merge resolution lost its cell");
57
- for (const origin of decisions.origins) {
58
- if (origin === context.relativeCellPos) continue;
59
- const originPos = context.tableStart + origin;
60
- const originCell = tr.doc.nodeAt(originPos);
61
- if (!originCell) return panic("Merge resolution lost its origin");
62
- tr.setNodeMarkup(originPos, void 0, resolvedTableMergeOriginAttrs(originCell));
63
- }
64
- if (folds) return mergeTableCellWithCellAbove(tr, cellPos);
65
- tr.setNodeMarkup(cellPos, void 0, resolvedVisibleTableCellMergeAttrs({
66
- cell,
67
- mode,
68
- origin: decisions.origins.has(context.relativeCellPos)
69
- }));
70
- return true;
71
- };
72
- const mergeTableCellWithCellAbove = (tr, cellPos) => {
73
- const context = tableCellContext(tr.doc, cellPos);
74
- const cell = tr.doc.nodeAt(cellPos);
75
- if (!context || !cell) return false;
76
- const map = TableMap.get(context.table);
77
- const rectangle = map.findCell(context.relativeCellPos);
78
- if (rectangle.top === 0) return false;
79
- const aboveRelativePos = map.map[(rectangle.top - 1) * map.width + rectangle.left];
80
- if (aboveRelativePos === void 0 || aboveRelativePos === context.relativeCellPos) return false;
81
- const aboveRectangle = map.findCell(aboveRelativePos);
82
- if (aboveRectangle.left !== rectangle.left || aboveRectangle.right !== rectangle.right || aboveRectangle.bottom !== rectangle.top) return false;
83
- const abovePos = context.tableStart + aboveRelativePos;
84
- const aboveCell = tr.doc.nodeAt(abovePos);
85
- const aboveRowspan = aboveCell?.attrs["rowspan"];
86
- const cellRowspan = cell.attrs["rowspan"];
87
- if (!aboveCell || typeof aboveRowspan !== "number" || typeof cellRowspan !== "number" || aboveRowspan < 1 || cellRowspan < 1) return false;
88
- removeRowsWithoutCellsInRange({
89
- tr,
90
- from: cellPos + 1,
91
- to: cellPos + cell.nodeSize - 1
92
- });
93
- const capturedCell = tr.doc.nodeAt(cellPos);
94
- if (!capturedCell) panic("Nested table cleanup removed its owning cell");
95
- const continuationCells = tableCellContinuationCells(aboveCell, aboveRowspan);
96
- continuationCells.push(tableCellContinuationFromNode(capturedCell));
97
- const nestedPayload = tableCellContinuationPayload(capturedCell);
98
- if (nestedPayload) continuationCells.push(...nestedPayload.cells);
99
- tr.delete(cellPos, cellPos + capturedCell.nodeSize);
100
- tr.setNodeMarkup(abovePos, void 0, {
101
- ...aboveCell.attrs,
102
- rowspan: aboveRowspan + cellRowspan,
103
- _docxVMergeContinuationCells: transportTableCellsWithParagraphPropertySources(continuationCells)
104
- });
105
- return true;
106
- };
107
18
  const tableCellContinuationCells = (cell, rowspan) => {
108
19
  const payload = tableCellContinuationPayload(cell);
109
20
  const cells = payload ? [...payload.cells] : [];
@@ -130,68 +41,6 @@ const emptyVerticalMergeContinuation = () => ({
130
41
  content: []
131
42
  }]
132
43
  });
133
- const resolveCollapsedTableCellMerge = (tr, cellPos, mode, revisionSet) => {
134
- const cell = tr.doc.nodeAt(cellPos);
135
- if (!cell) return false;
136
- const payload = tableCellContinuationPayload(cell);
137
- if (!payload) return false;
138
- const stored = payload.cells;
139
- const matchingIndices = [];
140
- const nextCells = stored.map((continuationCell, index) => {
141
- const change = getTableCellMergeChange(continuationCell);
142
- if (!change || revisionSet !== null && !revisionSet.has(change.info.id)) return continuationCell;
143
- matchingIndices.push(index);
144
- const nextCell = { ...continuationCell };
145
- delete nextCell.structuralChange;
146
- return nextCell;
147
- });
148
- if (matchingIndices.length === 0) return false;
149
- if (mode === "accept") {
150
- tr.setNodeAttribute(cellPos, "_docxVMergeContinuationCells", nextCells);
151
- return true;
152
- }
153
- const splitIndices = matchingIndices.filter((index) => {
154
- const change = getTableCellMergeChange(stored[index]);
155
- return change?.verticalMerge === "continue" && (change.verticalMergeOriginal ?? "rest") === "rest";
156
- });
157
- if (splitIndices.length === 0) {
158
- tr.setNodeAttribute(cellPos, "_docxVMergeContinuationCells", nextCells);
159
- return true;
160
- }
161
- const firstSplitIndex = splitIndices.at(0);
162
- if (firstSplitIndex === void 0 || splitIndices.length !== stored.length - firstSplitIndex || splitIndices.some((index, offset) => index !== firstSplitIndex + offset)) return false;
163
- const context = tableCellContext(tr.doc, cellPos);
164
- if (!context) return false;
165
- const map = TableMap.get(context.table);
166
- const rectangle = map.findCell(context.relativeCellPos);
167
- const rowspan = cell.attrs["rowspan"];
168
- if (typeof rowspan !== "number" || rowspan !== stored.length + 1 || rectangle.bottom - rectangle.top !== rowspan) return false;
169
- const restorations = [];
170
- const restoredCells = restoreTableCellsWithParagraphPropertySources(payload);
171
- for (const index of splitIndices) {
172
- const source = restoredCells[index];
173
- if (!source) return false;
174
- const restoredCell = createRestoredTableCell(cell, source);
175
- if (!restoredCell) return false;
176
- restorations.push({
177
- index,
178
- cell: restoredCell
179
- });
180
- }
181
- const mapFrom = tr.mapping.maps.length;
182
- for (const restoration of restorations) {
183
- const row = rectangle.top + restoration.index + 1;
184
- const insertionPos = context.tableStart + map.positionAt(row, rectangle.left, context.table);
185
- tr.insert(tr.mapping.slice(mapFrom).map(insertionPos, 1), restoration.cell);
186
- }
187
- const remainingCells = nextCells.slice(0, firstSplitIndex);
188
- tr.setNodeMarkup(cellPos, void 0, {
189
- ...cell.attrs,
190
- rowspan: firstSplitIndex + 1,
191
- _docxVMergeContinuationCells: remainingCells.length > 0 ? remainingCells : null
192
- });
193
- return true;
194
- };
195
44
  const createRestoredTableCell = (origin, source) => {
196
45
  const formatting = source.formatting ? { ...source.formatting } : void 0;
197
46
  if (formatting) delete formatting.vMerge;
@@ -204,4 +53,4 @@ const createRestoredTableCell = (origin, source) => {
204
53
  const restored = standaloneTableCellToProseMirror(restoredSource, origin.type.name === "tableHeader" ? "tableHeader" : "tableCell");
205
54
  return Result.try(() => origin.type.schema.nodeFromJSON(restored.toJSON())).unwrapOr(null);
206
55
  };
207
- export { createRestoredTableCell, hasMatchingCollapsedTableCellMerge, resolveCollapsedTableCellMerge, resolveVisibleTableCellMerge, tableCellContinuationCells, tableCellContinuationFromNode, tableCellContinuationPayload };
56
+ export { createRestoredTableCell, hasMatchingCollapsedTableCellMerge, tableCellContinuationCells, tableCellContinuationFromNode, tableCellContinuationPayload };
@@ -3,7 +3,7 @@ import { anchorTargetAttrs, normalizeUserUrl, sanitizeExternalUrl } from "../../
3
3
  import { expectHyperlinkMarkAttrs } from "../../attrs/index.js";
4
4
  import { withCanonicalCommand } from "../../canonicalCommands.js";
5
5
  import { canonicalSelectionRange } from "../../canonicalSelectionRange.js";
6
- import { assertHyperlinkRemovalRange, removeHyperlinkInRange } from "../../hyperlinkRemoval.js";
6
+ import { removeHyperlinkInRange, widenHyperlinkRemovalRange } from "../../hyperlinkRemoval.js";
7
7
  import { getDocumentBuiltInStyles } from "../../plugins/documentStyleState.js";
8
8
  import { createMarkExtension } from "../create.js";
9
9
  import { isMarkActive } from "./markUtils.js";
@@ -158,18 +158,16 @@ const HyperlinkExtension = createMarkExtension({
158
158
  }]);
159
159
  const removalRange = (state) => {
160
160
  if (state.selection instanceof CellSelection) return void 0;
161
- const { empty, $from } = state.selection;
162
- const { from, to } = canonicalSelectionRange(state);
163
- assertHyperlinkRemovalRange({
161
+ const { from, to } = widenHyperlinkRemovalRange({
164
162
  doc: state.doc,
165
- from,
166
- to
163
+ ...canonicalSelectionRange(state)
167
164
  });
168
- if (!empty) return {
165
+ if (!state.selection.empty) return {
169
166
  from,
170
167
  to
171
168
  };
172
- const linkMark = $from.marks().find((mark) => mark.type === documentHyperlinkType(state));
169
+ const $from = state.doc.resolve(from);
170
+ const linkMark = (from === to ? $from.marks() : state.doc.nodeAt(from)?.marks ?? []).find((mark) => mark.type === documentHyperlinkType(state));
173
171
  if (!linkMark) return void 0;
174
172
  let contiguous;
175
173
  let selected;
@@ -10,23 +10,26 @@
10
10
  * text never did. Rejecting brings the link back as it was; accepting leaves
11
11
  * the plain text an untracked removal leaves.
12
12
  */
13
- import { TaggedErrorClass } from "better-result";
14
13
  import { EditorState, Transaction } from "prosemirror-state";
15
14
  import { Node } from "prosemirror-model";
16
- declare const HyperlinkRemovalRefusalBase: TaggedErrorClass<"HyperlinkRemovalRefusal">;
17
- export declare class HyperlinkRemovalRefusal extends HyperlinkRemovalRefusalBase<{
18
- message: string;
19
- }> {}
20
15
  type HyperlinkRemovalRangeOptions = {
21
16
  doc: Node;
22
17
  from: number;
23
18
  to: number;
24
19
  };
25
- /** Canonical inline elements have no addressable interior gaps. */
26
- export declare const assertHyperlinkRemovalRange: ({ doc, from, to }: HyperlinkRemovalRangeOptions) => void;
20
+ /**
21
+ * The removal range widened to the edges of every linked inline element an
22
+ * endpoint falls inside. Such an element, a field result a link holds whole
23
+ * (a contents entry's page number), carries the link as one mark: the link
24
+ * leaves all of it or none of it, as Remove Hyperlink takes the whole link.
25
+ */
26
+ export declare const widenHyperlinkRemovalRange: ({ doc, from, to }: HyperlinkRemovalRangeOptions) => {
27
+ from: number;
28
+ to: number;
29
+ };
27
30
  /**
28
31
  * Remove the hyperlinks from [`from`, `to`) of `tr.doc`: directly, or, with
29
32
  * suggestions on, as a tracked replacement of the linked text by plain text.
30
33
  */
31
- export declare const removeHyperlinkInRange: (state: EditorState, tr: Transaction, from: number, to: number) => Transaction;
34
+ export declare const removeHyperlinkInRange: (state: EditorState, tr: Transaction, requestedFrom: number, requestedTo: number) => Transaction;
32
35
  export {};
@@ -3,7 +3,7 @@ import { getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/do
3
3
  import { readAuthoredRunFormatting, reconcileRunFormattingMarks } from "./runFormattingReconciliation.js";
4
4
  import { paragraphRunStyleContextAt } from "./runStyleFormatting.js";
5
5
  import { isSuggestionModeActive, makeRevisionInfo, suggestRangeDeletion } from "./suggestionCommands.js";
6
- import { TaggedError } from "better-result";
6
+ import { panic } from "better-result";
7
7
  // src/prosemirror/hyperlinkRemoval.ts
8
8
  /**
9
9
  * Removing a hyperlink takes the link and its Hyperlink character style off
@@ -17,18 +17,27 @@ import { TaggedError } from "better-result";
17
17
  * text never did. Rejecting brings the link back as it was; accepting leaves
18
18
  * the plain text an untracked removal leaves.
19
19
  */
20
- const HyperlinkRemovalRefusalBase = TaggedError("HyperlinkRemovalRefusal");
21
- var HyperlinkRemovalRefusal = class extends HyperlinkRemovalRefusalBase {};
22
- const partialInlineRefusal = () => new HyperlinkRemovalRefusal({ message: "Hyperlink removal cannot split an indivisible inline element." });
23
- /** Canonical inline elements have no addressable interior gaps. */
24
- const assertHyperlinkRemovalRange = ({ doc, from, to }) => {
25
- for (const position of [from, to]) {
20
+ /**
21
+ * The removal range widened to the edges of every linked inline element an
22
+ * endpoint falls inside. Such an element, a field result a link holds whole
23
+ * (a contents entry's page number), carries the link as one mark: the link
24
+ * leaves all of it or none of it, as Remove Hyperlink takes the whole link.
25
+ */
26
+ const widenHyperlinkRemovalRange = ({ doc, from, to }) => {
27
+ const outermostLinked = (position) => {
26
28
  const resolved = doc.resolve(position);
27
29
  for (let depth = 1; depth <= resolved.depth; depth += 1) {
28
30
  const node = resolved.node(depth);
29
- if (node.isInline && node.marks.some(({ type }) => type.name === "hyperlink")) throw partialInlineRefusal();
31
+ if (node.isInline && node.marks.some(({ type }) => type.name === "hyperlink")) return {
32
+ from: resolved.before(depth),
33
+ to: resolved.after(depth)
34
+ };
30
35
  }
31
- }
36
+ };
37
+ return {
38
+ from: outermostLinked(from)?.from ?? from,
39
+ to: outermostLinked(to)?.to ?? to
40
+ };
32
41
  };
33
42
  /** Contiguous stretches of linked, not yet deleted, inline content in [`from`, `to`) of `doc`. */
34
43
  const linkedRanges = (doc, from, to) => {
@@ -38,7 +47,7 @@ const linkedRanges = (doc, from, to) => {
38
47
  const start = Math.max(position, from);
39
48
  const end = Math.min(position + node.nodeSize, to);
40
49
  if (start >= end) return true;
41
- if (!node.isText && (start !== position || end !== position + node.nodeSize)) throw partialInlineRefusal();
50
+ if (!node.isText && (start !== position || end !== position + node.nodeSize)) panic("A widened removal range cut a linked inline element.");
42
51
  const piece = {
43
52
  from: start,
44
53
  to: end,
@@ -96,11 +105,11 @@ const setInlineMarks = (tr, from, to, current, marks) => {
96
105
  * Remove the hyperlinks from [`from`, `to`) of `tr.doc`: directly, or, with
97
106
  * suggestions on, as a tracked replacement of the linked text by plain text.
98
107
  */
99
- const removeHyperlinkInRange = (state, tr, from, to) => {
100
- assertHyperlinkRemovalRange({
108
+ const removeHyperlinkInRange = (state, tr, requestedFrom, requestedTo) => {
109
+ const { from, to } = widenHyperlinkRemovalRange({
101
110
  doc: tr.doc,
102
- from,
103
- to
111
+ from: requestedFrom,
112
+ to: requestedTo
104
113
  });
105
114
  const { schema } = state;
106
115
  const hyperlinkType = schema.marks["hyperlink"];
@@ -162,4 +171,4 @@ const removeHyperlinkInRange = (state, tr, from, to) => {
162
171
  }
163
172
  return tr;
164
173
  };
165
- export { HyperlinkRemovalRefusal, assertHyperlinkRemovalRange, removeHyperlinkInRange };
174
+ export { removeHyperlinkInRange, widenHyperlinkRemovalRange };
@@ -6,7 +6,7 @@
6
6
  * https://github.com/eigenpal/docx-editor/blob/main/packages/core/src/prosemirror/extensions/features/ParaIdAllocatorExtension.ts
7
7
  * (Apache-2.0); see that module for the id lifecycle rules.
8
8
  */
9
- import { EditorState, Plugin, PluginKey, Transaction } from "prosemirror-state";
9
+ import { EditorState, Plugin, PluginKey } from "prosemirror-state";
10
10
  import { Node } from "prosemirror-model";
11
11
  export type ParagraphPropertySourceSeed = {
12
12
  contract: string | null;
@@ -19,19 +19,6 @@ export declare const paraIdAllocatorKey: Readonly<{
19
19
  get: (state: EditorState) => Plugin<ParagraphPropertySourceSeed> | undefined;
20
20
  getState: (state: EditorState) => ParagraphPropertySourceSeed | undefined;
21
21
  }>;
22
- /**
23
- * Transaction meta asking this plugin to derive the ids it mints from a
24
- * caller-supplied seed instead of `Math.random()`.
25
- *
26
- * A live editor wants random ids: two people typing must not collide. A
27
- * generator whose whole output has to be reproducible — the document compare —
28
- * cannot afford them, and it is the only party that knows its run is meant to
29
- * be deterministic, so it says so on its own transaction rather than leaving
30
- * the plugin to guess.
31
- */
32
- export declare const deterministicParaIdSeedKey = "stll.folio.meta.deterministicParaIdSeed";
33
- /** Ask the allocator to mint reproducible ids for the paragraphs `tr` creates. */
34
- export declare const requestDeterministicParaIds: (tr: Transaction, seed: string) => Transaction;
35
22
  export declare const isUsableParaId: (value: unknown) => value is string;
36
23
  export declare const visitAuthoredParagraphs: (doc: Node, visit: (node: Node, pos: number) => void) => void;
37
24
  /**
@@ -14,19 +14,6 @@ import { Fragment } from "prosemirror-model";
14
14
  * (Apache-2.0); see that module for the id lifecycle rules.
15
15
  */
16
16
  const paraIdAllocatorKey = createPluginKeyOwner("paraIdAllocator");
17
- /**
18
- * Transaction meta asking this plugin to derive the ids it mints from a
19
- * caller-supplied seed instead of `Math.random()`.
20
- *
21
- * A live editor wants random ids: two people typing must not collide. A
22
- * generator whose whole output has to be reproducible — the document compare —
23
- * cannot afford them, and it is the only party that knows its run is meant to
24
- * be deterministic, so it says so on its own transaction rather than leaving
25
- * the plugin to guess.
26
- */
27
- const deterministicParaIdSeedKey = "stll.folio.meta.deterministicParaIdSeed";
28
- /** Ask the allocator to mint reproducible ids for the paragraphs `tr` creates. */
29
- const requestDeterministicParaIds = (tr, seed) => tr.setMeta(deterministicParaIdSeedKey, seed);
30
17
  const isUsableParaId = (value) => typeof value === "string" && value.length > 0 && value !== "00000000";
31
18
  /** Omitted grid cells render absent positions and own no package paragraphs. */
32
19
  const isOmittedGridCell = (node) => (node.type.spec["tableRole"] === "cell" || node.type.spec["tableRole"] === "header_cell") && (node.attrs["_omittedGridSlot"] === "before" || node.attrs["_omittedGridSlot"] === "after");
@@ -149,4 +136,4 @@ const ensureParaIdsInState = (state) => {
149
136
  tr.setMeta("addToHistory", false);
150
137
  return state.apply(tr);
151
138
  };
152
- export { deterministicParaIdSeedKey, ensureParaIdsInDoc, ensureParaIdsInState, isUsableParaId, paraIdAllocatorKey, requestDeterministicParaIds, visitAuthoredParagraphs };
139
+ export { ensureParaIdsInDoc, ensureParaIdsInState, isUsableParaId, paraIdAllocatorKey, visitAuthoredParagraphs };
@@ -14,7 +14,6 @@
14
14
  * lent them is re-read in the next paragraph's style.
15
15
  */
16
16
  import { RunStyleResolver } from "./runStyleFormatting.js";
17
- import { Transaction } from "prosemirror-state";
18
17
  import { Node } from "prosemirror-model";
19
18
  /** The two paragraphs a join runs together, and what stands between them. */
20
19
  type JoinSides = {
@@ -37,19 +36,4 @@ type JoinedParagraphAttrsOptions = Omit<JoinSides, "between"> & {
37
36
  * between the two paragraphs' content.
38
37
  */
39
38
  export declare const joinedParagraphAttrs: ({ paragraph, next, between, styleResolver }: JoinedParagraphAttrsOptions) => Node["attrs"];
40
- type JoinAtParagraphMarkOptions = {
41
- tr: Transaction;
42
- /** Position of the paragraph whose mark goes. */
43
- paragraphPos: number;
44
- paragraph: Node;
45
- /** The paragraph directly after it, which the join runs into. */
46
- next: Node;
47
- /**
48
- * Re-reads the moved runs' inherited formatting in the next paragraph's
49
- * style. Without one, the editor's join restyler does it when the
50
- * transaction is dispatched.
51
- */
52
- styleResolver: RunStyleResolver | null;
53
- };
54
- export declare const joinAtParagraphMark: ({ tr, paragraphPos, paragraph, next, styleResolver }: JoinAtParagraphMarkOptions) => void;
55
39
  export {};
@@ -1,9 +1,6 @@
1
- import { PARAGRAPH_SOURCE_JOIN_RULES, getProseParagraphPropertySourceToken, joinProseParagraphsWithRightPropertySource, markParagraphPropertySourceTransfers } from "../docx/paragraphPropertySource.js";
1
+ import { PARAGRAPH_SOURCE_JOIN_RULES } from "../docx/paragraphPropertySource.js";
2
2
  import { expectParagraphAttrs } from "./attrs/index.js";
3
- import { paragraphJoinAfter } from "./commands/paragraphBookmarkJoin.js";
4
- import { JOINED_RUNS_RESTYLED_META } from "./extensions/features/JoinedRunStyleExtension.js";
5
- import { rebaseParagraphRuns } from "./rebaseParagraphRunFormatting.js";
6
- import { paragraphRunStyleContext, resolveParagraphInheritedRunFormatting } from "./runStyleFormatting.js";
3
+ import { resolveParagraphInheritedRunFormatting } from "./runStyleFormatting.js";
7
4
  import { panic } from "better-result";
8
5
  // src/prosemirror/paragraphMarkJoin.ts
9
6
  /**
@@ -185,44 +182,4 @@ const joinedParagraphAttrs = ({ paragraph, next, between = 0, styleResolver }) =
185
182
  }
186
183
  return changed ? attrs : next.attrs;
187
184
  };
188
- const joinAtParagraphMark = ({ tr, paragraphPos, paragraph, next, styleResolver }) => {
189
- const boundary = paragraphPos + paragraph.nodeSize;
190
- const join = paragraphJoinAfter(tr.doc, boundary);
191
- if (!join || join.next !== next) panic("A paragraph-mark join lost its next paragraph");
192
- if (join.inlineBookmarks.length > 0) {
193
- const leftToken = getProseParagraphPropertySourceToken(paragraph);
194
- const rightToken = getProseParagraphPropertySourceToken(next);
195
- tr.replaceWith(boundary - 1, join.nextPosition + 1, join.inlineBookmarks);
196
- tr.setNodeMarkup(paragraphPos, void 0, joinedParagraphAttrs({
197
- paragraph,
198
- next,
199
- between: join.inlineBookmarks.reduce((size, node) => size + node.nodeSize, 0),
200
- styleResolver
201
- }));
202
- markParagraphPropertySourceTransfers(tr, [{
203
- displacedToken: typeof leftToken === "string" ? leftToken : null,
204
- selectedToken: typeof rightToken === "string" ? rightToken : null
205
- }]);
206
- } else joinProseParagraphsWithRightPropertySource({
207
- attrs: joinedParagraphAttrs({
208
- paragraph,
209
- next,
210
- styleResolver
211
- }),
212
- pos: boundary,
213
- transaction: tr
214
- });
215
- if (!styleResolver) return;
216
- if (paragraph.content.size > 0) rebaseParagraphRuns({
217
- previousContext: paragraphRunStyleContext(paragraph, styleResolver),
218
- paragraphPosition: paragraphPos,
219
- range: {
220
- from: 0,
221
- to: paragraph.content.size
222
- },
223
- styleResolver,
224
- tr
225
- });
226
- tr.setMeta(JOINED_RUNS_RESTYLED_META, true);
227
- };
228
- export { JOINED_PARAGRAPH_ATTR_NAMES, joinAtParagraphMark, joinedParagraphAttrs };
185
+ export { JOINED_PARAGRAPH_ATTR_NAMES, joinedParagraphAttrs };
@@ -0,0 +1,49 @@
1
+ import { TrackedChangeEntry } from "./utils/extractTrackedChanges.js";
2
+ import { Command, EditorState } from "prosemirror-state";
3
+ /**
4
+ * Add a comment mark to the current selection.
5
+ */
6
+ export declare function addCommentMark(commentId: number): Command;
7
+ /**
8
+ * Remove a comment mark by ID from the entire document.
9
+ */
10
+ export declare function removeCommentMark(commentId: number): Command;
11
+ export type ParagraphBoundaryChange = {
12
+ from: number;
13
+ to: number;
14
+ type: "insertion" | "deletion";
15
+ author?: string;
16
+ date?: string;
17
+ revisionId?: number;
18
+ };
19
+ export declare function findParagraphBoundaryChangeAtPosition(state: EditorState, pos: number): ParagraphBoundaryChange | null;
20
+ /** Every revision id one sidebar entry stands for. */
21
+ export declare const trackedChangeEntryRevisionIds: (entry: TrackedChangeEntry) => number[];
22
+ type ChangeRange = {
23
+ from: number;
24
+ to: number;
25
+ type: "insertion" | "deletion";
26
+ };
27
+ /**
28
+ * Find the tracked change mark range at a given cursor position.
29
+ * If the cursor is inside a tracked change, returns the full extent
30
+ * of that mark (expanding to cover all adjacent nodes with the same
31
+ * revision ID). If from !== to (range selection), returns {from, to}.
32
+ */
33
+ export declare function findChangeAtPosition(state: EditorState, from: number, to: number): {
34
+ from: number;
35
+ to: number;
36
+ };
37
+ /**
38
+ * Find the next tracked change after the given position. Returns the full
39
+ * range of the change (including adjacent text nodes that share the same
40
+ * insertion/deletion mark instance), not just the first text node.
41
+ */
42
+ export declare function findNextChange(state: EditorState, startPos: number): ChangeRange | null;
43
+ /**
44
+ * Find the previous tracked change before the given position. Returns the
45
+ * full range of the change (including adjacent text nodes that share the
46
+ * same insertion/deletion mark instance), not just the last text node.
47
+ */
48
+ export declare function findPreviousChange(state: EditorState, startPos: number): ChangeRange | null;
49
+ export {};