@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,12 @@
1
+ import { document_d_exports } from "../types/document.js";
2
+ /**
3
+ * Why the session cannot hold these stories of `document`, or `null`: the
4
+ * first block it cannot hold, else the first paragraph whose content it
5
+ * cannot hold, in each story in turn.
6
+ */
7
+ export declare const unsupportedSeedReason: (document: document_d_exports.Document, stories?: import("@stll/docx-core/ops").OpStory[]) => string | null;
8
+ /**
9
+ * The same verdict from one walk of every story, judging nothing once: the
10
+ * reference the block judgments above must equal.
11
+ */
12
+ export declare const unsupportedSeedReasonWholeDocument: (document: document_d_exports.Document, stories?: import("@stll/docx-core/ops").OpStory[]) => string | null;
@@ -0,0 +1,131 @@
1
+ import { canonicalInlineSourceIssue } from "./canonicalInlineProjection.js";
2
+ import { OP_STORIES, commentDocumentIssue, documentStories, findStoryBody } from "@stll/docx-core/ops";
3
+ // src/controller/canonicalSeedContent.ts
4
+ const STRUCTURE_ISSUE = "Canonical sessions currently require paragraphs, tables and supported inline atoms.";
5
+ const REVIEW_CARRIER_ISSUE = "Canonical sessions currently require plain paragraphs and supported inline atoms.";
6
+ /** Range markers may open or close between blocks; they hold no text. */
7
+ const BETWEEN_BLOCK_MARKERS = /* @__PURE__ */ new Set([
8
+ "commentRangeStart",
9
+ "commentRangeEnd",
10
+ "bookmarkStart",
11
+ "bookmarkEnd",
12
+ "moveFromRangeStart",
13
+ "moveFromRangeEnd",
14
+ "moveToRangeStart",
15
+ "moveToRangeEnd"
16
+ ]);
17
+ const issuesIn = (block) => {
18
+ const paragraphs = [];
19
+ const collect = (blocks) => {
20
+ for (const child of blocks) {
21
+ if (child.type === "paragraph") {
22
+ paragraphs.push(child);
23
+ continue;
24
+ }
25
+ if (BETWEEN_BLOCK_MARKERS.has(child.type)) continue;
26
+ if (child.type === "preservedBlock") continue;
27
+ if (child.type === "blockSdt") {
28
+ const issue = collect(child.content);
29
+ if (issue !== null) return issue;
30
+ continue;
31
+ }
32
+ if (child.type !== "table") return STRUCTURE_ISSUE;
33
+ for (const row of child.rows) for (const cell of row.cells) {
34
+ const issue = collect(cell.content);
35
+ if (issue !== null) return issue;
36
+ }
37
+ }
38
+ return null;
39
+ };
40
+ const structure = collect([block]);
41
+ let paragraph = null;
42
+ for (const candidate of paragraphs) {
43
+ paragraph = candidate.reviewCarrier === void 0 ? canonicalInlineSourceIssue(candidate.content) : REVIEW_CARRIER_ISSUE;
44
+ if (paragraph !== null) break;
45
+ }
46
+ return {
47
+ structure,
48
+ paragraph
49
+ };
50
+ };
51
+ const blockIssues = /* @__PURE__ */ new WeakMap();
52
+ const issuesOf = (block) => {
53
+ let issues = blockIssues.get(block);
54
+ if (issues === void 0) {
55
+ issues = issuesIn(block);
56
+ blockIssues.set(block, issues);
57
+ }
58
+ return issues;
59
+ };
60
+ /**
61
+ * Why the session cannot hold these stories of `document`, or `null`: the
62
+ * first block it cannot hold, else the first paragraph whose content it
63
+ * cannot hold, in each story in turn.
64
+ */
65
+ const unsupportedSeedReason = (document, stories = documentStories(document)) => {
66
+ const commentIssue = commentDocumentIssue(document, "all");
67
+ if (commentIssue !== void 0) return commentIssue;
68
+ for (const story of stories) {
69
+ const body = findStoryBody(document, story);
70
+ if (story !== OP_STORIES.MAIN && (story.kind === "footnote" || story.kind === "endnote")) {
71
+ const note = (story.kind === "footnote" ? document.package.footnotes : document.package.endnotes)?.find(({ id }) => id === story.id);
72
+ if (note?.noteType !== void 0 && note.noteType !== "normal") continue;
73
+ }
74
+ const content = body?.content;
75
+ if (!content || content.length === 0) return "Canonical sessions require a nonempty paragraph story.";
76
+ const issues = content.map(issuesOf);
77
+ const structure = issues.find((issue) => issue.structure !== null);
78
+ if (structure !== void 0) return structure.structure;
79
+ const paragraph = issues.find((issue) => issue.paragraph !== null);
80
+ if (paragraph !== void 0) return paragraph.paragraph;
81
+ }
82
+ return null;
83
+ };
84
+ /**
85
+ * The same verdict from one walk of every story, judging nothing once: the
86
+ * reference the block judgments above must equal.
87
+ */
88
+ const unsupportedSeedReasonWholeDocument = (document, stories = documentStories(document)) => {
89
+ const commentIssue = commentDocumentIssue(document, "all");
90
+ if (commentIssue !== void 0) return commentIssue;
91
+ for (const story of stories) {
92
+ const body = findStoryBody(document, story);
93
+ if (story !== OP_STORIES.MAIN && (story.kind === "footnote" || story.kind === "endnote")) {
94
+ const note = (story.kind === "footnote" ? document.package.footnotes : document.package.endnotes)?.find(({ id }) => id === story.id);
95
+ if (note?.noteType !== void 0 && note.noteType !== "normal") continue;
96
+ }
97
+ const content = body?.content;
98
+ if (!content || content.length === 0) return "Canonical sessions require a nonempty paragraph story.";
99
+ const paragraphs = [];
100
+ const collect = (blocks) => {
101
+ for (const block of blocks) {
102
+ if (block.type === "paragraph") {
103
+ paragraphs.push(block);
104
+ continue;
105
+ }
106
+ if (block.type === "commentRangeStart" || block.type === "commentRangeEnd" || block.type === "bookmarkStart" || block.type === "bookmarkEnd" || block.type === "moveFromRangeStart" || block.type === "moveFromRangeEnd" || block.type === "moveToRangeStart" || block.type === "moveToRangeEnd") continue;
107
+ if (block.type === "preservedBlock") continue;
108
+ if (block.type === "blockSdt") {
109
+ const issue = collect(block.content);
110
+ if (issue !== null) return issue;
111
+ continue;
112
+ }
113
+ if (block.type !== "table") return "Canonical sessions currently require paragraphs, tables and supported inline atoms.";
114
+ for (const row of block.rows) for (const cell of row.cells) {
115
+ const issue = collect(cell.content);
116
+ if (issue !== null) return issue;
117
+ }
118
+ }
119
+ return null;
120
+ };
121
+ const blockIssue = collect(content);
122
+ if (blockIssue !== null) return blockIssue;
123
+ for (const paragraph of paragraphs) {
124
+ if (paragraph.reviewCarrier !== void 0) return "Canonical sessions currently require plain paragraphs and supported inline atoms.";
125
+ const issue = canonicalInlineSourceIssue(paragraph.content);
126
+ if (issue !== null) return issue;
127
+ }
128
+ }
129
+ return null;
130
+ };
131
+ export { unsupportedSeedReason, unsupportedSeedReasonWholeDocument };
@@ -1,7 +1,12 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
- import { CanonicalGap } from "../types/canonicalCapabilities.js";
2
+ import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
3
+ import { CommentMarkerCache } from "../docx/commentAnchorIndex.js";
4
+ import { ListNormalizationCache } from "../docx/listModelNormalization.js";
5
+ import { ProjectionBlockCache } from "../prosemirror/conversion/toProseDoc.js";
3
6
  import { CanonicalSaveSnapshot } from "../types/canonicalSave.js";
4
- import { CanonicalInlineGap } from "./canonicalInlineProjection.js";
7
+ import { InlineProjectionCache } from "./canonicalInlineProjection.js";
8
+ import { ParagraphAddress, ParagraphIdIndex, ProjectedBlock, StoryProjectionFacts } from "./canonicalProjectionBlocks.js";
9
+ import { CanonicalSourceRestore } from "./canonicalSourceNormalization.js";
5
10
  import { Node } from "prosemirror-model";
6
11
  import { EditorState, Transaction } from "prosemirror-state";
7
12
  import { Err, Ok, Result, TaggedErrorClass } from "better-result";
@@ -9,8 +14,8 @@ import { DocumentOp, EditorIntent, OpStory, TextPosition, TouchedBlocks } from "
9
14
  declare const CanonicalSessionErrorBase: TaggedErrorClass<"CanonicalSessionError">;
10
15
  export declare class CanonicalSessionError extends CanonicalSessionErrorBase<{
11
16
  message: string;
12
- gap: CanonicalGap;
13
17
  reason: "refused" | "noChange";
18
+ ground: CanonicalRefusalGround;
14
19
  }> {}
15
20
  export type CanonicalSelection = {
16
21
  type: "text" | "inlineNode" | "cell" | "all";
@@ -25,34 +30,105 @@ export type CanonicalSessionMode = {
25
30
  author: string;
26
31
  };
27
32
  export declare const CANONICAL_PROJECTION_META = "folioCanonicalProjection";
28
- type ParagraphAddress = {
29
- blockId: string;
30
- container: readonly document_d_exports.BlockContent[];
31
- start: number;
32
- text: string;
33
- boundaries: readonly (readonly CanonicalInlineGap[])[];
34
- node: Node;
35
- source: document_d_exports.Paragraph;
36
- };
33
+ /**
34
+ * Which source gap an editor position names where invisible markers (comment
35
+ * ranges, bookmarks, permission ranges, proofing marks) share it: a caret
36
+ * takes the gap typed text takes (the seam's own gap); `afterMarkers` takes the
37
+ * seam's last gap and `beforeMarkers` its first.
38
+ */
39
+ export type CanonicalAddressEdge = "caret" | "afterMarkers" | "beforeMarkers";
37
40
  type CanonicalProjectionOptions = {
38
41
  doc: Node;
39
- paragraphs: readonly ParagraphAddress[];
40
42
  story: OpStory;
43
+ /** The story's blocks the projection was made from. */
44
+ content: readonly document_d_exports.BlockContent[];
45
+ /** One per top-level node of `doc`, in order. */
46
+ blocks: readonly ProjectedBlock[];
47
+ index: ParagraphIdIndex;
48
+ facts: StoryProjectionFacts;
49
+ /**
50
+ * Whether the next projection may keep this one's blocks: each top-level
51
+ * node was projected from the story block at its index alone, and no two
52
+ * source paragraphs share an id.
53
+ */
54
+ reusable: boolean;
41
55
  };
42
56
  /** Paragraph gaps bind logical units and source zero-width ordinals to PM positions. */
43
57
  declare class CanonicalProjection {
44
58
  readonly doc: Node;
45
59
  readonly story: OpStory;
46
- private readonly paragraphs;
47
- private readonly paragraphsById;
48
- constructor({ doc, paragraphs, story }: CanonicalProjectionOptions);
49
- addressAt(position: number): Result<TextPosition, CanonicalSessionError>;
50
- inputAddressAt(position: number): Result<TextPosition, CanonicalSessionError>;
60
+ readonly content: readonly document_d_exports.BlockContent[];
61
+ readonly blocks: readonly ProjectedBlock[];
62
+ readonly index: ParagraphIdIndex;
63
+ readonly facts: StoryProjectionFacts;
64
+ readonly reusable: boolean;
65
+ /** Where each top-level node starts. */
66
+ private readonly starts;
67
+ private readonly addresses;
68
+ constructor(options: CanonicalProjectionOptions,
69
+ /** What a projection of an equal document already worked out. */
70
+ held?: {
71
+ starts: readonly number[];
72
+ addresses: Map<string, ParagraphAddress>;
73
+ });
74
+ /**
75
+ * The same projection held as `doc`, a document equal to this one's. A
76
+ * commit's transaction ends on a document equal to the projection it staged,
77
+ * sharing the blocks it left; holding that document lets the next commit see
78
+ * the state it was given is the projection without comparing every node.
79
+ */
80
+ heldAs(doc: Node): CanonicalProjection;
81
+ private addressOf;
82
+ /** The paragraph whose content holds `position`, its ends included. */
83
+ private paragraphAround;
84
+ addressAt(position: number, edge?: CanonicalAddressEdge): Result<TextPosition, CanonicalSessionError>;
85
+ /**
86
+ * The source gaps a selection from `from` to `to` replaces between. Its
87
+ * edges stay inside the markers beside them, so replacing exactly the
88
+ * words a comment covers keeps the comment on the new text. A selection of
89
+ * a paragraph's whole text takes that paragraph's markers with it: an edge
90
+ * at the very start of a paragraph whose text the selection covers to its
91
+ * end reaches before the markers there, and an edge at the very end of a
92
+ * paragraph the selection covers from its start reaches after them, so a
93
+ * comment on nothing but the replaced text is emptied, as removing the
94
+ * text would empty it.
95
+ */
96
+ rangeEdgesAt(from: number, to: number): {
97
+ start: CanonicalAddressEdge;
98
+ end: CanonicalAddressEdge;
99
+ };
100
+ inputAddressAt(position: number, edge?: CanonicalAddressEdge): Result<TextPosition, CanonicalSessionError>;
51
101
  positionAt(address: TextPosition): Result<number, CanonicalSessionError>;
52
102
  selectionAt(state: EditorState): Result<CanonicalSelection, CanonicalSessionError>;
103
+ /** The first paragraph the projection addresses, in document order. */
104
+ get firstParagraph(): ParagraphAddress | undefined;
53
105
  paragraph(blockId: string): ParagraphAddress | undefined;
106
+ /** The paragraph whose node starts at `before`. */
107
+ paragraphStartingAt(before: number): ParagraphAddress | undefined;
54
108
  nextParagraphInContainer(blockId: string): ParagraphAddress | undefined;
55
109
  }
110
+ /** A session's projection pieces, reused by every projection of its stories. */
111
+ type StoryProjectionCaches = {
112
+ /** The main story's converted blocks. */
113
+ blocks: ProjectionBlockCache;
114
+ /** Each paragraph's gaps, by its source and editor node. */
115
+ inline: InlineProjectionCache;
116
+ /** Each story's normalized list rendering, by block and the counters before it. */
117
+ lists: ListNormalizationCache;
118
+ /** Each paragraph's comment markers, by its source. */
119
+ comments: CommentMarkerCache;
120
+ };
121
+ export declare const newStoryProjectionCaches: () => StoryProjectionCaches;
122
+ type ProjectStoryOptions = {
123
+ document: document_d_exports.Document;
124
+ styles: document_d_exports.StyleDefinitions | null | undefined;
125
+ story?: OpStory;
126
+ /** What earlier projections converted, kept by its session. */
127
+ caches?: StoryProjectionCaches;
128
+ /** A projection of the story whose top-level blocks this one may keep. */
129
+ previous?: CanonicalProjection;
130
+ };
131
+ declare const project: ({ document, styles, story, caches, previous }: ProjectStoryOptions) => Result<CanonicalProjection, CanonicalSessionError>;
56
132
  /** Input intent, never projection-step adjacency, determines the journal partition. */
57
133
  export type CanonicalInputSemantic = "typing" | "deleteBackward" | "deleteForward" | "paste" | "composition" | "replacement" | "structure";
58
134
  export type CanonicalCommit = {
@@ -64,6 +140,8 @@ export type CanonicalCommit = {
64
140
  touched: TouchedBlocks;
65
141
  version: number;
66
142
  origin: CanonicalOrigin;
143
+ /** Revisions a content control lock held back; they stay pending. */
144
+ lockHeld?: readonly number[];
67
145
  /** Publish only after every projection/plugin transaction has been accepted. */
68
146
  publish: () => Result<void, CanonicalSessionError>;
69
147
  };
@@ -83,6 +161,9 @@ type CanonicalSessionSeedOptions = {
83
161
  document: document_d_exports.Document;
84
162
  projection: CanonicalProjection;
85
163
  styles: document_d_exports.StyleDefinitions | null | undefined;
164
+ /** Stories the session reads in its own spelling, given back as read while unedited. */
165
+ sourceRestores?: readonly CanonicalSourceRestore[];
166
+ caches: StoryProjectionCaches;
86
167
  };
87
168
  type CanonicalReplaceTextInput = {
88
169
  from: number;
@@ -117,7 +198,10 @@ declare class CanonicalSession {
117
198
  private lifecycle;
118
199
  private readonly undone;
119
200
  private readonly styles;
120
- constructor({ document, projection, styles }: CanonicalSessionSeedOptions);
201
+ private readonly sourceRestores;
202
+ /** What earlier projections converted, reused by every later one. */
203
+ private readonly caches;
204
+ constructor({ document, projection, styles, sourceRestores, caches }: CanonicalSessionSeedOptions);
121
205
  /** Render only the committed comment projection while provisional IME blocks document snapshots. */
122
206
  getCommittedComments(): document_d_exports.Comment[];
123
207
  setMode(mode: CanonicalSessionMode): void;
@@ -136,7 +220,11 @@ declare class CanonicalSession {
136
220
  get document(): document_d_exports.Document;
137
221
  captureSaveSnapshot(): CanonicalSaveSnapshot;
138
222
  get projection(): CanonicalProjection;
223
+ /** The caret the last published edit returned, when the editor shows it at `position`. */
224
+ private editCaretAt;
139
225
  get selection(): CanonicalSelection | null;
226
+ /** Every paragraph identity this session has read or minted, live or retired. */
227
+ get reservedBlockIds(): ReadonlySet<string>;
140
228
  get version(): number;
141
229
  get canUndo(): boolean;
142
230
  get canRedo(): boolean;
@@ -146,6 +234,15 @@ declare class CanonicalSession {
146
234
  endComposition(): void;
147
235
  private checkState;
148
236
  prepareReplace(state: EditorState, { from, to, text, story, semantic, compositionPhase, time }: CanonicalReplaceTextInput): Result<CanonicalCommit, CanonicalSessionError>;
237
+ /**
238
+ * A structural edit over selected cells: each selected cell is cleared and
239
+ * the edit happens at the start of the first, as the editor's own command
240
+ * does over a cell selection. One commit, so one undo step.
241
+ */
242
+ prepareCellSelectionStructure(state: EditorState, structure: (at: TextPosition) => EditorIntent, { resourceOps, semantic }?: {
243
+ resourceOps?: readonly DocumentOp[];
244
+ semantic?: CanonicalInputSemantic;
245
+ }): Result<CanonicalCommit, CanonicalSessionError>;
149
246
  prepareIntent(state: EditorState, intent: EditorIntent): Result<CanonicalCommit, CanonicalSessionError>;
150
247
  prepareIntents(state: EditorState, { intents, resourceOps, semantic }: {
151
248
  intents: readonly EditorIntent[];
@@ -156,9 +253,24 @@ declare class CanonicalSession {
156
253
  private prepareJournalledOps;
157
254
  prepareSplit(state: EditorState): Result<CanonicalCommit, CanonicalSessionError>;
158
255
  prepareJoin(state: EditorState, direction: "backward" | "forward"): Result<CanonicalCommit, CanonicalSessionError>;
159
- prepareResolve(state: EditorState, { revisionIds, resolution }: {
256
+ prepareResolve(state: EditorState, { revisionIds, resolution, before }: {
160
257
  revisionIds: readonly number[];
161
258
  resolution: "accept" | "reject";
259
+ /** Operations applied ahead of the resolution, in the same commit. */
260
+ before?: readonly DocumentOp[];
261
+ }): Result<CanonicalCommit, CanonicalSessionError>;
262
+ /**
263
+ * Accept or reject one pending suggestion. Rejecting it rejects its
264
+ * revisions and removes the comments it proposes. Accepting it adopts its
265
+ * revisions as ordinary tracked changes by `author`, keeping their ids, as
266
+ * the editor does: the change then waits for review like any other. Its
267
+ * comments stay as ordinary comments.
268
+ */
269
+ prepareSuggestion(state: EditorState, { suggestionId, resolution, author, date }: {
270
+ suggestionId: string;
271
+ resolution: "accept" | "reject";
272
+ author: string;
273
+ date: string;
162
274
  }): Result<CanonicalCommit, CanonicalSessionError>;
163
275
  projectStory(story: OpStory): Result<CanonicalProjection, CanonicalSessionError>;
164
276
  prepareOperations(state: EditorState, ops: readonly DocumentOp[]): Result<CanonicalCommit, CanonicalSessionError>;
@@ -173,4 +285,4 @@ export declare const deletionRange: (state: EditorState, direction: "backward" |
173
285
  from: number;
174
286
  to: number;
175
287
  }, CanonicalSessionError>;
176
- export type { CanonicalProjection, CanonicalSession };
288
+ export { type CanonicalProjection, type CanonicalSession, project as projectCanonicalStory };