@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
@@ -20,6 +20,7 @@ import { PasteStyleInlinerExtension } from "./features/PasteStyleInlinerExtensio
20
20
  import { SelectionTrackerExtension } from "./features/SelectionTrackerExtension.js";
21
21
  import { MARK_EXTENSIONS, MARK_NESTING_ORDER } from "./markRegistry.js";
22
22
  import { BlockBookmarkBoundaryExtension } from "./nodes/BlockBookmarkBoundaryExtension.js";
23
+ import { BlockCommentRangeBoundaryExtension } from "./nodes/BlockCommentRangeBoundaryExtension.js";
23
24
  import { BlockCustomXmlExtension } from "./nodes/BlockCustomXmlExtension.js";
24
25
  import { BlockMoveRangeBoundaryExtension } from "./nodes/BlockMoveRangeBoundaryExtension.js";
25
26
  import { BlockSdtExtension } from "./nodes/BlockSdtExtension.js";
@@ -73,6 +74,7 @@ function createStarterKit(options = {}) {
73
74
  add("bookmarkBoundary", BookmarkBoundaryExtension({ getInternalClipboardToken }));
74
75
  add("blockBookmarkBoundary", BlockBookmarkBoundaryExtension({ getInternalClipboardToken }));
75
76
  add("blockMoveRangeBoundary", BlockMoveRangeBoundaryExtension({ getInternalClipboardToken }));
77
+ add("blockCommentRangeBoundary", BlockCommentRangeBoundaryExtension());
76
78
  add("commentReference", CommentReferenceExtension({ getInternalClipboardToken }));
77
79
  add("commentRangeBoundary", CommentRangeBoundaryExtension({ getInternalClipboardToken }));
78
80
  add("moveRangeBoundary", MoveRangeBoundaryExtension({ getInternalClipboardToken }));
@@ -14,7 +14,7 @@ const DocExtension = createNodeExtension({
14
14
  _adjustLineHeightInTable: { default: false },
15
15
  _doNotUseIndentAsNumberingTabStop: { default: false }
16
16
  },
17
- content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary)+"
17
+ content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary | blockCommentRangeBoundary)+"
18
18
  }
19
19
  });
20
20
  export { DocExtension };
@@ -22,4 +22,4 @@ export declare const autoBidiDetectionKey: Readonly<{
22
22
  * document already carried, is unaffected — it always round-trips.
23
23
  */
24
24
  export declare const ensureBaseDirectionInState: (state: EditorState) => EditorState;
25
- export declare const AutoBidiDetectionExtension: (options?: Partial<{}> | undefined) => Extension;
25
+ export declare const AutoBidiDetectionExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
@@ -1,3 +1,3 @@
1
1
  import { Extension } from "../types.js";
2
2
  export declare const JOINED_RUNS_RESTYLED_META = "joinedRunsRestyled";
3
- export declare const JoinedRunStyleExtension: (options?: Partial<{}> | undefined) => Extension;
3
+ export declare const JoinedRunStyleExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
@@ -52,5 +52,5 @@ export declare const mapParagraphKeepers: (oldDoc: Node, transactions: readonly
52
52
  export declare const ensureParaIdsInDoc: (doc: Node) => Node;
53
53
  /** {@link ensureParaIdsInDoc} for a state that already exists. */
54
54
  export declare const ensureParaIdsInState: (state: EditorState) => EditorState;
55
- export declare const ParaIdAllocatorExtension: (options?: Partial<{}> | undefined) => Extension;
55
+ export declare const ParaIdAllocatorExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
56
56
  export {};
@@ -35,6 +35,28 @@ type InternalParagraphChangeTrackerState = ParagraphChangeTrackerState & {
35
35
  /** The section records themselves, by identity. */
36
36
  sectionRecords: ReadonlySet<document_d_exports.SectionProperties>;
37
37
  };
38
+ type DocumentStructureCounts = {
39
+ blockStructureFingerprint: string;
40
+ sectionRecords: ReadonlySet<document_d_exports.SectionProperties>;
41
+ paragraphs: number;
42
+ /**
43
+ * Distinct section records the paragraphs carry, which is the number of
44
+ * `w:sectPr` the package states for them. A split copies a node's attrs, so
45
+ * both halves of a split section-ending paragraph hold one record until the
46
+ * from-leg keeps it on the trailing half: one section, not two.
47
+ */
48
+ sectionEndpoints: number;
49
+ sectionEndpointFingerprint: string;
50
+ };
51
+ /**
52
+ * Count the structural values the tracker compares for every transaction.
53
+ *
54
+ * Each top-level block's records are kept for the block node, so a keystroke
55
+ * recomputes only the block it changed. The fingerprint joins the blocks'
56
+ * records in order: two documents' fingerprints are equal exactly when their
57
+ * full record lists (every block and nested block with its path) are.
58
+ */
59
+ export declare function countDocumentStructure(doc: Node): DocumentStructureCounts;
38
60
  export declare function createParagraphChangeTrackerPlugin(): Plugin<InternalParagraphChangeTrackerState>;
39
61
  /**
40
62
  * Get the change tracker state from an EditorState
@@ -104,5 +126,5 @@ type MarkChangedParagraphRangesOptions = {
104
126
  };
105
127
  /** Record mark-only paragraph changes whose replacement step has a granular map. */
106
128
  export declare function markChangedParagraphRanges(tr: Transaction, batch: MarkChangedParagraphRangesOptions): Transaction;
107
- export declare const ParagraphChangeTrackerExtension: (options?: Partial<{}> | undefined) => Extension;
129
+ export declare const ParagraphChangeTrackerExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
108
130
  export {};
@@ -30,43 +30,72 @@ const isRemovedSectionReference = (value) => typeof value === "object" && value
30
30
  const isTrackedSectionEndpointRemoval = (value) => typeof value === "object" && value !== null && "type" in value && value.type === "tracked-section-endpoint-removal" && "sourceParagraphEndpointCount" in value && typeof value.sourceParagraphEndpointCount === "number" && Number.isSafeInteger(value.sourceParagraphEndpointCount) && "expectedParagraphEndpointCount" in value && typeof value.expectedParagraphEndpointCount === "number" && Number.isSafeInteger(value.expectedParagraphEndpointCount) && value.sourceParagraphEndpointCount > value.expectedParagraphEndpointCount && value.expectedParagraphEndpointCount >= 0 && "sourceEndpointFingerprint" in value && typeof value.sourceEndpointFingerprint === "string" && "expectedEndpointFingerprint" in value && typeof value.expectedEndpointFingerprint === "string" && "removedReferences" in value && Array.isArray(value.removedReferences) && value.removedReferences.every(isRemovedSectionReference);
31
31
  const isTrackedSectionEndpointRemovalMeta = (value) => typeof value === "object" && value !== null && "type" in value && value.type === "tracked-section-endpoint-removal-meta" && "authorization" in value && isTrackedSectionEndpointRemoval(value.authorization);
32
32
  const isSectionEditMeta = (value) => typeof value === "object" && value !== null && "type" in value && value.type === "section-edit-meta" && "authorization" in value && (value.authorization === null || isTrackedSectionEndpointRemoval(value.authorization)) && "expectedEndpointFingerprint" in value && typeof value.expectedEndpointFingerprint === "string";
33
- /** Count the structural values the tracker compares for every transaction. */
33
+ const blockStructures = /* @__PURE__ */ new WeakMap();
34
+ const relativePath = (parentPath, index) => parentPath.length === 0 ? `${index}` : `${parentPath}.${index}`;
35
+ const blockStructureOf = (block) => {
36
+ const cached = blockStructures.get(block);
37
+ if (cached) return cached;
38
+ const records = [];
39
+ const endpoints = [];
40
+ let paragraphs = 0;
41
+ const visit = (node, path) => {
42
+ records.push(node.type.name === "paragraph" ? [
43
+ path,
44
+ node.type.name,
45
+ node.attrs["paraId"] ?? null
46
+ ] : [
47
+ path,
48
+ node.type.name,
49
+ canonicalJson(node.attrs)
50
+ ]);
51
+ if (node.type.name === "paragraph") {
52
+ paragraphs++;
53
+ const sectionProperties = sectionPropertiesOf(node);
54
+ if (sectionProperties !== null) endpoints.push({
55
+ path,
56
+ paraId: node.attrs["paraId"] ?? null,
57
+ sectionProperties
58
+ });
59
+ return;
60
+ }
61
+ node.forEach((child, _offset, index) => visit(child, relativePath(path, index)));
62
+ };
63
+ visit(block, "");
64
+ const structure = {
65
+ records: JSON.stringify(records),
66
+ paragraphs,
67
+ endpoints
68
+ };
69
+ blockStructures.set(block, structure);
70
+ return structure;
71
+ };
72
+ /**
73
+ * Count the structural values the tracker compares for every transaction.
74
+ *
75
+ * Each top-level block's records are kept for the block node, so a keystroke
76
+ * recomputes only the block it changed. The fingerprint joins the blocks'
77
+ * records in order: two documents' fingerprints are equal exactly when their
78
+ * full record lists (every block and nested block with its path) are.
79
+ */
34
80
  function countDocumentStructure(doc) {
35
81
  let paragraphs = 0;
36
82
  const sectionRecords = /* @__PURE__ */ new Set();
37
83
  const blockRecords = [];
38
84
  const endpointRecords = [];
39
- const visit = (parent, parentPath) => {
40
- parent.forEach((node, _offset, index) => {
41
- const path = parentPath.length === 0 ? `${index}` : `${parentPath}.${index}`;
42
- blockRecords.push(node.type.name === "paragraph" ? [
43
- path,
44
- node.type.name,
45
- node.attrs["paraId"] ?? null
46
- ] : [
47
- path,
48
- node.type.name,
49
- canonicalJson(node.attrs)
50
- ]);
51
- if (node.type.name === "paragraph") {
52
- paragraphs++;
53
- const sectionProperties = sectionPropertiesOf(node);
54
- if (sectionProperties !== null) {
55
- sectionRecords.add(sectionProperties);
56
- endpointRecords.push({
57
- path: parentPath.length === 0 ? `${index}` : `${parentPath}.${index}`,
58
- paraId: node.attrs["paraId"] ?? null,
59
- sectionProperties
60
- });
61
- }
62
- return;
63
- }
64
- if (node.childCount > 0) visit(node, path);
65
- });
66
- };
67
- visit(doc, "");
85
+ doc.forEach((block, _offset, index) => {
86
+ const structure = blockStructureOf(block);
87
+ blockRecords.push(structure.records);
88
+ paragraphs += structure.paragraphs;
89
+ for (const endpoint of structure.endpoints) {
90
+ sectionRecords.add(endpoint.sectionProperties);
91
+ endpointRecords.push({
92
+ ...endpoint,
93
+ path: endpoint.path.length === 0 ? `${index}` : `${index}.${endpoint.path}`
94
+ });
95
+ }
96
+ });
68
97
  return {
69
- blockStructureFingerprint: JSON.stringify(blockRecords),
98
+ blockStructureFingerprint: blockRecords.join(""),
70
99
  sectionRecords,
71
100
  paragraphs,
72
101
  sectionEndpoints: sectionRecords.size,
@@ -543,4 +572,4 @@ const ParagraphChangeTrackerExtension = createExtension({
543
572
  return { plugins: [createParagraphChangeTrackerPlugin()] };
544
573
  }
545
574
  });
546
- export { ParagraphChangeTrackerExtension, clearTrackedChanges, createParagraphChangeTrackerPlugin, getChangeTrackerState, getChangedParagraphIds, getTrackedSectionEndpointRemoval, hasStructuralChanges, hasUntrackedChanges, ignoreTrackedChanges, markChangedParagraphRanges, markPackageChange, markSectionBreakRemoval, markStructuralChange, markTrackedSectionEndpointRemoval, paragraphChangeTrackerKey, repackWithEditorSectionRemovals };
575
+ export { ParagraphChangeTrackerExtension, clearTrackedChanges, countDocumentStructure, createParagraphChangeTrackerPlugin, getChangeTrackerState, getChangedParagraphIds, getTrackedSectionEndpointRemoval, hasStructuralChanges, hasUntrackedChanges, ignoreTrackedChanges, markChangedParagraphRanges, markPackageChange, markSectionBreakRemoval, markStructuralChange, markTrackedSectionEndpointRemoval, paragraphChangeTrackerKey, repackWithEditorSectionRemovals };
@@ -17,18 +17,19 @@ const hasListHint = (node) => node?.type.name === "paragraph" && Boolean(expectP
17
17
  */
18
18
  const flattenPastedHtmlLists = (html) => {
19
19
  if (!/<(?:ul|ol)\b/iu.test(html)) return html;
20
- const host = document.createElement("div");
20
+ const owner = document.implementation.createHTMLDocument("");
21
+ const host = owner.createElement("div");
21
22
  host.innerHTML = html;
22
23
  let nextGroup = 0;
23
24
  const flatten = (list, level) => {
24
- const fragment = document.createDocumentFragment();
25
+ const fragment = owner.createDocumentFragment();
25
26
  const group = ++nextGroup;
26
27
  const kind = list.localName === "ul" ? "bullet" : "numbered";
27
28
  const rawStart = Number(list.getAttribute("start"));
28
29
  const start = Number.isSafeInteger(rawStart) && rawStart > 0 ? rawStart : void 0;
29
30
  for (const item of Array.from(list.children)) {
30
31
  if (item.localName !== "li") continue;
31
- let paragraph = document.createElement("p");
32
+ let paragraph = owner.createElement("p");
32
33
  let emitted = false;
33
34
  const mark = (element) => {
34
35
  element.setAttribute("data-folio-list-group", String(group));
@@ -40,7 +41,7 @@ const flattenPastedHtmlLists = (html) => {
40
41
  if (!paragraph.hasChildNodes()) return;
41
42
  mark(paragraph);
42
43
  fragment.append(paragraph);
43
- paragraph = document.createElement("p");
44
+ paragraph = owner.createElement("p");
44
45
  emitted = true;
45
46
  };
46
47
  for (const child of Array.from(item.childNodes)) if (child instanceof Element && isList(child)) {
@@ -12,9 +12,14 @@ const CommentExtension = createMarkExtension({
12
12
  schemaMarkName: "comment",
13
13
  markSpec: {
14
14
  excludes: "",
15
- attrs: {
16
- /** Comment ID (matches Comment.id) */
17
- commentId: { default: 0 } },
15
+ attrs: {
16
+ /** Comment ID (matches Comment.id) */
17
+ commentId: { default: 0 },
18
+ /** Shown at a point comment's reference; see `CommentAttrs.point`. */
19
+ point: { default: false },
20
+ /** The pending suggestion proposing it; see `CommentAttrs.suggestionId`. */
21
+ suggestionId: { default: null }
22
+ },
18
23
  inclusive: false,
19
24
  parseDOM: [{
20
25
  tag: "span.docx-comment",
@@ -0,0 +1,4 @@
1
+ import { NodeExtension } from "../types.js";
2
+ /** The node name, for callers asking what a block container holds. */
3
+ export declare const BLOCK_COMMENT_RANGE_BOUNDARY_NODE_NAME = "blockCommentRangeBoundary";
4
+ export declare const BlockCommentRangeBoundaryExtension: () => NodeExtension;
@@ -0,0 +1,49 @@
1
+ import { expectCommentRangeBoundaryAttrs, readCommentRangeBoundaryMarker } from "../../commentRangeBoundaryAttrs.js";
2
+ import { createNodeExtension } from "../create.js";
3
+ // src/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.ts
4
+ /**
5
+ * A comment range boundary that stands between two blocks.
6
+ *
7
+ * The block-level twin of `commentRangeBoundary`, as `blockBookmarkBoundary`
8
+ * is of `bookmarkBoundary`: `CT_Body`, `CT_Tc` and `CT_SdtContentBlock`
9
+ * declare `w:commentRangeStart` and `w:commentRangeEnd` beside their blocks,
10
+ * and a range that opens beside a content control is written there. The node
11
+ * carries the same marker, read by the same reader, so the two levels cannot
12
+ * describe a comment range differently. The comment's mark still covers the
13
+ * text; the save keeps this node's marker as the range's own start or end.
14
+ */
15
+ /** The node name, for callers asking what a block container holds. */
16
+ const BLOCK_COMMENT_RANGE_BOUNDARY_NODE_NAME = "blockCommentRangeBoundary";
17
+ const BLOCK_COMMENT_RANGE_BOUNDARY_DOM_ATTRIBUTE = "data-docx-block-comment-range-boundary";
18
+ const BlockCommentRangeBoundaryExtension = createNodeExtension({
19
+ name: BLOCK_COMMENT_RANGE_BOUNDARY_NODE_NAME,
20
+ schemaNodeName: BLOCK_COMMENT_RANGE_BOUNDARY_NODE_NAME,
21
+ nodeSpec: {
22
+ group: "block",
23
+ atom: true,
24
+ selectable: false,
25
+ attrs: { marker: {} },
26
+ parseDOM: [{
27
+ tag: `div[${BLOCK_COMMENT_RANGE_BOUNDARY_DOM_ATTRIBUTE}]`,
28
+ getAttrs(dom) {
29
+ const raw = dom.getAttribute(BLOCK_COMMENT_RANGE_BOUNDARY_DOM_ATTRIBUTE);
30
+ if (raw === null) return false;
31
+ try {
32
+ const marker = readCommentRangeBoundaryMarker(JSON.parse(raw));
33
+ return marker ? { marker } : false;
34
+ } catch {
35
+ return false;
36
+ }
37
+ }
38
+ }],
39
+ toDOM(node) {
40
+ return ["div", {
41
+ [BLOCK_COMMENT_RANGE_BOUNDARY_DOM_ATTRIBUTE]: JSON.stringify(expectCommentRangeBoundaryAttrs(node).marker),
42
+ "aria-hidden": "true",
43
+ contenteditable: "false",
44
+ style: "display: none;"
45
+ }];
46
+ }
47
+ }
48
+ });
49
+ export { BLOCK_COMMENT_RANGE_BOUNDARY_NODE_NAME, BlockCommentRangeBoundaryExtension };
@@ -2,7 +2,7 @@ import { readCommentReferenceAttrs } from "../../commentReferenceAttrs.js";
2
2
  import { COMMENT_REFERENCE_NODE_NAME, resolveCommentReferences } from "../../commentReferenceIntegrity.js";
3
3
  import { createNodeExtension } from "../create.js";
4
4
  import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
5
- import { Plugin } from "prosemirror-state";
5
+ import { Plugin, TextSelection } from "prosemirror-state";
6
6
  // src/prosemirror/extensions/nodes/CommentReferenceExtension.ts
7
7
  /** Zero-width `w:commentReference`: where a comment's visible mark is painted. */
8
8
  const CommentReferenceExtension = createNodeExtension({
@@ -41,6 +41,8 @@ const CommentReferenceExtension = createNodeExtension({
41
41
  if (!resolution) return null;
42
42
  const transaction = newState.tr;
43
43
  for (const step of resolution.steps) transaction.step(step);
44
+ const { selection } = newState;
45
+ if (selection instanceof TextSelection && selection.empty) transaction.setSelection(TextSelection.create(transaction.doc, transaction.mapping.map(selection.head, -1)));
44
46
  return transaction;
45
47
  } })] })
46
48
  });
@@ -1,4 +1,5 @@
1
1
  import { imageLuminanceFilter } from "../../../utils/imageLuminance.js";
2
+ import { sanitizeImageSrc } from "../../../utils/sanitizeImageSrc.js";
2
3
  import { expectImageAttrs } from "../../attrs/index.js";
3
4
  import { pictureNamesDomAttrs, pictureNamesFromDom } from "../../imagePictureNames.js";
4
5
  import { createNodeExtension } from "../create.js";
@@ -6,6 +7,12 @@ import { createNodeExtension } from "../create.js";
6
7
  /**
7
8
  * Image Extension — inline/floating image node
8
9
  */
10
+ /**
11
+ * A source the DOM must not load (anything `sanitizeImageSrc` rejects, such
12
+ * as a linked `https:` image) is kept under this attribute instead of `src`,
13
+ * so the node still round-trips through the clipboard without a request.
14
+ */
15
+ const UNLOADED_SRC_ATTRIBUTE = "data-folio-src";
9
16
  const ImageExtension = createNodeExtension({
10
17
  name: "image",
11
18
  schemaNodeName: "image",
@@ -72,9 +79,10 @@ const ImageExtension = createNodeExtension({
72
79
  _docxRunFormatting: { default: null }
73
80
  },
74
81
  parseDOM: [{
75
- tag: "img[src]",
82
+ tag: `img[src], img[${UNLOADED_SRC_ATTRIBUTE}]`,
76
83
  getAttrs(dom) {
77
84
  const element = dom;
85
+ const src = element.getAttribute("src") || element.getAttribute(UNLOADED_SRC_ATTRIBUTE) || "";
78
86
  const pictureNames = pictureNamesFromDom(element);
79
87
  const alt = element.getAttribute("alt");
80
88
  const title = element.getAttribute("title");
@@ -87,7 +95,7 @@ const ImageExtension = createNodeExtension({
87
95
  const contrastRaw = element.dataset["contrast"];
88
96
  const contrast = contrastRaw === void 0 ? NaN : Number(contrastRaw);
89
97
  return {
90
- src: element.getAttribute("src") || "",
98
+ src,
91
99
  ...element.dataset["docPrName"] === void 0 ? {} : { docPrName: element.dataset["docPrName"] },
92
100
  ...Object.keys(pictureNames).length > 0 ? { pictureNames } : {},
93
101
  ...alt ? { alt } : {},
@@ -110,8 +118,9 @@ const ImageExtension = createNodeExtension({
110
118
  }],
111
119
  toDOM(node) {
112
120
  const attrs = expectImageAttrs(node);
121
+ const loadable = sanitizeImageSrc(attrs.src);
113
122
  const domAttrs = {
114
- src: attrs.src,
123
+ ...loadable === void 0 ? { [UNLOADED_SRC_ATTRIBUTE]: attrs.src } : { src: loadable },
115
124
  class: "docx-image",
116
125
  ...pictureNamesDomAttrs(attrs.pictureNames)
117
126
  };
@@ -6,6 +6,7 @@ import { isValidHexColor, resolveColor } from "../../../utils/colorResolver.js";
6
6
  import { resolveTablePlacementAlignment } from "../../../utils/tablePlacement.js";
7
7
  import { textFlowCss } from "../../../utils/textDirectionFlow.js";
8
8
  import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "../../attrs/index.js";
9
+ import { withCanonicalCellMerge, withCanonicalCellSplit, withCanonicalColumnDeletion, withCanonicalColumnInsertion, withCanonicalRowDeletion, withCanonicalRowInsertion, withCanonicalTableAttributeCommand, withCanonicalTableDeletion, withCanonicalTableInsertion } from "../../canonicalTableCommands.js";
9
10
  import { mintRevisionId } from "../../plugins/revisionIds.js";
10
11
  import { makeRevisionInfo } from "../../plugins/suggestionMode.js";
11
12
  import { pasteTableCells, pastedSliceWithNewTableCells } from "../../tableCellPaste.js";
@@ -398,7 +399,7 @@ const statedCellWidth = (value, type) => ({
398
399
  }
399
400
  });
400
401
  const tableCellSpec = {
401
- content: "(paragraph | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary)+",
402
+ content: "(paragraph | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary | blockCommentRangeBoundary)+",
402
403
  tableRole: "cell",
403
404
  isolating: true,
404
405
  attrs: {
@@ -468,7 +469,7 @@ const tableCellSpec = {
468
469
  }
469
470
  };
470
471
  const tableHeaderSpec = {
471
- content: "(paragraph | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary)+",
472
+ content: "(paragraph | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary | blockCommentRangeBoundary)+",
472
473
  tableRole: "header_cell",
473
474
  isolating: true,
474
475
  attrs: {
@@ -2004,39 +2005,39 @@ const TablePluginExtension = createExtension({
2004
2005
  Delete: chainCommands(deleteTableIfSelected(), preventTableMergeAtGap())
2005
2006
  },
2006
2007
  commands: {
2007
- insertTable: (rows, cols) => insertTable(rows, cols),
2008
- addRowAbove: () => addRowAbove,
2009
- addRowBelow: () => addRowBelow,
2010
- deleteRow: () => deleteRow,
2011
- addColumnLeft: () => addColumnLeft,
2012
- addColumnRight: () => addColumnRight,
2013
- deleteColumn: () => deleteColumn,
2014
- deleteTable: () => deleteTable,
2008
+ insertTable: (rows, cols) => withCanonicalTableInsertion(insertTable(rows, cols)),
2009
+ addRowAbove: () => withCanonicalRowInsertion(addRowAbove, "above"),
2010
+ addRowBelow: () => withCanonicalRowInsertion(addRowBelow, "below"),
2011
+ deleteRow: () => withCanonicalRowDeletion(deleteRow),
2012
+ addColumnLeft: () => withCanonicalColumnInsertion(addColumnLeft, "left"),
2013
+ addColumnRight: () => withCanonicalColumnInsertion(addColumnRight, "right"),
2014
+ deleteColumn: () => withCanonicalColumnDeletion(deleteColumn),
2015
+ deleteTable: () => withCanonicalTableDeletion(deleteTable),
2015
2016
  selectTable: () => selectTable,
2016
2017
  selectRow: () => selectRow,
2017
2018
  selectColumn: () => selectColumn,
2018
- mergeCells: () => preserveOmittedGridSlots(mergeCells),
2019
- splitCell: () => preserveOmittedGridSlots(preserveSourceCellIdentity(splitCell)),
2020
- setCellBorder: (side, spec, clearOthers) => setCellBorder(side, spec, clearOthers),
2021
- setTableBorders: (preset, borderSpec) => setTableBorders(preset, borderSpec),
2022
- setTableBorderPreset: (preset) => setTableBorderPreset(preset),
2023
- setCellVerticalAlign: (align) => setCellVerticalAlign(align),
2024
- setCellMargins: (margins) => setCellMargins(margins),
2025
- setCellTextDirection: (direction) => setCellTextDirection(direction),
2026
- toggleNoWrap: () => toggleNoWrap(),
2027
- setRowHeight: (height, rule) => setRowHeight(height, rule),
2028
- toggleHeaderRow: () => toggleHeaderRow(),
2029
- distributeColumns: () => distributeColumns(),
2019
+ mergeCells: () => withCanonicalCellMerge(preserveOmittedGridSlots(mergeCells)),
2020
+ splitCell: () => withCanonicalCellSplit(preserveOmittedGridSlots(preserveSourceCellIdentity(splitCell))),
2021
+ setCellBorder: (side, spec, clearOthers) => withCanonicalTableAttributeCommand(setCellBorder(side, spec, clearOthers)),
2022
+ setTableBorders: (preset, borderSpec) => withCanonicalTableAttributeCommand(setTableBorders(preset, borderSpec)),
2023
+ setTableBorderPreset: (preset) => withCanonicalTableAttributeCommand(setTableBorderPreset(preset)),
2024
+ setCellVerticalAlign: (align) => withCanonicalTableAttributeCommand(setCellVerticalAlign(align)),
2025
+ setCellMargins: (margins) => withCanonicalTableAttributeCommand(setCellMargins(margins)),
2026
+ setCellTextDirection: (direction) => withCanonicalTableAttributeCommand(setCellTextDirection(direction)),
2027
+ toggleNoWrap: () => withCanonicalTableAttributeCommand(toggleNoWrap()),
2028
+ setRowHeight: (height, rule) => withCanonicalTableAttributeCommand(setRowHeight(height, rule)),
2029
+ toggleHeaderRow: () => withCanonicalTableAttributeCommand(toggleHeaderRow()),
2030
+ distributeColumns: () => withCanonicalTableAttributeCommand(distributeColumns()),
2030
2031
  autoFitContents: () => autoFitContents(),
2031
- setTableProperties: (props) => setTableProperties(props),
2032
- applyTableStyle: (styleData) => applyTableStyle(styleData),
2033
- setCellFillColor: (color) => setCellFillColor(color),
2034
- setTableBorderColor: (color) => setTableBorderColor(color),
2035
- setTableBorderWidth: (size) => setTableBorderWidth(size),
2036
- removeTableBorders: () => setTableBorders("none"),
2037
- setAllTableBorders: (borderSpec) => setTableBorders("all", borderSpec),
2038
- setOutsideTableBorders: (borderSpec) => setTableBorders("outside", borderSpec),
2039
- setInsideTableBorders: (borderSpec) => setTableBorders("inside", borderSpec)
2032
+ setTableProperties: (props) => withCanonicalTableAttributeCommand(setTableProperties(props)),
2033
+ applyTableStyle: (styleData) => withCanonicalTableAttributeCommand(applyTableStyle(styleData)),
2034
+ setCellFillColor: (color) => withCanonicalTableAttributeCommand(setCellFillColor(color)),
2035
+ setTableBorderColor: (color) => withCanonicalTableAttributeCommand(setTableBorderColor(color)),
2036
+ setTableBorderWidth: (size) => withCanonicalTableAttributeCommand(setTableBorderWidth(size)),
2037
+ removeTableBorders: () => withCanonicalTableAttributeCommand(setTableBorders("none")),
2038
+ setAllTableBorders: (borderSpec) => withCanonicalTableAttributeCommand(setTableBorders("all", borderSpec)),
2039
+ setOutsideTableBorders: (borderSpec) => withCanonicalTableAttributeCommand(setTableBorders("outside", borderSpec)),
2040
+ setInsideTableBorders: (borderSpec) => withCanonicalTableAttributeCommand(setTableBorders("inside", borderSpec))
2040
2041
  }
2041
2042
  };
2042
2043
  }
@@ -71,7 +71,7 @@ const TextBoxExtension = createNodeExtension({
71
71
  schemaNodeName: "textBox",
72
72
  nodeSpec: {
73
73
  group: "block",
74
- content: "(paragraph | table)+",
74
+ content: "(paragraph | table | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary | blockCommentRangeBoundary)+",
75
75
  isolating: true,
76
76
  draggable: true,
77
77
  attrs: {
@@ -1,13 +1,15 @@
1
1
  import { FontFamilyAttrs, FontSizeAttrs, HyperlinkAttrs, TextColorAttrs, UnderlineAttrs } from "./schema/marks.js";
2
2
  import { ImageAttrs, ParagraphAttrs } from "./schema/nodes.js";
3
3
  import { ResolvedParagraphStyle, StyleResolver, createStyleResolver } from "./styles/styleResolver.js";
4
+ import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
5
+ import { ProseMirrorDocumentValidationIssue, ValidateProseMirrorDocumentResult, assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "./validation.js";
6
+ import { ToProseDocOptions, createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
4
7
  import { schema, singletonManager } from "./schema/index.js";
5
8
  import { getParagraphAlignment, getParagraphBidi, getStyleId } from "./extensions/core/ParagraphExtension.js";
6
9
  import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
7
10
  import { TableBorderCommandSpec, TableCellBorderCommandSpec } from "./extensions/types.js";
8
11
  import { ListNumberingMenuState, NO_LIST_NUMBERING_MENU, listNumberingMenuState } from "./listNumbering.js";
9
12
  import { CapturedTextFormatting, PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./commands/formatPainter.js";
10
- import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
11
13
  import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensions/marks/HyperlinkExtension.js";
12
14
  import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./commands/formatting.js";
13
15
  import { insertImageFromFile } from "./commands/image.js";
@@ -17,8 +19,6 @@ import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyl
17
19
  import { insertPageBreak } from "./commands/pageBreak.js";
18
20
  import "./commands/index.js";
19
21
  import { FromProseDocOptions, ProjectionReuse, fromProseDoc, updateDocumentContent } from "./conversion/fromProseDoc.js";
20
- import { ToProseDocOptions, createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
21
- import { ProseMirrorDocumentValidationIssue, ValidateProseMirrorDocumentResult, assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "./validation.js";
22
22
  import "./conversion/index.js";
23
23
  import { ActiveListState, ListState, ListType, NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState } from "./listState.js";
24
24
  import { SelectionChangeCallback, SelectionContext, createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./plugins/selectionTracker.js";
@@ -134,11 +134,12 @@ const createListLabelCounter = (numberingOrStreams = null, suppliedStreams) => {
134
134
  numPrFromStyle: counterAttrs.numPrFromStyle
135
135
  });
136
136
  const countedNumbering = effectiveParagraphNumberingReference(countedSources);
137
- const revisionSelectedRendering = counterInput._propertyChanges?.length && counterAttrs !== counterInput && numbering === null ? listRenderingFromAttrs({
137
+ const revisionSelectedRendering = counterInput._propertyChanges?.length && counterAttrs !== counterInput && numbering === null && countedNumbering !== void 0 ? listRenderingFromAttrs({
138
138
  attrs: counterAttrs,
139
139
  numId: countedNumbering?.numId ?? 1
140
140
  }) : void 0;
141
- const countedList = resolveParagraphList(countedSources, numbering, revisionSelectedRendering ?? projectedRendering);
141
+ const revisionSelected = counterInput._propertyChanges?.length && counterAttrs !== counterInput && numbering === null;
142
+ const countedList = resolveParagraphList(countedSources, numbering, revisionSelected ? revisionSelectedRendering : revisionSelectedRendering ?? projectedRendering);
142
143
  switch (countedList.kind) {
143
144
  case "none": return {
144
145
  kind: "none",
@@ -29,6 +29,12 @@ type ResolveListTargetOptions = {
29
29
  /** Candidate requests, most likely first (see `listRequestsForMarker`). */
30
30
  requests: readonly ListRequest[];
31
31
  };
32
+ /**
33
+ * The instance the package already defines for `request` that no paragraph
34
+ * of the story refers to (`referenced`): a new list takes it before one is
35
+ * minted. One rule for both engines.
36
+ */
37
+ export declare const unusedListInstanceFor: (numbering: NumberingMap, referenced: ReadonlySet<number>, request: ListRequest) => number | undefined;
32
38
  /**
33
39
  * The list a paragraph range joins: the list directly above it, else the one
34
40
  * directly below it, when it matches one of `requests`; otherwise a new list:
@@ -149,14 +149,17 @@ const referencedNumIds = (doc) => {
149
149
  * naming a `w:pStyle`, or a style link) belongs to that style and is never
150
150
  * offered.
151
151
  */
152
- const unusedInstanceFor = (numbering, doc, request) => {
153
- const referenced = referencedNumIds(doc);
154
- return numbering.definitions.nums.find(({ numId, abstractNumId }) => {
155
- const abstract = numbering.getAbstract(abstractNumId);
156
- const level = numbering.getLevel(numId, 0);
157
- return !referenced.has(numId) && abstract !== null && abstract.styleLink === void 0 && abstract.numStyleLink === void 0 && abstract.levels.every(({ pStyle }) => pStyle === void 0) && level !== null && levelMatches(level, request) && (level.start ?? 1) === (request.start ?? level.start ?? 1);
158
- })?.numId;
159
- };
152
+ const unusedInstanceFor = (numbering, doc, request) => unusedListInstanceFor(numbering, referencedNumIds(doc), request);
153
+ /**
154
+ * The instance the package already defines for `request` that no paragraph
155
+ * of the story refers to (`referenced`): a new list takes it before one is
156
+ * minted. One rule for both engines.
157
+ */
158
+ const unusedListInstanceFor = (numbering, referenced, request) => numbering.definitions.nums.find(({ numId, abstractNumId }) => {
159
+ const abstract = numbering.getAbstract(abstractNumId);
160
+ const level = numbering.getLevel(numId, 0);
161
+ return !referenced.has(numId) && abstract !== null && abstract.styleLink === void 0 && abstract.numStyleLink === void 0 && abstract.levels.every(({ pStyle }) => pStyle === void 0) && level !== null && levelMatches(level, request) && (level.start ?? 1) === (request.start ?? level.start ?? 1);
162
+ })?.numId;
160
163
  /**
161
164
  * The list a paragraph range joins: the list directly above it, else the one
162
165
  * directly below it, when it matches one of `requests`; otherwise a new list:
@@ -348,4 +351,4 @@ const listNumberingMenuState = (state) => restartNumbering(state) ? {
348
351
  type: "listItem",
349
352
  canContinue: continueNumbering(state)
350
353
  } : NO_LIST_NUMBERING_MENU;
351
- export { NO_LIST_NUMBERING_MENU, applyParagraphUpdates, continueNumbering, listItemAttrs, listNumberingMenuState, resolveListTarget, restartNumbering, setNumberingValue };
354
+ export { NO_LIST_NUMBERING_MENU, applyParagraphUpdates, continueNumbering, listItemAttrs, listNumberingMenuState, resolveListTarget, restartNumbering, setNumberingValue, unusedListInstanceFor };
@@ -0,0 +1,13 @@
1
+ import { Node } from "prosemirror-model";
2
+ import { LockedControlSpan, LockedControlTouch, LockedControlViolation } from "@stll/docx-core/model";
3
+ import { Transform } from "prosemirror-transform";
4
+ export declare const lockedControlSpans: (doc: Node) => readonly LockedControlSpan[];
5
+ /** What the locks of `doc` say about `touches`: `null` when they permit them all. */
6
+ export declare const lockedControlViolationIn: (doc: Node, touches: readonly LockedControlTouch[]) => LockedControlViolation | null;
7
+ /**
8
+ * What the locks of `transform`'s starting document say about its result: a
9
+ * control whose content is locked must come through with the same content,
10
+ * and one locked against removal must come through at all. Read from the
11
+ * result rather than the steps, so it holds for any step a command takes.
12
+ */
13
+ export declare const lockedControlViolationOfTransform: (transform: Transform) => LockedControlViolation | null;