@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
@@ -14,7 +14,7 @@ import { rebaseParagraphRuns } from "../rebaseParagraphRunFormatting.js";
14
14
  import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
15
15
  import { paragraphRunStyleContext } from "../runStyleFormatting.js";
16
16
  import { cellPasteRange, pasteTableCells } from "../tableCellPaste.js";
17
- import { afterNativeCompositionFlush, formattingMarksBesideLockedControl, handleEditorBeforeInput } from "../textInput.js";
17
+ import { afterNativeCompositionFlush, formattingMarksBesideLockedControl, handleEditorBeforeInput, keepTypedTextInComments } from "../textInput.js";
18
18
  import { canCarryTrackedRunMark } from "../trackedRunInlineAtoms.js";
19
19
  import { getDocumentNumbering } from "./documentNumbering.js";
20
20
  import { documentStylesKey, getDocumentStyleResolver } from "./documentStyleState.js";
@@ -266,8 +266,9 @@ function handleSuggestionPaste(view, slice, pluginState) {
266
266
  suffix.forEach((node) => {
267
267
  if (!node.marks.some((mark) => mark.type === deletionType)) deletedSuffix = false;
268
268
  });
269
+ const rotates = deletedSuffix && ($from.parent.attrs["pPrMark"]?.kind ?? "del") === "del" && paragraphEndsItsContainer($from.doc.resolve($from.before()), "paragraph") && slice.content.firstChild?.type === $from.parent.type && slice.content.lastChild?.type === $from.parent.type;
269
270
  const tr = view.state.tr.setMeta(SUGGESTION_META, true).setMeta("paste", true);
270
- const at = $from.before();
271
+ const at = rotates ? $from.after() : $from.before();
271
272
  tr.replaceRange(at, at, slice);
272
273
  const revision = makeMarkAttrs(pluginState);
273
274
  const end = tr.mapping.map(at, 1);
@@ -290,6 +291,13 @@ function handleSuggestionPaste(view, slice, pluginState) {
290
291
  return false;
291
292
  });
292
293
  markRangeAsInserted(tr, tr.doc, at, end, insertionType, deletionType, revision);
294
+ if (rotates) {
295
+ const rotation = tr.steps.length;
296
+ rotateIntoFinalParagraph(view.state, tr, $from.before(), revision);
297
+ tr.setSelection(TextSelection.near(tr.doc.resolve(tr.mapping.slice(rotation).map(end, -1)), -1));
298
+ view.dispatch(tr.scrollIntoView());
299
+ return true;
300
+ }
293
301
  if (deletedSuffix && $from.parent.attrs["pPrMark"] == null && !paragraphEndsItsContainer($from.doc.resolve($from.before()), "paragraph")) tr.setNodeAttribute(tr.mapping.map($from.before()), "pPrMark", {
294
302
  kind: "del",
295
303
  info: makeParagraphMarkInfo(pluginState)
@@ -362,9 +370,9 @@ function handleSuggestionPaste(view, slice, pluginState) {
362
370
  });
363
371
  markRangeAsInserted(tr, tr.doc, insertFrom, insertTo, insertionType, deletionType, insertAttrs);
364
372
  if (!inlineSlice) carryAcross();
365
- if (!closedBlocks && $to.parent.type.name === "paragraph") {
366
- const $end = tr.doc.resolve(tr.mapping.map(to));
367
- if ($end.parent.type.name === "paragraph" && $end.before() !== tr.mapping.map($from.before())) recordReplacedParagraphProperties({
373
+ if ($to.parent.type.name === "paragraph") {
374
+ const $end = tr.doc.resolve(closedBlocks ? Math.max(insertFrom, insertTo - 1) : tr.mapping.map(to));
375
+ if ($end.parent.type.name === "paragraph" && $end.before() !== tr.mapping.map($from.before()) && expectParagraphAttrs($end.parent).pPrMark?.kind !== "ins") recordReplacedParagraphProperties({
368
376
  tr,
369
377
  position: $end.before(),
370
378
  replaced: $to.parent,
@@ -604,6 +612,18 @@ function applySuggestionInsert(view, from, to, text, pluginState) {
604
612
  }
605
613
  separateSplitStretch(tr, typedFrom, typedTo, insertAttrs.revisionId);
606
614
  if (typesOverSelection) tr.setSelection(TextSelection.create(tr.doc, typedTo));
615
+ keepTypedTextInComments({
616
+ state: view.state,
617
+ tr,
618
+ replaced: {
619
+ from,
620
+ to
621
+ },
622
+ typed: {
623
+ from: typedFrom,
624
+ to: typedTo
625
+ }
626
+ });
607
627
  view.dispatch(tr.scrollIntoView());
608
628
  return true;
609
629
  }
@@ -833,7 +853,7 @@ function isCurrentAuthorParagraphInsertion(value, author) {
833
853
  /**
834
854
  * Handle delete (forward or backward) in suggestion mode.
835
855
  */
836
- function handleSuggestionDelete(state, dispatch, direction) {
856
+ function handleSuggestionDelete(state, dispatch, direction, { cut = false } = {}) {
837
857
  const pluginState = suggestionModeKey.getState(state);
838
858
  if (!pluginState?.active) return false;
839
859
  const { $from, $to, empty } = state.selection;
@@ -849,8 +869,11 @@ function handleSuggestionDelete(state, dispatch, direction) {
849
869
  to: rangeTo.pos
850
870
  }).sort((a, b) => b.from - a.from);
851
871
  for (const { from, to } of ranges) markRangeAsDeleted(tr, state.doc, from, to, deletionType, pluginState, state);
852
- if (state.selection instanceof CellSelection) tr.setSelection(state.selection.map(tr.doc, tr.mapping));
853
- else {
872
+ if (state.selection instanceof CellSelection && !cut) tr.setSelection(state.selection.map(tr.doc, tr.mapping));
873
+ else if (state.selection instanceof CellSelection) {
874
+ const caret = Selection.findFrom(tr.doc.resolve(tr.mapping.map(state.selection.to)), -1);
875
+ if (caret) tr.setSelection(caret);
876
+ } else {
854
877
  const cursorPos = tr.mapping.map($to.pos);
855
878
  tr.setSelection(TextSelection.near(tr.doc.resolve(cursorPos)));
856
879
  }
@@ -894,7 +917,7 @@ function handleSuggestionDelete(state, dispatch, direction) {
894
917
  return true;
895
918
  }
896
919
  /** Apply the editor's selected-content deletion path for a host cut action. */
897
- const deleteSelectionAsSuggestion = (state, dispatch) => state.selection.empty ? false : handleSuggestionDelete(state, dispatch, "forward");
920
+ const deleteSelectionAsSuggestion = (state, dispatch) => state.selection.empty ? false : handleSuggestionDelete(state, dispatch, "forward", { cut: true });
898
921
  /**
899
922
  * PM reads the removal of cancelled text back from the DOM, which can take the
900
923
  * text around it along and drop its revision marks. The same text was there when
@@ -1123,7 +1146,7 @@ function createSuggestionModePlugin(initialActive = false, author = "User") {
1123
1146
  data.setData("text/html", dom.innerHTML);
1124
1147
  data.setData("text/plain", text);
1125
1148
  event.preventDefault();
1126
- return handleSuggestionDelete(view.state, view.dispatch, "forward");
1149
+ return handleSuggestionDelete(view.state, view.dispatch, "forward", { cut: true });
1127
1150
  },
1128
1151
  compositionstart(view) {
1129
1152
  if (!suggestionModeKey.getState(view.state)?.active) return false;
@@ -78,6 +78,21 @@ const FIELD_PATH_HEAD_RE = /^[\p{L}_]/u;
78
78
  * keeps a real expression on exact matching.
79
79
  */
80
80
  const filterChainPath = ({ conditionPath }) => conditionPath !== void 0 && isFieldPath(conditionPath) && FIELD_PATH_HEAD_RE.test(conditionPath) ? conditionPath : void 0;
81
+ const isPreviewSpan = (span) => typeof span === "object" && span !== null && typeof Reflect.get(span, "text") === "string";
82
+ /**
83
+ * The value stored under one key, read like {@link ownVerdict}: only a key the
84
+ * host set itself, holding text or a list of text spans, counts. A marker named
85
+ * after an inherited property (`constructor`) or holding a malformed value
86
+ * keeps its authored text.
87
+ */
88
+ const ownPreviewValue = (values, key) => {
89
+ if (!Object.hasOwn(values, key)) return;
90
+ const value = values[key];
91
+ if (typeof value === "string") return value;
92
+ if (typeof value !== "object" || value === null) return;
93
+ const runs = Reflect.get(value, "runs");
94
+ return Array.isArray(runs) && runs.every(isPreviewSpan) ? { runs } : void 0;
95
+ };
81
96
  /**
82
97
  * The verdict stored under one key. Only a key the host set itself, holding a
83
98
  * real boolean, counts: an inherited property (`constructor`, or a boolean the
@@ -189,7 +204,7 @@ function collectPreviewEntries(ranges, values, hidden) {
189
204
  const entries = [];
190
205
  for (const range of ranges) {
191
206
  if (range.kind !== "placeholder" && range.kind !== "clause") continue;
192
- const value = values[range.expr];
207
+ const value = ownPreviewValue(values, range.expr);
193
208
  if (value === void 0 || templatePreviewValueText(value) === "") continue;
194
209
  if (hidden.some((block) => range.from >= block.from && range.from < block.to)) continue;
195
210
  entries.push({
@@ -6,7 +6,7 @@ import { paragraphRunStyleContext } from "./runStyleFormatting.js";
6
6
  import { Mark } from "prosemirror-model";
7
7
  // src/prosemirror/rebaseParagraphRuns.ts
8
8
  /** Two contexts that lend runs the same formatting: rebasing between them changes nothing. */
9
- const sameRunStyleContext = (source, target) => source.paragraphMarkPrecedesStyle === target.paragraphMarkPrecedesStyle && formattingEquals(source.baseParagraphFormatting, target.baseParagraphFormatting) && formattingEquals(source.paragraphFormatting, target.paragraphFormatting) && formattingEquals(source.paragraphMarkFormatting, target.paragraphMarkFormatting);
9
+ const sameRunStyleContext = (source, target) => formattingEquals(source.baseParagraphFormatting, target.baseParagraphFormatting) && formattingEquals(source.paragraphFormatting, target.paragraphFormatting) && formattingEquals(source.paragraphMarkFormatting, target.paragraphMarkFormatting);
10
10
  /** Rebuild rendered marks after the paragraph's style cascade changes. */
11
11
  const rebaseParagraphRuns = ({ tr, position, previous, target, styleResolver, range, storedMarks: initialStoredMarks }) => {
12
12
  const paragraph = tr.doc.nodeAt(position);
@@ -147,6 +147,7 @@ const createResolvedCommentPointCollector = ({ removes, retiresStructure }) => {
147
147
  const removedWithStructure = removedStructures.some(({ from, to }) => position > from && position < to);
148
148
  for (const mark of node.marks) {
149
149
  if (mark.type.name !== "comment") continue;
150
+ if (mark.attrs["point"] === true) continue;
150
151
  const id = mark.attrs["commentId"];
151
152
  if (!removedWithStructure && !removes(node, position)) retained.add(id);
152
153
  else if (!points.has(id)) points.set(id, position);
@@ -9,7 +9,6 @@ export type MarksToTextFormattingOptions = {
9
9
  baseParagraphFormatting?: document_d_exports.TextFormatting | undefined;
10
10
  inheritedFormatting?: document_d_exports.TextFormatting | undefined;
11
11
  paragraphMarkFormatting?: document_d_exports.TextFormatting | undefined;
12
- paragraphMarkPrecedesStyle?: boolean | undefined;
13
12
  styleResolver?: RunStyleResolver | null | undefined;
14
13
  };
15
14
  /** Overlay only changed visual marks; private authored properties stay with the run. */
@@ -533,8 +533,7 @@ function marksToTextFormatting(marks, options) {
533
533
  const runContext = {
534
534
  baseParagraphFormatting: options?.baseParagraphFormatting,
535
535
  paragraphFormatting: options?.inheritedFormatting,
536
- paragraphMarkFormatting: options?.paragraphMarkFormatting,
537
- paragraphMarkPrecedesStyle: options?.paragraphMarkPrecedesStyle ?? false
536
+ paragraphMarkFormatting: options?.paragraphMarkFormatting
538
537
  };
539
538
  const paragraphFormatting = paragraphFormattingForRun({
540
539
  context: runContext,
@@ -557,8 +556,7 @@ function marksToTextFormatting(marks, options) {
557
556
  const suppressedParagraphFormatting = suppressParagraphMarkFormatting({
558
557
  baseFormatting: options.baseParagraphFormatting,
559
558
  directFormatting: authoredFormatting,
560
- paragraphMarkFormatting: options.paragraphMarkFormatting,
561
- paragraphMarkPrecedesStyle: options.paragraphMarkPrecedesStyle ?? false
559
+ paragraphMarkFormatting: options.paragraphMarkFormatting
562
560
  });
563
561
  const suppressedInheritedFormatting = resolveEffectiveRunStyleFormatting({
564
562
  marks,
@@ -12,7 +12,6 @@ const readAuthoredRunFormatting = ({ context, marks, styleResolver }) => marksTo
12
12
  baseParagraphFormatting: context.baseParagraphFormatting,
13
13
  inheritedFormatting: context.paragraphFormatting,
14
14
  paragraphMarkFormatting: context.paragraphMarkFormatting,
15
- paragraphMarkPrecedesStyle: context.paragraphMarkPrecedesStyle,
16
15
  ...styleResolver !== void 0 ? { styleResolver } : {}
17
16
  });
18
17
  /** Preserve the authored distinction between an absent and empty property set in revisions. */
@@ -49,7 +48,8 @@ const reconcileRunFormattingMarks = ({ authoredFormatting, context, node, styleR
49
48
  const paragraphMarkOverrides = isParagraphMarkSuppressionEligible(authoredFormatting) ? getParagraphMarkSuppressionOverrides({
50
49
  directFormatting: authoredFormatting,
51
50
  paragraphMarkFormatting: context.paragraphMarkFormatting,
52
- suppressedFormatting: paragraphFormatting
51
+ suppressedFormatting: paragraphFormatting,
52
+ characterStyleFormatting: authoredFormatting.styleId === void 0 ? void 0 : styleResolver?.getRunStyleOwnProperties(authoredFormatting.styleId) ?? void 0
53
53
  }) : void 0;
54
54
  const overrideFormatting = mergeTextFormatting(paragraphMarkOverrides, authoredFormatting);
55
55
  const formattingMarks = textFormattingToMarks(effectiveFormatting, node.type.schema, {
@@ -14,4 +14,26 @@ export declare const continueSourceCarrierIdentitiesAcrossRevisions: (nodes: rea
14
14
  * A deleted paragraph mark joined two source paragraphs, whose carriers were
15
15
  * always separate, so it is not crossed.
16
16
  */
17
- export declare const continueSourceCarrierIdentitiesAcrossInsertedParagraphMarks: (blocks: readonly Node[]) => readonly Node[];
17
+ export declare const continueSourceCarrierIdentitiesAcrossInsertedParagraphMarks: (blocks: readonly Node[]) => readonly Node[];
18
+ /** One pass of the continuation over a story's top-level blocks. */
19
+ export type ContinuedBlocks = {
20
+ blocks: readonly Node[];
21
+ continued: readonly Node[];
22
+ };
23
+ /**
24
+ * Kept across passes over one story: the last pass and each container
25
+ * continued inside, so a container a pass left is not walked again.
26
+ */
27
+ export declare class CarrierContinuationCache {
28
+ last: ContinuedBlocks | undefined;
29
+ readonly containers: WeakMap<Node, Node>;
30
+ }
31
+ /**
32
+ * {@link continueSourceCarrierIdentitiesAcrossInsertedParagraphMarks} over a
33
+ * story's top-level blocks, keeping what the last pass gave the blocks it
34
+ * left. A block's continuation reads only the block and the one continued
35
+ * before it, so the run of blocks from the start that the last pass was given
36
+ * keeps its result, and a block of the run to the end keeps its result once
37
+ * the block before it continued to what it did then.
38
+ */
39
+ export declare const continueSourceCarrierIdentitiesKeeping: (blocks: readonly Node[], cache: CarrierContinuationCache) => readonly Node[];
@@ -1,6 +1,7 @@
1
1
  import { expectHyperlinkMarkAttrs, expectRunIdentityMarkAttrs } from "./attrs/index.js";
2
2
  import "./extensions/nodes/SdtExtension.js";
3
3
  import { RUN_IDENTITY_MARK_NAME } from "./runIdentity.js";
4
+ import { panic } from "better-result";
4
5
  import { Fragment, Mark } from "prosemirror-model";
5
6
  // src/prosemirror/runIdentityAcrossRevisions.ts
6
7
  /**
@@ -161,17 +162,65 @@ const continueSourceCarrierIdentitiesAcrossInsertedParagraphMarks = (blocks) =>
161
162
  let changed = false;
162
163
  const result = [];
163
164
  for (const block of blocks) {
164
- let next = block;
165
- if (!block.isTextblock && !block.isLeaf && !block.inlineContent) {
165
+ const next = continuedBlock(result.at(-1), block);
166
+ changed ||= next !== block;
167
+ result.push(next);
168
+ }
169
+ return changed ? result : blocks;
170
+ };
171
+ /** `block` as it stands after `previous`, the block before it as continued. */
172
+ const continuedBlock = (previous, block, containers) => {
173
+ let next = block;
174
+ if (!block.isTextblock && !block.isLeaf && !block.inlineContent) {
175
+ const known = containers?.get(block);
176
+ if (known === void 0) {
166
177
  const children = childrenOf(block);
167
178
  const continued = continueSourceCarrierIdentitiesAcrossInsertedParagraphMarks(children);
168
179
  if (continued !== children) next = block.copy(Fragment.fromArray([...continued]));
180
+ containers?.set(block, next);
181
+ } else next = known;
182
+ }
183
+ if (previous !== void 0 && next.type.name === "paragraph" && endsWithInsertedMark(previous)) next = continueAcrossInsertedMark(previous, next);
184
+ return next;
185
+ };
186
+ /**
187
+ * Kept across passes over one story: the last pass and each container
188
+ * continued inside, so a container a pass left is not walked again.
189
+ */
190
+ var CarrierContinuationCache = class {
191
+ last;
192
+ containers = /* @__PURE__ */ new WeakMap();
193
+ };
194
+ /**
195
+ * {@link continueSourceCarrierIdentitiesAcrossInsertedParagraphMarks} over a
196
+ * story's top-level blocks, keeping what the last pass gave the blocks it
197
+ * left. A block's continuation reads only the block and the one continued
198
+ * before it, so the run of blocks from the start that the last pass was given
199
+ * keeps its result, and a block of the run to the end keeps its result once
200
+ * the block before it continued to what it did then.
201
+ */
202
+ const continueSourceCarrierIdentitiesKeeping = (blocks, cache) => {
203
+ const last = cache.last;
204
+ const before = last?.blocks ?? [];
205
+ const kept = last?.continued ?? [];
206
+ let start = 0;
207
+ while (start < blocks.length && start < before.length && blocks[start] === before[start]) start += 1;
208
+ let after = 0;
209
+ while (after < blocks.length - start && after < before.length - start && blocks[blocks.length - 1 - after] === before[before.length - 1 - after]) after += 1;
210
+ const shift = before.length - blocks.length;
211
+ const continued = kept.slice(0, start);
212
+ for (let index = start; index < blocks.length; index += 1) {
213
+ const at = index + shift;
214
+ if (index >= blocks.length - after && continued[index - 1] === (at === 0 ? void 0 : kept[at - 1])) {
215
+ for (let rest = at; rest < kept.length; rest += 1) continued.push(kept[rest] ?? panic("Missing continued block"));
216
+ break;
169
217
  }
170
- const previous = result.at(-1);
171
- if (previous !== void 0 && next.type.name === "paragraph" && endsWithInsertedMark(previous)) next = continueAcrossInsertedMark(previous, next);
172
- changed ||= next !== block;
173
- result.push(next);
218
+ continued.push(continuedBlock(continued[index - 1], blocks[index] ?? panic("Missing block"), cache.containers));
174
219
  }
175
- return changed ? result : blocks;
220
+ cache.last = {
221
+ blocks,
222
+ continued
223
+ };
224
+ return continued;
176
225
  };
177
- export { SOURCE_CARRIER_MARK_NAMES, continueSourceCarrierIdentitiesAcrossInsertedParagraphMarks, continueSourceCarrierIdentitiesAcrossRevisions };
226
+ export { CarrierContinuationCache, SOURCE_CARRIER_MARK_NAMES, continueSourceCarrierIdentitiesAcrossInsertedParagraphMarks, continueSourceCarrierIdentitiesAcrossRevisions, continueSourceCarrierIdentitiesKeeping };
@@ -36,8 +36,7 @@ const restoreHistoricalRunFormatting = ({ node, paragraphContext, styleResolver
36
36
  context: {
37
37
  baseParagraphFormatting: paragraphContext.baseParagraphFormatting,
38
38
  paragraphFormatting: paragraphContext.baseParagraphFormatting,
39
- paragraphMarkFormatting: void 0,
40
- paragraphMarkPrecedesStyle: false
39
+ paragraphMarkFormatting: void 0
41
40
  },
42
41
  marks: node.marks,
43
42
  ...styleResolver !== void 0 ? { styleResolver } : {}
@@ -7,25 +7,35 @@ export declare const hasDirectRunFormatting: (formatting: document_d_exports.Tex
7
7
  /** A stated run property or character style establishes paragraph-mark suppression. */
8
8
  export declare const isParagraphMarkSuppressionEligible: (formatting: document_d_exports.TextFormatting | undefined) => boolean;
9
9
  export declare const stripParagraphMarkOnlyFormatting: (formatting: document_d_exports.TextFormatting) => document_d_exports.TextFormatting | undefined;
10
+ /**
11
+ * Whether a paragraph's mark lends its run properties to the paragraph's
12
+ * runs: only when the paragraph has no style. One rule for reading a run and
13
+ * for the save's view of what a run inherited.
14
+ */
15
+ export declare const paragraphMarkLendsRuns: (styleId: string | undefined) => boolean;
10
16
  export declare const stripParagraphMarkFormattingForBodyRuns: (formatting: document_d_exports.TextFormatting) => document_d_exports.TextFormatting | undefined;
11
17
  type SuppressParagraphMarkFormattingOptions = {
12
18
  baseFormatting: document_d_exports.TextFormatting | undefined;
13
19
  directFormatting: document_d_exports.TextFormatting | undefined;
14
20
  paragraphMarkFormatting: document_d_exports.TextFormatting | undefined;
15
- paragraphMarkPrecedesStyle?: boolean;
16
21
  };
17
- export declare const suppressParagraphMarkFormatting: ({ baseFormatting, directFormatting, paragraphMarkFormatting, paragraphMarkPrecedesStyle }: SuppressParagraphMarkFormattingOptions) => document_d_exports.TextFormatting | undefined;
22
+ export declare const suppressParagraphMarkFormatting: ({ baseFormatting, directFormatting, paragraphMarkFormatting }: SuppressParagraphMarkFormattingOptions) => document_d_exports.TextFormatting | undefined;
18
23
  type GetParagraphMarkSuppressionOverridesOptions = {
19
24
  directFormatting: document_d_exports.TextFormatting | undefined;
20
25
  paragraphMarkFormatting: document_d_exports.TextFormatting | undefined;
21
26
  suppressedFormatting: document_d_exports.TextFormatting | undefined;
27
+ /**
28
+ * The run's own character style. A property it states is the style's to
29
+ * give, not the paragraph mark's to take away: the run keeps it as the
30
+ * style cascade resolves it, with no override saying it is off.
31
+ */
32
+ characterStyleFormatting: document_d_exports.TextFormatting | undefined;
22
33
  };
23
- export declare const getParagraphMarkSuppressionOverrides: ({ directFormatting, paragraphMarkFormatting, suppressedFormatting }: GetParagraphMarkSuppressionOverridesOptions) => document_d_exports.TextFormatting | undefined;
34
+ export declare const getParagraphMarkSuppressionOverrides: ({ directFormatting, paragraphMarkFormatting, suppressedFormatting, characterStyleFormatting }: GetParagraphMarkSuppressionOverridesOptions) => document_d_exports.TextFormatting | undefined;
24
35
  export type ParagraphRunStyleContext = {
25
36
  baseParagraphFormatting: document_d_exports.TextFormatting | undefined;
26
37
  paragraphFormatting: document_d_exports.TextFormatting | undefined;
27
38
  paragraphMarkFormatting: document_d_exports.TextFormatting | undefined;
28
- paragraphMarkPrecedesStyle: boolean;
29
39
  };
30
40
  export type RunStyleResolver = Pick<StyleEngine, "builtInStyles" | "getDefaultCharacterStyle" | "getDefaultParagraphStyle" | "getDocDefaults" | "getRunStyleOwnProperties" | "getStyle" | "resolveParagraphStyle">;
31
41
  type ResolveParagraphBodyRunFormattingOptions = {
@@ -26,26 +26,32 @@ const stripParagraphMarkOnlyFormatting = (formatting) => {
26
26
  const { allCaps: _allCaps, highlight: _highlight, shading: _shading, smallCaps: _smallCaps, vertAlign: _vertAlign, preserved: _preserved, ...formattingForBody } = formatting;
27
27
  return Object.keys(formattingForBody).length > 0 ? formattingForBody : void 0;
28
28
  };
29
+ /**
30
+ * Whether a paragraph's mark lends its run properties to the paragraph's
31
+ * runs: only when the paragraph has no style. One rule for reading a run and
32
+ * for the save's view of what a run inherited.
33
+ */
34
+ const paragraphMarkLendsRuns = (styleId) => styleId === void 0;
29
35
  const stripParagraphMarkFormattingForBodyRuns = (formatting) => {
30
36
  const paragraphMarkFormatting = stripParagraphMarkOnlyFormatting(formatting);
31
37
  if (!paragraphMarkFormatting) return;
32
38
  const { fontFamily: _fontFamily, ...bodyRunFormatting } = paragraphMarkFormatting;
33
39
  return Object.keys(bodyRunFormatting).length > 0 ? bodyRunFormatting : void 0;
34
40
  };
35
- const suppressParagraphMarkFormatting = ({ baseFormatting, directFormatting, paragraphMarkFormatting, paragraphMarkPrecedesStyle = false }) => {
41
+ const suppressParagraphMarkFormatting = ({ baseFormatting, directFormatting, paragraphMarkFormatting }) => {
36
42
  if (!paragraphMarkFormatting) return baseFormatting;
37
- const result = (paragraphMarkPrecedesStyle ? mergeTextFormatting(paragraphMarkFormatting, baseFormatting) : mergeTextFormatting(baseFormatting, paragraphMarkFormatting)) ?? {};
43
+ const result = mergeTextFormatting(baseFormatting, paragraphMarkFormatting) ?? {};
38
44
  for (const property of PARAGRAPH_MARK_BOOLEAN_KEYS) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0) Reflect.set(result, property, baseFormatting?.[property] ?? false);
39
45
  for (const property of ["fontSize", "fontSizeCs"]) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0 && baseFormatting?.[property] !== void 0) result[property] = baseFormatting[property];
40
46
  if (paragraphMarkFormatting.underline !== void 0 && directFormatting?.underline === void 0) result.underline = { style: "none" };
41
47
  if (paragraphMarkFormatting.spacing !== void 0 && directFormatting?.spacing === void 0) result.spacing = 0;
42
48
  return Object.keys(result).length > 0 ? result : void 0;
43
49
  };
44
- const getParagraphMarkSuppressionOverrides = ({ directFormatting, paragraphMarkFormatting, suppressedFormatting }) => {
50
+ const getParagraphMarkSuppressionOverrides = ({ directFormatting, paragraphMarkFormatting, suppressedFormatting, characterStyleFormatting }) => {
45
51
  if (!paragraphMarkFormatting) return;
46
52
  const overrides = {};
47
- for (const property of PARAGRAPH_MARK_BOOLEAN_KEYS) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0 && suppressedFormatting?.[property] === false) Reflect.set(overrides, property, false);
48
- if (paragraphMarkFormatting.underline !== void 0 && directFormatting?.underline === void 0 && suppressedFormatting?.underline?.style === "none") overrides.underline = { style: "none" };
53
+ for (const property of PARAGRAPH_MARK_BOOLEAN_KEYS) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0 && characterStyleFormatting?.[property] === void 0 && suppressedFormatting?.[property] === false) Reflect.set(overrides, property, false);
54
+ if (paragraphMarkFormatting.underline !== void 0 && directFormatting?.underline === void 0 && characterStyleFormatting?.underline === void 0 && suppressedFormatting?.underline?.style === "none") overrides.underline = { style: "none" };
49
55
  return Object.keys(overrides).length > 0 ? overrides : void 0;
50
56
  };
51
57
  const withoutFontFamily = (formatting) => {
@@ -137,7 +143,7 @@ const resolveParagraphInheritedRunFormatting = (options) => {
137
143
  };
138
144
  const paragraphRunStyleContext = (paragraph, styleResolver) => {
139
145
  const attrs = expectParagraphAttrs(paragraph);
140
- const paragraphMarkFormatting = attrs._originalFormatting?.runProperties;
146
+ const paragraphMarkFormatting = paragraphMarkLendsRuns(attrs.styleId) ? attrs._originalFormatting?.runProperties : void 0;
141
147
  const characterStyleFormatting = paragraphMarkFormatting?.styleId ? styleResolver?.getRunStyleOwnProperties(paragraphMarkFormatting.styleId) : void 0;
142
148
  const resolvedParagraphMarkFormatting = cascadeStyleTextFormatting([{
143
149
  formatting: characterStyleFormatting,
@@ -154,8 +160,7 @@ const paragraphRunStyleContext = (paragraph, styleResolver) => {
154
160
  styleResolver
155
161
  }).defaultFormatting,
156
162
  paragraphFormatting: attrs.defaultTextFormatting ?? void 0,
157
- paragraphMarkFormatting: inheritableParagraphMarkFormatting,
158
- paragraphMarkPrecedesStyle: attrs.styleId !== void 0
163
+ paragraphMarkFormatting: inheritableParagraphMarkFormatting
159
164
  };
160
165
  };
161
166
  const paragraphFormattingForRun = ({ context, directFormatting, marks }) => {
@@ -163,8 +168,7 @@ const paragraphFormattingForRun = ({ context, directFormatting, marks }) => {
163
168
  return suppressParagraphMarkFormatting({
164
169
  baseFormatting: context.baseParagraphFormatting,
165
170
  directFormatting,
166
- paragraphMarkFormatting: context.paragraphMarkFormatting,
167
- paragraphMarkPrecedesStyle: context.paragraphMarkPrecedesStyle
171
+ paragraphMarkFormatting: context.paragraphMarkFormatting
168
172
  });
169
173
  };
170
174
  const paragraphRunStyleContextAt = ({ doc, pos, styleResolver }) => {
@@ -183,8 +187,7 @@ const paragraphRunStyleContextAt = ({ doc, pos, styleResolver }) => {
183
187
  const nearestParagraphRunStyleContext = (paragraph, styleResolver) => paragraph ? paragraphRunStyleContext(paragraph, styleResolver) : {
184
188
  baseParagraphFormatting: void 0,
185
189
  paragraphFormatting: void 0,
186
- paragraphMarkFormatting: void 0,
187
- paragraphMarkPrecedesStyle: false
190
+ paragraphMarkFormatting: void 0
188
191
  };
189
192
  /** Resolve the non-direct run cascade from shared document styles and the current paragraph. */
190
193
  const resolveEffectiveRunStyleFormatting = ({ marks, paragraphFormatting, styleResolver }) => {
@@ -202,4 +205,4 @@ const resolveEffectiveRunStyleFormatting = ({ marks, paragraphFormatting, styleR
202
205
  styleFormatting
203
206
  });
204
207
  };
205
- export { getParagraphMarkSuppressionOverrides, hasDirectRunFormatting, isParagraphMarkSuppressionEligible, nearestParagraphRunStyleContext, paragraphFormattingForRun, paragraphRunStyleContext, paragraphRunStyleContextAt, resolveEffectiveRunStyleFormatting, resolveParagraphBodyRunFormatting, resolveParagraphInheritedRunFormatting, stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting, suppressParagraphMarkFormatting };
208
+ export { getParagraphMarkSuppressionOverrides, hasDirectRunFormatting, isParagraphMarkSuppressionEligible, nearestParagraphRunStyleContext, paragraphFormattingForRun, paragraphMarkLendsRuns, paragraphRunStyleContext, paragraphRunStyleContextAt, resolveEffectiveRunStyleFormatting, resolveParagraphBodyRunFormatting, resolveParagraphInheritedRunFormatting, stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting, suppressParagraphMarkFormatting };
@@ -1,5 +1,5 @@
1
- import { ShadingProperties } from "../../types/colors.js";
2
1
  import { document_d_exports } from "../../types/document.js";
2
+ import { ShadingProperties } from "../../types/colors.js";
3
3
  import { TrackedCommentBoundary } from "../commentBoundaryOwnership.js";
4
4
  /**
5
5
  * Text color mark attributes
@@ -86,6 +86,18 @@ export type FootnoteRefAttrs = {
86
86
  };
87
87
  export type CommentAttrs = {
88
88
  commentId: number;
89
+ /**
90
+ * The comment was authored at a point (a bare `w:commentReference`): this
91
+ * mark only shows it on the text before the reference. The comment lives
92
+ * as long as its reference does, and saves as a point again.
93
+ */
94
+ point?: boolean;
95
+ /**
96
+ * The pending suggestion that proposed this comment. A proposed comment
97
+ * is never saved: it is accepted with its suggestion, which clears this,
98
+ * or removed when the suggestion is rejected.
99
+ */
100
+ suggestionId?: string;
89
101
  };
90
102
  /**
91
103
  * Provenance of a tracked change.
@@ -1,4 +1,4 @@
1
- import { createNumberingIdAllocator } from "../docx/numberingIds.js";
1
+ import { createNumberingIdAllocator, numberingNumIdsTaken } from "../docx/numberingIds.js";
2
2
  import { getCachedNumberingMap, isBulletLevel } from "../docx/numberingParser.js";
3
3
  import { paragraphNumberingReference } from "../docx/numberingReference.js";
4
4
  import { expectParagraphAttrs } from "./attrs/index.js";
@@ -57,7 +57,12 @@ const storyListNumbering = (state, numbering) => {
57
57
  doc: state.doc,
58
58
  numbering: completeNumberingForDoc(numbering, state.doc)
59
59
  };
60
- const existingNumIds = [...defined, ...referenced];
60
+ const existingNumIds = [
61
+ ...defined,
62
+ ...referenced,
63
+ ...numberingNumIdsTaken(numbering),
64
+ ...numberingNumIdsTaken(packageDefinitions)
65
+ ];
61
66
  const numIds = createNumberingIdAllocator("num", existingNumIds);
62
67
  const remap = {
63
68
  numIds: new Map([...colliding].map((numId) => [numId, numIds.next()])),
@@ -5,7 +5,7 @@ import { paragraphNumberingAttr } from "../numberingAttr.js";
5
5
  import { directionFromBidi } from "../paragraphDirection.js";
6
6
  import { styleResolvedParagraphFormatting } from "../paragraphFormattingProvenance.js";
7
7
  import { lineSpacingProvenanceFromSpacing } from "../paragraphSpacing.js";
8
- import { stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting } from "../runStyleFormatting.js";
8
+ import { paragraphMarkLendsRuns, stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting } from "../runStyleFormatting.js";
9
9
  import { cascadeStyleTextFormatting } from "./styleToggleCascade.js";
10
10
  // src/prosemirror/styles/paragraphStyleCascade.ts
11
11
  /**
@@ -36,7 +36,7 @@ function resolveRunFormattingWithoutDefaults(formatting, styleResolver) {
36
36
  * document read and for a paragraph whose properties a review restores.
37
37
  */
38
38
  const inheritableParagraphMarkFormatting = ({ runProperties, styleId, styleResolver }) => {
39
- if (styleId !== void 0) return void 0;
39
+ if (!paragraphMarkLendsRuns(styleId)) return void 0;
40
40
  const formatting = resolveRunFormattingWithoutDefaults(runProperties, styleResolver);
41
41
  return formatting ? stripParagraphMarkFormattingForBodyRuns(formatting) : void 0;
42
42
  };
@@ -1,3 +1,4 @@
1
+ import { Command } from "prosemirror-state";
1
2
  import { EditorView } from "prosemirror-view";
2
3
  /** 1px ≈ 15 twips at 96dpi (20 twips/pt × 72pt/in ÷ 96px/in). */
3
4
  export declare const TWIPS_PER_PIXEL = 15;
@@ -24,23 +25,23 @@ export declare function readColumnWidths(view: EditorView, pmStart: number, colI
24
25
  export declare function readRowHeight(view: EditorView, pmStart: number, rowIndex: number): number | null;
25
26
  /** Read the last-column width (the one being resized from the table's right edge). */
26
27
  export declare function readColumnWidthAt(view: EditorView, pmStart: number, colIndex: number): number | null;
27
- /** Commit a column-pair resize, preserving each spanning cell's full grid width. */
28
- export declare function commitColumnResize(view: EditorView, opts: {
28
+ /** A column-pair resize, preserving each spanning cell's full grid width. */
29
+ export declare const columnResizeCommand: (opts: {
29
30
  pmStart: number;
30
31
  colIdx: number;
31
32
  newLeft: number;
32
33
  newRight: number;
33
- }): void;
34
- /** Bake a row-resize into the PM doc: update the target row's `height` + `heightRule`. */
35
- export declare function commitRowResize(view: EditorView, opts: {
34
+ }) => Command;
35
+ /** A row resize: the row's `height`, at least that tall. */
36
+ export declare const rowResizeCommand: (opts: {
36
37
  pmStart: number;
37
38
  rowIdx: number;
38
39
  newHeight: number;
39
- }): void;
40
- /** Commit a right-edge resize, including cells that span the resized column. */
41
- export declare function commitRightEdgeResize(view: EditorView, opts: {
40
+ }) => Command;
41
+ /** A right-edge resize, including cells that span the resized column. */
42
+ export declare const rightEdgeResizeCommand: (opts: {
42
43
  pmStart: number;
43
44
  colIdx: number;
44
45
  newWidth: number;
45
- }): void;
46
+ }) => Command;
46
47
  export {};