@stll/folio-core 0.35.1 → 0.37.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 (236) hide show
  1. package/README.md +59 -1
  2. package/dist/ai-edits/apply.js +878 -377
  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 +141 -73
  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 +105 -20
  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 +62 -61
  20. package/dist/ai-edits/word-diff.d.ts +18 -3
  21. package/dist/ai-edits/word-diff.js +556 -67
  22. package/dist/ai-suggestions/conflict.js +1 -4
  23. package/dist/ai-suggestions/text-positions.d.ts +8 -0
  24. package/dist/ai-suggestions/text-positions.js +27 -5
  25. package/dist/compare/__fixtures__/body-sequence.js +3 -4
  26. package/dist/compare/column-alignment.d.ts +13 -13
  27. package/dist/compare/column-alignment.js +78 -39
  28. package/dist/compare/compare.d.ts +4 -3
  29. package/dist/compare/compare.js +48 -21
  30. package/dist/compare/content-alignment.d.ts +95 -0
  31. package/dist/compare/content-alignment.js +1450 -0
  32. package/dist/compare/content-types.d.ts +100 -0
  33. package/dist/compare/content-types.js +0 -0
  34. package/dist/compare/content.d.ts +209 -0
  35. package/dist/compare/content.js +885 -0
  36. package/dist/compare/formatting.d.ts +5 -5
  37. package/dist/compare/formatting.js +6 -4
  38. package/dist/compare/plan.d.ts +6 -1
  39. package/dist/compare/plan.js +171 -566
  40. package/dist/compare/scenario.d.ts +2 -2
  41. package/dist/compare/types.d.ts +3 -3
  42. package/dist/compare/verification.d.ts +8 -9
  43. package/dist/compare/verification.js +72 -50
  44. package/dist/compat/eigenpal.d.ts +5 -3
  45. package/dist/compat/eigenpal.js +3 -2
  46. package/dist/controller/headerFooterEditorManager.js +18 -10
  47. package/dist/controller/hiddenEditorApi.js +1 -1
  48. package/dist/controller/hiddenEditorManager.d.ts +7 -2
  49. package/dist/controller/hiddenEditorManager.js +15 -6
  50. package/dist/controller/layoutPipeline.js +5 -3
  51. package/dist/controller/noteEditorManager.js +12 -7
  52. package/dist/display-list/build/headerFooterPrimitives.js +1 -0
  53. package/dist/display-list/build/storyPrimitives.d.ts +5 -2
  54. package/dist/display-list/build/storyPrimitives.js +60 -3
  55. package/dist/display-list/build/tablePrimitives.js +30 -0
  56. package/dist/display-list/primitives.d.ts +1 -1
  57. package/dist/document-operations.d.ts +8 -4
  58. package/dist/document-operations.js +104 -12
  59. package/dist/docx/blockContentParser.js +6 -27
  60. package/dist/docx/commentParser.js +2 -4
  61. package/dist/docx/commentRangeIntegrity.js +2 -4
  62. package/dist/docx/documentClone.d.ts +2 -0
  63. package/dist/docx/documentClone.js +2 -0
  64. package/dist/docx/ensureParaIds.js +9 -4
  65. package/dist/docx/headerFooterParser.js +2 -4
  66. package/dist/docx/normalizeBaseDirection.js +5 -7
  67. package/dist/docx/numberingParser.d.ts +3 -1
  68. package/dist/docx/numberingParser.js +4 -1
  69. package/dist/docx/paragraphParser.js +34 -35
  70. package/dist/docx/paragraphPropertySource.d.ts +49 -0
  71. package/dist/docx/paragraphPropertySource.js +113 -0
  72. package/dist/docx/paragraphTraversal.js +30 -34
  73. package/dist/docx/rezip.d.ts +0 -8
  74. package/dist/docx/rezip.js +41 -16
  75. package/dist/docx/runConsolidator.js +2 -4
  76. package/dist/docx/runParser.js +6 -17
  77. package/dist/docx/sectionParser.js +1 -15
  78. package/dist/docx/serializer/paragraphSerializer.js +289 -30
  79. package/dist/docx/serializer/runSerializer.js +6 -12
  80. package/dist/docx/serializer/sectionPropertiesSerializer.js +2 -10
  81. package/dist/docx/serializer/tableSerializer.js +4 -23
  82. package/dist/docx/serializer/trackedChangeAttributes.d.ts +11 -0
  83. package/dist/docx/serializer/trackedChangeAttributes.js +31 -0
  84. package/dist/docx/server/build.d.ts +1 -1
  85. package/dist/docx/server/createBilingualDocument.js +8 -10
  86. package/dist/docx/server/evaluateDocxXmlPatchProposal.js +22 -13
  87. package/dist/docx/server/validateDocxConformance.js +17 -13
  88. package/dist/docx/tableParser.js +1 -37
  89. package/dist/docx/trackedChangeInfo.d.ts +11 -0
  90. package/dist/docx/trackedChangeInfo.js +38 -0
  91. package/dist/docx/verbatimCapture.d.ts +20 -9
  92. package/dist/docx/verbatimCapture.js +208 -8
  93. package/dist/docx/xmlParser.d.ts +3 -1
  94. package/dist/docx/xmlParser.js +6 -1
  95. package/dist/docx/xmlSafety.d.ts +1 -1
  96. package/dist/docx/xmlSafety.js +157 -0
  97. package/dist/headless-layout.js +5 -4
  98. package/dist/index.d.ts +5 -3
  99. package/dist/index.js +3 -2
  100. package/dist/internal/headlessRevisionResolution.d.ts +23 -0
  101. package/dist/internal/headlessRevisionResolution.js +155 -0
  102. package/dist/internal/headlessRevisionResolutionGuard.d.ts +12 -0
  103. package/dist/internal/headlessRevisionResolutionGuard.js +28 -0
  104. package/dist/internal/pageBreakRunDescendantIndex.d.ts +9 -0
  105. package/dist/internal/pageBreakRunDescendantIndex.js +27 -0
  106. package/dist/internal/pageBreakRunPartition.d.ts +26 -0
  107. package/dist/internal/pageBreakRunPartition.js +35 -0
  108. package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +15 -0
  109. package/dist/internal/pageBreakRunSourceDescendantIndex.js +126 -0
  110. package/dist/internal/sectionEndpointResolution.d.ts +32 -0
  111. package/dist/internal/sectionEndpointResolution.js +38 -0
  112. package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
  113. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +16 -4
  114. package/dist/layout-bridge/convert/headerFooterLayout.js +52 -9
  115. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +4 -0
  116. package/dist/layout-bridge/convert/toFlowBlocks.js +391 -82
  117. package/dist/layout-bridge/dom/clickToPositionDom.d.ts +8 -1
  118. package/dist/layout-bridge/dom/clickToPositionDom.js +114 -40
  119. package/dist/layout-bridge/dom/textStreamDom.d.ts +24 -0
  120. package/dist/layout-bridge/dom/textStreamDom.js +75 -0
  121. package/dist/layout-bridge/headerFooterLayout.js +16 -30
  122. package/dist/layout-engine/index.js +12 -3
  123. package/dist/layout-engine/measure/tableFragmentBorderGeometry.d.ts +17 -0
  124. package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +24 -0
  125. package/dist/layout-engine/renderedBreakReconciliation.js +1 -1
  126. package/dist/layout-engine/types.d.ts +7 -0
  127. package/dist/layout-painter/imageLayout.d.ts +1 -1
  128. package/dist/layout-painter/renderTable.js +20 -0
  129. package/dist/markdown/renderBlock.js +7 -10
  130. package/dist/model.d.ts +1 -1
  131. package/dist/paged-layout/rangeProjection.js +6 -9
  132. package/dist/paged-layout/transactionDirtyRange.d.ts +3 -1
  133. package/dist/paged-layout/transactionDirtyRange.js +23 -1
  134. package/dist/prosemirror/attrs/index.d.ts +7 -3
  135. package/dist/prosemirror/attrs/index.js +128 -7
  136. package/dist/prosemirror/bookmarkBoundaryIntegrity.d.ts +9 -0
  137. package/dist/prosemirror/bookmarkBoundaryIntegrity.js +22 -0
  138. package/dist/prosemirror/commands/comments.d.ts +10 -1
  139. package/dist/prosemirror/commands/comments.js +551 -87
  140. package/dist/prosemirror/commands/formatPainter.d.ts +45 -10
  141. package/dist/prosemirror/commands/formatPainter.js +319 -63
  142. package/dist/prosemirror/commands/index.d.ts +2 -2
  143. package/dist/prosemirror/commands/pageBreak.d.ts +5 -2
  144. package/dist/prosemirror/commands/pageBreak.js +18 -36
  145. package/dist/prosemirror/commands/propertyChangeScope.d.ts +27 -3
  146. package/dist/prosemirror/commands/propertyChangeScope.js +85 -14
  147. package/dist/prosemirror/conversion/fromProseDoc.d.ts +8 -5
  148. package/dist/prosemirror/conversion/fromProseDoc.js +935 -223
  149. package/dist/prosemirror/conversion/runShadingMark.js +2 -2
  150. package/dist/prosemirror/conversion/toProseDoc.d.ts +26 -1
  151. package/dist/prosemirror/conversion/toProseDoc.js +439 -291
  152. package/dist/prosemirror/extensions/StarterKit.js +4 -0
  153. package/dist/prosemirror/extensions/core/ParagraphExtension.js +54 -6
  154. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +7 -1
  155. package/dist/prosemirror/extensions/features/ListExtension.js +95 -123
  156. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +19 -6
  157. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +27 -1
  158. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +134 -30
  159. package/dist/prosemirror/extensions/features/pasteCleanup.js +9 -15
  160. package/dist/prosemirror/extensions/marks/BoldExtension.js +4 -3
  161. package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +4 -7
  162. package/dist/prosemirror/extensions/marks/CharacterStyleExtension.js +5 -11
  163. package/dist/prosemirror/extensions/marks/FontSizeExtension.js +3 -3
  164. package/dist/prosemirror/extensions/marks/ItalicExtension.js +4 -3
  165. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +13 -0
  166. package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +39 -0
  167. package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +7 -1
  168. package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +67 -21
  169. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -0
  170. package/dist/prosemirror/extensions/marks/markUtils.d.ts +8 -1
  171. package/dist/prosemirror/extensions/marks/markUtils.js +88 -2
  172. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +44 -3
  173. package/dist/prosemirror/extensions/nodes/FieldExtension.js +1 -1
  174. package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +15 -4
  175. package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +6 -0
  176. package/dist/prosemirror/extensions/nodes/PageBreakExtension.js +6 -0
  177. package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.d.ts +6 -0
  178. package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.js +36 -0
  179. package/dist/prosemirror/findReplaceSelection.js +8 -3
  180. package/dist/prosemirror/index.d.ts +3 -3
  181. package/dist/prosemirror/listMarker.d.ts +26 -1
  182. package/dist/prosemirror/listMarker.js +108 -14
  183. package/dist/prosemirror/pageBreakRunProjection.d.ts +28 -0
  184. package/dist/prosemirror/pageBreakRunProjection.js +47 -0
  185. package/dist/prosemirror/paraText.js +6 -0
  186. package/dist/prosemirror/paragraphAlignment.d.ts +12 -0
  187. package/dist/prosemirror/paragraphAlignment.js +13 -0
  188. package/dist/prosemirror/paragraphSpacing.d.ts +29 -0
  189. package/dist/prosemirror/paragraphSpacing.js +125 -0
  190. package/dist/prosemirror/plugins/documentNumbering.d.ts +8 -0
  191. package/dist/prosemirror/plugins/documentNumbering.js +18 -0
  192. package/dist/prosemirror/plugins/pmTextScan.d.ts +3 -2
  193. package/dist/prosemirror/plugins/pmTextScan.js +14 -4
  194. package/dist/prosemirror/plugins/suggestionMode.js +9 -11
  195. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +16 -0
  196. package/dist/prosemirror/rebaseParagraphRunFormatting.js +61 -0
  197. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +64 -0
  198. package/dist/prosemirror/runFormattingInlineCarriers.js +121 -0
  199. package/dist/prosemirror/runFormattingProvenance.d.ts +12 -0
  200. package/dist/prosemirror/runFormattingProvenance.js +48 -0
  201. package/dist/prosemirror/runFormattingReconciliation.d.ts +25 -0
  202. package/dist/prosemirror/runFormattingReconciliation.js +54 -0
  203. package/dist/prosemirror/runPropertyChangeResolution.d.ts +18 -0
  204. package/dist/prosemirror/runPropertyChangeResolution.js +18 -0
  205. package/dist/prosemirror/runStyleFormatting.d.ts +50 -0
  206. package/dist/prosemirror/runStyleFormatting.js +105 -0
  207. package/dist/prosemirror/schema/index.d.ts +3 -3
  208. package/dist/prosemirror/schema/marks.d.ts +84 -9
  209. package/dist/prosemirror/schema/marks.js +73 -1
  210. package/dist/prosemirror/schema/nodes.d.ts +30 -6
  211. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +14 -2
  212. package/dist/prosemirror/styles/resolvedStyleAttrs.js +45 -23
  213. package/dist/prosemirror/styles/styleResolver.d.ts +10 -13
  214. package/dist/prosemirror/styles/styleResolver.js +3 -3
  215. package/dist/prosemirror/styles/styleToggleCascade.d.ts +8 -1
  216. package/dist/prosemirror/styles/styleToggleCascade.js +24 -1
  217. package/dist/prosemirror/tableGridMutation.d.ts +20 -0
  218. package/dist/prosemirror/tableGridMutation.js +30 -0
  219. package/dist/prosemirror/trackedRunInlineAtoms.d.ts +31 -0
  220. package/dist/prosemirror/trackedRunInlineAtoms.js +39 -0
  221. package/dist/prosemirror/utils/visualLineNavigation.js +27 -31
  222. package/dist/prosemirror/validation.js +23 -4
  223. package/dist/redline.js +4 -1
  224. package/dist/render-dom/HeaderFooterSelectionOverlay.js +20 -20
  225. package/dist/render-dom/RenderedDomContext.js +17 -34
  226. package/dist/server.d.ts +4 -4
  227. package/dist/server.js +2 -2
  228. package/dist/style-engine/styleEngine.d.ts +1 -1
  229. package/dist/utils/clipboard.js +1 -1
  230. package/dist/utils/findReplace.js +38 -21
  231. package/dist/utils/mergeDocumentContent.js +3 -3
  232. package/dist/utils/replaceText.js +2 -1
  233. package/dist/version-comparison.d.ts +38 -44
  234. package/dist/version-comparison.js +270 -399
  235. package/dist/watermark/index.js +2 -4
  236. package/package.json +8 -2
@@ -1,8 +1,29 @@
1
1
  import { document_d_exports } from "../../types/document.js";
2
2
  import { ParagraphPropertyChangeAttrs } from "../schema/nodes.js";
3
+ import { Node } from "prosemirror-model";
3
4
  //#region src/prosemirror/commands/propertyChangeScope.d.ts
5
+ /** Editor-only suggestions are rebased away before save; every other entry emits `w:pPrChange`. */
6
+ declare const hasSerializableParagraphPropertyChange: (changes: readonly ParagraphPropertyChangeAttrs[] | null | undefined) => boolean;
4
7
  type AttrPatch = Record<string, unknown>;
5
8
  type ParagraphPropertySnapshot = NonNullable<ParagraphPropertyChangeAttrs["previousFormatting"]>;
9
+ type ParagraphPropertyChangeRemoval = {
10
+ type: "unchanged";
11
+ } | {
12
+ type: "keep-live";
13
+ remaining: ParagraphPropertyChangeAttrs[];
14
+ } | {
15
+ type: "restore-previous";
16
+ remaining: ParagraphPropertyChangeAttrs[];
17
+ previousFormatting: ParagraphPropertyChangeAttrs["previousFormatting"];
18
+ };
19
+ /**
20
+ * Remove selected entries from an oldest-to-newest paragraph-property chain.
21
+ * A retained entry immediately after a removed run inherits that run's
22
+ * earliest previous snapshot. Only a removed trailing run restores the live
23
+ * paragraph properties. This makes repeated scoped rejection independent of
24
+ * the order in which revisions are resolved.
25
+ */
26
+ declare const removeParagraphPropertyChanges: (changes: readonly ParagraphPropertyChangeAttrs[], shouldRemove: (change: ParagraphPropertyChangeAttrs) => boolean) => ParagraphPropertyChangeRemoval;
6
27
  /**
7
28
  * Paragraph attrs governed by a `w:pPrChange` — the attrs
8
29
  * `paragraphFormattingToAttrs` (conversion/toProseDoc.ts) can produce from a
@@ -19,9 +40,12 @@ type ParagraphPropertySnapshot = NonNullable<ParagraphPropertyChangeAttrs["previ
19
40
  * `runInWithNext` (`w:specVanish` lives in that rPr)
20
41
  * - load-time style/numbering bookkeeping the command layer cannot recompute
21
42
  * without a style resolver: `numPrFromStyle`, the `list*` rendering attrs,
22
- * `spacingFromDocDefaults`, `spacingFromImplicitDefaultStyle`
43
+ * `alignmentFromStyle`, `spacingFromDocDefaults`, and resolved style-spacing
44
+ * provenance in `spacingFromImplicitDefaultStyle`
23
45
  */
24
46
  declare const PPR_CHANGE_SCOPED_ATTR_KEYS: readonly ["styleId", "numPr", "alignment", "spaceBefore", "spaceAfter", "lineSpacing", "lineSpacingRule", "lineSpacingExplicit", "snapToGrid", "spacingExplicit", "indentLeft", "indentRight", "indentFirstLine", "hangingIndent", "borders", "shading", "tabs", "pageBreakBefore", "keepNext", "keepLines", "widowControl", "contextualSpacing", "outlineLevel", "direction", "_autospacingBase"];
47
+ /** The in-scope paragraph properties as they stand, for a `w:pPrChange` record. */
48
+ declare const paragraphPropertiesSnapshot: (node: Node) => ParagraphPropertySnapshot;
25
49
  /**
26
50
  * Build the attr patch that rejecting one pPrChange applies to a paragraph:
27
51
  * every in-scope key set to the stored previous value, or reset to `null`
@@ -29,7 +53,7 @@ declare const PPR_CHANGE_SCOPED_ATTR_KEYS: readonly ["styleId", "numPr", "alignm
29
53
  * the scoped set (editor-created list suggestions snapshot list-rendering
30
54
  * bookkeeping attrs) merge through 1:1 so their pre-change values restore too.
31
55
  */
32
- declare function paragraphRejectAttrPatch(previousFormatting: ParagraphPropertySnapshot | null | undefined): AttrPatch;
56
+ declare function paragraphRejectAttrPatch(previousFormatting: ParagraphPropertySnapshot | null | undefined, inheritedFormatting?: document_d_exports.ParagraphFormatting): AttrPatch;
33
57
  /**
34
58
  * Rebuild the paragraph's `_originalFormatting` (the serializer's pPr source)
35
59
  * after a reject: the stored old pPr wholesale within CT_PPrBase scope, with
@@ -66,4 +90,4 @@ declare function tableRowRejectAttrPatch(previousFormatting: document_d_exports.
66
90
  */
67
91
  declare function tableCellRejectAttrPatch(previousFormatting: document_d_exports.TableCellFormatting | undefined, liveOriginalFormatting: document_d_exports.TableCellFormatting | null | undefined): AttrPatch;
68
92
  //#endregion
69
- export { PPR_CHANGE_SCOPED_ATTR_KEYS, paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, sectionRejectProperties, tableCellRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch };
93
+ export { PPR_CHANGE_SCOPED_ATTR_KEYS, ParagraphPropertyChangeRemoval, hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot, paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges, sectionRejectProperties, tableCellRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch };
@@ -1,6 +1,53 @@
1
- import { setAutospacingBaseValue } from "../autospacingBase.js";
1
+ import { expectParagraphAttrs } from "../attrs/index.js";
2
+ import { directParagraphAlignment } from "../paragraphAlignment.js";
2
3
  import { directionFromBidi } from "../paragraphDirection.js";
4
+ import { directParagraphSpacing, paragraphSpacingAttrPatch, paragraphSpacingFromFormatting } from "../paragraphSpacing.js";
3
5
  //#region src/prosemirror/commands/propertyChangeScope.ts
6
+ /** Editor-only suggestions are rebased away before save; every other entry emits `w:pPrChange`. */
7
+ const hasSerializableParagraphPropertyChange = (changes) => changes?.some(({ info }) => info.provenance !== "suggested") === true;
8
+ /**
9
+ * Remove selected entries from an oldest-to-newest paragraph-property chain.
10
+ * A retained entry immediately after a removed run inherits that run's
11
+ * earliest previous snapshot. Only a removed trailing run restores the live
12
+ * paragraph properties. This makes repeated scoped rejection independent of
13
+ * the order in which revisions are resolved.
14
+ */
15
+ const removeParagraphPropertyChanges = (changes, shouldRemove) => {
16
+ const remaining = [];
17
+ let removedPrevious;
18
+ let removedAny = false;
19
+ let removingRun = false;
20
+ for (const change of changes) {
21
+ if (shouldRemove(change)) {
22
+ if (!removingRun) {
23
+ removedPrevious = change.previousFormatting;
24
+ removingRun = true;
25
+ }
26
+ removedAny = true;
27
+ continue;
28
+ }
29
+ if (!removingRun) {
30
+ remaining.push(change);
31
+ continue;
32
+ }
33
+ const rebased = { ...change };
34
+ if (removedPrevious === void 0) Reflect.deleteProperty(rebased, "previousFormatting");
35
+ else rebased.previousFormatting = removedPrevious;
36
+ remaining.push(rebased);
37
+ removedPrevious = void 0;
38
+ removingRun = false;
39
+ }
40
+ if (!removedAny) return { type: "unchanged" };
41
+ if (!removingRun) return {
42
+ type: "keep-live",
43
+ remaining
44
+ };
45
+ return {
46
+ type: "restore-previous",
47
+ remaining,
48
+ previousFormatting: removedPrevious
49
+ };
50
+ };
4
51
  /**
5
52
  * Paragraph attrs governed by a `w:pPrChange` — the attrs
6
53
  * `paragraphFormattingToAttrs` (conversion/toProseDoc.ts) can produce from a
@@ -17,7 +64,8 @@ import { directionFromBidi } from "../paragraphDirection.js";
17
64
  * `runInWithNext` (`w:specVanish` lives in that rPr)
18
65
  * - load-time style/numbering bookkeeping the command layer cannot recompute
19
66
  * without a style resolver: `numPrFromStyle`, the `list*` rendering attrs,
20
- * `spacingFromDocDefaults`, `spacingFromImplicitDefaultStyle`
67
+ * `alignmentFromStyle`, `spacingFromDocDefaults`, and resolved style-spacing
68
+ * provenance in `spacingFromImplicitDefaultStyle`
21
69
  */
22
70
  const PPR_CHANGE_SCOPED_ATTR_KEYS = [
23
71
  "styleId",
@@ -47,6 +95,31 @@ const PPR_CHANGE_SCOPED_ATTR_KEYS = [
47
95
  "_autospacingBase"
48
96
  ];
49
97
  const PPR_CHANGE_SCOPED_ATTR_KEY_SET = new Set(PPR_CHANGE_SCOPED_ATTR_KEYS);
98
+ /** Effective/bookkeeping attrs whose tracked snapshot must use direct provenance instead. */
99
+ const PPR_SPACING_ATTR_KEYS = /* @__PURE__ */ new Set([
100
+ "spaceBefore",
101
+ "spaceAfter",
102
+ "lineSpacing",
103
+ "lineSpacingRule",
104
+ "lineSpacingExplicit",
105
+ "spacingExplicit",
106
+ "_autospacingBase"
107
+ ]);
108
+ /** The in-scope paragraph properties as they stand, for a `w:pPrChange` record. */
109
+ const paragraphPropertiesSnapshot = (node) => {
110
+ const attrs = expectParagraphAttrs(node);
111
+ const snapshot = {};
112
+ for (const key of PPR_CHANGE_SCOPED_ATTR_KEYS) {
113
+ if (key === "alignment" || PPR_SPACING_ATTR_KEYS.has(key)) continue;
114
+ const value = attrs[key];
115
+ if (key === "hangingIndent" && value === false && attrs._originalFormatting?.hangingIndent === void 0) continue;
116
+ if (value !== null && value !== void 0) snapshot[key] = value;
117
+ }
118
+ const directAlignment = directParagraphAlignment(attrs);
119
+ if (directAlignment !== void 0) snapshot["alignment"] = directAlignment;
120
+ Object.assign(snapshot, directParagraphSpacing(attrs));
121
+ return snapshot;
122
+ };
50
123
  /**
51
124
  * Parser-shaped `ParagraphFormatting` keys that must NOT merge through to
52
125
  * attrs verbatim: they either normalize to a differently named attr
@@ -108,12 +181,19 @@ const PPR_CHANGE_SCOPED_FORMATTING_KEYS = [
108
181
  * the scoped set (editor-created list suggestions snapshot list-rendering
109
182
  * bookkeeping attrs) merge through 1:1 so their pre-change values restore too.
110
183
  */
111
- function paragraphRejectAttrPatch(previousFormatting) {
184
+ function paragraphRejectAttrPatch(previousFormatting, inheritedFormatting) {
112
185
  const prev = previousFormatting ?? {};
113
186
  const patch = {};
114
187
  for (const key of PPR_CHANGE_SCOPED_ATTR_KEYS) patch[key] = Object.hasOwn(prev, key) ? prev[key] ?? null : null;
188
+ if (!Object.hasOwn(prev, "alignment")) patch["alignment"] = inheritedFormatting?.alignment ?? null;
189
+ patch["alignmentFromStyle"] = inheritedFormatting?.alignment;
190
+ const directSpacing = paragraphSpacingFromFormatting(prev);
191
+ const inheritedSpacing = paragraphSpacingFromFormatting(inheritedFormatting);
192
+ Object.assign(patch, paragraphSpacingAttrPatch({
193
+ direct: directSpacing,
194
+ inherited: inheritedSpacing
195
+ }));
115
196
  if (!Object.hasOwn(prev, "direction")) patch["direction"] = directionFromBidi(prev.bidi);
116
- if (!Object.hasOwn(prev, "_autospacingBase")) patch["_autospacingBase"] = autospacingBaseFromFormatting(prev);
117
197
  for (const [key, value] of Object.entries(prev)) {
118
198
  if (PPR_CHANGE_SCOPED_ATTR_KEY_SET.has(key) || PPR_PARSER_ONLY_KEYS.has(key)) continue;
119
199
  patch[key] = value ?? null;
@@ -140,15 +220,6 @@ function paragraphRejectOriginalFormatting(previousFormatting, liveOriginal) {
140
220
  if (Object.keys(result).length === 0) return null;
141
221
  return result;
142
222
  }
143
- function autospacingBaseFromFormatting(prev) {
144
- const before = prev.beforeAutospacing === true;
145
- const after = prev.afterAutospacing === true;
146
- if (!before && !after) return null;
147
- const base = {};
148
- if (before) setAutospacingBaseValue(base, "before", prev.spaceBefore);
149
- if (after) setAutospacingBaseValue(base, "after", prev.spaceAfter);
150
- return base;
151
- }
152
223
  /**
153
224
  * Rejected section properties: the stored old sectPr wholesale, preserving
154
225
  * the live header/footer references — `EG_HdrFtrReferences` is not part of
@@ -241,4 +312,4 @@ function isRecord(value) {
241
312
  return typeof value === "object" && value !== null && !Array.isArray(value);
242
313
  }
243
314
  //#endregion
244
- export { PPR_CHANGE_SCOPED_ATTR_KEYS, paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, sectionRejectProperties, tableCellRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch };
315
+ export { PPR_CHANGE_SCOPED_ATTR_KEYS, hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot, paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges, sectionRejectProperties, tableCellRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch };
@@ -1,16 +1,19 @@
1
1
  import { document_d_exports } from "../../types/document.js";
2
2
  import { TableAttrs, TableCellAttrs, TableRowAttrs } from "../schema/nodes.js";
3
+ import { RunStyleResolver } from "../runStyleFormatting.js";
3
4
  import { Mark, Node } from "prosemirror-model";
4
5
  //#region src/prosemirror/conversion/fromProseDoc.d.ts
5
- /**
6
- * Convert a ProseMirror document to our Document type
7
- */
6
+ /** Convert a ProseMirror document to the document model. */
8
7
  declare function fromProseDoc(pmDoc: Node, baseDocument?: document_d_exports.Document): document_d_exports.Document;
9
8
  /**
10
9
  * Convert ProseMirror marks to TextFormatting
11
10
  */
12
11
  type MarksToTextFormattingOptions = {
13
- inheritedFormatting: document_d_exports.TextFormatting | undefined;
12
+ baseParagraphFormatting?: document_d_exports.TextFormatting | undefined;
13
+ inheritedFormatting?: document_d_exports.TextFormatting | undefined;
14
+ paragraphMarkFormatting?: document_d_exports.TextFormatting | undefined;
15
+ paragraphMarkPrecedesStyle?: boolean | undefined;
16
+ styleResolver?: RunStyleResolver | null | undefined;
14
17
  };
15
18
  declare function marksToTextFormatting(marks: readonly Mark[], options?: MarksToTextFormattingOptions): document_d_exports.TextFormatting;
16
19
  declare function tableAttrsToFormatting(attrs: TableAttrs): document_d_exports.TableFormatting | undefined;
@@ -32,6 +35,6 @@ declare function updateDocumentContent(originalDocument: document_d_exports.Docu
32
35
  * Used for converting edited header/footer PM content back to the document
33
36
  * model.
34
37
  */
35
- declare function proseDocToBlocks(pmDoc: Node): document_d_exports.BlockContent[];
38
+ declare function proseDocToBlocks(pmDoc: Node, baseContent?: document_d_exports.BlockContent[], styles?: NonNullable<document_d_exports.Document["package"]>["styles"]): document_d_exports.BlockContent[];
36
39
  //#endregion
37
40
  export { fromProseDoc, marksToTextFormatting, proseDocToBlocks, standaloneTableCellFromProseMirror, tableAttrsToFormatting, tableCellAttrsToFormatting, tableRowAttrsToFormatting, updateDocumentContent };