@stll/folio-core 0.68.0 → 0.70.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 (1134) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +4 -4
  2. package/dist/ai-edits/apply.d.ts +39 -16
  3. package/dist/ai-edits/apply.js +1014 -723
  4. package/dist/ai-edits/block-identity.d.ts +6 -0
  5. package/dist/ai-edits/block-identity.js +11 -1
  6. package/dist/ai-edits/blockRange.d.ts +9 -0
  7. package/dist/ai-edits/clean-text.d.ts +2 -0
  8. package/dist/ai-edits/clean-text.js +2 -1
  9. package/dist/ai-edits/comment-lifecycle.d.ts +24 -0
  10. package/dist/ai-edits/comment-lifecycle.js +17 -8
  11. package/dist/ai-edits/directJoin.d.ts +30 -0
  12. package/dist/ai-edits/directJoin.js +30 -0
  13. package/dist/ai-edits/existingRevisions.d.ts +9 -0
  14. package/dist/ai-edits/existingRevisions.js +30 -0
  15. package/dist/ai-edits/finalSectionReview.d.ts +11 -0
  16. package/dist/ai-edits/finalSectionReview.js +26 -0
  17. package/dist/ai-edits/headless.d.ts +275 -14
  18. package/dist/ai-edits/headless.js +1597 -195
  19. package/dist/ai-edits/index.d.ts +11 -10
  20. package/dist/ai-edits/index.js +2 -2
  21. package/dist/ai-edits/markdownInsertion.d.ts +25 -0
  22. package/dist/ai-edits/markdownInsertion.js +67 -0
  23. package/dist/ai-edits/minimal-replacement.d.ts +120 -1
  24. package/dist/ai-edits/minimal-replacement.js +81 -1
  25. package/dist/ai-edits/newListNumbering.d.ts +31 -7
  26. package/dist/ai-edits/newListNumbering.js +46 -8
  27. package/dist/ai-edits/note-references.d.ts +19 -1
  28. package/dist/ai-edits/note-references.js +3 -1
  29. package/dist/ai-edits/pending-suggestions.d.ts +44 -2
  30. package/dist/ai-edits/pending-suggestions.js +483 -22
  31. package/dist/ai-edits/pendingJoin.d.ts +170 -0
  32. package/dist/ai-edits/pendingJoin.js +272 -0
  33. package/dist/ai-edits/read.d.ts +57 -4
  34. package/dist/ai-edits/read.js +317 -40
  35. package/dist/ai-edits/removed-blocks.d.ts +1 -1
  36. package/dist/ai-edits/result-validation.d.ts +36 -1
  37. package/dist/ai-edits/result-validation.js +1 -1
  38. package/dist/ai-edits/retired-comment-receipts.d.ts +20 -0
  39. package/dist/ai-edits/retired-comment-receipts.js +165 -0
  40. package/dist/ai-edits/revisionStretches.d.ts +17 -0
  41. package/dist/ai-edits/snapshot.d.ts +12 -3
  42. package/dist/ai-edits/snapshot.js +9 -7
  43. package/dist/ai-edits/snapshotBatchFacts.d.ts +52 -0
  44. package/dist/ai-edits/snapshotBatchFacts.js +184 -0
  45. package/dist/ai-edits/table-geometry.d.ts +45 -11
  46. package/dist/ai-edits/table-geometry.js +141 -26
  47. package/dist/ai-edits/table-mutation-plan.d.ts +12 -0
  48. package/dist/ai-edits/table-mutation-plan.js +1 -1
  49. package/dist/ai-edits/table-row-column-mutations.d.ts +26 -3
  50. package/dist/ai-edits/table-row-column-mutations.js +90 -11
  51. package/dist/ai-edits/table-template.d.ts +21 -0
  52. package/dist/ai-edits/tableInsertionModes.d.ts +10 -0
  53. package/dist/ai-edits/tableInsertionModes.js +8 -0
  54. package/dist/ai-edits/tracked-batch-fidelity.d.ts +23 -0
  55. package/dist/ai-edits/tracked-batch-fidelity.js +357 -0
  56. package/dist/ai-edits/types.d.ts +81 -15
  57. package/dist/ai-edits/undefinedReferences.d.ts +49 -0
  58. package/dist/ai-edits/undefinedReferences.js +234 -0
  59. package/dist/ai-suggestions/apply.d.ts +12 -0
  60. package/dist/ai-suggestions/conflict.d.ts +9 -0
  61. package/dist/ai-suggestions/text-positions.d.ts +13 -0
  62. package/dist/canonical/batchCommentReferences.d.ts +20 -0
  63. package/dist/canonical/batchCommentReferences.js +93 -0
  64. package/dist/canonical/canonicalBatchReview.d.ts +25 -0
  65. package/dist/canonical/canonicalBatchReview.js +132 -0
  66. package/dist/{controller → canonical}/canonicalComments.d.ts +7 -4
  67. package/dist/{controller → canonical}/canonicalComments.js +36 -9
  68. package/dist/canonical/canonicalCompilerRefusal.d.ts +13 -0
  69. package/dist/canonical/canonicalCompilerRefusal.js +75 -0
  70. package/dist/canonical/canonicalIdLease.d.ts +40 -0
  71. package/dist/canonical/canonicalIdLease.js +96 -0
  72. package/dist/{controller → canonical}/canonicalInlineProjection.d.ts +1 -1
  73. package/dist/{controller → canonical}/canonicalInlineProjection.js +40 -20
  74. package/dist/canonical/canonicalInsertedCommentRange.d.ts +15 -0
  75. package/dist/canonical/canonicalInsertedCommentRange.js +43 -0
  76. package/dist/canonical/canonicalInsertionReplayIds.d.ts +40 -0
  77. package/dist/canonical/canonicalInsertionReplayIds.js +73 -0
  78. package/dist/canonical/canonicalJoinedReceipts.d.ts +11 -0
  79. package/dist/canonical/canonicalJoinedReceipts.js +22 -0
  80. package/dist/{controller → canonical}/canonicalListRendering.js +1 -1
  81. package/dist/canonical/canonicalLockGuard.d.ts +34 -0
  82. package/dist/canonical/canonicalLockGuard.js +208 -0
  83. package/dist/{controller → canonical}/canonicalOperations.js +1 -1
  84. package/dist/canonical/canonicalProjectionBlocks.d.ts +89 -0
  85. package/dist/canonical/canonicalProjectionBlocks.js +79 -0
  86. package/dist/{controller → canonical}/canonicalPublicOperations.d.ts +24 -9
  87. package/dist/canonical/canonicalPublicOperations.js +4791 -0
  88. package/dist/canonical/canonicalRemoteHistory.d.ts +48 -0
  89. package/dist/canonical/canonicalRemoteHistory.js +176 -0
  90. package/dist/canonical/canonicalRevisionLocks.d.ts +18 -0
  91. package/dist/canonical/canonicalRevisionLocks.js +30 -0
  92. package/dist/canonical/canonicalRevisionReceipts.d.ts +15 -0
  93. package/dist/canonical/canonicalRevisionReceipts.js +25 -0
  94. package/dist/canonical/canonicalRoomBase.d.ts +23 -0
  95. package/dist/canonical/canonicalRoomBase.js +38 -0
  96. package/dist/canonical/canonicalSeedContent.d.ts +36 -0
  97. package/dist/canonical/canonicalSeedContent.js +179 -0
  98. package/dist/{controller → canonical}/canonicalSelection.js +1 -1
  99. package/dist/canonical/canonicalSession.d.ts +515 -0
  100. package/dist/canonical/canonicalSession.js +2892 -0
  101. package/dist/canonical/canonicalSourceNormalization.d.ts +42 -0
  102. package/dist/canonical/canonicalSourceNormalization.js +166 -0
  103. package/dist/{controller → canonical}/canonicalTocSelection.js +1 -1
  104. package/dist/canonical/canonicalTrackedBatchFidelity.d.ts +9 -0
  105. package/dist/canonical/canonicalTrackedBatchFidelity.js +125 -0
  106. package/dist/canonical/canonicalWholeTextFidelity.d.ts +21 -0
  107. package/dist/canonical/canonicalWholeTextFidelity.js +88 -0
  108. package/dist/canonical/commentAnchorParagraph.d.ts +10 -0
  109. package/dist/canonical/commentAnchorParagraph.js +11 -0
  110. package/dist/canonical/controlEdges.d.ts +12 -0
  111. package/dist/canonical/controlEdges.js +17 -0
  112. package/dist/canonical/paragraphPatchAsRead.d.ts +19 -0
  113. package/dist/canonical/paragraphPatchAsRead.js +32 -0
  114. package/dist/canonical/propertySourcePreservation.d.ts +38 -0
  115. package/dist/canonical/propertySourcePreservation.js +129 -0
  116. package/dist/canonical/replacementRunSources.d.ts +29 -0
  117. package/dist/canonical/replacementRunSources.js +78 -0
  118. package/dist/compare/compare.d.ts +8 -6
  119. package/dist/compare/compare.js +37 -8
  120. package/dist/compare/content-alignment.d.ts +10 -1
  121. package/dist/compare/content-alignment.js +188 -27
  122. package/dist/compare/content.d.ts +9 -1
  123. package/dist/compare/content.js +2 -2
  124. package/dist/compare/formatting.d.ts +1 -0
  125. package/dist/compare/import-style-closure.d.ts +1 -1
  126. package/dist/compare/inline-atom-alignment.d.ts +83 -0
  127. package/dist/compare/inline-atom-alignment.js +173 -0
  128. package/dist/compare/inline-atoms-model.d.ts +65 -0
  129. package/dist/compare/inline-atoms-model.js +1131 -0
  130. package/dist/compare/inline-atoms.d.ts +4 -4
  131. package/dist/compare/inline-atoms.js +28 -139
  132. package/dist/compare/inline-provenance-model.d.ts +37 -0
  133. package/dist/compare/inline-provenance-model.js +138 -0
  134. package/dist/compare/inline-provenance.d.ts +52 -4
  135. package/dist/compare/inline-provenance.js +40 -7
  136. package/dist/compare/plan.d.ts +38 -4
  137. package/dist/compare/plan.js +22 -8
  138. package/dist/compare/scenario.d.ts +22 -1
  139. package/dist/compare/section-boundary-properties.d.ts +38 -5
  140. package/dist/compare/section-boundary-properties.js +164 -48
  141. package/dist/compare/style-resources.d.ts +3 -2
  142. package/dist/compare/style-resources.js +5 -4
  143. package/dist/compare/types.d.ts +5 -2
  144. package/dist/compare/verification.d.ts +24 -3
  145. package/dist/compare/verification.js +25 -18
  146. package/dist/compat/eigenpal.d.ts +32 -31
  147. package/dist/compat/eigenpal.js +3 -5
  148. package/dist/content-controls/findContentControls.d.ts +9 -0
  149. package/dist/content-controls/index.d.ts +8 -0
  150. package/dist/content-controls/mutateContentControls.d.ts +9 -0
  151. package/dist/controller/activeEditorStory.d.ts +1 -0
  152. package/dist/controller/anonymizationHighlights.d.ts +56 -0
  153. package/dist/controller/anonymizationHighlights.js +148 -0
  154. package/dist/controller/autocompleteSuggestion.d.ts +85 -0
  155. package/dist/controller/autocompleteSuggestion.js +213 -0
  156. package/dist/controller/canonicalClipboard.d.ts +2 -2
  157. package/dist/controller/canonicalClipboard.js +36 -16
  158. package/dist/controller/canonicalClipboardResources.js +9 -4
  159. package/dist/controller/canonicalCollaboration.d.ts +147 -0
  160. package/dist/controller/canonicalCollaboration.js +360 -0
  161. package/dist/controller/canonicalComposition.d.ts +7 -1
  162. package/dist/controller/canonicalComposition.js +48 -13
  163. package/dist/controller/canonicalContentControlValue.d.ts +17 -0
  164. package/dist/controller/canonicalContentControlValue.js +72 -0
  165. package/dist/controller/canonicalIndexedDbJournal.d.ts +6 -0
  166. package/dist/controller/canonicalIndexedDbJournal.js +80 -0
  167. package/dist/controller/canonicalInput.d.ts +13 -2
  168. package/dist/controller/canonicalInput.js +100 -17
  169. package/dist/controller/canonicalPresence.d.ts +63 -0
  170. package/dist/controller/canonicalPresence.js +125 -0
  171. package/dist/controller/canonicalReview.d.ts +1 -1
  172. package/dist/controller/canonicalReview.js +1 -1
  173. package/dist/controller/canonicalRoomAuthority.d.ts +66 -0
  174. package/dist/controller/canonicalRoomAuthority.js +119 -0
  175. package/dist/controller/canonicalRoomEditor.d.ts +87 -0
  176. package/dist/controller/canonicalRoomEditor.js +98 -0
  177. package/dist/controller/canonicalRoomTransport.d.ts +79 -0
  178. package/dist/controller/canonicalRoomTransport.js +104 -0
  179. package/dist/controller/canonicalRoomWire.d.ts +80 -0
  180. package/dist/controller/canonicalRoomWire.js +155 -0
  181. package/dist/controller/canonicalStoryEditor.d.ts +13 -1
  182. package/dist/controller/canonicalStoryEditor.js +55 -19
  183. package/dist/controller/canonicalStructure.d.ts +15 -5
  184. package/dist/controller/canonicalStructure.js +95 -34
  185. package/dist/controller/canonicalTabRoom.d.ts +91 -0
  186. package/dist/controller/canonicalTabRoom.js +553 -0
  187. package/dist/controller/canonicalYjsRoom.d.ts +102 -0
  188. package/dist/controller/canonicalYjsRoom.js +454 -0
  189. package/dist/controller/contentControlWidgetController.d.ts +16 -0
  190. package/dist/controller/contentControlWidgetController.js +7 -1
  191. package/dist/controller/documentChangeNotification.d.ts +5 -0
  192. package/dist/controller/documentChangeNotification.js +7 -0
  193. package/dist/controller/folioEditor.d.ts +12 -4
  194. package/dist/controller/folioEditor.js +21 -1
  195. package/dist/controller/folioEditorEvents.d.ts +1 -1
  196. package/dist/controller/fontReadiness.d.ts +14 -1
  197. package/dist/controller/fontReadiness.js +4 -4
  198. package/dist/controller/headerFooterEditorManager.d.ts +17 -6
  199. package/dist/controller/headerFooterEditorManager.js +29 -25
  200. package/dist/controller/hiddenEditorApi.d.ts +97 -14
  201. package/dist/controller/hiddenEditorApi.js +44 -3
  202. package/dist/controller/hiddenEditorManager.d.ts +68 -16
  203. package/dist/controller/hiddenEditorManager.js +440 -85
  204. package/dist/controller/hyphenationReadiness.d.ts +10 -0
  205. package/dist/controller/layoutPipeline.d.ts +14 -12
  206. package/dist/controller/layoutPipeline.js +66 -54
  207. package/dist/controller/layoutSession.d.ts +10 -6
  208. package/dist/controller/layoutSession.js +3 -1
  209. package/dist/controller/legacyTextAddress.d.ts +9 -0
  210. package/dist/controller/legacyTextAddress.js +52 -0
  211. package/dist/controller/noteEditorManager.d.ts +18 -6
  212. package/dist/controller/noteEditorManager.js +38 -32
  213. package/dist/controller/textPositionLookup.d.ts +24 -0
  214. package/dist/controller/textPositionLookup.js +78 -0
  215. package/dist/display-list/build/buildContext.d.ts +11 -0
  216. package/dist/display-list/build/buildDisplayList.d.ts +14 -1
  217. package/dist/display-list/build/colors.d.ts +8 -0
  218. package/dist/display-list/build/floatingImages.d.ts +10 -0
  219. package/dist/display-list/build/fontTable.d.ts +8 -0
  220. package/dist/display-list/build/furniture.d.ts +14 -2
  221. package/dist/display-list/build/glyphs.d.ts +7 -0
  222. package/dist/display-list/build/headerFooterPrimitives.d.ts +13 -0
  223. package/dist/display-list/build/imagePrimitives.d.ts +10 -0
  224. package/dist/display-list/build/pageBorderPrimitives.d.ts +16 -2
  225. package/dist/display-list/build/pageFurniture.d.ts +13 -0
  226. package/dist/display-list/build/paragraphPrimitives.d.ts +18 -0
  227. package/dist/display-list/build/paragraphPrimitives.js +17 -5
  228. package/dist/display-list/build/previewPrimitives.d.ts +14 -0
  229. package/dist/display-list/build/regions.d.ts +14 -0
  230. package/dist/display-list/build/storyPrimitives.d.ts +16 -0
  231. package/dist/display-list/build/strokes.d.ts +21 -3
  232. package/dist/display-list/build/strokes.js +2 -3
  233. package/dist/display-list/build/tablePrimitives.d.ts +15 -1
  234. package/dist/display-list/build/tablePrimitives.js +92 -55
  235. package/dist/display-list/build/textBoxPrimitives.d.ts +6 -0
  236. package/dist/display-list/build/unsupported.d.ts +10 -0
  237. package/dist/display-list/build/watermarkPrimitives.d.ts +15 -1
  238. package/dist/display-list/dom/renderDisplayListToDom.d.ts +33 -0
  239. package/dist/display-list/dom/renderDisplayListToDom.js +21 -11
  240. package/dist/display-list/editor/displayListPagePainter.d.ts +29 -1
  241. package/dist/display-list/editor/pageRenderer.d.ts +7 -0
  242. package/dist/display-list/html/renderDisplayListToHtml.d.ts +10 -0
  243. package/dist/display-list/primitives.d.ts +12 -1
  244. package/dist/display-list/selectDisplayPages.d.ts +8 -0
  245. package/dist/display-list/types.d.ts +11 -0
  246. package/dist/document-operations.d.ts +34 -4
  247. package/dist/document-operations.js +178 -40
  248. package/dist/docx/attributeRemainder.d.ts +35 -1
  249. package/dist/docx/automaticNoteMarkImport.d.ts +12 -0
  250. package/dist/docx/automaticNoteMarkImport.js +41 -0
  251. package/dist/docx/blockContentParser.d.ts +14 -5
  252. package/dist/docx/blockContentParser.js +19 -0
  253. package/dist/docx/blockPlainText.d.ts +14 -0
  254. package/dist/docx/blockPlainText.js +55 -4
  255. package/dist/docx/bookmarkParser.d.ts +17 -0
  256. package/dist/docx/bookmarkRangeJoin.d.ts +14 -0
  257. package/dist/docx/borderParser.d.ts +11 -0
  258. package/dist/docx/builtInStyles.d.ts +44 -1
  259. package/dist/docx/canonicalSave.d.ts +14 -4
  260. package/dist/docx/canonicalSave.js +133 -30
  261. package/dist/docx/canonicalSessionInput.d.ts +59 -4
  262. package/dist/docx/canonicalSessionInput.js +147 -6
  263. package/dist/docx/canonicalStoryRepack.d.ts +1 -0
  264. package/dist/docx/canonicalStoryRepack.js +2 -2
  265. package/dist/docx/chartPreview.js +10 -9
  266. package/dist/docx/commentAnchorIndex.d.ts +46 -1
  267. package/dist/docx/commentAnchorIndex.js +187 -7
  268. package/dist/docx/commentIdNormalization.d.ts +14 -0
  269. package/dist/docx/commentParagraphIds.d.ts +17 -0
  270. package/dist/docx/commentParagraphIds.js +79 -0
  271. package/dist/docx/commentParser.d.ts +20 -1
  272. package/dist/docx/commentParser.js +5 -0
  273. package/dist/docx/commentRangeIntegrity.js +27 -11
  274. package/dist/docx/commentRangeJoin.d.ts +21 -1
  275. package/dist/docx/commentRangeJoin.js +5 -1
  276. package/dist/docx/commentReferenceCompletion.d.ts +29 -2
  277. package/dist/docx/commentReferenceCompletion.js +4 -3
  278. package/dist/docx/commentReferenceNormalization.d.ts +17 -0
  279. package/dist/docx/commentReferenceNormalization.js +484 -49
  280. package/dist/docx/commentReplyMarkers.d.ts +22 -0
  281. package/dist/docx/compatibility.d.ts +10 -0
  282. package/dist/docx/containerChildren.d.ts +26 -1
  283. package/dist/docx/containerChildren.js +29 -3
  284. package/dist/docx/contentTypeRegistry.d.ts +16 -0
  285. package/dist/docx/contentTypeRegistry.js +49 -21
  286. package/dist/docx/danglingRelationshipReferences.d.ts +13 -0
  287. package/dist/docx/defaultParagraphStyle.d.ts +14 -1
  288. package/dist/docx/documentClone.d.ts +3 -2
  289. package/dist/docx/documentClone.js +1 -1
  290. package/dist/docx/documentParser.d.ts +28 -3
  291. package/dist/docx/documentParser.js +71 -4
  292. package/dist/docx/drawingAnchor.d.ts +17 -0
  293. package/dist/docx/drawingGroupChildren.d.ts +12 -0
  294. package/dist/docx/drawingIdNormalization.d.ts +8 -0
  295. package/dist/docx/drawingIdNormalization.js +46 -1
  296. package/dist/docx/drawingUtils.d.ts +6 -0
  297. package/dist/docx/drawingUtils.js +2 -2
  298. package/dist/docx/encryption/agileDecryption.d.ts +7 -0
  299. package/dist/docx/ensureParaIds.d.ts +73 -0
  300. package/dist/docx/ensureParaIds.js +299 -59
  301. package/dist/docx/ensureUniqueControlIds.js +10 -3
  302. package/dist/docx/ensureUniqueRevisionIds.d.ts +28 -0
  303. package/dist/docx/ensureUniqueRevisionIds.js +140 -0
  304. package/dist/docx/fieldParser.d.ts +27 -2
  305. package/dist/docx/fieldState.d.ts +15 -0
  306. package/dist/docx/fieldWrapperCaptures.d.ts +18 -0
  307. package/dist/docx/fieldWrapperCaptures.js +117 -0
  308. package/dist/docx/foldedListNumberFields.d.ts +14 -0
  309. package/dist/docx/fontTableParser.d.ts +11 -0
  310. package/dist/docx/footnoteParser.d.ts +24 -3
  311. package/dist/docx/footnoteParser.js +29 -6
  312. package/dist/docx/graphicFrameLocks.d.ts +9 -1
  313. package/dist/docx/groupDrawingParser.d.ts +2 -2
  314. package/dist/docx/headerFooterParser.d.ts +37 -5
  315. package/dist/docx/headerFooterParser.js +18 -4
  316. package/dist/docx/headerFooterRefParser.d.ts +7 -0
  317. package/dist/docx/hostCommentThreads.d.ts +21 -2
  318. package/dist/docx/hostCommentThreads.js +25 -2
  319. package/dist/docx/hyperlinkParser.d.ts +20 -3
  320. package/dist/docx/hyperlinkParser.js +19 -24
  321. package/dist/docx/imageParser.d.ts +27 -0
  322. package/dist/docx/index.d.ts +3 -3
  323. package/dist/docx/inlineContentRemovals.d.ts +8 -0
  324. package/dist/docx/inlineWrapperContent.d.ts +33 -1
  325. package/dist/docx/inlineWrapperContent.js +145 -1
  326. package/dist/docx/inlineWrapperParser.d.ts +14 -0
  327. package/dist/docx/listMarkerComputation.d.ts +37 -6
  328. package/dist/docx/listMarkerComputation.js +77 -28
  329. package/dist/docx/listModelNormalization.d.ts +24 -8
  330. package/dist/docx/listModelNormalization.js +426 -143
  331. package/dist/docx/listNumberingInstances.d.ts +39 -9
  332. package/dist/docx/listNumberingInstances.js +91 -44
  333. package/dist/docx/mainDocumentPart.d.ts +22 -1
  334. package/dist/docx/mainDocumentPart.js +51 -12
  335. package/dist/docx/markupRangeMarker.d.ts +16 -0
  336. package/dist/docx/markupRangeMarker.js +11 -2
  337. package/dist/docx/mathToMathml.d.ts +28 -0
  338. package/dist/docx/mergePropertyChangeLinks.d.ts +11 -0
  339. package/dist/docx/mergePropertyChangeLinks.js +30 -0
  340. package/dist/docx/nonVisualDrawingProps.d.ts +6 -0
  341. package/dist/docx/normalizeBaseDirection.d.ts +17 -0
  342. package/dist/docx/normalizedSourceParts.d.ts +21 -0
  343. package/dist/docx/normalizedSourceParts.js +81 -0
  344. package/dist/docx/notePropertiesParser.d.ts +7 -0
  345. package/dist/docx/noteReferenceMark.d.ts +9 -0
  346. package/dist/docx/noteReferenceStyles.d.ts +13 -0
  347. package/dist/docx/numberingIds.d.ts +6 -0
  348. package/dist/docx/numberingIds.js +6 -1
  349. package/dist/docx/numberingParser.d.ts +12 -0
  350. package/dist/docx/numberingReference.d.ts +10 -0
  351. package/dist/docx/numberingReferenceNormalization.d.ts +19 -0
  352. package/dist/docx/numberingReferenceNormalization.js +12 -2
  353. package/dist/docx/packageRelationshipsRoot.d.ts +24 -0
  354. package/dist/docx/packageRelationshipsRoot.js +28 -0
  355. package/dist/docx/packageUnnamedParagraphIds.d.ts +18 -0
  356. package/dist/docx/packageUnnamedParagraphIds.js +78 -0
  357. package/dist/docx/paraIdAttribute.d.ts +15 -0
  358. package/dist/docx/paragraphParser.d.ts +15 -3
  359. package/dist/docx/paragraphParser.js +126 -140
  360. package/dist/docx/paragraphProperties.d.ts +15 -1
  361. package/dist/docx/paragraphProperties.js +3 -5
  362. package/dist/docx/paragraphPropertySource.d.ts +60 -4
  363. package/dist/docx/paragraphPropertySource.js +239 -27
  364. package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
  365. package/dist/docx/paragraphTraversal.d.ts +39 -4
  366. package/dist/docx/paragraphTraversal.js +158 -42
  367. package/dist/docx/parseContext.d.ts +15 -0
  368. package/dist/docx/parseWarningMessage.d.ts +9 -0
  369. package/dist/docx/parseWarningMessage.js +7 -0
  370. package/dist/docx/parser.d.ts +1 -1
  371. package/dist/docx/parser.js +105 -29
  372. package/dist/docx/parserEnums.d.ts +21 -0
  373. package/dist/docx/partRelationships.d.ts +15 -0
  374. package/dist/docx/partRelationships.js +58 -0
  375. package/dist/docx/preservedRunContent.d.ts +2 -1
  376. package/dist/docx/preservedRunContent.js +40 -1
  377. package/dist/docx/previewBudget.d.ts +31 -0
  378. package/dist/docx/relsParser.d.ts +23 -0
  379. package/dist/docx/removeHeaderFooterParts.d.ts +1 -1
  380. package/dist/docx/removeHeaderFooterParts.js +1 -1
  381. package/dist/docx/replyToComment.d.ts +22 -1
  382. package/dist/docx/replyToComment.js +25 -21
  383. package/dist/docx/reviewResolutionProvenance.d.ts +32 -5
  384. package/dist/docx/reviewResolutionProvenance.js +284 -40
  385. package/dist/docx/rezip.d.ts +58 -11
  386. package/dist/docx/rezip.js +367 -101
  387. package/dist/docx/runConsolidator.d.ts +13 -0
  388. package/dist/docx/runParser.d.ts +4 -3
  389. package/dist/docx/runParser.js +27 -6
  390. package/dist/docx/runPayload.d.ts +29 -0
  391. package/dist/docx/saveDiagnostics.d.ts +3 -5
  392. package/dist/docx/sdtProperties.d.ts +17 -0
  393. package/dist/docx/sdtPropertiesPatch.d.ts +14 -0
  394. package/dist/docx/sectionParser.d.ts +21 -0
  395. package/dist/docx/sectionParser.js +1 -6
  396. package/dist/docx/selectiveSave.js +271 -80
  397. package/dist/docx/selectiveXmlPatch.d.ts +36 -1
  398. package/dist/docx/selectiveXmlPatch.js +342 -78
  399. package/dist/docx/serializer/blockSdtSerializer.d.ts +10 -0
  400. package/dist/docx/serializer/borderSerializer.d.ts +8 -0
  401. package/dist/docx/serializer/commentSerializer.d.ts +12 -1
  402. package/dist/docx/serializer/commentSerializer.js +1 -1
  403. package/dist/docx/serializer/documentSerializer.d.ts +21 -3
  404. package/dist/docx/serializer/documentSerializer.js +46 -7
  405. package/dist/docx/serializer/groupTextBoxWriteBack.d.ts +14 -0
  406. package/dist/docx/serializer/headerFooterSerializer.d.ts +11 -0
  407. package/dist/docx/serializer/markupRangeAttributes.d.ts +8 -0
  408. package/dist/docx/serializer/markupRangeAttributes.js +3 -1
  409. package/dist/docx/serializer/noteSerializer.d.ts +21 -0
  410. package/dist/docx/serializer/numberingSerializer.d.ts +14 -0
  411. package/dist/docx/serializer/paragraphSerializer.d.ts +11 -0
  412. package/dist/docx/serializer/paragraphSerializer.js +21 -9
  413. package/dist/docx/serializer/partNamespaces.d.ts +3 -1
  414. package/dist/docx/serializer/partNamespaces.js +4 -2
  415. package/dist/docx/serializer/runSerializer.js +12 -3
  416. package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +15 -0
  417. package/dist/docx/serializer/stylesSerializer.d.ts +26 -1
  418. package/dist/docx/serializer/stylesSerializer.js +111 -23
  419. package/dist/docx/serializer/tableSerializer.js +9 -7
  420. package/dist/docx/serializer/themeSerializer.d.ts +2 -1
  421. package/dist/docx/server/applyDocxXmlPatchProposal.js +1 -1
  422. package/dist/docx/server/build.d.ts +1 -1
  423. package/dist/docx/server/changeListFormat.d.ts +20 -0
  424. package/dist/docx/server/changeListFormat.js +102 -0
  425. package/dist/docx/server/createBilingualDocument.d.ts +21 -0
  426. package/dist/docx/server/materializeYjsDocx.js +2 -2
  427. package/dist/docx/server/migrateYjsAttrSchema.js +5 -5
  428. package/dist/docx/sessionListPruning.d.ts +11 -0
  429. package/dist/docx/settingsParser.d.ts +10 -0
  430. package/dist/docx/shadingParser.d.ts +10 -0
  431. package/dist/docx/shapeAlternateContent.js +9 -2
  432. package/dist/docx/shapeParser.d.ts +27 -0
  433. package/dist/docx/splitRevisionPieces.d.ts +1 -1
  434. package/dist/docx/storyBlockReplay.d.ts +37 -3
  435. package/dist/docx/storyBlockReplay.js +291 -69
  436. package/dist/docx/strictNames.d.ts +12 -1
  437. package/dist/docx/strictValueEncodings.gen.d.ts +9 -0
  438. package/dist/docx/structuralXmlPatch.d.ts +19 -3
  439. package/dist/docx/structuralXmlPatch.js +139 -35
  440. package/dist/docx/styleParser.d.ts +20 -3
  441. package/dist/docx/styleParser.js +3 -2
  442. package/dist/docx/tableLook.d.ts +15 -1
  443. package/dist/docx/tableParser.d.ts +17 -6
  444. package/dist/docx/tableParser.js +10 -5
  445. package/dist/docx/textBoxContentParser.d.ts +3 -2
  446. package/dist/docx/textBoxParser.d.ts +30 -3
  447. package/dist/docx/themeColorAttribute.d.ts +11 -0
  448. package/dist/docx/themeParser.d.ts +17 -5
  449. package/dist/docx/trackedMoveRangeNormalization.d.ts +9 -0
  450. package/dist/docx/trackedMoveRangeNormalization.js +40 -16
  451. package/dist/docx/transitionalSpelling.d.ts +9 -0
  452. package/dist/docx/unnamedParagraphIds.d.ts +33 -0
  453. package/dist/docx/unnamedParagraphIds.js +43 -0
  454. package/dist/docx/unreferencedHeaderFooters.d.ts +27 -0
  455. package/dist/docx/unreferencedHeaderFooters.js +130 -0
  456. package/dist/docx/unzip.d.ts +25 -0
  457. package/dist/docx/verbatimCapture.d.ts +18 -0
  458. package/dist/docx/verbatimCapture.js +76 -9
  459. package/dist/docx/vmlImageParser.d.ts +32 -1
  460. package/dist/docx/watermarkParser.d.ts +21 -0
  461. package/dist/docx/wrapPolygon.d.ts +11 -0
  462. package/dist/docx/wrapTypes.d.ts +6 -0
  463. package/dist/docx/xmlParser.d.ts +23 -19
  464. package/dist/docx/xmlParser.js +2 -20
  465. package/dist/docx/xmlRootInsertion.d.ts +8 -0
  466. package/dist/docx/xmlRootInsertion.js +28 -0
  467. package/dist/docx/xmlSafety.d.ts +1 -0
  468. package/dist/docx/xmlSafety.js +7 -11
  469. package/dist/export-pdf.d.ts +24 -1
  470. package/dist/fields/resolveFieldValues.js +2 -1
  471. package/dist/fonts/fontsourceFaces.d.ts +2 -2
  472. package/dist/fonts/headlessMeasure.d.ts +16 -0
  473. package/dist/generated/text_shaper.js +71 -59
  474. package/dist/generated/text_shaper_bg.wasm +0 -0
  475. package/dist/headless-layout.d.ts +36 -5
  476. package/dist/headless-layout.js +19 -4
  477. package/dist/i18n/messages/ar.gen.js +2 -0
  478. package/dist/i18n/messages/catalogs.gen.d.ts +34 -0
  479. package/dist/i18n/messages/catalogs.gen.js +34 -0
  480. package/dist/i18n/messages/cs.gen.js +2 -0
  481. package/dist/i18n/messages/de.gen.js +2 -0
  482. package/dist/i18n/messages/en.gen.js +2 -0
  483. package/dist/i18n/messages/es.gen.js +2 -0
  484. package/dist/i18n/messages/et.gen.js +2 -0
  485. package/dist/i18n/messages/fr.gen.js +2 -0
  486. package/dist/i18n/messages/he.gen.js +2 -0
  487. package/dist/i18n/messages/hi.gen.js +2 -0
  488. package/dist/i18n/messages/hu.gen.js +2 -0
  489. package/dist/i18n/messages/lt.gen.js +2 -0
  490. package/dist/i18n/messages/lv.gen.js +2 -0
  491. package/dist/i18n/messages/messages.gen.d.ts +2 -0
  492. package/dist/i18n/messages/pl.gen.js +2 -0
  493. package/dist/i18n/messages/pt-BR.gen.js +2 -0
  494. package/dist/i18n/messages/sk.gen.js +2 -0
  495. package/dist/i18n/messages/tr.gen.js +2 -0
  496. package/dist/i18n/messages/zh-CN.gen.js +2 -0
  497. package/dist/index.d.ts +33 -31
  498. package/dist/index.js +3 -4
  499. package/dist/internal/canonicalOperationStaging.d.ts +2 -0
  500. package/dist/internal/canonicalOperationStaging.js +4 -0
  501. package/dist/internal/canonicalTyping.d.ts +9 -0
  502. package/dist/internal/canonicalTyping.js +7 -0
  503. package/dist/internal/compare/inline-presentation.d.ts +8 -0
  504. package/dist/internal/indexedPositionMap.js +2 -1
  505. package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
  506. package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
  507. package/dist/internal/revisionResolutionInline.js +13 -13
  508. package/dist/internal/revisionResolutionStep.js +1 -0
  509. package/dist/internal/revisionResolutionTracking.js +2 -1
  510. package/dist/internal/subtreeHolds.d.ts +12 -0
  511. package/dist/internal/subtreeHolds.js +25 -0
  512. package/dist/internal/wholeStoryRevisionResolution.d.ts +1 -1
  513. package/dist/internal/wholeStoryRevisionResolution.js +57 -66
  514. package/dist/layout-bridge/cellSelectionHighlight.d.ts +8 -0
  515. package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
  516. package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +7 -0
  517. package/dist/layout-bridge/convert/editingFont.d.ts +26 -0
  518. package/dist/layout-bridge/convert/editingFont.js +42 -0
  519. package/dist/layout-bridge/convert/endnoteLayout.d.ts +19 -1
  520. package/dist/layout-bridge/convert/flowBlockPostprocessing.d.ts +5 -0
  521. package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
  522. package/dist/layout-bridge/convert/flowBorders.d.ts +10 -4
  523. package/dist/layout-bridge/convert/flowBorders.js +13 -1
  524. package/dist/layout-bridge/convert/flowConversionShared.d.ts +37 -8
  525. package/dist/layout-bridge/convert/flowConversionShared.js +39 -6
  526. package/dist/layout-bridge/convert/footnoteLayout.d.ts +12 -4
  527. package/dist/layout-bridge/convert/footnoteLayout.js +3 -1
  528. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +25 -5
  529. package/dist/layout-bridge/convert/imageConversion.d.ts +5 -1
  530. package/dist/layout-bridge/convert/listMarkers.d.ts +12 -7
  531. package/dist/layout-bridge/convert/markupViewFlow.d.ts +21 -0
  532. package/dist/layout-bridge/convert/markupViewFlow.js +4 -1
  533. package/dist/layout-bridge/convert/noteReferences.d.ts +4 -0
  534. package/dist/layout-bridge/convert/pageBreakSplitting.d.ts +4 -0
  535. package/dist/layout-bridge/convert/paragraphAttrs.d.ts +25 -9
  536. package/dist/layout-bridge/convert/paragraphAttrs.js +12 -5
  537. package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +36 -0
  538. package/dist/layout-bridge/convert/paragraphBlockCache.js +130 -0
  539. package/dist/layout-bridge/convert/paragraphConversion.d.ts +20 -6
  540. package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
  541. package/dist/layout-bridge/convert/paragraphFrames.d.ts +2 -4
  542. package/dist/layout-bridge/convert/paragraphFrames.js +4 -4
  543. package/dist/layout-bridge/convert/paragraphMarkFormatting.d.ts +13 -4
  544. package/dist/layout-bridge/convert/paragraphRuns.d.ts +7 -2
  545. package/dist/layout-bridge/convert/paragraphRuns.js +18 -4
  546. package/dist/layout-bridge/convert/runFormattingMerge.d.ts +10 -4
  547. package/dist/layout-bridge/convert/runMarkFormatting.d.ts +8 -3
  548. package/dist/layout-bridge/convert/runMarkFormatting.js +3 -5
  549. package/dist/layout-bridge/convert/sectionBoundaries.d.ts +4 -0
  550. package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
  551. package/dist/layout-bridge/convert/tableConversion.d.ts +15 -5
  552. package/dist/layout-bridge/convert/tableConversion.js +40 -19
  553. package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +38 -1
  554. package/dist/layout-bridge/convert/textBoxFill.d.ts +7 -2
  555. package/dist/layout-bridge/convert/textFormattingConversion.d.ts +18 -12
  556. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +8 -2
  557. package/dist/layout-bridge/convert/toFlowBlocks.js +200 -18
  558. package/dist/layout-bridge/convert/topLevelConversion.d.ts +96 -0
  559. package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
  560. package/dist/layout-bridge/convert/wrapEditorViewAsSurface.d.ts +10 -0
  561. package/dist/layout-bridge/dom/clickToPositionDom.js +45 -44
  562. package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
  563. package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
  564. package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
  565. package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
  566. package/dist/layout-bridge/dom/noteStoryDom.d.ts +1 -0
  567. package/dist/layout-bridge/dom/textStreamDom.js +3 -2
  568. package/dist/layout-bridge/engine/blockIndex.d.ts +3 -0
  569. package/dist/layout-bridge/engine/clickToPosition.d.ts +9 -0
  570. package/dist/layout-bridge/engine/hitTest.d.ts +6 -0
  571. package/dist/layout-bridge/engine/hitTest.js +3 -3
  572. package/dist/layout-bridge/engine/measuring/index.d.ts +20 -8
  573. package/dist/layout-bridge/engine/selectionRects.d.ts +9 -0
  574. package/dist/layout-bridge/headerFooterLayout.d.ts +12 -0
  575. package/dist/layout-bridge/headerFooterLayout.js +15 -14
  576. package/dist/layout-bridge/sectionColumns.d.ts +10 -1
  577. package/dist/layout-bridge/tableInsertHover.js +2 -1
  578. package/dist/layout-engine/footnoteContinuation.d.ts +8 -0
  579. package/dist/layout-engine/imageLayout.d.ts +4 -1
  580. package/dist/layout-engine/index.d.ts +10 -5
  581. package/dist/layout-engine/index.js +9 -3
  582. package/dist/layout-engine/keep-together.d.ts +6 -0
  583. package/dist/layout-engine/layoutFlowShared.d.ts +4 -0
  584. package/dist/layout-engine/layoutInstrumentation.d.ts +40 -1
  585. package/dist/layout-engine/layoutInstrumentation.js +26 -4
  586. package/dist/layout-engine/lineFlow.d.ts +1 -0
  587. package/dist/layout-engine/lineFlow.js +4 -1
  588. package/dist/layout-engine/measure/advanceComposition.d.ts +14 -1
  589. package/dist/layout-engine/measure/automaticTextSpacing.d.ts +1 -1
  590. package/dist/layout-engine/measure/cache.d.ts +8 -0
  591. package/dist/layout-engine/measure/cache.js +9 -1
  592. package/dist/layout-engine/measure/crossRunWords.d.ts +1 -1
  593. package/dist/layout-engine/measure/floatingLineClearance.d.ts +4 -0
  594. package/dist/layout-engine/measure/floatingTablePosition.d.ts +32 -1
  595. package/dist/layout-engine/measure/floatingTablePosition.js +49 -1
  596. package/dist/layout-engine/measure/font-metrics.worker.d.ts +16 -0
  597. package/dist/layout-engine/measure/hyphenationDictionaries.d.ts +18 -0
  598. package/dist/layout-engine/measure/hyphenationPreload.d.ts +4 -0
  599. package/dist/layout-engine/measure/index.d.ts +18 -8
  600. package/dist/layout-engine/measure/index.js +2 -1
  601. package/dist/layout-engine/measure/inlineObjectMetrics.d.ts +4 -0
  602. package/dist/layout-engine/measure/justification.d.ts +5 -1
  603. package/dist/layout-engine/measure/lineFitting.d.ts +6 -1
  604. package/dist/layout-engine/measure/lineTypography.d.ts +6 -1
  605. package/dist/layout-engine/measure/listMarkerWidth.d.ts +16 -1
  606. package/dist/layout-engine/measure/measureBlocks.d.ts +4 -1
  607. package/dist/layout-engine/measure/measureBlocks.js +127 -102
  608. package/dist/layout-engine/measure/measureContainer.d.ts +17 -0
  609. package/dist/layout-engine/measure/measureHelpers.d.ts +10 -1
  610. package/dist/layout-engine/measure/measureParagraph.d.ts +7 -1
  611. package/dist/layout-engine/measure/measureParagraph.js +51 -21
  612. package/dist/layout-engine/measure/measureProvider.d.ts +10 -0
  613. package/dist/layout-engine/measure/measureTypes.d.ts +8 -0
  614. package/dist/layout-engine/measure/measureWorker.d.ts +30 -0
  615. package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +14 -0
  616. package/dist/layout-engine/measure/measuresHoldNoPositions.d.ts +40 -0
  617. package/dist/layout-engine/measure/measuresHoldNoPositions.js +14 -0
  618. package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +20 -0
  619. package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
  620. package/dist/layout-engine/measure/paragraphMeasureShared.d.ts +21 -2
  621. package/dist/layout-engine/measure/paragraphMeasureShared.js +20 -1
  622. package/dist/layout-engine/measure/paragraphTabs.d.ts +4 -0
  623. package/dist/layout-engine/measure/raisedTableWrap.d.ts +16 -0
  624. package/dist/layout-engine/measure/raisedTableWrap.js +105 -0
  625. package/dist/layout-engine/measure/tableBorderBands.d.ts +35 -0
  626. package/dist/layout-engine/measure/tableBorderBands.js +251 -0
  627. package/dist/layout-engine/measure/tableCellFloating.js +1 -1
  628. package/dist/layout-engine/measure/tableCellFlow.d.ts +4 -4
  629. package/dist/layout-engine/measure/tableCellFlow.js +7 -10
  630. package/dist/layout-engine/measure/tableCellGrid.d.ts +4 -1
  631. package/dist/layout-engine/measure/tableCellGrid.js +30 -3
  632. package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
  633. package/dist/layout-engine/measure/tableMeasureMemo.d.ts +23 -0
  634. package/dist/layout-engine/measure/tableMeasureMemo.js +40 -0
  635. package/dist/layout-engine/measure/tableNoWrapWidths.d.ts +12 -0
  636. package/dist/layout-engine/measure/tableNoWrapWidths.js +73 -0
  637. package/dist/layout-engine/measure/tableVisibleBand.d.ts +6 -0
  638. package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +7 -1
  639. package/dist/layout-engine/noteAreaFlow.d.ts +10 -1
  640. package/dist/layout-engine/paginator.d.ts +6 -0
  641. package/dist/layout-engine/paginator.js +6 -5
  642. package/dist/layout-engine/paragraphLayout.d.ts +5 -1
  643. package/dist/layout-engine/paragraphSpacing.d.ts +17 -2
  644. package/dist/layout-engine/paragraphSpacing.js +103 -15
  645. package/dist/layout-engine/pmPageIndex.d.ts +14 -1
  646. package/dist/layout-engine/pmPageIndex.js +10 -1
  647. package/dist/layout-engine/section-breaks.d.ts +6 -0
  648. package/dist/layout-engine/sectionLayout.d.ts +6 -1
  649. package/dist/layout-engine/sectionVerticalAlignment.js +2 -1
  650. package/dist/layout-engine/tableHeaderCompatibility.d.ts +3 -0
  651. package/dist/layout-engine/tableHeaderCompatibility.js +5 -0
  652. package/dist/layout-engine/tableLayout.d.ts +17 -6
  653. package/dist/layout-engine/tableLayout.js +36 -25
  654. package/dist/layout-engine/tableRowBreak.d.ts +16 -0
  655. package/dist/layout-engine/tableRowBreak.js +2 -1
  656. package/dist/layout-engine/textBoxFlow.d.ts +9 -0
  657. package/dist/layout-engine/textBoxLayout.d.ts +5 -1
  658. package/dist/layout-engine/types.d.ts +41 -2
  659. package/dist/layout-engine/types.js +77 -27
  660. package/dist/layout-painter/borderStroke.d.ts +1 -1
  661. package/dist/layout-painter/characterFillBand.d.ts +14 -0
  662. package/dist/layout-painter/characterFillBand.js +79 -0
  663. package/dist/layout-painter/imageLayout.d.ts +11 -2
  664. package/dist/layout-painter/imageLayout.js +2 -1
  665. package/dist/layout-painter/index.d.ts +12 -6
  666. package/dist/layout-painter/pageShellStyles.d.ts +19 -0
  667. package/dist/layout-painter/pageShellStyles.js +32 -0
  668. package/dist/layout-painter/previewSvg.d.ts +7 -0
  669. package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
  670. package/dist/layout-painter/reconcileRenderedContent.js +119 -0
  671. package/dist/layout-painter/registry/modules/image.d.ts +7 -0
  672. package/dist/layout-painter/registry/modules/paragraph.d.ts +8 -0
  673. package/dist/layout-painter/registry/modules/table.d.ts +6 -0
  674. package/dist/layout-painter/registry/modules/textBox.d.ts +3 -0
  675. package/dist/layout-painter/registry/modules.d.ts +10 -0
  676. package/dist/layout-painter/registry/registry.d.ts +8 -0
  677. package/dist/layout-painter/registry/types.d.ts +11 -0
  678. package/dist/layout-painter/renderFragment.d.ts +6 -0
  679. package/dist/layout-painter/renderFragment.js +4 -6
  680. package/dist/layout-painter/renderImage.d.ts +8 -0
  681. package/dist/layout-painter/renderImage.js +2 -2
  682. package/dist/layout-painter/renderPage.d.ts +10 -3
  683. package/dist/layout-painter/renderPage.js +31 -33
  684. package/dist/layout-painter/renderParagraph.d.ts +6 -0
  685. package/dist/layout-painter/renderParagraph.js +36 -19
  686. package/dist/layout-painter/renderTable.d.ts +10 -1
  687. package/dist/layout-painter/renderTable.js +121 -36
  688. package/dist/layout-painter/renderTextBox.d.ts +9 -0
  689. package/dist/layout-painter/renderTextBox.js +2 -2
  690. package/dist/layout-painter/renderUtils.d.ts +5 -1
  691. package/dist/layout-painter/renderWatermark.d.ts +11 -1
  692. package/dist/layout-painter/sdtBoundary.d.ts +10 -0
  693. package/dist/layout-painter/sdtBoundary.js +3 -2
  694. package/dist/managers/ClipboardManager.d.ts +13 -0
  695. package/dist/managers/ContextMenuManager.d.ts +16 -4
  696. package/dist/managers/ContextMenuManager.js +3 -3
  697. package/dist/managers/DocumentLoaderManager.d.ts +19 -5
  698. package/dist/managers/DocumentLoaderManager.js +48 -13
  699. package/dist/managers/EditorModeManager.d.ts +11 -0
  700. package/dist/managers/ErrorManager.d.ts +11 -0
  701. package/dist/managers/FindReplaceManager.d.ts +14 -27
  702. package/dist/managers/FindReplaceManager.js +0 -49
  703. package/dist/managers/HistoryManager.d.ts +18 -0
  704. package/dist/managers/TableSelectionManager.d.ts +18 -4
  705. package/dist/managers/TableSelectionManager.js +22 -5
  706. package/dist/managers/editorShortcuts.d.ts +14 -2
  707. package/dist/managers/editorShortcuts.js +5 -3
  708. package/dist/managers/types.d.ts +15 -1
  709. package/dist/markdown/annotations.d.ts +9 -0
  710. package/dist/markdown/countParagraphList.d.ts +8 -0
  711. package/dist/markdown/escape.d.ts +6 -4
  712. package/dist/markdown/escape.js +17 -8
  713. package/dist/markdown/images.d.ts +11 -0
  714. package/dist/markdown/index.d.ts +24 -1
  715. package/dist/markdown/index.js +18 -1
  716. package/dist/markdown/internals.d.ts +7 -0
  717. package/dist/markdown/renderBlock.d.ts +5 -0
  718. package/dist/markdown/renderBlock.js +2 -7
  719. package/dist/markdown/renderParagraph.d.ts +22 -2
  720. package/dist/markdown/renderParagraph.js +11 -9
  721. package/dist/markdown/renderRuns.d.ts +10 -0
  722. package/dist/markdown/renderRuns.js +36 -3
  723. package/dist/markdown/renderTable.d.ts +7 -0
  724. package/dist/markdown/renderTable.js +2 -2
  725. package/dist/markdown/trailers.d.ts +7 -0
  726. package/dist/markdown/types.d.ts +9 -2
  727. package/dist/model.d.ts +25 -3
  728. package/dist/paged-layout/blockGeometry.js +3 -2
  729. package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
  730. package/dist/paged-layout/editorScrollRoot.js +10 -1
  731. package/dist/paged-layout/pageText.d.ts +1 -1
  732. package/dist/paged-layout/paragraphFlash.d.ts +3 -0
  733. package/dist/paged-layout/rangeProjection.d.ts +20 -1
  734. package/dist/paged-layout/rangeProjection.js +26 -7
  735. package/dist/paged-layout/scrollToPmPosition.d.ts +15 -0
  736. package/dist/paged-layout/scrollToPmPosition.js +3 -3
  737. package/dist/paged-layout/sectionBlockWidths.d.ts +2 -2
  738. package/dist/paged-layout/sectionGeometry.d.ts +4 -3
  739. package/dist/paged-layout/selectionViewportRect.d.ts +19 -0
  740. package/dist/paged-layout/selectionViewportRect.js +8 -2
  741. package/dist/panel-layout.d.ts +18 -1
  742. package/dist/panel-layout.js +36 -2
  743. package/dist/pdf/contentStream.d.ts +12 -0
  744. package/dist/pdf/fonts.d.ts +19 -0
  745. package/dist/pdf/paint.d.ts +9 -1
  746. package/dist/pdf/paint.js +51 -0
  747. package/dist/prosemirror/acceptedBlockNeighbours.d.ts +50 -0
  748. package/dist/prosemirror/acceptedBlockNeighbours.js +63 -0
  749. package/dist/prosemirror/alternateContentAttrs.d.ts +1 -1
  750. package/dist/prosemirror/anchoredTextBoxes.d.ts +20 -0
  751. package/dist/prosemirror/attrs/index.d.ts +2 -2
  752. package/dist/prosemirror/attrs/index.js +2 -1
  753. package/dist/prosemirror/authoredTransformAttrs.d.ts +14 -0
  754. package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +2 -2
  755. package/dist/prosemirror/canonicalCommands.d.ts +26 -1
  756. package/dist/prosemirror/canonicalCommands.js +12 -1
  757. package/dist/prosemirror/canonicalSelectionRange.d.ts +1 -1
  758. package/dist/prosemirror/canonicalTableCommands.d.ts +14 -0
  759. package/dist/prosemirror/canonicalTableCommands.js +18 -6
  760. package/dist/prosemirror/cellDragSelection.d.ts +9 -0
  761. package/dist/prosemirror/commands/comments.d.ts +27 -2
  762. package/dist/prosemirror/commands/comments.js +459 -159
  763. package/dist/prosemirror/commands/contentControls.d.ts +20 -3
  764. package/dist/prosemirror/commands/contentControls.js +18 -1
  765. package/dist/prosemirror/commands/contentControlsBlockFill.d.ts +11 -1
  766. package/dist/prosemirror/commands/formatPainter.d.ts +10 -0
  767. package/dist/prosemirror/commands/formatPainter.js +0 -1
  768. package/dist/prosemirror/commands/formatting.d.ts +9 -2
  769. package/dist/prosemirror/commands/hyperlink.d.ts +12 -0
  770. package/dist/prosemirror/commands/image.d.ts +12 -0
  771. package/dist/prosemirror/commands/index.d.ts +10 -5
  772. package/dist/prosemirror/commands/pageBreak.d.ts +3 -0
  773. package/dist/prosemirror/commands/paragraph.d.ts +8 -1
  774. package/dist/prosemirror/commands/pastePlainText.d.ts +8 -0
  775. package/dist/prosemirror/commands/pastePlainText.js +1 -1
  776. package/dist/prosemirror/commands/propertyChangeScope.d.ts +28 -15
  777. package/dist/prosemirror/commands/propertyChangeScope.js +5 -12
  778. package/dist/prosemirror/commands/replaceRangeText.d.ts +22 -0
  779. package/dist/prosemirror/commands/replaceRangeText.js +44 -0
  780. package/dist/prosemirror/commands/resolveAllTableChanges.js +3 -2
  781. package/dist/prosemirror/commands/resolveParagraphProperties.js +4 -8
  782. package/dist/prosemirror/commands/rulerParagraph.d.ts +25 -0
  783. package/dist/prosemirror/commands/rulerParagraph.js +18 -0
  784. package/dist/prosemirror/commands/sectionBreak.d.ts +5 -0
  785. package/dist/prosemirror/commands/table.d.ts +7 -0
  786. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -1
  787. package/dist/prosemirror/commentIdAllocator.d.ts +12 -6
  788. package/dist/prosemirror/commentIdAllocator.js +38 -29
  789. package/dist/prosemirror/commentOps.d.ts +7 -0
  790. package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +1 -1
  791. package/dist/prosemirror/commentRangeInlineAtoms.d.ts +4 -3
  792. package/dist/prosemirror/commentRangeInlineAtoms.js +1 -1
  793. package/dist/prosemirror/commentRecords.d.ts +154 -0
  794. package/dist/prosemirror/commentRecords.js +527 -0
  795. package/dist/prosemirror/commentReferenceAttrs.d.ts +1 -1
  796. package/dist/prosemirror/commentReferenceIntegrity.js +93 -14
  797. package/dist/prosemirror/containerFinalParagraph.d.ts +2 -0
  798. package/dist/prosemirror/containerFinalParagraph.js +3 -1
  799. package/dist/prosemirror/contentControlRevisions.d.ts +14 -0
  800. package/dist/prosemirror/conversion/effectiveTableCellFormatting.d.ts +5 -4
  801. package/dist/prosemirror/conversion/fromProseDoc.d.ts +1 -1
  802. package/dist/prosemirror/conversion/fromProseDoc.js +81 -61
  803. package/dist/prosemirror/conversion/index.d.ts +7 -2
  804. package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +21 -0
  805. package/dist/prosemirror/conversion/runShadingMark.d.ts +13 -1
  806. package/dist/prosemirror/conversion/storyConversionOptions.d.ts +16 -0
  807. package/dist/prosemirror/conversion/storyConversionOptions.js +13 -0
  808. package/dist/prosemirror/conversion/toProseDoc.d.ts +48 -14
  809. package/dist/prosemirror/conversion/toProseDoc.js +294 -145
  810. package/dist/prosemirror/copyOriginResolution.js +23 -10
  811. package/dist/prosemirror/documentSchema.d.ts +12 -0
  812. package/dist/prosemirror/emptyRangeAnchor.d.ts +39 -8
  813. package/dist/prosemirror/emptyRangeAnchor.js +63 -10
  814. package/dist/prosemirror/extensions/ExtensionManager.d.ts +7 -0
  815. package/dist/prosemirror/extensions/ExtensionManager.js +2 -0
  816. package/dist/prosemirror/extensions/StarterKit.d.ts +11 -2
  817. package/dist/prosemirror/extensions/core/DocExtension.d.ts +3 -0
  818. package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +3 -0
  819. package/dist/prosemirror/extensions/core/HistoryExtension.js +3 -2
  820. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +13 -4
  821. package/dist/prosemirror/extensions/core/ParagraphExtension.js +5 -3
  822. package/dist/prosemirror/extensions/core/TextExtension.d.ts +3 -0
  823. package/dist/prosemirror/extensions/create.d.ts +6 -0
  824. package/dist/prosemirror/extensions/features/BaseKeymapExtension.d.ts +5 -0
  825. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -3
  826. package/dist/prosemirror/extensions/features/BidiShortcutExtension.d.ts +10 -0
  827. package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.d.ts +10 -0
  828. package/dist/prosemirror/extensions/features/DropCursorExtension.d.ts +6 -0
  829. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +20 -0
  830. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +20 -23
  831. package/dist/prosemirror/extensions/features/GapCursorExtension.d.ts +13 -0
  832. package/dist/prosemirror/extensions/features/ImageDragExtension.d.ts +9 -0
  833. package/dist/prosemirror/extensions/features/ImagePasteExtension.d.ts +6 -0
  834. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +14 -0
  835. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +38 -21
  836. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +30 -3
  837. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +65 -45
  838. package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +17 -0
  839. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +7 -3
  840. package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.d.ts +14 -0
  841. package/dist/prosemirror/extensions/features/SelectionTrackerExtension.d.ts +4 -1
  842. package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +32 -3
  843. package/dist/prosemirror/extensions/features/pasteCleanup.js +23 -3
  844. package/dist/prosemirror/extensions/features/pastedCellSections.d.ts +22 -0
  845. package/dist/prosemirror/extensions/features/pastedCellSections.js +78 -0
  846. package/dist/prosemirror/extensions/features/pastedHeadingStyles.d.ts +22 -0
  847. package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +1 -0
  848. package/dist/prosemirror/extensions/markRegistry.d.ts +14 -1
  849. package/dist/prosemirror/extensions/marks/AllCapsExtension.d.ts +3 -0
  850. package/dist/prosemirror/extensions/marks/BoldExtension.d.ts +3 -0
  851. package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.d.ts +8 -0
  852. package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +14 -0
  853. package/dist/prosemirror/extensions/marks/CommentExtension.d.ts +6 -0
  854. package/dist/prosemirror/extensions/marks/CommentExtension.js +3 -1
  855. package/dist/prosemirror/extensions/marks/FontFamilyExtension.d.ts +3 -0
  856. package/dist/prosemirror/extensions/marks/FontFamilyExtension.js +4 -6
  857. package/dist/prosemirror/extensions/marks/FontSizeExtension.d.ts +3 -0
  858. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.d.ts +5 -0
  859. package/dist/prosemirror/extensions/marks/HiddenTextExtension.d.ts +17 -0
  860. package/dist/prosemirror/extensions/marks/HighlightExtension.d.ts +3 -0
  861. package/dist/prosemirror/extensions/marks/HyperlinkExtension.d.ts +3 -0
  862. package/dist/prosemirror/extensions/marks/HyphenElementExtension.d.ts +19 -0
  863. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +12 -0
  864. package/dist/prosemirror/extensions/marks/ItalicExtension.d.ts +3 -0
  865. package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +11 -2
  866. package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +2 -1
  867. package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -0
  868. package/dist/prosemirror/extensions/marks/SmallCapsExtension.d.ts +3 -0
  869. package/dist/prosemirror/extensions/marks/StrikeExtension.d.ts +3 -0
  870. package/dist/prosemirror/extensions/marks/SubscriptExtension.d.ts +3 -0
  871. package/dist/prosemirror/extensions/marks/SuperscriptExtension.d.ts +3 -0
  872. package/dist/prosemirror/extensions/marks/TextColorExtension.d.ts +3 -0
  873. package/dist/prosemirror/extensions/marks/TextEffectsExtensions.d.ts +6 -0
  874. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +7 -0
  875. package/dist/prosemirror/extensions/marks/UnderlineExtension.d.ts +3 -0
  876. package/dist/prosemirror/extensions/marks/markUtils.d.ts +10 -3
  877. package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +22 -0
  878. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +11 -0
  879. package/dist/prosemirror/extensions/nodes/BlockMoveRangeBoundaryExtension.d.ts +14 -0
  880. package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +17 -0
  881. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.d.ts +1 -0
  882. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +38 -4
  883. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +2 -1
  884. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
  885. package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +8 -0
  886. package/dist/prosemirror/extensions/nodes/HardBreakExtension.d.ts +3 -0
  887. package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.d.ts +3 -0
  888. package/dist/prosemirror/extensions/nodes/ImageExtension.d.ts +3 -0
  889. package/dist/prosemirror/extensions/nodes/MathExtension.d.ts +7 -0
  890. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +1 -0
  891. package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +3 -0
  892. package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.d.ts +1 -0
  893. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +25 -0
  894. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +9 -0
  895. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +1 -0
  896. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +7 -19
  897. package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.d.ts +1 -0
  898. package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +6 -0
  899. package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +6 -0
  900. package/dist/prosemirror/extensions/nodes/TabExtension.d.ts +3 -0
  901. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +8 -1
  902. package/dist/prosemirror/extensions/nodes/TableExtension.js +6 -6
  903. package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.d.ts +7 -0
  904. package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +7 -0
  905. package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +9 -0
  906. package/dist/prosemirror/extensions/types.d.ts +10 -1
  907. package/dist/prosemirror/findReplaceSelection.d.ts +1 -1
  908. package/dist/prosemirror/hyperlinkRemoval.d.ts +13 -1
  909. package/dist/prosemirror/imageCommit.d.ts +10 -0
  910. package/dist/prosemirror/index.d.ts +30 -20
  911. package/dist/prosemirror/indexedNodeLookup.d.ts +11 -0
  912. package/dist/prosemirror/inlineWrapperStack.d.ts +12 -0
  913. package/dist/prosemirror/insertOperations.d.ts +10 -1
  914. package/dist/prosemirror/insertOperations.js +2 -2
  915. package/dist/prosemirror/insertionGaps.d.ts +21 -0
  916. package/dist/prosemirror/insertionGaps.js +86 -0
  917. package/dist/prosemirror/keptRangeBoundaries.d.ts +16 -12
  918. package/dist/prosemirror/keptRangeBoundaries.js +28 -34
  919. package/dist/prosemirror/listAutoformatMarkers.d.ts +11 -0
  920. package/dist/prosemirror/listInstanceReferences.d.ts +5 -0
  921. package/dist/prosemirror/listLabels.d.ts +16 -3
  922. package/dist/prosemirror/listLabels.js +0 -6
  923. package/dist/prosemirror/listMarker.d.ts +2 -2
  924. package/dist/prosemirror/listNumbering.d.ts +1 -1
  925. package/dist/prosemirror/listRendering.d.ts +2 -2
  926. package/dist/prosemirror/listRenderingAttrs.d.ts +10 -1
  927. package/dist/prosemirror/lockedControls.d.ts +6 -0
  928. package/dist/prosemirror/markupViewNotes.d.ts +11 -1
  929. package/dist/prosemirror/markupViewProjection.d.ts +21 -4
  930. package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +1 -1
  931. package/dist/prosemirror/nativeSelection.d.ts +51 -0
  932. package/dist/prosemirror/nativeSelection.js +124 -0
  933. package/dist/prosemirror/noteReferenceOccurrences.d.ts +1 -1
  934. package/dist/prosemirror/noteReferenceReview.d.ts +17 -3
  935. package/dist/prosemirror/noteReferenceReview.js +26 -5
  936. package/dist/prosemirror/numberedRefFields.d.ts +2 -0
  937. package/dist/prosemirror/numberedRefFields.js +16 -5
  938. package/dist/prosemirror/pageBreakRunProjection.d.ts +2 -1
  939. package/dist/prosemirror/paraText.d.ts +14 -0
  940. package/dist/prosemirror/paragraphFormattingProvenance.d.ts +13 -1
  941. package/dist/prosemirror/paragraphIndentation.d.ts +6 -3
  942. package/dist/prosemirror/paragraphIndentation.js +2 -3
  943. package/dist/prosemirror/paragraphList.d.ts +1 -1
  944. package/dist/prosemirror/paragraphMarkJoin.d.ts +34 -8
  945. package/dist/prosemirror/paragraphMarkJoin.js +176 -18
  946. package/dist/prosemirror/paragraphPropertyCarry.d.ts +15 -1
  947. package/dist/prosemirror/paragraphPropertyCarry.js +5 -3
  948. package/dist/prosemirror/paragraphSpacing.d.ts +1 -1
  949. package/dist/prosemirror/pastePlacement.d.ts +17 -0
  950. package/dist/prosemirror/pastePlacement.js +22 -0
  951. package/dist/prosemirror/pastedCommentCopies.d.ts +87 -0
  952. package/dist/prosemirror/pastedCommentCopies.js +379 -0
  953. package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +12 -0
  954. package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +14 -0
  955. package/dist/prosemirror/plugins/contentControlWidgets.d.ts +15 -9
  956. package/dist/prosemirror/plugins/contentControlWidgets.js +24 -30
  957. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +17 -0
  958. package/dist/prosemirror/plugins/documentNumbering.d.ts +2 -1
  959. package/dist/prosemirror/plugins/documentNumbering.js +33 -14
  960. package/dist/prosemirror/plugins/documentStyleState.d.ts +3 -4
  961. package/dist/prosemirror/plugins/documentStyles.d.ts +20 -3
  962. package/dist/prosemirror/plugins/index.d.ts +7 -1
  963. package/dist/prosemirror/plugins/paragraphStyleResolution.d.ts +18 -1
  964. package/dist/prosemirror/plugins/paragraphStyleResolution.js +12 -2
  965. package/dist/prosemirror/plugins/pmTextScan.d.ts +18 -0
  966. package/dist/prosemirror/plugins/pmTextScan.js +42 -33
  967. package/dist/prosemirror/plugins/revisionIds.d.ts +14 -1
  968. package/dist/prosemirror/plugins/revisionIds.js +5 -1
  969. package/dist/prosemirror/plugins/selectionTracker.d.ts +12 -2
  970. package/dist/prosemirror/plugins/suggestionMode.d.ts +14 -11
  971. package/dist/prosemirror/plugins/suggestionMode.js +225 -35
  972. package/dist/prosemirror/plugins/templateDirectives.d.ts +17 -0
  973. package/dist/prosemirror/plugins/templatePreviewValues.d.ts +23 -0
  974. package/dist/prosemirror/plugins/templateSlashMenu.d.ts +19 -0
  975. package/dist/prosemirror/plugins/transactionInvariants.d.ts +19 -0
  976. package/dist/prosemirror/positionSweep.d.ts +21 -0
  977. package/dist/prosemirror/queries.d.ts +9 -0
  978. package/dist/prosemirror/queries.js +2 -2
  979. package/dist/prosemirror/rangeAnchorAttrs.d.ts +2 -2
  980. package/dist/prosemirror/rangeAnchorAttrs.js +55 -33
  981. package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
  982. package/dist/prosemirror/rejoinRunCarriers.d.ts +17 -0
  983. package/dist/prosemirror/replaceFindMatches.d.ts +20 -0
  984. package/dist/prosemirror/replaceFindMatches.js +33 -0
  985. package/dist/prosemirror/replacedAnnotations.d.ts +143 -0
  986. package/dist/prosemirror/replacedAnnotations.js +223 -26
  987. package/dist/prosemirror/revisionCarriers.js +9 -0
  988. package/dist/prosemirror/runFormattingFromMarks.d.ts +3 -3
  989. package/dist/prosemirror/runFormattingFromMarks.js +10 -51
  990. package/dist/prosemirror/runFormattingProvenance.d.ts +2 -1
  991. package/dist/prosemirror/runFormattingProvenance.js +2 -1
  992. package/dist/prosemirror/runFormattingReconciliation.js +3 -12
  993. package/dist/prosemirror/runIdentity.d.ts +14 -0
  994. package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +30 -1
  995. package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
  996. package/dist/prosemirror/runPropertyChangeResolution.d.ts +5 -13
  997. package/dist/prosemirror/runPropertyChangeResolution.js +13 -30
  998. package/dist/prosemirror/runStyleFormatting.d.ts +42 -113
  999. package/dist/prosemirror/runStyleFormatting.js +17 -74
  1000. package/dist/prosemirror/schema/index.d.ts +8 -1
  1001. package/dist/prosemirror/schema/marks.d.ts +21 -1
  1002. package/dist/prosemirror/schema/nodes.d.ts +15 -14
  1003. package/dist/prosemirror/sectionCarrier.d.ts +21 -0
  1004. package/dist/prosemirror/sectionMarkEdits.d.ts +18 -0
  1005. package/dist/prosemirror/selectionState.d.ts +10 -4
  1006. package/dist/prosemirror/storyListNumbering.d.ts +10 -0
  1007. package/dist/prosemirror/storyListNumbering.js +7 -2
  1008. package/dist/prosemirror/styles/index.d.ts +3 -0
  1009. package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +20 -18
  1010. package/dist/prosemirror/styles/paragraphStyleCascade.js +10 -19
  1011. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +4 -3
  1012. package/dist/prosemirror/styles/styleResolver.d.ts +40 -15
  1013. package/dist/prosemirror/styles/styleResolver.js +6 -6
  1014. package/dist/prosemirror/styles/styleToggleCascade.d.ts +18 -11
  1015. package/dist/prosemirror/styles/styleToggleCascade.js +2 -11
  1016. package/dist/prosemirror/styles/tableStyleRegions.d.ts +20 -7
  1017. package/dist/prosemirror/styles/tableStyleRegions.js +14 -13
  1018. package/dist/prosemirror/tableCellPaste.d.ts +21 -0
  1019. package/dist/prosemirror/tableCellPaste.js +32 -2
  1020. package/dist/prosemirror/tableGridMutation.d.ts +9 -0
  1021. package/dist/prosemirror/tableGridMutation.js +34 -2
  1022. package/dist/prosemirror/tablePositionedBookmarks.d.ts +6 -0
  1023. package/dist/prosemirror/tableResize.d.ts +20 -9
  1024. package/dist/prosemirror/tableResize.js +60 -49
  1025. package/dist/prosemirror/tableRunIn.d.ts +26 -1
  1026. package/dist/prosemirror/tableRunIn.js +39 -11
  1027. package/dist/prosemirror/textBoxAnchorAttrs.d.ts +1 -1
  1028. package/dist/prosemirror/textBoxHostCollapse.d.ts +11 -0
  1029. package/dist/prosemirror/textInput.d.ts +30 -1
  1030. package/dist/prosemirror/textInput.js +144 -17
  1031. package/dist/prosemirror/utils/findParagraphByParaId.d.ts +5 -0
  1032. package/dist/prosemirror/utils/tabCalculator.d.ts +6 -0
  1033. package/dist/prosemirror/utils/visualLineNavigation.js +21 -19
  1034. package/dist/prosemirror/validation.d.ts +19 -0
  1035. package/dist/prosemirror/validation.js +84 -16
  1036. package/dist/prosemirror/yjsDocumentMetadata.d.ts +9 -3
  1037. package/dist/prosemirror/yjsDocumentMetadata.js +49 -10
  1038. package/dist/prosemirror/zeroWidthAnchors.d.ts +18 -0
  1039. package/dist/redline.d.ts +4 -1
  1040. package/dist/redline.js +21 -13
  1041. package/dist/render-dom/BodySelectionOverlay.d.ts +5 -0
  1042. package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
  1043. package/dist/render-dom/RemoteSelectionOverlay.js +3 -3
  1044. package/dist/render-dom/RenderedDomContext.js +7 -6
  1045. package/dist/server.d.ts +30 -18
  1046. package/dist/server.js +4 -3
  1047. package/dist/shaping/placeRun.d.ts +8 -0
  1048. package/dist/shaping/shaper.d.ts +19 -0
  1049. package/dist/style-engine/index.d.ts +5 -0
  1050. package/dist/style-engine/styleEngine.d.ts +32 -13
  1051. package/dist/style-sets/extract.d.ts +1 -1
  1052. package/dist/style-sets/styleSetNormalization.d.ts +20 -1
  1053. package/dist/text-shaping.d.ts +9 -1
  1054. package/dist/types/anonymization.d.ts +17 -0
  1055. package/dist/types/anonymization.js +0 -0
  1056. package/dist/types/autocomplete.d.ts +46 -0
  1057. package/dist/types/autocomplete.js +0 -0
  1058. package/dist/types/canonicalCapabilities.d.ts +52 -53
  1059. package/dist/types/canonicalCapabilities.js +54 -56
  1060. package/dist/types/canonicalSave.d.ts +36 -0
  1061. package/dist/types/documentModel.d.ts +37 -0
  1062. package/dist/types/documentModel.js +24 -0
  1063. package/dist/types/docxSerialization.d.ts +10 -0
  1064. package/dist/types/index.d.ts +5 -0
  1065. package/dist/types/remote-selection.d.ts +2 -1
  1066. package/dist/types/selectiveSaveDecline.d.ts +44 -0
  1067. package/dist/types/selectiveSaveDecline.js +0 -0
  1068. package/dist/types/tableWidthKind.d.ts +2 -0
  1069. package/dist/types/tableWidthKind.js +9 -0
  1070. package/dist/utils/base64.d.ts +20 -0
  1071. package/dist/utils/borderCss.d.ts +18 -1
  1072. package/dist/utils/colorResolver.d.ts +12 -11
  1073. package/dist/utils/createDocument.d.ts +8 -1
  1074. package/dist/utils/createDocument.js +20 -2
  1075. package/dist/utils/diagonalHatch.d.ts +2 -0
  1076. package/dist/utils/diagonalHatch.js +16 -0
  1077. package/dist/utils/extremes.d.ts +4 -0
  1078. package/dist/utils/extremes.js +14 -0
  1079. package/dist/utils/findMatchView.d.ts +2 -2
  1080. package/dist/utils/findMatchView.js +4 -3
  1081. package/dist/utils/findReplace.d.ts +2 -2
  1082. package/dist/utils/findReplace.js +3 -2
  1083. package/dist/utils/fontFamilyMerge.d.ts +2 -1
  1084. package/dist/utils/fontResolver.d.ts +11 -2
  1085. package/dist/utils/formatToStyle.d.ts +21 -7
  1086. package/dist/utils/headerFooter.d.ts +16 -2
  1087. package/dist/utils/headerFooter.js +2 -6
  1088. package/dist/utils/imageResize.js +1 -1
  1089. package/dist/utils/listItems.d.ts +7 -0
  1090. package/dist/utils/listItems.js +9 -0
  1091. package/dist/utils/mergeDocumentContent.d.ts +7 -0
  1092. package/dist/utils/mergeDocumentContent.js +2 -2
  1093. package/dist/utils/outlineHeadings.d.ts +1 -1
  1094. package/dist/utils/paintedPositions.d.ts +60 -0
  1095. package/dist/utils/paintedPositions.js +101 -0
  1096. package/dist/utils/paragraphFormattingMerge.d.ts +11 -3
  1097. package/dist/utils/paragraphFormattingMerge.js +0 -8
  1098. package/dist/utils/paragraphInlineLayout.js +2 -1
  1099. package/dist/utils/repeatingStrokeGradient.d.ts +8 -0
  1100. package/dist/utils/repeatingStrokeGradient.js +13 -0
  1101. package/dist/utils/rotationBoundingBox.d.ts +8 -0
  1102. package/dist/utils/rulerControl.d.ts +71 -0
  1103. package/dist/utils/rulerControl.js +94 -0
  1104. package/dist/utils/tableOperations.d.ts +20 -4
  1105. package/dist/utils/tableOperations.js +1 -0
  1106. package/dist/utils/textDirectionFlow.d.ts +10 -0
  1107. package/dist/utils/textFormattingMerge.d.ts +18 -2
  1108. package/dist/utils/textFormattingMerge.js +0 -20
  1109. package/dist/utils/units.d.ts +2 -0
  1110. package/dist/utils/units.js +3 -1
  1111. package/dist/version-comparison.d.ts +63 -1
  1112. package/dist/version-comparison.js +2 -1
  1113. package/dist/watermark/index.d.ts +11 -0
  1114. package/dist/watermark/index.js +0 -5
  1115. package/package.json +7 -8
  1116. package/dist/controller/canonicalLockGuard.d.ts +0 -8
  1117. package/dist/controller/canonicalLockGuard.js +0 -88
  1118. package/dist/controller/canonicalPublicOperations.js +0 -900
  1119. package/dist/controller/canonicalSession.d.ts +0 -256
  1120. package/dist/controller/canonicalSession.js +0 -1717
  1121. package/dist/docx/canonicalResourceSave.d.ts +0 -15
  1122. package/dist/docx/canonicalResourceSave.js +0 -27
  1123. package/dist/internal/acceptedBlockProjection.d.ts +0 -9
  1124. package/dist/internal/acceptedBlockProjection.js +0 -50
  1125. package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +0 -60
  1126. package/dist/prosemirror/plugins/anonymizationDecorations.js +0 -111
  1127. package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +0 -127
  1128. package/dist/prosemirror/plugins/autocompleteSuggestion.js +0 -282
  1129. package/dist/utils/replaceText.d.ts +0 -25
  1130. package/dist/utils/replaceText.js +0 -242
  1131. /package/dist/{controller → canonical}/canonicalListRendering.d.ts +0 -0
  1132. /package/dist/{controller → canonical}/canonicalOperations.d.ts +0 -0
  1133. /package/dist/{controller → canonical}/canonicalSelection.d.ts +0 -0
  1134. /package/dist/{controller → canonical}/canonicalTocSelection.d.ts +0 -0
@@ -1,19 +1,21 @@
1
1
  import { NO_NUMBERING_IDS_IN_USE } from "../docx/numberingIds.js";
2
- import { isNumberingReference as isNumberingReference$1 } from "../docx/numberingReference.js";
2
+ import { proseParagraphAttrsWithoutPropertySource } from "../docx/paragraphPropertySource.js";
3
3
  import { formattingEquals } from "../docx/runConsolidator.js";
4
4
  import { isStyleSourcedParagraphNumbering } from "../internal/paragraphFormattingSerialization.js";
5
+ import { joinEndsBeforeTable, paragraphMergeLeaves, pendingJoinEnd } from "../prosemirror/acceptedBlockNeighbours.js";
5
6
  import { addTrackedDeletionMark } from "../prosemirror/addTrackedDeletionMark.js";
6
7
  import { deleteTextBoxesAnchoredAt, droppedTextBoxAnchorIds, endOfParagraphWithItsTextBoxes, gatherTextBoxesAfterParagraph, textBoxAnchorIdOf, textBoxAnchorIdsBetween } from "../prosemirror/anchoredTextBoxes.js";
7
8
  import { expectParagraphAttrs, expectRunPropertyChangeMarkAttrs, expectTableRowAttrs, mergeParagraphAttrs } from "../prosemirror/attrs/index.js";
8
9
  import { paragraphJoinAfter } from "../prosemirror/commands/paragraphBookmarkJoin.js";
9
10
  import { hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot } from "../prosemirror/commands/propertyChangeScope.js";
10
11
  import { resolveParagraphChangeAttrs } from "../prosemirror/commands/resolveParagraphProperties.js";
11
- import { addedBreakCarrierBefore, finalParagraphsOf, paragraphEndsItsContainer } from "../prosemirror/containerFinalParagraph.js";
12
+ import { addedBreakCarrierBefore, containerEndsAt, finalParagraphsOf, paragraphEndsItsContainer } from "../prosemirror/containerFinalParagraph.js";
12
13
  import { encloseWholeControls } from "../prosemirror/contentControlRevisions.js";
13
14
  import { JOINED_RUNS_RESTYLED_META } from "../prosemirror/extensions/features/JoinedRunStyleExtension.js";
14
15
  import { requestDeterministicParaIds } from "../prosemirror/extensions/features/ParaIdAllocatorExtension.js";
15
16
  import { markStructuralChange } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
16
17
  import "../prosemirror/extensions/nodes/TextBoxAnchorExtension.js";
18
+ import { InsertionGapOrder, insertionGap, insertionGapEnd } from "../prosemirror/insertionGaps.js";
17
19
  import { blockBoundariesOf, carriesCommentAnchor, inlineBoundariesOf, isBlockBoundaryNode, removeResolvedSubtree } from "../prosemirror/keptRangeBoundaries.js";
18
20
  import { CLEARED_LIST_RENDERING_ATTRS } from "../prosemirror/listMarker.js";
19
21
  import { lockedControlSpans } from "../prosemirror/lockedControls.js";
@@ -22,13 +24,13 @@ import { directParagraphAlignment } from "../prosemirror/paragraphAlignment.js";
22
24
  import { styleResolvedParagraphFormatting } from "../prosemirror/paragraphFormattingProvenance.js";
23
25
  import { directParagraphIndentation, paragraphIndentationAttrPatch, paragraphIndentationEqual, paragraphIndentationFromFormatting, withDirectParagraphIndentation } from "../prosemirror/paragraphIndentation.js";
24
26
  import { joinAtParagraphMark } from "../prosemirror/paragraphMarkJoin.js";
25
- import { carryParagraphProperties, paragraphLeftAfter, recordReplacedParagraphProperties } from "../prosemirror/paragraphPropertyCarry.js";
27
+ import { carryParagraphProperties, paragraphLeftAfter, paragraphPropertySnapshotsDiffer, recordReplacedParagraphProperties } from "../prosemirror/paragraphPropertyCarry.js";
26
28
  import { directParagraphSpacing, paragraphSpacingAttrPatch, paragraphSpacingEqual, paragraphSpacingFromFormatting, withDirectParagraphSpacing } from "../prosemirror/paragraphSpacing.js";
27
29
  import { getDocumentNumbering, getDocumentNumberingInstanceIds } from "../prosemirror/plugins/documentNumbering.js";
28
30
  import { getDocumentStyleDefinitions, getDocumentStyleResolver } from "../prosemirror/plugins/documentStyleState.js";
29
31
  import { claimRevisionIds, nextRevisionId, nextRevisionIdRange, reserveRevisionIds, seedRevisionIdsFromDoc } from "../prosemirror/plugins/revisionIds.js";
30
32
  import { rebaseParagraphRuns } from "../prosemirror/rebaseParagraphRuns.js";
31
- import { NON_INCLUSIVE_MARK_DISPOSITION, addCarriedMarks, annotatedReplacement, commentsAcrossBlockBoundary, commentsForTrackedInsertion, hasReplacedAnnotations, inheritedReplacementMarks, joinCommentStretches, placeTrackedInsertion, surveyAcceptedReplacedAnnotations, surveyReplacedAnnotations } from "../prosemirror/replacedAnnotations.js";
33
+ import { NON_INCLUSIVE_MARK_DISPOSITION, addCarriedMarks, annotatedReplacement, commentsAcrossBlockBoundary, commentsForTrackedInsertion, commentsSpanningInsertion, hasReplacedAnnotations, inheritedReplacementMarks, joinCommentStretches, placeTrackedInsertion, surveyAcceptedReplacedAnnotations, surveyReplacedAnnotations } from "../prosemirror/replacedAnnotations.js";
32
34
  import { applyMarksToRunFormattingRepresentation, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations } from "../prosemirror/runFormattingInlineCarriers.js";
33
35
  import { RUN_FORMATTING_MARK_NAMES } from "../prosemirror/runFormattingMarkNames.js";
34
36
  import { readAuthoredRunFormatting, readAuthoredRunPropertySnapshot, reconcileRunFormattingMarks } from "../prosemirror/runFormattingReconciliation.js";
@@ -36,34 +38,41 @@ import { paragraphRunStyleContext, paragraphRunStyleContextAt, resolveParagraphB
36
38
  import { sectionPropertiesOf } from "../prosemirror/sectionCarrier.js";
37
39
  import { listAttrsFromNumbering, listLevelAttrPatch, listLevelIndentRemovalPatch } from "../prosemirror/styles/resolvedStyleAttrs.js";
38
40
  import { removeRowsWithoutCellsAfterBatch } from "../prosemirror/tableGridMutation.js";
39
- import { runInCellPending } from "../prosemirror/tableRunIn.js";
41
+ import { paragraphGoes, tableGoes } from "../prosemirror/tableRunIn.js";
40
42
  import { isZeroWidthAnchor } from "../prosemirror/zeroWidthAnchors.js";
41
43
  import { getFolioParaIdFromBlockId } from "../types/block-id.js";
42
- import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
44
+ import { canonicalJson } from "../utils/canonicalJson.js";
43
45
  import { BatchClaims } from "./batch-claims.js";
44
46
  import { stripBlockIdentityAttrs } from "./block-identity.js";
45
47
  import { describeCharacterSplit } from "./character-boundaries.js";
46
48
  import { buildCleanBlockText, resolveCleanTextRange } from "./clean-text.js";
49
+ import { directJoinSurvivor, directJoinTakes } from "./directJoin.js";
50
+ import { EXISTING_REVISION_CONFLICT_MESSAGE, createExistingRevisionGuard } from "./existingRevisions.js";
47
51
  import { hasInlineEmphasis, parseInlineEmphasisRuns, stripInlineEmphasisMarkers } from "./inline-emphasis.js";
48
- import { applyTextChanges, changesFromSegments, keepAtomicSpans, planTextChanges, widenChangesToAtomicSpans } from "./minimal-replacement.js";
49
- import { assertNewListsAllocated, resolveNewListOperations, stageNewListOperations } from "./newListNumbering.js";
50
- import { comparisonApplying, cutsIntoNoteReference, noteReferenceEditsAllowed, noteReferenceOf, noteReferenceSpansWithin, planChangesAroundNoteReferences, segmentsAroundNoteReferences } from "./note-references.js";
51
- import { classifyResourceReference } from "./referenceClassification.js";
52
+ import { compileMarkdownInsertion, markdownRunText } from "./markdownInsertion.js";
53
+ import { BACKGROUND_MARK_NAMES, changesFromSegments, planReplacementChanges, planTextChanges, touchedBackgroundStretches } from "./minimal-replacement.js";
54
+ import { assertNewListsAllocated, deferInsertedList, resolveNewListOperations, stageNewListOperations } from "./newListNumbering.js";
55
+ import { comparisonApplying, cutsIntoNoteReference, noteReferenceEditsAllowed, noteReferenceOf, noteReferenceSpansWithin, segmentsAroundNoteReferences } from "./note-references.js";
56
+ import { PENDING_JOIN_INSERTION_REFUSAL, PENDING_PARAGRAPH_MARK_PROPERTY_REFUSAL, holdsOnlyDeletedContent, isDeletedPPrMark, isPendingDeletion, joinStopsAtTableAfter, pendingJoinBounds } from "./pendingJoin.js";
52
57
  import { getFolioDocumentOperationRemovedBlockIds, getTrackedFolioDocumentOperationCarrierBlockId, getTrackedFolioDocumentOperationRemovedBlockIds } from "./removed-blocks.js";
58
+ import { addRetiredCommentReceipts } from "./retired-comment-receipts.js";
53
59
  import { separateRevisionStretches } from "./revisionStretches.js";
54
60
  import { collectNoteReferenceLabels, hashFolioAIBlockContent, hashFolioAIBlockStructuralBoundaries, hashFolioAIBlockText, isHiddenTableRow } from "./snapshot.js";
55
- import { isEmptyTableCell, mergeTableRectangle, mergeTrackedVerticalTableCells, splitTableRectangle, splitTrackedVerticalTableCell } from "./table-cell-mutations.js";
61
+ import { followedOnlyByDeletedParagraphs, isInsertedPPrMark, isPlainDeletedPPrMark, snapshotBatchClaim } from "./snapshotBatchFacts.js";
62
+ import { mergeTableRectangle, mergeTrackedVerticalTableCells, splitTableRectangle, splitTrackedVerticalTableCell } from "./table-cell-mutations.js";
56
63
  import { planTableMutations } from "./table-mutation-plan.js";
57
- import { applyTableColumnDeletion, applyTableColumnInsertion, applyTableRowDeletion, applyTableRowInsertion, describeUnplacedCellTexts, findTableColumnInsertion, findTableRowInsertion, getTableColumnCoordinateKey, markTableRowContent, splitCellParagraphTexts } from "./table-row-column-mutations.js";
64
+ import { applyTableColumnDeletion, applyTableColumnInsertions, applyTableRowDeletion, applyTableRowInsertion, describeUnplacedCellTexts, findTableColumnInsertion, findTableRowInsertion, getTableColumnCoordinateKey, markTableRowContent, splitCellParagraphTexts } from "./table-row-column-mutations.js";
58
65
  import { findEnclosingTableCell, findEnclosingTableRow, findOutermostTableBoundary, tableRectangleCutsMergedCell } from "./table-targets.js";
59
66
  import { tableFromTemplate } from "./table-template.js";
67
+ import { supportsTableInsertionMode } from "./tableInsertionModes.js";
68
+ import { findUndefinedOperationReference } from "./undefinedReferences.js";
60
69
  import { wordDiffSessionFromOptions } from "./word-diff.js";
61
70
  import { panic } from "better-result";
62
71
  import { CONTENT_CONTROL_LOCK, REVIEW_CARRIERS, firstLockedControlViolation, lockedControlMessage } from "@stll/docx-core/model";
63
72
  import { Fragment, Mark } from "prosemirror-model";
64
73
  import { TableMap } from "prosemirror-tables";
65
74
  import { canSplit } from "prosemirror-transform";
66
- import { contentRank, deletionRemovesBlock, groupInsertionRuns, orderAddressingBeforeRemoval, orderBatchOperations } from "@stll/docx-core/ops";
75
+ import { BATCH_ANNOTATION_KINDS, SPLIT_HALVES, contentRank, deletionRemovesBlock, finalBreakCarrier, groupInsertionRuns, orderAddressingBeforeRemoval, orderBatchOperations } from "@stll/docx-core/ops";
67
76
  // src/ai-edits/apply.ts
68
77
  const coarseWordDiff = (before, after) => {
69
78
  if (before === after) return before.length === 0 ? [] : [{
@@ -139,10 +148,10 @@ const SUGGESTED_SUPPORTED_OPERATION_TYPES = /* @__PURE__ */ new Set([
139
148
  "deleteTableColumn"
140
149
  ]);
141
150
  /** Operations that only add marks: they move no position of the document. */
142
- const ANNOTATION_OPERATION_TYPES = /* @__PURE__ */ new Set([
143
- "formatRange",
144
- "commentOnRange",
145
- "commentOnBlock"
151
+ const ANNOTATION_KIND_OF = /* @__PURE__ */ new Map([
152
+ ["formatRange", BATCH_ANNOTATION_KINDS.FORMATTING],
153
+ ["commentOnRange", BATCH_ANNOTATION_KINDS.COMMENT],
154
+ ["commentOnBlock", BATCH_ANNOTATION_KINDS.COMMENT]
146
155
  ]);
147
156
  const REPLACE_BLOCK_IMPACT = {
148
157
  text: {
@@ -409,6 +418,16 @@ const paragraphPropertiesBeforePendingChanges = (node) => {
409
418
  const earliest = Array.isArray(propertyChanges) ? propertyChanges[0] : void 0;
410
419
  return earliest === void 0 ? paragraphPropertiesSnapshot(node) : earliest.previousFormatting ?? {};
411
420
  };
421
+ /**
422
+ * Whether two pPr snapshots state the same properties. A pending change read
423
+ * back from a saved package has no `numPrFromStyle`, which no package writes
424
+ * and the live snapshot always states, nor absent values written as null, so
425
+ * only what a package can say is compared, in any key order.
426
+ */
427
+ const sameParagraphProperties = (left, right) => {
428
+ const stated = (properties) => canonicalJson(Object.fromEntries(Object.entries(properties).filter(([key, value]) => key !== "numPrFromStyle" && value != null)));
429
+ return stated(left) === stated(right);
430
+ };
412
431
  /** The pPr rejecting every pending change of a paragraph's properties leaves. */
413
432
  const paragraphPropertiesOnReject = (node) => {
414
433
  const [earliest] = expectParagraphAttrs(node)._propertyChanges ?? [];
@@ -561,8 +580,7 @@ const applyBlockParagraphProperties = ({ tr, position, node, properties, styleRe
561
580
  /** No inherited formatting: every run-formatting mark reads as authored. */
562
581
  const OPERATION_TEXT_CONTEXT = {
563
582
  baseParagraphFormatting: void 0,
564
- paragraphFormatting: void 0,
565
- paragraphMarkFormatting: void 0
583
+ paragraphFormatting: void 0
566
584
  };
567
585
  const applyReplaceBlockStyleId = ({ item, tr, styleResolver, revisionInfo }) => {
568
586
  if (item.operation.type !== "replaceBlock" || item.operation.styleId === void 0) return {
@@ -636,7 +654,7 @@ const applyReplaceBlockStyleId = ({ item, tr, styleResolver, revisionInfo }) =>
636
654
  };
637
655
  };
638
656
  const REPLACEMENT_BACKGROUND_CLEAR_FORMATTING = {
639
- highlight: false,
657
+ highlight: null,
640
658
  runShading: false
641
659
  };
642
660
  const includedFormattingProperty = (includedProperties, property) => includedProperties === void 0 || includedProperties.includes(property);
@@ -672,7 +690,10 @@ const patchAuthoredRunFormatting = ({ authoredFormatting, formatting, includedPr
672
690
  if (formatting.color === null) delete next.color;
673
691
  else next.color = { rgb: formatting.color.replace(/^#/u, "").toUpperCase() };
674
692
  }
675
- if (formatting.highlight === false && includedFormattingProperty(includedProperties, "highlight")) delete next.highlight;
693
+ if (formatting.highlight !== void 0 && includedFormattingProperty(includedProperties, "highlight")) {
694
+ if (formatting.highlight === null) delete next.highlight;
695
+ else next.highlight = formatting.highlight;
696
+ }
676
697
  if (formatting.runShading === false && includedFormattingProperty(includedProperties, "runShading")) delete next.shading;
677
698
  return next;
678
699
  };
@@ -982,199 +1003,92 @@ const mapTableRowInsertion = (tr, insertion) => {
982
1003
  rowspanUpdates: insertion.rowspanUpdates.map((update) => tr.mapping.map(insertion.tableStart + update, 1) - tableStart)
983
1004
  };
984
1005
  };
985
- /** The cells a column deletion removes: every cell standing in that column alone. */
986
- const deletedColumnCellRanges = (doc, { tablePosition, columnIndex }) => {
987
- const table = doc.nodeAt(tablePosition);
988
- if (!table || table.type.spec["tableRole"] !== "table") return [];
989
- const map = TableMap.get(table);
990
- const tableStart = tablePosition + 1;
991
- const ranges = [];
992
- const seen = /* @__PURE__ */ new Set();
993
- for (let row = 0; row < map.height; row++) {
994
- const relative = map.map[row * map.width + columnIndex];
995
- if (relative === void 0 || seen.has(relative)) continue;
996
- seen.add(relative);
997
- const rectangle = map.findCell(relative);
998
- const cell = table.nodeAt(relative);
999
- if (!cell || rectangle.left !== columnIndex || rectangle.right !== columnIndex + 1) continue;
1000
- ranges.push({
1001
- from: tableStart + relative,
1002
- to: tableStart + relative + cell.nodeSize
1003
- });
1004
- }
1005
- return ranges;
1006
- };
1007
- /** A row deletion also changes cells whose vertical merge began above it. */
1008
- const deletedRowAffectedRanges = ({ doc, deletion, row }) => {
1009
- const ranges = [{
1010
- from: deletion.rowPosition,
1011
- to: deletion.rowPosition + row.nodeSize
1012
- }];
1013
- const table = doc.nodeAt(deletion.tablePosition);
1014
- if (table?.type.spec["tableRole"] !== "table") return panic("A resolved row deletion lost its table", { position: deletion.tablePosition });
1015
- const map = TableMap.get(table);
1016
- const seen = /* @__PURE__ */ new Set();
1017
- for (let column = 0; column < map.width; column++) {
1018
- const relative = map.map[deletion.rowIndex * map.width + column];
1019
- if (relative === void 0 || seen.has(relative)) continue;
1020
- seen.add(relative);
1021
- const position = deletion.tableStart + relative;
1022
- if (position >= deletion.rowPosition) continue;
1023
- const cell = table.nodeAt(relative);
1024
- if (cell) ranges.push({
1025
- from: position,
1026
- to: position + cell.nodeSize
1027
- });
1028
- }
1029
- return ranges;
1030
- };
1031
- /**
1032
- * The blank cells a merge folds into the first cell of its rectangle. Only a
1033
- * blank cell can fold away tracked, so an edit that fills one decides whether
1034
- * the merge applies in one mode and not the other; see `batch-claims.ts`. A
1035
- * cell with content folds directly and is refused tracked whatever the batch
1036
- * does inside it.
1037
- */
1038
- const foldedBlankCellRanges = (doc, { tablePosition, rectangle }) => {
1039
- const table = doc.nodeAt(tablePosition);
1040
- if (table?.type.spec["tableRole"] !== "table") return panic("A resolved cell merge lost its table", { position: tablePosition });
1041
- const map = TableMap.get(table);
1042
- const tableStart = tablePosition + 1;
1043
- const kept = map.map[rectangle.top * map.width + rectangle.left];
1044
- return map.cellsInRect(rectangle).flatMap((relative) => {
1045
- const cell = relative === kept ? null : table.nodeAt(relative);
1046
- return cell && isEmptyTableCell(cell) ? [{
1047
- from: tableStart + relative,
1048
- to: tableStart + relative + cell.nodeSize
1049
- }] : [];
1050
- });
1051
- };
1052
- /**
1053
- * The paragraphs before `paragraph`, which ends its container, nearest first,
1054
- * up to the container's start or another block, past those that go whole, as
1055
- * `finalParagraphPredecessor` looks past them. See the `deleteBlock` claim's
1056
- * `paragraphsBefore`.
1057
- */
1058
- const paragraphsBeforeFinal = ($paragraph, paragraph) => {
1059
- const paragraphs = [];
1060
- let position = $paragraph.pos;
1061
- for (let index = $paragraph.index() - 1; index >= 0; index--) {
1062
- const node = $paragraph.parent.child(index);
1063
- position -= node.nodeSize;
1064
- if (node.type !== paragraph.type) break;
1065
- const mark = node.attrs["pPrMark"];
1066
- if (isPlainDeletedPPrMark(mark) && holdsOnlyDeletedContent(node)) continue;
1067
- paragraphs.push({
1068
- block: position,
1069
- keepsBreak: mark == null
1070
- });
1071
- }
1072
- return paragraphs;
1073
- };
1074
1006
  /** What `item` claims of the document its batch resolved against; see `batch-claims.ts`. */
1075
1007
  const batchClaimOf = ({ item, doc, producesTrackedChanges }) => {
1008
+ const claim = (operation) => snapshotBatchClaim({
1009
+ item: operation,
1010
+ doc,
1011
+ producesTrackedChanges
1012
+ });
1076
1013
  const block = item.blockFrom;
1077
1014
  switch (item.operation.type) {
1078
1015
  case "replaceInBlock":
1079
- case "replaceRange": return {
1016
+ case "replaceRange": return claim({
1080
1017
  type: "text",
1081
1018
  block,
1082
1019
  from: item.from,
1083
1020
  to: item.to
1084
- };
1021
+ });
1085
1022
  case "formatRange":
1086
1023
  case "commentOnRange":
1087
- case "commentOnBlock": return {
1024
+ case "commentOnBlock": return claim({
1088
1025
  type: "annotation",
1089
1026
  block,
1090
1027
  from: item.from,
1091
1028
  to: item.to
1092
- };
1093
- case "splitBlock": return {
1029
+ });
1030
+ case "splitBlock": return claim({
1094
1031
  type: "split",
1095
1032
  block,
1096
1033
  from: item.from,
1097
1034
  to: item.to
1098
- };
1099
- case "replaceBlock": return item.replaceBlockImpact === "style" ? {
1035
+ });
1036
+ case "replaceBlock": return claim(item.replaceBlockImpact === "style" ? {
1100
1037
  type: "paragraphProperties",
1101
1038
  block
1102
1039
  } : {
1103
1040
  type: "rewriteBlock",
1104
1041
  block
1105
- };
1106
- case "setBlockParagraphProperties": return {
1042
+ });
1043
+ case "setBlockParagraphProperties": return claim({
1107
1044
  type: "paragraphProperties",
1108
1045
  block
1109
- };
1110
- case "mergeBlockWithNext": return {
1046
+ });
1047
+ case "mergeBlockWithNext": return claim({
1111
1048
  type: "merge",
1112
1049
  block,
1113
1050
  next: item.blockTo,
1114
1051
  joinsNow: !producesTrackedChanges,
1115
1052
  setsProperties: item.operation.mergedParagraphProperties !== void 0
1116
- };
1117
- case "deleteBlock": {
1118
- const at = doc.resolve(block);
1119
- const endsItsContainer = paragraphEndsItsContainer(at, item.blockNode.type.name);
1120
- const keepsParagraph = producesTrackedChanges ? endsItsContainer : endsItsContainer && at.nodeBefore?.type.name !== item.blockNode.type.name;
1121
- return {
1122
- type: "deleteBlock",
1123
- block,
1124
- end: item.blockTo,
1125
- keepsParagraph,
1126
- endsContainer: endsItsContainer,
1127
- paragraphsBefore: producesTrackedChanges && endsItsContainer ? paragraphsBeforeFinal(at, item.blockNode) : []
1128
- };
1129
- }
1053
+ });
1054
+ case "deleteBlock": return claim({
1055
+ type: "deleteBlock",
1056
+ block,
1057
+ end: item.blockTo,
1058
+ node: item.blockNode
1059
+ });
1130
1060
  case "insertAfterBlock":
1131
1061
  case "insertBeforeBlock":
1132
1062
  case "insertSignatureTable":
1133
- case "insertTable": return {
1063
+ case "insertTable": return claim({
1134
1064
  type: "insertion",
1135
1065
  at: item.from
1136
- };
1066
+ });
1137
1067
  case "deleteTable": {
1138
1068
  const deleted = item.deletedTable;
1139
- return deleted ? {
1140
- type: "tableRemoval",
1141
- table: deleted.position,
1142
- wholeTable: true,
1143
- axis: "table",
1144
- ranges: [{
1145
- from: deleted.position,
1146
- to: deleted.position + deleted.node.nodeSize
1147
- }]
1148
- } : { type: "unclaimed" };
1069
+ return deleted ? claim({
1070
+ type: "deleteTable",
1071
+ position: deleted.position,
1072
+ node: deleted.node
1073
+ }) : { type: "unclaimed" };
1149
1074
  }
1150
1075
  case "deleteTableRow": {
1151
1076
  const deletion = item.tableRowDeletion;
1152
1077
  const row = deletion ? doc.nodeAt(deletion.rowPosition) : null;
1153
1078
  const table = deletion ? doc.nodeAt(deletion.tablePosition) : null;
1154
- return deletion && row && table?.type.spec["tableRole"] === "table" ? {
1155
- type: "tableRemoval",
1156
- table: deletion.tablePosition,
1157
- wholeTable: table.childCount === 1,
1158
- axis: "row",
1159
- ranges: table.childCount === 1 ? [{
1160
- from: deletion.tablePosition,
1161
- to: deletion.tablePosition + table.nodeSize
1162
- }] : deletedRowAffectedRanges({
1163
- doc,
1164
- deletion,
1165
- row
1166
- })
1167
- } : { type: "unclaimed" };
1079
+ return deletion && row && table?.type.spec["tableRole"] === "table" ? claim({
1080
+ type: "deleteTableRow",
1081
+ deletion,
1082
+ row,
1083
+ table
1084
+ }) : { type: "unclaimed" };
1168
1085
  }
1169
1086
  case "deleteTableColumn": {
1170
1087
  const deletion = item.tableColumnDeletion;
1171
- return deletion ? {
1172
- type: "tableRemoval",
1173
- table: deletion.tablePosition,
1174
- wholeTable: false,
1175
- axis: "column",
1176
- ranges: deletedColumnCellRanges(doc, deletion)
1177
- } : { type: "unclaimed" };
1088
+ return deletion ? claim({
1089
+ type: "deleteTableColumn",
1090
+ deletion
1091
+ }) : { type: "unclaimed" };
1178
1092
  }
1179
1093
  case "insertTableRow":
1180
1094
  case "insertTableColumn":
@@ -1185,12 +1099,11 @@ const batchClaimOf = ({ item, doc, producesTrackedChanges }) => {
1185
1099
  if (item.operation.type === "insertTableRow") axis = "row";
1186
1100
  if (item.operation.type === "insertTableColumn") axis = "column";
1187
1101
  if (target.type === "none") return { type: "unclaimed" };
1188
- return {
1102
+ return claim({
1189
1103
  type: "tableStructure",
1190
- table: target.tablePosition,
1191
- axis,
1192
- folded: target.type === "mergeCells" ? foldedBlankCellRanges(doc, target) : []
1193
- };
1104
+ target,
1105
+ axis
1106
+ });
1194
1107
  }
1195
1108
  }
1196
1109
  };
@@ -1481,9 +1394,11 @@ const readNow = (item, tr) => {
1481
1394
  * break is pending removal while its words stay, accepting runs them into the
1482
1395
  * paragraph the join leaves, which already carries the joined paragraph's
1483
1396
  * properties (see `carryParagraphProperties`). Null when the paragraph stands
1484
- * alone, or goes whole as a pending deletion.
1397
+ * alone, or goes whole as a pending deletion. A block the running batch put
1398
+ * between the two takes the break pending removal once the batch is done, and
1399
+ * the paragraph then stands alone too: it reads as itself, not as the block.
1485
1400
  */
1486
- const pendingJoinSurvivor = ({ doc, paragraphPos, cleanText, noteReferences, removedBreakPositions }) => {
1401
+ const pendingJoinSurvivor = ({ doc, paragraphPos, cleanText, noteReferences, removedBreakPositions, batchBlockIn }) => {
1487
1402
  const paragraph = doc.nodeAt(paragraphPos);
1488
1403
  if (paragraph?.type.name !== "paragraph" || !isDeletedPPrMark(paragraph.attrs["pPrMark"]) || isPendingDeletion(doc, paragraphPos, paragraph, cleanText)) return null;
1489
1404
  const survivor = paragraphLeftAfter({
@@ -1493,6 +1408,7 @@ const pendingJoinSurvivor = ({ doc, paragraphPos, cleanText, noteReferences, rem
1493
1408
  });
1494
1409
  const left = survivor === null ? null : doc.nodeAt(survivor);
1495
1410
  if (survivor === null || left?.type !== paragraph.type) return null;
1411
+ if (batchBlockIn?.(paragraphPos + paragraph.nodeSize, survivor + 1)) return null;
1496
1412
  return isDeletedPPrMark(left.attrs["pPrMark"]) && isPendingDeletion(doc, survivor, left, buildCleanBlockText(left, survivor, {
1497
1413
  fieldResults: "text",
1498
1414
  noteReferences
@@ -1503,9 +1419,12 @@ const pendingJoinSurvivor = ({ doc, paragraphPos, cleanText, noteReferences, rem
1503
1419
  * its anchor: a paragraph a pending join runs into another reads as that one,
1504
1420
  * as the joined paragraph does when the merge is applied directly. A
1505
1421
  * suggestion is read against the document as it stands, where the join has
1506
- * not run anything together yet, so it copies the paragraph it names.
1422
+ * not run anything together yet, so it copies the paragraph it names. The
1423
+ * blocks the batch already put in are not that paragraph: each insertion
1424
+ * reads the properties it asked for, and an insertion that asked for none
1425
+ * reads the anchor, never another insertion of the batch.
1507
1426
  */
1508
- const insertionFormattingAnchor = ({ item, tr, mode, noteReferences, removedBreakPositions }) => {
1427
+ const insertionFormattingAnchor = ({ item, tr, mode, noteReferences, removedBreakPositions, gapOrder }) => {
1509
1428
  if (mode === "suggested") return item;
1510
1429
  const position = sinceRead(tr, item).map(item.blockFrom, 1);
1511
1430
  const anchor = tr.doc.nodeAt(position);
@@ -1518,7 +1437,8 @@ const insertionFormattingAnchor = ({ item, tr, mode, noteReferences, removedBrea
1518
1437
  noteReferences
1519
1438
  }).text,
1520
1439
  noteReferences,
1521
- removedBreakPositions
1440
+ removedBreakPositions,
1441
+ batchBlockIn: (from, to) => gapOrder.holdsBlockIn(tr, from, to)
1522
1442
  });
1523
1443
  const source = survivor === null ? null : tr.doc.nodeAt(survivor);
1524
1444
  return source ? {
@@ -1526,120 +1446,17 @@ const insertionFormattingAnchor = ({ item, tr, mode, noteReferences, removedBrea
1526
1446
  blockNode: source
1527
1447
  } : item;
1528
1448
  };
1529
- const keepsWords = ({ doc, paragraphPos, noteReferences }) => {
1530
- const paragraph = doc.nodeAt(paragraphPos);
1531
- if (paragraph?.type.name !== "paragraph") return false;
1532
- const cleanText = buildCleanBlockText(paragraph, paragraphPos, {
1533
- fieldResults: "text",
1534
- noteReferences
1535
- }).text;
1536
- return cleanText.length > 0 && !isPendingDeletion(doc, paragraphPos, paragraph, cleanText);
1537
- };
1538
- /**
1539
- * Whether accepting runs the paragraph into the one its pending join leaves:
1540
- * it keeps words, or it is empty. One whose words are all pending deletion
1541
- * goes whole instead.
1542
- */
1543
- const joinsIn = (options) => options.doc.nodeAt(options.paragraphPos)?.content.size === 0 || keepsWords(options);
1544
- /**
1545
- * Whether a pending join runs earlier words on to `paragraphPos`, the start of
1546
- * a paragraph or a place between blocks: the paragraphs before it, back to one
1547
- * that keeps words, all have their breaks pending removal.
1548
- */
1549
- const joinRunsWordsInto = ({ doc, paragraphPos, noteReferences }) => {
1550
- const $place = doc.resolve(paragraphPos);
1551
- let position = paragraphPos;
1552
- for (let index = $place.index() - 1; index >= 0; index--) {
1553
- const previous = $place.parent.child(index);
1554
- position -= previous.nodeSize;
1555
- if (previous.type.name !== "paragraph" || !isDeletedPPrMark(previous.attrs["pPrMark"])) return false;
1556
- if (keepsWords({
1557
- doc,
1558
- paragraphPos: position,
1559
- noteReferences
1560
- })) return true;
1561
- }
1562
- return false;
1563
- };
1564
- /**
1565
- * Whether a pending join runs earlier words on to `paragraphPos`, right before
1566
- * a table. A paragraph put there cannot stand apart once accepted: keeping its
1567
- * own break, it takes the words, and taking the deleted break from them, it
1568
- * runs into the table's first cell. Where that cell is itself pending nothing
1569
- * runs into it, so a paragraph right after the words can take their break and
1570
- * stand; so can one with a paragraph going whole between it and the table.
1571
- */
1572
- const joinStopsAtTableAfter = (options) => {
1573
- if (!joinRunsWordsInto(options)) return false;
1574
- const $place = options.doc.resolve(options.paragraphPos);
1575
- for (let index = $place.index(); index < $place.parent.childCount; index++) {
1576
- const next = $place.parent.child(index);
1577
- if (next.type.name === "paragraph") return false;
1578
- if (next.type.spec["tableRole"] === "table") {
1579
- const before = $place.nodeBefore;
1580
- return !runInCellPending(next) || before !== null && holdsOnlyDeletedContent(before);
1581
- }
1582
- }
1583
- return false;
1584
- };
1585
- /**
1586
- * Where a block goes before and after the paragraph at `paragraphPos`, read
1587
- * as the joined paragraph a pending join makes of it. A join runs the words
1588
- * of each paragraph whose break is pending removal into the paragraph it
1589
- * leaves, so a block put between them would take those words once accepted,
1590
- * as the same edits applied directly never do. Where a paragraph runs into
1591
- * one the join leaves that keeps words of its own, a block after any
1592
- * paragraph of the join goes after the paragraph it leaves, and a block
1593
- * before that one goes before the first paragraph the join takes in, empty
1594
- * ones included. A join into a paragraph with no words left (an emptied
1595
- * final carrier, or one going whole) runs nothing together, nor does a
1596
- * paragraph going whole with no join running through it: blocks keep their
1597
- * places.
1598
- */
1599
- const pendingJoinBounds = (options) => {
1600
- const { doc, paragraphPos, noteReferences } = options;
1601
- const paragraph = doc.nodeAt(paragraphPos);
1602
- let after = paragraphPos;
1603
- if (paragraph?.type.name === "paragraph" && isDeletedPPrMark(paragraph.attrs["pPrMark"]) && (joinsIn(options) || joinRunsWordsInto(options))) {
1604
- const survivor = paragraphLeftAfter({
1605
- doc,
1606
- paragraphPos
1607
- });
1608
- if (survivor !== null && keepsWords({
1609
- doc,
1610
- paragraphPos: survivor,
1611
- noteReferences
1612
- })) after = survivor;
1613
- }
1614
- let before = paragraphPos;
1615
- if (paragraph?.type.name === "paragraph" && keepsWords(options)) {
1616
- let start = paragraphPos;
1617
- for (;;) {
1618
- const previous = doc.resolve(start).nodeBefore;
1619
- if (previous?.type !== paragraph.type || !isDeletedPPrMark(previous.attrs["pPrMark"])) break;
1620
- start -= previous.nodeSize;
1621
- if (joinsIn({
1622
- doc,
1623
- paragraphPos: start,
1624
- noteReferences
1625
- })) before = start;
1626
- }
1627
- }
1628
- return {
1629
- before,
1630
- after: endOfParagraphWithItsTextBoxes(doc, after)
1631
- };
1632
- };
1633
1449
  /** Where a block insertion lands as it runs (see `joinSide`). */
1634
1450
  const insertionAt = ({ item, tr, noteReferences }) => {
1635
1451
  if (item.joinSide === void 0) return item.from;
1636
1452
  const position = sinceRead(tr, item).map(item.blockFrom, 1);
1637
1453
  if (tr.doc.nodeAt(position)?.type.name !== "paragraph") return item.from;
1638
- return pendingJoinBounds({
1454
+ const bounds = pendingJoinBounds({
1639
1455
  doc: tr.doc,
1640
1456
  paragraphPos: position,
1641
1457
  noteReferences
1642
- })[item.joinSide];
1458
+ });
1459
+ return insertionGap(tr.doc, bounds[item.joinSide], item.joinSide);
1643
1460
  };
1644
1461
  /**
1645
1462
  * Where a block insertion lands as it runs, with the comments running across
@@ -1682,48 +1499,7 @@ const insertBlocksInsideComments = ({ tr, at, blocks, carriedComments }) => {
1682
1499
  for (const comment of spanning) next = next.addMark(at, at + fragment.size, comment);
1683
1500
  return next;
1684
1501
  };
1685
- /** A paragraph mark that is a pending insertion (not a relocation's end). */
1686
- const isInsertedPPrMark = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "ins";
1687
1502
  const isSuggestedParagraphInsert = (paragraph) => typeof paragraph.attrs["_suggestedInsert"] === "object" && paragraph.attrs["_suggestedInsert"] !== null;
1688
- /** A paragraph mark that is a pending deletion, or a relocation's source. */
1689
- const isDeletedPPrMark = (value) => typeof value === "object" && value !== null && "kind" in value && (value.kind === "del" || value.kind === "moveFrom");
1690
- const pendingJoinInsertionRefusal = {
1691
- reason: "pendingParagraphMarkDeletion",
1692
- message: "Accepting the pending paragraph mark deletion before this place would run the paragraph together with the words before it or the table after it. Resolve that change first, or insert elsewhere."
1693
- };
1694
- const pendingParagraphMarkPropertyRefusal = {
1695
- reason: "pendingParagraphMarkDeletion",
1696
- canonicalRefusal: { gap: CANONICAL_GAP.publicPendingParagraphMarkProperties },
1697
- message: "Resolve the pending paragraph mark deletion before editing its properties, or provide mergedParagraphProperties on the merge operation for atomic intent."
1698
- };
1699
- const hasRevisionMarker = (value) => typeof value === "object" && value !== null && "revisionId" in value;
1700
- const isDeletedCell = (cell) => {
1701
- const marker = cell.attrs["cellMarker"];
1702
- return typeof marker === "object" && marker !== null && "kind" in marker && marker.kind === "del";
1703
- };
1704
- /**
1705
- * Whether accepting every change removes the paragraph at `blockFrom` whole:
1706
- * its paragraph mark and all of its text pending deletion (`cleanText`, the
1707
- * accepted reading, is empty), or the table row or cell holding it pending
1708
- * deletion. A reader lists such a paragraph as a blank block.
1709
- *
1710
- * Word keeps a paragraph whose mark is deleted joined to the next one: text
1711
- * typed into it stays inserted there, and accepting runs it into the next
1712
- * paragraph (or, in a deleted row, takes it away with the row). An operation
1713
- * that asks for the paragraph to read something cannot get that without
1714
- * rejecting the deletion, which is the reviewer's call, not a side effect.
1715
- */
1716
- const isPendingDeletion = (doc, blockFrom, paragraph, cleanText) => {
1717
- if (cleanText.length === 0 && isDeletedPPrMark(paragraph.attrs["pPrMark"])) return true;
1718
- const $block = doc.resolve(blockFrom);
1719
- for (let depth = $block.depth; depth > 0; depth -= 1) {
1720
- const ancestor = $block.node(depth);
1721
- const name = ancestor.type.name;
1722
- if (name === "tableRow" && hasRevisionMarker(ancestor.attrs["trDel"])) return true;
1723
- if ((name === "tableCell" || name === "tableHeader") && isDeletedCell(ancestor)) return true;
1724
- }
1725
- return false;
1726
- };
1727
1503
  /** Whether every piece of the paragraph's content is pending inserted text. */
1728
1504
  const holdsOnlyInsertedContent = (paragraph, revisions) => {
1729
1505
  let whollyInserted = true;
@@ -1746,15 +1522,7 @@ const holdsOnlyContentInsertedBy = (paragraph, revisionIds) => {
1746
1522
  });
1747
1523
  return whollyInserted;
1748
1524
  };
1749
- /**
1750
- * Remove the paragraph between `from` and `to`, its content with it but not
1751
- * the range boundaries it holds: those stay where it was, as rejecting a
1752
- * pending paragraph or accepting a deleted one leaves them. With a paragraph
1753
- * after it they open that paragraph, where the joined break leaves them,
1754
- * with any standing between the two; before a table they stand between
1755
- * blocks; ending its container, they close the paragraph before it.
1756
- */
1757
- const removeParagraph = (tr, from, to) => {
1525
+ const removeParagraph = ({ tr, from, to, kind }) => {
1758
1526
  const paragraph = tr.doc.nodeAt(from);
1759
1527
  const kept = paragraph === null ? [] : removeResolvedSubtree(paragraph, {
1760
1528
  mode: "reject",
@@ -1777,6 +1545,7 @@ const removeParagraph = (tr, from, to) => {
1777
1545
  return tr.insert(opening + 1, [...kept, ...joined]).delete(from, opening);
1778
1546
  }
1779
1547
  if (following !== null) {
1548
+ if (kind === "retract-pending") return at.nodeBefore?.type.name === "paragraph" ? tr.delete(from, to).insert(from - 1, kept) : tr.replaceWith(from + 1, to - 1, kept).setNodeAttribute(from, "pPrMark", null);
1780
1549
  const comments = kept.filter(carriesCommentAnchor);
1781
1550
  const between = blockBoundariesOf(kept.filter((node) => !carriesCommentAnchor(node)));
1782
1551
  if (comments.length === 0) return tr.replaceWith(from, to, between);
@@ -1840,16 +1609,6 @@ const addedOrDeletedBreakRevisionId = (value) => {
1840
1609
  return typeof info.id === "number" ? info.id : null;
1841
1610
  };
1842
1611
  /** Whether every piece of the paragraph's content is pending deleted text (or it has none). */
1843
- const holdsOnlyDeletedContent = (paragraph) => {
1844
- let whollyDeleted = true;
1845
- paragraph.descendants((node) => {
1846
- if (!whollyDeleted) return false;
1847
- if (!node.isInline || isZeroWidthAnchor(node)) return true;
1848
- whollyDeleted = node.marks.some((mark) => mark.type.name === "deletion");
1849
- return false;
1850
- });
1851
- return whollyDeleted;
1852
- };
1853
1612
  /**
1854
1613
  * Where the paragraph at `position` runs on into the next paragraph when its
1855
1614
  * added break is retracted, across the tables between them: the next
@@ -1904,22 +1663,6 @@ const moveParagraphPastTables = (tr, from, before) => {
1904
1663
  tr.delete(from, from + paragraph.nodeSize).insert(target, paragraph);
1905
1664
  return target;
1906
1665
  };
1907
- /**
1908
- * Whether everything after `position` in its container is paragraphs pending
1909
- * deletion: a join there, once accepted, has no words after it.
1910
- */
1911
- const followedOnlyByDeletedParagraphs = (doc, position) => {
1912
- const at = doc.resolve(position);
1913
- let deletes = false;
1914
- for (let index = at.index(); index < at.parent.childCount; index++) {
1915
- const node = at.parent.child(index);
1916
- if (node.type.name !== "paragraph" || !holdsOnlyDeletedContent(node)) return false;
1917
- deletes ||= node.content.size > 0 || isPlainDeletedPPrMark(node.attrs["pPrMark"]);
1918
- }
1919
- return deletes;
1920
- };
1921
- /** A paragraph mark that is a plain pending deletion (not a relocation's source). */
1922
- const isPlainDeletedPPrMark = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "del";
1923
1666
  /** An emptied paragraph still carries deleted content, rather than being an original blank. */
1924
1667
  const hasDeletedContent = (paragraph) => {
1925
1668
  let found = false;
@@ -2035,13 +1778,12 @@ const finalParagraphPredecessor = (doc, at) => {
2035
1778
  return null;
2036
1779
  };
2037
1780
  /**
2038
- * The paragraph whose break a recorded final deletion retires, if any. A
2039
- * deletion that nothing preceded when it ran keeps its paragraph emptied, as
2040
- * the deletion alone does: a paragraph the batch places before it afterwards
2041
- * (an insertion after a table, a deleted table's predecessor) lands after the
2042
- * deletion and keeps its own break.
1781
+ * The paragraph whose break a recorded final deletion retires, if any, read
1782
+ * from the finished batch: what precedes the emptied paragraph then, whatever
1783
+ * stood there when the deletion ran. A paragraph the batch places before it
1784
+ * gives up its break; a table it places there leaves the paragraph emptied.
2043
1785
  */
2044
- const retiredFinalBreak = (doc, at, deletion) => deletion.precededWhenDeleted ? finalParagraphPredecessor(doc, at) : null;
1786
+ const retiredFinalBreak = (doc, at) => finalParagraphPredecessor(doc, at);
2045
1787
  /**
2046
1788
  * The paragraph a direct replay leaves at a container's end when the batch
2047
1789
  * deletes every paragraph back to the container's start or a table.
@@ -2063,7 +1805,7 @@ const collapsedFinalRunSource = (doc, at, batchRevisionIds) => {
2063
1805
  if (emptied?.type.name !== "paragraph") return null;
2064
1806
  const $emptied = doc.resolve(at);
2065
1807
  if (!paragraphEndsItsContainer($emptied, emptied.type.name)) return null;
2066
- let source = null;
1808
+ const before = [];
2067
1809
  let position = at;
2068
1810
  for (let index = $emptied.index() - 1; index >= 0; index--) {
2069
1811
  const node = $emptied.parent.child(index);
@@ -2075,29 +1817,84 @@ const collapsedFinalRunSource = (doc, at, batchRevisionIds) => {
2075
1817
  deletedEarlier &&= trDel != null && !batchRevisionIds.has(trDel.revisionId);
2076
1818
  });
2077
1819
  if (deletedEarlier) continue;
2078
- return source;
1820
+ break;
2079
1821
  }
2080
- if (node.type !== emptied.type) return source;
1822
+ if (node.type !== emptied.type) break;
2081
1823
  const mark = node.attrs["pPrMark"];
2082
- if (!isPlainDeletedPPrMark(mark) || !holdsOnlyDeletedContent(node)) return null;
1824
+ if (!isPlainDeletedPPrMark(mark) || !holdsOnlyDeletedContent(node)) {
1825
+ before.push({
1826
+ paragraph: {
1827
+ node,
1828
+ position
1829
+ },
1830
+ deleted: false
1831
+ });
1832
+ break;
1833
+ }
2083
1834
  const revisionId = addedOrDeletedBreakRevisionId(mark);
2084
- if (revisionId !== null && batchRevisionIds.has(revisionId)) source = {
2085
- node,
2086
- position
2087
- };
1835
+ if (revisionId !== null && batchRevisionIds.has(revisionId)) before.push({
1836
+ paragraph: {
1837
+ node,
1838
+ position
1839
+ },
1840
+ deleted: true
1841
+ });
2088
1842
  }
2089
- return source;
1843
+ const carrier = finalBreakCarrier(before);
1844
+ return carrier.type === "runStart" ? carrier.paragraph : null;
2090
1845
  };
1846
+ /**
1847
+ * Whether a final deletion can retract the inserted break between
1848
+ * `predecessor` and the paragraph it joins. A paragraph holds one pending
1849
+ * property change, so a predecessor with its own must agree with the target
1850
+ * on what rejecting gives back, or already read as the target did. Which
1851
+ * change the batch put on the predecessor before the retirement runs (a
1852
+ * merge into it, a property write, a restyle) does not decide it: one at a
1853
+ * time the retraction runs first, while the predecessor reads as before.
1854
+ */
2091
1855
  const canRetractFinalBreak = ({ predecessor, target }) => {
2092
1856
  if (target.type !== predecessor.type) return false;
2093
- return !(JSON.stringify(paragraphPropertiesBeforePendingChanges(target)) !== JSON.stringify(paragraphPropertiesSnapshot(predecessor)) && hasSerializableParagraphPropertyChange(expectParagraphAttrs(predecessor)._propertyChanges));
1857
+ const targetBefore = paragraphPropertiesBeforePendingChanges(target);
1858
+ return !(!sameParagraphProperties(targetBefore, paragraphPropertiesSnapshot(predecessor)) && !sameParagraphProperties(targetBefore, paragraphPropertiesBeforePendingChanges(predecessor)) && hasSerializableParagraphPropertyChange(expectParagraphAttrs(predecessor)._propertyChanges));
1859
+ };
1860
+ /** The successor that can take a retractable final break. */
1861
+ const finalBreakRetractionTarget = (doc, predecessor) => {
1862
+ const position = retractedBreakTargetPosition(doc, predecessor);
1863
+ const target = doc.nodeAt(position);
1864
+ return target && canRetractFinalBreak({
1865
+ predecessor: predecessor.node,
1866
+ target
1867
+ }) ? {
1868
+ position,
1869
+ target
1870
+ } : null;
1871
+ };
1872
+ const retractsForeignFinalBreak = ({ doc, position, author }) => {
1873
+ const predecessor = finalParagraphPredecessor(doc, position);
1874
+ if (!predecessor) return false;
1875
+ return isForeignAddedBreak(predecessor.node, author) && (pendingParagraphRetraction(doc, position)?.clearBreakAt === predecessor.position || finalBreakRetractionTarget(doc, predecessor) !== null);
1876
+ };
1877
+ /** Whether `paragraph`'s break or any of its words is another author's pending insertion. */
1878
+ const holdsForeignInsertion = (paragraph, author) => {
1879
+ if (isForeignAddedBreak(paragraph, author)) return true;
1880
+ let foreign = false;
1881
+ paragraph.descendants((node) => {
1882
+ if (foreign) return false;
1883
+ foreign = node.marks.some((mark) => mark.type.name === "insertion" && mark.attrs["author"] !== author);
1884
+ return !foreign;
1885
+ });
1886
+ return foreign;
1887
+ };
1888
+ const isForeignAddedBreak = (node, author) => {
1889
+ const mark = expectParagraphAttrs(node).pPrMark;
1890
+ return (mark?.kind === "ins" || mark?.kind === "moveTo") && mark.info.author !== author;
2094
1891
  };
2095
1892
  /** Pending retirements, read after the merge has mapped any inserted separator. */
2096
1893
  const pendingRemovedFinalBreakPositions = (tr, deletions) => {
2097
1894
  const positions = /* @__PURE__ */ new Set();
2098
1895
  for (const deletion of deletions) {
2099
1896
  const at = tr.mapping.slice(deletion.mappedFrom).map(deletion.position);
2100
- const predecessor = retiredFinalBreak(tr.doc, at, deletion);
1897
+ const predecessor = retiredFinalBreak(tr.doc, at);
2101
1898
  if (!predecessor || predecessor.node.attrs["pPrMark"] != null) continue;
2102
1899
  positions.add(predecessor.position);
2103
1900
  }
@@ -2122,7 +1919,7 @@ const hasDeferredParagraphPropertyWrite = ({ tr, deletions, targets, mergedPrope
2122
1919
  const at = tr.mapping.slice(deletion.mappedFrom).map(deletion.position);
2123
1920
  const target = tr.doc.nodeAt(at);
2124
1921
  if (!target) continue;
2125
- const predecessor = retiredFinalBreak(tr.doc, at, deletion);
1922
+ const predecessor = retiredFinalBreak(tr.doc, at);
2126
1923
  if (!predecessor) continue;
2127
1924
  const mark = predecessor.node.attrs["pPrMark"];
2128
1925
  if (mark == null && mergedPropertyTargets.some(({ position, mappedFrom }) => {
@@ -2156,7 +1953,7 @@ const paragraphPropertyRevisionTargets = ({ item, tr, deletedFinalParagraphs })
2156
1953
  const removedBreakPositions = pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs);
2157
1954
  for (const deletion of deletedFinalParagraphs) {
2158
1955
  const at = tr.mapping.slice(deletion.mappedFrom).map(deletion.position);
2159
- const predecessor = retiredFinalBreak(tr.doc, at, deletion);
1956
+ const predecessor = retiredFinalBreak(tr.doc, at);
2160
1957
  if (!predecessor || addedBreakRevisionId(predecessor.node.attrs["pPrMark"]) === null) continue;
2161
1958
  const target = tr.doc.nodeAt(retractedBreakTargetPosition(tr.doc, predecessor));
2162
1959
  if (!target) continue;
@@ -2165,15 +1962,207 @@ const paragraphPropertyRevisionTargets = ({ item, tr, deletedFinalParagraphs })
2165
1962
  target
2166
1963
  })) removedBreakPositions.add(predecessor.position);
2167
1964
  }
2168
- const survivorPosition = paragraphLeftAfter({
1965
+ const survivorPosition = paragraphMergeLeaves({
2169
1966
  doc: tr.doc,
2170
1967
  paragraphPos: position,
2171
1968
  removedBreakPositions
2172
1969
  });
2173
- const survivor = survivorPosition === null ? null : tr.doc.nodeAt(survivorPosition);
1970
+ const survivor = survivorPosition === null || survivorPosition === position ? null : tr.doc.nodeAt(survivorPosition);
2174
1971
  if (survivor?.type.name === "paragraph") targets.push(survivor);
2175
1972
  return targets;
2176
1973
  };
1974
+ const IDENTITY_ATTRS = ["paraId", "textId"];
1975
+ const withIdentityOf = ({ tr, position, source }) => {
1976
+ if (tr.doc.nodeAt(position)?.type !== source.type) panic("A deferred direct join no longer targets its paragraph type.");
1977
+ let next = tr;
1978
+ for (const name of IDENTITY_ATTRS) if (next.doc.nodeAt(position)?.attrs[name] !== source.attrs[name]) next = next.setNodeAttribute(position, name, source.attrs[name] ?? null);
1979
+ return next;
1980
+ };
1981
+ /** The paragraphs a direct join of `retired` into `survivor` reports, by id. */
1982
+ const paragraphIdentityOf = (retired, survivor) => {
1983
+ const retiredBlockId = retired.attrs["paraId"];
1984
+ const blockId = survivor.attrs["paraId"];
1985
+ if (typeof blockId !== "string") return void 0;
1986
+ if (typeof retiredBlockId !== "string" || retiredBlockId === blockId) return {
1987
+ type: "retained",
1988
+ blockId
1989
+ };
1990
+ return {
1991
+ type: "joined",
1992
+ blockId,
1993
+ retiredBlockId
1994
+ };
1995
+ };
1996
+ /**
1997
+ * Whether a paragraph stands right before `at`, so that a container-ending
1998
+ * paragraph deleted directly there can go: that one ends the container.
1999
+ */
2000
+ const precededByParagraph = (at, paragraphTypeName) => at.nodeBefore?.type.name === paragraphTypeName;
2001
+ const withSettledDirectFinalDeletions = (tr, deletions) => {
2002
+ const edits = [];
2003
+ /** Per container end, the paragraph to end it with again: the last one removed. */
2004
+ const restored = /* @__PURE__ */ new Map();
2005
+ for (const deletion of deletions) {
2006
+ const mapped = tr.mapping.slice(deletion.mappedFrom).mapResult(deletion.position, 1);
2007
+ if (mapped.deleted) continue;
2008
+ const at = mapped.pos;
2009
+ if (deletion.kind === "emptied") {
2010
+ edits.push({
2011
+ kind: "emptied",
2012
+ at
2013
+ });
2014
+ continue;
2015
+ }
2016
+ const $end = tr.doc.resolve(at);
2017
+ if (containerEndsAt($end, deletion.paragraph.type.name) && $end.nodeBefore?.type.spec["tableRole"] === "table") {
2018
+ const deletionIds = restored.get(at)?.deletionIds ?? [];
2019
+ deletionIds.push(deletion.operationId);
2020
+ restored.set(at, {
2021
+ paragraph: deletion.paragraph,
2022
+ identity: deletion.identity,
2023
+ deletionIds
2024
+ });
2025
+ }
2026
+ }
2027
+ for (const [at, { paragraph, identity }] of restored) edits.push({
2028
+ kind: "restored",
2029
+ at,
2030
+ paragraph,
2031
+ identity
2032
+ });
2033
+ for (const edit of edits.toSorted((left, right) => right.at - left.at)) {
2034
+ if (edit.kind === "restored") {
2035
+ const { paragraph } = edit;
2036
+ tr.insert(edit.at, paragraph.type.create(paragraph.attrs, null, paragraph.marks));
2037
+ tr = withIdentityOf({
2038
+ tr,
2039
+ position: edit.at,
2040
+ source: edit.identity
2041
+ });
2042
+ continue;
2043
+ }
2044
+ const node = tr.doc.nodeAt(edit.at);
2045
+ if (node?.type.name !== "paragraph" || node.content.size > 0) continue;
2046
+ const $at = tr.doc.resolve(edit.at);
2047
+ if (!paragraphEndsItsContainer($at, node.type.name) || !precededByParagraph($at, node.type.name)) continue;
2048
+ tr.delete(edit.at, edit.at + node.nodeSize);
2049
+ }
2050
+ const identities = /* @__PURE__ */ new Map();
2051
+ for (const { deletionIds, identity } of restored.values()) for (const id of deletionIds) identities.set(id, identity);
2052
+ return identities;
2053
+ };
2054
+ /** Every pending join in `doc`, with where accepting every change ends it. */
2055
+ const pendingJoinsOf = (doc) => {
2056
+ const joins = [];
2057
+ doc.descendants((node, position) => {
2058
+ if (node.type.name !== "paragraph") return !node.isTextblock;
2059
+ const end = pendingJoinEnd(doc, position);
2060
+ if (end !== null) joins.push({
2061
+ source: position,
2062
+ end
2063
+ });
2064
+ return false;
2065
+ });
2066
+ return joins;
2067
+ };
2068
+ /**
2069
+ * Keep each pending join ending where it did before the batch, when the batch
2070
+ * removed what ended it. An edit reads the document as accepting leaves it,
2071
+ * where the joined words are one paragraph with the break the join ended at;
2072
+ * removing a block beside that paragraph leaves it standing, as it does when
2073
+ * the edit is applied directly.
2074
+ *
2075
+ * - The paragraph a join runs into is part of the joined paragraph, and its
2076
+ * break is the joined paragraph's break. Deleting the paragraph deletes its
2077
+ * words; its break stays, or the joined words would run on into the block
2078
+ * after it. Where the batch also deletes the words joined into it, nothing
2079
+ * of the join is left and the break goes with them. The deletion keeps the
2080
+ * break as it runs (`endsPendingJoinAt`) and the batch settles it once it
2081
+ * has finished (`withKeptJoinBreaksSettled`).
2082
+ * - A table that stays stops a join run past paragraphs accepting removes,
2083
+ * and the joined words keep their own paragraph (`joinEndsBeforeTable`).
2084
+ * Removing that table keeps them there: the break of the paragraph they
2085
+ * stand in stays, which is what accepting already did. This runs here.
2086
+ *
2087
+ * Neither changes what rejecting gives back. A break a merge deletes is a
2088
+ * join asked for, and goes.
2089
+ */
2090
+ const withJoinsEndingWhereTheyDid = ({ tr, joins }) => {
2091
+ for (const join of joins) {
2092
+ const source = tr.mapping.mapResult(join.source, 1);
2093
+ const end = tr.mapping.mapResult(join.end.position, 1);
2094
+ const paragraph = tr.doc.nodeAt(source.pos);
2095
+ if (source.deleted || paragraph?.type.name !== "paragraph" || !isPlainDeletedPPrMark(paragraph.attrs["pPrMark"]) || paragraphGoes(paragraph, "accept")) continue;
2096
+ if (join.end.kind === "paragraph") continue;
2097
+ const table = end.deleted ? null : tr.doc.nodeAt(end.pos);
2098
+ const tableRemoved = table === null || table.type.spec["tableRole"] === "table" && tableGoes(table, "accept");
2099
+ const stillStopped = pendingJoinEnd(tr.doc, source.pos)?.kind === "table";
2100
+ if (tableRemoved && !stillStopped) tr.setNodeAttribute(source.pos, "pPrMark", null);
2101
+ }
2102
+ };
2103
+ /**
2104
+ * Whether the paragraph at `position` is where a pending join from before the
2105
+ * batch ends, with the joined words still in its source: its break is the
2106
+ * joined paragraph's, which a deletion of the paragraph keeps.
2107
+ */
2108
+ const endsPendingJoinAt = (tr, joins, position) => joins.some((join) => {
2109
+ if (join.end.kind !== "paragraph") return false;
2110
+ const source = tr.mapping.mapResult(join.source, 1);
2111
+ if (source.deleted) return false;
2112
+ const end = pendingJoinEnd(tr.doc, source.pos);
2113
+ return end?.kind === "paragraph" && end.position === position;
2114
+ });
2115
+ /**
2116
+ * Where the pending join from before the batch whose source is the paragraph
2117
+ * at `position` ends, when it ends at a paragraph: null otherwise.
2118
+ */
2119
+ const pendingJoinEndOfSource = (tr, joins, position) => {
2120
+ for (const join of joins) {
2121
+ if (join.end.kind !== "paragraph") continue;
2122
+ const source = tr.mapping.mapResult(join.source, 1);
2123
+ if (source.deleted || source.pos !== position) continue;
2124
+ const end = tr.mapping.mapResult(join.end.position, 1);
2125
+ return end.deleted ? null : end.pos;
2126
+ }
2127
+ return null;
2128
+ };
2129
+ /**
2130
+ * Settle the breaks tracked deletions kept as a pending join's end, once the
2131
+ * batch has finished. The deletion keeps the break as it runs, so every
2132
+ * operation after it in the batch reads the joined paragraph where it stands,
2133
+ * as it does when the deletion is applied on its own. Where the batch also
2134
+ * deleted the words joined into it, nothing of the join is left, and the
2135
+ * break goes with the paragraph after all. A deletion of those words records
2136
+ * the join's end here too, so the break goes as well when an earlier batch
2137
+ * deleted the paragraph and kept it: one batch or two, the same is left.
2138
+ */
2139
+ const withKeptJoinBreaksSettled = ({ tr, kept, appliedIds, revisionSeed, author, date }) => {
2140
+ const addedRevisions = [];
2141
+ const located = kept.filter(({ operationId }) => appliedIds.has(operationId));
2142
+ if (located.length === 0) return addedRevisions;
2143
+ const joinEnds = new Set(pendingJoinsOf(tr.doc).flatMap(({ end }) => end.kind === "paragraph" ? [end.position] : []));
2144
+ let nextRevisionId = revisionSeed;
2145
+ for (const { operationId, position, mappedFrom, revisionExtras } of located) {
2146
+ const mapped = tr.mapping.slice(mappedFrom).mapResult(position, 1);
2147
+ const paragraph = mapped.deleted ? null : tr.doc.nodeAt(mapped.pos);
2148
+ if (paragraph?.type.name !== "paragraph" || paragraph.attrs["pPrMark"] != null || joinEnds.has(mapped.pos) || !holdsOnlyDeletedContent(paragraph) || paragraphEndsItsContainer(tr.doc.resolve(mapped.pos), paragraph.type.name)) continue;
2149
+ const revisionId = nextRevisionId++;
2150
+ tr.setNodeAttribute(mapped.pos, "pPrMark", {
2151
+ kind: "del",
2152
+ info: {
2153
+ id: revisionId,
2154
+ author,
2155
+ date,
2156
+ ...revisionExtras
2157
+ }
2158
+ });
2159
+ addedRevisions.push({
2160
+ operationId,
2161
+ revisionId
2162
+ });
2163
+ }
2164
+ return addedRevisions;
2165
+ };
2177
2166
  /**
2178
2167
  * Finish the tracked deletion of every paragraph a container ends with.
2179
2168
  *
@@ -2197,7 +2186,7 @@ const paragraphPropertyRevisionTargets = ({ item, tr, deletedFinalParagraphs })
2197
2186
  * emptied one is settled only then, since the batch runs backwards and an
2198
2187
  * insertion or deletion before it lands after it.
2199
2188
  */
2200
- const withRetiredFinalParagraphs = ({ tr, deletions, mergedPropertyTargets, appliedIds, batchRevisionIds, revisionSeed, author, date, styleResolver, numbering }) => {
2189
+ const withRetiredFinalParagraphs = ({ tr, deletions, mergedPropertyTargets, appliedIds, batchRevisionIds, revisionSeed, author, refuseCrossAuthorRevisions, date, styleResolver, numbering }) => {
2201
2190
  let nextRevisionId = revisionSeed;
2202
2191
  const addedRevisions = [];
2203
2192
  const retractedRevisionIds = [];
@@ -2210,9 +2199,9 @@ const withRetiredFinalParagraphs = ({ tr, deletions, mergedPropertyTargets, appl
2210
2199
  const { operationId, revisionExtras } = deletion;
2211
2200
  const emptied = tr.doc.nodeAt(at);
2212
2201
  if (emptied?.type.name !== "paragraph") continue;
2213
- const predecessor = retiredFinalBreak(tr.doc, at, deletion);
2202
+ const predecessor = retiredFinalBreak(tr.doc, at);
2214
2203
  if (!predecessor) {
2215
- const source = deletion.precededWhenDeleted ? collapsedFinalRunSource(tr.doc, at, batchRevisionIds) : null;
2204
+ const source = collapsedFinalRunSource(tr.doc, at, batchRevisionIds);
2216
2205
  if (!source) continue;
2217
2206
  const revisionId = nextRevisionId;
2218
2207
  const carried = carryParagraphProperties({
@@ -2241,16 +2230,21 @@ const withRetiredFinalParagraphs = ({ tr, deletions, mergedPropertyTargets, appl
2241
2230
  const { node: previous } = predecessor;
2242
2231
  let { position } = predecessor;
2243
2232
  const mark = previous.attrs["pPrMark"];
2244
- if (mark == null) {
2233
+ const foreignBreak = !refuseCrossAuthorRevisions && isForeignAddedBreak(previous, author) && expectParagraphAttrs(previous).pPrMark?.deletion === void 0 ? expectParagraphAttrs(previous).pPrMark : void 0;
2234
+ if (mark == null || foreignBreak) {
2245
2235
  const revisionId = nextRevisionId++;
2246
- tr.setNodeAttribute(position, "pPrMark", {
2236
+ const info = {
2237
+ id: revisionId,
2238
+ author,
2239
+ date,
2240
+ ...revisionExtras
2241
+ };
2242
+ tr.setNodeAttribute(position, "pPrMark", foreignBreak ? {
2243
+ ...foreignBreak,
2244
+ deletion: { info }
2245
+ } : {
2247
2246
  kind: "del",
2248
- info: {
2249
- id: revisionId,
2250
- author,
2251
- date,
2252
- ...revisionExtras
2253
- }
2247
+ info
2254
2248
  });
2255
2249
  if (!mergedPropertyTargets.some(({ position: target, mappedFrom }) => {
2256
2250
  const mapped = tr.mapping.slice(mappedFrom).mapResult(target);
@@ -2282,13 +2276,21 @@ const withRetiredFinalParagraphs = ({ tr, deletions, mergedPropertyTargets, appl
2282
2276
  });
2283
2277
  continue;
2284
2278
  }
2285
- if (addedBreakRevisionId(mark) !== null) {
2286
- const targetPosition = retractedBreakTargetPosition(tr.doc, predecessor);
2287
- const following = tr.doc.nodeAt(targetPosition);
2288
- if (!following || !canRetractFinalBreak({
2289
- predecessor: previous,
2290
- target: following
2291
- })) continue;
2279
+ const takenForeignBreak = isForeignAddedBreak(previous, author) && expectParagraphAttrs(previous).pPrMark?.deletion !== void 0;
2280
+ if (refuseCrossAuthorRevisions && takenForeignBreak) return {
2281
+ type: "blocked",
2282
+ operationId,
2283
+ nextRevisionId
2284
+ };
2285
+ if (addedBreakRevisionId(mark) !== null && !takenForeignBreak) {
2286
+ const retraction = finalBreakRetractionTarget(tr.doc, predecessor);
2287
+ if (retraction === null) continue;
2288
+ if (refuseCrossAuthorRevisions && isForeignAddedBreak(previous, author)) return {
2289
+ type: "blocked",
2290
+ operationId,
2291
+ nextRevisionId
2292
+ };
2293
+ const { position: targetPosition, target: following } = retraction;
2292
2294
  if (targetPosition !== position + previous.nodeSize) position = moveParagraphPastTables(tr, position, targetPosition);
2293
2295
  joinAtParagraphMark({
2294
2296
  tr,
@@ -2328,6 +2330,7 @@ const withRetiredFinalParagraphs = ({ tr, deletions, mergedPropertyTargets, appl
2328
2330
  }
2329
2331
  }
2330
2332
  return {
2333
+ type: "resolved",
2331
2334
  nextRevisionId,
2332
2335
  resolvedOperationIds,
2333
2336
  addedRevisions,
@@ -2352,10 +2355,14 @@ const withRetiredFinalParagraphs = ({ tr, deletions, mergedPropertyTargets, appl
2352
2355
  * the free one records the other's as `w:pPrChange` — what a rejection reads
2353
2356
  * to put the container's ending back the way it was.
2354
2357
  *
2355
- * This runs once over the finished document rather than at each insertion:
2356
- * which paragraph ends a container is only settled when the batch is, and an
2357
- * insertion that looked final was undone by the next operation writing a table
2358
- * after it.
2358
+ * The rotation runs once over the finished document rather than at each
2359
+ * insertion: which paragraph ends a container is only settled when the batch
2360
+ * is, and an insertion that looked final was undone by the next operation
2361
+ * writing a table after it. A deleted break an insertion supersedes is moved
2362
+ * first (`withSupersededDeletedBreaksMoved`); that move is settled as soon as
2363
+ * the insertion lands, and the batch makes it then too, so what later
2364
+ * operations of the batch read beside the insertion is what they read after
2365
+ * it alone.
2359
2366
  * A wholly inserted table from this batch can be crossed to reach the carrier;
2360
2367
  * its removal on reject exposes that same paragraph boundary again.
2361
2368
  *
@@ -2366,7 +2373,48 @@ const withRetiredFinalParagraphs = ({ tr, deletions, mergedPropertyTargets, appl
2366
2373
  * paragraph's words run into the one after it, which ends with the free mark,
2367
2374
  * and neither break is left to resolve.
2368
2375
  */
2369
- const withRotatedAddedFinalBreaks = ({ tr, batchRevisionIds, revisionSeed, author, date, initials, styleResolver, numbering }) => {
2376
+ const withRotatedAddedFinalBreaks = (options) => {
2377
+ const { tr, batchRevisionIds, author, date, initials } = options;
2378
+ const moved = withSupersededDeletedBreaksMoved(options);
2379
+ const nextRevisionId = moved.nextRevisionId;
2380
+ const synthesizedRevisions = [...moved.synthesizedRevisions];
2381
+ const paragraphTypeName = tr.doc.type.schema.nodes["paragraph"]?.name ?? "paragraph";
2382
+ const rotations = finalParagraphsOf(tr.doc, paragraphTypeName).flatMap(({ node, position }) => {
2383
+ const mark = node.attrs["pPrMark"];
2384
+ const revisionId = addedBreakRevisionId(mark);
2385
+ return revisionId !== null && batchRevisionIds.has(revisionId) ? [{
2386
+ mark,
2387
+ node,
2388
+ ownerRevisionId: revisionId,
2389
+ position
2390
+ }] : [];
2391
+ }).toSorted((left, right) => right.position - left.position);
2392
+ return withFinalBreaksRotated({
2393
+ tr,
2394
+ rotations,
2395
+ batchRevisionIds,
2396
+ author,
2397
+ date,
2398
+ initials,
2399
+ styleResolver: options.styleResolver,
2400
+ nextRevisionId,
2401
+ synthesizedRevisions
2402
+ });
2403
+ };
2404
+ /**
2405
+ * A later insertion may land between a deleted break and the paragraph it
2406
+ * would join into. Move the old deletion to the new boundary so resolving
2407
+ * either revision keeps the inserted paragraph separate.
2408
+ *
2409
+ * Unlike the rotation of a container's final break, this needs nothing the
2410
+ * rest of the batch settles: a paragraph inserted right after one whose
2411
+ * break a pending change deletes stands there whatever comes later. The
2412
+ * batch therefore moves the deletion as soon as such a paragraph lands, so
2413
+ * every later operation of the batch reads the boundary as it does after
2414
+ * that insertion alone, and once more at the end; the move is idempotent,
2415
+ * and a later insertion right after the moved break carries it on.
2416
+ */
2417
+ const withSupersededDeletedBreaksMoved = ({ tr, batchRevisionIds, revisionSeed, author, date, initials, styleResolver, numbering }) => {
2370
2418
  let nextRevisionId = revisionSeed;
2371
2419
  const synthesizedRevisions = [];
2372
2420
  const supersededDeletedBreaks = [];
@@ -2466,17 +2514,14 @@ const withRotatedAddedFinalBreaks = ({ tr, batchRevisionIds, revisionSeed, autho
2466
2514
  });
2467
2515
  }
2468
2516
  }
2469
- const paragraphTypeName = tr.doc.type.schema.nodes["paragraph"]?.name ?? "paragraph";
2470
- const rotations = finalParagraphsOf(tr.doc, paragraphTypeName).flatMap(({ node, position }) => {
2471
- const mark = node.attrs["pPrMark"];
2472
- const revisionId = addedBreakRevisionId(mark);
2473
- return revisionId !== null && batchRevisionIds.has(revisionId) ? [{
2474
- mark,
2475
- node,
2476
- ownerRevisionId: revisionId,
2477
- position
2478
- }] : [];
2479
- }).toSorted((left, right) => right.position - left.position);
2517
+ return {
2518
+ nextRevisionId,
2519
+ synthesizedRevisions
2520
+ };
2521
+ };
2522
+ /** The rotation of every final break `withRotatedAddedFinalBreaks` found. */
2523
+ const withFinalBreaksRotated = ({ tr, rotations, batchRevisionIds, author, date, initials, styleResolver, nextRevisionId: revisionSeed, synthesizedRevisions }) => {
2524
+ let nextRevisionId = revisionSeed;
2480
2525
  let next = tr;
2481
2526
  const retractedRevisionIds = [];
2482
2527
  for (const { position: finalPosition, node: final, mark: finalMark } of rotations) {
@@ -2519,7 +2564,7 @@ const withRotatedAddedFinalBreaks = ({ tr, batchRevisionIds, revisionSeed, autho
2519
2564
  const cancels = carrier.cancelsDeletedBreak && previous.position === carrier.position;
2520
2565
  if (!cancels) next = next.setNodeAttribute(previous.position, "pPrMark", carriedMark);
2521
2566
  const currentFormatting = paragraphPropertiesSnapshot(current.node);
2522
- if (JSON.stringify(previousFormatting) !== JSON.stringify(currentFormatting)) {
2567
+ if (!sameParagraphProperties(previousFormatting, currentFormatting)) {
2523
2568
  const liveCurrent = next.doc.nodeAt(current.position);
2524
2569
  if (!liveCurrent || liveCurrent.type.name !== final.type.name) panic("A final-mark rotation lost its paragraph", { position: current.position });
2525
2570
  const existing = expectParagraphAttrs(liveCurrent)._propertyChanges;
@@ -2619,6 +2664,7 @@ const buildInsertedParagraphs = ({ item, schema, formattingFromStyle, mode, auth
2619
2664
  const formatsEveryParagraph = operation.formattingScope === "allParagraphs";
2620
2665
  const baseAttrs = operation.inheritFormatting === false ? {} : {
2621
2666
  ...stripBlockIdentityAttrs(item.blockNode.attrs),
2667
+ _sectionProperties: null,
2622
2668
  _preservedAttributes: null,
2623
2669
  _propertyChanges: null,
2624
2670
  pPrMark: null,
@@ -2647,7 +2693,18 @@ const buildInsertedParagraphs = ({ item, schema, formattingFromStyle, mode, auth
2647
2693
  if (commentMark) marks.push(commentMark);
2648
2694
  const hardPageBreak = isFirstParagraph ? operation.hardPageBreak : void 0;
2649
2695
  let content = null;
2650
- if (hardPageBreak !== void 0) {
2696
+ const markdown = item.markdownParagraphs?.at(paragraphIndex);
2697
+ if (markdown !== void 0) content = markdown.content.flatMap((run) => cleanTextInlineNodes({
2698
+ schema,
2699
+ text: markdownRunText(run),
2700
+ marks
2701
+ }).map((node) => node.mark(reconcileRunFormattingMarks({
2702
+ authoredFormatting: run.formatting ?? {},
2703
+ context: OPERATION_TEXT_CONTEXT,
2704
+ node,
2705
+ styleResolver
2706
+ }))));
2707
+ else if (hardPageBreak !== void 0) {
2651
2708
  const pageBreakRun = schema.nodes["pageBreakRun"];
2652
2709
  if (pageBreakRun === void 0) panic("The schema has no page-break run node", { operationId: operation.id });
2653
2710
  content = [pageBreakRun.create(hardPageBreak, null, marks)];
@@ -2765,6 +2822,11 @@ const buildInsertedParagraphs = ({ item, schema, formattingFromStyle, mode, auth
2765
2822
  date,
2766
2823
  ...initials ? { initials } : {}
2767
2824
  };
2825
+ const outlineLevel = markdown?.formatting?.outlineLevel;
2826
+ if (outlineLevel !== void 0) {
2827
+ attrs["outlineLevel"] = outlineLevel;
2828
+ attrs["_originalFormatting"] = { outlineLevel };
2829
+ }
2768
2830
  const paragraph = item.blockNode.type.create(attrs, content);
2769
2831
  const sourceContext = OPERATION_TEXT_CONTEXT;
2770
2832
  const targetContext = paragraphRunStyleContext(paragraph, styleResolver);
@@ -2833,7 +2895,7 @@ const markTerminalTableReviewCarrier = (tr, before) => {
2833
2895
  const last = lastBlockBeforeTextBoxes(tr.doc);
2834
2896
  if (last?.node.type.name === "paragraph" && expectParagraphAttrs(last.node).pPrMark?.kind === "ins") tr.setNodeAttribute(last.position, "reviewCarrier", REVIEW_CARRIERS.TERMINAL_TABLE);
2835
2897
  };
2836
- const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: requestedOperations, mode = "tracked-changes", author = "AI", initials, createCommentId, revisionStamp, revisionIdSeed, wordDiff, wordDiffMode = "bounded", tableTemplates, replacementBackground = "clear", undefinedReferences, numberingIdsElsewhere }) => {
2898
+ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: requestedOperations, mode = "tracked-changes", author = "AI", initials, createCommentId, revisionStamp, revisionIdSeed, wordDiff, wordDiffMode = "bounded", tableTemplates, replacementBackground = "clear", refuseCrossAuthorRevisions, undefinedReferences, numberingIdsElsewhere }) => {
2837
2899
  seedRevisionIdsFromDoc(view.state.doc);
2838
2900
  const applied = [];
2839
2901
  const skipped = [];
@@ -2843,6 +2905,10 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
2843
2905
  const deletionType = view.state.schema.marks["deletion"];
2844
2906
  const commentType = view.state.schema.marks["comment"];
2845
2907
  const occupiedCommentIds = /* @__PURE__ */ new Set();
2908
+ const conflictsWithRevision = mode === "direct" || !refuseCrossAuthorRevisions ? void 0 : createExistingRevisionGuard({
2909
+ doc: view.state.doc,
2910
+ author
2911
+ });
2846
2912
  if (commentType) view.state.doc.descendants((node) => {
2847
2913
  for (const mark of node.marks) {
2848
2914
  if (mark.type !== commentType) continue;
@@ -2934,29 +3000,17 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
2934
3000
  });
2935
3001
  continue;
2936
3002
  }
2937
- const undefinedStyle = findUndefinedParagraphStyleReference({
2938
- operation,
2939
- definitions: styleDefinitions,
2940
- undefinedReferences
2941
- });
2942
- if (undefinedStyle !== void 0) {
2943
- skipped.push({
2944
- id: operation.id,
2945
- reason: "missingStyle",
2946
- message: describeUndefinedParagraphStyle(undefinedStyle, styleDefinitions)
2947
- });
2948
- continue;
2949
- }
2950
- const undefinedNumbering = findUndefinedNumberingReference({
3003
+ const undefinedReference = findUndefinedOperationReference({
2951
3004
  operation,
2952
- instanceIds: numberingInstanceIds,
3005
+ styles: styleDefinitions,
3006
+ numberingInstanceIds,
2953
3007
  undefinedReferences
2954
3008
  });
2955
- if (undefinedNumbering !== void 0) {
3009
+ if (undefinedReference !== void 0) {
2956
3010
  skipped.push({
2957
3011
  id: operation.id,
2958
- reason: "missingNumbering",
2959
- message: describeUndefinedNumbering(undefinedNumbering, numberingInstanceIds)
3012
+ reason: undefinedReference.reason,
3013
+ message: undefinedReference.message
2960
3014
  });
2961
3015
  continue;
2962
3016
  }
@@ -3011,6 +3065,18 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3011
3065
  doc: view.state.doc,
3012
3066
  producesTrackedChanges
3013
3067
  });
3068
+ if (operation.type !== "commentOnBlock" && operation.type !== "commentOnRange" && conflictsWithRevision !== void 0 && (conflictsWithRevision(claim) || claim.type === "deleteBlock" && claim.endsContainer && retractsForeignFinalBreak({
3069
+ doc: view.state.doc,
3070
+ position: claim.block,
3071
+ author
3072
+ }))) {
3073
+ skipped.push({
3074
+ id: operation.id,
3075
+ reason: "existingRevisionConflict",
3076
+ message: EXISTING_REVISION_CONFLICT_MESSAGE
3077
+ });
3078
+ continue;
3079
+ }
3014
3080
  const lockViolation = comparisonApplying() ? null : firstLockedControlViolation(lockedControls(), lockTouchesOf(resolution.operation, claim));
3015
3081
  if (lockViolation !== null) {
3016
3082
  skipped.push({
@@ -3040,7 +3106,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3040
3106
  if (carrierBlockId !== void 0) removedBlocksBy.delete(carrierBlockId);
3041
3107
  if (deletion) claimedTableRows.add(`${deletion.tablePosition}:${deletion.rowIndex}`);
3042
3108
  if (columnDeletion) claimedTableColumns.add(getTableColumnCoordinateKey(columnDeletion));
3043
- if ((operation.type === "insertAfterBlock" || operation.type === "insertBeforeBlock") && operation.lineBreakMode !== "inline" && LINE_BREAK_PATTERN.test(operation.text)) normalizations.push({
3109
+ if ((operation.type === "insertAfterBlock" || operation.type === "insertBeforeBlock") && operation.textFormat !== "markdown" && operation.lineBreakMode !== "inline" && LINE_BREAK_PATTERN.test(operation.text)) normalizations.push({
3044
3110
  id: operation.id,
3045
3111
  code: "splitMultilineText",
3046
3112
  paragraphCount: resolution.operation.insertTexts?.length ?? 1
@@ -3048,6 +3114,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3048
3114
  resolved.push({
3049
3115
  ...resolution.operation,
3050
3116
  batchBlockFrom: resolution.operation.blockFrom,
3117
+ ...BLOCK_INSERTION_TYPES.has(resolution.operation.operation.type) && { gap: resolution.operation.joinAt ?? resolution.operation.from },
3051
3118
  originalIndex: index,
3052
3119
  ...commentText !== void 0 && { commentText }
3053
3120
  });
@@ -3097,10 +3164,47 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3097
3164
  });
3098
3165
  }
3099
3166
  let tr = view.state.tr;
3167
+ /** The blocks the batch has put into each gap so far. */
3168
+ const gapOrder = new InsertionGapOrder();
3169
+ /**
3170
+ * Where `items`, block insertions of one gap, land next to the blocks of
3171
+ * their gap already in; undefined while none is, and they land where they
3172
+ * are placed, at `placed`.
3173
+ */
3174
+ const gapLanding = (items, placed) => {
3175
+ const gap = items[0]?.gap;
3176
+ if (gap === void 0) return void 0;
3177
+ const orders = items.map(({ originalIndex }) => originalIndex).toSorted((left, right) => left - right);
3178
+ return gapOrder.landing(tr, gap, orders, placed);
3179
+ };
3180
+ /** Note `items` (document order) just put at `at`, as `blocks` each. */
3181
+ const gapLanded = (items, blocks, at) => {
3182
+ const gap = items[0]?.gap;
3183
+ if (gap === void 0) return;
3184
+ gapOrder.record(tr, gap, items.map((landed, index) => ({
3185
+ order: landed.originalIndex,
3186
+ size: Fragment.from(blocks[index]).size
3187
+ })), at);
3188
+ };
3189
+ /** The pending joins before the batch: see `withJoinsEndingWhereTheyDid`. */
3190
+ const joinsBefore = isSuggested ? [] : pendingJoinsOf(view.state.doc);
3191
+ /** Breaks a tracked `deleteBlock` kept as a join's end: see `withKeptJoinBreaksSettled`. */
3192
+ const keptJoinBreaks = [];
3100
3193
  /** Text boxes a tracked block deletion deletes, by anchor. */
3101
3194
  const deletedTextBoxAnchorIds = /* @__PURE__ */ new Set();
3102
3195
  /** Container-ending paragraphs a tracked `deleteBlock` emptied: see `withRetiredFinalParagraphs`. */
3103
3196
  const deletedFinalParagraphs = [];
3197
+ /** Container-ending paragraphs a direct `deleteBlock` took: see `withSettledDirectFinalDeletions`. */
3198
+ const directFinalDeletions = [];
3199
+ const directJoinIdentities = [];
3200
+ const directIdentityAt = (position, paragraph) => {
3201
+ return directJoinIdentities.findLast((candidate) => {
3202
+ const targetId = candidate.target.attrs["paraId"];
3203
+ if (typeof targetId === "string") return targetId === paragraph.attrs["paraId"];
3204
+ const mapped = tr.mapping.slice(candidate.mappedFrom).mapResult(candidate.position, 1);
3205
+ return !mapped.deleted && mapped.pos === position;
3206
+ })?.source ?? paragraph;
3207
+ };
3104
3208
  const mergedPropertyTargets = [];
3105
3209
  const deferredNoopFinalDeletions = /* @__PURE__ */ new Set();
3106
3210
  const ownsSharedRevisionIdCursor = revisionIdSeed === void 0 && revisionStamp === void 0;
@@ -3156,27 +3260,37 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3156
3260
  insertion: item.tableColumnInsertion !== void 0,
3157
3261
  inputIndex: item.originalIndex
3158
3262
  };
3159
- if (ANNOTATION_OPERATION_TYPES.has(item.operation.type)) return {
3263
+ const annotation = ANNOTATION_KIND_OF.get(item.operation.type);
3264
+ if (annotation !== void 0) return {
3160
3265
  type: "annotation",
3266
+ kind: annotation,
3161
3267
  position: item.from,
3162
3268
  inputIndex: item.originalIndex
3163
3269
  };
3164
3270
  const hasDeletedSplit = tableAfterDeletedSplit.has(item.blockFrom);
3271
+ let position = item.from;
3272
+ if (hasDeletedSplit && item.operation.type === "deleteBlock") position = item.blockTo;
3273
+ else if (BLOCK_INSERTION_TYPES.has(item.operation.type)) position = insertionGapEnd(view.state.doc, item.from);
3165
3274
  return {
3166
3275
  type: "content",
3167
- position: hasDeletedSplit && item.operation.type === "deleteBlock" ? item.blockTo : item.from,
3276
+ position,
3168
3277
  rank: contentRank(item.operation, { hasDeletedSplit }),
3169
3278
  inputIndex: item.originalIndex
3170
3279
  };
3171
3280
  };
3172
3281
  const batchDeletions = new Set(executableResolved.flatMap((item) => item.operation.type === "deleteBlock" ? [item.blockFrom] : []));
3282
+ const directlyJoinedAway = new Set(producesTrackedChanges ? [] : executableResolved.flatMap((item) => item.operation.type === "mergeBlockWithNext" ? [item.blockFrom] : []));
3173
3283
  const blockAccess = (item) => {
3174
3284
  const doc = view.state.doc;
3175
3285
  if (item.operation.type === "mergeBlockWithNext") {
3176
3286
  const next = paragraphJoinAfter(doc, item.blockTo);
3287
+ if (!next) return {
3288
+ addresses: [item.blockFrom],
3289
+ removes: []
3290
+ };
3177
3291
  return {
3178
3292
  addresses: [item.blockFrom],
3179
- removes: next ? [next.nextPosition] : []
3293
+ removes: producesTrackedChanges ? [next.nextPosition] : directJoinTakes(item.blockFrom, next.nextPosition)
3180
3294
  };
3181
3295
  }
3182
3296
  if (item.operation.type === "deleteTableRow" || item.operation.type === "deleteTable") return {
@@ -3187,28 +3301,32 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3187
3301
  addresses: [],
3188
3302
  removes: []
3189
3303
  };
3304
+ if (item.operation.type === "insertBeforeBlock" && directlyJoinedAway.has(item.blockFrom)) return {
3305
+ addresses: [],
3306
+ removes: []
3307
+ };
3190
3308
  if (item.operation.type !== "deleteBlock") return {
3191
3309
  addresses: [item.blockFrom],
3192
3310
  removes: []
3193
3311
  };
3194
3312
  const at = doc.resolve(item.blockFrom);
3195
- let hasKeptParagraphBefore = false;
3313
+ const before = [];
3196
3314
  let position = at.pos;
3197
3315
  for (let index = at.index() - 1; index >= 0; index -= 1) {
3198
3316
  const previous = at.parent.child(index);
3199
3317
  position -= previous.nodeSize;
3200
3318
  if (previous.type !== item.blockNode.type) break;
3201
- if (!batchDeletions.has(position)) {
3202
- hasKeptParagraphBefore = true;
3203
- break;
3204
- }
3319
+ before.push({
3320
+ paragraph: position,
3321
+ deleted: batchDeletions.has(position)
3322
+ });
3205
3323
  }
3206
3324
  const appended = executableResolved.some((other) => other.blockFrom === item.blockFrom && (other.operation.type === "insertAfterBlock" || other.operation.type === "insertTable" && other.operation.position !== "before"));
3207
3325
  return {
3208
3326
  addresses: [],
3209
3327
  removes: deletionRemovesBlock({
3210
3328
  endsContainer: !appended && paragraphEndsItsContainer(at, item.blockNode.type.name),
3211
- hasKeptParagraphBefore
3329
+ carrier: finalBreakCarrier(before).type
3212
3330
  }) ? [item.blockFrom] : []
3213
3331
  };
3214
3332
  };
@@ -3228,7 +3346,27 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3228
3346
  /** Paragraphs a retracted break of this batch joined, to the one it left. */
3229
3347
  const joinedInto = /* @__PURE__ */ new Map();
3230
3348
  const executionGroups = groupRuns(executionOrder);
3349
+ /** Property revisions moving a superseded deleted break wrote, by owner. */
3350
+ const movedBreakRevisions = [];
3351
+ let landedParagraphs = false;
3231
3352
  for (const executionGroup of executionGroups) {
3353
+ if (landedParagraphs) {
3354
+ continueSharedRevisionIds();
3355
+ const moved = withSupersededDeletedBreaksMoved({
3356
+ tr,
3357
+ batchRevisionIds: new Set(applied.flatMap(({ revisionIds }) => revisionIds ?? [])),
3358
+ revisionSeed,
3359
+ author,
3360
+ date,
3361
+ initials,
3362
+ styleResolver: styleResolver ?? null,
3363
+ numbering
3364
+ });
3365
+ revisionSeed = moved.nextRevisionId;
3366
+ claimSharedRevisionIds(revisionSeed);
3367
+ movedBreakRevisions.push(...moved.synthesizedRevisions);
3368
+ }
3369
+ landedParagraphs = executionGroup.some(({ operation }) => BLOCK_INSERTION_TYPES.has(operation.type) || operation.type === "splitBlock");
3232
3370
  const insertionState = tr;
3233
3371
  const insertionRun = executionGroup.flatMap((resolvedCandidate) => {
3234
3372
  const candidate = readNow(resolvedCandidate, insertionState);
@@ -3301,7 +3439,8 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3301
3439
  tr,
3302
3440
  mode,
3303
3441
  noteReferences,
3304
- removedBreakPositions: pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs)
3442
+ removedBreakPositions: pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs),
3443
+ gapOrder
3305
3444
  });
3306
3445
  const built = buildInsertedParagraphs({
3307
3446
  item: formatted,
@@ -3332,16 +3471,19 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3332
3471
  }
3333
3472
  const nodes = [];
3334
3473
  for (const group of nodeGroups.toReversed()) for (const node of group) nodes.push(node);
3474
+ const placed = insertionAt({
3475
+ item,
3476
+ tr,
3477
+ noteReferences
3478
+ });
3479
+ const runAt = gapLanding(insertionRun, placed) ?? placed;
3335
3480
  tr = insertBlocksInsideComments({
3336
3481
  tr,
3337
- at: insertionAt({
3338
- item,
3339
- tr,
3340
- noteReferences
3341
- }),
3482
+ at: runAt,
3342
3483
  blocks: nodes,
3343
3484
  ...item.boundaryComments !== void 0 && { carriedComments: item.boundaryComments }
3344
3485
  });
3486
+ gapLanded(insertionRun.toReversed(), nodeGroups.toReversed(), runAt);
3345
3487
  applied.push(...runApplied);
3346
3488
  continue;
3347
3489
  }
@@ -3349,6 +3491,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3349
3491
  const commentMark = provisionalCommentId !== void 0 && commentType ? commentType.create({ commentId: provisionalCommentId }) : null;
3350
3492
  const stepsBefore = tr.steps.length;
3351
3493
  let appliedRevisionIds = [];
3494
+ let paragraphIdentity;
3352
3495
  let unifiedFormatting = false;
3353
3496
  if (isSuggested && !SUGGESTED_SUPPORTED_OPERATION_TYPES.has(item.operation.type)) {
3354
3497
  skipped.push({
@@ -3538,7 +3681,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3538
3681
  if (changesStyle && isDeletedPPrMark(tr.doc.nodeAt(sinceRead(tr, item).map(item.blockFrom, -1))?.attrs["pPrMark"])) {
3539
3682
  skipped.push({
3540
3683
  id: item.operation.id,
3541
- ...pendingParagraphMarkPropertyRefusal
3684
+ ...PENDING_PARAGRAPH_MARK_PROPERTY_REFUSAL
3542
3685
  });
3543
3686
  continue;
3544
3687
  }
@@ -3711,7 +3854,8 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3711
3854
  tr,
3712
3855
  mode,
3713
3856
  noteReferences,
3714
- removedBreakPositions: pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs)
3857
+ removedBreakPositions: pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs),
3858
+ gapOrder
3715
3859
  });
3716
3860
  const built = buildInsertedParagraphs({
3717
3861
  item: formatted,
@@ -3735,22 +3879,19 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3735
3879
  tr,
3736
3880
  noteReferences
3737
3881
  });
3882
+ const landed = gapLanding([item], placement.at);
3883
+ const comments = landed === void 0 ? placement.comments : item.boundaryComments;
3884
+ const insertedAt = landed ?? placement.at;
3738
3885
  tr = insertBlocksInsideComments({
3739
3886
  tr,
3740
- at: placement.at,
3887
+ at: insertedAt,
3741
3888
  blocks: built.nodes,
3742
- ...placement.comments !== void 0 && { carriedComments: placement.comments }
3889
+ ...comments !== void 0 && { carriedComments: comments }
3743
3890
  });
3891
+ gapLanded([item], [built.nodes], insertedAt);
3744
3892
  break;
3745
3893
  }
3746
3894
  case "insertSignatureTable": {
3747
- if (mode === "tracked-changes") {
3748
- skipped.push({
3749
- id: item.operation.id,
3750
- reason: "unsupportedMode"
3751
- });
3752
- continue;
3753
- }
3754
3895
  const signatureTable = buildSignatureTableNode({
3755
3896
  schema: view.state.schema,
3756
3897
  parties: item.operation.parties
@@ -3777,11 +3918,14 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3777
3918
  }, signatureTable.content, signatureTable.marks);
3778
3919
  appliedRevisionIds = [revisionId];
3779
3920
  }
3780
- tr = tr.insert(insertionAt({
3921
+ const placed = insertionAt({
3781
3922
  item,
3782
3923
  tr,
3783
3924
  noteReferences
3784
- }), node);
3925
+ });
3926
+ const insertedAt = gapLanding([item], placed) ?? placed;
3927
+ tr = tr.insert(insertedAt, node);
3928
+ gapLanded([item], [node], insertedAt);
3785
3929
  break;
3786
3930
  }
3787
3931
  case "insertTableRow": {
@@ -3827,9 +3971,10 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3827
3971
  continue;
3828
3972
  }
3829
3973
  const revision = structuralRevision;
3830
- const result = applyTableColumnInsertion({
3974
+ const result = applyTableColumnInsertions({
3831
3975
  tr,
3832
3976
  insertion,
3977
+ columnCount: item.operation.columnCount ?? 1,
3833
3978
  cellTexts: item.operation.cellTexts,
3834
3979
  revision
3835
3980
  });
@@ -3852,7 +3997,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3852
3997
  operationRevisionSeed += result.revisionIds.length;
3853
3998
  appliedRevisionIds = [...result.revisionIds];
3854
3999
  const columnKey = getTableColumnCoordinateKey(insertion);
3855
- insertedColumnCounts.set(columnKey, (insertedColumnCounts.get(columnKey) ?? 0) + 1);
4000
+ insertedColumnCounts.set(columnKey, (insertedColumnCounts.get(columnKey) ?? 0) + (item.operation.columnCount ?? 1));
3856
4001
  break;
3857
4002
  }
3858
4003
  case "deleteTableColumn": {
@@ -3873,6 +4018,14 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3873
4018
  revision,
3874
4019
  emptiedRows
3875
4020
  });
4021
+ if (result.type === "pendingTableChange") {
4022
+ skipped.push({
4023
+ id: item.operation.id,
4024
+ reason: "pendingTableChange",
4025
+ message: result.message
4026
+ });
4027
+ continue;
4028
+ }
3876
4029
  if (result.type === "unsupported") {
3877
4030
  skipped.push({
3878
4031
  id: item.operation.id,
@@ -3979,6 +4132,14 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
3979
4132
  deletion,
3980
4133
  revision: structuralRevision
3981
4134
  });
4135
+ if (result.type === "pendingTableChange") {
4136
+ skipped.push({
4137
+ id: item.operation.id,
4138
+ reason: "pendingTableChange",
4139
+ message: result.message
4140
+ });
4141
+ continue;
4142
+ }
3982
4143
  if (result.type === "unsupported") {
3983
4144
  skipped.push({
3984
4145
  id: item.operation.id,
@@ -4003,11 +4164,67 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4003
4164
  }
4004
4165
  if (mode === "direct") {
4005
4166
  const at = tr.doc.resolve(item.blockFrom);
4006
- tr = !paragraphEndsItsContainer(at, item.blockNode.type.name) || at.nodeBefore?.type.name === item.blockNode.type.name ? removeParagraph(tr, item.blockFrom, item.blockTo) : emptyParagraph(tr, item.blockFrom, item.blockTo);
4167
+ const endsItsContainer = paragraphEndsItsContainer(at, item.blockNode.type.name);
4168
+ const leavesAParagraph = !endsItsContainer || precededByParagraph(at, item.blockNode.type.name);
4169
+ const deletedNode = tr.doc.nodeAt(item.blockFrom);
4170
+ const deletedIdentity = deletedNode ? directIdentityAt(item.blockFrom, deletedNode) : void 0;
4171
+ const mappedFrom = tr.mapping.maps.length;
4172
+ tr = leavesAParagraph ? removeParagraph({
4173
+ tr,
4174
+ from: item.blockFrom,
4175
+ to: item.blockTo,
4176
+ kind: "direct"
4177
+ }) : emptyParagraph(tr, item.blockFrom, item.blockTo);
4178
+ const preceding = at.nodeBefore;
4179
+ if (endsItsContainer && leavesAParagraph && deletedNode && preceding?.type.name === item.blockNode.type.name) {
4180
+ if (directJoinSurvivor() === SPLIT_HALVES.SECOND) {
4181
+ const position = item.blockFrom - preceding.nodeSize;
4182
+ const source = deletedIdentity ?? deletedNode;
4183
+ const retired = directIdentityAt(position, preceding);
4184
+ directJoinIdentities.push({
4185
+ position,
4186
+ mappedFrom: tr.mapping.maps.length,
4187
+ source,
4188
+ target: preceding,
4189
+ operationId: item.operation.id
4190
+ });
4191
+ paragraphIdentity = paragraphIdentityOf(retired, source);
4192
+ } else paragraphIdentity = paragraphIdentityOf(deletedNode, preceding);
4193
+ } else if (endsItsContainer && !leavesAParagraph && deletedNode) {
4194
+ const source = deletedIdentity ?? deletedNode;
4195
+ paragraphIdentity = paragraphIdentityOf(source, source);
4196
+ }
4197
+ if (endsItsContainer && deletedNode) directFinalDeletions.push(leavesAParagraph ? {
4198
+ kind: "removed",
4199
+ position: item.blockTo,
4200
+ mappedFrom,
4201
+ paragraph: deletedNode,
4202
+ operationId: item.operation.id,
4203
+ blockId: item.operation.blockId,
4204
+ identity: deletedIdentity ?? deletedNode
4205
+ } : {
4206
+ kind: "emptied",
4207
+ position: item.blockFrom,
4208
+ mappedFrom,
4209
+ operationId: item.operation.id,
4210
+ blockId: item.operation.blockId,
4211
+ identity: deletedIdentity ?? deletedNode
4212
+ });
4007
4213
  break;
4008
4214
  }
4009
- const retraction = isPairedMove(item.operation.moveId) ? null : pendingParagraphRetraction(tr.doc, item.blockFrom);
4215
+ const retraction = isPairedMove(item.operation.moveId) || holdsForeignInsertion(item.blockNode, author) ? null : pendingParagraphRetraction(tr.doc, item.blockFrom);
4010
4216
  if (retraction) {
4217
+ const breakOwner = retraction.clearBreakAt === null ? null : tr.doc.nodeAt(retraction.clearBreakAt);
4218
+ if (conflictsWithRevision !== void 0 && breakOwner && isForeignAddedBreak(breakOwner, author)) {
4219
+ skipped.push({
4220
+ id: item.operation.id,
4221
+ reason: "existingRevisionConflict",
4222
+ message: EXISTING_REVISION_CONFLICT_MESSAGE
4223
+ });
4224
+ continue;
4225
+ }
4226
+ }
4227
+ if (retraction && !(retraction.clearBreakAt !== null && isForeignAddedBreak(tr.doc.nodeAt(retraction.clearBreakAt) ?? item.blockNode, author))) {
4011
4228
  if (isSuggested && !isSuggestedParagraphInsert(item.blockNode)) {
4012
4229
  skipped.push({
4013
4230
  id: item.operation.id,
@@ -4016,7 +4233,12 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4016
4233
  continue;
4017
4234
  }
4018
4235
  const retracted = tr.doc.nodeAt(item.blockFrom);
4019
- tr = removeParagraph(tr, item.blockFrom, item.blockTo);
4236
+ tr = removeParagraph({
4237
+ tr,
4238
+ from: item.blockFrom,
4239
+ to: item.blockTo,
4240
+ kind: "retract-pending"
4241
+ });
4020
4242
  if (retraction.clearBreakAt !== null) {
4021
4243
  tr = tr.setNodeAttribute(retraction.clearBreakAt, "pPrMark", null);
4022
4244
  const revisionIdProperties = operationRevisionSeed;
@@ -4072,13 +4294,28 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4072
4294
  appliedRevisionIds = inlineRevisionApplied ? [revisionId] : [];
4073
4295
  let markPosition = sinceRead(tr, item).map(item.blockFrom);
4074
4296
  const markOwner = tr.doc.nodeAt(markPosition);
4075
- const across = markOwner && !isPairedMove(item.operation.moveId) && addedBreakRevisionId(markOwner.attrs["pPrMark"]) !== null ? paragraphAcrossVanishingTables(tr.doc, markPosition) : null;
4297
+ const ownerMark = markOwner && expectParagraphAttrs(markOwner).pPrMark;
4298
+ const deletesForeignBreak = markOwner !== null && ownerMark !== void 0 && ownerMark !== null && ownerMark.deletion === void 0 && !isPairedMove(item.operation.moveId) && isForeignAddedBreak(markOwner, author);
4299
+ const foreignBreakTaken = markOwner !== null && ownerMark?.deletion !== void 0 && !isPairedMove(item.operation.moveId) && isForeignAddedBreak(markOwner, author);
4300
+ const across = markOwner && !deletesForeignBreak && !foreignBreakTaken && !isPairedMove(item.operation.moveId) && addedBreakRevisionId(markOwner.attrs["pPrMark"]) !== null ? paragraphAcrossVanishingTables(tr.doc, markPosition) : null;
4076
4301
  if (across !== null) markPosition = moveParagraphPastTables(tr, markPosition, across);
4077
4302
  const markPlace = tr.doc.resolve(markPosition);
4078
4303
  const endsItsContainer = paragraphEndsItsContainer(markPlace, item.blockNode.type.name);
4079
4304
  const deleted = tr.doc.nodeAt(markPosition);
4080
4305
  const following = deleted && paragraphJoinAfter(tr.doc, markPosition + deleted.nodeSize)?.next;
4081
- if (deleted && following?.type === deleted.type && !isPairedMove(item.operation.moveId) && addedBreakRevisionId(deleted.attrs["pPrMark"]) !== null) {
4306
+ if (deletesForeignBreak && ownerMark) {
4307
+ const markRevisionId = operationRevisionSeed++;
4308
+ tr = tr.setNodeAttribute(markPosition, "pPrMark", {
4309
+ ...ownerMark,
4310
+ deletion: { info: {
4311
+ id: markRevisionId,
4312
+ author,
4313
+ date,
4314
+ ...trackedRevisionExtras
4315
+ } }
4316
+ });
4317
+ appliedRevisionIds = inlineRevisionApplied ? [revisionId, markRevisionId] : [markRevisionId];
4318
+ } else if (foreignBreakTaken) {} else if (deleted && following?.type === deleted.type && !isPairedMove(item.operation.moveId) && addedBreakRevisionId(deleted.attrs["pPrMark"]) !== null) {
4082
4319
  const restored = paragraphPropertiesOnReject(deleted);
4083
4320
  const followingChanges = expectParagraphAttrs(following)._propertyChanges;
4084
4321
  const recordsRestored = isInsertedPPrMark(following.attrs["pPrMark"]) && !hasSerializableParagraphPropertyChange(followingChanges) && JSON.stringify(restored) !== JSON.stringify(paragraphPropertiesSnapshot(following));
@@ -4107,7 +4344,13 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4107
4344
  });
4108
4345
  appliedRevisionIds = [...appliedRevisionIds, propertyRevisionId];
4109
4346
  }
4110
- } else if (!endsItsContainer && deleted?.attrs["pPrMark"] == null) {
4347
+ } else if (!endsItsContainer && deleted?.attrs["pPrMark"] == null && !isPairedMove(item.operation.moveId) && endsPendingJoinAt(tr, joinsBefore, markPosition)) keptJoinBreaks.push({
4348
+ operationId: item.operation.id,
4349
+ position: markPosition,
4350
+ mappedFrom: tr.mapping.maps.length,
4351
+ revisionExtras: trackedRevisionExtras
4352
+ });
4353
+ else if (!endsItsContainer && deleted?.attrs["pPrMark"] == null) {
4111
4354
  const markRevisionId = operationRevisionSeed++;
4112
4355
  tr = tr.setNodeAttribute(markPosition, "pPrMark", {
4113
4356
  kind: isPairedMove(item.operation.moveId) ? "moveFrom" : "del",
@@ -4121,7 +4364,6 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4121
4364
  appliedRevisionIds = inlineRevisionApplied ? [revisionId, markRevisionId] : [markRevisionId];
4122
4365
  } else if (endsItsContainer && !isPairedMove(item.operation.moveId)) deletedFinalParagraphs.push({
4123
4366
  operationId: item.operation.id,
4124
- precededWhenDeleted: finalParagraphPredecessor(tr.doc, markPosition) !== null,
4125
4367
  position: markPosition,
4126
4368
  mappedFrom: tr.mapping.maps.length,
4127
4369
  revisionExtras: trackedRevisionExtras
@@ -4130,12 +4372,18 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4130
4372
  const finalPosition = deletedFinalParagraphAfter(tr.doc.resolve(markPosition), deleted.type.name, new Set(applied.flatMap(({ revisionIds }) => revisionIds ?? [])));
4131
4373
  if (finalPosition !== null) deletedFinalParagraphs.push({
4132
4374
  operationId: item.operation.id,
4133
- precededWhenDeleted: true,
4134
4375
  position: finalPosition,
4135
4376
  mappedFrom: tr.mapping.maps.length,
4136
4377
  revisionExtras: trackedRevisionExtras
4137
4378
  });
4138
4379
  }
4380
+ const joinEnd = isPairedMove(item.operation.moveId) ? null : pendingJoinEndOfSource(tr, joinsBefore, markPosition);
4381
+ if (joinEnd !== null) keptJoinBreaks.push({
4382
+ operationId: item.operation.id,
4383
+ position: joinEnd,
4384
+ mappedFrom: tr.mapping.maps.length,
4385
+ revisionExtras: trackedRevisionExtras
4386
+ });
4139
4387
  }
4140
4388
  if (commentMark) tr = tr.addMark(item.from, item.to, commentMark);
4141
4389
  break;
@@ -4172,44 +4420,19 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4172
4420
  tr,
4173
4421
  noteReferences
4174
4422
  });
4175
- let at = usesRetractedSplit ? sinceRead(tr, item).map(item.blockFrom, -1) : placement.at;
4176
- let insertionComments = carriedComments ?? placement.comments;
4177
- if (!usesRetractedSplit) {
4423
+ const landed = gapLanding([item], placement.at);
4424
+ let at = landed ?? (usesRetractedSplit ? sinceRead(tr, item).map(item.blockFrom, -1) : placement.at);
4425
+ let insertionComments = landed === void 0 ? carriedComments ?? placement.comments : item.boundaryComments;
4426
+ if (landed === void 0 && !usesRetractedSplit) {
4178
4427
  const boundary = tr.doc.resolve(at);
4179
4428
  const before = boundary.nodeBefore;
4180
4429
  const finalDeleted = deletedFinalParagraphAfter(boundary, "paragraph");
4181
- const mapping = tr.mapping;
4182
- const pendingIndex = finalDeleted === null ? -1 : deletedFinalParagraphs.findIndex(({ position, mappedFrom }) => mapping.slice(mappedFrom).map(position) === finalDeleted);
4183
- const pending = pendingIndex < 0 ? void 0 : deletedFinalParagraphs.at(pendingIndex);
4184
- if (before?.type.name === "paragraph" && finalDeleted !== null && (pending !== void 0 || isPlainDeletedPPrMark(before.attrs["pPrMark"]) && !holdsOnlyDeletedContent(before))) {
4430
+ if (before?.type.name === "paragraph" && finalDeleted !== null && isPlainDeletedPPrMark(before.attrs["pPrMark"]) && !holdsOnlyDeletedContent(before)) {
4185
4431
  insertionComments = commentsAcrossBlockBoundary(tr.doc, at);
4186
4432
  const final = tr.doc.nodeAt(finalDeleted);
4187
4433
  if (!final) panic("A deleted final paragraph vanished before table insertion", { finalDeleted });
4188
- if (pending) {
4189
- const receiptIndex = applied.findIndex(({ id }) => id === pending.operationId);
4190
- const receipt = receiptIndex < 0 ? void 0 : applied.at(receiptIndex);
4191
- if (receipt === void 0) panic("A deleted final paragraph lost its operation receipt", { operationId: pending.operationId });
4192
- const revisionId = operationRevisionSeed++;
4193
- tr.setNodeAttribute(finalDeleted, "pPrMark", {
4194
- kind: "del",
4195
- info: {
4196
- id: revisionId,
4197
- author,
4198
- date,
4199
- ...pending.revisionExtras
4200
- }
4201
- });
4202
- applied[receiptIndex] = {
4203
- ...receipt,
4204
- revisionId: receipt.revisionId ?? revisionId,
4205
- revisionIds: [...receipt.revisionIds ?? [], revisionId]
4206
- };
4207
- deletedFinalParagraphs.splice(pendingIndex, 1);
4208
- deferredNoopFinalDeletions.delete(pending.operationId);
4209
- } else {
4210
- tr.setNodeAttribute(at - before.nodeSize, "pPrMark", null);
4211
- tr.setNodeAttribute(finalDeleted, "pPrMark", before.attrs["pPrMark"]);
4212
- }
4434
+ tr.setNodeAttribute(at - before.nodeSize, "pPrMark", null);
4435
+ tr.setNodeAttribute(finalDeleted, "pPrMark", before.attrs["pPrMark"]);
4213
4436
  at = finalDeleted + final.nodeSize;
4214
4437
  }
4215
4438
  }
@@ -4219,6 +4442,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4219
4442
  blocks: table,
4220
4443
  ...insertionComments !== void 0 && { carriedComments: insertionComments }
4221
4444
  });
4445
+ gapLanded([item], [table], at);
4222
4446
  markStructuralChange(tr);
4223
4447
  break;
4224
4448
  }
@@ -4273,7 +4497,8 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4273
4497
  if (holdsPendingInsertedRow) {
4274
4498
  skipped.push({
4275
4499
  id: item.operation.id,
4276
- reason: "unsupportedBlock"
4500
+ reason: "pendingTableChange",
4501
+ message: "A row already carries a structural revision."
4277
4502
  });
4278
4503
  continue;
4279
4504
  }
@@ -4312,7 +4537,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4312
4537
  if (isDeletedPPrMark(liveBlock.attrs["pPrMark"])) {
4313
4538
  skipped.push({
4314
4539
  id: item.operation.id,
4315
- ...pendingParagraphMarkPropertyRefusal
4540
+ ...PENDING_PARAGRAPH_MARK_PROPERTY_REFUSAL
4316
4541
  });
4317
4542
  continue;
4318
4543
  }
@@ -4370,6 +4595,14 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4370
4595
  if (mode === "direct") {
4371
4596
  if (item.to > item.from) tr = tr.delete(item.from, item.to);
4372
4597
  tr = tr.split(item.from);
4598
+ const secondPosition = item.from + 1;
4599
+ const secondHalf = tr.doc.nodeAt(secondPosition);
4600
+ if (secondHalf?.type.name !== "paragraph") panic("A direct split lost its newly created second paragraph.");
4601
+ tr = tr.setNodeMarkup(secondPosition, void 0, proseParagraphAttrsWithoutPropertySource({
4602
+ ...secondHalf.attrs,
4603
+ paraId: null,
4604
+ textId: null
4605
+ }), secondHalf.marks);
4373
4606
  tr = tr.setNodeAttribute(item.blockFrom, "pPrMark", null);
4374
4607
  if (splitsFromItsTextBoxes) gatherTextBoxesAfterParagraph(tr, item.blockFrom);
4375
4608
  } else {
@@ -4468,6 +4701,22 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4468
4701
  });
4469
4702
  continue;
4470
4703
  }
4704
+ const endsBeforeTable = joinEndsBeforeTable(tr.doc, join.nextPosition);
4705
+ if (conflictsWithRevision !== void 0 && !endsBeforeTable) {
4706
+ const survivor = tr.doc.nodeAt(paragraphMergeLeaves({
4707
+ doc: tr.doc,
4708
+ paragraphPos: blockFrom,
4709
+ removedBreakPositions: pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs)
4710
+ }) ?? join.nextPosition);
4711
+ if (survivor && expectParagraphAttrs(survivor)._propertyChanges?.some(({ info }) => info.author !== author) && (item.operation.mergedParagraphProperties !== void 0 || paragraphPropertySnapshotsDiffer(paragraphPropertiesSnapshot(live), paragraphPropertiesSnapshot(survivor)))) {
4712
+ skipped.push({
4713
+ id: item.operation.id,
4714
+ reason: "existingRevisionConflict",
4715
+ message: EXISTING_REVISION_CONFLICT_MESSAGE
4716
+ });
4717
+ continue;
4718
+ }
4719
+ }
4471
4720
  allocateNewLists({
4472
4721
  status: "willApply",
4473
4722
  items: [item]
@@ -4503,6 +4752,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4503
4752
  if (separator.length > 0) tr = withSeparator(tr);
4504
4753
  const nextPosition = join.nextPosition + separator.length;
4505
4754
  const next = tr.doc.nodeAt(nextPosition);
4755
+ const nextIdentity = next ? directIdentityAt(nextPosition, next) : void 0;
4506
4756
  const paragraph = tr.doc.nodeAt(blockFrom);
4507
4757
  if (next && paragraph) tr = rebaseParagraphRuns({
4508
4758
  tr,
@@ -4516,9 +4766,23 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4516
4766
  else tr = tr.join(blockTo + separator.length);
4517
4767
  const secondSection = second ? sectionPropertiesOf(second) : null;
4518
4768
  const joined = tr.doc.nodeAt(blockFrom);
4519
- if (joined && second) tr = tr.setNodeAttribute(blockFrom, "pPrMark", expectParagraphAttrs(second).pPrMark ?? null);
4769
+ const endingMark = second && !endsBeforeTable ? expectParagraphAttrs(second).pPrMark : null;
4770
+ if (joined && second) {
4771
+ tr = tr.setNodeAttribute(blockFrom, "pPrMark", endingMark ?? null);
4772
+ if (directJoinSurvivor() === SPLIT_HALVES.SECOND) {
4773
+ const source = nextIdentity ?? second;
4774
+ const retired = directIdentityAt(blockFrom, joined);
4775
+ directJoinIdentities.push({
4776
+ position: blockFrom,
4777
+ mappedFrom: tr.mapping.maps.length,
4778
+ source,
4779
+ target: joined,
4780
+ operationId: item.operation.id
4781
+ });
4782
+ paragraphIdentity = paragraphIdentityOf(retired, source);
4783
+ } else paragraphIdentity = paragraphIdentityOf(second, joined);
4784
+ }
4520
4785
  if (joined && sectionPropertiesOf(joined) !== secondSection) tr = tr.setNodeAttribute(blockFrom, "_sectionProperties", secondSection);
4521
- const endingMark = second ? expectParagraphAttrs(second).pPrMark : null;
4522
4786
  if (joined && (endingMark?.kind === "del" || endingMark?.kind === "moveFrom")) {
4523
4787
  if (item.operation.mergedParagraphProperties) {
4524
4788
  const ending = tr.doc.nodeAt(blockFrom) ?? joined;
@@ -4532,11 +4796,11 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4532
4796
  }).tr;
4533
4797
  mergedPropertiesApplied = true;
4534
4798
  }
4535
- const survivor = paragraphLeftAfter({
4799
+ const survivor = paragraphMergeLeaves({
4536
4800
  doc: tr.doc,
4537
4801
  paragraphPos: blockFrom
4538
4802
  });
4539
- if (survivor !== null) tr = carryParagraphProperties({
4803
+ if (survivor !== null && survivor !== blockFrom) tr = carryParagraphProperties({
4540
4804
  tr,
4541
4805
  position: survivor,
4542
4806
  source: tr.doc.nodeAt(blockFrom) ?? joined,
@@ -4576,7 +4840,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4576
4840
  if (typeof firstId === "string" && typeof nextId === "string") joinedInto.set(firstId, nextId);
4577
4841
  const joinedMark = tr.doc.nodeAt(blockFrom)?.attrs["pPrMark"];
4578
4842
  const removedBreakPositions = pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs);
4579
- const carryPos = isDeletedPPrMark(joinedMark) || removedBreakPositions.has(blockFrom) ? paragraphLeftAfter({
4843
+ const carryPos = isDeletedPPrMark(joinedMark) || removedBreakPositions.has(blockFrom) ? paragraphMergeLeaves({
4580
4844
  doc: tr.doc,
4581
4845
  paragraphPos: blockFrom,
4582
4846
  removedBreakPositions
@@ -4608,26 +4872,28 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4608
4872
  ...trackedRevisionExtras
4609
4873
  }
4610
4874
  });
4611
- const survivorPos = paragraphLeftAfter({
4875
+ const survivorPos = paragraphMergeLeaves({
4612
4876
  doc: tr.doc,
4613
4877
  paragraphPos: blockFrom,
4614
4878
  removedBreakPositions: pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs)
4615
4879
  }) ?? nextPosition;
4616
- const carried = carryParagraphProperties({
4617
- tr,
4618
- position: survivorPos,
4619
- source: paragraph,
4620
- styleResolver,
4621
- numbering,
4622
- revision: {
4623
- id: revisionIdMark,
4624
- author,
4625
- date,
4626
- ...trackedRevisionExtras
4627
- }
4628
- });
4629
- tr = carried.tr;
4630
- mergedPropertiesRecorded = carried.tracked;
4880
+ if (survivorPos !== blockFrom) {
4881
+ const carried = carryParagraphProperties({
4882
+ tr,
4883
+ position: survivorPos,
4884
+ source: paragraph,
4885
+ styleResolver,
4886
+ numbering,
4887
+ revision: {
4888
+ id: revisionIdMark,
4889
+ author,
4890
+ date,
4891
+ ...trackedRevisionExtras
4892
+ }
4893
+ });
4894
+ tr = carried.tr;
4895
+ mergedPropertiesRecorded = carried.tracked;
4896
+ }
4631
4897
  mergedPropertiesAt = survivorPos;
4632
4898
  }
4633
4899
  }
@@ -4705,9 +4971,13 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4705
4971
  revisionId: appliedRevisionIds[0],
4706
4972
  revisionIds: appliedRevisionIds
4707
4973
  },
4708
- ...suggestionId !== null && { suggestionId }
4974
+ ...suggestionId !== null && { suggestionId },
4975
+ ...paragraphIdentity !== void 0 && { paragraphIdentity }
4709
4976
  });
4710
4977
  }
4978
+ const stepsBeforeFinalDeletions = tr.steps.length;
4979
+ const restoredFinalDeletions = withSettledDirectFinalDeletions(tr, directFinalDeletions);
4980
+ if (tr.steps.length > stepsBeforeFinalDeletions) markStructuralChange(tr);
4711
4981
  removeRowsWithoutCellsAfterBatch(tr, emptiedRows);
4712
4982
  markTerminalTableReviewCarrier(tr, view.state.doc);
4713
4983
  if (tr.docChanged || deferredNoopFinalDeletions.size > 0) {
@@ -4735,11 +5005,38 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4735
5005
  batchRevisionIds,
4736
5006
  revisionSeed,
4737
5007
  author,
5008
+ refuseCrossAuthorRevisions,
4738
5009
  date,
4739
5010
  styleResolver,
4740
5011
  numbering
4741
5012
  });
5013
+ if (retired.type === "blocked") return {
5014
+ heldRevisionConflict: true,
5015
+ applied: [],
5016
+ skipped: [...skipped, ...applied.map(({ id }) => id === retired.operationId ? {
5017
+ id,
5018
+ reason: "existingRevisionConflict",
5019
+ message: EXISTING_REVISION_CONFLICT_MESSAGE
5020
+ } : {
5021
+ id,
5022
+ reason: "atomicBatchRejected"
5023
+ })],
5024
+ nextRevisionId: retired.nextRevisionId
5025
+ };
4742
5026
  revisionSeed = retired.nextRevisionId;
5027
+ withJoinsEndingWhereTheyDid({
5028
+ tr,
5029
+ joins: joinsBefore
5030
+ });
5031
+ const settledJoinBreaks = withKeptJoinBreaksSettled({
5032
+ tr,
5033
+ kept: keptJoinBreaks,
5034
+ appliedIds: new Set(applied.map(({ id }) => id)),
5035
+ revisionSeed,
5036
+ author,
5037
+ date
5038
+ });
5039
+ revisionSeed += settledJoinBreaks.length;
4743
5040
  for (const operationId of deferredNoopFinalDeletions) {
4744
5041
  if (retired.resolvedOperationIds.has(operationId)) continue;
4745
5042
  const receiptIndex = applied.findIndex(({ id }) => id === operationId);
@@ -4751,7 +5048,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4751
5048
  }
4752
5049
  const receiptIndexByRevisionId = /* @__PURE__ */ new Map();
4753
5050
  for (const [receiptIndex, receipt] of applied.entries()) for (const revisionId of receipt.revisionIds ?? []) receiptIndexByRevisionId.set(revisionId, receiptIndex);
4754
- for (const { ownerRevisionId, revisionId } of rotated.synthesizedRevisions) {
5051
+ for (const { ownerRevisionId, revisionId } of [...movedBreakRevisions, ...rotated.synthesizedRevisions]) {
4755
5052
  const receiptIndex = receiptIndexByRevisionId.get(ownerRevisionId);
4756
5053
  const receipt = receiptIndex === void 0 ? void 0 : applied.at(receiptIndex);
4757
5054
  if (receiptIndex === void 0 || !receipt?.revisionIds) panic("A synthesized final-mark revision lost its operation receipt", {
@@ -4763,7 +5060,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4763
5060
  revisionIds: [...receipt.revisionIds, revisionId]
4764
5061
  };
4765
5062
  }
4766
- for (const { operationId, revisionId } of retired.addedRevisions) {
5063
+ for (const { operationId, revisionId } of [...retired.addedRevisions, ...settledJoinBreaks]) {
4767
5064
  const receiptIndex = applied.findIndex(({ id }) => id === operationId);
4768
5065
  const receipt = applied.at(receiptIndex);
4769
5066
  if (receiptIndex < 0 || !receipt) panic("A retired final-mark revision lost its operation receipt", {
@@ -4804,6 +5101,90 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
4804
5101
  }
4805
5102
  claimSharedRevisionIds(revisionSeed);
4806
5103
  if (revisionStamp) requestDeterministicParaIds(tr, `${revisionStamp.date}:${String(revisionStamp.idSeed)}`);
5104
+ if (directJoinIdentities.length > 0 || directFinalDeletions.length > 0) {
5105
+ const appliedIds = new Set(applied.map(({ id }) => id));
5106
+ const insertedBefore = new Set(executableResolved.flatMap(({ operation }) => operation.type === "insertBeforeBlock" && appliedIds.has(operation.id) ? [operation.blockId] : []));
5107
+ for (const deletion of directFinalDeletions) {
5108
+ if (!insertedBefore.has(deletion.blockId)) continue;
5109
+ const mapped = tr.mapping.slice(deletion.mappedFrom).mapResult(deletion.position, 1);
5110
+ if (mapped.deleted) continue;
5111
+ const at = tr.doc.resolve(mapped.pos);
5112
+ const target = at.nodeBefore;
5113
+ if (target?.type.name !== "paragraph" || !containerEndsAt(at, target.type.name)) continue;
5114
+ const position = mapped.pos - target.nodeSize;
5115
+ const pending = directJoinIdentities.find(({ operationId }) => operationId === deletion.operationId);
5116
+ if (pending) {
5117
+ pending.position = position;
5118
+ pending.mappedFrom = tr.mapping.maps.length;
5119
+ pending.target = target;
5120
+ } else directJoinIdentities.push({
5121
+ position,
5122
+ mappedFrom: tr.mapping.maps.length,
5123
+ target,
5124
+ source: deletion.identity,
5125
+ operationId: deletion.operationId
5126
+ });
5127
+ }
5128
+ const positionsByIdentity = /* @__PURE__ */ new Map();
5129
+ tr.doc.descendants((node, position) => {
5130
+ const id = node.attrs["paraId"];
5131
+ if (typeof id === "string") {
5132
+ if (positionsByIdentity.has(id)) panic("A direct join found duplicate paragraph identities.");
5133
+ positionsByIdentity.set(id, position);
5134
+ }
5135
+ return !node.isTextblock;
5136
+ });
5137
+ const transfers = /* @__PURE__ */ new Map();
5138
+ for (const pending of directJoinIdentities) {
5139
+ if (restoredFinalDeletions.has(pending.operationId)) continue;
5140
+ const mapped = tr.mapping.slice(pending.mappedFrom).mapResult(pending.position, 1);
5141
+ const targetId = pending.target.attrs["paraId"];
5142
+ const position = typeof targetId === "string" ? positionsByIdentity.get(targetId) : mapped.pos;
5143
+ if (position === void 0 || typeof targetId !== "string" && mapped.deleted) {
5144
+ if (!mapped.deleted) panic("A deferred direct join lost an untouched paragraph identity.");
5145
+ continue;
5146
+ }
5147
+ transfers.set(position, pending);
5148
+ }
5149
+ const finalPositions = /* @__PURE__ */ new Map();
5150
+ tr.doc.descendants((node, position) => {
5151
+ const identity = (transfers.get(position)?.source ?? node).attrs["paraId"];
5152
+ if (typeof identity === "string") {
5153
+ if (finalPositions.has(identity)) panic("Deferred direct joins would duplicate a paragraph identity.");
5154
+ finalPositions.set(identity, position);
5155
+ }
5156
+ return !node.isTextblock;
5157
+ });
5158
+ const settledIdentities = new Map(restoredFinalDeletions);
5159
+ for (const pending of transfers.values()) settledIdentities.set(pending.operationId, pending.source);
5160
+ for (const [operationId, source] of settledIdentities) {
5161
+ const receipt = applied.find(({ id }) => id === operationId);
5162
+ if (!receipt) panic("A deferred direct join lost its applied receipt.");
5163
+ const outcome = receipt.paragraphIdentity;
5164
+ if (outcome?.type === "joined" && finalPositions.has(outcome.retiredBlockId)) receipt.paragraphIdentity = {
5165
+ type: "retained",
5166
+ blockId: outcome.blockId
5167
+ };
5168
+ if (outcome === void 0) {
5169
+ const blockId = source.attrs["paraId"];
5170
+ if (typeof blockId === "string") receipt.paragraphIdentity = {
5171
+ type: "retained",
5172
+ blockId
5173
+ };
5174
+ }
5175
+ }
5176
+ for (const [position, pending] of transfers) tr = withIdentityOf({
5177
+ tr,
5178
+ position,
5179
+ source: pending.source
5180
+ });
5181
+ }
5182
+ if (mode === "tracked-changes") addRetiredCommentReceipts({
5183
+ before: view.state,
5184
+ after: tr.doc,
5185
+ applied,
5186
+ operations: requestedOperations.filter((operation) => operation.type !== "deleteBlock" || !isPairedMove(operation.moveId))
5187
+ });
4807
5188
  if (tr.docChanged) view.dispatch(tr);
4808
5189
  }
4809
5190
  return {
@@ -4828,8 +5209,9 @@ const previewFolioAIEditOperations = (options) => previewFolioAIEditOperationsWi
4828
5209
  * comment ids it placed, for a caller that checks the result before reporting
4829
5210
  * it. Internal: not re-exported from the package entry points.
4830
5211
  */
4831
- const previewFolioAIEditOperationsWithResult = (options) => {
4832
- const { view, createCommentId, ...applyOptions } = options;
5212
+ const previewFolioAIEditOperationsWithResult = (options, wordDiffMode = "coarse") => {
5213
+ const { view, createCommentId, wordDiff, ...applyOptions } = options;
5214
+ const granularity = wordDiffMode === "bounded" ? wordDiff?.granularity : void 0;
4833
5215
  let previewCommentId = -1;
4834
5216
  const commentIds = [];
4835
5217
  const previewView = {
@@ -4841,17 +5223,22 @@ const previewFolioAIEditOperationsWithResult = (options) => {
4841
5223
  const result = applyFolioAIEditOperationsInternal({
4842
5224
  ...applyOptions,
4843
5225
  view: previewView,
5226
+ ...granularity !== void 0 && { wordDiff: { granularity } },
4844
5227
  ...createCommentId !== void 0 && { createCommentId: () => {
4845
5228
  const id = previewCommentId--;
4846
5229
  commentIds.push(id);
4847
5230
  return id;
4848
5231
  } },
4849
5232
  revisionIdSeed: -1e9,
4850
- wordDiffMode: "coarse"
5233
+ wordDiffMode
4851
5234
  });
4852
5235
  return {
4853
5236
  outcome: {
4854
- applied: result.applied.map(({ id }) => ({ id })),
5237
+ applied: result.applied.map(({ id, paragraphIdentity, retiredCommentIds }) => ({
5238
+ id,
5239
+ ...paragraphIdentity === void 0 ? {} : { paragraphIdentity },
5240
+ ...retiredCommentIds === void 0 ? {} : { retiredCommentIds }
5241
+ })),
4855
5242
  skipped: result.skipped,
4856
5243
  ...result.normalizations !== void 0 && { normalizations: result.normalizations },
4857
5244
  nextRevisionId: options.revisionStamp?.idSeed ?? nextRevisionId()
@@ -4884,7 +5271,7 @@ const cleanTextInlineNodes = ({ schema, text, marks = [] }) => {
4884
5271
  const insertCleanText = ({ tr, from, to, text, standsInFor, keepsReplacedText = false }) => {
4885
5272
  const annotations = surveyReplacedAnnotations(tr.doc, from, to);
4886
5273
  const carried = standsInFor ? surveyReplacedAnnotations(tr.doc, standsInFor.from, standsInFor.to).carried : [];
4887
- const replaced = keepsReplacedText ? commentsForTrackedInsertion(tr.doc, from, [carried])[0] ?? [] : carried;
5274
+ const replaced = keepsReplacedText ? commentsForTrackedInsertion(tr.doc, from, [carried])[0] ?? [] : addCarriedMarks(carried, commentsSpanningInsertion(tr.doc, from, to));
4888
5275
  const baseMarks = (tr.selection.from === from && tr.selection.to === to ? tr.storedMarks : null) ?? inheritedReplacementMarks(tr.doc, from, to);
4889
5276
  if (!hasReplacedAnnotations(annotations) && replaced.length === 0 && !hasCleanTextControls(text)) {
4890
5277
  if (text.length === 0) return {
@@ -5028,7 +5415,6 @@ const replacedCleanSpan = (item, cleanBlock) => {
5028
5415
  default: return null;
5029
5416
  }
5030
5417
  };
5031
- const BACKGROUND_MARK_NAMES = /* @__PURE__ */ new Set(["highlight", "runShading"]);
5032
5418
  /**
5033
5419
  * Formatting, as opposed to a mark naming something outside the text or
5034
5420
  * describing one character (see `NON_INCLUSIVE_MARK_DISPOSITION`).
@@ -5051,18 +5437,20 @@ const planDocumentReplacement = ({ doc, item, replacement, noteReferences, planC
5051
5437
  const spanStart = span.start;
5052
5438
  const spanEnd = span.start + span.text.length;
5053
5439
  const noteReferenceSpans = noteReferenceSpansWithin(cleanBlock, spanStart, spanEnd);
5054
- const editsReferences = !(segmentsAroundNoteReferences(span.text, replacement, noteReferenceSpans) !== null) && noteReferenceEditsAllowed();
5055
- const atomicSpans = cleanBlock.structuralBoundaries.flatMap((boundary) => boundary.type === "field" || editsReferences && boundary.type === "noteReference" ? [{
5056
- offset: boundary.offset - spanStart,
5057
- length: boundary.length
5058
- }] : []);
5059
- const planPieces = (plan) => editsReferences ? [...plan(span.text, replacement)] : planChangesAroundNoteReferences(span.text, replacement, noteReferenceSpans, plan);
5060
- const pieceChanges = planPieces(planChanges);
5061
- if (pieceChanges === null) return null;
5062
- const widened = widenChangesToAtomicSpans(span.text, pieceChanges, atomicSpans);
5063
- const keptPieces = keepFieldsOf === void 0 ? null : planPieces(keepFieldsOf);
5064
- const changes = keptPieces === null ? widened : keepAtomicSpans(span.text, replacement, widened, widenChangesToAtomicSpans(span.text, keptPieces, atomicSpans), atomicSpans);
5065
- if (applyTextChanges(span.text, changes) !== replacement) return null;
5440
+ const keepsReferences = segmentsAroundNoteReferences(span.text, replacement, noteReferenceSpans) !== null;
5441
+ const changes = planReplacementChanges({
5442
+ source: span.text,
5443
+ replacement,
5444
+ noteReferences: noteReferenceSpans,
5445
+ editsReferences: !keepsReferences && noteReferenceEditsAllowed(),
5446
+ fields: cleanBlock.structuralBoundaries.flatMap((boundary) => boundary.type === "field" ? [{
5447
+ offset: boundary.offset - spanStart,
5448
+ length: boundary.length
5449
+ }] : []),
5450
+ planChanges,
5451
+ ...keepFieldsOf === void 0 ? {} : { keepFieldsOf }
5452
+ });
5453
+ if (changes === null) return null;
5066
5454
  const unitAt = (index) => {
5067
5455
  const from = cleanBlock.offsets[index];
5068
5456
  const node = from === void 0 ? null : doc.nodeAt(from);
@@ -5145,7 +5533,7 @@ const planDocumentReplacement = ({ doc, item, replacement, noteReferences, planC
5145
5533
  text: change.text,
5146
5534
  insertion: {
5147
5535
  at: matchedFrom,
5148
- marks: (current) => current.resolve(matchedFrom).marks()
5536
+ marks: (current) => addCarriedMarks(current.resolve(matchedFrom).marks(), commentsSpanningInsertion(current, matchedFrom))
5149
5537
  }
5150
5538
  });
5151
5539
  continue;
@@ -5160,7 +5548,7 @@ const planDocumentReplacement = ({ doc, item, replacement, noteReferences, planC
5160
5548
  text: change.text,
5161
5549
  insertion: {
5162
5550
  at: climbAfter(previous.to),
5163
- marks: (current) => addCarriedMarks(styleSource === null ? [] : current.resolve(styleSource.to).marks(), matchCarried)
5551
+ marks: (current) => addCarriedMarks(addCarriedMarks(styleSource === null ? [] : current.resolve(styleSource.to).marks(), matchCarried), commentsSpanningInsertion(current, climbAfter(previous.to)))
5164
5552
  }
5165
5553
  });
5166
5554
  continue;
@@ -5174,7 +5562,7 @@ const planDocumentReplacement = ({ doc, item, replacement, noteReferences, planC
5174
5562
  text: change.text,
5175
5563
  insertion: {
5176
5564
  at: climbBefore(first.from),
5177
- marks: (current) => addCarriedMarks(styleSource === null ? [] : (current.nodeAt(styleSource.from)?.marks ?? []).filter(isFormattingMark), matchCarried)
5565
+ marks: (current) => addCarriedMarks(addCarriedMarks(styleSource === null ? [] : (current.nodeAt(styleSource.from)?.marks ?? []).filter(isFormattingMark), matchCarried), commentsSpanningInsertion(current, climbBefore(first.from)))
5178
5566
  }
5179
5567
  });
5180
5568
  }
@@ -5512,6 +5900,8 @@ const applyMinimalTrackedReplacement = ({ tr, item, noteReferences, replacement,
5512
5900
  const styleSource = plan.replacementStyleSource(change.change);
5513
5901
  if (first === void 0 || last === void 0 || styleSource === null) panic("A planned replacement lost the characters it removes");
5514
5902
  at = last.to;
5903
+ const sourceHolder = doc.resolve(first.from);
5904
+ if (sourceHolder.parent.type.name === "sdt" && at > sourceHolder.after()) at = sourceHolder.end();
5515
5905
  removedFrom = first.from;
5516
5906
  marks = addCarriedMarks(inheritedReplacementMarks(doc, styleSource.from, styleSource.to), surveyAcceptedReplacedAnnotations(doc, first.from, last.to).carried);
5517
5907
  for (const piece of change.pieces) {
@@ -5561,32 +5951,18 @@ const applyMinimalTrackedReplacement = ({ tr, item, noteReferences, replacement,
5561
5951
  };
5562
5952
  /**
5563
5953
  * The clean-text characters of every background stretch a change touches,
5564
- * within the matched span.
5565
- *
5566
- * Text written onto a highlighted value is new text, so the marker saying
5567
- * "fill this in" must not survive on it, and changing one digit of a
5568
- * highlighted amount still fills the whole amount. Background elsewhere in the
5569
- * match is left alone.
5954
+ * within the matched span (see {@link touchedBackgroundStretches}).
5570
5955
  */
5571
5956
  const touchedBackgroundIndices = ({ doc, plan: { changes, spanStart, spanEnd, unitAt } }) => {
5572
5957
  const hasBackground = (index) => {
5573
- const unit = unitAt(index);
5958
+ const unit = unitAt(spanStart + index);
5574
5959
  return (unit === null ? null : doc.nodeAt(unit.from))?.marks.some((mark) => BACKGROUND_MARK_NAMES.has(mark.type.name)) ?? false;
5575
5960
  };
5576
- const touched = /* @__PURE__ */ new Set();
5577
- for (const change of changes) {
5578
- const start = spanStart + change.start;
5579
- const end = spanStart + change.end;
5580
- const touchedFrom = start === end ? Math.max(start - 1, spanStart) : start;
5581
- const touchedTo = start === end ? Math.min(end + 1, spanEnd) : end;
5582
- for (let index = touchedFrom; index < touchedTo; index++) {
5583
- if (touched.has(index) || !hasBackground(index)) continue;
5584
- touched.add(index);
5585
- for (let left = index - 1; left >= spanStart && hasBackground(left); left--) touched.add(left);
5586
- for (let right = index + 1; right < spanEnd && hasBackground(right); right++) touched.add(right);
5587
- }
5588
- }
5589
- return touched;
5961
+ const touched = touchedBackgroundStretches(changes, {
5962
+ length: spanEnd - spanStart,
5963
+ hasBackground
5964
+ });
5965
+ return new Set([...touched].map((index) => spanStart + index));
5590
5966
  };
5591
5967
  /** The document ranges owning clean characters `indices`, merged where they meet. */
5592
5968
  const unitRanges = (indices, unitAt) => {
@@ -5711,6 +6087,10 @@ const resolveOperationTarget = ({ snapshot, operation, liveBlocks, liveBlocksByP
5711
6087
  noteReferences
5712
6088
  });
5713
6089
  if (primaryBlock.type === "skip") return primaryBlock;
6090
+ if ((operation.type === "insertTable" || operation.type === "insertSignatureTable") && !supportsTableInsertionMode(operation.type, mode)) return {
6091
+ type: "skip",
6092
+ reason: "unsupportedMode"
6093
+ };
5714
6094
  const { blockNode, blockFrom, blockTo, cleanBlock, currentText, currentTextHash } = primaryBlock;
5715
6095
  if (operation.precondition !== void 0 && currentTextHash !== operation.precondition.blockTextHash) return {
5716
6096
  type: "skip",
@@ -5724,15 +6104,22 @@ const resolveOperationTarget = ({ snapshot, operation, liveBlocks, liveBlocksByP
5724
6104
  paragraphPos: blockFrom,
5725
6105
  noteReferences
5726
6106
  });
6107
+ const besideTable = (boundary, side) => {
6108
+ const at = insertionGap(doc, boundary, side);
6109
+ return {
6110
+ from: at,
6111
+ at
6112
+ };
6113
+ };
5727
6114
  const beside = (side) => {
5728
- const plain = side === "after" ? endOfParagraphWithItsTextBoxes(doc, blockFrom) : blockFrom;
5729
- const at = joinBounds()[side];
5730
- const from = side === "after" ? plain : at;
6115
+ const gap = (position) => insertionGap(doc, position, side);
6116
+ const plain = gap(side === "after" ? endOfParagraphWithItsTextBoxes(doc, blockFrom) : blockFrom);
6117
+ const at = gap(joinBounds()[side]);
5731
6118
  return at === plain ? {
5732
- from,
6119
+ from: at,
5733
6120
  at
5734
6121
  } : {
5735
- from,
6122
+ from: at,
5736
6123
  at,
5737
6124
  joinSide: side,
5738
6125
  joinAt: at
@@ -5787,29 +6174,43 @@ const resolveOperationTarget = ({ snapshot, operation, liveBlocks, liveBlocksByP
5787
6174
  if (operation.type === "insertAfterBlock" || operation.type === "insertBeforeBlock") {
5788
6175
  const tableBoundary = findOutermostTableBoundary(doc, blockFrom);
5789
6176
  const side = operation.type === "insertAfterBlock" ? "after" : "before";
5790
- const placed = tableBoundary ? {
5791
- from: tableBoundary[side],
5792
- at: tableBoundary[side]
5793
- } : beside(side);
6177
+ const placed = tableBoundary ? besideTable(tableBoundary[side], side) : beside(side);
5794
6178
  if (joinStopsAtTableAfter({
5795
6179
  doc,
5796
6180
  paragraphPos: placed.at,
5797
- noteReferences
6181
+ noteReferences,
6182
+ insertedBlock: "paragraph"
5798
6183
  })) return {
5799
6184
  type: "skip",
5800
- ...pendingJoinInsertionRefusal
6185
+ ...PENDING_JOIN_INSERTION_REFUSAL
5801
6186
  };
5802
6187
  const insertFrom = placed.from;
6188
+ const markdown = operation.textFormat === "markdown" ? compileMarkdownInsertion(operation.text) : void 0;
6189
+ if (markdown?.type === "unsupported") return {
6190
+ type: "skip",
6191
+ reason: "unsupportedBlock",
6192
+ message: markdown.message
6193
+ };
6194
+ const splitParagraphs = operation.lineBreakMode !== "inline" && LINE_BREAK_PATTERN.test(operation.text);
6195
+ const insertTexts = markdown?.paragraphs.map(({ content }) => content.map(markdownRunText).join("")) ?? (splitParagraphs ? splitInsertParagraphTexts(operation.text) : [operation.text]);
5803
6196
  return {
5804
6197
  type: "resolved",
5805
6198
  operation: {
5806
- operation,
6199
+ operation: markdown === void 0 ? operation : {
6200
+ ...operation,
6201
+ inheritFormatting: false,
6202
+ ...markdown.listKind !== void 0 && {
6203
+ formattingScope: "allParagraphs",
6204
+ numbering: deferInsertedList(markdown.listKind)
6205
+ }
6206
+ },
5807
6207
  from: insertFrom,
5808
6208
  to: insertFrom,
5809
6209
  blockFrom,
5810
6210
  blockTo,
5811
6211
  blockNode,
5812
- insertTexts: operation.lineBreakMode !== "inline" && LINE_BREAK_PATTERN.test(operation.text) ? splitInsertParagraphTexts(operation.text) : [operation.text],
6212
+ insertTexts,
6213
+ ...markdown !== void 0 && { markdownParagraphs: markdown.paragraphs },
5813
6214
  boundaryComments: commentsAcrossBlockBoundary(doc, placed.at),
5814
6215
  ...placed.joinSide !== void 0 && {
5815
6216
  joinSide: placed.joinSide,
@@ -5825,10 +6226,17 @@ const resolveOperationTarget = ({ snapshot, operation, liveBlocks, liveBlocksByP
5825
6226
  };
5826
6227
  const position = operation.position ?? "after";
5827
6228
  const tableBoundary = findOutermostTableBoundary(doc, blockFrom);
5828
- const placed = tableBoundary ? {
5829
- from: tableBoundary[position],
5830
- at: tableBoundary[position]
5831
- } : beside(position);
6229
+ const placed = tableBoundary ? besideTable(tableBoundary[position], position) : beside(position);
6230
+ if (joinStopsAtTableAfter({
6231
+ doc,
6232
+ paragraphPos: placed.at,
6233
+ noteReferences,
6234
+ insertedBlock: "table",
6235
+ joinBeforeTable: "stopsAtDeletedParagraph"
6236
+ })) return {
6237
+ type: "skip",
6238
+ ...PENDING_JOIN_INSERTION_REFUSAL
6239
+ };
5832
6240
  return {
5833
6241
  type: "resolved",
5834
6242
  operation: {
@@ -6064,10 +6472,17 @@ const resolveOperationTarget = ({ snapshot, operation, liveBlocks, liveBlocksByP
6064
6472
  if (operation.type === "insertTable") {
6065
6473
  const side = (operation.position ?? "after") === "after" ? "after" : "before";
6066
6474
  const tableBoundary = findOutermostTableBoundary(doc, blockFrom);
6067
- const placed = tableBoundary ? {
6068
- from: tableBoundary[side],
6069
- at: tableBoundary[side]
6070
- } : beside(side);
6475
+ const placed = tableBoundary ? besideTable(tableBoundary[side], side) : beside(side);
6476
+ if (joinStopsAtTableAfter({
6477
+ doc,
6478
+ paragraphPos: placed.at,
6479
+ noteReferences,
6480
+ insertedBlock: "table",
6481
+ joinBeforeTable: "stopsAtDeletedParagraph"
6482
+ })) return {
6483
+ type: "skip",
6484
+ ...PENDING_JOIN_INSERTION_REFUSAL
6485
+ };
6071
6486
  return {
6072
6487
  type: "resolved",
6073
6488
  operation: {
@@ -6110,7 +6525,7 @@ const resolveOperationTarget = ({ snapshot, operation, liveBlocks, liveBlocksByP
6110
6525
  if (operation.type === "setBlockParagraphProperties") {
6111
6526
  if (isDeletedPPrMark(blockNode.attrs["pPrMark"])) return {
6112
6527
  type: "skip",
6113
- ...pendingParagraphMarkPropertyRefusal
6528
+ ...PENDING_PARAGRAPH_MARK_PROPERTY_REFUSAL
6114
6529
  };
6115
6530
  return {
6116
6531
  type: "resolved",
@@ -6191,7 +6606,7 @@ const resolveOperationTarget = ({ snapshot, operation, liveBlocks, liveBlocksByP
6191
6606
  const replaceChangesStyle = operation.type === "replaceBlock" && operation.styleId !== void 0 && operation.styleId !== (expectParagraphAttrs(blockNode).styleId ?? null);
6192
6607
  if (replaceChangesStyle && isDeletedPPrMark(blockNode.attrs["pPrMark"])) return {
6193
6608
  type: "skip",
6194
- ...pendingParagraphMarkPropertyRefusal
6609
+ ...PENDING_PARAGRAPH_MARK_PROPERTY_REFUSAL
6195
6610
  };
6196
6611
  if (replaceChangesText && cleanBlock.structuralBoundaries.some((boundary) => boundary.type !== "field" && boundary.type !== "noteReference")) return {
6197
6612
  type: "skip",
@@ -6337,132 +6752,8 @@ const getTextRangeFromCleanBlock = (cleanBlock) => {
6337
6752
  };
6338
6753
  };
6339
6754
  const getOperationCommentText = (operation) => "comment" in operation ? operation.comment?.text : void 0;
6340
- /**
6341
- * Every paragraph style an operation names, with the field that names it.
6342
- * `null` clears the style and names none; an omitted one keeps the style the
6343
- * paragraph or its anchor already carries, which the document holds by
6344
- * construction.
6345
- */
6346
- const operationParagraphStyleReferences = (operation) => {
6347
- switch (operation.type) {
6348
- case "insertAfterBlock":
6349
- case "insertBeforeBlock":
6350
- case "replaceBlock": return [{
6351
- path: "styleId",
6352
- styleId: operation.styleId
6353
- }];
6354
- case "setBlockParagraphProperties": return [{
6355
- path: "properties.styleId",
6356
- styleId: operation.properties.styleId
6357
- }];
6358
- case "splitBlock": return [{
6359
- path: "firstParagraphProperties.styleId",
6360
- styleId: operation.firstParagraphProperties?.styleId
6361
- }, {
6362
- path: "secondParagraphProperties.styleId",
6363
- styleId: operation.secondParagraphProperties?.styleId
6364
- }];
6365
- case "mergeBlockWithNext": return [{
6366
- path: "mergedParagraphProperties.styleId",
6367
- styleId: operation.mergedParagraphProperties?.styleId
6368
- }];
6369
- default: return [];
6370
- }
6371
- };
6372
- /**
6373
- * Explicit editing requests refuse unavailable paragraph styles before apply.
6374
- * Source-preserving imports keep their references verbatim; closure import
6375
- * validates every defined resource separately. A state without the styles
6376
- * plugin cannot classify a reference and checks nothing.
6377
- */
6378
- const findUndefinedParagraphStyleReference = ({ operation, definitions, undefinedReferences }) => {
6379
- if (definitions === null) return;
6380
- for (const { path, styleId } of operationParagraphStyleReferences(operation)) {
6381
- if (styleId === null || styleId === void 0) continue;
6382
- const reference = classifyResourceReference({
6383
- kind: "style",
6384
- id: styleId,
6385
- sourceDefines: (id) => definitions.get(id) !== void 0,
6386
- destinationDefines: (id) => definitions.get(id) !== void 0
6387
- });
6388
- if (undefinedReferences === "keep") continue;
6389
- if (reference !== "sourceDefined") return {
6390
- path,
6391
- styleId,
6392
- definedAs: void 0
6393
- };
6394
- const definition = definitions.get(styleId) ?? panic("A classified style lost its definition");
6395
- if (definition.type !== "paragraph") return {
6396
- path,
6397
- styleId,
6398
- definedAs: definition.type
6399
- };
6400
- }
6401
- };
6402
- const MAX_LISTED_PARAGRAPH_STYLES = 12;
6403
- const describeUndefinedParagraphStyle = ({ path, styleId, definedAs }, definitions) => {
6404
- const defined = (definitions?.paragraphStyles() ?? []).map((style) => style.styleId);
6405
- let available = "it defines no visible paragraph styles";
6406
- if (defined.length > 0) available = `its paragraph styles include ${defined.slice(0, MAX_LISTED_PARAGRAPH_STYLES).join(", ")}${defined.length > MAX_LISTED_PARAGRAPH_STYLES ? ", …" : ""}`;
6407
- return `${path} "${styleId}" ${definedAs === void 0 ? "names no style in this document" : `names a ${definedAs} style, not a paragraph style`} (${available}).`;
6408
- };
6409
- /** The `w:num` id a stated numbering names, when it names one. */
6410
- const statedNumberingInstance = (numbering) => numbering?.kind === "reference" && isNumberingReference$1(numbering.numId) ? numbering.numId : void 0;
6411
- /**
6412
- * Every numbering instance an operation names, with the field that names it.
6413
- * Only reference variants name an instance; inheritance, cancellation and level-only do not.
6414
- */
6415
- const operationNumberingReferences = (operation) => {
6416
- switch (operation.type) {
6417
- case "insertAfterBlock":
6418
- case "insertBeforeBlock": return [{
6419
- path: "numbering",
6420
- numbering: operation.numbering
6421
- }];
6422
- case "setBlockParagraphProperties": return [{
6423
- path: "properties.numbering",
6424
- numbering: operation.properties.numbering
6425
- }];
6426
- case "splitBlock": return [{
6427
- path: "firstParagraphProperties.numbering",
6428
- numbering: operation.firstParagraphProperties?.numbering
6429
- }, {
6430
- path: "secondParagraphProperties.numbering",
6431
- numbering: operation.secondParagraphProperties?.numbering
6432
- }];
6433
- case "mergeBlockWithNext": return [{
6434
- path: "mergedParagraphProperties.numbering",
6435
- numbering: operation.mergedParagraphProperties?.numbering
6436
- }];
6437
- default: return [];
6438
- }
6439
- };
6440
- const findUndefinedNumberingReference = ({ operation, instanceIds, undefinedReferences }) => {
6441
- if (instanceIds === null) return;
6442
- for (const { path, numbering } of operationNumberingReferences(operation)) {
6443
- const numId = statedNumberingInstance(numbering);
6444
- if (numId === void 0) continue;
6445
- const reference = classifyResourceReference({
6446
- kind: "numbering",
6447
- id: numId,
6448
- sourceDefines: (id) => instanceIds.has(id),
6449
- destinationDefines: (id) => instanceIds.has(id)
6450
- });
6451
- if (undefinedReferences !== "keep" && reference !== "sourceDefined") return {
6452
- path,
6453
- numId
6454
- };
6455
- }
6456
- };
6457
- const MAX_LISTED_NUMBERING_INSTANCES = 12;
6458
- const describeUndefinedNumbering = ({ path, numId }, instanceIds) => {
6459
- const defined = [...instanceIds ?? []].sort((left, right) => left - right);
6460
- let available = "it defines none";
6461
- if (defined.length > 0) available = `it defines ${defined.slice(0, MAX_LISTED_NUMBERING_INSTANCES).join(", ")}${defined.length > MAX_LISTED_NUMBERING_INSTANCES ? ", …" : ""}`;
6462
- return `${path}.numId ${String(numId)} names no numbering instance in this document (${available}).`;
6463
- };
6464
6755
  const getOperationQuote = (operation) => {
6465
6756
  if (operation.type === "replaceInBlock") return operation.find;
6466
6757
  if (operation.type === "commentOnBlock") return operation.quote;
6467
6758
  };
6468
- export { SUGGESTED_SUPPORTED_OPERATION_TYPES, applyFolioAIEditOperations, applyFolioAIEditOperationsInPackage, insertCleanText, previewFolioAIEditOperations, previewFolioAIEditOperationsWithResult };
6759
+ export { SUGGESTED_SUPPORTED_OPERATION_TYPES, applyFolioAIEditOperations, applyFolioAIEditOperationsInPackage, buildSignatureTableNode, buildTableNode, insertCleanText, previewFolioAIEditOperations, previewFolioAIEditOperationsWithResult };