@stll/folio-core 0.66.2 → 0.68.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 (323) hide show
  1. package/dist/ai-edits/apply.d.ts +9 -1
  2. package/dist/ai-edits/apply.js +138 -17
  3. package/dist/ai-edits/batch-claims.js +5 -3
  4. package/dist/ai-edits/clean-text.js +4 -1
  5. package/dist/ai-edits/headless.d.ts +36 -21
  6. package/dist/ai-edits/headless.js +104 -34
  7. package/dist/ai-edits/index.d.ts +2 -2
  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/read.d.ts +19 -0
  11. package/dist/ai-edits/read.js +6 -4
  12. package/dist/ai-edits/snapshot.d.ts +6 -0
  13. package/dist/ai-edits/snapshot.js +32 -17
  14. package/dist/ai-edits/table-cell-mutations.js +3 -2
  15. package/dist/ai-edits/table-row-column-mutations.js +20 -6
  16. package/dist/ai-edits/types.d.ts +9 -1
  17. package/dist/ai-suggestions/apply.js +13 -4
  18. package/dist/compare/compare.js +2 -1
  19. package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
  20. package/dist/compare/inserted-resource-snapshot.js +7 -3
  21. package/dist/controller/canonicalClipboard.js +29 -12
  22. package/dist/controller/canonicalComposition.d.ts +1 -1
  23. package/dist/controller/canonicalComposition.js +77 -19
  24. package/dist/controller/canonicalInlineProjection.d.ts +35 -10
  25. package/dist/controller/canonicalInlineProjection.js +192 -28
  26. package/dist/controller/canonicalInput.d.ts +2 -2
  27. package/dist/controller/canonicalInput.js +47 -2
  28. package/dist/controller/canonicalListRendering.d.ts +2 -1
  29. package/dist/controller/canonicalListRendering.js +1 -1
  30. package/dist/controller/canonicalLockGuard.d.ts +8 -0
  31. package/dist/controller/canonicalLockGuard.js +88 -0
  32. package/dist/controller/canonicalPublicOperations.d.ts +12 -4
  33. package/dist/controller/canonicalPublicOperations.js +274 -20
  34. package/dist/controller/canonicalSession.d.ts +87 -7
  35. package/dist/controller/canonicalSession.js +328 -75
  36. package/dist/controller/canonicalStoryEditor.d.ts +3 -2
  37. package/dist/controller/canonicalStoryEditor.js +4 -3
  38. package/dist/controller/canonicalStructure.d.ts +2 -1
  39. package/dist/controller/canonicalStructure.js +129 -7
  40. package/dist/controller/contentControlWidgetController.d.ts +5 -0
  41. package/dist/controller/contentControlWidgetController.js +13 -1
  42. package/dist/controller/folioEditor.js +1 -0
  43. package/dist/controller/headerFooterEditorManager.d.ts +2 -2
  44. package/dist/controller/headerFooterEditorManager.js +5 -5
  45. package/dist/controller/hiddenEditorApi.d.ts +6 -0
  46. package/dist/controller/hiddenEditorApi.js +1 -0
  47. package/dist/controller/hiddenEditorManager.d.ts +10 -3
  48. package/dist/controller/hiddenEditorManager.js +94 -38
  49. package/dist/controller/layoutPipeline.d.ts +2 -0
  50. package/dist/controller/layoutPipeline.js +55 -18
  51. package/dist/controller/layoutSession.d.ts +1 -0
  52. package/dist/controller/noteEditorManager.d.ts +2 -2
  53. package/dist/controller/noteEditorManager.js +5 -5
  54. package/dist/display-list/build/pageFurniture.js +41 -19
  55. package/dist/display-list/build/tablePrimitives.d.ts +3 -1
  56. package/dist/display-list/build/tablePrimitives.js +49 -14
  57. package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
  58. package/dist/document-operations.d.ts +8 -0
  59. package/dist/document-operations.js +4 -3
  60. package/dist/docx/blockContentParser.d.ts +7 -3
  61. package/dist/docx/blockContentParser.js +2 -3
  62. package/dist/docx/blockPlainText.js +2 -0
  63. package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
  64. package/dist/docx/bookmarkRangeJoin.js +43 -0
  65. package/dist/docx/canonicalSave.js +5 -1
  66. package/dist/docx/canonicalSessionInput.d.ts +5 -1
  67. package/dist/docx/canonicalSessionInput.js +7 -2
  68. package/dist/docx/chartPreview.d.ts +4 -1
  69. package/dist/docx/chartPreview.js +26 -15
  70. package/dist/docx/commentAnchorIndex.d.ts +21 -5
  71. package/dist/docx/commentAnchorIndex.js +39 -11
  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/encryption/compoundFile.js +9 -1
  80. package/dist/docx/encryption/encryptionInfo.js +16 -2
  81. package/dist/docx/ensureParaIds.js +46 -7
  82. package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
  83. package/dist/docx/ensureUniqueControlIds.js +110 -0
  84. package/dist/docx/headerFooterVerbatim.d.ts +7 -0
  85. package/dist/docx/headerFooterVerbatim.js +13 -2
  86. package/dist/docx/hostCommentThreads.d.ts +17 -0
  87. package/dist/docx/hostCommentThreads.js +49 -0
  88. package/dist/docx/hyperlinkParser.js +9 -2
  89. package/dist/docx/inlineWrapperContent.d.ts +8 -1
  90. package/dist/docx/inlineWrapperContent.js +9 -2
  91. package/dist/docx/listMarkerComputation.d.ts +35 -1
  92. package/dist/docx/listMarkerComputation.js +39 -1
  93. package/dist/docx/listModelNormalization.d.ts +44 -1
  94. package/dist/docx/listModelNormalization.js +227 -96
  95. package/dist/docx/mainDocumentPart.d.ts +6 -0
  96. package/dist/docx/mainDocumentPart.js +65 -0
  97. package/dist/docx/markupRangeMarker.d.ts +14 -0
  98. package/dist/docx/markupRangeMarker.js +15 -1
  99. package/dist/docx/metadataPrivacy.js +43 -22
  100. package/dist/docx/normalizeBaseDirection.js +3 -1
  101. package/dist/docx/packageParts.d.ts +1 -1
  102. package/dist/docx/packageParts.js +10 -4
  103. package/dist/docx/paragraphParser.js +159 -48
  104. package/dist/docx/paragraphPropertySource.d.ts +7 -0
  105. package/dist/docx/paragraphPropertySource.js +22 -1
  106. package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
  107. package/dist/docx/paragraphTraversal.js +2 -0
  108. package/dist/docx/parseWarningMessage.js +2 -1
  109. package/dist/docx/parser.js +6 -0
  110. package/dist/docx/previewBudget.d.ts +6 -0
  111. package/dist/docx/previewBudget.js +7 -1
  112. package/dist/docx/renderedPageBreakNormalization.js +1 -1
  113. package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
  114. package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
  115. package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
  116. package/dist/docx/reviewResolutionProvenance.js +110 -25
  117. package/dist/docx/rezip.d.ts +6 -0
  118. package/dist/docx/rezip.js +42 -25
  119. package/dist/docx/selectiveSave.js +6 -10
  120. package/dist/docx/selectiveXmlPatch.d.ts +5 -4
  121. package/dist/docx/selectiveXmlPatch.js +11 -7
  122. package/dist/docx/serializer/documentSerializer.js +3 -1
  123. package/dist/docx/serializer/headerFooterSerializer.js +3 -1
  124. package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
  125. package/dist/docx/serializer/markupRangeAttributes.js +6 -1
  126. package/dist/docx/serializer/noteSerializer.d.ts +17 -4
  127. package/dist/docx/serializer/noteSerializer.js +23 -16
  128. package/dist/docx/serializer/paragraphSerializer.js +56 -12
  129. package/dist/docx/serializer/runSerializer.d.ts +1 -3
  130. package/dist/docx/serializer/runSerializer.js +2 -2
  131. package/dist/docx/serializer/tableSerializer.d.ts +4 -0
  132. package/dist/docx/serializer/tableSerializer.js +4 -2
  133. package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
  134. package/dist/docx/server/createBilingualDocument.js +27 -5
  135. package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
  136. package/dist/docx/sessionListPruning.d.ts +2 -0
  137. package/dist/docx/sessionListPruning.js +50 -0
  138. package/dist/docx/shapeAlternateContent.js +19 -0
  139. package/dist/docx/splitRevisionPieces.d.ts +10 -0
  140. package/dist/docx/splitRevisionPieces.js +14 -0
  141. package/dist/docx/storyBlockReplay.js +4 -0
  142. package/dist/docx/structuralXmlPatch.js +19 -7
  143. package/dist/docx/tableParser.d.ts +6 -2
  144. package/dist/docx/tableParser.js +2 -3
  145. package/dist/docx/textBoxContentParser.d.ts +11 -0
  146. package/dist/docx/textBoxContentParser.js +51 -0
  147. package/dist/docx/textBoxParser.d.ts +0 -5
  148. package/dist/docx/textBoxParser.js +1 -23
  149. package/dist/docx/unzip.js +2 -0
  150. package/dist/docx/verticalMergeProjection.js +1 -1
  151. package/dist/fonts/fontsourceFaces.d.ts +2 -8
  152. package/dist/fonts/fontsourceFaces.js +1 -7
  153. package/dist/i18n/messages/ar.gen.js +3 -0
  154. package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
  155. package/dist/i18n/messages/catalogs.gen.js +51 -0
  156. package/dist/i18n/messages/cs.gen.js +3 -0
  157. package/dist/i18n/messages/de.gen.js +3 -0
  158. package/dist/i18n/messages/en.gen.js +3 -0
  159. package/dist/i18n/messages/es.gen.js +3 -0
  160. package/dist/i18n/messages/et.gen.js +3 -0
  161. package/dist/i18n/messages/fr.gen.js +3 -0
  162. package/dist/i18n/messages/he.gen.js +3 -0
  163. package/dist/i18n/messages/hi.gen.js +3 -0
  164. package/dist/i18n/messages/hu.gen.js +3 -0
  165. package/dist/i18n/messages/lt.gen.js +3 -0
  166. package/dist/i18n/messages/lv.gen.js +3 -0
  167. package/dist/i18n/messages/messages.gen.d.ts +3 -0
  168. package/dist/i18n/messages/pl.gen.js +3 -0
  169. package/dist/i18n/messages/pt-BR.gen.js +3 -0
  170. package/dist/i18n/messages/sk.gen.js +3 -0
  171. package/dist/i18n/messages/tr.gen.js +3 -0
  172. package/dist/i18n/messages/zh-CN.gen.js +3 -0
  173. package/dist/internal/acceptedBlockProjection.js +2 -0
  174. package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
  175. package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
  176. package/dist/internal/revisionResolutionInline.js +1 -2
  177. package/dist/internal/wholeStoryRevisionResolution.js +57 -12
  178. package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
  179. package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
  180. package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
  181. package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
  182. package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
  183. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  184. package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
  185. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  186. package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
  187. package/dist/layout-bridge/convert/tableConversion.js +25 -10
  188. package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
  189. package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
  190. package/dist/layout-bridge/engine/blockIndex.js +12 -0
  191. package/dist/layout-bridge/engine/clickToPosition.js +5 -1
  192. package/dist/layout-bridge/engine/hitTest.js +9 -10
  193. package/dist/layout-bridge/engine/selectionRects.js +6 -6
  194. package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
  195. package/dist/layout-engine/footnoteContinuation.js +210 -0
  196. package/dist/layout-engine/index.d.ts +2 -2
  197. package/dist/layout-engine/index.js +7 -2
  198. package/dist/layout-engine/measure/cache.js +10 -5
  199. package/dist/layout-engine/measure/measureParagraph.js +1 -1
  200. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  201. package/dist/layout-engine/measure/tableCellFloating.js +1 -0
  202. package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
  203. package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
  204. package/dist/layout-engine/tableLayout.js +34 -7
  205. package/dist/layout-engine/tableRowBreak.d.ts +46 -0
  206. package/dist/layout-engine/tableRowBreak.js +193 -36
  207. package/dist/layout-engine/types.d.ts +43 -3
  208. package/dist/layout-painter/previewSvg.d.ts +8 -0
  209. package/dist/layout-painter/previewSvg.js +47 -0
  210. package/dist/layout-painter/renderImage.js +2 -1
  211. package/dist/layout-painter/renderPage.d.ts +5 -4
  212. package/dist/layout-painter/renderPage.js +52 -20
  213. package/dist/layout-painter/renderParagraph.js +3 -2
  214. package/dist/layout-painter/renderTable.d.ts +5 -2
  215. package/dist/layout-painter/renderTable.js +39 -22
  216. package/dist/managers/AutoSaveManager.d.ts +5 -1
  217. package/dist/managers/FindReplaceManager.js +3 -10
  218. package/dist/markdown/escape.d.ts +20 -1
  219. package/dist/markdown/escape.js +43 -1
  220. package/dist/markdown/renderBlock.js +4 -1
  221. package/dist/markdown/renderParagraph.js +13 -27
  222. package/dist/markdown/renderTable.js +6 -2
  223. package/dist/markdown/trailers.js +1 -0
  224. package/dist/pdf/images.d.ts +17 -1
  225. package/dist/pdf/images.js +22 -4
  226. package/dist/pdf/writePdf.js +4 -2
  227. package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
  228. package/dist/prosemirror/attrs/index.js +1 -0
  229. package/dist/prosemirror/canonicalCommands.d.ts +39 -1
  230. package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
  231. package/dist/prosemirror/canonicalTableCommands.js +362 -0
  232. package/dist/prosemirror/commands/comments.d.ts +25 -0
  233. package/dist/prosemirror/commands/comments.js +122 -18
  234. package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
  235. package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
  236. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  237. package/dist/prosemirror/commands/index.d.ts +1 -1
  238. package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
  239. package/dist/prosemirror/commands/pastePlainText.js +13 -3
  240. package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
  241. package/dist/prosemirror/commentIdAllocator.js +2 -2
  242. package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
  243. package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
  244. package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
  245. package/dist/prosemirror/commentReferenceIntegrity.js +22 -8
  246. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
  247. package/dist/prosemirror/conversion/fromProseDoc.js +115 -35
  248. package/dist/prosemirror/conversion/index.d.ts +1 -1
  249. package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
  250. package/dist/prosemirror/conversion/toProseDoc.js +325 -55
  251. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  252. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  253. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
  254. package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
  255. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
  256. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
  257. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
  258. package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
  259. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
  260. package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
  261. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
  262. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
  263. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
  264. package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
  265. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
  266. package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
  267. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
  268. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
  269. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
  270. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
  271. package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
  272. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
  273. package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
  274. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
  275. package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
  276. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
  277. package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
  278. package/dist/prosemirror/extensions/nodes/TableExtension.js +119 -38
  279. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
  280. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
  281. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
  282. package/dist/prosemirror/index.d.ts +2 -2
  283. package/dist/prosemirror/listLabels.js +3 -2
  284. package/dist/prosemirror/listNumbering.d.ts +6 -0
  285. package/dist/prosemirror/listNumbering.js +12 -9
  286. package/dist/prosemirror/lockedControls.d.ts +13 -0
  287. package/dist/prosemirror/lockedControls.js +106 -0
  288. package/dist/prosemirror/markupViewProjection.js +1 -1
  289. package/dist/prosemirror/noteReferenceReview.js +2 -2
  290. package/dist/prosemirror/plugins/documentNumbering.js +4 -1
  291. package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
  292. package/dist/prosemirror/plugins/suggestionMode.js +195 -30
  293. package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
  294. package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
  295. package/dist/prosemirror/replacedAnnotations.js +1 -0
  296. package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
  297. package/dist/prosemirror/rowGridOmissions.js +21 -0
  298. package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
  299. package/dist/prosemirror/runFormattingFromMarks.js +2 -4
  300. package/dist/prosemirror/runFormattingReconciliation.js +2 -2
  301. package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
  302. package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
  303. package/dist/prosemirror/runStyleFormatting.js +16 -13
  304. package/dist/prosemirror/schema/marks.d.ts +6 -0
  305. package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
  306. package/dist/prosemirror/tableGridMutation.d.ts +19 -2
  307. package/dist/prosemirror/tableGridMutation.js +118 -15
  308. package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
  309. package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
  310. package/dist/prosemirror/validation.js +2 -1
  311. package/dist/redline.js +23 -9
  312. package/dist/server.d.ts +2 -2
  313. package/dist/style-sets/extract.js +2 -2
  314. package/dist/types/canonicalCapabilities.d.ts +29 -8
  315. package/dist/types/canonicalCapabilities.js +13 -9
  316. package/dist/utils/cssString.d.ts +7 -0
  317. package/dist/utils/cssString.js +9 -0
  318. package/dist/utils/fontResolver.js +4 -1
  319. package/dist/utils/replaceText.d.ts +11 -0
  320. package/dist/utils/replaceText.js +39 -7
  321. package/dist/version-comparison.d.ts +9 -1
  322. package/dist/version-comparison.js +11 -5
  323. package/package.json +2 -2
@@ -660,6 +660,11 @@ function getParagraphBidi(state) {
660
660
  if (paragraph.type.name !== "paragraph") return false;
661
661
  return directionIsRtl(paragraph.attrs["direction"]);
662
662
  }
663
+ /** Set the selected paragraphs' writing direction. */
664
+ const setParagraphDirection = (direction) => withCanonicalParagraphFormatting(setParagraphAttr("direction", {
665
+ source: "manual",
666
+ value: direction
667
+ }), { bidi: direction === "rtl" });
663
668
  const ParagraphExtension = createNodeExtension({
664
669
  name: "paragraph",
665
670
  schemaNodeName: "paragraph",
@@ -829,14 +834,8 @@ const ParagraphExtension = createNodeExtension({
829
834
  return setParagraphAttr("direction", directionFor(paragraph))(state, dispatch);
830
835
  }, (paragraph) => ({ bidi: directionIsRtl(directionFor(paragraph)) }));
831
836
  },
832
- setRtl: () => withCanonicalParagraphFormatting(setParagraphAttr("direction", {
833
- source: "manual",
834
- value: "rtl"
835
- }), { bidi: true }),
836
- setLtr: () => withCanonicalParagraphFormatting(setParagraphAttr("direction", {
837
- source: "manual",
838
- value: "ltr"
839
- }), { bidi: false }),
837
+ setRtl: () => setParagraphDirection("rtl"),
838
+ setLtr: () => setParagraphDirection("ltr"),
840
839
  setTabs: (tabs) => withCanonicalParagraphFormatting(setParagraphAttr("tabs", tabs.length > 0 ? tabs : null), { tabs: tabs.length > 0 ? tabs : null }),
841
840
  addTabStop: (position, alignment = "left", leader = "none") => {
842
841
  const tabsFor = (paragraph) => [...(expectParagraphAttrs(paragraph).tabs ?? []).filter((tab) => tab.position !== position), {
@@ -864,4 +863,4 @@ const ParagraphExtension = createNodeExtension({
864
863
  } };
865
864
  }
866
865
  });
867
- export { ParagraphExtension, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId };
866
+ export { ParagraphExtension, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId, setParagraphDirection };
@@ -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;
@@ -3,6 +3,7 @@ import { getTransactionDirtyRange } from "../../../paged-layout/transactionDirty
3
3
  import { detectBaseDirection } from "../../../utils/baseDirection.js";
4
4
  import { directionIsAutoManaged } from "../../paragraphDirection.js";
5
5
  import { createPluginKeyOwner } from "../../pluginKeyOwner.js";
6
+ import { afterNativeCompositionFlush } from "../../textInput.js";
6
7
  import { createExtension } from "../create.js";
7
8
  import { ignoreTrackedChanges } from "./ParagraphChangeTrackerExtension.js";
8
9
  import { Plugin } from "prosemirror-state";
@@ -130,17 +131,51 @@ const ensureBaseDirectionInState = (state) => {
130
131
  if (updates.length === 0) return state;
131
132
  return state.apply(applyBidiUpdates(state, updates));
132
133
  };
133
- const createAutoBidiDetectionPlugin = () => new Plugin({
134
- key: autoBidiDetectionKey.createKey(),
135
- appendTransaction(transactions, _oldState, newState) {
136
- if (!transactions.some((t) => t.docChanged)) return null;
137
- const [first, ...rest] = transactions;
138
- const range = first && rest.length === 0 ? getTransactionDirtyRange(first) : null;
139
- const updates = range ? collectBidiUpdatesInRange(newState.doc, range) : collectBidiUpdates(newState.doc);
140
- if (updates.length === 0) return null;
141
- return applyBidiUpdates(newState, updates);
142
- }
143
- });
134
+ const createAutoBidiDetectionPlugin = () => {
135
+ const composing = /* @__PURE__ */ new Set();
136
+ let deferred = false;
137
+ const finish = (view) => {
138
+ composing.delete(view);
139
+ if (!deferred || composing.size > 0 || view.isDestroyed) return;
140
+ deferred = false;
141
+ const updates = collectBidiUpdates(view.state.doc);
142
+ if (updates.length > 0) view.dispatch(applyBidiUpdates(view.state, updates));
143
+ };
144
+ return new Plugin({
145
+ key: autoBidiDetectionKey.createKey(),
146
+ view: (view) => ({ destroy: () => {
147
+ composing.delete(view);
148
+ } }),
149
+ props: { handleDOMEvents: {
150
+ compositionstart(view) {
151
+ composing.add(view);
152
+ return false;
153
+ },
154
+ compositionend(view) {
155
+ afterNativeCompositionFlush(() => {
156
+ finish(view);
157
+ });
158
+ return false;
159
+ },
160
+ blur(view) {
161
+ finish(view);
162
+ return false;
163
+ }
164
+ } },
165
+ appendTransaction(transactions, _oldState, newState) {
166
+ if (!transactions.some((t) => t.docChanged)) return null;
167
+ if (composing.size > 0) {
168
+ deferred = true;
169
+ return null;
170
+ }
171
+ const [first, ...rest] = transactions;
172
+ const range = first && rest.length === 0 ? getTransactionDirtyRange(first) : null;
173
+ const updates = range ? collectBidiUpdatesInRange(newState.doc, range) : collectBidiUpdates(newState.doc);
174
+ if (updates.length === 0) return null;
175
+ return applyBidiUpdates(newState, updates);
176
+ }
177
+ });
178
+ };
144
179
  const AutoBidiDetectionExtension = createExtension({
145
180
  name: "autoBidiDetection",
146
181
  defaultOptions: {},
@@ -1,6 +1,7 @@
1
1
  import { mergeTextFormatting } from "../../../utils/textFormattingMerge.js";
2
2
  import { expectCharacterStyleMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs } from "../../attrs/index.js";
3
3
  import { clearIndentOnBackspace } from "../../commands/clearParagraphIndent.js";
4
+ import { deleteBesideInlineAnchor } from "../../commands/deleteBesideInlineAnchor.js";
4
5
  import { keepSectionBreaksOnSurvivingMarks } from "../../commands/sectionBreak.js";
5
6
  import { getDocumentStyleResolver } from "../../plugins/documentStyleState.js";
6
7
  import { RUN_FORMATTING_MARK_NAMES } from "../../runFormattingMarkNames.js";
@@ -232,8 +233,8 @@ const BaseKeymapExtension = createExtension({
232
233
  return { keyboardShortcuts: {
233
234
  ...baseKeymap,
234
235
  Enter: splitBlockClearBorders,
235
- Backspace: keepSectionBreaksOnSurvivingMarks(chainCommands(deleteSelection, clearIndentOnBackspace, joinBackward)),
236
- Delete: keepSectionBreaksOnSurvivingMarks(chainCommands(deleteSelection, joinForward)),
236
+ Backspace: keepSectionBreaksOnSurvivingMarks(chainCommands(deleteSelection, deleteBesideInlineAnchor(joinBackward, "backward"), clearIndentOnBackspace, joinBackward)),
237
+ Delete: keepSectionBreaksOnSurvivingMarks(chainCommands(deleteSelection, deleteBesideInlineAnchor(joinForward, "forward"), joinForward)),
237
238
  "Mod-a": selectAll,
238
239
  Escape: selectParentNode
239
240
  } };
@@ -1,4 +1,4 @@
1
- import { singletonManager } from "../../schema/index.js";
1
+ import { setParagraphDirection } from "../core/ParagraphExtension.js";
2
2
  import { createExtension } from "../create.js";
3
3
  import { Priority } from "../types.js";
4
4
  import { createBidiShortcutController } from "./bidiShortcutController.js";
@@ -27,8 +27,7 @@ const BidiShortcutExtension = createExtension({
27
27
  handleDOMEvents: { keyup(view, event) {
28
28
  const direction = controller.handleKeyUp(event);
29
29
  if (!direction) return false;
30
- const cmds = singletonManager.getCommands();
31
- (direction === "ltr" ? cmds["setLtr"] : cmds["setRtl"])?.()(view.state, view.dispatch);
30
+ setParagraphDirection(direction)(view.state, view.dispatch);
32
31
  return false;
33
32
  } }
34
33
  } })] };
@@ -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;
@@ -383,6 +383,27 @@ const listAutoformatRule = () => new InputRule(LIST_MARKER_PATTERN, (state, matc
383
383
  requests
384
384
  }) ? tr : null;
385
385
  });
386
+ const liveText = (paragraph, end) => {
387
+ let text = "";
388
+ paragraph.forEach((node, offset) => {
389
+ if (offset < end && !node.marks.some(({ type }) => type.name === "deletion")) text += node.isText ? (node.text ?? "").slice(0, end - offset) : "";
390
+ });
391
+ return text;
392
+ };
393
+ /**
394
+ * The text before the caret once what is struck has gone: what typing over a
395
+ * selection leaves. A paragraph whose break is struck joins the one after it.
396
+ */
397
+ const textBeforeCaretLeft = ($head) => {
398
+ let text = liveText($head.parent, $head.parentOffset);
399
+ const container = $head.node($head.depth - 1);
400
+ for (let index = $head.index($head.depth - 1) - 1; index >= 0; index--) {
401
+ const before = container.child(index);
402
+ if (before.attrs["pPrMark"]?.kind !== "del") break;
403
+ text = liveText(before, before.content.size) + text;
404
+ }
405
+ return text;
406
+ };
386
407
  /**
387
408
  * List autoformat while suggesting. The suggestion plugin has already
388
409
  * recorded the typed space as a tracked insertion; this follows it with the
@@ -396,7 +417,7 @@ const suggestedListAutoformat = (autoformat) => new Plugin({ appendTransaction(t
396
417
  if (!transactions.some((tr) => tr.getMeta("suggestionModeTextInput") === " ")) return null;
397
418
  const { $head, empty } = state.selection;
398
419
  if (!empty || !makeRevisionInfo(state) || !acceptsListMarker($head.parent)) return null;
399
- const requests = listRequestsForMarker($head.parent.textBetween(0, $head.parentOffset, null, ""));
420
+ const requests = listRequestsForMarker(textBeforeCaretLeft($head));
400
421
  if (!requests) return null;
401
422
  const start = $head.start();
402
423
  const tr = state.tr;
@@ -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 {};
@@ -104,5 +104,5 @@ type MarkChangedParagraphRangesOptions = {
104
104
  };
105
105
  /** Record mark-only paragraph changes whose replacement step has a granular map. */
106
106
  export declare function markChangedParagraphRanges(tr: Transaction, batch: MarkChangedParagraphRangesOptions): Transaction;
107
- export declare const ParagraphChangeTrackerExtension: (options?: Partial<{}> | undefined) => Extension;
107
+ export declare const ParagraphChangeTrackerExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
108
108
  export {};
@@ -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,12 @@ 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
+ },
18
21
  inclusive: false,
19
22
  parseDOM: [{
20
23
  tag: "span.docx-comment",
@@ -140,6 +140,11 @@ const HyperlinkExtension = createMarkExtension({
140
140
  tooltip: tooltip || null
141
141
  });
142
142
  let tr = state.tr.addMark(from, to, mark);
143
+ state.doc.nodesBetween(from, to, (node, position) => {
144
+ if (node.type.name !== "field" && node.type.name !== "structuredField") return true;
145
+ tr = tr.removeMark(position, position + node.nodeSize, hlType);
146
+ return false;
147
+ });
143
148
  const textColorType = state.schema.marks["textColor"];
144
149
  if (textColorType) tr = tr.removeMark(from, to, textColorType);
145
150
  dispatch(tr.scrollIntoView());
@@ -22,7 +22,7 @@ const TextColorExtension = createMarkExtension({
22
22
  parseDOM: [{
23
23
  style: "color",
24
24
  getAttrs: (value) => {
25
- const hexMatch = /#(?<hex>[0-9a-fA-F]{6}|[0-9a-fA-F]{3})/u.exec(value);
25
+ const hexMatch = /^#(?<hex>[0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/u.exec(value);
26
26
  if (hexMatch) return { rgb: (hexMatch.groups?.["hex"] ?? "").toUpperCase() };
27
27
  return false;
28
28
  }
@@ -16,9 +16,13 @@ import { authorFromClipboardRevision } from "../features/clipboardTrackedRevisio
16
16
  * ProseMirror toDOM runs before the layout painter, so we set the
17
17
  * decoration here for correct rendering in both the layout-painter
18
18
  * path and the ProseMirror DOM path.
19
+ *
20
+ * The line is a longhand because the underline and strike parse rules read the
21
+ * `text-decoration` shorthand. A review mark's presentation is not run
22
+ * formatting, and ProseMirror reads this DOM back on every native edit.
19
23
  */
20
- const insertionStyle = (color) => `color: ${color}; text-decoration: underline; text-decoration-color: ${color};`;
21
- const deletionStyle = (color) => `color: ${color}; text-decoration: line-through; text-decoration-color: ${color};`;
24
+ const insertionStyle = (color) => `color: ${color}; text-decoration-line: underline; text-decoration-color: ${color};`;
25
+ const deletionStyle = (color) => `color: ${color}; text-decoration-line: line-through; text-decoration-color: ${color};`;
22
26
  /**
23
27
  * Suggested (AI-proposed) tracked changes reuse the insertion/deletion visual
24
28
  * grammar but with a DOTTED stroke and a dedicated suggestion hue, kept
@@ -31,8 +35,8 @@ const deletionStyle = (color) => `color: ${color}; text-decoration: line-through
31
35
  const SUGGESTION_COLOR = "var(--suggestion-color, #6d3bd6)";
32
36
  const SUGGESTION_TINT = "var(--suggestion-bg, color-mix(in oklch, #6d3bd6 12%, transparent))";
33
37
  const SUGGESTION_TINT_LAYER = `linear-gradient(${SUGGESTION_TINT}, ${SUGGESTION_TINT})`;
34
- const suggestedInsertionStyle = () => `color: ${SUGGESTION_COLOR}; text-decoration: underline; text-decoration-style: dotted; text-decoration-color: ${SUGGESTION_COLOR}; background-image: ${SUGGESTION_TINT_LAYER};`;
35
- const suggestedDeletionStyle = () => `color: ${SUGGESTION_COLOR}; text-decoration: line-through; text-decoration-style: dotted; text-decoration-color: ${SUGGESTION_COLOR}; background-image: ${SUGGESTION_TINT_LAYER};`;
38
+ const suggestedInsertionStyle = () => `color: ${SUGGESTION_COLOR}; text-decoration-line: underline; text-decoration-style: dotted; text-decoration-color: ${SUGGESTION_COLOR}; background-image: ${SUGGESTION_TINT_LAYER};`;
39
+ const suggestedDeletionStyle = () => `color: ${SUGGESTION_COLOR}; text-decoration-line: line-through; text-decoration-style: dotted; text-decoration-color: ${SUGGESTION_COLOR}; background-image: ${SUGGESTION_TINT_LAYER};`;
36
40
  const revisionAncestorsFromDom = (serialized) => {
37
41
  if (serialized === void 0) return null;
38
42
  try {
@@ -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 };
@@ -4,6 +4,7 @@ import { findInvalidBookmarkBoundaryIds } from "../../bookmarkBoundaryIntegrity.
4
4
  import { createNodeExtension } from "../create.js";
5
5
  import { BLOCK_BOOKMARK_BOUNDARY_NODE_NAME } from "./BlockBookmarkBoundaryExtension.js";
6
6
  import { bookmarkBoundaryAttrSpec, bookmarkBoundaryDomAttributes, parseBookmarkBoundaryDom } from "./bookmarkBoundaryDom.js";
7
+ import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
7
8
  import { Plugin } from "prosemirror-state";
8
9
  // src/prosemirror/extensions/nodes/BookmarkBoundaryExtension.ts
9
10
  /** The node name, for callers asking whether a paragraph holds any content. */
@@ -73,7 +74,10 @@ const BookmarkBoundaryExtension = createNodeExtension({
73
74
  getAttrs: (dom) => parseBookmarkBoundaryDom(dom, options.getInternalClipboardToken?.())
74
75
  }],
75
76
  toDOM(node) {
76
- return ["span", bookmarkBoundaryDomAttributes(node, options.getInternalClipboardToken?.())];
77
+ return ["span", {
78
+ ...bookmarkBoundaryDomAttributes(node, options.getInternalClipboardToken?.()),
79
+ style: INLINE_ANCHOR_DOM_STYLE
80
+ }];
77
81
  }
78
82
  }),
79
83
  onSchemaReady: () => ({ plugins: [new Plugin({ appendTransaction(transactions, _oldState, newState) {
@@ -1,5 +1,6 @@
1
1
  import { expectCommentRangeBoundaryAttrs, readCommentRangeBoundaryMarker } from "../../commentRangeBoundaryAttrs.js";
2
2
  import { createNodeExtension } from "../create.js";
3
+ import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
3
4
  // src/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.ts
4
5
  const COMMENT_RANGE_BOUNDARY_NODE_NAME = "commentRangeBoundary";
5
6
  const COMMENT_RANGE_BOUNDARY_DOM_ATTRIBUTE = "data-docx-comment-range-boundary";
@@ -33,7 +34,7 @@ const CommentRangeBoundaryExtension = createNodeExtension({
33
34
  [COMMENT_RANGE_BOUNDARY_DOM_ATTRIBUTE]: JSON.stringify(marker),
34
35
  "aria-hidden": "true",
35
36
  contenteditable: "false",
36
- style: "display: none;",
37
+ style: INLINE_ANCHOR_DOM_STYLE,
37
38
  ...options.getInternalClipboardToken ? { "data-docx-internal-clipboard": options.getInternalClipboardToken() } : {}
38
39
  }];
39
40
  }
@@ -1,6 +1,7 @@
1
1
  import { readCommentReferenceAttrs } from "../../commentReferenceAttrs.js";
2
2
  import { COMMENT_REFERENCE_NODE_NAME, resolveCommentReferences } from "../../commentReferenceIntegrity.js";
3
3
  import { createNodeExtension } from "../create.js";
4
+ import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
4
5
  import { Plugin } from "prosemirror-state";
5
6
  // src/prosemirror/extensions/nodes/CommentReferenceExtension.ts
6
7
  /** Zero-width `w:commentReference`: where a comment's visible mark is painted. */
@@ -29,14 +30,14 @@ const CommentReferenceExtension = createNodeExtension({
29
30
  "data-docx-comment-reference": String(attrs.ok ? attrs.value.commentId : ""),
30
31
  "aria-hidden": "true",
31
32
  contenteditable: "false",
32
- style: "display: none;",
33
+ style: INLINE_ANCHOR_DOM_STYLE,
33
34
  ...options.getInternalClipboardToken ? { "data-docx-internal-clipboard": options.getInternalClipboardToken() } : {}
34
35
  }];
35
36
  }
36
37
  }),
37
- onSchemaReady: () => ({ plugins: [new Plugin({ appendTransaction(transactions, _oldState, newState) {
38
+ onSchemaReady: () => ({ plugins: [new Plugin({ appendTransaction(transactions, oldState, newState) {
38
39
  if (!transactions.some(({ docChanged }) => docChanged)) return null;
39
- const resolution = resolveCommentReferences(newState.doc);
40
+ const resolution = resolveCommentReferences(newState.doc, oldState.doc);
40
41
  if (!resolution) return null;
41
42
  const transaction = newState.tr;
42
43
  for (const step of resolution.steps) transaction.step(step);
@@ -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
  };
@@ -1,6 +1,7 @@
1
1
  import { INTERNAL_CLIPBOARD_TOKEN_ATTRIBUTE, isInternalClipboardDom } from "../../copyOriginDom.js";
2
2
  import { expectMoveRangeBoundaryAttrs, moveRangeMarkerForDom, readMoveRangeMarker, withoutUntrustedCopyOrigin } from "../../moveRangeBoundaryAttrs.js";
3
3
  import { createNodeExtension } from "../create.js";
4
+ import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
4
5
  // src/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.ts
5
6
  /** Hidden boundary for one non-empty tracked-move range. */
6
7
  const MOVE_RANGE_BOUNDARY_NODE_NAME = "moveRangeBoundary";
@@ -37,7 +38,7 @@ const MoveRangeBoundaryExtension = createNodeExtension({
37
38
  [MOVE_RANGE_BOUNDARY_DOM_ATTRIBUTE]: JSON.stringify(marker),
38
39
  "aria-hidden": "true",
39
40
  contenteditable: "false",
40
- style: "display: none;",
41
+ style: INLINE_ANCHOR_DOM_STYLE,
41
42
  ...internalClipboardToken ? { [INTERNAL_CLIPBOARD_TOKEN_ATTRIBUTE]: internalClipboardToken } : {}
42
43
  }];
43
44
  }
@@ -1,5 +1,6 @@
1
1
  import { expectNoteMarkerAttrs } from "../../../internal/noteMarkerAttrs.js";
2
2
  import { createNodeExtension } from "../create.js";
3
+ import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
3
4
  // src/prosemirror/extensions/nodes/NoteMarkerExtension.ts
4
5
  /** An authored automatic note mark: invisible, but retained through PM JSON and edits. */
5
6
  const NOTE_MARKER_NODE_NAME = "noteMarker";
@@ -27,7 +28,7 @@ const NoteMarkerExtension = createNodeExtension({
27
28
  "data-docx-note-marker": kind,
28
29
  "aria-hidden": "true",
29
30
  contenteditable: "false",
30
- style: "display: none;"
31
+ style: INLINE_ANCHOR_DOM_STYLE
31
32
  }];
32
33
  }
33
34
  }
@@ -3,6 +3,7 @@ import { INTERNAL_CLIPBOARD_TOKEN_ATTRIBUTE, isInternalClipboardDom } from "../.
3
3
  import { withoutUntrustedCopyOrigin } from "../../moveRangeBoundaryAttrs.js";
4
4
  import { readRangeAnchorAttrs, readRangeAnchorValues } from "../../rangeAnchorAttrs.js";
5
5
  import { createNodeExtension } from "../create.js";
6
+ import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
6
7
  // src/prosemirror/extensions/nodes/RangeAnchorExtension.ts
7
8
  /** Zero-width comment or tracked-move range that spans no content. */
8
9
  /** The node name, for callers asking whether a paragraph holds any content. */
@@ -52,7 +53,7 @@ const RangeAnchorExtension = createNodeExtension({
52
53
  [RANGE_ANCHOR_DOM_ATTRIBUTE]: serializedMarkers,
53
54
  "aria-hidden": "true",
54
55
  contenteditable: "false",
55
- style: "display: none;",
56
+ style: INLINE_ANCHOR_DOM_STYLE,
56
57
  ...internalClipboardToken ? { [INTERNAL_CLIPBOARD_TOKEN_ATTRIBUTE]: internalClipboardToken } : {}
57
58
  }];
58
59
  }
@@ -1,4 +1,5 @@
1
1
  import { createNodeExtension } from "../create.js";
2
+ import { INLINE_ANCHOR_DOM_STYLE } from "./inlineAnchorDom.js";
2
3
  // src/prosemirror/extensions/nodes/RenderedPageBreakExtension.ts
3
4
  /** Zero-width cached pagination boundary preserved from DOCX. */
4
5
  /**
@@ -19,7 +20,7 @@ const RenderedPageBreakExtension = createNodeExtension({
19
20
  toDOM() {
20
21
  return ["span", {
21
22
  "data-docx-rendered-page-break": "true",
22
- style: "display: none;"
23
+ style: INLINE_ANCHOR_DOM_STYLE
23
24
  }];
24
25
  }
25
26
  }