@stll/folio-core 0.36.0 → 0.37.1

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 (200) hide show
  1. package/README.md +59 -1
  2. package/dist/ai-edits/apply.js +689 -367
  3. package/dist/ai-edits/block-identity.d.ts +4 -1
  4. package/dist/ai-edits/block-identity.js +4 -1
  5. package/dist/ai-edits/blockRange.js +14 -14
  6. package/dist/ai-edits/clean-text.d.ts +40 -1
  7. package/dist/ai-edits/clean-text.js +52 -2
  8. package/dist/ai-edits/headless.d.ts +3 -1
  9. package/dist/ai-edits/headless.js +133 -71
  10. package/dist/ai-edits/index.d.ts +3 -3
  11. package/dist/ai-edits/index.js +2 -2
  12. package/dist/ai-edits/read.js +38 -20
  13. package/dist/ai-edits/snapshot.d.ts +14 -6
  14. package/dist/ai-edits/snapshot.js +99 -19
  15. package/dist/ai-edits/table-cell-mutations.js +1 -1
  16. package/dist/ai-edits/table-row-column-mutations.js +7 -0
  17. package/dist/ai-edits/table-template.d.ts +11 -1
  18. package/dist/ai-edits/table-template.js +49 -17
  19. package/dist/ai-edits/types.d.ts +60 -57
  20. package/dist/ai-suggestions/conflict.js +1 -4
  21. package/dist/ai-suggestions/text-positions.d.ts +8 -0
  22. package/dist/ai-suggestions/text-positions.js +27 -5
  23. package/dist/compare/__fixtures__/body-sequence.js +3 -4
  24. package/dist/compare/column-alignment.d.ts +13 -13
  25. package/dist/compare/column-alignment.js +78 -39
  26. package/dist/compare/compare.d.ts +4 -3
  27. package/dist/compare/compare.js +41 -5
  28. package/dist/compare/content-alignment.d.ts +95 -0
  29. package/dist/compare/content-alignment.js +1450 -0
  30. package/dist/compare/content-types.d.ts +100 -0
  31. package/dist/compare/content-types.js +0 -0
  32. package/dist/compare/content.d.ts +209 -0
  33. package/dist/compare/content.js +885 -0
  34. package/dist/compare/formatting.d.ts +5 -5
  35. package/dist/compare/formatting.js +6 -4
  36. package/dist/compare/plan.d.ts +6 -1
  37. package/dist/compare/plan.js +201 -569
  38. package/dist/compare/scenario.d.ts +2 -2
  39. package/dist/compare/types.d.ts +3 -3
  40. package/dist/compare/verification.d.ts +2 -2
  41. package/dist/compare/verification.js +25 -8
  42. package/dist/compat/eigenpal.d.ts +5 -3
  43. package/dist/compat/eigenpal.js +3 -2
  44. package/dist/controller/headerFooterEditorManager.js +14 -6
  45. package/dist/controller/hiddenEditorManager.d.ts +7 -2
  46. package/dist/controller/hiddenEditorManager.js +15 -6
  47. package/dist/controller/layoutPipeline.js +5 -3
  48. package/dist/controller/noteEditorManager.js +12 -7
  49. package/dist/display-list/build/headerFooterPrimitives.js +1 -0
  50. package/dist/display-list/build/storyPrimitives.d.ts +5 -2
  51. package/dist/display-list/build/storyPrimitives.js +60 -3
  52. package/dist/display-list/build/tablePrimitives.js +30 -0
  53. package/dist/display-list/primitives.d.ts +1 -1
  54. package/dist/document-operations.d.ts +8 -6
  55. package/dist/document-operations.js +121 -26
  56. package/dist/docx/blockContentParser.js +6 -27
  57. package/dist/docx/ensureParaIds.js +9 -4
  58. package/dist/docx/numberingParser.d.ts +3 -1
  59. package/dist/docx/numberingParser.js +4 -1
  60. package/dist/docx/paragraphParser.js +7 -6
  61. package/dist/docx/paragraphTraversal.js +30 -34
  62. package/dist/docx/rezip.d.ts +0 -8
  63. package/dist/docx/rezip.js +41 -16
  64. package/dist/docx/runParser.js +4 -2
  65. package/dist/docx/serializer/paragraphSerializer.js +2 -0
  66. package/dist/docx/serializer/runSerializer.js +5 -3
  67. package/dist/docx/serializer/trackedChangeAttributes.d.ts +3 -1
  68. package/dist/docx/serializer/trackedChangeAttributes.js +11 -1
  69. package/dist/docx/server/build.d.ts +1 -1
  70. package/dist/headless-layout.js +5 -4
  71. package/dist/index.d.ts +5 -3
  72. package/dist/index.js +3 -2
  73. package/dist/internal/headlessRevisionResolution.d.ts +23 -0
  74. package/dist/internal/headlessRevisionResolution.js +176 -0
  75. package/dist/internal/headlessRevisionResolutionGuard.d.ts +12 -0
  76. package/dist/internal/headlessRevisionResolutionGuard.js +28 -0
  77. package/dist/internal/pageBreakRunDescendantIndex.d.ts +9 -0
  78. package/dist/internal/pageBreakRunDescendantIndex.js +27 -0
  79. package/dist/internal/pageBreakRunPartition.d.ts +26 -0
  80. package/dist/internal/pageBreakRunPartition.js +35 -0
  81. package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +15 -0
  82. package/dist/internal/pageBreakRunSourceDescendantIndex.js +126 -0
  83. package/dist/internal/sectionEndpointResolution.d.ts +32 -0
  84. package/dist/internal/sectionEndpointResolution.js +38 -0
  85. package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
  86. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +16 -4
  87. package/dist/layout-bridge/convert/headerFooterLayout.js +48 -5
  88. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +4 -0
  89. package/dist/layout-bridge/convert/toFlowBlocks.js +379 -75
  90. package/dist/layout-bridge/dom/clickToPositionDom.d.ts +8 -1
  91. package/dist/layout-bridge/dom/clickToPositionDom.js +114 -40
  92. package/dist/layout-bridge/dom/textStreamDom.d.ts +24 -0
  93. package/dist/layout-bridge/dom/textStreamDom.js +75 -0
  94. package/dist/layout-bridge/headerFooterLayout.js +16 -30
  95. package/dist/layout-engine/index.js +12 -3
  96. package/dist/layout-engine/measure/tableFragmentBorderGeometry.d.ts +17 -0
  97. package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +24 -0
  98. package/dist/layout-engine/renderedBreakReconciliation.js +1 -1
  99. package/dist/layout-engine/types.d.ts +7 -0
  100. package/dist/layout-painter/imageLayout.d.ts +1 -1
  101. package/dist/layout-painter/renderTable.js +20 -0
  102. package/dist/model.d.ts +1 -1
  103. package/dist/paged-layout/rangeProjection.js +6 -9
  104. package/dist/paged-layout/transactionDirtyRange.d.ts +3 -1
  105. package/dist/paged-layout/transactionDirtyRange.js +23 -1
  106. package/dist/prosemirror/attrs/index.d.ts +7 -3
  107. package/dist/prosemirror/attrs/index.js +113 -7
  108. package/dist/prosemirror/bookmarkBoundaryIntegrity.d.ts +9 -0
  109. package/dist/prosemirror/bookmarkBoundaryIntegrity.js +22 -0
  110. package/dist/prosemirror/commands/comments.d.ts +10 -1
  111. package/dist/prosemirror/commands/comments.js +167 -59
  112. package/dist/prosemirror/commands/formatPainter.d.ts +45 -10
  113. package/dist/prosemirror/commands/formatPainter.js +319 -63
  114. package/dist/prosemirror/commands/index.d.ts +2 -2
  115. package/dist/prosemirror/commands/pageBreak.d.ts +5 -2
  116. package/dist/prosemirror/commands/pageBreak.js +18 -36
  117. package/dist/prosemirror/commands/propertyChangeScope.d.ts +7 -5
  118. package/dist/prosemirror/commands/propertyChangeScope.js +27 -18
  119. package/dist/prosemirror/conversion/fromProseDoc.d.ts +7 -2
  120. package/dist/prosemirror/conversion/fromProseDoc.js +809 -209
  121. package/dist/prosemirror/conversion/runShadingMark.js +2 -2
  122. package/dist/prosemirror/conversion/toProseDoc.d.ts +26 -1
  123. package/dist/prosemirror/conversion/toProseDoc.js +416 -283
  124. package/dist/prosemirror/extensions/StarterKit.js +4 -0
  125. package/dist/prosemirror/extensions/core/ParagraphExtension.js +12 -8
  126. package/dist/prosemirror/extensions/features/ListExtension.js +95 -123
  127. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -1
  128. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +27 -1
  129. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +134 -30
  130. package/dist/prosemirror/extensions/features/pasteCleanup.js +9 -15
  131. package/dist/prosemirror/extensions/marks/BoldExtension.js +4 -3
  132. package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +4 -7
  133. package/dist/prosemirror/extensions/marks/CharacterStyleExtension.js +5 -11
  134. package/dist/prosemirror/extensions/marks/FontSizeExtension.js +3 -3
  135. package/dist/prosemirror/extensions/marks/ItalicExtension.js +4 -3
  136. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +13 -0
  137. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +39 -0
  138. package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +7 -1
  139. package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +67 -21
  140. package/dist/prosemirror/extensions/marks/markUtils.d.ts +8 -1
  141. package/dist/prosemirror/extensions/marks/markUtils.js +88 -2
  142. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +44 -3
  143. package/dist/prosemirror/extensions/nodes/FieldExtension.js +1 -1
  144. package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +15 -4
  145. package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +6 -0
  146. package/dist/prosemirror/extensions/nodes/PageBreakExtension.js +6 -0
  147. package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.d.ts +6 -0
  148. package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.js +36 -0
  149. package/dist/prosemirror/findReplaceSelection.js +8 -3
  150. package/dist/prosemirror/index.d.ts +3 -3
  151. package/dist/prosemirror/listMarker.d.ts +26 -1
  152. package/dist/prosemirror/listMarker.js +108 -14
  153. package/dist/prosemirror/pageBreakRunProjection.d.ts +28 -0
  154. package/dist/prosemirror/pageBreakRunProjection.js +47 -0
  155. package/dist/prosemirror/paraText.js +6 -0
  156. package/dist/prosemirror/paragraphSpacing.d.ts +29 -0
  157. package/dist/prosemirror/paragraphSpacing.js +125 -0
  158. package/dist/prosemirror/plugins/documentNumbering.d.ts +8 -0
  159. package/dist/prosemirror/plugins/documentNumbering.js +18 -0
  160. package/dist/prosemirror/plugins/pmTextScan.d.ts +3 -2
  161. package/dist/prosemirror/plugins/pmTextScan.js +14 -4
  162. package/dist/prosemirror/plugins/suggestionMode.js +8 -10
  163. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +16 -0
  164. package/dist/prosemirror/rebaseParagraphRunFormatting.js +61 -0
  165. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +64 -0
  166. package/dist/prosemirror/runFormattingInlineCarriers.js +121 -0
  167. package/dist/prosemirror/runFormattingProvenance.d.ts +12 -0
  168. package/dist/prosemirror/runFormattingProvenance.js +48 -0
  169. package/dist/prosemirror/runFormattingReconciliation.d.ts +25 -0
  170. package/dist/prosemirror/runFormattingReconciliation.js +54 -0
  171. package/dist/prosemirror/runPropertyChangeResolution.d.ts +18 -0
  172. package/dist/prosemirror/runPropertyChangeResolution.js +18 -0
  173. package/dist/prosemirror/runStyleFormatting.d.ts +50 -0
  174. package/dist/prosemirror/runStyleFormatting.js +105 -0
  175. package/dist/prosemirror/schema/index.d.ts +3 -3
  176. package/dist/prosemirror/schema/marks.d.ts +82 -9
  177. package/dist/prosemirror/schema/marks.js +73 -1
  178. package/dist/prosemirror/schema/nodes.d.ts +18 -5
  179. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +14 -2
  180. package/dist/prosemirror/styles/resolvedStyleAttrs.js +44 -23
  181. package/dist/prosemirror/styles/styleResolver.d.ts +10 -13
  182. package/dist/prosemirror/styles/styleResolver.js +3 -3
  183. package/dist/prosemirror/styles/styleToggleCascade.d.ts +8 -1
  184. package/dist/prosemirror/styles/styleToggleCascade.js +24 -1
  185. package/dist/prosemirror/tableGridMutation.d.ts +20 -0
  186. package/dist/prosemirror/tableGridMutation.js +30 -0
  187. package/dist/prosemirror/trackedRunInlineAtoms.d.ts +31 -0
  188. package/dist/prosemirror/trackedRunInlineAtoms.js +39 -0
  189. package/dist/prosemirror/utils/visualLineNavigation.js +27 -31
  190. package/dist/prosemirror/validation.js +23 -4
  191. package/dist/render-dom/HeaderFooterSelectionOverlay.js +20 -20
  192. package/dist/render-dom/RenderedDomContext.js +17 -34
  193. package/dist/server.d.ts +4 -4
  194. package/dist/server.js +2 -2
  195. package/dist/style-engine/styleEngine.d.ts +1 -1
  196. package/dist/utils/clipboard.js +1 -1
  197. package/dist/utils/findReplace.js +38 -21
  198. package/dist/version-comparison.d.ts +38 -44
  199. package/dist/version-comparison.js +270 -401
  200. package/package.json +3 -2
@@ -1,3 +1,4 @@
1
+ import { mergeDirtyRanges } from "./incrementalMeasure.js";
1
2
  import { AddMarkStep, RemoveMarkStep } from "prosemirror-transform";
2
3
  //#region src/paged-layout/transactionDirtyRange.ts
3
4
  function getTransactionDirtyRange(transaction) {
@@ -9,6 +10,27 @@ function getTransactionDirtyRange(transaction) {
9
10
  if (!Number.isFinite(dirtyRange.from) || !Number.isFinite(dirtyRange.to)) return null;
10
11
  return dirtyRange;
11
12
  }
13
+ /** Collect every transaction in an applied batch in the final document's coordinates. */
14
+ function getTransactionsDirtyRange(transactions) {
15
+ let combinedRange = null;
16
+ for (let index = 0; index < transactions.length; index += 1) {
17
+ const transaction = transactions[index];
18
+ if (!transaction) continue;
19
+ const range = getTransactionDirtyRange(transaction);
20
+ if (!range) continue;
21
+ let from = range.from;
22
+ let to = range.to;
23
+ for (const followingTransaction of transactions.slice(index + 1)) {
24
+ from = followingTransaction.mapping.map(from, -1);
25
+ to = followingTransaction.mapping.map(to, 1);
26
+ }
27
+ combinedRange = mergeDirtyRanges(combinedRange, {
28
+ from,
29
+ to
30
+ });
31
+ }
32
+ return combinedRange;
33
+ }
12
34
  function includeStepDirtyRange(transaction, stepIndex, dirtyRange) {
13
35
  const map = transaction.mapping.maps[stepIndex];
14
36
  if (!map) return;
@@ -24,4 +46,4 @@ function includeStepDirtyRange(transaction, stepIndex, dirtyRange) {
24
46
  if (step instanceof AddMarkStep || step instanceof RemoveMarkStep) extend(step.from, step.to);
25
47
  }
26
48
  //#endregion
27
- export { getTransactionDirtyRange };
49
+ export { getTransactionDirtyRange, getTransactionsDirtyRange };
@@ -1,5 +1,5 @@
1
- import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "../schema/marks.js";
2
- import { BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, MathAttrs, ParagraphAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "../schema/nodes.js";
1
+ import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "../schema/marks.js";
2
+ import { BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "../schema/nodes.js";
3
3
  import "../schema/index.js";
4
4
  import { Mark, Node } from "prosemirror-model";
5
5
  //#region src/prosemirror/attrs/index.d.ts
@@ -18,6 +18,8 @@ declare const readParagraphAttrs: (node: Node) => ReadProseMirrorAttrsResult<Par
18
18
  declare const expectParagraphAttrs: (node: Node) => ParagraphAttrs;
19
19
  declare const readHardBreakAttrs: (node: Node) => ReadProseMirrorAttrsResult<HardBreakAttrs>;
20
20
  declare const expectHardBreakAttrs: (node: Node) => HardBreakAttrs;
21
+ declare const readPageBreakRunAttrs: (node: Node) => ReadProseMirrorAttrsResult<PageBreakRunAttrs>;
22
+ declare const expectPageBreakRunAttrs: (node: Node) => PageBreakRunAttrs;
21
23
  declare const readTabAttrs: (node: Node) => ReadProseMirrorAttrsResult<TabAttrs>;
22
24
  declare const expectTabAttrs: (node: Node) => TabAttrs;
23
25
  declare const readSymbolAttrs: (node: Node) => ReadProseMirrorAttrsResult<SymbolAttrs>;
@@ -74,6 +76,8 @@ declare const readTrackedChangeMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsRe
74
76
  declare const expectTrackedChangeMarkAttrs: (mark: Mark) => TrackedChangeMarkAttrs;
75
77
  declare const readRunPropertyChangeMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<RunPropertyChangeMarkAttrs>;
76
78
  declare const expectRunPropertyChangeMarkAttrs: (mark: Mark) => RunPropertyChangeMarkAttrs;
79
+ declare const readPageBreakRunOwnerMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<PageBreakRunOwnerMarkAttrs>;
80
+ declare const expectPageBreakRunOwnerMarkAttrs: (mark: Mark) => PageBreakRunOwnerMarkAttrs;
77
81
  declare const readRunFormattingOverrideMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<RunFormattingOverrideAttrs>;
78
82
  declare const expectRunFormattingOverrideMarkAttrs: (mark: Mark) => RunFormattingOverrideAttrs;
79
83
  declare const readHyperlinkMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<HyperlinkAttrs>;
@@ -85,4 +89,4 @@ declare const mergeTableAttrs: (node: Node, patch: NodeAttrPatch<TableAttrs>) =>
85
89
  declare const mergeTableRowAttrs: (node: Node, patch: NodeAttrPatch<TableRowAttrs>) => TableRowAttrs;
86
90
  declare const mergeTableCellAttrs: (node: Node, patch: NodeAttrPatch<TableCellAttrs>) => TableCellAttrs;
87
91
  //#endregion
88
- export { ProseMirrorAttrIssue, ReadProseMirrorAttrsResult, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
92
+ export { ProseMirrorAttrIssue, ReadProseMirrorAttrsResult, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectPageBreakRunOwnerMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readPageBreakRunOwnerMarkAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
@@ -1,7 +1,7 @@
1
1
  import { EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "../../types/documentEnumValues.js";
2
2
  import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
3
3
  import { isParagraphDirection } from "../paragraphDirection.js";
4
- import { TRACKED_CHANGE_PROVENANCE_VALUES } from "../schema/marks.js";
4
+ import { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS, RUN_FORMATTING_BOOLEAN_PROPERTIES, RUN_FORMATTING_VALUE_PROPERTIES, TRACKED_CHANGE_PROVENANCE_VALUES } from "../schema/marks.js";
5
5
  import { panic } from "better-result";
6
6
  import { DRAWING_RAW_XML_MODES, isOoxmlSymbolCharacter } from "@stll/docx-core/model";
7
7
  //#region src/prosemirror/attrs/index.ts
@@ -77,7 +77,13 @@ const TEXT_BOX_TRACKED_CHANGE_TYPES = [
77
77
  "moveFrom",
78
78
  "moveTo"
79
79
  ];
80
- const HARD_BREAK_TYPES = ["column"];
80
+ const HARD_BREAK_TYPES = ["column", "textWrapping"];
81
+ const PAGE_BREAK_CLEAR_VALUES = [
82
+ "none",
83
+ "left",
84
+ "right",
85
+ "all"
86
+ ];
81
87
  const RUN_FORMATTING_OVERRIDE_BOOLEAN_KEYS = [
82
88
  "bold",
83
89
  "italic",
@@ -91,6 +97,20 @@ const RUN_FORMATTING_OVERRIDE_BOOLEAN_KEYS = [
91
97
  "outline"
92
98
  ];
93
99
  const RUN_FORMATTING_OVERRIDE_FALSE_KEYS = ["doubleStrike", "rtl"];
100
+ const RUN_FORMATTING_OVERRIDE_STRING_SENTINELS = {
101
+ color: ["auto"],
102
+ effect: ["none"],
103
+ emphasisMark: ["none"],
104
+ highlight: ["none"],
105
+ underline: ["none"],
106
+ vertAlign: ["baseline"]
107
+ };
108
+ const RUN_FORMATTING_OVERRIDE_NUMBER_SENTINELS = {
109
+ kerning: 0,
110
+ position: 0,
111
+ scale: 100,
112
+ spacing: 0
113
+ };
94
114
  const RUN_FORMATTING_OVERRIDE_DIRECT_FONT_PROPERTIES = [
95
115
  "fontFamily",
96
116
  "fontSize",
@@ -112,6 +132,7 @@ const SECTION_VERTICAL_ALIGNMENTS = [
112
132
  ];
113
133
  const paragraphAttrsCache = /* @__PURE__ */ new WeakMap();
114
134
  const hardBreakAttrsCache = /* @__PURE__ */ new WeakMap();
135
+ const pageBreakRunAttrsCache = /* @__PURE__ */ new WeakMap();
115
136
  const tabAttrsCache = /* @__PURE__ */ new WeakMap();
116
137
  const symbolAttrsCache = /* @__PURE__ */ new WeakMap();
117
138
  const tableAttrsCache = /* @__PURE__ */ new WeakMap();
@@ -139,6 +160,7 @@ const footnoteRefAttrsCache = /* @__PURE__ */ new WeakMap();
139
160
  const commentAttrsCache = /* @__PURE__ */ new WeakMap();
140
161
  const trackedChangeAttrsCache = /* @__PURE__ */ new WeakMap();
141
162
  const runPropertyChangeAttrsCache = /* @__PURE__ */ new WeakMap();
163
+ const pageBreakRunOwnerAttrsCache = /* @__PURE__ */ new WeakMap();
142
164
  const runFormattingOverrideAttrsCache = /* @__PURE__ */ new WeakMap();
143
165
  const hyperlinkAttrsCache = /* @__PURE__ */ new WeakMap();
144
166
  const readParagraphAttrs = (node) => {
@@ -158,7 +180,7 @@ const readParagraphAttrs = (node) => {
158
180
  optionalNumber(attrs, "spaceBefore", "paragraph.attrs.spaceBefore", issues);
159
181
  optionalNumber(attrs, "spaceAfter", "paragraph.attrs.spaceAfter", issues);
160
182
  optionalNumber(attrs, "lineSpacing", "paragraph.attrs.lineSpacing", issues);
161
- optionalBoolean(attrs, "lineSpacingExplicit", "paragraph.attrs.lineSpacingExplicit", issues);
183
+ optionalLineSpacingProvenance(attrs, "lineSpacingExplicit", "paragraph.attrs.lineSpacingExplicit", issues);
162
184
  optionalBoolean(attrs, "snapToGrid", "paragraph.attrs.snapToGrid", issues);
163
185
  optionalOneOf(attrs, "lineSpacingRule", "paragraph.attrs.lineSpacingRule", issues, LINE_SPACING_RULE_VALUES);
164
186
  optionalNumber(attrs, "indentLeft", "paragraph.attrs.indentLeft", issues);
@@ -170,6 +192,7 @@ const readParagraphAttrs = (node) => {
170
192
  optionalBoolean(attrs, "listIsBullet", "paragraph.attrs.listIsBullet", issues);
171
193
  optionalBoolean(attrs, "listIsLegal", "paragraph.attrs.listIsLegal", issues);
172
194
  optionalString(attrs, "listMarker", "paragraph.attrs.listMarker", issues);
195
+ optionalString(attrs, "listMarkerTemplate", "paragraph.attrs.listMarkerTemplate", issues);
173
196
  optionalBoolean(attrs, "listMarkerHidden", "paragraph.attrs.listMarkerHidden", issues);
174
197
  optionalTextFormatting(attrs, "listMarkerFormatting", "paragraph.attrs.listMarkerFormatting", issues);
175
198
  optionalOneOf(attrs, "listMarkerAlignment", "paragraph.attrs.listMarkerAlignment", issues, [
@@ -229,9 +252,18 @@ const readHardBreakAttrs = (node) => {
229
252
  const issues = [];
230
253
  expectNodeType(node, "hardBreak", issues);
231
254
  optionalOneOf(attrs, "breakType", "hardBreak.attrs.breakType", issues, HARD_BREAK_TYPES);
255
+ optionalOneOf(attrs, "clear", "hardBreak.attrs.clear", issues, PAGE_BREAK_CLEAR_VALUES);
232
256
  return attrsResult(attrs, issues);
233
257
  };
234
258
  const expectHardBreakAttrs = (node) => expectCachedNodeAttrs(node, hardBreakAttrsCache, readHardBreakAttrs, "hard break attrs");
259
+ const readPageBreakRunAttrs = (node) => {
260
+ const attrs = attrsRecord(node.attrs);
261
+ const issues = [];
262
+ expectNodeType(node, "pageBreakRun", issues);
263
+ optionalOneOf(attrs, "clear", "pageBreakRun.attrs.clear", issues, PAGE_BREAK_CLEAR_VALUES);
264
+ return attrsResult(attrs, issues);
265
+ };
266
+ const expectPageBreakRunAttrs = (node) => expectCachedNodeAttrs(node, pageBreakRunAttrsCache, readPageBreakRunAttrs, "page break run attrs");
235
267
  const readTabAttrs = (node) => {
236
268
  const attrs = attrsRecord(node.attrs);
237
269
  const issues = [];
@@ -558,7 +590,6 @@ const readCharacterStyleMarkAttrs = (mark) => {
558
590
  const issues = [];
559
591
  expectMarkType(mark, "characterStyle", issues);
560
592
  requiredString(attrs, "styleId", "characterStyle.attrs.styleId", issues);
561
- optionalRecord(attrs, "_styleRPr", "characterStyle.attrs._styleRPr", issues);
562
593
  return attrsResult(attrs, issues);
563
594
  };
564
595
  const expectCharacterStyleMarkAttrs = (mark) => expectCachedMarkAttrs(mark, characterStyleAttrsCache, readCharacterStyleMarkAttrs, "character style attrs");
@@ -674,6 +705,18 @@ const readRunPropertyChangeMarkAttrs = (mark) => {
674
705
  return attrsResult(attrs, issues);
675
706
  };
676
707
  const expectRunPropertyChangeMarkAttrs = (mark) => expectCachedMarkAttrs(mark, runPropertyChangeAttrsCache, readRunPropertyChangeMarkAttrs, "run property change attrs");
708
+ const readPageBreakRunOwnerMarkAttrs = (mark) => {
709
+ const attrs = attrsRecord(mark.attrs);
710
+ const issues = [];
711
+ expectMarkType(mark, "pageBreakRunOwner", issues);
712
+ const id = attrs["id"];
713
+ if (typeof id !== "number" || !Number.isSafeInteger(id) || id < 0) issues.push({
714
+ path: "pageBreakRunOwner.attrs.id",
715
+ message: "Expected a non-negative safe integer."
716
+ });
717
+ return attrsResult(attrs, issues);
718
+ };
719
+ const expectPageBreakRunOwnerMarkAttrs = (mark) => expectCachedMarkAttrs(mark, pageBreakRunOwnerAttrsCache, readPageBreakRunOwnerMarkAttrs, "page break run owner attrs");
677
720
  const readRunFormattingOverrideMarkAttrs = (mark) => {
678
721
  const attrs = attrsRecord(mark.attrs);
679
722
  const issues = [];
@@ -684,13 +727,65 @@ const readRunFormattingOverrideMarkAttrs = (mark) => {
684
727
  optionalBoolean(attrs, "italicCs", "runFormattingOverride.attrs.italicCs", issues);
685
728
  optionalNumber(attrs, "fontSizeCs", "runFormattingOverride.attrs.fontSizeCs", issues);
686
729
  optionalBoolean(attrs, "cs", "runFormattingOverride.attrs.cs", issues);
687
- optionalOneOf(attrs, "underline", "runFormattingOverride.attrs.underline", issues, ["none"]);
730
+ optionalShading(attrs, "shading", "runFormattingOverride.attrs.shading", issues);
731
+ const shading = attrs["shading"];
732
+ if (isRecord(shading) && shading["pattern"] !== "nil") issues.push({
733
+ path: "runFormattingOverride.attrs.shading.pattern",
734
+ message: "Expected \"nil\"."
735
+ });
736
+ for (const [key, values] of Object.entries(RUN_FORMATTING_OVERRIDE_STRING_SENTINELS)) optionalOneOf(attrs, key, `runFormattingOverride.attrs.${key}`, issues, values);
737
+ for (const [key, expected] of Object.entries(RUN_FORMATTING_OVERRIDE_NUMBER_SENTINELS)) {
738
+ const value = attrs[key];
739
+ if (value !== void 0 && value !== null && value !== expected) issues.push({
740
+ path: `runFormattingOverride.attrs.${key}`,
741
+ message: `Expected ${expected}.`
742
+ });
743
+ }
688
744
  optionalOneOfArray(attrs, "directFontProperties", "runFormattingOverride.attrs.directFontProperties", issues, RUN_FORMATTING_OVERRIDE_DIRECT_FONT_PROPERTIES);
745
+ optionalOneOfArray(attrs, "complexScriptPropertyAbsences", "runFormattingOverride.attrs.complexScriptPropertyAbsences", issues, COMPLEX_SCRIPT_RUN_PROPERTY_KEYS);
746
+ optionalOneOfArray(attrs, "_authoredOn", "runFormattingOverride.attrs._authoredOn", issues, RUN_FORMATTING_BOOLEAN_PROPERTIES);
747
+ optionalOneOfArray(attrs, "_authoredOff", "runFormattingOverride.attrs._authoredOff", issues, RUN_FORMATTING_BOOLEAN_PROPERTIES);
748
+ optionalTextFormatting(attrs, "_authoredValues", "runFormattingOverride.attrs._authoredValues", issues);
749
+ const authoredValues = attrs["_authoredValues"];
750
+ if (isRecord(authoredValues)) {
751
+ const allowed = new Set(RUN_FORMATTING_VALUE_PROPERTIES);
752
+ for (const property of Object.keys(authoredValues)) if (!allowed.has(property)) issues.push({
753
+ path: `runFormattingOverride.attrs._authoredValues.${property}`,
754
+ message: "Expected a non-boolean authored formatting property."
755
+ });
756
+ }
689
757
  const directFontProperties = attrs["directFontProperties"];
690
758
  if (Array.isArray(directFontProperties) && new Set(directFontProperties).size !== directFontProperties.length) issues.push({
691
759
  path: "runFormattingOverride.attrs.directFontProperties",
692
760
  message: "Expected unique direct font properties."
693
761
  });
762
+ const complexScriptPropertyAbsences = attrs["complexScriptPropertyAbsences"];
763
+ if (Array.isArray(complexScriptPropertyAbsences) && new Set(complexScriptPropertyAbsences).size !== complexScriptPropertyAbsences.length) issues.push({
764
+ path: "runFormattingOverride.attrs.complexScriptPropertyAbsences",
765
+ message: "Expected unique complex-script property absences."
766
+ });
767
+ if (Array.isArray(complexScriptPropertyAbsences)) {
768
+ for (const property of complexScriptPropertyAbsences) if (attrs[property] !== void 0 && attrs[property] !== null) issues.push({
769
+ path: `runFormattingOverride.attrs.${property}`,
770
+ message: "Expected a property to be either present or explicitly absent, not both."
771
+ });
772
+ }
773
+ for (const provenanceKey of ["_authoredOn", "_authoredOff"]) {
774
+ const properties = attrs[provenanceKey];
775
+ if (Array.isArray(properties) && new Set(properties).size !== properties.length) issues.push({
776
+ path: `runFormattingOverride.attrs.${provenanceKey}`,
777
+ message: "Expected unique authored formatting properties."
778
+ });
779
+ }
780
+ const authoredOn = attrs["_authoredOn"];
781
+ const authoredOff = attrs["_authoredOff"];
782
+ if (Array.isArray(authoredOn) && Array.isArray(authoredOff)) {
783
+ const off = new Set(authoredOff);
784
+ for (const property of authoredOn) if (off.has(property)) issues.push({
785
+ path: "runFormattingOverride.attrs._authoredOff",
786
+ message: "Expected authored formatting to be either on or off, not both."
787
+ });
788
+ }
694
789
  return attrsResult(attrs, issues);
695
790
  };
696
791
  const expectRunFormattingOverrideMarkAttrs = (mark) => expectCachedMarkAttrs(mark, runFormattingOverrideAttrsCache, readRunFormattingOverrideMarkAttrs, "run formatting override attrs");
@@ -920,6 +1015,16 @@ const optionalOneOf = (attrs, key, path, issues, allowed) => {
920
1015
  message: `Expected one of ${allowed.join(", ")}.`
921
1016
  });
922
1017
  };
1018
+ const LINE_SPACING_PROVENANCE_VALUES = [
1019
+ "value",
1020
+ "rule",
1021
+ "both"
1022
+ ];
1023
+ const optionalLineSpacingProvenance = (attrs, key, path, issues) => {
1024
+ const value = attrs[key];
1025
+ if (value === void 0 || value === null || typeof value === "boolean") return;
1026
+ optionalOneOf(attrs, key, path, issues, LINE_SPACING_PROVENANCE_VALUES);
1027
+ };
923
1028
  const optionalShapeLineEnd = (attrs, key, path, issues) => {
924
1029
  const value = attrs[key];
925
1030
  if (value === void 0 || value === null) return;
@@ -1428,8 +1533,8 @@ const PARAGRAPH_FORMATTING_NUMBER_KEYS = [
1428
1533
  const validateParagraphFormatting = (value, path, issues) => {
1429
1534
  optionalOneOf(value, "alignment", `${path}.alignment`, issues, PARAGRAPH_ALIGNMENT_VALUES);
1430
1535
  for (const key of PARAGRAPH_FORMATTING_BOOLEAN_KEYS) optionalBoolean(value, key, `${path}.${key}`, issues);
1536
+ optionalLineSpacingProvenance(value, "lineSpacingExplicit", `${path}.lineSpacingExplicit`, issues);
1431
1537
  for (const key of [
1432
- "lineSpacingExplicit",
1433
1538
  "listIsBullet",
1434
1539
  "listIsLegal",
1435
1540
  "listMarkerHidden",
@@ -1446,6 +1551,7 @@ const validateParagraphFormatting = (value, path, issues) => {
1446
1551
  optionalString(value, "styleId", `${path}.styleId`, issues);
1447
1552
  optionalOneOf(value, "listNumFmt", `${path}.listNumFmt`, issues, NUMBER_FORMAT_VALUES);
1448
1553
  optionalString(value, "listMarker", `${path}.listMarker`, issues);
1554
+ optionalString(value, "listMarkerTemplate", `${path}.listMarkerTemplate`, issues);
1449
1555
  optionalTextFormatting(value, "listMarkerFormatting", `${path}.listMarkerFormatting`, issues);
1450
1556
  optionalOneOf(value, "listMarkerAlignment", `${path}.listMarkerAlignment`, issues, [
1451
1557
  "left",
@@ -1744,4 +1850,4 @@ const optionalEmptyHyperlinkArray = (value, issues) => {
1744
1850
  }
1745
1851
  };
1746
1852
  //#endregion
1747
- export { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
1853
+ export { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectPageBreakRunOwnerMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readPageBreakRunOwnerMarkAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
@@ -0,0 +1,9 @@
1
+ //#region src/prosemirror/bookmarkBoundaryIntegrity.d.ts
2
+ type BookmarkBoundaryOccurrence = {
3
+ id: number;
4
+ type: "start" | "end";
5
+ position: number;
6
+ };
7
+ declare const findInvalidBookmarkBoundaryIds: (occurrences: readonly BookmarkBoundaryOccurrence[], reservedIds?: ReadonlySet<number>) => ReadonlySet<number>;
8
+ //#endregion
9
+ export { BookmarkBoundaryOccurrence, findInvalidBookmarkBoundaryIds };
@@ -0,0 +1,22 @@
1
+ //#region src/prosemirror/bookmarkBoundaryIntegrity.ts
2
+ const findInvalidBookmarkBoundaryIds = (occurrences, reservedIds = /* @__PURE__ */ new Set()) => {
3
+ const summaries = /* @__PURE__ */ new Map();
4
+ for (const occurrence of occurrences) {
5
+ const summary = summaries.get(occurrence.id) ?? {
6
+ startPositions: [],
7
+ endPositions: []
8
+ };
9
+ if (occurrence.type === "start") summary.startPositions.push(occurrence.position);
10
+ else summary.endPositions.push(occurrence.position);
11
+ summaries.set(occurrence.id, summary);
12
+ }
13
+ const invalidIds = /* @__PURE__ */ new Set();
14
+ for (const [id, summary] of summaries) {
15
+ const start = summary.startPositions.at(0);
16
+ const end = summary.endPositions.at(0);
17
+ if (reservedIds.has(id) || summary.startPositions.length !== 1 || summary.endPositions.length !== 1 || start === void 0 || end === void 0 || start >= end) invalidIds.add(id);
18
+ }
19
+ return invalidIds;
20
+ };
21
+ //#endregion
22
+ export { findInvalidBookmarkBoundaryIds };
@@ -8,6 +8,7 @@ declare function addCommentMark(commentId: number): Command;
8
8
  * Remove a comment mark by ID from the entire document.
9
9
  */
10
10
  declare function removeCommentMark(commentId: number): Command;
11
+ type ResolveMode = "accept" | "reject";
11
12
  type ParagraphBoundaryChange = {
12
13
  from: number;
13
14
  to: number;
@@ -37,6 +38,14 @@ declare function acceptAllChanges(): Command;
37
38
  * Reject all tracked changes in the document.
38
39
  */
39
40
  declare function rejectAllChanges(): Command;
41
+ /**
42
+ * Resolve a complete state synchronously for a headless reader or writer.
43
+ *
44
+ * @internal The replacement transaction is consumed here and never exposed:
45
+ * it is deliberately not an editor command and must not be transported or
46
+ * mapped through concurrent edits.
47
+ */
48
+ declare function resolveAllChangesInHeadlessState(state: EditorState, mode: ResolveMode): EditorState;
40
49
  /**
41
50
  * Find the document range covered by all revision carriers with any of the
42
51
  * given ids. Returns null when none are present (already accepted/rejected, or
@@ -165,4 +174,4 @@ declare function findNextChange(state: EditorState, startPos: number): ChangeRan
165
174
  */
166
175
  declare function findPreviousChange(state: EditorState, startPos: number): ChangeRange | null;
167
176
  //#endregion
168
- export { AcceptSuggestionOptions, FolioSuggestion, ParagraphBoundaryChange, SuggestionAppliedAs, SuggestionKind, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findChangeAtPosition, findNextChange, findParagraphBoundaryChangeAtPosition, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark };
177
+ export { AcceptSuggestionOptions, FolioSuggestion, ParagraphBoundaryChange, SuggestionAppliedAs, SuggestionKind, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findChangeAtPosition, findNextChange, findParagraphBoundaryChangeAtPosition, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark, resolveAllChangesInHeadlessState };