@stll/folio-core 0.67.0 → 0.69.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 (350) hide show
  1. package/dist/ai-edits/apply.d.ts +9 -1
  2. package/dist/ai-edits/apply.js +94 -8
  3. package/dist/ai-edits/headless.d.ts +36 -21
  4. package/dist/ai-edits/headless.js +106 -36
  5. package/dist/ai-edits/index.d.ts +2 -2
  6. package/dist/ai-edits/newListNumbering.d.ts +14 -1
  7. package/dist/ai-edits/newListNumbering.js +24 -1
  8. package/dist/ai-edits/note-references.d.ts +6 -0
  9. package/dist/ai-edits/note-references.js +7 -1
  10. package/dist/ai-edits/pending-suggestions.js +2 -2
  11. package/dist/ai-edits/read.d.ts +19 -0
  12. package/dist/ai-edits/snapshot.d.ts +6 -0
  13. package/dist/ai-edits/snapshot.js +8 -3
  14. package/dist/ai-edits/types.d.ts +9 -1
  15. package/dist/ai-suggestions/apply.js +13 -4
  16. package/dist/compare/compare.js +2 -1
  17. package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
  18. package/dist/compare/inserted-resource-snapshot.js +7 -3
  19. package/dist/controller/canonicalClipboard.js +31 -14
  20. package/dist/controller/canonicalComposition.js +35 -6
  21. package/dist/controller/canonicalInlineProjection.d.ts +35 -10
  22. package/dist/controller/canonicalInlineProjection.js +192 -28
  23. package/dist/controller/canonicalInput.d.ts +2 -1
  24. package/dist/controller/canonicalInput.js +32 -7
  25. package/dist/controller/canonicalListRendering.d.ts +2 -1
  26. package/dist/controller/canonicalListRendering.js +1 -1
  27. package/dist/controller/canonicalLockGuard.d.ts +23 -0
  28. package/dist/controller/canonicalLockGuard.js +133 -0
  29. package/dist/controller/canonicalProjectionBlocks.d.ts +79 -0
  30. package/dist/controller/canonicalProjectionBlocks.js +75 -0
  31. package/dist/controller/canonicalPublicOperations.d.ts +12 -4
  32. package/dist/controller/canonicalPublicOperations.js +676 -46
  33. package/dist/controller/canonicalSeedContent.d.ts +12 -0
  34. package/dist/controller/canonicalSeedContent.js +131 -0
  35. package/dist/controller/canonicalSession.d.ts +133 -21
  36. package/dist/controller/canonicalSession.js +738 -205
  37. package/dist/controller/canonicalSourceNormalization.d.ts +21 -0
  38. package/dist/controller/canonicalSourceNormalization.js +148 -0
  39. package/dist/controller/canonicalStoryEditor.d.ts +4 -3
  40. package/dist/controller/canonicalStoryEditor.js +20 -15
  41. package/dist/controller/canonicalStructure.d.ts +2 -1
  42. package/dist/controller/canonicalStructure.js +129 -7
  43. package/dist/controller/contentControlWidgetController.d.ts +5 -0
  44. package/dist/controller/contentControlWidgetController.js +13 -1
  45. package/dist/controller/folioEditor.js +4 -0
  46. package/dist/controller/headerFooterEditorManager.d.ts +7 -2
  47. package/dist/controller/headerFooterEditorManager.js +11 -6
  48. package/dist/controller/hiddenEditorApi.d.ts +17 -2
  49. package/dist/controller/hiddenEditorApi.js +4 -0
  50. package/dist/controller/hiddenEditorManager.d.ts +11 -3
  51. package/dist/controller/hiddenEditorManager.js +157 -48
  52. package/dist/controller/layoutPipeline.js +50 -16
  53. package/dist/controller/layoutSession.d.ts +3 -0
  54. package/dist/controller/layoutSession.js +3 -1
  55. package/dist/controller/noteEditorManager.d.ts +7 -2
  56. package/dist/controller/noteEditorManager.js +11 -6
  57. package/dist/display-list/build/pageFurniture.js +41 -19
  58. package/dist/display-list/build/tablePrimitives.js +23 -4
  59. package/dist/display-list/dom/renderDisplayListToDom.js +13 -11
  60. package/dist/document-operations.d.ts +9 -1
  61. package/dist/document-operations.js +4 -3
  62. package/dist/docx/blockContentParser.d.ts +7 -3
  63. package/dist/docx/blockContentParser.js +2 -3
  64. package/dist/docx/blockPlainText.js +2 -0
  65. package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
  66. package/dist/docx/bookmarkRangeJoin.js +43 -0
  67. package/dist/docx/canonicalSave.js +11 -2
  68. package/dist/docx/canonicalSessionInput.d.ts +5 -1
  69. package/dist/docx/canonicalSessionInput.js +7 -2
  70. package/dist/docx/commentAnchorIndex.d.ts +40 -5
  71. package/dist/docx/commentAnchorIndex.js +94 -12
  72. package/dist/docx/commentRangeIntegrity.js +30 -24
  73. package/dist/docx/commentRangeJoin.d.ts +4 -0
  74. package/dist/docx/commentRangeJoin.js +26 -12
  75. package/dist/docx/commentReferenceCompletion.js +5 -4
  76. package/dist/docx/commentReferenceNormalization.js +40 -18
  77. package/dist/docx/compatibility.js +9 -2
  78. package/dist/docx/containerChildren.js +22 -1
  79. package/dist/docx/contentTypeRegistry.js +1 -1
  80. package/dist/docx/encryption/compoundFile.js +9 -1
  81. package/dist/docx/encryption/encryptionInfo.js +16 -2
  82. package/dist/docx/ensureParaIds.js +46 -7
  83. package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
  84. package/dist/docx/ensureUniqueControlIds.js +110 -0
  85. package/dist/docx/headerFooterVerbatim.d.ts +7 -0
  86. package/dist/docx/headerFooterVerbatim.js +13 -2
  87. package/dist/docx/hostCommentThreads.d.ts +27 -0
  88. package/dist/docx/hostCommentThreads.js +72 -0
  89. package/dist/docx/hyperlinkParser.js +9 -2
  90. package/dist/docx/inlineWrapperContent.d.ts +8 -1
  91. package/dist/docx/inlineWrapperContent.js +9 -2
  92. package/dist/docx/listMarkerComputation.d.ts +35 -1
  93. package/dist/docx/listMarkerComputation.js +39 -1
  94. package/dist/docx/listModelNormalization.d.ts +44 -1
  95. package/dist/docx/listModelNormalization.js +226 -96
  96. package/dist/docx/listNumberingInstances.d.ts +1 -1
  97. package/dist/docx/listNumberingInstances.js +2 -2
  98. package/dist/docx/markupRangeMarker.d.ts +14 -0
  99. package/dist/docx/markupRangeMarker.js +15 -1
  100. package/dist/docx/metadataPrivacy.js +43 -22
  101. package/dist/docx/normalizeBaseDirection.js +3 -1
  102. package/dist/docx/numberingIds.d.ts +6 -0
  103. package/dist/docx/numberingIds.js +6 -1
  104. package/dist/docx/numberingReferenceNormalization.d.ts +4 -0
  105. package/dist/docx/numberingReferenceNormalization.js +12 -2
  106. package/dist/docx/paragraphParser.js +159 -48
  107. package/dist/docx/paragraphPropertySource.d.ts +29 -0
  108. package/dist/docx/paragraphPropertySource.js +106 -16
  109. package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
  110. package/dist/docx/paragraphTraversal.js +2 -0
  111. package/dist/docx/parseWarningMessage.js +2 -1
  112. package/dist/docx/parser.js +8 -0
  113. package/dist/docx/removeHeaderFooterParts.js +1 -1
  114. package/dist/docx/renderedPageBreakNormalization.js +1 -1
  115. package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
  116. package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
  117. package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
  118. package/dist/docx/reviewResolutionProvenance.js +171 -33
  119. package/dist/docx/rezip.d.ts +6 -0
  120. package/dist/docx/rezip.js +38 -21
  121. package/dist/docx/selectiveSave.js +6 -10
  122. package/dist/docx/selectiveXmlPatch.d.ts +5 -4
  123. package/dist/docx/selectiveXmlPatch.js +11 -7
  124. package/dist/docx/serializer/documentSerializer.js +5 -2
  125. package/dist/docx/serializer/headerFooterSerializer.js +3 -1
  126. package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
  127. package/dist/docx/serializer/markupRangeAttributes.js +6 -1
  128. package/dist/docx/serializer/noteSerializer.d.ts +17 -4
  129. package/dist/docx/serializer/noteSerializer.js +23 -16
  130. package/dist/docx/serializer/paragraphSerializer.js +56 -12
  131. package/dist/docx/serializer/partNamespaces.d.ts +1 -1
  132. package/dist/docx/serializer/partNamespaces.js +1 -1
  133. package/dist/docx/serializer/runSerializer.d.ts +1 -3
  134. package/dist/docx/serializer/runSerializer.js +2 -2
  135. package/dist/docx/serializer/tableSerializer.d.ts +4 -0
  136. package/dist/docx/serializer/tableSerializer.js +4 -2
  137. package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
  138. package/dist/docx/server/build.d.ts +1 -1
  139. package/dist/docx/server/createBilingualDocument.js +27 -5
  140. package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
  141. package/dist/docx/sessionListPruning.d.ts +2 -0
  142. package/dist/docx/sessionListPruning.js +50 -0
  143. package/dist/docx/splitRevisionPieces.d.ts +10 -0
  144. package/dist/docx/splitRevisionPieces.js +14 -0
  145. package/dist/docx/storyBlockReplay.js +19 -2
  146. package/dist/docx/structuralXmlPatch.js +44 -11
  147. package/dist/docx/tableParser.d.ts +6 -2
  148. package/dist/docx/tableParser.js +2 -3
  149. package/dist/docx/textBoxContentParser.d.ts +11 -0
  150. package/dist/docx/textBoxContentParser.js +51 -0
  151. package/dist/docx/textBoxParser.d.ts +0 -5
  152. package/dist/docx/textBoxParser.js +1 -23
  153. package/dist/docx/verticalMergeProjection.js +1 -1
  154. package/dist/docx/xmlParser.d.ts +1 -1
  155. package/dist/docx/xmlParser.js +2 -3
  156. package/dist/fonts/fontsourceFaces.d.ts +2 -8
  157. package/dist/fonts/fontsourceFaces.js +1 -7
  158. package/dist/i18n/messages/ar.gen.js +3 -0
  159. package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
  160. package/dist/i18n/messages/catalogs.gen.js +51 -0
  161. package/dist/i18n/messages/cs.gen.js +3 -0
  162. package/dist/i18n/messages/de.gen.js +3 -0
  163. package/dist/i18n/messages/en.gen.js +3 -0
  164. package/dist/i18n/messages/es.gen.js +3 -0
  165. package/dist/i18n/messages/et.gen.js +3 -0
  166. package/dist/i18n/messages/fr.gen.js +3 -0
  167. package/dist/i18n/messages/he.gen.js +3 -0
  168. package/dist/i18n/messages/hi.gen.js +3 -0
  169. package/dist/i18n/messages/hu.gen.js +3 -0
  170. package/dist/i18n/messages/lt.gen.js +3 -0
  171. package/dist/i18n/messages/lv.gen.js +3 -0
  172. package/dist/i18n/messages/messages.gen.d.ts +3 -0
  173. package/dist/i18n/messages/pl.gen.js +3 -0
  174. package/dist/i18n/messages/pt-BR.gen.js +3 -0
  175. package/dist/i18n/messages/sk.gen.js +3 -0
  176. package/dist/i18n/messages/tr.gen.js +3 -0
  177. package/dist/i18n/messages/zh-CN.gen.js +3 -0
  178. package/dist/internal/acceptedBlockProjection.js +2 -0
  179. package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
  180. package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
  181. package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
  182. package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
  183. package/dist/internal/revisionResolutionInline.js +1 -2
  184. package/dist/internal/subtreeHolds.d.ts +12 -0
  185. package/dist/internal/subtreeHolds.js +25 -0
  186. package/dist/internal/wholeStoryRevisionResolution.js +1 -1
  187. package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
  188. package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
  189. package/dist/layout-bridge/convert/flowConversionShared.d.ts +15 -1
  190. package/dist/layout-bridge/convert/flowConversionShared.js +9 -1
  191. package/dist/layout-bridge/convert/paragraphAttrs.d.ts +15 -4
  192. package/dist/layout-bridge/convert/paragraphAttrs.js +11 -4
  193. package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +26 -0
  194. package/dist/layout-bridge/convert/paragraphBlockCache.js +137 -0
  195. package/dist/layout-bridge/convert/paragraphConversion.d.ts +12 -2
  196. package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
  197. package/dist/layout-bridge/convert/paragraphRuns.d.ts +2 -2
  198. package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
  199. package/dist/layout-bridge/convert/tableConversion.js +19 -8
  200. package/dist/layout-bridge/convert/toFlowBlocks.js +144 -15
  201. package/dist/layout-bridge/convert/topLevelConversion.d.ts +74 -0
  202. package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
  203. package/dist/layout-bridge/dom/clickToPositionDom.js +41 -40
  204. package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
  205. package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
  206. package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
  207. package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
  208. package/dist/layout-bridge/dom/textStreamDom.js +3 -2
  209. package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
  210. package/dist/layout-bridge/engine/blockIndex.js +12 -0
  211. package/dist/layout-bridge/engine/hitTest.js +9 -10
  212. package/dist/layout-bridge/engine/selectionRects.js +6 -6
  213. package/dist/layout-bridge/headerFooterLayout.js +12 -11
  214. package/dist/layout-bridge/tableInsertHover.js +2 -1
  215. package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
  216. package/dist/layout-engine/footnoteContinuation.js +210 -0
  217. package/dist/layout-engine/index.d.ts +2 -2
  218. package/dist/layout-engine/index.js +7 -2
  219. package/dist/layout-engine/measure/cache.d.ts +2 -0
  220. package/dist/layout-engine/measure/cache.js +16 -6
  221. package/dist/layout-engine/measure/measureParagraph.js +1 -1
  222. package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +8 -0
  223. package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
  224. package/dist/layout-engine/tableLayout.js +29 -5
  225. package/dist/layout-engine/tableRowBreak.d.ts +36 -0
  226. package/dist/layout-engine/tableRowBreak.js +43 -1
  227. package/dist/layout-engine/types.d.ts +42 -1
  228. package/dist/layout-painter/imageLayout.js +2 -1
  229. package/dist/layout-painter/pageShellStyles.d.ts +10 -0
  230. package/dist/layout-painter/pageShellStyles.js +32 -0
  231. package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
  232. package/dist/layout-painter/reconcileRenderedContent.js +117 -0
  233. package/dist/layout-painter/renderFragment.js +4 -6
  234. package/dist/layout-painter/renderImage.js +2 -2
  235. package/dist/layout-painter/renderPage.d.ts +4 -4
  236. package/dist/layout-painter/renderPage.js +54 -46
  237. package/dist/layout-painter/renderParagraph.js +3 -3
  238. package/dist/layout-painter/renderTable.js +16 -16
  239. package/dist/layout-painter/renderTextBox.js +2 -2
  240. package/dist/layout-painter/sdtBoundary.js +3 -2
  241. package/dist/managers/AutoSaveManager.d.ts +5 -1
  242. package/dist/managers/FindReplaceManager.js +3 -10
  243. package/dist/markdown/escape.d.ts +20 -1
  244. package/dist/markdown/escape.js +43 -1
  245. package/dist/markdown/renderBlock.js +4 -1
  246. package/dist/markdown/renderParagraph.js +13 -27
  247. package/dist/markdown/renderTable.js +6 -2
  248. package/dist/markdown/trailers.js +1 -0
  249. package/dist/paged-layout/blockGeometry.js +3 -2
  250. package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
  251. package/dist/paged-layout/editorScrollRoot.js +10 -1
  252. package/dist/paged-layout/rangeProjection.js +5 -4
  253. package/dist/paged-layout/scrollToPmPosition.js +3 -3
  254. package/dist/paged-layout/selectionViewportRect.d.ts +6 -0
  255. package/dist/paged-layout/selectionViewportRect.js +8 -2
  256. package/dist/pdf/images.d.ts +17 -1
  257. package/dist/pdf/images.js +22 -4
  258. package/dist/pdf/writePdf.js +4 -2
  259. package/dist/prosemirror/attrs/index.js +2 -0
  260. package/dist/prosemirror/canonicalCommands.d.ts +39 -1
  261. package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
  262. package/dist/prosemirror/canonicalTableCommands.js +362 -0
  263. package/dist/prosemirror/commands/comments.d.ts +30 -2
  264. package/dist/prosemirror/commands/comments.js +189 -18
  265. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  266. package/dist/prosemirror/commands/index.d.ts +1 -1
  267. package/dist/prosemirror/commentIdAllocator.js +2 -2
  268. package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
  269. package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
  270. package/dist/prosemirror/commentRecords.d.ts +137 -0
  271. package/dist/prosemirror/commentRecords.js +400 -0
  272. package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
  273. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
  274. package/dist/prosemirror/conversion/fromProseDoc.js +85 -34
  275. package/dist/prosemirror/conversion/index.d.ts +2 -2
  276. package/dist/prosemirror/conversion/toProseDoc.d.ts +140 -4
  277. package/dist/prosemirror/conversion/toProseDoc.js +432 -76
  278. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  279. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  280. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
  281. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
  282. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
  283. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +23 -1
  284. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +61 -32
  285. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
  286. package/dist/prosemirror/extensions/marks/CommentExtension.js +8 -3
  287. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
  288. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
  289. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
  290. package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
  291. package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
  292. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
  293. package/dist/prosemirror/index.d.ts +3 -3
  294. package/dist/prosemirror/listLabels.js +3 -2
  295. package/dist/prosemirror/listNumbering.d.ts +6 -0
  296. package/dist/prosemirror/listNumbering.js +12 -9
  297. package/dist/prosemirror/lockedControls.d.ts +13 -0
  298. package/dist/prosemirror/lockedControls.js +106 -0
  299. package/dist/prosemirror/markupViewProjection.js +1 -1
  300. package/dist/prosemirror/nativeSelection.d.ts +33 -0
  301. package/dist/prosemirror/nativeSelection.js +74 -0
  302. package/dist/prosemirror/noteReferenceReview.js +2 -2
  303. package/dist/prosemirror/numberedRefFields.d.ts +2 -0
  304. package/dist/prosemirror/numberedRefFields.js +16 -5
  305. package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -8
  306. package/dist/prosemirror/paragraphMarkJoin.js +155 -16
  307. package/dist/prosemirror/plugins/contentControlWidgets.js +2 -2
  308. package/dist/prosemirror/plugins/documentNumbering.js +37 -15
  309. package/dist/prosemirror/plugins/suggestionMode.js +33 -10
  310. package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
  311. package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
  312. package/dist/prosemirror/replacedAnnotations.js +1 -0
  313. package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
  314. package/dist/prosemirror/runFormattingFromMarks.js +2 -4
  315. package/dist/prosemirror/runFormattingReconciliation.js +2 -2
  316. package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +23 -1
  317. package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
  318. package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
  319. package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
  320. package/dist/prosemirror/runStyleFormatting.js +16 -13
  321. package/dist/prosemirror/schema/marks.d.ts +13 -1
  322. package/dist/prosemirror/storyListNumbering.js +7 -2
  323. package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
  324. package/dist/prosemirror/tableResize.d.ts +10 -9
  325. package/dist/prosemirror/tableResize.js +60 -49
  326. package/dist/prosemirror/textInput.d.ts +30 -1
  327. package/dist/prosemirror/textInput.js +144 -17
  328. package/dist/prosemirror/utils/visualLineNavigation.js +20 -18
  329. package/dist/prosemirror/validation.d.ts +19 -0
  330. package/dist/prosemirror/validation.js +79 -5
  331. package/dist/redline.js +23 -9
  332. package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
  333. package/dist/render-dom/RenderedDomContext.js +7 -6
  334. package/dist/server.d.ts +2 -2
  335. package/dist/style-sets/extract.js +2 -2
  336. package/dist/types/canonicalCapabilities.d.ts +38 -16
  337. package/dist/types/canonicalCapabilities.js +21 -18
  338. package/dist/utils/cssString.d.ts +7 -0
  339. package/dist/utils/cssString.js +9 -0
  340. package/dist/utils/findMatchView.js +4 -3
  341. package/dist/utils/fontResolver.js +4 -1
  342. package/dist/utils/formatToStyle.d.ts +1 -1
  343. package/dist/utils/mergeDocumentContent.js +2 -2
  344. package/dist/utils/paintedPositions.d.ts +60 -0
  345. package/dist/utils/paintedPositions.js +101 -0
  346. package/dist/utils/replaceText.d.ts +11 -0
  347. package/dist/utils/replaceText.js +39 -7
  348. package/dist/version-comparison.d.ts +9 -1
  349. package/dist/version-comparison.js +11 -5
  350. package/package.json +2 -3
@@ -0,0 +1,400 @@
1
+ import "./commentIdAllocator.js";
2
+ import { isCommentRangeBoundaryNode, readCommentRangeBoundaryAttrs } from "./commentRangeBoundaryAttrs.js";
3
+ import { readCommentReferenceAttrs } from "./commentReferenceAttrs.js";
4
+ import "./commentReferenceIntegrity.js";
5
+ import "./extensions/nodes/RangeAnchorExtension.js";
6
+ import { createPluginKeyOwner } from "./pluginKeyOwner.js";
7
+ import { SUGGESTION_BYPASS_META } from "./plugins/suggestionMode.js";
8
+ import { readRangeAnchorAttrs } from "./rangeAnchorAttrs.js";
9
+ import { panic } from "better-result";
10
+ import { Step, StepMap, StepResult } from "prosemirror-transform";
11
+ import { Plugin, Selection } from "prosemirror-state";
12
+ import { closeHistory } from "prosemirror-history";
13
+ // src/prosemirror/commentRecords.ts
14
+ /**
15
+ * The comment threads of a ProseMirror session, held in its editor state.
16
+ *
17
+ * A thread's text, author, replies and resolution live beside the document,
18
+ * not in it, yet they are part of what the user edits: deleting a comment
19
+ * removes its record and its anchors together, and undoing that has to bring
20
+ * both back. Keeping the records in a host list outside the editor made every
21
+ * comment edit invisible to the editor's history, so undo restored the anchor
22
+ * at best and the save then lost the thread.
23
+ *
24
+ * Here the records change only through {@link CommentRecordsStep}, a step that
25
+ * leaves the document as it is and inverts to the records it replaced. Every
26
+ * comment edit is a transaction holding that step and, when the anchors
27
+ * change too, the mark and node steps beside it, so history undoes and redoes
28
+ * a comment edit as one. Hosts mirror the records from the state; saving, the
29
+ * controlled `comments` prop and document operations read the same records.
30
+ */
31
+ const STEP_TYPE = "folioCommentRecords";
32
+ /**
33
+ * Replace the session's comment records. The document is unchanged, so the
34
+ * step maps nothing; its inverse puts back the records it replaced.
35
+ */
36
+ var CommentRecordsStep = class CommentRecordsStep extends Step {
37
+ before;
38
+ after;
39
+ constructor(before, after) {
40
+ super();
41
+ this.before = before;
42
+ this.after = after;
43
+ }
44
+ apply(doc) {
45
+ return StepResult.ok(doc);
46
+ }
47
+ getMap() {
48
+ return StepMap.empty;
49
+ }
50
+ invert() {
51
+ return new CommentRecordsStep(this.after, this.before);
52
+ }
53
+ map() {
54
+ return this;
55
+ }
56
+ merge(other) {
57
+ return other instanceof CommentRecordsStep && other.before === this.after ? new CommentRecordsStep(this.before, other.after) : null;
58
+ }
59
+ toJSON() {
60
+ return {
61
+ stepType: STEP_TYPE,
62
+ before: this.before,
63
+ after: this.after
64
+ };
65
+ }
66
+ static fromJSON(_schema, json) {
67
+ if (typeof json !== "object" || json === null || !("before" in json) || !("after" in json) || !Array.isArray(json.before) || !Array.isArray(json.after)) throw new RangeError("Invalid comment records step JSON");
68
+ const { before, after } = json;
69
+ return new CommentRecordsStep(before, after);
70
+ }
71
+ };
72
+ Step.jsonID(STEP_TYPE, CommentRecordsStep);
73
+ const commentRecordsOwner = createPluginKeyOwner("commentRecords");
74
+ const SYNC_META = `${commentRecordsOwner.key}.sync`;
75
+ const listeners = /* @__PURE__ */ new WeakMap();
76
+ /**
77
+ * The plugin that holds a session's comment records, starting from `initial`
78
+ * (the loaded document's comments).
79
+ */
80
+ function createCommentRecordsPlugin(initial) {
81
+ return new Plugin({
82
+ key: commentRecordsOwner.createKey(),
83
+ state: {
84
+ init: () => ({
85
+ records: initial,
86
+ origin: "sync"
87
+ }),
88
+ apply: (transaction, value) => {
89
+ let records = value.records;
90
+ for (const step of transaction.steps) if (step instanceof CommentRecordsStep) records = step.after;
91
+ if (records === value.records) return value;
92
+ return {
93
+ records,
94
+ origin: transaction.getMeta(SYNC_META) === true ? "sync" : "edit"
95
+ };
96
+ }
97
+ },
98
+ view: (created) => {
99
+ const current = commentRecordsOwner.getState(created.state);
100
+ if (current) for (const listener of listeners.get(created) ?? []) listener(current.records, "sync");
101
+ return {
102
+ update: (view, previous) => {
103
+ const next = commentRecordsOwner.getState(view.state);
104
+ if (!next || next === commentRecordsOwner.getState(previous)) return;
105
+ for (const listener of listeners.get(view) ?? []) listener(next.records, next.origin);
106
+ },
107
+ destroy: () => {
108
+ for (const listener of listeners.get(created) ?? []) listener(null, "sync");
109
+ }
110
+ };
111
+ }
112
+ });
113
+ }
114
+ /** The session's comment records, or `null` when the state holds none. */
115
+ function commentRecordsOf(state) {
116
+ return commentRecordsOwner.getState(state)?.records ?? null;
117
+ }
118
+ /**
119
+ * Call `listener` whenever the view's comment records change, including a
120
+ * state the view is given for a newly loaded document. Returns the
121
+ * unsubscribe function.
122
+ */
123
+ function subscribeCommentRecords(view, listener) {
124
+ let set = listeners.get(view);
125
+ if (!set) {
126
+ set = /* @__PURE__ */ new Set();
127
+ listeners.set(view, set);
128
+ }
129
+ set.add(listener);
130
+ return () => {
131
+ set.delete(listener);
132
+ };
133
+ }
134
+ /** The records a transaction ends on, given the state it started from. */
135
+ function commentRecordsAfter(state, transaction) {
136
+ let records = commentRecordsOf(state);
137
+ if (records === null) return null;
138
+ for (const step of transaction.steps) if (step instanceof CommentRecordsStep) records = step.after;
139
+ return records;
140
+ }
141
+ /**
142
+ * Add the step replacing the records `transaction` ends on with `next`.
143
+ * Returns false when the state holds no records.
144
+ */
145
+ function stepCommentRecords(state, transaction, next) {
146
+ const current = commentRecordsAfter(state, transaction);
147
+ if (current === null) return false;
148
+ if (current !== next) transaction.step(new CommentRecordsStep(current, next));
149
+ return true;
150
+ }
151
+ /**
152
+ * A transaction writing a host's value into the records: kept out of the
153
+ * undo history and reported as `sync`, so it is not echoed back to the host.
154
+ */
155
+ function syncCommentRecords(state, next) {
156
+ const current = commentRecordsOf(state);
157
+ if (current === null || current === next) return null;
158
+ return state.tr.step(new CommentRecordsStep(current, next)).setMeta("addToHistory", false).setMeta(SYNC_META, true);
159
+ }
160
+ /**
161
+ * Whether a transaction only writes a host's comment list in: no document
162
+ * content and no user edit changes, so it neither marks the document changed
163
+ * nor needs an editable document.
164
+ */
165
+ function isCommentRecordsSync(transaction) {
166
+ return transaction.getMeta(SYNC_META) === true && transaction.steps.length > 0 && transaction.steps.every((step) => step instanceof CommentRecordsStep);
167
+ }
168
+ /** A comment and every reply whose parent chain reaches it. */
169
+ function commentThreadIds(records, id) {
170
+ const ids = /* @__PURE__ */ new Set([id]);
171
+ let added = true;
172
+ while (added) {
173
+ added = false;
174
+ for (const comment of records) if (!ids.has(comment.id) && comment.parentId !== void 0 && ids.has(comment.parentId)) {
175
+ ids.add(comment.id);
176
+ added = true;
177
+ }
178
+ }
179
+ return ids;
180
+ }
181
+ const editTransaction = (state) => closeHistory(state.tr).setMeta(SUGGESTION_BYPASS_META, true);
182
+ /**
183
+ * An undoable edit replacing the records with `next`, for a host change that
184
+ * touches no anchor (a reply, a resolution, a list the host computed).
185
+ */
186
+ function editCommentRecords(state, next) {
187
+ const records = commentRecordsOf(state);
188
+ if (records === null || records === next) return null;
189
+ const tr = editTransaction(state);
190
+ stepCommentRecords(state, tr, next);
191
+ return tr;
192
+ }
193
+ /** Append comments (new threads or replies) to the records. */
194
+ function appendCommentRecords(state, additions) {
195
+ const records = commentRecordsOf(state);
196
+ if (records === null || additions.length === 0) return null;
197
+ const tr = editTransaction(state);
198
+ stepCommentRecords(state, tr, [...records, ...additions]);
199
+ return tr;
200
+ }
201
+ /** Mark one comment resolved or open again. */
202
+ function setCommentResolved(state, id, done) {
203
+ const records = commentRecordsOf(state);
204
+ if (records === null) return null;
205
+ const index = records.findIndex((comment) => comment.id === id);
206
+ const comment = records[index];
207
+ if (!comment || (comment.done ?? false) === done) return null;
208
+ const next = records.with(index, {
209
+ ...comment,
210
+ done
211
+ });
212
+ const tr = editTransaction(state);
213
+ stepCommentRecords(state, tr, next);
214
+ return tr;
215
+ }
216
+ const clampRange = (state, range) => {
217
+ const size = state.doc.content.size;
218
+ const from = Math.max(0, Math.min(range.from, size));
219
+ const to = Math.max(from, Math.min(range.to, size));
220
+ return from === to ? null : {
221
+ from,
222
+ to
223
+ };
224
+ };
225
+ /**
226
+ * Anchor a new thread on `range` and add its record, in one transaction.
227
+ * Returns null when the range is empty or out of the document.
228
+ */
229
+ function addCommentThread(state, range, comment) {
230
+ const records = commentRecordsOf(state);
231
+ const commentType = state.schema.marks["comment"];
232
+ const safe = clampRange(state, range);
233
+ if (records === null || !commentType || !safe) return null;
234
+ const tr = editTransaction(state).addMark(safe.from, safe.to, commentType.create({ commentId: comment.id }));
235
+ stepCommentRecords(state, tr, [...records, comment]);
236
+ return tr;
237
+ }
238
+ /**
239
+ * Show the add-comment flow's highlight on `range`. The highlight is not an
240
+ * edit: it stays out of the undo history, so undoing a comment never brings
241
+ * it back.
242
+ */
243
+ function markPendingComment(view, range, options) {
244
+ const commentType = view.state.schema.marks["comment"];
245
+ const safe = clampRange(view.state, range);
246
+ if (!commentType || !safe) return false;
247
+ const tr = view.state.tr.addMark(safe.from, safe.to, commentType.create({ commentId: -1 })).setMeta("addToHistory", false).setMeta(SUGGESTION_BYPASS_META, true);
248
+ if (options?.selectEnd) tr.setSelection(Selection.near(tr.doc.resolve(safe.to), -1));
249
+ view.dispatch(tr);
250
+ return true;
251
+ }
252
+ /** Remove the add-comment flow's highlight from `range`. */
253
+ function clearPendingComment(view, range) {
254
+ const commentType = view.state.schema.marks["comment"];
255
+ const safe = clampRange(view.state, range);
256
+ if (!commentType || !safe) return;
257
+ const pending = commentType.create({ commentId: -1 });
258
+ if (!view.state.doc.rangeHasMark(safe.from, safe.to, pending)) return;
259
+ view.dispatch(view.state.tr.removeMark(safe.from, safe.to, pending).setMeta("addToHistory", false).setMeta(SUGGESTION_BYPASS_META, true));
260
+ }
261
+ /**
262
+ * The add-comment flow's commit: the highlight on `range` gives way to the
263
+ * new thread's mark, and the thread joins the records, as one undoable edit.
264
+ */
265
+ function commitCommentThread(view, range, comment) {
266
+ if (!addCommentThread(view.state, range, comment)) return false;
267
+ clearPendingComment(view, range);
268
+ const tr = addCommentThread(view.state, range, comment);
269
+ if (!tr) return false;
270
+ view.dispatch(tr);
271
+ return true;
272
+ }
273
+ const anchoredCommentId = (node) => {
274
+ if (node.type.name === "commentReference") {
275
+ const attrs = readCommentReferenceAttrs(node);
276
+ return attrs.ok ? attrs.value.commentId : void 0;
277
+ }
278
+ if (isCommentRangeBoundaryNode(node)) {
279
+ const attrs = readCommentRangeBoundaryAttrs(node);
280
+ return attrs.ok ? attrs.value.marker.id : void 0;
281
+ }
282
+ if (node.type.name === "rangeAnchor") {
283
+ const attrs = readRangeAnchorAttrs(node);
284
+ return attrs.ok && attrs.value.start.type === "commentRangeStart" ? attrs.value.start.id : void 0;
285
+ }
286
+ };
287
+ /**
288
+ * Remove every anchor of the comments in `ids` from the transaction's
289
+ * document: their `comment` marks, references and range boundaries.
290
+ */
291
+ function removeCommentAnchors(transaction, ids) {
292
+ const marks = [];
293
+ const nodes = [];
294
+ transaction.doc.descendants((node, position) => {
295
+ for (const mark of node.marks) {
296
+ const commentId = mark.attrs["commentId"];
297
+ if (mark.type.name === "comment" && typeof commentId === "number" && ids.has(commentId)) marks.push({
298
+ from: position,
299
+ to: position + node.nodeSize,
300
+ mark
301
+ });
302
+ }
303
+ const anchored = anchoredCommentId(node);
304
+ if (anchored !== void 0 && ids.has(anchored)) {
305
+ nodes.push({
306
+ from: position,
307
+ to: position + node.nodeSize
308
+ });
309
+ return false;
310
+ }
311
+ return true;
312
+ });
313
+ for (const { from, to, mark } of marks) transaction.removeMark(from, to, mark);
314
+ for (const { from, to } of nodes.toReversed()) transaction.delete(from, to);
315
+ }
316
+ /** Delete a thread: its record, every reply under it, and its anchors. */
317
+ function deleteCommentThread(state, id) {
318
+ const records = commentRecordsOf(state);
319
+ if (records === null) return null;
320
+ const ids = commentThreadIds(records, id);
321
+ const next = records.filter((comment) => !ids.has(comment.id));
322
+ const tr = editTransaction(state);
323
+ removeCommentAnchors(tr, ids);
324
+ stepCommentRecords(state, tr, next);
325
+ return tr.steps.length > 0 ? tr : null;
326
+ }
327
+ /**
328
+ * The comment ids a document names through a mark, reference or range
329
+ * boundary.
330
+ */
331
+ function commentIdsNamedIn(doc) {
332
+ const ids = /* @__PURE__ */ new Set();
333
+ doc.descendants((node) => {
334
+ for (const mark of node.marks) {
335
+ const commentId = mark.attrs["commentId"];
336
+ if (mark.type.name === "comment" && typeof commentId === "number") ids.add(commentId);
337
+ }
338
+ const anchored = anchoredCommentId(node);
339
+ if (anchored !== void 0) ids.add(anchored);
340
+ return true;
341
+ });
342
+ return ids;
343
+ }
344
+ /**
345
+ * Remove the threads a review resolution left without any anchor: accepting
346
+ * the deletion of everything a comment covers, or rejecting the suggestion
347
+ * that inserted it, retires the comment with its replies, in the same
348
+ * transaction. Other edits keep records whose anchors are gone for now (a
349
+ * cut keeps the thread for the paste).
350
+ */
351
+ function retireThreadsResolvedAway(state, transaction) {
352
+ if (transaction.doc === state.doc) return;
353
+ const records = commentRecordsAfter(state, transaction);
354
+ if (records === null || records.length === 0) return;
355
+ const before = commentIdsNamedIn(state.doc);
356
+ if (before.size === 0) return;
357
+ const after = commentIdsNamedIn(transaction.doc);
358
+ const retired = /* @__PURE__ */ new Set();
359
+ for (const id of before) {
360
+ if (after.has(id) || id === -1) continue;
361
+ for (const threadId of commentThreadIds(records, id)) retired.add(threadId);
362
+ }
363
+ if (retired.size === 0) return;
364
+ const next = records.filter(({ id }) => !retired.has(id));
365
+ if (next.length !== records.length) stepCommentRecords(state, transaction, next);
366
+ }
367
+ /**
368
+ * Add the records of `created` comments that `transaction`'s document names
369
+ * and the records lack, so comments a document operation anchors join the
370
+ * records in the operation's own transaction.
371
+ */
372
+ function recordCreatedComments(state, transaction, created) {
373
+ if (created.length === 0) return;
374
+ const records = commentRecordsAfter(state, transaction);
375
+ if (records === null) return;
376
+ const known = new Set(records.map(({ id }) => id));
377
+ const named = commentIdsNamedIn(transaction.doc);
378
+ const additions = created.filter(({ id }) => named.has(id) && !known.has(id));
379
+ if (additions.length > 0) stepCommentRecords(state, transaction, [...records, ...additions]);
380
+ }
381
+ /**
382
+ * `view` for a document operation: its dispatch adds the records of the
383
+ * `created` comments the operation anchors, in the operation's transaction.
384
+ */
385
+ function recordingCommentsView(view, created) {
386
+ return {
387
+ get state() {
388
+ return view.state;
389
+ },
390
+ dispatch: (transaction) => {
391
+ recordCreatedComments(view.state, transaction, created);
392
+ view.dispatch(transaction);
393
+ }
394
+ };
395
+ }
396
+ /** Panic unless the state holds records; for callers that require them. */
397
+ function expectCommentRecords(state) {
398
+ return commentRecordsOf(state) ?? panic("The editor state holds no comments.");
399
+ }
400
+ export { CommentRecordsStep, addCommentThread, appendCommentRecords, clearPendingComment, commentIdsNamedIn, commentRecordsAfter, commentRecordsOf, commentThreadIds, commitCommentThread, createCommentRecordsPlugin, deleteCommentThread, editCommentRecords, expectCommentRecords, isCommentRecordsSync, markPendingComment, recordCreatedComments, recordingCommentsView, removeCommentAnchors, retireThreadsResolvedAway, setCommentResolved, stepCommentRecords, subscribeCommentRecords, syncCommentRecords };
@@ -1,7 +1,6 @@
1
- import { readCommentRangeBoundaryAttrs } from "./commentRangeBoundaryAttrs.js";
1
+ import { isCommentRangeBoundaryNode, readCommentRangeBoundaryAttrs } from "./commentRangeBoundaryAttrs.js";
2
2
  import { isCommentRangeInertAtom } from "./commentRangeInlineAtoms.js";
3
3
  import { readCommentReferenceAttrs } from "./commentReferenceAttrs.js";
4
- import "./extensions/nodes/CommentRangeBoundaryExtension.js";
5
4
  import "./extensions/nodes/RangeAnchorExtension.js";
6
5
  import { readRangeAnchorAttrs } from "./rangeAnchorAttrs.js";
7
6
  import { panic } from "better-result";
@@ -43,7 +42,7 @@ const surveyCommentReferences = (doc) => {
43
42
  }
44
43
  return false;
45
44
  }
46
- if (node.type.name === "commentRangeBoundary") {
45
+ if (isCommentRangeBoundaryNode(node)) {
47
46
  const attrs = readCommentRangeBoundaryAttrs(node);
48
47
  if (attrs.ok) {
49
48
  const { id } = attrs.value.marker;
@@ -54,7 +53,7 @@ const surveyCommentReferences = (doc) => {
54
53
  if (inert) return false;
55
54
  if (!node.isInline) return true;
56
55
  for (const mark of node.marks) {
57
- if (mark.type.name !== "comment") continue;
56
+ if (mark.type.name !== "comment" || mark.attrs["point"] === true) continue;
58
57
  const commentId = mark.attrs["commentId"];
59
58
  if (typeof commentId !== "number") continue;
60
59
  markEnds.set(commentId, Math.max(markEnds.get(commentId) ?? 0, position + node.nodeSize));
@@ -41,6 +41,8 @@ export declare function tableAttrsToFormatting(attrs: TableAttrs): document_d_ex
41
41
  */
42
42
  export declare function tableRowAttrsToFormatting(attrs: TableRowAttrs): document_d_exports.TableRowFormatting | undefined;
43
43
  export declare const standaloneTableCellFromProseMirror: (node: Node) => document_d_exports.TableCell;
44
+ /** A table node's rows as the save writes them, vertical merges included. */
45
+ export declare const standaloneTableRowsFromProseMirror: (node: Node) => document_d_exports.TableRow[];
44
46
  export declare function tableCellAttrsToFormatting(attrs: TableCellAttrs): document_d_exports.TableCellFormatting | undefined;
45
47
  /**
46
48
  * Update a Document with content from a ProseMirror document