@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,362 @@
1
+ import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs } from "./attrs/index.js";
2
+ import { withCanonicalCommand } from "./canonicalCommands.js";
3
+ import { standaloneTableRowsFromProseMirror, tableAttrsToFormatting, tableCellAttrsToFormatting, tableRowAttrsToFormatting } from "./conversion/fromProseDoc.js";
4
+ import { isInTable, selectedRect } from "prosemirror-tables";
5
+ import { DOCUMENT_OP_TYPES } from "@stll/docx-core/ops";
6
+ // src/prosemirror/canonicalTableCommands.ts
7
+ const SCOPES = {
8
+ table: "table",
9
+ tableRow: "row",
10
+ tableCell: "cell",
11
+ tableHeader: "cell"
12
+ };
13
+ const isScoped = (name) => Object.hasOwn(SCOPES, name);
14
+ /** Keys whose saved value changed: the new value, or null where the key went. */
15
+ const patchBetween = (before, after) => {
16
+ const patch = {};
17
+ const keys = Object.keys({
18
+ ...before,
19
+ ...after
20
+ });
21
+ for (const key of keys) {
22
+ const was = before?.[key];
23
+ const is = after?.[key];
24
+ if (JSON.stringify(was) === JSON.stringify(is)) continue;
25
+ patch[key] = after !== void 0 && Object.hasOwn(after, key) ? is : null;
26
+ }
27
+ return patch;
28
+ };
29
+ /**
30
+ * The patch of the formatting the save writes for a table, row or cell node,
31
+ * between its attributes before and after the command, as a target at `at`.
32
+ */
33
+ const targetBetween = (scope, before, after, at) => {
34
+ switch (scope) {
35
+ case "table": return {
36
+ scope,
37
+ at,
38
+ patch: patchBetween(tableAttrsToFormatting(expectTableAttrs(before)), tableAttrsToFormatting(expectTableAttrs(after)))
39
+ };
40
+ case "row": return {
41
+ scope,
42
+ at,
43
+ patch: patchBetween(tableRowAttrsToFormatting(expectTableRowAttrs(before)), tableRowAttrsToFormatting(expectTableRowAttrs(after)))
44
+ };
45
+ case "cell": return {
46
+ scope,
47
+ at,
48
+ patch: patchBetween(tableCellAttrsToFormatting(expectTableCellAttrs(before)), tableCellAttrsToFormatting(expectTableCellAttrs(after)))
49
+ };
50
+ }
51
+ };
52
+ /**
53
+ * A position inside the first paragraph that belongs to the node itself, which
54
+ * addresses it. A paragraph of a nested table would address the inner table.
55
+ */
56
+ const firstParagraphPosition = (node, position) => {
57
+ let found;
58
+ node.descendants((child, offset) => {
59
+ if (found !== void 0 || child.type.name === "table") return false;
60
+ if (child.isTextblock) {
61
+ found = position + 1 + offset + 1;
62
+ return false;
63
+ }
64
+ return true;
65
+ });
66
+ return found;
67
+ };
68
+ /**
69
+ * What an attribute-only table command does, as table formatting patches.
70
+ *
71
+ * The command runs against the state without dispatching to the view. Every
72
+ * table, row and cell whose attributes it changed lowers to a patch of the
73
+ * formatting the save would write for it, so the session applies exactly what
74
+ * the editor would have saved. A command that changes anything else (content,
75
+ * a node's type, a span) has no attribute lowering and stays refused.
76
+ */
77
+ const lowerTableAttributeCommand = (command, state) => {
78
+ let transaction;
79
+ if (!command(state, (dispatched) => {
80
+ transaction = dispatched;
81
+ }) || transaction === void 0) return void 0;
82
+ const changed = transaction;
83
+ const targets = [];
84
+ const grids = [];
85
+ const expected = state.tr;
86
+ let lowerable = true;
87
+ state.doc.descendants((node, position) => {
88
+ if (!lowerable) return false;
89
+ if (!isScoped(node.type.name)) return true;
90
+ const after = changed.doc.nodeAt(changed.mapping.map(position, -1));
91
+ if (after === null || after.type !== node.type) {
92
+ lowerable = false;
93
+ return false;
94
+ }
95
+ if (after.attrs["colspan"] !== node.attrs["colspan"] || after.attrs["rowspan"] !== node.attrs["rowspan"]) {
96
+ lowerable = false;
97
+ return false;
98
+ }
99
+ if (JSON.stringify(after.attrs) === JSON.stringify(node.attrs)) return true;
100
+ expected.setNodeMarkup(position, void 0, after.attrs, node.marks);
101
+ const at = firstParagraphPosition(node, position);
102
+ if (node.type.name === "table") {
103
+ const grid = gridEdit(node, after, at);
104
+ if (grid === null) {
105
+ lowerable = false;
106
+ return false;
107
+ }
108
+ if (grid !== void 0) grids.push(grid);
109
+ }
110
+ const target = targetBetween(SCOPES[node.type.name], node, after, at ?? 0);
111
+ if (Object.keys(target.patch).length === 0) return true;
112
+ if (at === void 0) {
113
+ lowerable = false;
114
+ return false;
115
+ }
116
+ targets.push(target);
117
+ return true;
118
+ });
119
+ if (!lowerable || !expected.doc.eq(changed.doc)) return void 0;
120
+ return [...grids, ...targets.length === 0 ? [] : [{
121
+ type: "formatTable",
122
+ targets
123
+ }]];
124
+ };
125
+ /**
126
+ * The grid a command left on a table, as a grid edit: `undefined` when the
127
+ * grid is unchanged, `null` when the change cannot be written as a grid.
128
+ */
129
+ const gridEdit = (before, after, at) => {
130
+ const was = expectTableAttrs(before).columnWidths;
131
+ const is = expectTableAttrs(after).columnWidths;
132
+ if (JSON.stringify(was) === JSON.stringify(is)) return void 0;
133
+ if (at === void 0 || is === void 0 || is.length === 0) return null;
134
+ return {
135
+ type: "editTable",
136
+ at,
137
+ edit: {
138
+ type: DOCUMENT_OP_TYPES.SET_TABLE_GRID,
139
+ columnWidths: [...is]
140
+ }
141
+ };
142
+ };
143
+ /** Register a command whose whole effect is table, row and cell attributes. */
144
+ const withCanonicalTableAttributeCommand = (command) => withCanonicalCommand(command, (state) => lowerTableAttributeCommand(command, state));
145
+ /** A paragraph of the table's own, outside the given columns, that addresses it. */
146
+ const tableAnchor = (rect, avoid = {
147
+ left: 0,
148
+ right: 0
149
+ }) => {
150
+ const { map, table, tableStart } = rect;
151
+ for (let row = 0; row < map.height; row += 1) for (let column = 0; column < map.width; column += 1) {
152
+ if (column >= avoid.left && column < avoid.right) continue;
153
+ const offset = map.map[row * map.width + column];
154
+ if (offset === void 0) continue;
155
+ const cell = table.nodeAt(offset);
156
+ if (cell === null || cell.attrs["_omittedGridSlot"] != null) continue;
157
+ const cellRect = map.findCell(offset);
158
+ if (cellRect.left < avoid.right && cellRect.right > avoid.left) continue;
159
+ const at = firstParagraphPosition(cell, tableStart + offset);
160
+ if (at !== void 0) return at;
161
+ }
162
+ };
163
+ /**
164
+ * Register a command that changes a table's columns or cells, lowered from the
165
+ * selection it acts on to the engine's table edit. The command still runs
166
+ * against the state first: one it would refuse has no lowering.
167
+ */
168
+ const withCanonicalTableStructureCommand = (command, lower) => withCanonicalCommand(command, (state) => {
169
+ if (!isInTable(state)) return void 0;
170
+ let transaction;
171
+ if (!command(state, (dispatched) => {
172
+ transaction = dispatched;
173
+ }) || transaction === void 0) return void 0;
174
+ return lower(selectedRect(state), state, transaction);
175
+ });
176
+ /** The width the command gave the column it inserted, from the table it left. */
177
+ const insertedWidth = (rect, changed, column) => {
178
+ const after = changed.doc.nodeAt(changed.mapping.map(rect.tableStart - 1, -1));
179
+ if (after === null || after.type.name !== "table") return void 0;
180
+ return expectTableAttrs(after).columnWidths?.[column];
181
+ };
182
+ const insertColumn = (side) => (rect, _state, changed) => {
183
+ const column = side === "left" ? rect.left : rect.right;
184
+ const width = insertedWidth(rect, changed, column);
185
+ const at = tableAnchor(rect);
186
+ if (width === void 0 || at === void 0) return void 0;
187
+ return [{
188
+ type: "editTable",
189
+ at,
190
+ edit: {
191
+ type: DOCUMENT_OP_TYPES.INSERT_COLUMN,
192
+ column,
193
+ width
194
+ }
195
+ }];
196
+ };
197
+ /** Each selected column, from the right so the indices still hold. */
198
+ const deleteColumns = (rect) => {
199
+ const at = tableAnchor(rect, {
200
+ left: rect.left,
201
+ right: rect.right
202
+ });
203
+ if (at === void 0) return void 0;
204
+ const intents = [];
205
+ for (let column = rect.right - 1; column >= rect.left; column -= 1) intents.push({
206
+ type: "editTable",
207
+ at,
208
+ edit: {
209
+ type: DOCUMENT_OP_TYPES.DELETE_COLUMN,
210
+ column
211
+ }
212
+ });
213
+ return intents;
214
+ };
215
+ const mergeCells$1 = (rect) => {
216
+ const at = tableAnchor(rect);
217
+ if (at === void 0) return void 0;
218
+ return [{
219
+ type: "editTable",
220
+ at,
221
+ edit: {
222
+ type: DOCUMENT_OP_TYPES.MERGE_CELLS,
223
+ top: rect.top,
224
+ bottom: rect.bottom,
225
+ left: rect.left,
226
+ right: rect.right
227
+ }
228
+ }];
229
+ };
230
+ /** The cell at the selection's top left, addressed by its own paragraph. */
231
+ const splitCell$1 = (rect) => {
232
+ const offset = rect.map.map[rect.top * rect.map.width + rect.left];
233
+ const cell = offset === void 0 ? null : rect.table.nodeAt(offset);
234
+ if (offset === void 0 || cell === null) return void 0;
235
+ const at = firstParagraphPosition(cell, rect.tableStart + offset);
236
+ if (at === void 0) return void 0;
237
+ return [{
238
+ type: "editTable",
239
+ at,
240
+ edit: { type: DOCUMENT_OP_TYPES.SPLIT_CELL }
241
+ }];
242
+ };
243
+ const withCanonicalColumnInsertion = (command, side) => withCanonicalTableStructureCommand(command, insertColumn(side));
244
+ const withCanonicalColumnDeletion = (command) => withCanonicalTableStructureCommand(command, deleteColumns);
245
+ const withCanonicalCellMerge = (command) => withCanonicalTableStructureCommand(command, mergeCells$1);
246
+ const withCanonicalCellSplit = (command) => withCanonicalTableStructureCommand(command, splitCell$1);
247
+ /** A paragraph of the table's own in the given row. */
248
+ const rowAnchor = (rect, row) => {
249
+ const { map, table, tableStart } = rect;
250
+ for (let column = 0; column < map.width; column += 1) {
251
+ const offset = map.map[row * map.width + column];
252
+ if (offset === void 0) continue;
253
+ const cell = table.nodeAt(offset);
254
+ if (cell === null || cell.attrs["_omittedGridSlot"] != null) continue;
255
+ if (map.findCell(offset).top !== row) continue;
256
+ const at = firstParagraphPosition(cell, tableStart + offset);
257
+ if (at !== void 0) return at;
258
+ }
259
+ };
260
+ /**
261
+ * The row the command inserted, as the save would write it. Revision marks
262
+ * the command put on it are left to the engine, which records its own.
263
+ */
264
+ const insertedRow = (rect, changed, index) => {
265
+ const after = changed.doc.nodeAt(changed.mapping.map(rect.tableStart - 1, -1));
266
+ if (after === null || after.type.name !== "table") return void 0;
267
+ const row = standaloneTableRowsFromProseMirror(after)[index];
268
+ if (row === void 0) return void 0;
269
+ const { structuralChange: _structuralChange, propertyChanges: _propertyChanges, ...plain } = row;
270
+ return plain;
271
+ };
272
+ const insertRow = (side) => (rect, _state, changed) => {
273
+ const index = side === "above" ? rect.top : rect.bottom;
274
+ const row = insertedRow(rect, changed, index);
275
+ const at = rowAnchor(rect, side === "above" ? rect.top : rect.bottom - 1);
276
+ if (row === void 0 || at === void 0) return void 0;
277
+ return [{
278
+ type: "editTableRow",
279
+ at,
280
+ edit: {
281
+ type: DOCUMENT_OP_TYPES.INSERT_ROW,
282
+ at: index,
283
+ row
284
+ }
285
+ }];
286
+ };
287
+ /** Each selected row from the bottom, addressed by a paragraph of its own. */
288
+ const deleteRows = (rect) => {
289
+ const intents = [];
290
+ for (let row = rect.bottom - 1; row >= rect.top; row -= 1) {
291
+ const at = rowAnchor(rect, row);
292
+ if (at === void 0) return void 0;
293
+ intents.push({
294
+ type: "editTableRow",
295
+ at,
296
+ edit: { type: DOCUMENT_OP_TYPES.DELETE_ROW }
297
+ });
298
+ }
299
+ return intents;
300
+ };
301
+ const withCanonicalRowInsertion = (command, side) => withCanonicalTableStructureCommand(command, insertRow(side));
302
+ const withCanonicalRowDeletion = (command) => withCanonicalTableStructureCommand(command, deleteRows);
303
+ /** The table the selection is in, addressed by a paragraph of its own. */
304
+ const deleteTable = (rect) => {
305
+ const at = tableAnchor(rect);
306
+ if (at === void 0) return void 0;
307
+ return [{
308
+ type: "editTableBlock",
309
+ at,
310
+ edit: { type: DOCUMENT_OP_TYPES.DELETE_TABLE }
311
+ }];
312
+ };
313
+ const withCanonicalTableDeletion = (command) => withCanonicalTableStructureCommand(command, deleteTable);
314
+ /**
315
+ * Register the insert table command, lowered to a table and an empty
316
+ * paragraph after the paragraph that holds the caret, as the command places
317
+ * them. The table is the one the command built, without the revision marks
318
+ * it put on its rows; in suggesting mode the engine records its own.
319
+ */
320
+ const withCanonicalTableInsertion = (command) => withCanonicalCommand(command, (state) => {
321
+ const { $from } = state.selection;
322
+ let depth = $from.depth;
323
+ while (depth > 0 && $from.node(depth).type.name !== "paragraph" && $from.node(depth).type.name !== "table") depth -= 1;
324
+ const afterTable = depth > 0 && $from.node(depth).type.name === "table";
325
+ const atStart = depth === 0 && $from.pos === 0 && state.doc.firstChild?.type.name === "paragraph";
326
+ if (depth === 0 && !atStart) return void 0;
327
+ const following = afterTable ? state.doc.resolve($from.after(depth)).nodeAfter : null;
328
+ if (afterTable && following?.type.name !== "paragraph") return void 0;
329
+ let transaction;
330
+ if (!command(state, (dispatched) => {
331
+ transaction = dispatched;
332
+ }) || transaction === void 0) return void 0;
333
+ const at = atStart ? 0 : transaction.mapping.map($from.after(depth), -1);
334
+ const leading = afterTable ? transaction.doc.nodeAt(at) : null;
335
+ const inserted = transaction.doc.nodeAt(leading?.type.name === "paragraph" ? at + leading.nodeSize : at);
336
+ const before = atStart || afterTable;
337
+ const anchorPosition = () => {
338
+ if (atStart) return 1;
339
+ if (afterTable) return $from.after(depth) + 1;
340
+ return $from.start(depth);
341
+ };
342
+ if (inserted === null || inserted.type.name !== "table") return void 0;
343
+ const formatting = tableAttrsToFormatting(expectTableAttrs(inserted));
344
+ const columnWidths = expectTableAttrs(inserted).columnWidths;
345
+ const table = {
346
+ type: "table",
347
+ ...formatting === void 0 ? {} : { formatting },
348
+ ...columnWidths === void 0 ? {} : { columnWidths: [...columnWidths] },
349
+ rows: standaloneTableRowsFromProseMirror(inserted).map(({ structuralChange: _change, propertyChanges: _changes, ...row }) => row)
350
+ };
351
+ return [{
352
+ type: "editTableBlock",
353
+ at: anchorPosition(),
354
+ edit: {
355
+ type: DOCUMENT_OP_TYPES.INSERT_TABLE,
356
+ table,
357
+ ...before ? { side: "before" } : {},
358
+ ...afterTable ? { separated: true } : {}
359
+ }
360
+ }];
361
+ });
362
+ export { lowerTableAttributeCommand, withCanonicalCellMerge, withCanonicalCellSplit, withCanonicalColumnDeletion, withCanonicalColumnInsertion, withCanonicalRowDeletion, withCanonicalRowInsertion, withCanonicalTableAttributeCommand, withCanonicalTableDeletion, withCanonicalTableInsertion };
@@ -1,4 +1,6 @@
1
+ import { TrackedChangeEntry } from "../utils/extractTrackedChanges.js";
1
2
  import { Command, EditorState } from "prosemirror-state";
3
+ import { LockedControlViolation } from "@stll/docx-core/model";
2
4
  import { Mapping } from "prosemirror-transform";
3
5
  /**
4
6
  * Add a comment mark to the current selection.
@@ -18,6 +20,21 @@ export type ParagraphBoundaryChange = {
18
20
  revisionId?: number;
19
21
  };
20
22
  export declare function findParagraphBoundaryChangeAtPosition(state: EditorState, pos: number): ParagraphBoundaryChange | null;
23
+ /**
24
+ * What the content-control locks say about resolving the tracked changes
25
+ * between `from` and `to` (only those of `revisionIds`, when given): `null`
26
+ * when they allow it or there is nothing there to resolve. A revision whose
27
+ * resolution would change a content-locked control's content, or remove a
28
+ * control locked against removal, stays pending.
29
+ */
30
+ export declare const changeResolutionLockViolation: (state: EditorState, { from, to, mode, revisionIds }: {
31
+ from: number;
32
+ to: number;
33
+ mode: "accept" | "reject";
34
+ revisionIds?: readonly number[];
35
+ }) => LockedControlViolation | null;
36
+ /** {@link changeResolutionLockViolation} for the revisions `revisionIds`, wherever they are. */
37
+ export declare const revisionResolutionLockViolation: (state: EditorState, revisionIds: number | readonly number[], mode: "accept" | "reject") => LockedControlViolation | null;
21
38
  /**
22
39
  * Accept a tracked change at the given range.
23
40
  * - Insertion: remove mark, keep text
@@ -39,6 +56,14 @@ export declare function acceptAllChanges(): Command;
39
56
  * Reject all tracked changes in the document.
40
57
  */
41
58
  export declare function rejectAllChanges(): Command;
59
+ /**
60
+ * The revisions of `state` that a content control's lock keeps from being
61
+ * resolved in `mode`, each with the lock's verdict: see
62
+ * {@link changeResolutionLockViolation}. Empty without a locked control.
63
+ */
64
+ export declare const lockHeldRevisions: (state: EditorState, mode: "accept" | "reject") => Map<number, LockedControlViolation>;
65
+ /** Every revision id one sidebar entry stands for. */
66
+ export declare const trackedChangeEntryRevisionIds: (entry: TrackedChangeEntry) => number[];
42
67
  /**
43
68
  * Resolve a complete state synchronously for a headless reader or writer.
44
69
  *
@@ -74,13 +99,16 @@ export declare function acceptAIEditRevision(revisionIds: number | readonly numb
74
99
  * See {@link acceptAIEditRevision} for the id semantics.
75
100
  */
76
101
  export declare function rejectAIEditRevision(revisionIds: number | readonly number[]): Command;
77
- export type SuggestionKind = "insertion" | "deletion" | "formatting" | "insertBlock" | "insertTable" | "insertRow" | "deleteRow" | "insertColumn" | "deleteColumn";
102
+ /** The ids of the comments a pending suggestion proposes. */
103
+ export declare function suggestionCommentIds(state: EditorState, suggestionId: string): number[];
104
+ export type SuggestionKind = "insertion" | "deletion" | "formatting" | "insertBlock" | "insertTable" | "insertRow" | "deleteRow" | "insertColumn" | "deleteColumn" | "comment";
78
105
  /**
79
106
  * How a suggestion is applied when accepted:
80
107
  * - `"tracked"` — converts to a normal OOXML tracked change (`w:ins`/`w:del`,
81
108
  * paragraph-mark `w:ins`, row/cell `w:ins`/`w:del`);
82
109
  * - `"direct"` — no OOXML tracked representation exists (a whole inserted
83
- * table), so accepting applies it directly;
110
+ * table), so accepting applies it directly; a suggestion that only
111
+ * proposes a comment is accepted as an ordinary comment;
84
112
  * - `"mixed"` — a heterogeneous group (one `suggestionId` spanning a whole
85
113
  * inserted table AND other edits) whose parts apply both ways. Accept still
86
114
  * resolves the whole group in one transaction; this flag lets the host