@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,20 +1,26 @@
1
+ import { document_d_exports } from "../types/document.js";
2
+ import { FolioContentBlock, FolioContentInlineBooleanProperty, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentTableLocation } from "../compare/content-types.js";
1
3
  //#region src/ai-edits/types.d.ts
2
4
  type FolioAIBlockKind = "heading" | "listItem" | "paragraph";
3
- type FolioAIInlineFormatting = Partial<Record<"bold" | "italic" | "underline" | "strike", boolean>> & {
4
- fontFamily?: string | null;
5
- fontSizePt?: number | null;
6
- color?: string | null;
7
- };
8
- type FolioAIBlockPreviewRun = {
9
- text: string;
10
- bold?: boolean;
11
- italic?: boolean;
12
- underline?: boolean;
13
- strike?: boolean;
14
- fontFamily?: string;
15
- fontSizePt?: number;
16
- color?: string;
17
- directFormatting?: FolioAIInlineFormatting;
5
+ /** Boolean run properties supported by snapshots and range-formatting mutations. */
6
+ type FolioAIInlineBooleanProperty = FolioContentInlineBooleanProperty;
7
+ type FolioAIInlineFormatting = FolioContentInlineFormatting;
8
+ /**
9
+ * A run-formatting mutation: `false` authors an explicit off value, while
10
+ * `null` removes the direct property so its inherited value becomes effective.
11
+ */
12
+ type FolioAIInlineFormattingPatch = FolioContentInlineFormattingPatch;
13
+ type FolioAIBlockPreviewRun = FolioContentRun;
14
+ /**
15
+ * A zero-width inline structure at one clean-text boundary. `pageBreak`
16
+ * always represents an authored `<w:br w:type="page"/>`; an omitted `clear`
17
+ * remains distinct from any explicit value even though it does not affect
18
+ * layout for this break type.
19
+ */
20
+ type FolioAIBlockStructuralBoundary = {
21
+ type: "pageBreak";
22
+ offset: number;
23
+ clear?: document_d_exports.BreakContent["clear"];
18
24
  };
19
25
  /**
20
26
  * Where a block sits inside its innermost enclosing table. Every index is
@@ -24,47 +30,20 @@ type FolioAIBlockPreviewRun = {
24
30
  * not a grid column), and `paragraphIndex` orders the block among the cell's
25
31
  * own blocks. Absent on a block that is not inside a table.
26
32
  */
27
- type FolioAIBlockTableLocation = {
28
- /**
29
- * Document-order index of the OUTERMOST table the block sits in — the same
30
- * as `tableIndex` unless tables nest. A comparison aligns on this: a table
31
- * inside a cell is part of its parent, not a structure of its own that can
32
- * be paired against one somewhere else.
33
- */
34
- outerTableIndex: number;
35
- tableIndex: number;
36
- rowIndex: number;
37
- cellIndex: number;
38
- /** Grid column occupied by the cell's left edge, derived from `TableMap`. */
39
- gridColumnIndex: number;
40
- /** Number of grid columns occupied by this physical cell. */
41
- columnSpan: number;
42
- /** Number of grid rows occupied by this physical cell. */
43
- rowSpan: number;
44
- paragraphIndex: number;
45
- };
46
- type FolioAIBlock = {
47
- id: string;
48
- kind: FolioAIBlockKind;
49
- text: string;
50
- /** One-based heading depth when the block has outline semantics. */
51
- headingLevel?: number;
52
- displayLabel?: string;
53
- styleId?: string;
54
- /**
55
- * `w:numPr/w:ilvl`: the block's list indent level. Present only on a block
56
- * that carries numbering, and the only pPr property a redline can move
57
- * without touching a word — a demoted list item reads as unchanged text and
58
- * is not.
59
- */
60
- listLevel?: number;
61
- previewRuns?: FolioAIBlockPreviewRun[];
62
- table?: FolioAIBlockTableLocation;
33
+ type FolioAIBlockTableLocation = FolioContentTableLocation;
34
+ type FolioAIBlock = FolioContentBlock<FolioAIBlockKind> & {
35
+ structuralBoundaries?: readonly FolioAIBlockStructuralBoundary[];
63
36
  };
37
+ /**
38
+ * The complete modeled attribute set of one direct `w:pPr/w:spacing` child.
39
+ * Optional fields preserve the distinction between an absent attribute and
40
+ * an explicit zero or false value.
41
+ */
42
+ type FolioAIParagraphSpacing = FolioContentParagraphSpacing;
64
43
  /**
65
44
  * The paragraph properties an operation may set. A subset of `w:pPrChange`'s
66
- * scope: the two a comparison can see in a block projection, and the two an
67
- * agent has a reason to change.
45
+ * scope: properties a comparison can see in a block projection and an agent
46
+ * has a reason to change.
68
47
  */
69
48
  type FolioAIBlockParagraphProperties = {
70
49
  /** `w:pStyle`. `null` clears the style back to the default. */
@@ -74,6 +53,10 @@ type FolioAIBlockParagraphProperties = {
74
53
  * paragraph stops being a list item rather than moving to another level.
75
54
  */
76
55
  listLevel?: number | null;
56
+ /** Direct `w:jc`. `null` clears the override and restores style inheritance. */
57
+ alignment?: document_d_exports.ParagraphAlignment | null;
58
+ /** Direct `w:spacing` attributes. `null` removes the whole direct child. */
59
+ spacing?: FolioAIParagraphSpacing | null;
77
60
  };
78
61
  /**
79
62
  * Every paragraph of one story, blank ones included.
@@ -84,8 +67,7 @@ type FolioAIBlockParagraphProperties = {
84
67
  * document for a person or a model wants only the paragraphs that carry text,
85
68
  * and says so with `isFolioAIContentBlock`.
86
69
  */
87
- type FolioAIEditSnapshot = {
88
- blocks: FolioAIBlock[];
70
+ type FolioAIEditSnapshot = FolioContentSnapshot<FolioAIBlock> & {
89
71
  anchors: Record<string, FolioAIBlockAnchor>;
90
72
  };
91
73
  type FolioAIBlockAnchor = {
@@ -95,6 +77,8 @@ type FolioAIBlockAnchor = {
95
77
  text: string;
96
78
  normalizedText: string;
97
79
  textHash: string;
80
+ /** Hash of zero-width structural boundaries in the clean block view. */
81
+ structuralBoundaryHash: string;
98
82
  hashOccurrenceCount: number;
99
83
  };
100
84
  type FolioAIComment = {
@@ -213,7 +197,7 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
213
197
  id: string;
214
198
  type: "formatRange";
215
199
  range: FolioAITextRangeHandle;
216
- formatting: FolioAIInlineFormatting;
200
+ formatting: FolioAIInlineFormattingPatch;
217
201
  } | {
218
202
  id: string;
219
203
  type: "insertAfterBlock" | "insertBeforeBlock";
@@ -222,7 +206,7 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
222
206
  * The paragraph text to insert. A line break splits `text` into
223
207
  * consecutive paragraphs at the same anchor instead of becoming
224
208
  * literal newlines inside one paragraph: only the first paragraph
225
- * gets `styleId` / `inheritFormatting`, later ones use body
209
+ * gets `styleId` / `alignment` / `inheritFormatting`, later ones use body
226
210
  * formatting. Blank lines are dropped. Reported as a
227
211
  * `splitMultilineText` normalization when it happens.
228
212
  *
@@ -262,6 +246,16 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
262
246
  * inheritance alone cannot say.
263
247
  */
264
248
  listLevel?: number | null;
249
+ /**
250
+ * Direct `w:jc` for the inserted block. `null` clears alignment copied
251
+ * from the anchor and lets the inserted paragraph's style decide.
252
+ */
253
+ alignment?: document_d_exports.ParagraphAlignment | null;
254
+ /**
255
+ * Direct `w:spacing` for the inserted block. `null` clears spacing
256
+ * copied from the anchor and lets the inserted paragraph's style decide.
257
+ */
258
+ spacing?: FolioAIParagraphSpacing | null;
265
259
  comment?: FolioAIComment;
266
260
  } | {
267
261
  id: string;
@@ -269,7 +263,8 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
269
263
  blockId: string;
270
264
  text: string;
271
265
  preserveFormatting?: boolean;
272
- styleId?: string;
266
+ /** Paragraph style to apply; `null` clears the direct style. */
267
+ styleId?: string | null;
273
268
  comment?: FolioAIComment;
274
269
  } |
275
270
  /**
@@ -464,14 +459,18 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
464
459
  * provenance: rendered with the tracked-change grammar but stripped from
465
460
  * serialized DOCX until a human accepts them. Behaves like `"tracked-changes"`
466
461
  * and covers the inline text/format operations (replaceInBlock, replaceRange,
467
- * formatRange) plus the block and table row/column structural operations
468
- * (insertAfterBlock, insertBeforeBlock, replaceBlock, deleteBlock,
462
+ * formatRange), paragraph properties, plus the block and table row/column structural
463
+ * operations (insertAfterBlock, insertBeforeBlock, replaceBlock, deleteBlock,
469
464
  * insertSignatureTable, insertTableRow, deleteTableRow, insertTableColumn,
470
465
  * deleteTableColumn). Only comment operations and cell merge/split report
471
466
  * `unsupportedMode`.
472
467
  */
473
468
  type FolioAIEditApplyMode = "direct" | "tracked-changes" | "suggested";
474
469
  type FolioAIEditSkipReason = "missingBlock" | "changedBlock" | "ambiguousFind" | "missingFind" | "unsupportedBlock" | "unsupportedMode" | "atomicBatchRejected" | "preconditionFailed" | "staleRange" | "emptyOperation" |
470
+ /** The paragraph already owns the one `w:pPrChange` OOXML permits. */
471
+ "pendingParagraphPropertyChange" |
472
+ /** The affected run already owns the one `w:rPrChange` OOXML permits. */
473
+ "pendingRunPropertyChange" |
475
474
  /**
476
475
  * The operation would not change the document — find equals
477
476
  * replace, or replaceBlock's `text` matches the live block.
@@ -506,6 +505,8 @@ type FolioAIEditAppliedOperation = {
506
505
  * fromProseDoc serialises a single id carrying both as a Word
507
506
  * "moveTo/moveFrom" pair, not an ins/del — so the two sides must
508
507
  * be distinct ids in the doc but conceptually one operation here.
508
+ * The list also includes a paragraph-property revision synthesized
509
+ * when an inserted final paragraph mark rotates to its carrier.
509
510
  * Use this list when you need to accept or reject every mark
510
511
  * belonging to this op.
511
512
  */
@@ -558,4 +559,4 @@ type FolioAIEditApplyResult = {
558
559
  normalizations?: FolioAIEditNormalization[];
559
560
  };
560
561
  //#endregion
561
- export { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockParagraphProperties, FolioAIBlockPreviewRun, FolioAIBlockTableLocation, FolioAIComment, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAIInlineFormatting, FolioAISignatureParty, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult };
562
+ export { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockParagraphProperties, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIBlockTableLocation, FolioAIComment, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIParagraphSpacing, FolioAISignatureParty, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult };
@@ -23,8 +23,11 @@
23
23
  * 3. When what survives is still too fragmented for its length, the whole
24
24
  * paragraph is one replacement ({@link isTooFragmented}).
25
25
  *
26
- * O(n*m) on token counts; past {@link MAX_WORD_DIFF_CELLS} the DP is skipped
27
- * for a single whole-string `del` + `ins` pair.
26
+ * Common affixes and unique-token anchors split the input into independent
27
+ * gaps before any quadratic work. The residual gaps share one
28
+ * {@link MAX_WORD_DIFF_CELLS} allowance per comparison or apply scope; once it
29
+ * is spent, a gap is a single `del` + `ins` pair. A standalone call owns one
30
+ * fresh scope.
28
31
  */
29
32
  type WordDiffSegment = {
30
33
  type: "equal" | "del" | "ins";
@@ -58,6 +61,18 @@ type WordDiffOptions = {
58
61
  /** Default: nothing normalized, so both strings reconstruct exactly. */
59
62
  normalization?: WordDiffNormalization;
60
63
  };
64
+ /**
65
+ * One internal comparison/apply scope. Every diff shares the same quadratic
66
+ * allowance; public standalone calls below still receive a fresh allowance.
67
+ * Not re-exported from a package entry point.
68
+ */
69
+ declare const createWordDiffSession: (options?: WordDiffOptions) => {
70
+ diff: (before: string, after: string) => WordDiffSegment[];
71
+ };
72
+ /** Attach one internal work scope without widening a caller-facing option type. */
73
+ declare const createScopedWordDiffOptions: <Options extends WordDiffOptions>(options: Options) => Options;
74
+ /** Reuse an internal scope when present; ordinary public callers get a fresh one. */
75
+ declare const wordDiffSessionFromOptions: (options: WordDiffOptions | undefined) => ReturnType<typeof createWordDiffSession>;
61
76
  declare const diffWordSegments: (before: string, after: string, options?: WordDiffOptions) => WordDiffSegment[];
62
77
  //#endregion
63
- export { WORD_DIFF_GRANULARITIES, WordDiffGranularity, WordDiffNormalization, WordDiffOptions, WordDiffSegment, diffWordSegments };
78
+ export { WORD_DIFF_GRANULARITIES, WordDiffGranularity, WordDiffNormalization, WordDiffOptions, WordDiffSegment, createScopedWordDiffOptions, createWordDiffSession, diffWordSegments, wordDiffSessionFromOptions };