@stll/folio-core 0.52.0 → 0.54.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 (389) 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 +1779 -141
  4. package/dist/ai-edits/batch-claims.d.ts +145 -0
  5. package/dist/ai-edits/batch-claims.js +275 -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 +91 -7
  14. package/dist/ai-edits/headless.js +520 -51
  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 +6 -4
  26. package/dist/ai-edits/read.js +113 -50
  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/revisionStretches.d.ts +17 -0
  30. package/dist/ai-edits/revisionStretches.js +80 -0
  31. package/dist/ai-edits/snapshot.d.ts +36 -3
  32. package/dist/ai-edits/snapshot.js +180 -25
  33. package/dist/ai-edits/table-cell-mutations.d.ts +4 -2
  34. package/dist/ai-edits/table-cell-mutations.js +6 -2
  35. package/dist/ai-edits/table-geometry.d.ts +1 -1
  36. package/dist/ai-edits/table-row-column-mutations.d.ts +44 -17
  37. package/dist/ai-edits/table-row-column-mutations.js +86 -34
  38. package/dist/ai-edits/types.d.ts +155 -16
  39. package/dist/compare/compare.d.ts +1 -1
  40. package/dist/compare/compare.js +65 -16
  41. package/dist/compare/content-alignment.d.ts +5 -1
  42. package/dist/compare/content-alignment.js +52 -34
  43. package/dist/compare/content-types.d.ts +7 -0
  44. package/dist/compare/content.d.ts +4 -1
  45. package/dist/compare/content.js +6 -1
  46. package/dist/compare/formatting.js +2 -1
  47. package/dist/compare/inline-atoms.d.ts +21 -4
  48. package/dist/compare/inline-atoms.js +138 -16
  49. package/dist/compare/inline-provenance.js +1 -1
  50. package/dist/compare/plan.js +10 -5
  51. package/dist/compare/scenario.js +14 -3
  52. package/dist/compare/section-boundary-properties.js +1 -1
  53. package/dist/compare/types.d.ts +4 -2
  54. package/dist/compare/types.js +2 -1
  55. package/dist/compare/verification.d.ts +1 -1
  56. package/dist/compare/verification.js +15 -3
  57. package/dist/controller/committedLayoutDiff.d.ts +25 -0
  58. package/dist/controller/committedLayoutDiff.js +71 -0
  59. package/dist/controller/contentControlWidgetController.d.ts +1 -1
  60. package/dist/controller/folioEditor.d.ts +1 -1
  61. package/dist/controller/fontReadiness.d.ts +70 -3
  62. package/dist/controller/fontReadiness.js +100 -10
  63. package/dist/controller/headerFooterEditorManager.js +6 -1
  64. package/dist/controller/layoutPipeline.d.ts +12 -10
  65. package/dist/controller/layoutPipeline.js +65 -11
  66. package/dist/controller/layoutRunOptions.d.ts +24 -0
  67. package/dist/controller/layoutRunOptions.js +17 -0
  68. package/dist/controller/layoutScheduler.d.ts +19 -14
  69. package/dist/controller/layoutScheduler.js +15 -12
  70. package/dist/controller/layoutSession.d.ts +26 -2
  71. package/dist/controller/layoutSession.js +1 -1
  72. package/dist/controller/noteEditorManager.js +8 -3
  73. package/dist/document-operations.d.ts +11 -2
  74. package/dist/document-operations.js +230 -21
  75. package/dist/docx/altChunk.d.ts +8 -0
  76. package/dist/docx/altChunk.js +17 -0
  77. package/dist/docx/archiveInflation.d.ts +127 -0
  78. package/dist/docx/archiveInflation.js +181 -0
  79. package/dist/docx/attributeRemainder.d.ts +1 -1
  80. package/dist/docx/blockContentParser.d.ts +64 -1
  81. package/dist/docx/blockContentParser.js +17 -4
  82. package/dist/docx/blockCustomXmlShell.d.ts +7 -0
  83. package/dist/docx/blockCustomXmlShell.js +14 -0
  84. package/dist/docx/blockPlainText.js +7 -0
  85. package/dist/docx/commentAnchorIndex.js +1 -1
  86. package/dist/docx/commentRangeIntegrity.js +8 -3
  87. package/dist/docx/commentReferenceNormalization.js +1 -1
  88. package/dist/docx/commentReplyMarkers.js +20 -1
  89. package/dist/docx/compatibility.d.ts +1 -1
  90. package/dist/docx/compatibility.js +34 -13
  91. package/dist/docx/containerChildren.gen.d.ts +1 -1
  92. package/dist/docx/containerChildren.gen.js +1 -0
  93. package/dist/docx/documentParser.js +12 -12
  94. package/dist/docx/drawingIdNormalization.d.ts +3 -1
  95. package/dist/docx/drawingIdNormalization.js +6 -1
  96. package/dist/docx/ensureParaIds.js +119 -97
  97. package/dist/docx/footnoteParser.js +8 -4
  98. package/dist/docx/headerFooterParser.js +3 -3
  99. package/dist/docx/headerFooterReferenceNormalization.d.ts +20 -1
  100. package/dist/docx/headerFooterReferenceNormalization.js +52 -27
  101. package/dist/docx/hyperlinkParser.d.ts +1 -1
  102. package/dist/docx/index.d.ts +1 -1
  103. package/dist/docx/listNumberingInstances.d.ts +59 -0
  104. package/dist/docx/listNumberingInstances.js +249 -0
  105. package/dist/docx/metadataPrivacy.js +24 -1
  106. package/dist/docx/normalizeBaseDirection.js +2 -1
  107. package/dist/docx/noteReferenceMark.d.ts +15 -0
  108. package/dist/docx/noteReferenceMark.js +48 -0
  109. package/dist/docx/opaqueCarrier.d.ts +7 -0
  110. package/dist/docx/opaqueCarrier.js +38 -0
  111. package/dist/docx/packageParts.js +4 -1
  112. package/dist/docx/paragraphParser.js +96 -27
  113. package/dist/docx/paragraphPropertySource.d.ts +4 -2
  114. package/dist/docx/paragraphPropertySource.js +10 -2
  115. package/dist/docx/paragraphTraversal.js +1 -0
  116. package/dist/docx/parseWarningMessage.js +4 -1
  117. package/dist/docx/parser.js +175 -22
  118. package/dist/docx/rezip.js +31 -7
  119. package/dist/docx/sdtProperties.js +1 -1
  120. package/dist/docx/sdtPropertiesPatch.js +3 -0
  121. package/dist/docx/selectiveSave.js +16 -9
  122. package/dist/docx/selectiveXmlPatch.d.ts +3 -1
  123. package/dist/docx/selectiveXmlPatch.js +186 -39
  124. package/dist/docx/serializer/blockCustomXmlSerializer.d.ts +5 -0
  125. package/dist/docx/serializer/blockCustomXmlSerializer.js +4 -0
  126. package/dist/docx/serializer/documentSerializer.js +2 -0
  127. package/dist/docx/serializer/headerFooterSerializer.js +2 -0
  128. package/dist/docx/serializer/noteSerializer.js +3 -1
  129. package/dist/docx/serializer/paragraphSerializer.js +33 -9
  130. package/dist/docx/serializer/tableSerializer.js +25 -38
  131. package/dist/docx/server/boundedArchive.d.ts +8 -13
  132. package/dist/docx/server/boundedArchive.js +70 -59
  133. package/dist/docx/server/createBilingualDocument.js +3 -3
  134. package/dist/docx/server/extractDocxText.d.ts +8 -2
  135. package/dist/docx/server/extractDocxText.js +2 -2
  136. package/dist/docx/server/validateDocxConformance.d.ts +1 -1
  137. package/dist/docx/server/validateDocxConformance.js +1 -0
  138. package/dist/docx/tableParser.d.ts +157 -1
  139. package/dist/docx/tableParser.js +89 -10
  140. package/dist/docx/textBoxParser.js +1 -1
  141. package/dist/docx/unzip.d.ts +20 -2
  142. package/dist/docx/unzip.js +136 -25
  143. package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
  144. package/dist/docx/wordprocessingPrefixes.js +286 -0
  145. package/dist/fonts/embeddedFonts.js +1 -1
  146. package/dist/i18n/messages/catalogs.gen.d.ts +170 -34
  147. package/dist/i18n/messages/catalogs.gen.js +187 -51
  148. package/dist/i18n/messages/messages.gen.d.ts +10 -2
  149. package/dist/internal/compare/inline-presentation.d.ts +2 -1
  150. package/dist/internal/compare/inline-presentation.js +11 -10
  151. package/dist/internal/headlessRevisionResolutionGuard.d.ts +2 -8
  152. package/dist/internal/headlessRevisionResolutionGuard.js +2 -11
  153. package/dist/internal/indexedPositionMap.d.ts +11 -0
  154. package/dist/internal/indexedPositionMap.js +42 -0
  155. package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
  156. package/dist/internal/revisionResolutionEdits.d.ts +13 -0
  157. package/dist/internal/revisionResolutionEdits.js +19 -0
  158. package/dist/internal/revisionResolutionInline.d.ts +24 -0
  159. package/dist/internal/{headlessRevisionResolution.js → revisionResolutionInline.js} +61 -43
  160. package/dist/internal/revisionResolutionStep.d.ts +34 -0
  161. package/dist/internal/revisionResolutionStep.js +282 -0
  162. package/dist/internal/revisionResolutionTracking.d.ts +11 -0
  163. package/dist/internal/revisionResolutionTracking.js +124 -0
  164. package/dist/internal/wholeStoryRevisionResolution.d.ts +56 -0
  165. package/dist/internal/wholeStoryRevisionResolution.js +600 -0
  166. package/dist/layout-bridge/convert/markupViewFlow.d.ts +20 -0
  167. package/dist/layout-bridge/convert/markupViewFlow.js +123 -0
  168. package/dist/layout-bridge/convert/tableConversion.js +1 -1
  169. package/dist/layout-bridge/convert/toFlowBlocks.js +10 -1
  170. package/dist/layout-engine/layoutInstrumentation.d.ts +9 -1
  171. package/dist/layout-engine/layoutInstrumentation.js +4 -1
  172. package/dist/layout-engine/measure/cache.d.ts +18 -1
  173. package/dist/layout-engine/measure/cache.js +31 -1
  174. package/dist/layout-engine/measure/font-metrics.worker.js +3 -7
  175. package/dist/layout-engine/measure/measureContainer.js +7 -47
  176. package/dist/layout-engine/measure/measureHelpers.d.ts +6 -1
  177. package/dist/layout-engine/measure/measureHelpers.js +22 -2
  178. package/dist/layout-engine/measure/measureParagraph.js +2 -2
  179. package/dist/layout-engine/measure/measureWorker.js +2 -3
  180. package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +6 -7
  181. package/dist/layout-engine/measure/measureWorkerProtocol.js +1 -2
  182. package/dist/layout-engine/measure/paragraphMeasureShared.d.ts +12 -1
  183. package/dist/layout-engine/measure/paragraphMeasureShared.js +14 -1
  184. package/dist/layout-engine/types.d.ts +6 -0
  185. package/dist/layout-painter/renderPage.js +1 -0
  186. package/dist/layout-painter/renderParagraph.js +1 -1
  187. package/dist/managers/ContextMenuManager.js +5 -2
  188. package/dist/managers/types.d.ts +3 -0
  189. package/dist/markdown/escape.d.ts +2 -2
  190. package/dist/markdown/escape.js +4 -5
  191. package/dist/markdown/fromMarkdown.js +2 -1
  192. package/dist/markdown/internals.d.ts +11 -1
  193. package/dist/markdown/internals.js +24 -3
  194. package/dist/markdown/renderBlock.js +121 -25
  195. package/dist/markdown/renderParagraph.d.ts +13 -1
  196. package/dist/markdown/renderParagraph.js +85 -38
  197. package/dist/markdown/renderRuns.d.ts +10 -1
  198. package/dist/markdown/renderRuns.js +323 -69
  199. package/dist/markdown/renderTable.js +24 -12
  200. package/dist/markdown/trailers.js +2 -2
  201. package/dist/markdown/types.d.ts +29 -7
  202. package/dist/paged-layout/incrementalMeasure.d.ts +1 -2
  203. package/dist/paged-layout/incrementalMeasure.js +1 -9
  204. package/dist/paged-layout/transactionDirtyRange.d.ts +1 -3
  205. package/dist/paged-layout/transactionDirtyRange.js +29 -41
  206. package/dist/panel-layout.d.ts +83 -0
  207. package/dist/panel-layout.js +96 -0
  208. package/dist/prosemirror/anchoredTextBoxes.d.ts +37 -0
  209. package/dist/prosemirror/anchoredTextBoxes.js +156 -0
  210. package/dist/prosemirror/attrs/index.d.ts +6 -2
  211. package/dist/prosemirror/attrs/index.js +172 -1
  212. package/dist/prosemirror/clearRunColor.d.ts +6 -0
  213. package/dist/prosemirror/clearRunColor.js +46 -0
  214. package/dist/prosemirror/commands/comments.d.ts +7 -8
  215. package/dist/prosemirror/commands/comments.js +281 -212
  216. package/dist/prosemirror/commands/contentControls.d.ts +1 -1
  217. package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
  218. package/dist/prosemirror/commands/formatPainter.js +1 -1
  219. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  220. package/dist/prosemirror/commands/hyperlink.js +2 -1
  221. package/dist/prosemirror/commands/index.d.ts +2 -2
  222. package/dist/prosemirror/commands/index.js +2 -2
  223. package/dist/prosemirror/commands/paragraph.d.ts +7 -1
  224. package/dist/prosemirror/commands/paragraph.js +9 -1
  225. package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +13 -0
  226. package/dist/prosemirror/commands/paragraphBookmarkJoin.js +22 -0
  227. package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
  228. package/dist/prosemirror/commands/propertyChangeScope.d.ts +3 -2
  229. package/dist/prosemirror/commands/propertyChangeScope.js +24 -3
  230. package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +40 -0
  231. package/dist/prosemirror/commands/resolveAllTableChanges.js +620 -0
  232. package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +15 -0
  233. package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +46 -0
  234. package/dist/prosemirror/commands/resolveParagraphProperties.d.ts +16 -0
  235. package/dist/prosemirror/commands/resolveParagraphProperties.js +73 -0
  236. package/dist/prosemirror/commands/sectionBreak.js +2 -1
  237. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +15 -2
  238. package/dist/prosemirror/commands/tableCellMergeResolution.js +23 -7
  239. package/dist/prosemirror/containerFinalParagraph.d.ts +11 -5
  240. package/dist/prosemirror/containerFinalParagraph.js +7 -6
  241. package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
  242. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
  243. package/dist/prosemirror/conversion/fromProseDoc.js +177 -605
  244. package/dist/prosemirror/conversion/toProseDoc.d.ts +4 -11
  245. package/dist/prosemirror/conversion/toProseDoc.js +70 -154
  246. package/dist/prosemirror/documentSchema.d.ts +8 -0
  247. package/dist/prosemirror/documentSchema.js +18 -0
  248. package/dist/prosemirror/emptyFieldResultRuns.d.ts +18 -0
  249. package/dist/prosemirror/emptyFieldResultRuns.js +33 -0
  250. package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
  251. package/dist/prosemirror/extensions/ExtensionManager.js +3 -1
  252. package/dist/prosemirror/extensions/StarterKit.js +5 -1
  253. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  254. package/dist/prosemirror/extensions/core/ParagraphExtension.js +116 -63
  255. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +4 -1
  256. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +24 -3
  257. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +20 -0
  258. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +43 -0
  259. package/dist/prosemirror/extensions/features/ListExtension.js +167 -128
  260. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +19 -2
  261. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +33 -20
  262. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +31 -2
  263. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +270 -99
  264. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +3 -2
  265. package/dist/prosemirror/extensions/features/pasteCleanup.js +2 -1
  266. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
  267. package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +12 -0
  268. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +124 -0
  269. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +33 -11
  270. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +8 -4
  271. package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
  272. package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
  273. package/dist/prosemirror/extensions/marks/StrikeExtension.js +2 -2
  274. package/dist/prosemirror/extensions/marks/SubscriptExtension.js +2 -2
  275. package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +2 -2
  276. package/dist/prosemirror/extensions/marks/TextColorExtension.js +4 -3
  277. package/dist/prosemirror/extensions/marks/markUtils.d.ts +15 -8
  278. package/dist/prosemirror/extensions/marks/markUtils.js +25 -10
  279. package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +12 -0
  280. package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +46 -0
  281. package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.d.ts +6 -0
  282. package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.js +52 -0
  283. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +2 -2
  284. package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +3 -3
  285. package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
  286. package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +5 -3
  287. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +4 -1
  288. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
  289. package/dist/prosemirror/extensions/nodes/TableExtension.js +121 -226
  290. package/dist/prosemirror/extensions/types.d.ts +11 -1
  291. package/dist/prosemirror/findReplaceSelection.js +1 -1
  292. package/dist/prosemirror/hyperlinkRemoval.d.ts +9 -0
  293. package/dist/prosemirror/hyperlinkRemoval.js +129 -0
  294. package/dist/prosemirror/index.d.ts +5 -3
  295. package/dist/prosemirror/index.js +5 -3
  296. package/dist/prosemirror/indexedNodeLookup.d.ts +17 -0
  297. package/dist/prosemirror/indexedNodeLookup.js +103 -0
  298. package/dist/prosemirror/listAutoformatMarkers.d.ts +19 -0
  299. package/dist/prosemirror/listAutoformatMarkers.js +98 -0
  300. package/dist/prosemirror/listInstanceReferences.d.ts +12 -0
  301. package/dist/prosemirror/listInstanceReferences.js +72 -0
  302. package/dist/prosemirror/listLabels.d.ts +24 -0
  303. package/dist/prosemirror/listLabels.js +111 -0
  304. package/dist/prosemirror/listNumbering.d.ts +92 -0
  305. package/dist/prosemirror/listNumbering.js +330 -0
  306. package/dist/prosemirror/listRendering.d.ts +27 -0
  307. package/dist/prosemirror/listRendering.js +27 -0
  308. package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
  309. package/dist/prosemirror/listRenderingAttrs.js +8 -1
  310. package/dist/prosemirror/markupViewNotes.d.ts +8 -0
  311. package/dist/prosemirror/markupViewNotes.js +49 -0
  312. package/dist/prosemirror/markupViewProjection.d.ts +97 -0
  313. package/dist/prosemirror/markupViewProjection.js +88 -0
  314. package/dist/prosemirror/noteReferenceReview.d.ts +77 -0
  315. package/dist/prosemirror/noteReferenceReview.js +332 -0
  316. package/dist/prosemirror/numberingAttr.d.ts +9 -1
  317. package/dist/prosemirror/numberingAttr.js +9 -1
  318. package/dist/prosemirror/outlineLevelAttr.js +1 -1
  319. package/dist/prosemirror/paragraphIndentation.d.ts +10 -1
  320. package/dist/prosemirror/paragraphIndentation.js +32 -7
  321. package/dist/prosemirror/paragraphMarkJoin.d.ts +21 -0
  322. package/dist/prosemirror/paragraphMarkJoin.js +26 -0
  323. package/dist/prosemirror/paragraphPropertyCarry.d.ts +64 -0
  324. package/dist/prosemirror/paragraphPropertyCarry.js +158 -0
  325. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
  326. package/dist/prosemirror/plugins/documentNumbering.d.ts +27 -1
  327. package/dist/prosemirror/plugins/documentNumbering.js +97 -11
  328. package/dist/prosemirror/plugins/documentStyleState.d.ts +26 -0
  329. package/dist/prosemirror/plugins/documentStyleState.js +32 -0
  330. package/dist/prosemirror/plugins/documentStyles.d.ts +3 -13
  331. package/dist/prosemirror/plugins/documentStyles.js +67 -17
  332. package/dist/prosemirror/plugins/index.d.ts +2 -1
  333. package/dist/prosemirror/plugins/index.js +2 -1
  334. package/dist/prosemirror/plugins/paragraphStyleResolution.d.ts +15 -0
  335. package/dist/prosemirror/plugins/paragraphStyleResolution.js +230 -0
  336. package/dist/prosemirror/plugins/suggestionMode.d.ts +27 -3
  337. package/dist/prosemirror/plugins/suggestionMode.js +490 -63
  338. package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
  339. package/dist/prosemirror/plugins/transactionInvariants.d.ts +32 -0
  340. package/dist/prosemirror/plugins/transactionInvariants.js +86 -0
  341. package/dist/prosemirror/positionSweep.d.ts +24 -0
  342. package/dist/prosemirror/positionSweep.js +222 -0
  343. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +23 -3
  344. package/dist/prosemirror/rebaseParagraphRunFormatting.js +39 -13
  345. package/dist/prosemirror/rebaseParagraphRuns.d.ts +36 -0
  346. package/dist/prosemirror/rebaseParagraphRuns.js +99 -0
  347. package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
  348. package/dist/prosemirror/replacedAnnotations.d.ts +33 -1
  349. package/dist/prosemirror/replacedAnnotations.js +170 -1
  350. package/dist/prosemirror/runFormattingFromMarks.d.ts +18 -0
  351. package/dist/prosemirror/runFormattingFromMarks.js +567 -0
  352. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
  353. package/dist/prosemirror/runFormattingReconciliation.js +10 -9
  354. package/dist/prosemirror/schema/index.d.ts +2 -2
  355. package/dist/prosemirror/schema/index.js +3 -0
  356. package/dist/prosemirror/schema/nodes.d.ts +44 -11
  357. package/dist/prosemirror/sectionMarkEdits.d.ts +20 -0
  358. package/dist/prosemirror/sectionMarkEdits.js +59 -0
  359. package/dist/prosemirror/storyListNumbering.d.ts +17 -0
  360. package/dist/prosemirror/storyListNumbering.js +102 -0
  361. package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +59 -0
  362. package/dist/prosemirror/styles/paragraphStyleCascade.js +145 -0
  363. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +21 -2
  364. package/dist/prosemirror/styles/resolvedStyleAttrs.js +38 -1
  365. package/dist/prosemirror/styles/tableStyleRegions.d.ts +31 -0
  366. package/dist/prosemirror/styles/tableStyleRegions.js +55 -0
  367. package/dist/prosemirror/tableCellPaste.d.ts +74 -0
  368. package/dist/prosemirror/tableCellPaste.js +525 -0
  369. package/dist/prosemirror/tableGridMutation.d.ts +87 -2
  370. package/dist/prosemirror/tableGridMutation.js +255 -2
  371. package/dist/prosemirror/tableRunIn.d.ts +51 -0
  372. package/dist/prosemirror/tableRunIn.js +165 -0
  373. package/dist/prosemirror/textInput.js +11 -2
  374. package/dist/prosemirror/trackedRevisionPath.d.ts +17 -0
  375. package/dist/prosemirror/trackedRevisionPath.js +32 -0
  376. package/dist/prosemirror/validation.js +5 -1
  377. package/dist/redline.js +93 -9
  378. package/dist/render-dom/BodySelectionOverlay.d.ts +4 -1
  379. package/dist/render-dom/BodySelectionOverlay.js +3 -2
  380. package/dist/server.d.ts +2 -2
  381. package/dist/utils/findReplace.js +2 -2
  382. package/dist/utils/mergeDocumentContent.js +1 -1
  383. package/dist/utils/noteReferenceLabels.d.ts +36 -0
  384. package/dist/utils/noteReferenceLabels.js +32 -0
  385. package/dist/utils/replaceText.js +1 -1
  386. package/dist/version-comparison.d.ts +1 -0
  387. package/dist/version-comparison.js +1 -0
  388. package/package.json +6 -5
  389. package/dist/internal/headlessRevisionResolution.d.ts +0 -23
@@ -1,10 +1,36 @@
1
1
  import { markStructuralChange } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
2
- import { reconcileTableGridAfterColumnRemoval } from "../prosemirror/tableGridMutation.js";
2
+ import { markRowsEmptiedInBatch, 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
+ /**
9
+ * The revision of the `index`th cell a column change marks. The save writes
10
+ * each cell's marker as a revision of its own, and each is accepted or
11
+ * rejected on its own; the reviewer's revisions are those from the start.
12
+ */
13
+ const cellRevision = (revision, index) => ({
14
+ ...revision,
15
+ revisionId: revision.revisionId + index
16
+ });
17
+ const UNPLACED_TEXT_PREVIEW_LENGTH = 40;
18
+ const previewCellText = (text) => JSON.stringify(text.length > UNPLACED_TEXT_PREVIEW_LENGTH ? `${text.slice(0, UNPLACED_TEXT_PREVIEW_LENGTH)}…` : text);
19
+ /**
20
+ * Name the `cellTexts` a new row or column has no cell for, or `null` when
21
+ * every one of them has a place.
22
+ *
23
+ * A row is narrower than the table where a vertical merge from above reaches
24
+ * through it, and a column is shorter than the table where a horizontal merge
25
+ * spans across it; the merged cell takes that slot, so the texts are counted
26
+ * against the cells that are really built. Anything past the last one would
27
+ * be dropped by an operation reported as applied.
28
+ */
29
+ const describeUnplacedCellTexts = ({ cellTexts, capacity, target }) => {
30
+ if (cellTexts === void 0 || cellTexts.length <= capacity) return null;
31
+ const unplaced = cellTexts.slice(capacity).map((text, offset) => `cellTexts[${capacity + offset}] ${previewCellText(text)}`);
32
+ 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`;
33
+ };
8
34
  const getTableColumnCoordinateKey = ({ tablePosition, columnIndex }) => `${tablePosition}:${columnIndex}`;
9
35
  const findTableColumnInsertion = ({ doc, blockFrom, position }) => {
10
36
  const target = findEnclosingTableCell(doc, blockFrom);
@@ -28,7 +54,6 @@ const findTableRowInsertion = ({ doc, blockFrom, position }) => {
28
54
  });
29
55
  };
30
56
  const applyTableRowInsertion = ({ tr, insertion, cellTexts, revision, template }) => {
31
- if (revision && insertion.rowspanUpdates.length > 0) return { type: "unsupported" };
32
57
  const liveRowspanUpdates = [];
33
58
  for (const updatePosition of insertion.rowspanUpdates) {
34
59
  const cellPosition = insertion.tableStart + updatePosition;
@@ -46,7 +71,7 @@ const applyTableRowInsertion = ({ tr, insertion, cellTexts, revision, template }
46
71
  rowspan: update.rowspan + 1
47
72
  });
48
73
  const rowAttrs = revision ? { trIns: revision } : null;
49
- const templated = template === void 0 ? null : tableRowFromTemplate({
74
+ const templated = template === void 0 || insertion.rowspanUpdates.length > 0 ? null : tableRowFromTemplate({
50
75
  template,
51
76
  columnCount: insertion.columnCount
52
77
  });
@@ -73,12 +98,14 @@ const applyTableRowInsertion = ({ tr, insertion, cellTexts, revision, template }
73
98
  * accept and an inserted row's text on reject when the row marker stands
74
99
  * alone, so the two must always be written together.
75
100
  *
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.
101
+ * Two kinds of run stay unmarked. A run that already carries a revision of the
102
+ * same kind keeps it, because overwriting would drop the earlier revision; a
103
+ * pending insertion inside a deleted row is marked deleted as well (`w:ins >
104
+ * w:del`), as `deleteBlock` marks one inside a deleted paragraph, so every
105
+ * reader leaves it out with the rest of the row. A cell that spans into the
106
+ * row below survives the deletion — `removeTableRow` moves it down and
107
+ * shortens its span — so marking its text would delete content the accepted
108
+ * document must still hold.
82
109
  */
83
110
  const markTableRowContent = ({ tr, rowPosition, kind, revision }) => {
84
111
  const row = tr.doc.nodeAt(rowPosition);
@@ -103,7 +130,7 @@ const markTableRowContent = ({ tr, rowPosition, kind, revision }) => {
103
130
  if (!node.isInline) return true;
104
131
  if (node.marks.some(isTrackedChangeMark)) {
105
132
  wholeRowMarkable = false;
106
- return false;
133
+ if (kind === "insertion" || node.marks.some(({ type }) => type.name === "deletion")) return false;
107
134
  }
108
135
  const from = contentFrom + offset;
109
136
  markable.push({
@@ -127,14 +154,27 @@ const applyTableColumnInsertion = ({ tr, insertion, cellTexts, revision }) => {
127
154
  const tablePosition = tr.mapping.map(insertion.tablePosition, 1);
128
155
  const table = tr.doc.nodeAt(tablePosition);
129
156
  if (!table || table.type.spec["tableRole"] !== "table") return { type: "unsupported" };
157
+ const map = TableMap.get(table);
158
+ if (insertion.columnIndex >= 0 && insertion.columnIndex <= map.width) {
159
+ const overflow = describeUnplacedCellTexts({
160
+ cellTexts,
161
+ capacity: getInsertedPhysicalColumnRows(map, insertion.columnIndex).length,
162
+ target: "column"
163
+ });
164
+ if (overflow !== null) return {
165
+ type: "payloadDoesNotFit",
166
+ message: overflow
167
+ };
168
+ }
130
169
  const actions = buildTableColumnInsertionActions({
131
- map: TableMap.get(table),
170
+ map,
132
171
  table,
133
172
  columnIndex: insertion.columnIndex,
134
173
  cellTexts
135
174
  });
136
175
  if (!actions || revision && actions.some(({ type }) => type === "setColspan")) return { type: "unsupported" };
137
176
  const mapFrom = tr.mapping.maps.length;
177
+ let markedCells = 0;
138
178
  for (const action of actions) {
139
179
  const position = tr.mapping.slice(mapFrom).map(tablePosition + 1 + action.position);
140
180
  if (action.type === "setColspan") {
@@ -145,14 +185,20 @@ const applyTableColumnInsertion = ({ tr, insertion, cellTexts, revision }) => {
145
185
  ...action.cell.attrs,
146
186
  cellMarker: {
147
187
  kind: "ins",
148
- info: revision
188
+ info: cellRevision(revision, markedCells++)
149
189
  }
150
190
  }, action.cell.content) : action.cell;
151
191
  tr.insert(position, cell);
152
192
  }
153
- return applied(tr, revision);
193
+ reconcileTableGridAfterColumnInsertion({
194
+ tr,
195
+ tablePosition,
196
+ previousTable: table,
197
+ insertedColumn: insertion.columnIndex
198
+ });
199
+ return applied(tr, revision, markedCells);
154
200
  };
155
- const applyTableColumnDeletion = ({ tr, deletion, insertedColumnCount, revision }) => {
201
+ const applyTableColumnDeletion = ({ tr, deletion, insertedColumnCount, revision, emptiedRows }) => {
156
202
  const tablePosition = tr.mapping.map(deletion.tablePosition, 1);
157
203
  const table = tr.doc.nodeAt(tablePosition);
158
204
  if (!table || table.type.spec["tableRole"] !== "table") return { type: "unsupported" };
@@ -166,12 +212,12 @@ const applyTableColumnDeletion = ({ tr, deletion, insertedColumnCount, revision
166
212
  columnIndex
167
213
  });
168
214
  if (!cellPositions) return { type: "unsupported" };
169
- for (const cellPosition of cellPositions) tr.setNodeAttribute(tablePosition + 1 + cellPosition, "cellMarker", {
215
+ for (const [index, cellPosition] of cellPositions.entries()) tr.setNodeAttribute(tablePosition + 1 + cellPosition, "cellMarker", {
170
216
  kind: "del",
171
- info: revision
217
+ info: cellRevision(revision, index)
172
218
  });
173
219
  markStructuralChange(tr);
174
- return applied(tr, revision);
220
+ return applied(tr, revision, cellPositions.length);
175
221
  }
176
222
  if (map.width === 1) {
177
223
  const transaction = deleteTableNode({
@@ -196,6 +242,13 @@ const applyTableColumnDeletion = ({ tr, deletion, insertedColumnCount, revision
196
242
  previousTable: table,
197
243
  removedColumn: columnIndex
198
244
  });
245
+ if (emptiedRows) markRowsEmptiedInBatch({
246
+ tr,
247
+ tablePosition,
248
+ previousTable: table,
249
+ emptied: emptiedRows
250
+ });
251
+ else removeRowsWithoutCells(tr, tablePosition);
199
252
  return applied(tr, null);
200
253
  };
201
254
  const applyTableRowDeletion = ({ tr, deletion, revision }) => {
@@ -213,32 +266,30 @@ const applyTableRowDeletion = ({ tr, deletion, revision }) => {
213
266
  markStructuralChange(tr);
214
267
  return applied(tr, revision);
215
268
  }
216
- const table = tr.doc.nodeAt(deletion.tablePosition);
217
- if (!table || table.type.spec["tableRole"] !== "table" || deletion.rowIndex >= table.childCount) return { type: "unsupported" };
269
+ const at = tr.doc.resolve(tr.mapping.map(deletion.rowPosition));
270
+ const table = at.parent;
271
+ if (table.type.spec["tableRole"] !== "table" || at.nodeAfter?.type.spec["tableRole"] !== "row") return { type: "unsupported" };
272
+ const tablePosition = at.before();
218
273
  if (table.childCount === 1) {
219
274
  const transaction = deleteTableNode({
220
275
  tr,
221
- tablePosition: deletion.tablePosition,
276
+ tablePosition,
222
277
  table
223
278
  });
224
279
  return transaction ? applied(transaction, null) : { type: "unsupported" };
225
280
  }
226
- const map = TableMap.get(table);
227
- removeRow(tr, {
228
- map,
281
+ removeTableRow(tr, {
282
+ map: TableMap.get(table),
229
283
  table,
230
- tableStart: deletion.tableStart,
231
- left: 0,
232
- top: deletion.rowIndex,
233
- right: map.width,
234
- bottom: deletion.rowIndex + 1
235
- }, deletion.rowIndex);
284
+ tableStart: at.start()
285
+ }, at.index());
236
286
  return applied(tr, null);
237
287
  };
238
- const applied = (transaction, revision) => ({
288
+ const applied = (transaction, revision, revisionCount = 1) => ({
239
289
  type: "applied",
240
290
  transaction,
241
- revisionId: revision?.revisionId ?? null
291
+ revisionId: revision?.revisionId ?? null,
292
+ revisionIds: revision ? Array.from({ length: revisionCount }, (_, index) => revision.revisionId + index) : []
242
293
  });
243
294
  const deleteTableNode = ({ tr, tablePosition, table }) => {
244
295
  const tableEnd = tablePosition + table.nodeSize;
@@ -302,7 +353,8 @@ const splitCellParagraphTexts = (text) => text.split(CELL_LINE_BREAK_PATTERN);
302
353
  * Fill the new row's cells from `cellTexts`, in order: the nth text goes in
303
354
  * the nth cell the row actually has, which is how a caller reading the row
304
355
  * through the block snapshot counts them (`table.cellIndex`). Cells the caller
305
- * did not name stay empty.
356
+ * did not name stay empty. The resolver has already refused more texts than
357
+ * cells ({@link describeUnplacedCellTexts}).
306
358
  */
307
359
  const populateTableRow = (row, cellTexts) => {
308
360
  if (cellTexts === void 0) return row;
@@ -404,4 +456,4 @@ const getTableColumnDeletionCellPositions = ({ map, table, columnIndex }) => {
404
456
  return [...positions];
405
457
  };
406
458
  //#endregion
407
- export { applyTableColumnDeletion, applyTableColumnInsertion, applyTableRowDeletion, applyTableRowInsertion, findTableColumnInsertion, findTableRowInsertion, getTableColumnCoordinateKey, markTableRowContent, splitCellParagraphTexts };
459
+ 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
  *