@stll/folio-core 0.66.2 → 0.68.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 (323) hide show
  1. package/dist/ai-edits/apply.d.ts +9 -1
  2. package/dist/ai-edits/apply.js +138 -17
  3. package/dist/ai-edits/batch-claims.js +5 -3
  4. package/dist/ai-edits/clean-text.js +4 -1
  5. package/dist/ai-edits/headless.d.ts +36 -21
  6. package/dist/ai-edits/headless.js +104 -34
  7. package/dist/ai-edits/index.d.ts +2 -2
  8. package/dist/ai-edits/note-references.d.ts +6 -0
  9. package/dist/ai-edits/note-references.js +7 -1
  10. package/dist/ai-edits/read.d.ts +19 -0
  11. package/dist/ai-edits/read.js +6 -4
  12. package/dist/ai-edits/snapshot.d.ts +6 -0
  13. package/dist/ai-edits/snapshot.js +32 -17
  14. package/dist/ai-edits/table-cell-mutations.js +3 -2
  15. package/dist/ai-edits/table-row-column-mutations.js +20 -6
  16. package/dist/ai-edits/types.d.ts +9 -1
  17. package/dist/ai-suggestions/apply.js +13 -4
  18. package/dist/compare/compare.js +2 -1
  19. package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
  20. package/dist/compare/inserted-resource-snapshot.js +7 -3
  21. package/dist/controller/canonicalClipboard.js +29 -12
  22. package/dist/controller/canonicalComposition.d.ts +1 -1
  23. package/dist/controller/canonicalComposition.js +77 -19
  24. package/dist/controller/canonicalInlineProjection.d.ts +35 -10
  25. package/dist/controller/canonicalInlineProjection.js +192 -28
  26. package/dist/controller/canonicalInput.d.ts +2 -2
  27. package/dist/controller/canonicalInput.js +47 -2
  28. package/dist/controller/canonicalListRendering.d.ts +2 -1
  29. package/dist/controller/canonicalListRendering.js +1 -1
  30. package/dist/controller/canonicalLockGuard.d.ts +8 -0
  31. package/dist/controller/canonicalLockGuard.js +88 -0
  32. package/dist/controller/canonicalPublicOperations.d.ts +12 -4
  33. package/dist/controller/canonicalPublicOperations.js +274 -20
  34. package/dist/controller/canonicalSession.d.ts +87 -7
  35. package/dist/controller/canonicalSession.js +328 -75
  36. package/dist/controller/canonicalStoryEditor.d.ts +3 -2
  37. package/dist/controller/canonicalStoryEditor.js +4 -3
  38. package/dist/controller/canonicalStructure.d.ts +2 -1
  39. package/dist/controller/canonicalStructure.js +129 -7
  40. package/dist/controller/contentControlWidgetController.d.ts +5 -0
  41. package/dist/controller/contentControlWidgetController.js +13 -1
  42. package/dist/controller/folioEditor.js +1 -0
  43. package/dist/controller/headerFooterEditorManager.d.ts +2 -2
  44. package/dist/controller/headerFooterEditorManager.js +5 -5
  45. package/dist/controller/hiddenEditorApi.d.ts +6 -0
  46. package/dist/controller/hiddenEditorApi.js +1 -0
  47. package/dist/controller/hiddenEditorManager.d.ts +10 -3
  48. package/dist/controller/hiddenEditorManager.js +94 -38
  49. package/dist/controller/layoutPipeline.d.ts +2 -0
  50. package/dist/controller/layoutPipeline.js +55 -18
  51. package/dist/controller/layoutSession.d.ts +1 -0
  52. package/dist/controller/noteEditorManager.d.ts +2 -2
  53. package/dist/controller/noteEditorManager.js +5 -5
  54. package/dist/display-list/build/pageFurniture.js +41 -19
  55. package/dist/display-list/build/tablePrimitives.d.ts +3 -1
  56. package/dist/display-list/build/tablePrimitives.js +49 -14
  57. package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
  58. package/dist/document-operations.d.ts +8 -0
  59. package/dist/document-operations.js +4 -3
  60. package/dist/docx/blockContentParser.d.ts +7 -3
  61. package/dist/docx/blockContentParser.js +2 -3
  62. package/dist/docx/blockPlainText.js +2 -0
  63. package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
  64. package/dist/docx/bookmarkRangeJoin.js +43 -0
  65. package/dist/docx/canonicalSave.js +5 -1
  66. package/dist/docx/canonicalSessionInput.d.ts +5 -1
  67. package/dist/docx/canonicalSessionInput.js +7 -2
  68. package/dist/docx/chartPreview.d.ts +4 -1
  69. package/dist/docx/chartPreview.js +26 -15
  70. package/dist/docx/commentAnchorIndex.d.ts +21 -5
  71. package/dist/docx/commentAnchorIndex.js +39 -11
  72. package/dist/docx/commentRangeIntegrity.js +30 -24
  73. package/dist/docx/commentRangeJoin.d.ts +4 -0
  74. package/dist/docx/commentRangeJoin.js +26 -12
  75. package/dist/docx/commentReferenceCompletion.js +5 -4
  76. package/dist/docx/commentReferenceNormalization.js +40 -18
  77. package/dist/docx/compatibility.js +9 -2
  78. package/dist/docx/containerChildren.js +22 -1
  79. package/dist/docx/encryption/compoundFile.js +9 -1
  80. package/dist/docx/encryption/encryptionInfo.js +16 -2
  81. package/dist/docx/ensureParaIds.js +46 -7
  82. package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
  83. package/dist/docx/ensureUniqueControlIds.js +110 -0
  84. package/dist/docx/headerFooterVerbatim.d.ts +7 -0
  85. package/dist/docx/headerFooterVerbatim.js +13 -2
  86. package/dist/docx/hostCommentThreads.d.ts +17 -0
  87. package/dist/docx/hostCommentThreads.js +49 -0
  88. package/dist/docx/hyperlinkParser.js +9 -2
  89. package/dist/docx/inlineWrapperContent.d.ts +8 -1
  90. package/dist/docx/inlineWrapperContent.js +9 -2
  91. package/dist/docx/listMarkerComputation.d.ts +35 -1
  92. package/dist/docx/listMarkerComputation.js +39 -1
  93. package/dist/docx/listModelNormalization.d.ts +44 -1
  94. package/dist/docx/listModelNormalization.js +227 -96
  95. package/dist/docx/mainDocumentPart.d.ts +6 -0
  96. package/dist/docx/mainDocumentPart.js +65 -0
  97. package/dist/docx/markupRangeMarker.d.ts +14 -0
  98. package/dist/docx/markupRangeMarker.js +15 -1
  99. package/dist/docx/metadataPrivacy.js +43 -22
  100. package/dist/docx/normalizeBaseDirection.js +3 -1
  101. package/dist/docx/packageParts.d.ts +1 -1
  102. package/dist/docx/packageParts.js +10 -4
  103. package/dist/docx/paragraphParser.js +159 -48
  104. package/dist/docx/paragraphPropertySource.d.ts +7 -0
  105. package/dist/docx/paragraphPropertySource.js +22 -1
  106. package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
  107. package/dist/docx/paragraphTraversal.js +2 -0
  108. package/dist/docx/parseWarningMessage.js +2 -1
  109. package/dist/docx/parser.js +6 -0
  110. package/dist/docx/previewBudget.d.ts +6 -0
  111. package/dist/docx/previewBudget.js +7 -1
  112. package/dist/docx/renderedPageBreakNormalization.js +1 -1
  113. package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
  114. package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
  115. package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
  116. package/dist/docx/reviewResolutionProvenance.js +110 -25
  117. package/dist/docx/rezip.d.ts +6 -0
  118. package/dist/docx/rezip.js +42 -25
  119. package/dist/docx/selectiveSave.js +6 -10
  120. package/dist/docx/selectiveXmlPatch.d.ts +5 -4
  121. package/dist/docx/selectiveXmlPatch.js +11 -7
  122. package/dist/docx/serializer/documentSerializer.js +3 -1
  123. package/dist/docx/serializer/headerFooterSerializer.js +3 -1
  124. package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
  125. package/dist/docx/serializer/markupRangeAttributes.js +6 -1
  126. package/dist/docx/serializer/noteSerializer.d.ts +17 -4
  127. package/dist/docx/serializer/noteSerializer.js +23 -16
  128. package/dist/docx/serializer/paragraphSerializer.js +56 -12
  129. package/dist/docx/serializer/runSerializer.d.ts +1 -3
  130. package/dist/docx/serializer/runSerializer.js +2 -2
  131. package/dist/docx/serializer/tableSerializer.d.ts +4 -0
  132. package/dist/docx/serializer/tableSerializer.js +4 -2
  133. package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
  134. package/dist/docx/server/createBilingualDocument.js +27 -5
  135. package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
  136. package/dist/docx/sessionListPruning.d.ts +2 -0
  137. package/dist/docx/sessionListPruning.js +50 -0
  138. package/dist/docx/shapeAlternateContent.js +19 -0
  139. package/dist/docx/splitRevisionPieces.d.ts +10 -0
  140. package/dist/docx/splitRevisionPieces.js +14 -0
  141. package/dist/docx/storyBlockReplay.js +4 -0
  142. package/dist/docx/structuralXmlPatch.js +19 -7
  143. package/dist/docx/tableParser.d.ts +6 -2
  144. package/dist/docx/tableParser.js +2 -3
  145. package/dist/docx/textBoxContentParser.d.ts +11 -0
  146. package/dist/docx/textBoxContentParser.js +51 -0
  147. package/dist/docx/textBoxParser.d.ts +0 -5
  148. package/dist/docx/textBoxParser.js +1 -23
  149. package/dist/docx/unzip.js +2 -0
  150. package/dist/docx/verticalMergeProjection.js +1 -1
  151. package/dist/fonts/fontsourceFaces.d.ts +2 -8
  152. package/dist/fonts/fontsourceFaces.js +1 -7
  153. package/dist/i18n/messages/ar.gen.js +3 -0
  154. package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
  155. package/dist/i18n/messages/catalogs.gen.js +51 -0
  156. package/dist/i18n/messages/cs.gen.js +3 -0
  157. package/dist/i18n/messages/de.gen.js +3 -0
  158. package/dist/i18n/messages/en.gen.js +3 -0
  159. package/dist/i18n/messages/es.gen.js +3 -0
  160. package/dist/i18n/messages/et.gen.js +3 -0
  161. package/dist/i18n/messages/fr.gen.js +3 -0
  162. package/dist/i18n/messages/he.gen.js +3 -0
  163. package/dist/i18n/messages/hi.gen.js +3 -0
  164. package/dist/i18n/messages/hu.gen.js +3 -0
  165. package/dist/i18n/messages/lt.gen.js +3 -0
  166. package/dist/i18n/messages/lv.gen.js +3 -0
  167. package/dist/i18n/messages/messages.gen.d.ts +3 -0
  168. package/dist/i18n/messages/pl.gen.js +3 -0
  169. package/dist/i18n/messages/pt-BR.gen.js +3 -0
  170. package/dist/i18n/messages/sk.gen.js +3 -0
  171. package/dist/i18n/messages/tr.gen.js +3 -0
  172. package/dist/i18n/messages/zh-CN.gen.js +3 -0
  173. package/dist/internal/acceptedBlockProjection.js +2 -0
  174. package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
  175. package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
  176. package/dist/internal/revisionResolutionInline.js +1 -2
  177. package/dist/internal/wholeStoryRevisionResolution.js +57 -12
  178. package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
  179. package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
  180. package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
  181. package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
  182. package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
  183. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  184. package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
  185. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  186. package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
  187. package/dist/layout-bridge/convert/tableConversion.js +25 -10
  188. package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
  189. package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
  190. package/dist/layout-bridge/engine/blockIndex.js +12 -0
  191. package/dist/layout-bridge/engine/clickToPosition.js +5 -1
  192. package/dist/layout-bridge/engine/hitTest.js +9 -10
  193. package/dist/layout-bridge/engine/selectionRects.js +6 -6
  194. package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
  195. package/dist/layout-engine/footnoteContinuation.js +210 -0
  196. package/dist/layout-engine/index.d.ts +2 -2
  197. package/dist/layout-engine/index.js +7 -2
  198. package/dist/layout-engine/measure/cache.js +10 -5
  199. package/dist/layout-engine/measure/measureParagraph.js +1 -1
  200. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  201. package/dist/layout-engine/measure/tableCellFloating.js +1 -0
  202. package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
  203. package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
  204. package/dist/layout-engine/tableLayout.js +34 -7
  205. package/dist/layout-engine/tableRowBreak.d.ts +46 -0
  206. package/dist/layout-engine/tableRowBreak.js +193 -36
  207. package/dist/layout-engine/types.d.ts +43 -3
  208. package/dist/layout-painter/previewSvg.d.ts +8 -0
  209. package/dist/layout-painter/previewSvg.js +47 -0
  210. package/dist/layout-painter/renderImage.js +2 -1
  211. package/dist/layout-painter/renderPage.d.ts +5 -4
  212. package/dist/layout-painter/renderPage.js +52 -20
  213. package/dist/layout-painter/renderParagraph.js +3 -2
  214. package/dist/layout-painter/renderTable.d.ts +5 -2
  215. package/dist/layout-painter/renderTable.js +39 -22
  216. package/dist/managers/AutoSaveManager.d.ts +5 -1
  217. package/dist/managers/FindReplaceManager.js +3 -10
  218. package/dist/markdown/escape.d.ts +20 -1
  219. package/dist/markdown/escape.js +43 -1
  220. package/dist/markdown/renderBlock.js +4 -1
  221. package/dist/markdown/renderParagraph.js +13 -27
  222. package/dist/markdown/renderTable.js +6 -2
  223. package/dist/markdown/trailers.js +1 -0
  224. package/dist/pdf/images.d.ts +17 -1
  225. package/dist/pdf/images.js +22 -4
  226. package/dist/pdf/writePdf.js +4 -2
  227. package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
  228. package/dist/prosemirror/attrs/index.js +1 -0
  229. package/dist/prosemirror/canonicalCommands.d.ts +39 -1
  230. package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
  231. package/dist/prosemirror/canonicalTableCommands.js +362 -0
  232. package/dist/prosemirror/commands/comments.d.ts +25 -0
  233. package/dist/prosemirror/commands/comments.js +122 -18
  234. package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
  235. package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
  236. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  237. package/dist/prosemirror/commands/index.d.ts +1 -1
  238. package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
  239. package/dist/prosemirror/commands/pastePlainText.js +13 -3
  240. package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
  241. package/dist/prosemirror/commentIdAllocator.js +2 -2
  242. package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
  243. package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
  244. package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
  245. package/dist/prosemirror/commentReferenceIntegrity.js +22 -8
  246. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
  247. package/dist/prosemirror/conversion/fromProseDoc.js +115 -35
  248. package/dist/prosemirror/conversion/index.d.ts +1 -1
  249. package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
  250. package/dist/prosemirror/conversion/toProseDoc.js +325 -55
  251. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  252. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  253. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
  254. package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
  255. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
  256. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
  257. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
  258. package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
  259. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
  260. package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
  261. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
  262. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
  263. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
  264. package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
  265. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
  266. package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
  267. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
  268. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
  269. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
  270. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
  271. package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
  272. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
  273. package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
  274. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
  275. package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
  276. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
  277. package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
  278. package/dist/prosemirror/extensions/nodes/TableExtension.js +119 -38
  279. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
  280. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
  281. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
  282. package/dist/prosemirror/index.d.ts +2 -2
  283. package/dist/prosemirror/listLabels.js +3 -2
  284. package/dist/prosemirror/listNumbering.d.ts +6 -0
  285. package/dist/prosemirror/listNumbering.js +12 -9
  286. package/dist/prosemirror/lockedControls.d.ts +13 -0
  287. package/dist/prosemirror/lockedControls.js +106 -0
  288. package/dist/prosemirror/markupViewProjection.js +1 -1
  289. package/dist/prosemirror/noteReferenceReview.js +2 -2
  290. package/dist/prosemirror/plugins/documentNumbering.js +4 -1
  291. package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
  292. package/dist/prosemirror/plugins/suggestionMode.js +195 -30
  293. package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
  294. package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
  295. package/dist/prosemirror/replacedAnnotations.js +1 -0
  296. package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
  297. package/dist/prosemirror/rowGridOmissions.js +21 -0
  298. package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
  299. package/dist/prosemirror/runFormattingFromMarks.js +2 -4
  300. package/dist/prosemirror/runFormattingReconciliation.js +2 -2
  301. package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
  302. package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
  303. package/dist/prosemirror/runStyleFormatting.js +16 -13
  304. package/dist/prosemirror/schema/marks.d.ts +6 -0
  305. package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
  306. package/dist/prosemirror/tableGridMutation.d.ts +19 -2
  307. package/dist/prosemirror/tableGridMutation.js +118 -15
  308. package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
  309. package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
  310. package/dist/prosemirror/validation.js +2 -1
  311. package/dist/redline.js +23 -9
  312. package/dist/server.d.ts +2 -2
  313. package/dist/style-sets/extract.js +2 -2
  314. package/dist/types/canonicalCapabilities.d.ts +29 -8
  315. package/dist/types/canonicalCapabilities.js +13 -9
  316. package/dist/utils/cssString.d.ts +7 -0
  317. package/dist/utils/cssString.js +9 -0
  318. package/dist/utils/fontResolver.js +4 -1
  319. package/dist/utils/replaceText.d.ts +11 -0
  320. package/dist/utils/replaceText.js +39 -7
  321. package/dist/version-comparison.d.ts +9 -1
  322. package/dist/version-comparison.js +11 -5
  323. package/package.json +2 -2
@@ -23,7 +23,7 @@ import { pluginsForHeadlessRevisionResolution } from "../internal/headlessRevisi
23
23
  import { withTrackedSectionEndpointRemoval } from "../internal/sectionEndpointResolution.js";
24
24
  import { captureSectionReferenceInventory, resolvedSectionReferenceLosses, withSectionReferenceResolution } from "../internal/sectionReferenceResolution.js";
25
25
  import { expectCharacterStyleMarkAttrs, expectFootnoteRefMarkAttrs } from "../prosemirror/attrs/index.js";
26
- import { acceptAIEditRevision, acceptSuggestion, getSuggestions, rejectAIEditRevision, rejectAllSuggestions, rejectSuggestion, resolveAllChangesInHeadlessState, suggestionIdOfRevision } from "../prosemirror/commands/comments.js";
26
+ import { acceptAIEditRevision, acceptSuggestion, getSuggestions, rejectAIEditRevision, rejectAllSuggestions, rejectSuggestion, resolveAllChangesInHeadlessState, revisionResolutionLockViolation, suggestionIdOfRevision } from "../prosemirror/commands/comments.js";
27
27
  import { sectionRejectProperties } from "../prosemirror/commands/propertyChangeScope.js";
28
28
  import { allocateCommentId, createCommentIdAllocator, seedCommentAllocator } from "../prosemirror/commentIdAllocator.js";
29
29
  import { fromProseDoc, proseDocToBlocks } from "../prosemirror/conversion/fromProseDoc.js";
@@ -33,6 +33,7 @@ import { ensureParaIdsInDoc } from "../prosemirror/extensions/features/ParaIdAll
33
33
  import { getChangedParagraphIds, getTrackedSectionEndpointRemoval, hasStructuralChanges, hasUntrackedChanges } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
34
34
  import { completeNumberingForDoc } from "../prosemirror/listInstanceReferences.js";
35
35
  import "../prosemirror/listMarker.js";
36
+ import { lockedControlSpans } from "../prosemirror/lockedControls.js";
36
37
  import { deleteNoteWithReference, noteDeletionRevisions, noteKeysReferencedIn, noteReferenceStates, noteReferencesRestored, referenceDeletions, referencedNotes } from "../prosemirror/noteReferenceReview.js";
37
38
  import { createDocumentNumberingPlugin, getDocumentNumbering, withDocumentNumbering } from "../prosemirror/plugins/documentNumbering.js";
38
39
  import { getDocumentStyleResolver } from "../prosemirror/plugins/documentStyleState.js";
@@ -53,7 +54,7 @@ import { collectNoteReferenceLabels, createFolioAIEditSnapshotWithStyleResolver,
53
54
  import { matchTableGeometry } from "./table-geometry.js";
54
55
  import { tableTemplateCanCrossPackageLosslessly } from "./table-template.js";
55
56
  import { TaggedError, panic } from "better-result";
56
- import { REVIEW_CARRIERS, finalizeParagraphFormatting, numberingLevelEntries, setDocumentBodyComments } from "@stll/docx-core/model";
57
+ import { CONTENT_CONTROL_LOCK, REVIEW_CARRIERS, finalizeParagraphFormatting, lockedControlMessage, numberingLevelEntries, setDocumentBodyComments } from "@stll/docx-core/model";
57
58
  import { reconcileDocumentPartRelationships } from "@stll/docx-core/ops";
58
59
  import { EditorState } from "prosemirror-state";
59
60
  import { ZipArchive } from "@stll/docx-core/zip";
@@ -85,6 +86,12 @@ const createReviewerComment = ({ id, text, author, date }) => ({
85
86
  date: date ?? (/* @__PURE__ */ new Date()).toISOString(),
86
87
  content: [commentTextParagraph(text)]
87
88
  });
89
+ /**
90
+ * How many document-operation batches a reviewer can step back through.
91
+ * Each entry holds the story's state before and after its batch; older
92
+ * entries are dropped, as an editor's undo history drops its oldest steps.
93
+ */
94
+ const FOLIO_DOCUMENT_OPERATION_UNDO_LIMIT = 100;
88
95
  const FOLIO_REVIEWED_VIEWS = Object.freeze([
89
96
  "original",
90
97
  "current-markup",
@@ -238,9 +245,9 @@ const rejectSuggestions = (state) => {
238
245
  return settled;
239
246
  };
240
247
  const createHeadlessPlugins = (styles, numbering) => [
248
+ createDocumentNumberingPlugin(numbering),
241
249
  ...pluginsForHeadlessRevisionResolution(singletonManager.getPlugins()),
242
- createDocumentStylesPlugin(styles),
243
- createDocumentNumberingPlugin(numbering)
250
+ createDocumentStylesPlugin(styles)
244
251
  ];
245
252
  const createStateSnapshot = (state) => createFolioAIEditSnapshotWithStyleResolver(state.doc, getDocumentStyleResolver(state), getDocumentNumbering(state));
246
253
  const formatStorySnapshotForLLM = (snapshot, annotated) => {
@@ -310,6 +317,22 @@ const paragraphPlainText = (paragraph) => {
310
317
  * const reviewed = await reviewer.toBuffer();
311
318
  * ```
312
319
  */
320
+ /**
321
+ * The changes of a story, by revision id, that a content control's lock keeps
322
+ * from being resolved in `mode`: every physical revision of one change is
323
+ * resolved together, so the change is held when resolving them would break a
324
+ * lock. Empty without a locked control.
325
+ */
326
+ const lockHeldChanges = (state, mode) => {
327
+ const held = /* @__PURE__ */ new Map();
328
+ if (lockedControlSpans(state.doc).length === 0) return held;
329
+ for (const { id } of getTrackedChangesFromDoc(state.doc)) {
330
+ const ids = getTrackedChangeGroupIdsFromDoc(state.doc, id);
331
+ const violation = revisionResolutionLockViolation(state, ids, mode);
332
+ if (violation !== null) held.set(id, violation);
333
+ }
334
+ return held;
335
+ };
313
336
  var FolioDocxReviewer = class FolioDocxReviewer {
314
337
  /** Default author for tracked changes and comments. */
315
338
  author;
@@ -692,19 +715,10 @@ var FolioDocxReviewer = class FolioDocxReviewer {
692
715
  }
693
716
  });
694
717
  }
695
- /**
696
- * The package's numbering, flattened to what a reader sees: one entry per
697
- * numbering instance and level, with the format and level text that produce
698
- * its labels.
699
- *
700
- * Labels are rendered from these definitions rather than stored on the
701
- * paragraphs, so nothing in a block projection changes when a list is
702
- * renumbered — which is right for an insertion that renumbers the items
703
- * below it, and wrong for a list whose FORMAT changed. Sorted so two
704
- * packages can be compared entry by entry.
705
- */
706
- readNumberingDefinitions() {
707
- return numberingLevelsOf(completeNumberingForDoc(this.baseDocument.package.numbering, this.state.doc)).toSorted((left, right) => left.numId - right.numId || left.level - right.level);
718
+ readNumberingDefinitions(story = MAIN_STORY) {
719
+ const doc = story.type === "main" ? this.state.doc : this.readSecondaryStoryDoc(story);
720
+ if (!doc) return null;
721
+ return numberingLevelsOf(completeNumberingForDoc(this.baseDocument.package.numbering, doc)).toSorted((left, right) => left.numId - right.numId || left.level - right.level);
708
722
  }
709
723
  /** Return parsed package metadata without exposing the mutable document model. */
710
724
  getDocumentProperties() {
@@ -969,17 +983,25 @@ var FolioDocxReviewer = class FolioDocxReviewer {
969
983
  activeSuggestionIds
970
984
  });
971
985
  }
972
- if (result.undoHandle !== null) this.documentOperationUndoEntries.push({
973
- undoHandle: result.undoHandle,
974
- story,
975
- beforeState,
976
- afterState: view.state,
977
- createdCommentsLengthBefore,
978
- createdCommentsLengthAfter: this.createdComments.length
979
- });
986
+ if (result.undoHandle !== null) {
987
+ this.documentOperationUndoEntries.push({
988
+ undoHandle: result.undoHandle,
989
+ story,
990
+ beforeState,
991
+ afterState: view.state,
992
+ createdCommentsLengthBefore,
993
+ createdCommentsLengthAfter: this.createdComments.length
994
+ });
995
+ const excess = this.documentOperationUndoEntries.length - 100;
996
+ if (excess > 0) this.documentOperationUndoEntries.splice(0, excess);
997
+ }
980
998
  return result;
981
999
  }
982
- /** Undo the latest unchanged document-operation batch and its created comments. */
1000
+ /**
1001
+ * Undo the latest unchanged document-operation batch and its created
1002
+ * comments. Only the last {@link FOLIO_DOCUMENT_OPERATION_UNDO_LIMIT}
1003
+ * batches are kept; an older handle is `unknownHandle`.
1004
+ */
983
1005
  undoDocumentOperations(undoHandle) {
984
1006
  const entryIndex = this.documentOperationUndoEntries.findIndex((entry) => entry.undoHandle.type === undoHandle.type && entry.undoHandle.id === undoHandle.id);
985
1007
  if (entryIndex === -1) return {
@@ -1376,7 +1398,10 @@ var FolioDocxReviewer = class FolioDocxReviewer {
1376
1398
  * redline. Pass a {@link FolioReviewChange} from {@link getChanges} or its
1377
1399
  * revision id. Reuses the editor's own accept command headlessly, so the
1378
1400
  * resolved state persists on {@link toBuffer}. Returns `false` when the
1379
- * revision is no longer present (already resolved, or never existed).
1401
+ * revision is no longer present (already resolved, or never existed), or
1402
+ * when a content control's lock holds it: accepting would change a
1403
+ * content-locked control's content or remove a control locked against
1404
+ * removal. A held change stays pending as it is.
1380
1405
  */
1381
1406
  acceptChange(target) {
1382
1407
  return this.resolveWithSectionReferenceHistory(() => this.withNotesFollowingReferences(() => this.acceptChangeInternal(target)));
@@ -1384,6 +1409,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
1384
1409
  acceptChangeInternal(target) {
1385
1410
  const id = revisionIdOf(target);
1386
1411
  const ids = getTrackedChangeGroupIdsFromDoc(this.state.doc, id);
1412
+ if (revisionResolutionLockViolation(this.state, ids, "accept") !== null) return false;
1387
1413
  const suggestionId = suggestionIdOfRevision(this.state, id);
1388
1414
  if (suggestionId !== null && !this.runCommand(acceptSuggestion(suggestionId, { author: this.author }))) return false;
1389
1415
  let bodyChanged = false;
@@ -1401,6 +1427,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
1401
1427
  rejectChangeInternal(target) {
1402
1428
  const id = revisionIdOf(target);
1403
1429
  const ids = getTrackedChangeGroupIdsFromDoc(this.state.doc, id);
1430
+ if (revisionResolutionLockViolation(this.state, ids, "reject") !== null) return false;
1404
1431
  const suggestionId = suggestionIdOfRevision(this.state, id);
1405
1432
  if (suggestionId !== null && this.runCommand(rejectSuggestion(suggestionId))) return true;
1406
1433
  let bodyChanged = false;
@@ -1440,13 +1467,26 @@ var FolioDocxReviewer = class FolioDocxReviewer {
1440
1467
  * Every story, not just the body: a revision in a header or a footnote is
1441
1468
  * one a reviewer meant to resolve, and leaving it behind means an accepted
1442
1469
  * document still carries a redline nobody can see from the body.
1470
+ *
1471
+ * A change a content control's lock holds (see {@link acceptChange}) stays
1472
+ * pending as it is and is listed in `skipped`; `resolved` counts the
1473
+ * ordinary changes resolved.
1443
1474
  */
1444
1475
  acceptAll() {
1445
- return this.resolveWithSectionReferenceHistory(() => this.resolveEveryStory("accept") + this.resolveEveryFinalSectionChange("accept"));
1476
+ return this.resolveAll("accept");
1446
1477
  }
1447
1478
  /** Reject every tracked change in the package. See {@link acceptAll}. */
1448
1479
  rejectAll() {
1449
- return this.resolveWithSectionReferenceHistory(() => this.resolveEveryStory("reject") + this.resolveEveryFinalSectionChange("reject"));
1480
+ return this.resolveAll("reject");
1481
+ }
1482
+ resolveAll(mode) {
1483
+ return this.resolveWithSectionReferenceHistory(() => {
1484
+ const skipped = [];
1485
+ return {
1486
+ resolved: this.resolveEveryStory(mode, skipped) + this.resolveEveryFinalSectionChange(mode),
1487
+ skipped
1488
+ };
1489
+ });
1450
1490
  }
1451
1491
  resolveWithSectionReferenceHistory(resolve) {
1452
1492
  const before = captureSectionReferenceInventory(this.state.doc, this.currentFinalSectionProperties());
@@ -1482,8 +1522,8 @@ var FolioDocxReviewer = class FolioDocxReviewer {
1482
1522
  });
1483
1523
  return propertyChanges?.length ?? 0;
1484
1524
  }
1485
- resolveEveryStory(mode) {
1486
- return this.withNotesFollowingReferences(() => this.resolveEveryStoryOnce(mode));
1525
+ resolveEveryStory(mode, skipped) {
1526
+ return this.withNotesFollowingReferences(() => this.resolveEveryStoryOnce(mode, skipped));
1487
1527
  }
1488
1528
  /**
1489
1529
  * Change the body the way a note follows its reference: a note whose
@@ -1553,13 +1593,18 @@ var FolioDocxReviewer = class FolioDocxReviewer {
1553
1593
  }
1554
1594
  return keys;
1555
1595
  }
1556
- resolveEveryStoryOnce(mode) {
1596
+ resolveEveryStoryOnce(mode, skipped) {
1557
1597
  let count = 0;
1558
1598
  const resolvedStories = [];
1559
1599
  const refreshes = [];
1560
1600
  for (const handle of this.listStoryHandlesInternal()) {
1561
1601
  const state = this.getEditableStoryState(handle);
1562
1602
  if (!state) continue;
1603
+ const held = lockHeldChanges(state, mode);
1604
+ if (held.size > 0) {
1605
+ count += this.resolveStoryAroundHeldChanges(handle, mode, held, skipped);
1606
+ continue;
1607
+ }
1563
1608
  const ordinaryCount = getTrackedChangesFromDoc(state.doc).filter(({ id }) => mode === "reject" || suggestionIdOfRevision(state, id) === null).length;
1564
1609
  count += ordinaryCount;
1565
1610
  const withSuggestions = mode === "accept" && ordinaryCount > 0 && getSuggestions(state).length > 0 ? this.acceptOrdinaryChangesWithSuggestions(state, handle) : null;
@@ -1580,6 +1625,31 @@ var FolioDocxReviewer = class FolioDocxReviewer {
1580
1625
  }
1581
1626
  return count;
1582
1627
  }
1628
+ /**
1629
+ * Resolve each change of a story a content control's lock does not hold, on
1630
+ * its own: the one-pass resolver takes the whole story or nothing. The held
1631
+ * changes stay pending as they are and are reported in `skipped`.
1632
+ */
1633
+ resolveStoryAroundHeldChanges(handle, mode, held, skipped) {
1634
+ for (const [id, violation] of held) skipped.push({
1635
+ id,
1636
+ reason: CONTENT_CONTROL_LOCK,
1637
+ message: lockedControlMessage(violation)
1638
+ });
1639
+ const state = this.getEditableStoryState(handle);
1640
+ if (!state) return 0;
1641
+ let resolved = 0;
1642
+ for (const { id } of getTrackedChangesFromDoc(state.doc).toReversed()) {
1643
+ if (held.has(id)) continue;
1644
+ const current = this.getEditableStoryState(handle);
1645
+ if (!current) break;
1646
+ const ids = getTrackedChangeGroupIdsFromDoc(current.doc, id);
1647
+ if (ids.length === 0) continue;
1648
+ const resolveOne = mode === "accept" ? acceptAIEditRevision(ids) : rejectAIEditRevision(ids);
1649
+ if (this.runStoryCommand(resolveOne, handle)) resolved += 1;
1650
+ }
1651
+ return resolved;
1652
+ }
1583
1653
  acceptOrdinaryChangesWithSuggestions(state, story) {
1584
1654
  const originalSuggestions = getSuggestions(state);
1585
1655
  const records = this.exportPendingSuggestions().filter((record) => editableStoryKey(record.story) === editableStoryKey(story));
@@ -1775,7 +1845,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
1775
1845
  }));
1776
1846
  }
1777
1847
  if (kept.length !== definitions.length || snapshot.createdComments.length > 0 || snapshot.resolvedOverrides.size > 0) setDocumentBodyComments(document.package.document, this.withResolvedOverrides(kept, snapshot.resolvedOverrides));
1778
- const normalized = normalizeListModelRendering(reconcileDocumentPartRelationships(document)).document;
1848
+ const normalized = normalizeListModelRendering(reconcileDocumentPartRelationships(document), { inverse: "omit" }).document;
1779
1849
  visitDocxParagraphs({
1780
1850
  documentBody: normalized.package.document,
1781
1851
  headers: normalized.package.headers,
@@ -2310,4 +2380,4 @@ const applyFolioAIEditsToBuffer = async (buffer, operations, options = {}) => {
2310
2380
  skipped
2311
2381
  };
2312
2382
  };
2313
- export { FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioDocumentStoryNotFoundError, FolioDocxReviewer, UnsupportedFolioReviewedViewError, applyFolioAIEditsToBuffer, getFolioDocxComparisonAccess, isFolioResolvedReviewedView, isFolioReviewedView };
2383
+ export { FOLIO_DOCUMENT_OPERATION_UNDO_LIMIT, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioDocumentStoryNotFoundError, FolioDocxReviewer, UnsupportedFolioReviewedViewError, applyFolioAIEditsToBuffer, getFolioDocxComparisonAccess, isFolioResolvedReviewedView, isFolioReviewedView };
@@ -6,10 +6,10 @@ import { DocPositionRange, clampRangeToDocSize, resolveFolioAIBlockRange, resolv
6
6
  import { buildAnnotatedBlockText } from "./clean-text.js";
7
7
  import { ApplyFolioDocumentOperationsOptions, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationResultBase, FolioDocumentOperationStatus, FolioDocumentOperationStory, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "../document-operations.js";
8
8
  import { FOLIO_PENDING_SUGGESTION_VERSION, FolioPendingSuggestionLoadResult, FolioPendingSuggestionRecord, FolioPendingSuggestionRegistry, FolioPendingSuggestionStaleReason, createPendingSuggestionSourceSnapshot } from "./pending-suggestions.js";
9
- import { FolioCommentAnchor, FolioReviewChange, FolioReviewChangeKind, getCommentAnchorsFromDoc, getTrackedChangesFromDoc } from "./read.js";
9
+ import { FolioCommentAnchor, FolioReviewChange, FolioReviewChangeKind, FolioReviewResolution, FolioReviewResolutionSkip, getCommentAnchorsFromDoc, getTrackedChangesFromDoc } from "./read.js";
10
10
  import { createFolioAIEditSnapshot, createFolioAIEditSnapshotWithStyleResolver, createFolioAITextRangeHandle, hashFolioAIBlockText, isFolioAIContentBlock, normalizeFolioAIBlockText } from "./snapshot.js";
11
11
  import { FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioApplyDocumentOperationsToStoryOptions, FolioDocumentStory, FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioEditableDocumentStoryHandle, FolioReadReviewedStoryOptions, FolioResolveReviewedStoryOptions, FolioResolvedReviewedView, FolioReviewedStory, FolioReviewedView, UnsupportedFolioReviewedViewError, isFolioResolvedReviewedView, isFolioReviewedView } from "./headless.js";
12
12
  import { getFolioDocumentOutline, readFolioDocumentSection } from "./scoped-reading.js";
13
13
  import { getFolioDocumentOperationRemovedBlockIds } from "./removed-blocks.js";
14
14
  import { getFolioParaIdFromBlockId } from "../types/block-id.js";
15
- export { type ApplyFolioDocumentOperationsOptions, type DocPositionRange, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_PENDING_SUGGESTION_VERSION, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIEditView, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIInsertFormattingScope, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsToStoryOptions, type FolioCommentAnchor, type FolioContentParagraphKind, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioEditableDocumentStoryHandle, type FolioPendingSuggestionLoadResult, type FolioPendingSuggestionRecord, FolioPendingSuggestionRegistry, type FolioPendingSuggestionStaleReason, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeKind, type FolioReviewedStory, type FolioReviewedView, type FolioRevisionStamp, type FolioUndefinedReferencePolicy, type FolioWordDiffOptions, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioReviewedViewError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, applyFolioAIEditOperations, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, buildAnnotatedBlockText, clampRangeToDocSize, createFolioAIEditSnapshot, createFolioAIEditSnapshotWithStyleResolver, createFolioAITextRangeHandle, createPendingSuggestionSourceSnapshot, diffWordSegments, getCommentAnchorsFromDoc, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationRemovedBlockIds, getFolioDocumentOutline, getFolioParaIdFromBlockId, getTrackedChangesFromDoc, hashFolioAIBlockText, isFolioAIContentBlock, isFolioDocumentOperationModeSupported, isFolioResolvedReviewedView, isFolioReviewedView, isSupportedFolioDocumentOperationVersion, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, readFolioDocumentSection, resolveFolioAIBlockRange, resolveFolioAITextRange, resolvePassageRange };
15
+ export { type ApplyFolioDocumentOperationsOptions, type DocPositionRange, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_PENDING_SUGGESTION_VERSION, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIEditView, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIInsertFormattingScope, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsToStoryOptions, type FolioCommentAnchor, type FolioContentParagraphKind, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioEditableDocumentStoryHandle, type FolioPendingSuggestionLoadResult, type FolioPendingSuggestionRecord, FolioPendingSuggestionRegistry, type FolioPendingSuggestionStaleReason, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeKind, type FolioReviewResolution, type FolioReviewResolutionSkip, type FolioReviewedStory, type FolioReviewedView, type FolioRevisionStamp, type FolioUndefinedReferencePolicy, type FolioWordDiffOptions, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioReviewedViewError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, applyFolioAIEditOperations, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, buildAnnotatedBlockText, clampRangeToDocSize, createFolioAIEditSnapshot, createFolioAIEditSnapshotWithStyleResolver, createFolioAITextRangeHandle, createPendingSuggestionSourceSnapshot, diffWordSegments, getCommentAnchorsFromDoc, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationRemovedBlockIds, getFolioDocumentOutline, getFolioParaIdFromBlockId, getTrackedChangesFromDoc, hashFolioAIBlockText, isFolioAIContentBlock, isFolioDocumentOperationModeSupported, isFolioResolvedReviewedView, isFolioReviewedView, isSupportedFolioDocumentOperationVersion, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, readFolioDocumentSection, resolveFolioAIBlockRange, resolveFolioAITextRange, resolvePassageRange };
@@ -63,6 +63,12 @@ export declare const cutsIntoNoteReference: ({ structuralBoundaries }: Structura
63
63
  export declare const withComparisonNoteReferenceEdits: <T>(apply: () => T) => T;
64
64
  /** @internal Whether the running apply belongs to a comparison (see above). */
65
65
  export declare const noteReferenceEditsAllowed: () => boolean;
66
+ /**
67
+ * @internal Whether the running apply belongs to a comparison. Its operations
68
+ * describe differences two documents already hold, so the content-control
69
+ * locks, which guard editing a document, do not refuse them.
70
+ */
71
+ export declare const comparisonApplying: () => boolean;
66
72
  /** The pieces of a replacement between the markers it has to keep. */
67
73
  type NoteReferenceSegments = {
68
74
  /** The source text between markers, with its offset in the source. */
@@ -78,6 +78,12 @@ const withComparisonNoteReferenceEdits = (apply) => {
78
78
  };
79
79
  /** @internal Whether the running apply belongs to a comparison (see above). */
80
80
  const noteReferenceEditsAllowed = () => comparisonEditsNoteReferences;
81
+ /**
82
+ * @internal Whether the running apply belongs to a comparison. Its operations
83
+ * describe differences two documents already hold, so the content-control
84
+ * locks, which guard editing a document, do not refuse them.
85
+ */
86
+ const comparisonApplying = () => comparisonEditsNoteReferences;
81
87
  const NOTE_MARKER_PATTERN = /\[\^e?[1-9]\d*\]/gu;
82
88
  const markerCount = (text) => text.match(NOTE_MARKER_PATTERN)?.length ?? 0;
83
89
  /**
@@ -135,4 +141,4 @@ const planChangesAroundNoteReferences = (source, replacement, spans, planChanges
135
141
  text: change.text
136
142
  })));
137
143
  };
138
- export { createNoteReferenceLabeler, cutsIntoNoteReference, noteReferenceEditsAllowed, noteReferenceOf, noteReferenceSpansWithin, planChangesAroundNoteReferences, readerTextOf, segmentsAroundNoteReferences, withComparisonNoteReferenceEdits };
144
+ export { comparisonApplying, createNoteReferenceLabeler, cutsIntoNoteReference, noteReferenceEditsAllowed, noteReferenceOf, noteReferenceSpansWithin, planChangesAroundNoteReferences, readerTextOf, segmentsAroundNoteReferences, withComparisonNoteReferenceEdits };
@@ -49,6 +49,25 @@ export type FolioReviewChange = {
49
49
  */
50
50
  blockId: string | null;
51
51
  };
52
+ /** A tracked change an accept-all or reject-all left pending, and why. */
53
+ export type FolioReviewResolutionSkip = {
54
+ /** The change's revision id, as {@link FolioReviewChange.id}. */
55
+ id: number;
56
+ /**
57
+ * `contentControlLock`: resolving it would change the content of a content
58
+ * control whose `w:lock` is `contentLocked` or `sdtContentLocked`, or remove
59
+ * one whose lock is `sdtLocked` or `sdtContentLocked`.
60
+ */
61
+ reason: "contentControlLock";
62
+ message: string;
63
+ };
64
+ /** What an accept-all or reject-all did. */
65
+ export type FolioReviewResolution = {
66
+ /** The ordinary tracked changes it resolved. */
67
+ resolved: number;
68
+ /** The changes it left pending, each as it was. */
69
+ skipped: FolioReviewResolutionSkip[];
70
+ };
52
71
  /** A comment anchor (the ranged text a comment marks) discovered in the body. */
53
72
  export type FolioCommentAnchor = {
54
73
  commentId: number;
@@ -1,6 +1,6 @@
1
1
  import { expectRunPropertyChangeMarkAttrs, expectTrackedChangeMarkAttrs } from "../prosemirror/attrs/index.js";
2
2
  import { getFolioNodeRevisionCarriers } from "../prosemirror/revisionCarriers.js";
3
- import { expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomDisposition } from "../prosemirror/runFormattingInlineCarriers.js";
3
+ import { expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomDisposition, runFormattingInlineAtomResultText } from "../prosemirror/runFormattingInlineCarriers.js";
4
4
  import { getTableCellMergeChange } from "../prosemirror/tableCellMergeRevision.js";
5
5
  import { enclosingInsertionAncestors, trackedRevisionLayerOf } from "../prosemirror/trackedRevisionPath.js";
6
6
  import { commentAnchorIdsForNode } from "./comment-lifecycle.js";
@@ -356,8 +356,10 @@ const getCommentAnchorsFromDoc = (doc) => {
356
356
  start: bodyText.length,
357
357
  end: bodyText.length
358
358
  });
359
- if (!node.isInline || node.text === void 0) return;
360
- const text = readerTextOf(node, noteReferences);
359
+ const isStructuredField = node.type.name === "structuredField";
360
+ const fieldText = isStructuredField ? node.textContent : runFormattingInlineAtomResultText(node);
361
+ if (!node.isInline || node.text === void 0 && fieldText === null) return;
362
+ const text = node.text === void 0 ? fieldText ?? "" : readerTextOf(node, noteReferences);
361
363
  const end = bodyText.length + text.length;
362
364
  for (const mark of node.marks) {
363
365
  if (mark.type !== commentType || typeof mark.attrs["commentId"] !== "number") continue;
@@ -372,7 +374,7 @@ const getCommentAnchorsFromDoc = (doc) => {
372
374
  end
373
375
  });
374
376
  }
375
- bodyText += text;
377
+ if (!isStructuredField) bodyText += text;
376
378
  });
377
379
  return [...ranges].map(([commentId, { blockId, start, end }]) => ({
378
380
  commentId,
@@ -67,6 +67,12 @@ export declare const isFolioAIContentBlock: ({ text }: Pick<FolioAIBlock, "text"
67
67
  */
68
68
  export declare const trailingBodyBlockId: ({ blocks }: FolioAIEditSnapshot) => string | null;
69
69
  export declare const hashFolioAIBlockText: (text: string) => string;
70
+ /**
71
+ * The identity of a block's text: what a snapshot anchor records, and what an
72
+ * engine compares an anchor or a precondition against. Whitespace runs collapse
73
+ * and the ends trim, so a block reads the same however its spaces were typed.
74
+ */
75
+ export declare const hashFolioAIBlockContent: (text: string) => string;
70
76
  /**
71
77
  * Canonical public projection of the clean view's inline structure.
72
78
  *
@@ -241,6 +241,12 @@ const hashFolioAIBlockText = (text) => {
241
241
  for (const character of text) hash = (hash * 33 + (character.codePointAt(0) ?? 0)) % 2147483647;
242
242
  return `h${hash.toString(36)}`;
243
243
  };
244
+ /**
245
+ * The identity of a block's text: what a snapshot anchor records, and what an
246
+ * engine compares an anchor or a precondition against. Whitespace runs collapse
247
+ * and the ends trim, so a block reads the same however its spaces were typed.
248
+ */
249
+ const hashFolioAIBlockContent = (text) => hashFolioAIBlockText(normalizeFolioAIBlockText(text));
244
250
  const EMPTY_FOLIO_AI_BLOCK_STRUCTURAL_BOUNDARIES = Object.freeze([]);
245
251
  const EMPTY_FOLIO_AI_BLOCK_STRUCTURAL_BOUNDARY_HASH = hashFolioAIBlockText(JSON.stringify(EMPTY_FOLIO_AI_BLOCK_STRUCTURAL_BOUNDARIES));
246
252
  /**
@@ -368,7 +374,7 @@ const STORY_TABLE_HIDDEN_SUBTREE = "hidden-subtree";
368
374
  const STORY_TABLE = "table";
369
375
  /** Shared visibility and table-role rule for both story projection walks. */
370
376
  const classifyNonTextblockStoryTableNode = (node) => {
371
- if (isHiddenTableRow(node)) return STORY_TABLE_HIDDEN_SUBTREE;
377
+ if (isHiddenTableRow(node) || node.attrs["_omittedGridSlot"]) return STORY_TABLE_HIDDEN_SUBTREE;
372
378
  return node.type.spec["tableRole"] === TABLE_ROLE_TABLE ? STORY_TABLE : STORY_TABLE_CONTAINER;
373
379
  };
374
380
  /**
@@ -508,7 +514,7 @@ const createFolioAIEditSnapshotInternal = (doc, styleResolver, noteReferenceLabe
508
514
  const structuralBoundaries = projectFolioAIBlockStructuralBoundaries(cleanBlock);
509
515
  const structuralBoundaryHash = hashFolioAIBlockStructuralBoundaryProjection(structuralBoundaries);
510
516
  const normalizedText = normalizeFolioAIBlockText(text);
511
- const textHash = hashFolioAIBlockText(normalizedText);
517
+ const textHash = hashFolioAIBlockContent(text);
512
518
  hashCounts.set(textHash, (hashCounts.get(textHash) ?? 0) + 1);
513
519
  const paraIdAttr = node.attrs["paraId"];
514
520
  const paraId = typeof paraIdAttr === "string" && paraIdAttr.length > 0 ? paraIdAttr : null;
@@ -704,18 +710,7 @@ const getPreviewRuns = ({ node, nodeFrom, cleanBlock, styleResolver }) => {
704
710
  const defaultStyle = getDefaultPreviewRunStyle(node, styleResolver);
705
711
  let paragraphStyleContext;
706
712
  let cleanOffset = 0;
707
- node.descendants((child, relativePosition) => {
708
- const start = nodeFrom + 1 + relativePosition;
709
- const noteReference = cleanBlock.structuralBoundaries.find((boundary) => boundary.type === "noteReference" && boundary.from === start);
710
- let text;
711
- if (noteReference !== void 0) text = cleanBlock.text.slice(noteReference.offset, noteReference.offset + noteReference.length);
712
- else text = child.isText ? child.text : runFormattingInlineAtomCleanText(child);
713
- if (text === void 0 || text === null || text.length === 0) return true;
714
- if (child.marks.some((mark) => mark.type.name === DELETION_MARK || mark.type.name === HIDDEN_MARK)) return false;
715
- while ((cleanBlock.offsets[cleanOffset] ?? Number.POSITIVE_INFINITY) < start) cleanOffset++;
716
- const lastCharacterPosition = child.isText && noteReference === void 0 ? start + text.length - 1 : start;
717
- if (cleanBlock.offsets[cleanOffset] !== start || cleanBlock.offsets[cleanOffset + text.length - 1] !== lastCharacterPosition) return false;
718
- cleanOffset += text.length;
713
+ const pushRun = (child, text) => {
719
714
  const style = getPreviewRunStyle(child.marks, defaultStyle);
720
715
  const hasAuthorshipCarrier = child.marks.some(({ type }) => type.name === RUN_FORMATTING_OVERRIDE_MARK || type.name === CHARACTER_STYLE_MARK);
721
716
  let directFormatting;
@@ -726,7 +721,6 @@ const getPreviewRuns = ({ node, nodeFrom, cleanBlock, styleResolver }) => {
726
721
  baseParagraphFormatting: paragraphStyleContext.baseParagraphFormatting,
727
722
  inheritedFormatting: paragraphStyleContext.paragraphFormatting,
728
723
  paragraphMarkFormatting: paragraphStyleContext.paragraphMarkFormatting,
729
- paragraphMarkPrecedesStyle: paragraphStyleContext.paragraphMarkPrecedesStyle,
730
724
  styleResolver
731
725
  });
732
726
  directFormatting = getDirectPreviewRunStyle(child.marks, directTextFormatting, styleResolver);
@@ -734,13 +728,34 @@ const getPreviewRuns = ({ node, nodeFrom, cleanBlock, styleResolver }) => {
734
728
  const previous = runs.at(-1);
735
729
  if (previous && samePreviewRunStyle(previous, style) && sameDirectFormatting(previous.directFormatting, directFormatting)) {
736
730
  previous.text += text;
737
- return false;
731
+ return;
738
732
  }
739
733
  runs.push({
740
734
  text,
741
735
  ...style,
742
736
  ...!isEmptyPreviewRunStyle(directFormatting) && { directFormatting }
743
737
  });
738
+ };
739
+ node.descendants((child, relativePosition) => {
740
+ const start = nodeFrom + 1 + relativePosition;
741
+ const noteReference = cleanBlock.structuralBoundaries.find((boundary) => boundary.type === "noteReference" && boundary.from === start);
742
+ let text;
743
+ if (noteReference !== void 0) text = cleanBlock.text.slice(noteReference.offset, noteReference.offset + noteReference.length);
744
+ else if (child.type.name === "structuredField") text = child.textContent;
745
+ else text = child.isText ? child.text : runFormattingInlineAtomCleanText(child);
746
+ if (text === void 0 || text === null || text.length === 0) return true;
747
+ if (child.marks.some((mark) => mark.type.name === DELETION_MARK || mark.type.name === HIDDEN_MARK)) return false;
748
+ while ((cleanBlock.offsets[cleanOffset] ?? Number.POSITIVE_INFINITY) < start) cleanOffset++;
749
+ const lastCharacterPosition = child.isText && noteReference === void 0 ? start + text.length - 1 : start;
750
+ if (cleanBlock.offsets[cleanOffset] !== start || cleanBlock.offsets[cleanOffset + text.length - 1] !== lastCharacterPosition) return false;
751
+ cleanOffset += text.length;
752
+ if (child.type.name === "structuredField") {
753
+ child.forEach((run) => {
754
+ if (run.isText && run.text) pushRun(run, run.text);
755
+ });
756
+ return false;
757
+ }
758
+ pushRun(child, text);
744
759
  return false;
745
760
  });
746
761
  if (runs.every(isUnstyledPreviewRun)) return;
@@ -884,4 +899,4 @@ const samePreviewRunStyle = (run, style) => run.bold === style.bold && run.itali
884
899
  const isEmptyPreviewRunStyle = ({ bold, italic, underline, strike, fontFamily, fontSizePt, color }) => bold === void 0 && italic === void 0 && underline === void 0 && strike === void 0 && fontFamily === void 0 && fontSizePt === void 0 && color === void 0;
885
900
  const sameDirectFormatting = (left, right) => left === void 0 && isEmptyPreviewRunStyle(right) || left !== void 0 && left.bold === right.bold && left.italic === right.italic && left.underline === right.underline && left.strike === right.strike && left.fontFamily === right.fontFamily && left.fontSizePt === right.fontSizePt && left.color === right.color;
886
901
  const isUnstyledPreviewRun = ({ directFormatting, ...style }) => isEmptyPreviewRunStyle(style) && (directFormatting === void 0 || isEmptyPreviewRunStyle(directFormatting));
887
- export { alignedNoteReferenceLabels, collectNoteReferenceLabels, createFolioAIEditSnapshot, createFolioAIEditSnapshotWithStyleResolver, createFolioAITextRangeHandle, detachFolioAIEditSnapshotExternalHyperlinks, folioStoryTables, hashFolioAIBlockStructuralBoundaries, hashFolioAIBlockText, isFolioAIContentBlock, isHiddenTableRow, normalizeFolioAIBlockText, numberingReferenceKeysOf, projectFolioAIBlockStructuralBoundaries, relabelFolioAIEditSnapshotNoteReferences, remapFolioAIEditSnapshotNumberingReferences, remapFolioAIEditSnapshotStyleReferences, sourceDocumentOf, storyTablesOf, styleResolverOf, trailingBodyBlockId };
902
+ export { alignedNoteReferenceLabels, collectNoteReferenceLabels, createFolioAIEditSnapshot, createFolioAIEditSnapshotWithStyleResolver, createFolioAITextRangeHandle, detachFolioAIEditSnapshotExternalHyperlinks, folioStoryTables, hashFolioAIBlockContent, hashFolioAIBlockStructuralBoundaries, hashFolioAIBlockText, isFolioAIContentBlock, isHiddenTableRow, normalizeFolioAIBlockText, numberingReferenceKeysOf, projectFolioAIBlockStructuralBoundaries, relabelFolioAIEditSnapshotNoteReferences, remapFolioAIEditSnapshotNumberingReferences, remapFolioAIEditSnapshotStyleReferences, sourceDocumentOf, storyTablesOf, styleResolverOf, trailingBodyBlockId };
@@ -22,7 +22,7 @@ const mergeTableRectangle = ({ tr, tablePosition, table, rectangle }) => {
22
22
  const cellPosition = map.map[row * map.width + column];
23
23
  if (cellPosition === void 0 || seen.has(cellPosition)) continue;
24
24
  const cell = table.nodeAt(cellPosition);
25
- if (!cell) return null;
25
+ if (!cell || cell.attrs["_omittedGridSlot"]) return null;
26
26
  seen.add(cellPosition);
27
27
  cells.push({
28
28
  position: cellPosition,
@@ -63,7 +63,7 @@ const mergeTableRectangle = ({ tr, tablePosition, table, rectangle }) => {
63
63
  const contentStart = isEmptyTableCell(merged.cell) ? absoluteMergedPosition + 1 : contentEnd;
64
64
  tr = tr.replaceWith(contentStart, contentEnd, appendedContent);
65
65
  }
66
- removeRowsWithoutCells(tr, tablePosition);
66
+ removeRowsWithoutCells(tr, tablePosition, table);
67
67
  return tr;
68
68
  };
69
69
  const mergeTopRowColwidths = (cells, mergedColspan) => {
@@ -109,6 +109,7 @@ const mergeTrackedVerticalTableCells = ({ tr, tablePosition, table, rectangle, r
109
109
  const position = map.map[row * map.width + rectangle.left];
110
110
  if (position === void 0) return null;
111
111
  const cell = table.nodeAt(position);
112
+ if (cell?.attrs["_omittedGridSlot"]) return null;
112
113
  if (!cell || !tableRectanglesEqual(map.findCell(position), {
113
114
  left: rectangle.left,
114
115
  top: row,
@@ -1,6 +1,6 @@
1
1
  import { addTrackedDeletionMark } from "../prosemirror/addTrackedDeletionMark.js";
2
2
  import { markStructuralChange } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
3
- import { markRowsEmptiedInBatch, reconcileTableGridAfterColumnInsertion, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCells, removeTableRow } from "../prosemirror/tableGridMutation.js";
3
+ import { markRowsEmptiedInBatch, omittedSlotTakingColumn, reconcileTableGridAfterColumnInsertion, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCells, removeTableRow } from "../prosemirror/tableGridMutation.js";
4
4
  import { sliceText } from "../utils/sliceText.js";
5
5
  import { stripBlockIdentityAttrs } from "./block-identity.js";
6
6
  import { findEnclosingTableCell, findEnclosingTableRow } from "./table-targets.js";
@@ -177,7 +177,7 @@ const applyTableColumnInsertion = ({ tr, insertion, cellTexts, revision }) => {
177
177
  if (insertion.columnIndex >= 0 && insertion.columnIndex <= map.width) {
178
178
  const overflow = describeUnplacedCellTexts({
179
179
  cellTexts,
180
- capacity: getInsertedPhysicalColumnRows(map, insertion.columnIndex).length,
180
+ capacity: getInsertedPhysicalColumnRows(map, table, insertion.columnIndex).length,
181
181
  target: "column"
182
182
  });
183
183
  if (overflow !== null) return {
@@ -200,6 +200,10 @@ const applyTableColumnInsertion = ({ tr, insertion, cellTexts, revision }) => {
200
200
  tr.setNodeMarkup(position, void 0, action.attrs);
201
201
  continue;
202
202
  }
203
+ if (action.type === "growOmittedSlot") {
204
+ tr.setNodeAttribute(position, "colspan", action.colspan);
205
+ continue;
206
+ }
203
207
  const cell = revision ? action.cell.type.create({
204
208
  ...action.cell.attrs,
205
209
  cellMarker: {
@@ -267,7 +271,7 @@ const applyTableColumnDeletion = ({ tr, deletion, insertedColumnCount, revision,
267
271
  previousTable: table,
268
272
  emptied: emptiedRows
269
273
  });
270
- else removeRowsWithoutCells(tr, tablePosition);
274
+ else removeRowsWithoutCells(tr, tablePosition, table);
271
275
  return applied(tr, null);
272
276
  };
273
277
  const applyTableRowDeletion = ({ tr, deletion, revision }) => {
@@ -391,11 +395,11 @@ const populateTableRow = (row, cellTexts) => {
391
395
  });
392
396
  return row.type.create(row.attrs, cells);
393
397
  };
394
- const getInsertedPhysicalColumnRows = (map, columnIndex) => {
398
+ const getInsertedPhysicalColumnRows = (map, table, columnIndex) => {
395
399
  const rows = [];
396
400
  for (let row = 0; row < map.height; row++) {
397
401
  const index = row * map.width + columnIndex;
398
- if (!(columnIndex > 0 && columnIndex < map.width && map.map[index - 1] === map.map[index])) rows.push(row);
402
+ if (!(columnIndex > 0 && columnIndex < map.width && map.map[index - 1] === map.map[index]) && omittedSlotTakingColumn(map, table, row, columnIndex) === null) rows.push(row);
399
403
  }
400
404
  return rows;
401
405
  };
@@ -423,7 +427,7 @@ const populateTableCell = (cell, text) => {
423
427
  };
424
428
  const buildTableColumnInsertionActions = ({ map, table, columnIndex, cellTexts }) => {
425
429
  if (columnIndex < 0 || columnIndex > map.width) return null;
426
- const physicalRows = getInsertedPhysicalColumnRows(map, columnIndex);
430
+ const physicalRows = getInsertedPhysicalColumnRows(map, table, columnIndex);
427
431
  if ((cellTexts?.length ?? 0) > physicalRows.length) return null;
428
432
  let referenceColumn = columnIndex > 0 ? -1 : 0;
429
433
  if (columnIsHeader(map, table, columnIndex + referenceColumn)) referenceColumn = columnIndex === 0 || columnIndex === map.width ? null : 0;
@@ -431,6 +435,15 @@ const buildTableColumnInsertionActions = ({ map, table, columnIndex, cellTexts }
431
435
  let physicalCellIndex = 0;
432
436
  for (let row = 0; row < map.height; row++) {
433
437
  const index = row * map.width + columnIndex;
438
+ const omitted = omittedSlotTakingColumn(map, table, row, columnIndex);
439
+ if (omitted !== null) {
440
+ actions.push({
441
+ type: "growOmittedSlot",
442
+ position: omitted,
443
+ colspan: (Number(table.nodeAt(omitted)?.attrs["colspan"]) || 1) + 1
444
+ });
445
+ continue;
446
+ }
434
447
  if (columnIndex > 0 && columnIndex < map.width && map.map[index - 1] === map.map[index]) {
435
448
  const position = map.map[index];
436
449
  if (position === void 0) return null;
@@ -468,6 +481,7 @@ const getTableColumnDeletionCellPositions = ({ map, table, columnIndex }) => {
468
481
  const position = map.map[row * map.width + columnIndex];
469
482
  if (position === void 0) return null;
470
483
  const cell = table.nodeAt(position);
484
+ if (cell?.attrs["_omittedGridSlot"]) continue;
471
485
  const tableRole = cell?.type.spec["tableRole"];
472
486
  if (!cell || tableRole !== "cell" && tableRole !== "header_cell" || cell.attrs["colspan"] !== 1 || cell.attrs["cellMarker"] != null) return null;
473
487
  positions.add(position);
@@ -564,7 +564,15 @@ export type FolioAIResolvedEditOperation = FolioAIEditOperation<FolioContentStat
564
564
  * `unsupportedMode`.
565
565
  */
566
566
  export type FolioAIEditApplyMode = "direct" | "tracked-changes" | "suggested";
567
- export type FolioAIEditSkipReason = "missingBlock" | "changedBlock" | "ambiguousFind" | "missingFind" | "unsupportedBlock" | "unsupportedMode" | "atomicBatchRejected" | "preconditionFailed" | "staleRange" | "emptyOperation" |
567
+ export type FolioAIEditSkipReason =
568
+ /**
569
+ * A content control's `w:lock` forbids the change: it reaches inside a
570
+ * control whose content is locked (`contentLocked`, `sdtContentLocked`), or
571
+ * removes one that may not be removed (`sdtLocked`, `sdtContentLocked`),
572
+ * also by deleting the paragraph or text that holds it. Nothing was
573
+ * applied; `message` names the lock.
574
+ */
575
+ "contentControlLock" | "missingBlock" | "changedBlock" | "ambiguousFind" | "missingFind" | "unsupportedBlock" | "unsupportedMode" | "atomicBatchRejected" | "preconditionFailed" | "staleRange" | "emptyOperation" |
568
576
  /** The paragraph already owns the one `w:pPrChange` OOXML permits. */
569
577
  "pendingParagraphPropertyChange" |
570
578
  /** The affected run already owns the one `w:rPrChange` OOXML permits. */