@stll/folio-core 0.52.0 → 0.53.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 (307) hide show
  1. package/README.md +23 -0
  2. package/dist/ai-edits/apply.d.ts +26 -1
  3. package/dist/ai-edits/apply.js +1519 -105
  4. package/dist/ai-edits/batch-claims.d.ts +130 -0
  5. package/dist/ai-edits/batch-claims.js +244 -0
  6. package/dist/ai-edits/blockRange.js +9 -3
  7. package/dist/ai-edits/character-boundaries.d.ts +43 -0
  8. package/dist/ai-edits/character-boundaries.js +95 -0
  9. package/dist/ai-edits/clean-text.d.ts +33 -3
  10. package/dist/ai-edits/clean-text.js +52 -6
  11. package/dist/ai-edits/comment-lifecycle.d.ts +18 -0
  12. package/dist/ai-edits/comment-lifecycle.js +52 -0
  13. package/dist/ai-edits/headless.d.ts +71 -7
  14. package/dist/ai-edits/headless.js +381 -41
  15. package/dist/ai-edits/index.d.ts +2 -1
  16. package/dist/ai-edits/index.js +2 -1
  17. package/dist/ai-edits/minimal-replacement.d.ts +21 -6
  18. package/dist/ai-edits/minimal-replacement.js +134 -15
  19. package/dist/ai-edits/newListNumbering.d.ts +23 -0
  20. package/dist/ai-edits/newListNumbering.js +94 -0
  21. package/dist/ai-edits/note-references.d.ts +96 -0
  22. package/dist/ai-edits/note-references.js +139 -0
  23. package/dist/ai-edits/pending-suggestions.d.ts +79 -0
  24. package/dist/ai-edits/pending-suggestions.js +306 -0
  25. package/dist/ai-edits/read.d.ts +1 -1
  26. package/dist/ai-edits/read.js +56 -43
  27. package/dist/ai-edits/result-validation.d.ts +29 -0
  28. package/dist/ai-edits/result-validation.js +164 -0
  29. package/dist/ai-edits/snapshot.d.ts +36 -3
  30. package/dist/ai-edits/snapshot.js +177 -23
  31. package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
  32. package/dist/ai-edits/table-cell-mutations.js +4 -1
  33. package/dist/ai-edits/table-geometry.d.ts +1 -1
  34. package/dist/ai-edits/table-row-column-mutations.d.ts +38 -16
  35. package/dist/ai-edits/table-row-column-mutations.js +61 -26
  36. package/dist/ai-edits/types.d.ts +155 -16
  37. package/dist/compare/compare.d.ts +1 -1
  38. package/dist/compare/compare.js +65 -16
  39. package/dist/compare/content-alignment.js +13 -2
  40. package/dist/compare/content-types.d.ts +7 -0
  41. package/dist/compare/content.d.ts +4 -1
  42. package/dist/compare/content.js +6 -1
  43. package/dist/compare/formatting.js +2 -1
  44. package/dist/compare/inline-atoms.d.ts +21 -4
  45. package/dist/compare/inline-atoms.js +138 -16
  46. package/dist/compare/plan.js +10 -5
  47. package/dist/compare/scenario.js +14 -3
  48. package/dist/compare/section-boundary-properties.js +1 -1
  49. package/dist/compare/types.d.ts +4 -2
  50. package/dist/compare/types.js +2 -1
  51. package/dist/compare/verification.d.ts +1 -1
  52. package/dist/compare/verification.js +15 -3
  53. package/dist/controller/committedLayoutDiff.d.ts +25 -0
  54. package/dist/controller/committedLayoutDiff.js +71 -0
  55. package/dist/controller/contentControlWidgetController.d.ts +1 -1
  56. package/dist/controller/folioEditor.d.ts +1 -1
  57. package/dist/controller/fontReadiness.d.ts +70 -3
  58. package/dist/controller/fontReadiness.js +100 -10
  59. package/dist/controller/headerFooterEditorManager.js +6 -1
  60. package/dist/controller/layoutPipeline.d.ts +12 -10
  61. package/dist/controller/layoutPipeline.js +62 -9
  62. package/dist/controller/layoutRunOptions.d.ts +24 -0
  63. package/dist/controller/layoutRunOptions.js +17 -0
  64. package/dist/controller/layoutScheduler.d.ts +19 -14
  65. package/dist/controller/layoutScheduler.js +15 -12
  66. package/dist/controller/layoutSession.d.ts +26 -2
  67. package/dist/controller/layoutSession.js +1 -1
  68. package/dist/controller/noteEditorManager.js +8 -3
  69. package/dist/document-operations.d.ts +11 -2
  70. package/dist/document-operations.js +230 -21
  71. package/dist/docx/altChunk.d.ts +8 -0
  72. package/dist/docx/altChunk.js +17 -0
  73. package/dist/docx/attributeRemainder.d.ts +1 -1
  74. package/dist/docx/blockContentParser.d.ts +64 -1
  75. package/dist/docx/blockContentParser.js +17 -4
  76. package/dist/docx/blockCustomXmlShell.d.ts +7 -0
  77. package/dist/docx/blockCustomXmlShell.js +14 -0
  78. package/dist/docx/blockPlainText.js +7 -0
  79. package/dist/docx/commentAnchorIndex.js +1 -1
  80. package/dist/docx/commentRangeIntegrity.js +8 -3
  81. package/dist/docx/commentReferenceNormalization.js +1 -1
  82. package/dist/docx/commentReplyMarkers.js +20 -1
  83. package/dist/docx/compatibility.d.ts +1 -1
  84. package/dist/docx/compatibility.js +34 -13
  85. package/dist/docx/containerChildren.gen.d.ts +1 -1
  86. package/dist/docx/containerChildren.gen.js +1 -0
  87. package/dist/docx/documentParser.js +12 -12
  88. package/dist/docx/drawingIdNormalization.d.ts +3 -1
  89. package/dist/docx/drawingIdNormalization.js +6 -1
  90. package/dist/docx/ensureParaIds.js +119 -97
  91. package/dist/docx/footnoteParser.js +8 -4
  92. package/dist/docx/headerFooterParser.js +3 -3
  93. package/dist/docx/headerFooterReferenceNormalization.d.ts +20 -1
  94. package/dist/docx/headerFooterReferenceNormalization.js +52 -27
  95. package/dist/docx/hyperlinkParser.d.ts +1 -1
  96. package/dist/docx/index.d.ts +1 -1
  97. package/dist/docx/listNumberingInstances.d.ts +59 -0
  98. package/dist/docx/listNumberingInstances.js +249 -0
  99. package/dist/docx/normalizeBaseDirection.js +2 -1
  100. package/dist/docx/opaqueCarrier.d.ts +7 -0
  101. package/dist/docx/opaqueCarrier.js +38 -0
  102. package/dist/docx/packageParts.js +4 -1
  103. package/dist/docx/paragraphParser.js +91 -24
  104. package/dist/docx/paragraphPropertySource.d.ts +4 -2
  105. package/dist/docx/paragraphPropertySource.js +7 -1
  106. package/dist/docx/paragraphTraversal.js +1 -0
  107. package/dist/docx/parseWarningMessage.js +4 -1
  108. package/dist/docx/parser.js +173 -20
  109. package/dist/docx/rezip.js +27 -5
  110. package/dist/docx/sdtProperties.js +1 -1
  111. package/dist/docx/sdtPropertiesPatch.js +3 -0
  112. package/dist/docx/selectiveSave.js +16 -9
  113. package/dist/docx/selectiveXmlPatch.js +106 -37
  114. package/dist/docx/serializer/blockCustomXmlSerializer.d.ts +5 -0
  115. package/dist/docx/serializer/blockCustomXmlSerializer.js +4 -0
  116. package/dist/docx/serializer/documentSerializer.js +2 -0
  117. package/dist/docx/serializer/headerFooterSerializer.js +2 -0
  118. package/dist/docx/serializer/noteSerializer.js +3 -1
  119. package/dist/docx/serializer/paragraphSerializer.js +33 -9
  120. package/dist/docx/serializer/tableSerializer.js +25 -38
  121. package/dist/docx/server/createBilingualDocument.js +3 -3
  122. package/dist/docx/tableParser.d.ts +157 -1
  123. package/dist/docx/tableParser.js +89 -10
  124. package/dist/docx/textBoxParser.js +1 -1
  125. package/dist/docx/unzip.d.ts +2 -1
  126. package/dist/docx/unzip.js +1 -1
  127. package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
  128. package/dist/docx/wordprocessingPrefixes.js +286 -0
  129. package/dist/i18n/messages/catalogs.gen.d.ts +136 -0
  130. package/dist/i18n/messages/catalogs.gen.js +153 -17
  131. package/dist/i18n/messages/messages.gen.d.ts +8 -0
  132. package/dist/internal/compare/inline-presentation.d.ts +2 -1
  133. package/dist/internal/compare/inline-presentation.js +11 -10
  134. package/dist/internal/headlessRevisionResolutionGuard.d.ts +2 -8
  135. package/dist/internal/headlessRevisionResolutionGuard.js +2 -11
  136. package/dist/internal/indexedPositionMap.d.ts +11 -0
  137. package/dist/internal/indexedPositionMap.js +42 -0
  138. package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
  139. package/dist/internal/revisionResolutionEdits.d.ts +13 -0
  140. package/dist/internal/revisionResolutionEdits.js +19 -0
  141. package/dist/internal/revisionResolutionInline.d.ts +24 -0
  142. package/dist/internal/{headlessRevisionResolution.js → revisionResolutionInline.js} +61 -43
  143. package/dist/internal/revisionResolutionStep.d.ts +34 -0
  144. package/dist/internal/revisionResolutionStep.js +282 -0
  145. package/dist/internal/revisionResolutionTracking.d.ts +11 -0
  146. package/dist/internal/revisionResolutionTracking.js +124 -0
  147. package/dist/internal/wholeStoryRevisionResolution.d.ts +56 -0
  148. package/dist/internal/wholeStoryRevisionResolution.js +530 -0
  149. package/dist/layout-bridge/convert/markupViewFlow.d.ts +20 -0
  150. package/dist/layout-bridge/convert/markupViewFlow.js +123 -0
  151. package/dist/layout-bridge/convert/tableConversion.js +1 -1
  152. package/dist/layout-bridge/convert/toFlowBlocks.js +10 -1
  153. package/dist/layout-engine/layoutInstrumentation.d.ts +9 -1
  154. package/dist/layout-engine/layoutInstrumentation.js +4 -1
  155. package/dist/layout-engine/measure/cache.d.ts +18 -1
  156. package/dist/layout-engine/measure/cache.js +31 -1
  157. package/dist/layout-engine/measure/font-metrics.worker.js +3 -7
  158. package/dist/layout-engine/measure/measureContainer.js +7 -47
  159. package/dist/layout-engine/measure/measureHelpers.d.ts +6 -1
  160. package/dist/layout-engine/measure/measureHelpers.js +22 -2
  161. package/dist/layout-engine/measure/measureWorker.js +2 -3
  162. package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +6 -7
  163. package/dist/layout-engine/measure/measureWorkerProtocol.js +1 -2
  164. package/dist/layout-engine/types.d.ts +6 -0
  165. package/dist/layout-painter/renderPage.js +1 -0
  166. package/dist/layout-painter/renderParagraph.js +1 -1
  167. package/dist/managers/ContextMenuManager.js +5 -2
  168. package/dist/managers/types.d.ts +3 -0
  169. package/dist/markdown/fromMarkdown.js +2 -1
  170. package/dist/markdown/internals.d.ts +11 -1
  171. package/dist/markdown/internals.js +24 -3
  172. package/dist/markdown/renderBlock.js +39 -9
  173. package/dist/markdown/renderParagraph.d.ts +13 -1
  174. package/dist/markdown/renderParagraph.js +85 -38
  175. package/dist/markdown/renderRuns.js +3 -10
  176. package/dist/markdown/renderTable.js +24 -12
  177. package/dist/markdown/trailers.js +2 -2
  178. package/dist/markdown/types.d.ts +29 -7
  179. package/dist/paged-layout/incrementalMeasure.d.ts +1 -2
  180. package/dist/paged-layout/incrementalMeasure.js +1 -9
  181. package/dist/paged-layout/transactionDirtyRange.d.ts +1 -3
  182. package/dist/paged-layout/transactionDirtyRange.js +29 -41
  183. package/dist/panel-layout.d.ts +83 -0
  184. package/dist/panel-layout.js +96 -0
  185. package/dist/prosemirror/anchoredTextBoxes.d.ts +37 -0
  186. package/dist/prosemirror/anchoredTextBoxes.js +156 -0
  187. package/dist/prosemirror/attrs/index.d.ts +6 -2
  188. package/dist/prosemirror/attrs/index.js +172 -1
  189. package/dist/prosemirror/commands/comments.d.ts +7 -8
  190. package/dist/prosemirror/commands/comments.js +241 -207
  191. package/dist/prosemirror/commands/contentControls.d.ts +1 -1
  192. package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
  193. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  194. package/dist/prosemirror/commands/index.d.ts +2 -2
  195. package/dist/prosemirror/commands/index.js +2 -2
  196. package/dist/prosemirror/commands/paragraph.d.ts +7 -1
  197. package/dist/prosemirror/commands/paragraph.js +9 -1
  198. package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +13 -0
  199. package/dist/prosemirror/commands/paragraphBookmarkJoin.js +22 -0
  200. package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
  201. package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +40 -0
  202. package/dist/prosemirror/commands/resolveAllTableChanges.js +615 -0
  203. package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +15 -0
  204. package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +46 -0
  205. package/dist/prosemirror/commands/resolveParagraphProperties.d.ts +16 -0
  206. package/dist/prosemirror/commands/resolveParagraphProperties.js +59 -0
  207. package/dist/prosemirror/commands/sectionBreak.js +2 -1
  208. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +8 -2
  209. package/dist/prosemirror/commands/tableCellMergeResolution.js +1 -1
  210. package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
  211. package/dist/prosemirror/conversion/fromProseDoc.js +181 -31
  212. package/dist/prosemirror/conversion/toProseDoc.js +39 -4
  213. package/dist/prosemirror/emptyFieldResultRuns.d.ts +18 -0
  214. package/dist/prosemirror/emptyFieldResultRuns.js +33 -0
  215. package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
  216. package/dist/prosemirror/extensions/ExtensionManager.js +3 -1
  217. package/dist/prosemirror/extensions/StarterKit.js +3 -1
  218. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  219. package/dist/prosemirror/extensions/core/ParagraphExtension.js +12 -0
  220. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -0
  221. package/dist/prosemirror/extensions/features/ListExtension.js +161 -123
  222. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +19 -2
  223. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +33 -20
  224. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +31 -2
  225. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +270 -99
  226. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +3 -2
  227. package/dist/prosemirror/extensions/features/pasteCleanup.js +2 -1
  228. package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +12 -0
  229. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +126 -0
  230. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +21 -5
  231. package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
  232. package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
  233. package/dist/prosemirror/extensions/marks/markUtils.d.ts +7 -2
  234. package/dist/prosemirror/extensions/marks/markUtils.js +8 -2
  235. package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +10 -0
  236. package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +35 -0
  237. package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.d.ts +6 -0
  238. package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.js +52 -0
  239. package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +3 -3
  240. package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
  241. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +4 -1
  242. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
  243. package/dist/prosemirror/extensions/nodes/TableExtension.js +19 -18
  244. package/dist/prosemirror/extensions/types.d.ts +4 -1
  245. package/dist/prosemirror/findReplaceSelection.js +1 -1
  246. package/dist/prosemirror/index.d.ts +3 -2
  247. package/dist/prosemirror/index.js +3 -2
  248. package/dist/prosemirror/indexedNodeLookup.d.ts +17 -0
  249. package/dist/prosemirror/indexedNodeLookup.js +103 -0
  250. package/dist/prosemirror/listAutoformatMarkers.d.ts +19 -0
  251. package/dist/prosemirror/listAutoformatMarkers.js +98 -0
  252. package/dist/prosemirror/listInstanceReferences.d.ts +12 -0
  253. package/dist/prosemirror/listInstanceReferences.js +72 -0
  254. package/dist/prosemirror/listLabels.d.ts +24 -0
  255. package/dist/prosemirror/listLabels.js +111 -0
  256. package/dist/prosemirror/listNumbering.d.ts +110 -0
  257. package/dist/prosemirror/listNumbering.js +345 -0
  258. package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
  259. package/dist/prosemirror/listRenderingAttrs.js +8 -1
  260. package/dist/prosemirror/markupViewProjection.d.ts +95 -0
  261. package/dist/prosemirror/markupViewProjection.js +83 -0
  262. package/dist/prosemirror/numberingAttr.d.ts +9 -1
  263. package/dist/prosemirror/numberingAttr.js +9 -1
  264. package/dist/prosemirror/outlineLevelAttr.js +1 -1
  265. package/dist/prosemirror/paragraphIndentation.d.ts +10 -1
  266. package/dist/prosemirror/paragraphIndentation.js +29 -7
  267. package/dist/prosemirror/paragraphMarkJoin.d.ts +19 -0
  268. package/dist/prosemirror/paragraphMarkJoin.js +24 -0
  269. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
  270. package/dist/prosemirror/plugins/documentNumbering.d.ts +27 -1
  271. package/dist/prosemirror/plugins/documentNumbering.js +97 -11
  272. package/dist/prosemirror/plugins/documentStyles.d.ts +10 -1
  273. package/dist/prosemirror/plugins/documentStyles.js +14 -1
  274. package/dist/prosemirror/plugins/suggestionMode.d.ts +16 -2
  275. package/dist/prosemirror/plugins/suggestionMode.js +116 -52
  276. package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
  277. package/dist/prosemirror/plugins/transactionInvariants.d.ts +32 -0
  278. package/dist/prosemirror/plugins/transactionInvariants.js +86 -0
  279. package/dist/prosemirror/positionSweep.d.ts +24 -0
  280. package/dist/prosemirror/positionSweep.js +222 -0
  281. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
  282. package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
  283. package/dist/prosemirror/replacedAnnotations.d.ts +33 -1
  284. package/dist/prosemirror/replacedAnnotations.js +170 -1
  285. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
  286. package/dist/prosemirror/schema/index.d.ts +2 -2
  287. package/dist/prosemirror/schema/index.js +3 -0
  288. package/dist/prosemirror/schema/nodes.d.ts +42 -11
  289. package/dist/prosemirror/sectionMarkEdits.d.ts +20 -0
  290. package/dist/prosemirror/sectionMarkEdits.js +59 -0
  291. package/dist/prosemirror/storyListNumbering.d.ts +17 -0
  292. package/dist/prosemirror/storyListNumbering.js +102 -0
  293. package/dist/prosemirror/tableGridMutation.d.ts +48 -2
  294. package/dist/prosemirror/tableGridMutation.js +106 -1
  295. package/dist/prosemirror/validation.js +5 -1
  296. package/dist/redline.js +93 -9
  297. package/dist/render-dom/BodySelectionOverlay.d.ts +4 -1
  298. package/dist/render-dom/BodySelectionOverlay.js +3 -2
  299. package/dist/utils/findReplace.js +2 -2
  300. package/dist/utils/mergeDocumentContent.js +1 -1
  301. package/dist/utils/noteReferenceLabels.d.ts +36 -0
  302. package/dist/utils/noteReferenceLabels.js +32 -0
  303. package/dist/utils/replaceText.js +1 -1
  304. package/dist/version-comparison.d.ts +1 -0
  305. package/dist/version-comparison.js +1 -0
  306. package/package.json +3 -2
  307. package/dist/internal/headlessRevisionResolution.d.ts +0 -23
@@ -1,7 +1,7 @@
1
1
  import { TableStructureRevision } from "./table-template.js";
2
2
  import { TableRowTarget } from "./table-targets.js";
3
- import { Transaction } from "prosemirror-state";
4
3
  import { Node } from "prosemirror-model";
4
+ import { Transaction } from "prosemirror-state";
5
5
  //#region src/ai-edits/table-row-column-mutations.d.ts
6
6
  type TableRowInsertion = {
7
7
  tableStart: number;
@@ -10,14 +10,13 @@ type TableRowInsertion = {
10
10
  cells: readonly Node[];
11
11
  rowspanUpdates: readonly number[];
12
12
  /**
13
- * The table's column count, which is not `cells.length`. One cell can occupy
14
- * several columns (a `colspan`), and one column can have no cell in this row
15
- * at all (a `rowspan` from a row above reaches down into it).
13
+ * The table's column count, which is not `cells.length`: a column can have
14
+ * no cell in this row at all, when a `rowspan` from a row above reaches down
15
+ * through it. A template row has to span all of it.
16
16
  *
17
- * It is what `cellTexts` is SIZED against — the most cells any row of this
18
- * table could have — while the texts themselves fill the new row's cells in
19
- * order. Sizing against `cells.length` refused a row the table can hold
20
- * whenever a span made this row narrower than the table.
17
+ * `cellTexts` is sized against `cells.length` instead, because the nth text
18
+ * fills the nth cell the row has: a text past the last one has nowhere to
19
+ * go, and is refused rather than dropped.
21
20
  */
22
21
  columnCount: number;
23
22
  };
@@ -34,6 +33,27 @@ type TableRowColumnMutationResult = {
34
33
  } | {
35
34
  type: "unsupported";
36
35
  };
36
+ type TableColumnInsertionResult = TableRowColumnMutationResult | {
37
+ type: "payloadDoesNotFit";
38
+ message: string;
39
+ };
40
+ type DescribeUnplacedCellTextsOptions = {
41
+ cellTexts: readonly string[] | undefined;
42
+ /** Cells the new row or column actually has. */
43
+ capacity: number;
44
+ target: "row" | "column";
45
+ };
46
+ /**
47
+ * Name the `cellTexts` a new row or column has no cell for, or `null` when
48
+ * every one of them has a place.
49
+ *
50
+ * A row is narrower than the table where a vertical merge from above reaches
51
+ * through it, and a column is shorter than the table where a horizontal merge
52
+ * spans across it; the merged cell takes that slot, so the texts are counted
53
+ * against the cells that are really built. Anything past the last one would
54
+ * be dropped by an operation reported as applied.
55
+ */
56
+ declare const describeUnplacedCellTexts: ({ cellTexts, capacity, target }: DescribeUnplacedCellTextsOptions) => string | null;
37
57
  declare const getTableColumnCoordinateKey: ({ tablePosition, columnIndex }: TableColumnInsertion) => string;
38
58
  type FindTableColumnInsertionOptions = {
39
59
  doc: Node;
@@ -75,12 +95,14 @@ type MarkTableRowContentOptions = {
75
95
  * accept and an inserted row's text on reject when the row marker stands
76
96
  * alone, so the two must always be written together.
77
97
  *
78
- * Two kinds of run stay unmarked. A run that already carries a revision keeps
79
- * it, because OOXML nests `w:ins`/`w:del` but the editable model holds one
80
- * wrapper per run and overwriting would drop the earlier revision. A cell that
81
- * spans into the row below survives the deletion — `removeRow` moves it down
82
- * and shortens its span — so marking its text would delete content the
83
- * accepted document must still hold.
98
+ * Two kinds of run stay unmarked. A run that already carries a revision of the
99
+ * same kind keeps it, because overwriting would drop the earlier revision; a
100
+ * pending insertion inside a deleted row is marked deleted as well (`w:ins >
101
+ * w:del`), as `deleteBlock` marks one inside a deleted paragraph, so every
102
+ * reader leaves it out with the rest of the row. A cell that spans into the
103
+ * row below survives the deletion — `removeTableRow` moves it down and
104
+ * shortens its span — so marking its text would delete content the accepted
105
+ * document must still hold.
84
106
  */
85
107
  declare const markTableRowContent: ({ tr, rowPosition, kind, revision }: MarkTableRowContentOptions) => void;
86
108
  type ApplyTableColumnInsertionOptions = {
@@ -89,7 +111,7 @@ type ApplyTableColumnInsertionOptions = {
89
111
  cellTexts: readonly string[] | undefined;
90
112
  revision: TableStructureRevision | null;
91
113
  };
92
- declare const applyTableColumnInsertion: ({ tr, insertion, cellTexts, revision }: ApplyTableColumnInsertionOptions) => TableRowColumnMutationResult;
114
+ declare const applyTableColumnInsertion: ({ tr, insertion, cellTexts, revision }: ApplyTableColumnInsertionOptions) => TableColumnInsertionResult;
93
115
  type ApplyTableColumnDeletionOptions = {
94
116
  tr: Transaction;
95
117
  deletion: TableColumnDeletion;
@@ -116,4 +138,4 @@ declare const applyTableRowDeletion: ({ tr, deletion, revision }: ApplyTableRowD
116
138
  */
117
139
  declare const splitCellParagraphTexts: (text: string) => string[];
118
140
  //#endregion
119
- export { MarkTableRowContentOptions, TableColumnDeletion, TableColumnInsertion, TableRowDeletion, TableRowInsertion, applyTableColumnDeletion, applyTableColumnInsertion, applyTableRowDeletion, applyTableRowInsertion, findTableColumnInsertion, findTableRowInsertion, getTableColumnCoordinateKey, markTableRowContent, splitCellParagraphTexts };
141
+ export { MarkTableRowContentOptions, TableColumnDeletion, TableColumnInsertion, TableRowDeletion, TableRowInsertion, applyTableColumnDeletion, applyTableColumnInsertion, applyTableRowDeletion, applyTableRowInsertion, describeUnplacedCellTexts, findTableColumnInsertion, findTableRowInsertion, getTableColumnCoordinateKey, markTableRowContent, splitCellParagraphTexts };
@@ -1,10 +1,27 @@
1
1
  import { markStructuralChange } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
2
- import { reconcileTableGridAfterColumnRemoval } from "../prosemirror/tableGridMutation.js";
2
+ import { reconcileTableGridAfterColumnInsertion, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCells, removeTableRow } from "../prosemirror/tableGridMutation.js";
3
3
  import { stripBlockIdentityAttrs } from "./block-identity.js";
4
4
  import { findEnclosingTableCell, findEnclosingTableRow } from "./table-targets.js";
5
5
  import { tableRowFromTemplate } from "./table-template.js";
6
- import { TableMap, columnIsHeader, removeColumn, removeRow, rowIsHeader, tableNodeTypes } from "prosemirror-tables";
6
+ import { TableMap, columnIsHeader, removeColumn, rowIsHeader, tableNodeTypes } from "prosemirror-tables";
7
7
  //#region src/ai-edits/table-row-column-mutations.ts
8
+ const UNPLACED_TEXT_PREVIEW_LENGTH = 40;
9
+ const previewCellText = (text) => JSON.stringify(text.length > UNPLACED_TEXT_PREVIEW_LENGTH ? `${text.slice(0, UNPLACED_TEXT_PREVIEW_LENGTH)}…` : text);
10
+ /**
11
+ * Name the `cellTexts` a new row or column has no cell for, or `null` when
12
+ * every one of them has a place.
13
+ *
14
+ * A row is narrower than the table where a vertical merge from above reaches
15
+ * through it, and a column is shorter than the table where a horizontal merge
16
+ * spans across it; the merged cell takes that slot, so the texts are counted
17
+ * against the cells that are really built. Anything past the last one would
18
+ * be dropped by an operation reported as applied.
19
+ */
20
+ const describeUnplacedCellTexts = ({ cellTexts, capacity, target }) => {
21
+ if (cellTexts === void 0 || cellTexts.length <= capacity) return null;
22
+ const unplaced = cellTexts.slice(capacity).map((text, offset) => `cellTexts[${capacity + offset}] ${previewCellText(text)}`);
23
+ return `the new ${target} has ${capacity} cell${capacity === 1 ? "" : "s"} (${target === "row" ? "a merged cell from the row above reaches through the rest" : "a merged cell spans across the rest"}), so ${unplaced.join(", ")} would not be placed`;
24
+ };
8
25
  const getTableColumnCoordinateKey = ({ tablePosition, columnIndex }) => `${tablePosition}:${columnIndex}`;
9
26
  const findTableColumnInsertion = ({ doc, blockFrom, position }) => {
10
27
  const target = findEnclosingTableCell(doc, blockFrom);
@@ -28,7 +45,6 @@ const findTableRowInsertion = ({ doc, blockFrom, position }) => {
28
45
  });
29
46
  };
30
47
  const applyTableRowInsertion = ({ tr, insertion, cellTexts, revision, template }) => {
31
- if (revision && insertion.rowspanUpdates.length > 0) return { type: "unsupported" };
32
48
  const liveRowspanUpdates = [];
33
49
  for (const updatePosition of insertion.rowspanUpdates) {
34
50
  const cellPosition = insertion.tableStart + updatePosition;
@@ -46,7 +62,7 @@ const applyTableRowInsertion = ({ tr, insertion, cellTexts, revision, template }
46
62
  rowspan: update.rowspan + 1
47
63
  });
48
64
  const rowAttrs = revision ? { trIns: revision } : null;
49
- const templated = template === void 0 ? null : tableRowFromTemplate({
65
+ const templated = template === void 0 || insertion.rowspanUpdates.length > 0 ? null : tableRowFromTemplate({
50
66
  template,
51
67
  columnCount: insertion.columnCount
52
68
  });
@@ -73,12 +89,14 @@ const applyTableRowInsertion = ({ tr, insertion, cellTexts, revision, template }
73
89
  * accept and an inserted row's text on reject when the row marker stands
74
90
  * alone, so the two must always be written together.
75
91
  *
76
- * Two kinds of run stay unmarked. A run that already carries a revision keeps
77
- * it, because OOXML nests `w:ins`/`w:del` but the editable model holds one
78
- * wrapper per run and overwriting would drop the earlier revision. A cell that
79
- * spans into the row below survives the deletion — `removeRow` moves it down
80
- * and shortens its span — so marking its text would delete content the
81
- * accepted document must still hold.
92
+ * Two kinds of run stay unmarked. A run that already carries a revision of the
93
+ * same kind keeps it, because overwriting would drop the earlier revision; a
94
+ * pending insertion inside a deleted row is marked deleted as well (`w:ins >
95
+ * w:del`), as `deleteBlock` marks one inside a deleted paragraph, so every
96
+ * reader leaves it out with the rest of the row. A cell that spans into the
97
+ * row below survives the deletion — `removeTableRow` moves it down and
98
+ * shortens its span — so marking its text would delete content the accepted
99
+ * document must still hold.
82
100
  */
83
101
  const markTableRowContent = ({ tr, rowPosition, kind, revision }) => {
84
102
  const row = tr.doc.nodeAt(rowPosition);
@@ -103,7 +121,7 @@ const markTableRowContent = ({ tr, rowPosition, kind, revision }) => {
103
121
  if (!node.isInline) return true;
104
122
  if (node.marks.some(isTrackedChangeMark)) {
105
123
  wholeRowMarkable = false;
106
- return false;
124
+ if (kind === "insertion" || node.marks.some(({ type }) => type.name === "deletion")) return false;
107
125
  }
108
126
  const from = contentFrom + offset;
109
127
  markable.push({
@@ -127,8 +145,20 @@ const applyTableColumnInsertion = ({ tr, insertion, cellTexts, revision }) => {
127
145
  const tablePosition = tr.mapping.map(insertion.tablePosition, 1);
128
146
  const table = tr.doc.nodeAt(tablePosition);
129
147
  if (!table || table.type.spec["tableRole"] !== "table") return { type: "unsupported" };
148
+ const map = TableMap.get(table);
149
+ if (insertion.columnIndex >= 0 && insertion.columnIndex <= map.width) {
150
+ const overflow = describeUnplacedCellTexts({
151
+ cellTexts,
152
+ capacity: getInsertedPhysicalColumnRows(map, insertion.columnIndex).length,
153
+ target: "column"
154
+ });
155
+ if (overflow !== null) return {
156
+ type: "payloadDoesNotFit",
157
+ message: overflow
158
+ };
159
+ }
130
160
  const actions = buildTableColumnInsertionActions({
131
- map: TableMap.get(table),
161
+ map,
132
162
  table,
133
163
  columnIndex: insertion.columnIndex,
134
164
  cellTexts
@@ -150,6 +180,12 @@ const applyTableColumnInsertion = ({ tr, insertion, cellTexts, revision }) => {
150
180
  }, action.cell.content) : action.cell;
151
181
  tr.insert(position, cell);
152
182
  }
183
+ reconcileTableGridAfterColumnInsertion({
184
+ tr,
185
+ tablePosition,
186
+ previousTable: table,
187
+ insertedColumn: insertion.columnIndex
188
+ });
153
189
  return applied(tr, revision);
154
190
  };
155
191
  const applyTableColumnDeletion = ({ tr, deletion, insertedColumnCount, revision }) => {
@@ -196,6 +232,7 @@ const applyTableColumnDeletion = ({ tr, deletion, insertedColumnCount, revision
196
232
  previousTable: table,
197
233
  removedColumn: columnIndex
198
234
  });
235
+ removeRowsWithoutCells(tr, tablePosition);
199
236
  return applied(tr, null);
200
237
  };
201
238
  const applyTableRowDeletion = ({ tr, deletion, revision }) => {
@@ -213,26 +250,23 @@ const applyTableRowDeletion = ({ tr, deletion, revision }) => {
213
250
  markStructuralChange(tr);
214
251
  return applied(tr, revision);
215
252
  }
216
- const table = tr.doc.nodeAt(deletion.tablePosition);
217
- if (!table || table.type.spec["tableRole"] !== "table" || deletion.rowIndex >= table.childCount) return { type: "unsupported" };
253
+ const at = tr.doc.resolve(tr.mapping.map(deletion.rowPosition));
254
+ const table = at.parent;
255
+ if (table.type.spec["tableRole"] !== "table" || at.nodeAfter?.type.spec["tableRole"] !== "row") return { type: "unsupported" };
256
+ const tablePosition = at.before();
218
257
  if (table.childCount === 1) {
219
258
  const transaction = deleteTableNode({
220
259
  tr,
221
- tablePosition: deletion.tablePosition,
260
+ tablePosition,
222
261
  table
223
262
  });
224
263
  return transaction ? applied(transaction, null) : { type: "unsupported" };
225
264
  }
226
- const map = TableMap.get(table);
227
- removeRow(tr, {
228
- map,
265
+ removeTableRow(tr, {
266
+ map: TableMap.get(table),
229
267
  table,
230
- tableStart: deletion.tableStart,
231
- left: 0,
232
- top: deletion.rowIndex,
233
- right: map.width,
234
- bottom: deletion.rowIndex + 1
235
- }, deletion.rowIndex);
268
+ tableStart: at.start()
269
+ }, at.index());
236
270
  return applied(tr, null);
237
271
  };
238
272
  const applied = (transaction, revision) => ({
@@ -302,7 +336,8 @@ const splitCellParagraphTexts = (text) => text.split(CELL_LINE_BREAK_PATTERN);
302
336
  * Fill the new row's cells from `cellTexts`, in order: the nth text goes in
303
337
  * the nth cell the row actually has, which is how a caller reading the row
304
338
  * through the block snapshot counts them (`table.cellIndex`). Cells the caller
305
- * did not name stay empty.
339
+ * did not name stay empty. The resolver has already refused more texts than
340
+ * cells ({@link describeUnplacedCellTexts}).
306
341
  */
307
342
  const populateTableRow = (row, cellTexts) => {
308
343
  if (cellTexts === void 0) return row;
@@ -404,4 +439,4 @@ const getTableColumnDeletionCellPositions = ({ map, table, columnIndex }) => {
404
439
  return [...positions];
405
440
  };
406
441
  //#endregion
407
- export { applyTableColumnDeletion, applyTableColumnInsertion, applyTableRowDeletion, applyTableRowInsertion, findTableColumnInsertion, findTableRowInsertion, getTableColumnCoordinateKey, markTableRowContent, splitCellParagraphTexts };
442
+ export { applyTableColumnDeletion, applyTableColumnInsertion, applyTableRowDeletion, applyTableRowInsertion, describeUnplacedCellTexts, findTableColumnInsertion, findTableRowInsertion, getTableColumnCoordinateKey, markTableRowContent, splitCellParagraphTexts };
@@ -1,7 +1,8 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
  import { FolioContentBlock, FolioContentInlineBooleanProperty, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentListReference, FolioContentParagraphIndentation, FolioContentParagraphKind, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentTableLocation } from "../compare/content-types.js";
3
+ import { ListKind } from "../docx/listNumberingInstances.js";
3
4
  //#region src/ai-edits/types.d.ts
4
- type FolioAIBlockKind = FolioContentParagraphKind;
5
+ type FolioAIBlockKind = FolioContentParagraphKind | "diagnostic";
5
6
  /** Boolean run properties supported by snapshots and range-formatting mutations. */
6
7
  type FolioAIInlineBooleanProperty = FolioContentInlineBooleanProperty;
7
8
  type FolioAIInlineFormatting = FolioContentInlineFormatting;
@@ -12,15 +13,28 @@ type FolioAIInlineFormatting = FolioContentInlineFormatting;
12
13
  type FolioAIInlineFormattingPatch = FolioContentInlineFormattingPatch;
13
14
  type FolioAIBlockPreviewRun = FolioContentRun;
14
15
  /**
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.
16
+ * Inline structure inside a block's clean text.
17
+ *
18
+ * `pageBreak` is zero-width at one clean-text boundary and always represents
19
+ * an authored `<w:br w:type="page"/>`; an omitted `clear` remains distinct from
20
+ * any explicit value even though it does not affect layout for this break type.
21
+ *
22
+ * `noteReference` is a footnote or endnote reference, which the text shows as
23
+ * its marker (`[^1]` for the first footnote, `[^e1]` for the first endnote —
24
+ * the numbering the Markdown export uses) over `length` characters from
25
+ * `offset`. The marker is structure, not text: a range may not cut into it,
26
+ * and a text edit that would rewrite or remove it is refused
27
+ * (`protectedReference`).
19
28
  */
20
29
  type FolioAIBlockStructuralBoundary = {
21
30
  type: "pageBreak";
22
31
  offset: number;
23
32
  clear?: document_d_exports.BreakContent["clear"];
33
+ } | {
34
+ type: "noteReference";
35
+ noteType: "footnote" | "endnote";
36
+ offset: number;
37
+ length: number;
24
38
  };
25
39
  /**
26
40
  * Where a block sits inside its innermost enclosing table. Every index is
@@ -33,6 +47,11 @@ type FolioAIBlockStructuralBoundary = {
33
47
  type FolioAIBlockTableLocation = FolioContentTableLocation;
34
48
  type FolioAIBlock = FolioContentBlock<FolioAIBlockKind> & {
35
49
  structuralBoundaries?: readonly FolioAIBlockStructuralBoundary[];
50
+ /** Present on a read-only block that reports preserved content Folio cannot interpret. */
51
+ diagnostic?: {
52
+ type: "opaqueCarrier";
53
+ carrier: string;
54
+ };
36
55
  };
37
56
  /**
38
57
  * The complete modeled attribute set of one direct `w:pPr/w:spacing` child.
@@ -43,6 +62,22 @@ type FolioAIParagraphSpacing = FolioContentParagraphSpacing;
43
62
  /** The complete modeled attribute set of one direct `w:pPr/w:ind` child. */
44
63
  type FolioAIParagraphIndentation = FolioContentParagraphIndentation;
45
64
  type FolioAIListReference = FolioContentListReference;
65
+ /** The kinds of list an operation can start. */
66
+ type FolioAIListKind = ListKind;
67
+ /**
68
+ * Start a new list: a numbering instance of `kind`, defined for the
69
+ * operation, with its paragraphs at `level` (zero-based, default 0). Every
70
+ * paragraph one operation numbers this way joins the same new list; separate
71
+ * operations start separate lists. A package without a numbering part gets
72
+ * one.
73
+ */
74
+ type FolioAINewListReference = {
75
+ start: "new";
76
+ kind: FolioAIListKind;
77
+ level?: number;
78
+ };
79
+ /** An existing numbering instance and level, or a new list. */
80
+ type FolioAIListNumbering = FolioAIListReference | FolioAINewListReference;
46
81
  /** Which paragraphs split from one insertion's `text` receive its paragraph formatting. */
47
82
  type FolioAIInsertFormattingScope = "firstParagraph" | "allParagraphs";
48
83
  /**
@@ -53,13 +88,15 @@ type FolioAIInsertFormattingScope = "firstParagraph" | "allParagraphs";
53
88
  type FolioAIBlockParagraphProperties = {
54
89
  /** `w:pStyle`. `null` clears the style back to the default. */
55
90
  styleId?: string | null;
91
+ /** Direct `w:outlineLvl`. `null` restores style inheritance. */
92
+ outlineLevel?: document_d_exports.OutlineLevel | null;
56
93
  /**
57
94
  * `w:numPr/w:ilvl`, zero-based. `null` removes numbering unless `numbering`
58
95
  * supplies a concrete instance; together they retain that instance without
59
96
  * an authored level.
60
97
  */
61
98
  listLevel?: number | null;
62
- numbering?: FolioAIListReference | null;
99
+ numbering?: FolioAIListNumbering | null;
63
100
  /** Direct `w:jc`. `null` clears the override and restores style inheritance. */
64
101
  alignment?: document_d_exports.ParagraphAlignment | null;
65
102
  /** Direct `w:spacing` attributes. `null` removes the whole direct child. */
@@ -234,8 +271,8 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
234
271
  /**
235
272
  * Which paragraphs split from `text` receive the operation's
236
273
  * paragraph formatting: the inherited anchor formatting plus
237
- * `styleId`, `listLevel`, `numbering`, `alignment`, `spacing` and
238
- * `indentation`. `"firstParagraph"` (the default) formats the first
274
+ * `styleId`, `outlineLevel`, `listLevel`, `numbering`, `alignment`,
275
+ * `spacing` and `indentation`. `"firstParagraph"` (the default) formats the first
239
276
  * and leaves the rest as body paragraphs, for a heading followed by
240
277
  * its body. `"allParagraphs"` formats every paragraph alike, for
241
278
  * several list items in one operation. `pageBreakBefore` and
@@ -270,6 +307,13 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
270
307
  * inheritance alone cannot say.
271
308
  */
272
309
  styleId?: string | null;
310
+ /**
311
+ * Direct `w:outlineLvl` for the inserted block. Without it the
312
+ * inserted paragraph keeps the level the anchor states itself, so a
313
+ * body paragraph inserted beside a heading that states its level
314
+ * becomes a heading. `null` clears it and lets the style decide.
315
+ */
316
+ outlineLevel?: document_d_exports.OutlineLevel | null;
273
317
  /**
274
318
  * Override `w:numPr/w:ilvl` on the inserted block, keeping the
275
319
  * anchor's `w:numId`. Without it the inserted paragraph takes the
@@ -279,7 +323,7 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
279
323
  * they retain that instance without an authored level.
280
324
  */
281
325
  listLevel?: number | null;
282
- numbering?: FolioAIListReference | null;
326
+ numbering?: FolioAIListNumbering | null;
283
327
  /**
284
328
  * Direct `w:jc` for the inserted block. `null` clears alignment copied
285
329
  * from the anchor and lets the inserted paragraph's style decide.
@@ -456,10 +500,12 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
456
500
  * Initial text for each cell of the new row, in order — the same order
457
501
  * a block's `table.cellIndex` counts. Cells left unnamed stay empty.
458
502
  *
459
- * Sized against the table's COLUMN count, which is the most cells any
460
- * row of it could have: more texts than that is refused rather than
461
- * silently truncated, and fewer is not, so a row the table can hold is
462
- * no longer refused because a span makes it narrower than the table.
503
+ * Sized against the cells the new row really has, which is fewer than
504
+ * the table's columns where a vertical merge from the row above
505
+ * reaches through the insertion point (the merge grows through the
506
+ * new row and keeps its column). More texts than cells is refused as
507
+ * `payloadDoesNotFit`, naming the texts with no cell, before anything
508
+ * is written; fewer leaves the remaining cells empty.
463
509
  *
464
510
  * A line break in a cell's text starts a new paragraph in that cell,
465
511
  * as in `insertTable`.
@@ -476,7 +522,11 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
476
522
  /** Stable paragraph anchor inside the cell that receives the new sibling column. */
477
523
  blockId: string;
478
524
  position?: "after" | "before";
479
- /** Initial text for newly created physical cells in row order. */
525
+ /**
526
+ * Initial text for newly created physical cells in row order. A
527
+ * horizontal merge the new column crosses widens instead of taking a
528
+ * cell, so more texts than new cells is refused as `payloadDoesNotFit`.
529
+ */
480
530
  cellTexts?: string[];
481
531
  } | {
482
532
  id: string;
@@ -539,7 +589,74 @@ type FolioAIEditSkipReason = "missingBlock" | "changedBlock" | "ambiguousFind" |
539
589
  * no entity to attach suggestions to); the operation was neither applied
540
590
  * nor queued.
541
591
  */
542
- "documentNotEditable";
592
+ "documentNotEditable" |
593
+ /**
594
+ * The operation supplies more values than its target can hold, so applying
595
+ * it would drop some of them: an `insertTableRow` whose `cellTexts` outnumber
596
+ * the cells the new row has (a vertical merge crossing the insertion point
597
+ * extends through the new row and takes a column away from it), or an
598
+ * `insertTableColumn` whose `cellTexts` outnumber the cells the new column
599
+ * has. Nothing was applied; `message` names the values that do not fit.
600
+ * Supply fewer values, or anchor the operation where the table has room.
601
+ */
602
+ "payloadDoesNotFit" |
603
+ /**
604
+ * An earlier operation of the same batch already claims this operation's
605
+ * target: it deletes, rewrites, splits or merges the block this one edits,
606
+ * or edits an overlapping stretch of its text. Operations of one batch all
607
+ * address the document as it was read, so this one would have landed on
608
+ * positions the other had moved. Nothing of it was applied; re-read the
609
+ * document after the batch and send it again, on its own.
610
+ */
611
+ "overlappingOperation" |
612
+ /**
613
+ * An offset of the operation falls inside one character: between the two
614
+ * UTF-16 halves of a surrogate pair (an emoji, a character outside the
615
+ * Basic Multilingual Plane), or — for an operation that changes text or
616
+ * breaks a paragraph — inside a grapheme cluster (a letter and its combining
617
+ * marks, an emoji sequence joined with zero-width joiners, a flag). Text cut
618
+ * there cannot be written back whole. Nothing was applied; move the offset
619
+ * to the boundary before or after the character.
620
+ */
621
+ "splitsCharacter" |
622
+ /**
623
+ * The text change would rewrite or remove a footnote or endnote reference
624
+ * (the `[^1]` / `[^e1]` markers the text shows), or write a marker-shaped
625
+ * string of its own. A reference is structure, not text: keep each marker
626
+ * the match covers in the replacement, in order, or match only the prose
627
+ * beside it.
628
+ */
629
+ "protectedReference" |
630
+ /**
631
+ * The operation names a paragraph style (`styleId`) the document does not
632
+ * define, or one defined as a table, character or numbering style. Nothing
633
+ * was applied: such a `w:pStyle` confers no formatting, so the paragraph
634
+ * would keep its body look. Use a paragraph style the document defines, or
635
+ * `null` to clear the style.
636
+ */
637
+ "missingStyle" |
638
+ /**
639
+ * The operation names a numbering instance (`numbering.numId`) the document
640
+ * does not define. Nothing was applied: a paragraph referencing a missing
641
+ * `w:num` cannot be saved. Re-read the document and use an instance it
642
+ * defines, or clear the numbering.
643
+ */
644
+ "missingNumbering" |
645
+ /**
646
+ * Applying the operation would have left a document that cannot be saved:
647
+ * the save-time model validator rejected the result. Nothing from the
648
+ * operation was applied; `message` carries the validator's path and reason.
649
+ */
650
+ "invalidResult" |
651
+ /**
652
+ * The block is pending deletion: a tracked change deletes its text and its
653
+ * paragraph mark, or the table row or cell holding it, so a reader lists it
654
+ * as a blank block and accepting removes it. Nothing was applied: text
655
+ * written there would join the next paragraph, or go with the row, once the
656
+ * deletion is accepted. Reject that deletion first, or insert a new block
657
+ * next to it.
658
+ */
659
+ "pendingDeletion";
543
660
  type FolioAIEditAppliedOperation = {
544
661
  id: string;
545
662
  commentId?: number;
@@ -572,6 +689,15 @@ type FolioAIEditAppliedOperation = {
572
689
  type FolioAIEditSkippedOperation = {
573
690
  id: string;
574
691
  reason: FolioAIEditSkipReason;
692
+ /**
693
+ * What exactly was wrong when the reason alone does not say: the values a
694
+ * `payloadDoesNotFit` skip could not place, the earlier operation an
695
+ * `overlappingOperation` skip conflicts with, the offset and character of a
696
+ * `splitsCharacter` skip, the undefined style of a `missingStyle` skip, the
697
+ * undefined instance of a `missingNumbering` skip, or the validator's path
698
+ * and message of an `invalidResult` one.
699
+ */
700
+ message?: string;
575
701
  };
576
702
  /**
577
703
  * One automatic adjustment `apply.ts` made to an operation's input to keep the
@@ -600,6 +726,19 @@ type FolioAIEditNormalization =
600
726
  id: string;
601
727
  code: "unpairedMove";
602
728
  moveId: string;
729
+ } |
730
+ /**
731
+ * A text replacement rewrote a stretch whose characters did not all carry
732
+ * the same formatting, link or comment. The new text takes the formatting
733
+ * of the first character it replaces, and every link and comment over the
734
+ * stretch; text the replacement keeps keeps its own. A change spanning
735
+ * several words keeps only whole words, so no word is left partly in the
736
+ * old formatting. Direct and tracked modes allocate alike: accepting the
737
+ * tracked replacement leaves what the direct one writes.
738
+ */
739
+ {
740
+ id: string;
741
+ code: "uniformReplacementFormatting";
603
742
  };
604
743
  type FolioAIEditNormalizationCode = FolioAIEditNormalization["code"];
605
744
  type FolioAIEditApplyResult = {
@@ -609,4 +748,4 @@ type FolioAIEditApplyResult = {
609
748
  normalizations?: FolioAIEditNormalization[];
610
749
  };
611
750
  //#endregion
612
- export { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockParagraphProperties, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIBlockTableLocation, FolioAIComment, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIInsertFormattingScope, FolioAIListReference, FolioAIParagraphIndentation, FolioAIParagraphSpacing, FolioAISignatureParty, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult };
751
+ export { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockParagraphProperties, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIBlockTableLocation, FolioAIComment, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIInsertFormattingScope, FolioAIListKind, FolioAIListNumbering, FolioAIListReference, FolioAINewListReference, FolioAIParagraphIndentation, FolioAIParagraphSpacing, FolioAISignatureParty, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult };
@@ -100,7 +100,7 @@ type AppliedComparison = {
100
100
  * what you could not represent" and "give me nothing unless you can prove it"
101
101
  * are both legitimate asks and only the caller knows which one it is making.
102
102
  */
103
- declare const applyComparison: ({ reviewer, revisionStamp, granularity, revisionFormat, terminalTableCarrierStaged, numberingChanges, targetNumbering, targetNumberingReferences, targetNumberingReferenceMap, finalSectionComparison, styleImportFailure, pairs }: ParsedComparison, planned: readonly PlannedStoryComparison[]) => Result<AppliedComparison, CompareDocxApplyError | CompareDocxOperationLimitError>;
103
+ declare const applyComparison: ({ reviewer, revisionStamp, granularity, revisionFormat, terminalTableCarrierStaged, numberingChanges, targetNumbering, targetNumberingReferences, targetNumberingReferenceMap, finalSectionComparison, styleImportFailure, pairs, unsupported }: ParsedComparison, planned: readonly PlannedStoryComparison[]) => Result<AppliedComparison, CompareDocxApplyError | CompareDocxOperationLimitError>;
104
104
  /**
105
105
  * Stage 4: the result package, with every ZIP entry date pinned.
106
106
  *