@notectl/core 2.3.7 → 2.4.2
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.
- package/README.md +1 -1
- package/dist/chunks/AlignmentPlugin-Cp7HYGaH.mjs +2 -0
- package/dist/chunks/AlignmentPlugin-Cp7HYGaH.mjs.map +1 -0
- package/dist/chunks/{AttrRegistry-CtNhf2EF.mjs → AttrRegistry-Di936wMv.mjs} +2 -2
- package/dist/chunks/AttrRegistry-Di936wMv.mjs.map +1 -0
- package/dist/chunks/{AttributedMarkCommands-B3MQdob_.mjs → AttributedMarkCommands-DKHuhZA7.mjs} +2 -2
- package/dist/chunks/AttributedMarkCommands-DKHuhZA7.mjs.map +1 -0
- package/dist/chunks/BidiIsolationPlugin-GWukKdgJ.mjs +2 -0
- package/dist/chunks/BidiIsolationPlugin-GWukKdgJ.mjs.map +1 -0
- package/dist/chunks/BlockAlignment-BqyBQ4uV.mjs +2 -0
- package/dist/chunks/BlockAlignment-BqyBQ4uV.mjs.map +1 -0
- package/dist/chunks/BlockInsertion-CXfXqUZl.mjs +2 -0
- package/dist/chunks/BlockInsertion-CXfXqUZl.mjs.map +1 -0
- package/dist/chunks/BlockTypePickerRegistry-BTET9jM-.mjs.map +1 -1
- package/dist/chunks/BlockquotePlugin-CSL_7Yit.mjs +2 -0
- package/dist/chunks/BlockquotePlugin-CSL_7Yit.mjs.map +1 -0
- package/dist/chunks/CSSValueEquivalence-DeyUKPQ7.mjs +2 -0
- package/dist/chunks/CSSValueEquivalence-DeyUKPQ7.mjs.map +1 -0
- package/dist/chunks/{CaretNavigationPlugin-DEZU09LJ.mjs → CaretNavigationPlugin-BQPqqK4n.mjs} +2 -2
- package/dist/chunks/CaretNavigationPlugin-BQPqqK4n.mjs.map +1 -0
- package/dist/chunks/CodeBlockPlugin-B4AcDJRK.mjs +2 -0
- package/dist/chunks/CodeBlockPlugin-B4AcDJRK.mjs.map +1 -0
- package/dist/chunks/ColorGrid-DAs0--ty.mjs.map +1 -1
- package/dist/chunks/ColorPickerPopup-B6340f3p.mjs +2 -0
- package/dist/chunks/ColorPickerPopup-B6340f3p.mjs.map +1 -0
- package/dist/chunks/{ColorValidation-B9d_umnf.mjs → ColorValidation-ZBKZ_gTr.mjs} +2 -2
- package/dist/chunks/ColorValidation-ZBKZ_gTr.mjs.map +1 -0
- package/dist/chunks/Commands-Bk7Cl1nH.mjs +2 -0
- package/dist/chunks/Commands-Bk7Cl1nH.mjs.map +1 -0
- package/dist/chunks/ContentModel-dkGOh3N7.mjs +2 -0
- package/dist/chunks/ContentModel-dkGOh3N7.mjs.map +1 -0
- package/dist/chunks/{CursorMarks-dx51OGBf.mjs → CursorMarks-CqHLzGNI.mjs} +2 -2
- package/dist/chunks/CursorMarks-CqHLzGNI.mjs.map +1 -0
- package/dist/chunks/{Decoration-BwhoA4MU.mjs → Decoration-BoFcdSXk.mjs} +2 -2
- package/dist/chunks/Decoration-BoFcdSXk.mjs.map +1 -0
- package/dist/chunks/{DirectionDetection-ZrkMhyaL.mjs → DirectionDetection-a-1iksmh.mjs} +2 -2
- package/dist/chunks/DirectionDetection-a-1iksmh.mjs.map +1 -0
- package/dist/chunks/DirectionIcons-Bbawl9ei.mjs.map +1 -1
- package/dist/chunks/{Document-D_2cIBJG.mjs → Document-ssR6hBzG.mjs} +2 -2
- package/dist/chunks/Document-ssR6hBzG.mjs.map +1 -0
- package/dist/chunks/DocumentParser-C99N0MWF.mjs +2 -0
- package/dist/chunks/DocumentParser-C99N0MWF.mjs.map +1 -0
- package/dist/chunks/DomUtils-Bf7JLFlx.mjs.map +1 -1
- package/dist/chunks/EditorEventBoundary-zpYRxryo.mjs.map +1 -1
- package/dist/chunks/FontPlugin-BcXNFqqO.mjs +2 -0
- package/dist/chunks/FontPlugin-BcXNFqqO.mjs.map +1 -0
- package/dist/chunks/FontSizePlugin-Dswra3oU.mjs +2 -0
- package/dist/chunks/FontSizePlugin-Dswra3oU.mjs.map +1 -0
- package/dist/chunks/FormulaPlugin-DVpLaKi5.mjs +2 -0
- package/dist/chunks/FormulaPlugin-DVpLaKi5.mjs.map +1 -0
- package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs +2 -0
- package/dist/chunks/GapCursorPlugin-QDGwnaRR.mjs.map +1 -0
- package/dist/chunks/HTMLSanitization-Ce9dVT1q.mjs.map +1 -1
- package/dist/chunks/HTMLUtils-DTpsjZyK.mjs +2 -0
- package/dist/chunks/HTMLUtils-DTpsjZyK.mjs.map +1 -0
- package/dist/chunks/{HardBreakPlugin-CC4rntSX.mjs → HardBreakPlugin-gjCq8prD.mjs} +2 -2
- package/dist/chunks/HardBreakPlugin-gjCq8prD.mjs.map +1 -0
- package/dist/chunks/HeadingPlugin-B7EfynaH.mjs +2 -0
- package/dist/chunks/HeadingPlugin-B7EfynaH.mjs.map +1 -0
- package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs +2 -0
- package/dist/chunks/HighlightPlugin-LdO0INtJ.mjs.map +1 -0
- package/dist/chunks/HorizontalRulePlugin-YywXVZYr.mjs +2 -0
- package/dist/chunks/HorizontalRulePlugin-YywXVZYr.mjs.map +1 -0
- package/dist/chunks/ImagePlugin-BAhZuVdE.mjs +2 -0
- package/dist/chunks/ImagePlugin-BAhZuVdE.mjs.map +1 -0
- package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs +2 -0
- package/dist/chunks/InlineCodePlugin-Bu9-rE4B.mjs.map +1 -0
- package/dist/chunks/InlineStyleMarkSpec-BhfGgfH9.mjs +2 -0
- package/dist/chunks/InlineStyleMarkSpec-BhfGgfH9.mjs.map +1 -0
- package/dist/chunks/KeyboardNav-D0my3wuy.mjs.map +1 -1
- package/dist/chunks/LinkPlugin-CAUaWW5-.mjs +2 -0
- package/dist/chunks/LinkPlugin-CAUaWW5-.mjs.map +1 -0
- package/dist/chunks/{ListPlugin--dqEctgn.mjs → ListPlugin-U1r4p_fE.mjs} +2 -2
- package/dist/chunks/ListPlugin-U1r4p_fE.mjs.map +1 -0
- package/dist/chunks/MarkCommands-C0ps9h0z.mjs +2 -0
- package/dist/chunks/MarkCommands-C0ps9h0z.mjs.map +1 -0
- package/dist/chunks/MarkInputRule-DNneF2gp.mjs.map +1 -1
- package/dist/chunks/MarkdownHTMLRegistry-BunUDiza.mjs +2 -0
- package/dist/chunks/MarkdownHTMLRegistry-BunUDiza.mjs.map +1 -0
- package/dist/chunks/{MarkdownParser-D1d9zB0R.mjs → MarkdownParser-uX1p_GQk.mjs} +2 -2
- package/dist/chunks/MarkdownParser-uX1p_GQk.mjs.map +1 -0
- package/dist/chunks/MarkdownSerializer--MrgJTdJ.mjs +2 -0
- package/dist/chunks/MarkdownSerializer--MrgJTdJ.mjs.map +1 -0
- package/dist/chunks/MathFont-BS8IwYh2.mjs.map +1 -1
- package/dist/chunks/NavigationQueries-CaKfccu7.mjs +2 -0
- package/dist/chunks/NavigationQueries-CaKfccu7.mjs.map +1 -0
- package/dist/chunks/NodeResolver-F4RtpoEd.mjs +2 -0
- package/dist/chunks/NodeResolver-F4RtpoEd.mjs.map +1 -0
- package/dist/chunks/{NodeSelectionCommands-DK3iEh18.mjs → NodeSelectionCommands-CAqIHW_6.mjs} +2 -2
- package/dist/chunks/NodeSelectionCommands-CAqIHW_6.mjs.map +1 -0
- package/dist/chunks/NodeSpecPatching-BrjPAbqe.mjs.map +1 -1
- package/dist/chunks/Platform-ByobkiCc.mjs.map +1 -1
- package/dist/chunks/PluginHelpers-B3gk3VB3.mjs +2 -0
- package/dist/chunks/PluginHelpers-B3gk3VB3.mjs.map +1 -0
- package/dist/chunks/PopupKeyboardPatterns-BcwdDxRq.mjs.map +1 -1
- package/dist/chunks/PopupManager-Dxv0OVMo.mjs +2 -0
- package/dist/chunks/PopupManager-Dxv0OVMo.mjs.map +1 -0
- package/dist/chunks/PopupPositioning-CIqgpqlW.mjs.map +1 -1
- package/dist/chunks/{PrintPlugin-BQ7LWbEB.mjs → PrintPlugin-DAEiEyKQ.mjs} +2 -2
- package/dist/chunks/PrintPlugin-DAEiEyKQ.mjs.map +1 -0
- package/dist/chunks/{RangeIterator-DDOxTQIf.mjs → RangeIterator-sJ_c9MNr.mjs} +2 -2
- package/dist/chunks/RangeIterator-sJ_c9MNr.mjs.map +1 -0
- package/dist/chunks/Schema-BSM4YLNT.mjs +2 -0
- package/dist/chunks/Schema-BSM4YLNT.mjs.map +1 -0
- package/dist/chunks/SchemaRegistry-Cs7rxafF.mjs +2 -0
- package/dist/chunks/SchemaRegistry-Cs7rxafF.mjs.map +1 -0
- package/dist/chunks/Selection-DC6AOGgF.mjs.map +1 -1
- package/dist/chunks/SelectionReplacement-vC1xhFS0.mjs +2 -0
- package/dist/chunks/SelectionReplacement-vC1xhFS0.mjs.map +1 -0
- package/dist/chunks/SelectionSync-BkjCwGp-.mjs +2 -0
- package/dist/chunks/SelectionSync-BkjCwGp-.mjs.map +1 -0
- package/dist/chunks/{SelectionTransactions-DNCzsl_b.mjs → SelectionTransactions-mQ1NfMEg.mjs} +2 -2
- package/dist/chunks/SelectionTransactions-mQ1NfMEg.mjs.map +1 -0
- package/dist/chunks/ShortcutFormatting-TwiufqeV.mjs.map +1 -1
- package/dist/chunks/SimpleMark-D6vz3Nfd.mjs +2 -0
- package/dist/chunks/SimpleMark-D6vz3Nfd.mjs.map +1 -0
- package/dist/chunks/SmartPastePlugin-BHsYKbgd.mjs +2 -0
- package/dist/chunks/SmartPastePlugin-BHsYKbgd.mjs.map +1 -0
- package/dist/chunks/StarterFonts-BDQPg-cu.mjs.map +1 -1
- package/dist/chunks/{StrikethroughPlugin-d-EW2YYx.mjs → StrikethroughPlugin-v-VJZzUZ.mjs} +2 -2
- package/dist/chunks/StrikethroughPlugin-v-VJZzUZ.mjs.map +1 -0
- package/dist/chunks/StyleClassNames-BsAx7k5T.mjs +2 -0
- package/dist/chunks/StyleClassNames-BsAx7k5T.mjs.map +1 -0
- package/dist/chunks/StyleRuntime-C0RSqKzG.mjs.map +1 -1
- package/dist/chunks/{SuperSubPlugin-C-kvFQyx.mjs → SuperSubPlugin-x1iPnZyt.mjs} +2 -2
- package/dist/chunks/SuperSubPlugin-x1iPnZyt.mjs.map +1 -0
- package/dist/chunks/SyntaxTokenTypes-BUCOMtL8.mjs.map +1 -1
- package/dist/chunks/TableDimensions-BSEOEox2.mjs +2 -0
- package/dist/chunks/TableDimensions-BSEOEox2.mjs.map +1 -0
- package/dist/chunks/TablePlugin-CjKThPug.mjs +2 -0
- package/dist/chunks/TablePlugin-CjKThPug.mjs.map +1 -0
- package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs +2 -0
- package/dist/chunks/TextColorPlugin-Bnl9of9E.mjs.map +1 -0
- package/dist/chunks/{TextDirectionAutoPlugin-LVDkKdDX.mjs → TextDirectionAutoPlugin-DOH5cfyy.mjs} +2 -2
- package/dist/chunks/TextDirectionAutoPlugin-DOH5cfyy.mjs.map +1 -0
- package/dist/chunks/{TextDirectionPlugin-CtGwof7i.mjs → TextDirectionPlugin-JwlR-R-b.mjs} +2 -2
- package/dist/chunks/TextDirectionPlugin-JwlR-R-b.mjs.map +1 -0
- package/dist/chunks/TextDirectionService-BcX07mw2.mjs +2 -0
- package/dist/chunks/TextDirectionService-BcX07mw2.mjs.map +1 -0
- package/dist/chunks/{TextFormattingPlugin-DlS0SeW7.mjs → TextFormattingPlugin-Kc_UNoOz.mjs} +2 -2
- package/dist/chunks/TextFormattingPlugin-Kc_UNoOz.mjs.map +1 -0
- package/dist/chunks/ThemeEngine-kIXtSRkI.mjs.map +1 -1
- package/dist/chunks/ToolbarPlugin-CgZA2hz8.mjs +2 -0
- package/dist/chunks/ToolbarPlugin-CgZA2hz8.mjs.map +1 -0
- package/dist/chunks/TypeBrands-Ch9856Gb.mjs.map +1 -1
- package/dist/chunks/TypedKeys-CA4bfw9O.mjs.map +1 -1
- package/dist/chunks/VideoPlugin-DJXfuNA9.mjs +2 -0
- package/dist/chunks/VideoPlugin-DJXfuNA9.mjs.map +1 -0
- package/dist/chunks/XmlPatterns-RN32-0ob.mjs.map +1 -1
- package/dist/chunks/XmlSupport-3Za6SIqF.mjs.map +1 -1
- package/dist/chunks/ar--Isa9OHJ.mjs.map +1 -1
- package/dist/chunks/ar--O0A9OTR.mjs.map +1 -1
- package/dist/chunks/ar-0g2bmXTn.mjs.map +1 -1
- package/dist/chunks/ar-4b8e2YSc.mjs.map +1 -1
- package/dist/chunks/ar-B03uY4xr.mjs.map +1 -1
- package/dist/chunks/ar-BAfInw85.mjs.map +1 -1
- package/dist/chunks/ar-BRX5E_Pw.mjs.map +1 -1
- package/dist/chunks/ar-BWOue6jG.mjs.map +1 -1
- package/dist/chunks/ar-Bdmunk5h.mjs.map +1 -1
- package/dist/chunks/ar-BwaoCUVN.mjs.map +1 -1
- package/dist/chunks/ar-BzqAYGER.mjs.map +1 -1
- package/dist/chunks/ar-C9lO1jsY.mjs.map +1 -1
- package/dist/chunks/ar-CMXjVzFx.mjs.map +1 -1
- package/dist/chunks/ar-CR6UdFL9.mjs.map +1 -1
- package/dist/chunks/ar-CrOb0jL2.mjs.map +1 -1
- package/dist/chunks/ar-Cy_77yRf.mjs.map +1 -1
- package/dist/chunks/ar-D1jFXqLJ.mjs.map +1 -1
- package/dist/chunks/ar-DahJwMI9.mjs.map +1 -1
- package/dist/chunks/ar-Dcl3kgtd.mjs.map +1 -1
- package/dist/chunks/ar-Dg9PdDet.mjs.map +1 -1
- package/dist/chunks/ar-DhwCFHql.mjs +2 -0
- package/dist/chunks/ar-DhwCFHql.mjs.map +1 -0
- package/dist/chunks/ar-Dx2lO0Nm.mjs.map +1 -1
- package/dist/chunks/ar-NV_puwI2.mjs.map +1 -1
- package/dist/chunks/ar-Uzo1Azdw.mjs.map +1 -1
- package/dist/chunks/ar-XmSFrtmd.mjs.map +1 -1
- package/dist/chunks/ar-eOA3UmiE.mjs.map +1 -1
- package/dist/chunks/ar-sGZ-oZqB.mjs.map +1 -1
- package/dist/chunks/color-picker-D6HrTsDM.mjs +2 -0
- package/dist/chunks/color-picker-D6HrTsDM.mjs.map +1 -0
- package/dist/chunks/de-B8-w9gPi.mjs.map +1 -1
- package/dist/chunks/de-B9zSHWqY.mjs.map +1 -1
- package/dist/chunks/de-BX4y4PlH.mjs.map +1 -1
- package/dist/chunks/de-BXQBXxFJ.mjs.map +1 -1
- package/dist/chunks/de-BcPntcnr.mjs.map +1 -1
- package/dist/chunks/de-BdD3DpUB.mjs.map +1 -1
- package/dist/chunks/de-Bwxlcuee.mjs.map +1 -1
- package/dist/chunks/de-BxQIt_1Y.mjs.map +1 -1
- package/dist/chunks/de-C-Yf378-.mjs.map +1 -1
- package/dist/chunks/de-C7uehgMu.mjs.map +1 -1
- package/dist/chunks/de-C9ZhDqPi.mjs.map +1 -1
- package/dist/chunks/de-CHcv_Vmf.mjs.map +1 -1
- package/dist/chunks/de-CTzAMkXC.mjs.map +1 -1
- package/dist/chunks/de-CaeEIyzV.mjs.map +1 -1
- package/dist/chunks/de-CjLUbQmg.mjs +2 -0
- package/dist/chunks/de-CjLUbQmg.mjs.map +1 -0
- package/dist/chunks/de-DHs9i4af.mjs.map +1 -1
- package/dist/chunks/de-DJ5EkXQo.mjs.map +1 -1
- package/dist/chunks/de-DRbhnS4T.mjs.map +1 -1
- package/dist/chunks/de-DViI26lG.mjs.map +1 -1
- package/dist/chunks/de-DY3obIAF.mjs.map +1 -1
- package/dist/chunks/de-DcMhfRBu.mjs.map +1 -1
- package/dist/chunks/de-DiPz7abS.mjs.map +1 -1
- package/dist/chunks/de-Dl4QFHMa.mjs.map +1 -1
- package/dist/chunks/de-XCCpWyg0.mjs.map +1 -1
- package/dist/chunks/de-e6J6nvAD.mjs.map +1 -1
- package/dist/chunks/de-i95F9SDy.mjs.map +1 -1
- package/dist/chunks/de-uKR7koQe.mjs.map +1 -1
- package/dist/chunks/es-B0Za939C.mjs.map +1 -1
- package/dist/chunks/es-B8K3Yvf3.mjs.map +1 -1
- package/dist/chunks/es-BIXm2Coj.mjs.map +1 -1
- package/dist/chunks/es-BJHF95J_.mjs.map +1 -1
- package/dist/chunks/es-BMm9kqjC.mjs.map +1 -1
- package/dist/chunks/es-BQ9dox_E.mjs.map +1 -1
- package/dist/chunks/es-BQweZX6P.mjs.map +1 -1
- package/dist/chunks/es-BdpTTRuX.mjs.map +1 -1
- package/dist/chunks/es-C7uVqFYr.mjs.map +1 -1
- package/dist/chunks/es-CCQFu1t1.mjs.map +1 -1
- package/dist/chunks/es-CEAJj7aB.mjs.map +1 -1
- package/dist/chunks/es-CMSzvjOT.mjs +2 -0
- package/dist/chunks/es-CMSzvjOT.mjs.map +1 -0
- package/dist/chunks/es-CUKJujcb.mjs.map +1 -1
- package/dist/chunks/es-CXuMz87y.mjs.map +1 -1
- package/dist/chunks/es-CgMfhkJJ.mjs.map +1 -1
- package/dist/chunks/es-CtOtKQCP.mjs.map +1 -1
- package/dist/chunks/es-DD01rZ6N.mjs.map +1 -1
- package/dist/chunks/es-DDoqchUq.mjs.map +1 -1
- package/dist/chunks/es-DFokqQst.mjs.map +1 -1
- package/dist/chunks/es-DHxdoEzR.mjs.map +1 -1
- package/dist/chunks/es-DehVGwQ8.mjs.map +1 -1
- package/dist/chunks/es-DrJyl38L.mjs.map +1 -1
- package/dist/chunks/es-fTW0TkYV.mjs.map +1 -1
- package/dist/chunks/es-kfKiqpyD.mjs.map +1 -1
- package/dist/chunks/es-nRLq7bgP.mjs.map +1 -1
- package/dist/chunks/es-paXY7HFt.mjs.map +1 -1
- package/dist/chunks/es-xuahrvJN.mjs.map +1 -1
- package/dist/chunks/fr-0qEo3bRP.mjs.map +1 -1
- package/dist/chunks/fr-5HkMazAf.mjs.map +1 -1
- package/dist/chunks/fr-B9pBLaVx.mjs.map +1 -1
- package/dist/chunks/fr-BRXUnq3R.mjs.map +1 -1
- package/dist/chunks/fr-BSUKEtTk.mjs.map +1 -1
- package/dist/chunks/fr-BeRlON1t.mjs.map +1 -1
- package/dist/chunks/fr-Bg937iAy.mjs.map +1 -1
- package/dist/chunks/fr-BwWrFThE.mjs.map +1 -1
- package/dist/chunks/fr-C3EKRThN.mjs.map +1 -1
- package/dist/chunks/fr-CKjH6tJI.mjs.map +1 -1
- package/dist/chunks/fr-CQs0-pNX.mjs.map +1 -1
- package/dist/chunks/fr-CfhyYN-t.mjs.map +1 -1
- package/dist/chunks/fr-D0MDdoir.mjs.map +1 -1
- package/dist/chunks/fr-D5ulA3Z6.mjs.map +1 -1
- package/dist/chunks/fr-DB_OvHWH.mjs +2 -0
- package/dist/chunks/fr-DB_OvHWH.mjs.map +1 -0
- package/dist/chunks/fr-DEZ_oxzS.mjs.map +1 -1
- package/dist/chunks/fr-DciSEykY.mjs.map +1 -1
- package/dist/chunks/fr-DhWQzZy3.mjs.map +1 -1
- package/dist/chunks/fr-DiDhVhyV.mjs.map +1 -1
- package/dist/chunks/fr-DjMZ-3K5.mjs.map +1 -1
- package/dist/chunks/fr-F2ZrfVaF.mjs.map +1 -1
- package/dist/chunks/fr-KXmbys88.mjs.map +1 -1
- package/dist/chunks/fr-NVOinLyF.mjs.map +1 -1
- package/dist/chunks/fr-SbpHNrQ-.mjs.map +1 -1
- package/dist/chunks/fr-ZsRdLuys.mjs.map +1 -1
- package/dist/chunks/fr-eC0UdAPu.mjs.map +1 -1
- package/dist/chunks/fr-fshsDD66.mjs.map +1 -1
- package/dist/chunks/full-BsWAZr1w.mjs +2 -0
- package/dist/chunks/full-BsWAZr1w.mjs.map +1 -0
- package/dist/chunks/hi-4CiAKVjT.mjs.map +1 -1
- package/dist/chunks/hi-B-ZuX4aN.mjs.map +1 -1
- package/dist/chunks/hi-B2YB3Bo4.mjs.map +1 -1
- package/dist/chunks/hi-B2uhiPCN.mjs.map +1 -1
- package/dist/chunks/hi-B5cl8TWK.mjs.map +1 -1
- package/dist/chunks/hi-BNJIGWQQ.mjs.map +1 -1
- package/dist/chunks/hi-BOMkDPqC.mjs.map +1 -1
- package/dist/chunks/hi-Bl-yeeOI.mjs.map +1 -1
- package/dist/chunks/hi-BsZzSMfL.mjs.map +1 -1
- package/dist/chunks/hi-By8YwVIX.mjs.map +1 -1
- package/dist/chunks/hi-BzbMD_cP.mjs.map +1 -1
- package/dist/chunks/hi-C2jEsf8v.mjs.map +1 -1
- package/dist/chunks/hi-CTWubxLY.mjs.map +1 -1
- package/dist/chunks/hi-ChNQZZ1z.mjs +2 -0
- package/dist/chunks/hi-ChNQZZ1z.mjs.map +1 -0
- package/dist/chunks/hi-CoclKAUM.mjs.map +1 -1
- package/dist/chunks/hi-CrmakMVj.mjs.map +1 -1
- package/dist/chunks/hi-DWX6k5ZD.mjs.map +1 -1
- package/dist/chunks/hi-DY55FuDK.mjs.map +1 -1
- package/dist/chunks/hi-DrC2H81d.mjs.map +1 -1
- package/dist/chunks/hi-DsdXcOB6.mjs.map +1 -1
- package/dist/chunks/hi-Dt89SxNy.mjs.map +1 -1
- package/dist/chunks/hi-J8ErB5nB.mjs.map +1 -1
- package/dist/chunks/hi-L6pJxZam.mjs.map +1 -1
- package/dist/chunks/hi-SECtQQzq.mjs.map +1 -1
- package/dist/chunks/hi-j3TDLMYd.mjs.map +1 -1
- package/dist/chunks/hi-l6DA-aOw.mjs.map +1 -1
- package/dist/chunks/hi-uACJUw53.mjs.map +1 -1
- package/dist/chunks/minimal-DO7LiFTa.mjs +2 -0
- package/dist/chunks/minimal-DO7LiFTa.mjs.map +1 -0
- package/dist/chunks/pt-5VeuNDd2.mjs.map +1 -1
- package/dist/chunks/pt-BCXgUDiU.mjs.map +1 -1
- package/dist/chunks/pt-BDam9cDu.mjs.map +1 -1
- package/dist/chunks/pt-Bb908r0n.mjs.map +1 -1
- package/dist/chunks/pt-BkpVtod-.mjs.map +1 -1
- package/dist/chunks/pt-BlFAJZo7.mjs.map +1 -1
- package/dist/chunks/pt-Bu7Mbz67.mjs.map +1 -1
- package/dist/chunks/pt-BuZ7acHF.mjs.map +1 -1
- package/dist/chunks/pt-C8sOyw0V.mjs.map +1 -1
- package/dist/chunks/pt-CEUgbrii.mjs.map +1 -1
- package/dist/chunks/pt-CFrcl1v_.mjs.map +1 -1
- package/dist/chunks/pt-CI8t6oul.mjs +2 -0
- package/dist/chunks/pt-CI8t6oul.mjs.map +1 -0
- package/dist/chunks/pt-CMrFpUWS.mjs.map +1 -1
- package/dist/chunks/pt-CMx2wPPY.mjs.map +1 -1
- package/dist/chunks/pt-CR4j8gtE.mjs.map +1 -1
- package/dist/chunks/pt-Cc4zysaT.mjs.map +1 -1
- package/dist/chunks/pt-Cv6q7x5x.mjs.map +1 -1
- package/dist/chunks/pt-DFKJVh7k.mjs.map +1 -1
- package/dist/chunks/pt-DYMyMgKQ.mjs.map +1 -1
- package/dist/chunks/pt-D__tcM2T.mjs.map +1 -1
- package/dist/chunks/pt-Dg2ctkug.mjs.map +1 -1
- package/dist/chunks/pt-DgfMoLWR.mjs.map +1 -1
- package/dist/chunks/pt-OXa_IR4Q.mjs.map +1 -1
- package/dist/chunks/pt-UPF7DBlz.mjs.map +1 -1
- package/dist/chunks/pt-_qxIe7zX.mjs.map +1 -1
- package/dist/chunks/pt-paXY7HFt.mjs.map +1 -1
- package/dist/chunks/pt-zMHcNGPk.mjs.map +1 -1
- package/dist/chunks/register-DXLu8Njp.mjs +3 -0
- package/dist/chunks/register-DXLu8Njp.mjs.map +1 -0
- package/dist/chunks/ru-9WtNGZtl.mjs +2 -0
- package/dist/chunks/ru-9WtNGZtl.mjs.map +1 -0
- package/dist/chunks/ru-B1m8J9dl.mjs.map +1 -1
- package/dist/chunks/ru-BNPUT-3S.mjs.map +1 -1
- package/dist/chunks/ru-BotG0MFT.mjs.map +1 -1
- package/dist/chunks/ru-C-APN_dm.mjs.map +1 -1
- package/dist/chunks/ru-C9yFslEG.mjs.map +1 -1
- package/dist/chunks/ru-CkG_bpfo.mjs.map +1 -1
- package/dist/chunks/ru-Cs8KCNyq.mjs.map +1 -1
- package/dist/chunks/ru-CsP6mLxp.mjs.map +1 -1
- package/dist/chunks/ru-CvDl-yEd.mjs.map +1 -1
- package/dist/chunks/ru-CwyPz2Va.mjs.map +1 -1
- package/dist/chunks/ru-D53d-_UB.mjs.map +1 -1
- package/dist/chunks/ru-DJMpeuey.mjs.map +1 -1
- package/dist/chunks/ru-DSRv3_Rg.mjs.map +1 -1
- package/dist/chunks/ru-DV-lgEtM.mjs.map +1 -1
- package/dist/chunks/ru-DiwQV30V.mjs.map +1 -1
- package/dist/chunks/ru-DkW9XZFy.mjs.map +1 -1
- package/dist/chunks/ru-DyCTlhjg.mjs.map +1 -1
- package/dist/chunks/ru-QGX8lOTs.mjs.map +1 -1
- package/dist/chunks/ru-QcTo2yoL.mjs.map +1 -1
- package/dist/chunks/ru-Y11wuxOB.mjs.map +1 -1
- package/dist/chunks/ru-Yngw7nFP.mjs.map +1 -1
- package/dist/chunks/ru-d68SZpEe.mjs.map +1 -1
- package/dist/chunks/ru-gxbzqLL8.mjs.map +1 -1
- package/dist/chunks/ru-k7o3Qks3.mjs.map +1 -1
- package/dist/chunks/ru-l73diFXn.mjs.map +1 -1
- package/dist/chunks/ru-q8kz-237.mjs.map +1 -1
- package/dist/chunks/src-5GKFQ2mQ.mjs.map +1 -1
- package/dist/chunks/xml-BsV44TrJ.mjs.map +1 -1
- package/dist/chunks/zh-BFZOM3lF.mjs.map +1 -1
- package/dist/chunks/zh-BGYJXxVl.mjs.map +1 -1
- package/dist/chunks/zh-BP97XjlS.mjs.map +1 -1
- package/dist/chunks/zh-BQ73oqxc.mjs.map +1 -1
- package/dist/chunks/zh-BQqf3wJZ.mjs.map +1 -1
- package/dist/chunks/zh-Baxh6v0j.mjs.map +1 -1
- package/dist/chunks/zh-BrqJ4ywP.mjs +2 -0
- package/dist/chunks/zh-BrqJ4ywP.mjs.map +1 -0
- package/dist/chunks/zh-BvuAbM2S.mjs.map +1 -1
- package/dist/chunks/zh-C-wHnDo5.mjs.map +1 -1
- package/dist/chunks/zh-C7iCgCRP.mjs.map +1 -1
- package/dist/chunks/zh-CRsDvfPR.mjs.map +1 -1
- package/dist/chunks/zh-CWGAPVei.mjs.map +1 -1
- package/dist/chunks/zh-CWIzJcXi.mjs.map +1 -1
- package/dist/chunks/zh-CYV-db-K.mjs.map +1 -1
- package/dist/chunks/zh-CiIyOm6U.mjs.map +1 -1
- package/dist/chunks/zh-CnW44JEw.mjs.map +1 -1
- package/dist/chunks/zh-D1HSmSOf.mjs.map +1 -1
- package/dist/chunks/zh-DWN1Jqn3.mjs.map +1 -1
- package/dist/chunks/zh-DYD476c5.mjs.map +1 -1
- package/dist/chunks/zh-DdzgYD7k.mjs.map +1 -1
- package/dist/chunks/zh-DgSmvLyw.mjs.map +1 -1
- package/dist/chunks/zh-DlVfQn4z.mjs.map +1 -1
- package/dist/chunks/zh-Oj-qSUEp.mjs.map +1 -1
- package/dist/chunks/zh-YfuE_m2y.mjs.map +1 -1
- package/dist/chunks/zh-dGSDBBzb.mjs.map +1 -1
- package/dist/chunks/zh-ikm3rSTR.mjs.map +1 -1
- package/dist/chunks/zh-oZl1P_p0.mjs.map +1 -1
- package/dist/commands/BlockInsertion.d.ts +15 -19
- package/dist/commands/BlockInsertion.d.ts.map +1 -1
- package/dist/commands/Commands.d.ts.map +1 -1
- package/dist/commands/CompositionCommands.d.ts +47 -0
- package/dist/commands/CompositionCommands.d.ts.map +1 -0
- package/dist/commands/CompositionRebase.d.ts +24 -0
- package/dist/commands/CompositionRebase.d.ts.map +1 -0
- package/dist/commands/PasteCommand.d.ts.map +1 -1
- package/dist/commands/SelectionDeletion.d.ts +20 -8
- package/dist/commands/SelectionDeletion.d.ts.map +1 -1
- package/dist/commands/SelectionReplacement.d.ts +42 -0
- package/dist/commands/SelectionReplacement.d.ts.map +1 -0
- package/dist/editor/BlockIdentity.d.ts +16 -0
- package/dist/editor/BlockIdentity.d.ts.map +1 -0
- package/dist/editor/ContentSerializer.d.ts +13 -11
- package/dist/editor/ContentSerializer.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +6 -5
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/styles/link.d.ts +3 -0
- package/dist/editor/styles/link.d.ts.map +1 -0
- package/dist/fonts.mjs +1 -1
- package/dist/full.mjs +1 -1
- package/dist/html.mjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/input/CompositionController.d.ts +78 -0
- package/dist/input/CompositionController.d.ts.map +1 -0
- package/dist/input/HTMLParser.d.ts +15 -2
- package/dist/input/HTMLParser.d.ts.map +1 -1
- package/dist/input/InputHandler.d.ts +34 -1
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/InputManager.d.ts +3 -0
- package/dist/input/InputManager.d.ts.map +1 -1
- package/dist/input/PasteHTMLHandler.d.ts.map +1 -1
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/input/PasteRichBlockHandler.d.ts +10 -17
- package/dist/input/PasteRichBlockHandler.d.ts.map +1 -1
- package/dist/markdown.mjs +1 -1
- package/dist/model/BlockAlignment.d.ts +6 -0
- package/dist/model/BlockAlignment.d.ts.map +1 -1
- package/dist/model/BlockOffsetText.d.ts +11 -0
- package/dist/model/BlockOffsetText.d.ts.map +1 -0
- package/dist/model/CompositionState.d.ts +14 -0
- package/dist/model/CompositionState.d.ts.map +1 -1
- package/dist/model/ContentModel.d.ts +6 -1
- package/dist/model/ContentModel.d.ts.map +1 -1
- package/dist/model/FileHandlerDispatcher.d.ts +3 -1
- package/dist/model/FileHandlerDispatcher.d.ts.map +1 -1
- package/dist/model/FileHandlerRegistry.d.ts +11 -2
- package/dist/model/FileHandlerRegistry.d.ts.map +1 -1
- package/dist/model/HTMLUtils.d.ts +16 -3
- package/dist/model/HTMLUtils.d.ts.map +1 -1
- package/dist/model/MarkSpec.d.ts +5 -3
- package/dist/model/MarkSpec.d.ts.map +1 -1
- package/dist/model/NodeResolver.d.ts +2 -0
- package/dist/model/NodeResolver.d.ts.map +1 -1
- package/dist/model/NodeSpec.d.ts +2 -1
- package/dist/model/NodeSpec.d.ts.map +1 -1
- package/dist/model/Schema.d.ts +2 -0
- package/dist/model/Schema.d.ts.map +1 -1
- package/dist/model/SchemaRegistry.d.ts +26 -1
- package/dist/model/SchemaRegistry.d.ts.map +1 -1
- package/dist/model/StyleClass.d.ts +45 -0
- package/dist/model/StyleClass.d.ts.map +1 -0
- package/dist/model/StyleClassRegistry.d.ts +28 -0
- package/dist/model/StyleClassRegistry.d.ts.map +1 -0
- package/dist/model/TextChange.d.ts +40 -0
- package/dist/model/TextChange.d.ts.map +1 -0
- package/dist/notectl-core.mjs +1 -1
- package/dist/notectl-core.umd.js +1 -1
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/Plugin.d.ts +11 -0
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/PluginContextFactory.d.ts +2 -0
- package/dist/plugins/PluginContextFactory.d.ts.map +1 -1
- package/dist/plugins/RegistrationTracker.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentPlugin.d.ts +17 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/bidi-isolation.mjs +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockSchema.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font/FontPlugin.d.ts +13 -0
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeOperations.d.ts +2 -0
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePlugin.d.ts +11 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/formula/FormulaCommands.d.ts +6 -4
- package/dist/plugins/formula/FormulaCommands.d.ts.map +1 -1
- package/dist/plugins/formula/FormulaPlugin.d.ts.map +1 -1
- package/dist/plugins/formula/latex/LatexParser.d.ts.map +1 -1
- package/dist/plugins/formula/latex/LatexSymbols.d.ts.map +1 -1
- package/dist/plugins/formula/latex/LookupOwn.d.ts +6 -0
- package/dist/plugins/formula/latex/LookupOwn.d.ts.map +1 -0
- package/dist/plugins/formula/latex/handlers/Accents.d.ts.map +1 -1
- package/dist/plugins/formula/latex/handlers/Delimiters.d.ts.map +1 -1
- package/dist/plugins/formula/latex/handlers/Environments.d.ts.map +1 -1
- package/dist/plugins/formula/latex/handlers/Fonts.d.ts.map +1 -1
- package/dist/plugins/formula/latex/handlers/Spacing.d.ts.map +1 -1
- package/dist/plugins/formula.mjs +1 -1
- package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts.map +1 -1
- package/dist/plugins/gap-cursor.mjs +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight/HighlightPlugin.d.ts +11 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/ImageCommands.d.ts +15 -3
- package/dist/plugins/image/ImageCommands.d.ts.map +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/inline-code/InlineCodePlugin.d.ts.map +1 -1
- package/dist/plugins/inline-code.mjs +1 -1
- package/dist/plugins/link/LinkInteractionController.d.ts +26 -0
- package/dist/plugins/link/LinkInteractionController.d.ts.map +1 -0
- package/dist/plugins/link/LinkLocale.d.ts +7 -1
- package/dist/plugins/link/LinkLocale.d.ts.map +1 -1
- package/dist/plugins/link/LinkNavigation.d.ts +12 -0
- package/dist/plugins/link/LinkNavigation.d.ts.map +1 -0
- package/dist/plugins/link/LinkPlugin.d.ts +4 -4
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link/LinkPreview.d.ts +28 -0
- package/dist/plugins/link/LinkPreview.d.ts.map +1 -0
- package/dist/plugins/link/locales/ar.d.ts.map +1 -1
- package/dist/plugins/link/locales/de.d.ts.map +1 -1
- package/dist/plugins/link/locales/es.d.ts.map +1 -1
- package/dist/plugins/link/locales/fr.d.ts.map +1 -1
- package/dist/plugins/link/locales/hi.d.ts.map +1 -1
- package/dist/plugins/link/locales/pt.d.ts.map +1 -1
- package/dist/plugins/link/locales/ru.d.ts.map +1 -1
- package/dist/plugins/link/locales/zh.d.ts.map +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/print.mjs +1 -1
- package/dist/plugins/shared/ColorValidation.d.ts +12 -4
- package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
- package/dist/plugins/shared/InlineStyleMarkSpec.d.ts +10 -0
- package/dist/plugins/shared/InlineStyleMarkSpec.d.ts.map +1 -1
- package/dist/plugins/shared/PopupManager.d.ts +5 -0
- package/dist/plugins/shared/PopupManager.d.ts.map +1 -1
- package/dist/plugins/shared/StyleClassNames.d.ts +10 -0
- package/dist/plugins/shared/StyleClassNames.d.ts.map +1 -0
- package/dist/plugins/shared.mjs +1 -1
- package/dist/plugins/smart-paste/SmartPastePlugin.d.ts +0 -1
- package/dist/plugins/smart-paste/SmartPastePlugin.d.ts.map +1 -1
- package/dist/plugins/smart-paste.mjs +1 -1
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-color/TextColorPlugin.d.ts +11 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +1 -1
- package/dist/plugins/text-direction-auto.mjs +1 -1
- package/dist/plugins/text-direction.mjs +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/plugins/video.mjs +1 -1
- package/dist/presets/full.mjs +1 -1
- package/dist/presets/minimal.mjs +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/register.mjs +1 -1
- package/dist/serialization/AlignmentHTML.d.ts +43 -0
- package/dist/serialization/AlignmentHTML.d.ts.map +1 -0
- package/dist/serialization/CSSClassCollector.d.ts +20 -17
- package/dist/serialization/CSSClassCollector.d.ts.map +1 -1
- package/dist/serialization/CSSValueEquivalence.d.ts +24 -0
- package/dist/serialization/CSSValueEquivalence.d.ts.map +1 -0
- package/dist/serialization/DocumentParser.d.ts +2 -1
- package/dist/serialization/DocumentParser.d.ts.map +1 -1
- package/dist/serialization/DocumentSerializer.d.ts +0 -4
- package/dist/serialization/DocumentSerializer.d.ts.map +1 -1
- package/dist/serialization/FirstTagAttributes.d.ts +16 -0
- package/dist/serialization/FirstTagAttributes.d.ts.map +1 -0
- package/dist/serialization/HTMLParseRules.d.ts +32 -0
- package/dist/serialization/HTMLParseRules.d.ts.map +1 -0
- package/dist/serialization/HTMLParseSession.d.ts +21 -0
- package/dist/serialization/HTMLParseSession.d.ts.map +1 -0
- package/dist/serialization/MarkSerializer.d.ts.map +1 -1
- package/dist/serialization/StyleClassHTML.d.ts +37 -0
- package/dist/serialization/StyleClassHTML.d.ts.map +1 -0
- package/dist/serialization/StyleRehydration.d.ts +16 -0
- package/dist/serialization/StyleRehydration.d.ts.map +1 -0
- package/dist/serialization/TableDimensions.d.ts.map +1 -1
- package/dist/serialization/index.d.ts +2 -1
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/markdown/InlineSerializers.d.ts.map +1 -1
- package/dist/state/EditorState.d.ts.map +1 -1
- package/dist/state/History.d.ts +2 -1
- package/dist/state/History.d.ts.map +1 -1
- package/dist/state/NavigationQueries.d.ts.map +1 -1
- package/dist/state/SelectionValidation.d.ts +12 -0
- package/dist/state/SelectionValidation.d.ts.map +1 -0
- package/dist/state/StepApplication.d.ts.map +1 -1
- package/dist/state/StepMapping.d.ts.map +1 -1
- package/dist/state/Steps.d.ts +3 -0
- package/dist/state/Steps.d.ts.map +1 -1
- package/dist/state/StructuralPositions.d.ts +15 -0
- package/dist/state/StructuralPositions.d.ts.map +1 -0
- package/dist/state/TransactionBuilder.d.ts +13 -15
- package/dist/state/TransactionBuilder.d.ts.map +1 -1
- package/dist/test/TestUtils.d.ts.map +1 -1
- package/dist/view/CursorWrapper.d.ts.map +1 -1
- package/dist/view/EditorView.d.ts +25 -1
- package/dist/view/EditorView.d.ts.map +1 -1
- package/dist/view/EditorViewEvents.d.ts.map +1 -1
- package/dist/view/InlineContentDOM.d.ts +44 -0
- package/dist/view/InlineContentDOM.d.ts.map +1 -0
- package/dist/view/Reconciler.d.ts +20 -1
- package/dist/view/Reconciler.d.ts.map +1 -1
- package/dist/view/RenderedBlockText.d.ts +27 -0
- package/dist/view/RenderedBlockText.d.ts.map +1 -0
- package/dist/view/SelectionSync.d.ts.map +1 -1
- package/package.json +9 -8
- package/dist/chunks/AlignmentPlugin-DIwrRsHd.mjs +0 -2
- package/dist/chunks/AlignmentPlugin-DIwrRsHd.mjs.map +0 -1
- package/dist/chunks/AttrRegistry-CtNhf2EF.mjs.map +0 -1
- package/dist/chunks/AttributedMarkCommands-B3MQdob_.mjs.map +0 -1
- package/dist/chunks/BidiIsolationPlugin-cOLlL3Y9.mjs +0 -2
- package/dist/chunks/BidiIsolationPlugin-cOLlL3Y9.mjs.map +0 -1
- package/dist/chunks/BlockInsertion-O5pAFKid.mjs +0 -2
- package/dist/chunks/BlockInsertion-O5pAFKid.mjs.map +0 -1
- package/dist/chunks/BlockquotePlugin-D-jRWLQB.mjs +0 -2
- package/dist/chunks/BlockquotePlugin-D-jRWLQB.mjs.map +0 -1
- package/dist/chunks/CaretNavigationPlugin-DEZU09LJ.mjs.map +0 -1
- package/dist/chunks/CodeBlockPlugin-BandNM3t.mjs +0 -2
- package/dist/chunks/CodeBlockPlugin-BandNM3t.mjs.map +0 -1
- package/dist/chunks/ColorPickerPopup-CFYCCN7m.mjs +0 -2
- package/dist/chunks/ColorPickerPopup-CFYCCN7m.mjs.map +0 -1
- package/dist/chunks/ColorValidation-B9d_umnf.mjs.map +0 -1
- package/dist/chunks/Commands-D-0UXYvo.mjs +0 -2
- package/dist/chunks/Commands-D-0UXYvo.mjs.map +0 -1
- package/dist/chunks/ContentModel-Bzmzeqwg.mjs +0 -2
- package/dist/chunks/ContentModel-Bzmzeqwg.mjs.map +0 -1
- package/dist/chunks/CursorMarks-dx51OGBf.mjs.map +0 -1
- package/dist/chunks/Decoration-BwhoA4MU.mjs.map +0 -1
- package/dist/chunks/DirectionDetection-ZrkMhyaL.mjs.map +0 -1
- package/dist/chunks/Document-D_2cIBJG.mjs.map +0 -1
- package/dist/chunks/DocumentParser-i-CreJ48.mjs +0 -2
- package/dist/chunks/DocumentParser-i-CreJ48.mjs.map +0 -1
- package/dist/chunks/FontPlugin-BySgRcF3.mjs +0 -2
- package/dist/chunks/FontPlugin-BySgRcF3.mjs.map +0 -1
- package/dist/chunks/FontSizePlugin-zJDiyhUv.mjs +0 -2
- package/dist/chunks/FontSizePlugin-zJDiyhUv.mjs.map +0 -1
- package/dist/chunks/FormulaPlugin-CI0r4X1o.mjs +0 -2
- package/dist/chunks/FormulaPlugin-CI0r4X1o.mjs.map +0 -1
- package/dist/chunks/GapCursorPlugin-NozsEK9J.mjs +0 -2
- package/dist/chunks/GapCursorPlugin-NozsEK9J.mjs.map +0 -1
- package/dist/chunks/HTMLUtils-B0nGyFLb.mjs +0 -2
- package/dist/chunks/HTMLUtils-B0nGyFLb.mjs.map +0 -1
- package/dist/chunks/HardBreakPlugin-CC4rntSX.mjs.map +0 -1
- package/dist/chunks/HeadingPlugin-BCh12hFT.mjs +0 -2
- package/dist/chunks/HeadingPlugin-BCh12hFT.mjs.map +0 -1
- package/dist/chunks/HighlightPlugin-By7CWUss.mjs +0 -2
- package/dist/chunks/HighlightPlugin-By7CWUss.mjs.map +0 -1
- package/dist/chunks/HorizontalRulePlugin-CxmUMM34.mjs +0 -2
- package/dist/chunks/HorizontalRulePlugin-CxmUMM34.mjs.map +0 -1
- package/dist/chunks/ImagePlugin-C_MuvfYo.mjs +0 -2
- package/dist/chunks/ImagePlugin-C_MuvfYo.mjs.map +0 -1
- package/dist/chunks/InlineCodePlugin-C1SqGfv5.mjs +0 -2
- package/dist/chunks/InlineCodePlugin-C1SqGfv5.mjs.map +0 -1
- package/dist/chunks/InlineStyleMarkSpec-Cx3goc3W.mjs +0 -2
- package/dist/chunks/InlineStyleMarkSpec-Cx3goc3W.mjs.map +0 -1
- package/dist/chunks/LinkPlugin-Bsmt97Kw.mjs +0 -2
- package/dist/chunks/LinkPlugin-Bsmt97Kw.mjs.map +0 -1
- package/dist/chunks/ListPlugin--dqEctgn.mjs.map +0 -1
- package/dist/chunks/MarkCommands-CJvLGL5G.mjs +0 -2
- package/dist/chunks/MarkCommands-CJvLGL5G.mjs.map +0 -1
- package/dist/chunks/MarkdownHTMLRegistry-CISsC0lH.mjs +0 -2
- package/dist/chunks/MarkdownHTMLRegistry-CISsC0lH.mjs.map +0 -1
- package/dist/chunks/MarkdownParser-D1d9zB0R.mjs.map +0 -1
- package/dist/chunks/MarkdownSerializer-Oex2RzNw.mjs +0 -2
- package/dist/chunks/MarkdownSerializer-Oex2RzNw.mjs.map +0 -1
- package/dist/chunks/NavigationQueries-Bt4zZ17v.mjs +0 -2
- package/dist/chunks/NavigationQueries-Bt4zZ17v.mjs.map +0 -1
- package/dist/chunks/NodeResolver-BtIknXqD.mjs +0 -2
- package/dist/chunks/NodeResolver-BtIknXqD.mjs.map +0 -1
- package/dist/chunks/NodeSelectionCommands-DK3iEh18.mjs.map +0 -1
- package/dist/chunks/PluginHelpers-WG1Lzzh3.mjs +0 -2
- package/dist/chunks/PluginHelpers-WG1Lzzh3.mjs.map +0 -1
- package/dist/chunks/PopupManager-Jz5JrUdC.mjs +0 -2
- package/dist/chunks/PopupManager-Jz5JrUdC.mjs.map +0 -1
- package/dist/chunks/PrintPlugin-BQ7LWbEB.mjs.map +0 -1
- package/dist/chunks/RangeIterator-DDOxTQIf.mjs.map +0 -1
- package/dist/chunks/SchemaRegistry-acc6q_5x.mjs +0 -2
- package/dist/chunks/SchemaRegistry-acc6q_5x.mjs.map +0 -1
- package/dist/chunks/SelectionSync-CwOHMMfI.mjs +0 -2
- package/dist/chunks/SelectionSync-CwOHMMfI.mjs.map +0 -1
- package/dist/chunks/SelectionTransactions-DNCzsl_b.mjs.map +0 -1
- package/dist/chunks/SimpleMark-CTDtEIMV.mjs +0 -2
- package/dist/chunks/SimpleMark-CTDtEIMV.mjs.map +0 -1
- package/dist/chunks/SmartPastePlugin-CjExbE9Q.mjs +0 -2
- package/dist/chunks/SmartPastePlugin-CjExbE9Q.mjs.map +0 -1
- package/dist/chunks/StrikethroughPlugin-d-EW2YYx.mjs.map +0 -1
- package/dist/chunks/SuperSubPlugin-C-kvFQyx.mjs.map +0 -1
- package/dist/chunks/TableDimensions-BcARMxQB.mjs +0 -2
- package/dist/chunks/TableDimensions-BcARMxQB.mjs.map +0 -1
- package/dist/chunks/TablePlugin-CdXY0Px5.mjs +0 -2
- package/dist/chunks/TablePlugin-CdXY0Px5.mjs.map +0 -1
- package/dist/chunks/TextColorPlugin-BLTKft_Z.mjs +0 -2
- package/dist/chunks/TextColorPlugin-BLTKft_Z.mjs.map +0 -1
- package/dist/chunks/TextDirectionAutoPlugin-LVDkKdDX.mjs.map +0 -1
- package/dist/chunks/TextDirectionPlugin-CtGwof7i.mjs.map +0 -1
- package/dist/chunks/TextDirectionService-OFOU6r_s.mjs +0 -2
- package/dist/chunks/TextDirectionService-OFOU6r_s.mjs.map +0 -1
- package/dist/chunks/TextFormattingPlugin-DlS0SeW7.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-CMHJCdYY.mjs +0 -2
- package/dist/chunks/ToolbarPlugin-CMHJCdYY.mjs.map +0 -1
- package/dist/chunks/VideoPlugin-C9z4JfP_.mjs +0 -2
- package/dist/chunks/VideoPlugin-C9z4JfP_.mjs.map +0 -1
- package/dist/chunks/ar-Ctrv6cIi.mjs +0 -2
- package/dist/chunks/ar-Ctrv6cIi.mjs.map +0 -1
- package/dist/chunks/color-picker-DJ05ey9o.mjs +0 -2
- package/dist/chunks/color-picker-DJ05ey9o.mjs.map +0 -1
- package/dist/chunks/de-JhGflzS5.mjs +0 -2
- package/dist/chunks/de-JhGflzS5.mjs.map +0 -1
- package/dist/chunks/es-Bv7bDbMp.mjs +0 -2
- package/dist/chunks/es-Bv7bDbMp.mjs.map +0 -1
- package/dist/chunks/fr-DtzIu6tU.mjs +0 -2
- package/dist/chunks/fr-DtzIu6tU.mjs.map +0 -1
- package/dist/chunks/full-9sO5JbWG.mjs +0 -2
- package/dist/chunks/full-9sO5JbWG.mjs.map +0 -1
- package/dist/chunks/hi-Bu799xIO.mjs +0 -2
- package/dist/chunks/hi-Bu799xIO.mjs.map +0 -1
- package/dist/chunks/minimal-C07d5reO.mjs +0 -2
- package/dist/chunks/minimal-C07d5reO.mjs.map +0 -1
- package/dist/chunks/pt-DmN9u3NX.mjs +0 -2
- package/dist/chunks/pt-DmN9u3NX.mjs.map +0 -1
- package/dist/chunks/register-DMdtiQ_Z.mjs +0 -3
- package/dist/chunks/register-DMdtiQ_Z.mjs.map +0 -1
- package/dist/chunks/ru-BxySx7an.mjs +0 -2
- package/dist/chunks/ru-BxySx7an.mjs.map +0 -1
- package/dist/chunks/zh-DuucmOns.mjs +0 -2
- package/dist/chunks/zh-DuucmOns.mjs.map +0 -1
- package/dist/editor/styles/base.d.ts +0 -3
- package/dist/editor/styles/base.d.ts.map +0 -1
- package/dist/editor/styles/color-picker.d.ts +0 -3
- package/dist/editor/styles/color-picker.d.ts.map +0 -1
- package/dist/editor/styles/font-select.d.ts +0 -3
- package/dist/editor/styles/font-select.d.ts.map +0 -1
- package/dist/editor/styles/font-size-select.d.ts +0 -3
- package/dist/editor/styles/font-size-select.d.ts.map +0 -1
- package/dist/editor/styles/heading-select.d.ts +0 -3
- package/dist/editor/styles/heading-select.d.ts.map +0 -1
- package/dist/editor/styles/image.d.ts +0 -3
- package/dist/editor/styles/image.d.ts.map +0 -1
- package/dist/editor/styles/reduced-motion.d.ts +0 -3
- package/dist/editor/styles/reduced-motion.d.ts.map +0 -1
- package/dist/editor/styles/table.d.ts +0 -3
- package/dist/editor/styles/table.d.ts.map +0 -1
- package/dist/editor/styles/toolbar.d.ts +0 -3
- package/dist/editor/styles/toolbar.d.ts.map +0 -1
- package/dist/plugins/blockquote/BlockquoteStyles.d.ts +0 -3
- package/dist/plugins/blockquote/BlockquoteStyles.d.ts.map +0 -1
- package/dist/plugins/formula/FormulaStyles.d.ts +0 -12
- package/dist/plugins/formula/FormulaStyles.d.ts.map +0 -1
- package/dist/plugins/image/ImagePopupStyles.d.ts +0 -3
- package/dist/plugins/image/ImagePopupStyles.d.ts.map +0 -1
- package/dist/plugins/video/VideoPopupStyles.d.ts +0 -3
- package/dist/plugins/video/VideoPopupStyles.d.ts.map +0 -1
- package/dist/plugins/video/VideoStyles.d.ts +0 -3
- package/dist/plugins/video/VideoStyles.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorValidation-ZBKZ_gTr.mjs","names":["HEX_COLOR_PATTERN","isValidHexColor","value","test","hexColorKey","key","TypeError","toLowerCase","knownColors","palette","styleClasses","Object","keys","filter","map","RGB_PATTERN","HSL_PATTERN","CSS_NAMED_COLORS","Set","isValidCSSColor","trimmed","trim","has","resolveColors","colors","fallbackPalette","pluginName","length","invalid","c","Error","join","seen","unique","color","normalized","add","push","FONT_FAMILY_FORBIDDEN","isValidCSSFontFamily","FONT_SIZE_PATTERN","isValidCSSFontSize"],"sources":["../../src/plugins/shared/ColorValidation.ts"],"sourcesContent":["/**\n * Shared CSS validation and normalization utilities\n * for style-based mark plugins (TextColor, Highlight, Font, FontSize).\n */\n\nimport type { StyleClassNames } from '../../model/StyleClass.js';\n\nconst HEX_COLOR_PATTERN: RegExp = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;\n\n/** Returns `true` when the value is a valid `#RGB` or `#RRGGBB` hex color. */\nexport function isValidHexColor(value: string): boolean {\n\treturn HEX_COLOR_PATTERN.test(value);\n}\n\n/**\n * Reads a `styleClasses` key of a color plugin as a hex color, lowercased like\n * the palette. Throws a `TypeError` for anything else.\n */\nexport function hexColorKey(key: string): string {\n\tif (!isValidHexColor(key)) {\n\t\tthrow new TypeError(`\"${key}\" is not a hex color; use keys such as \"#e03131\".`);\n\t}\n\treturn key.toLowerCase();\n}\n\n/**\n * The colors a color plugin stores in its own spelling: its palette, then the\n * colors its `styleClasses` option maps, lowercased like the palette. Keys\n * that are not hex colors are left to the `styleClasses` validation.\n */\nexport function knownColors(\n\tpalette: readonly string[],\n\tstyleClasses: StyleClassNames<string> | undefined,\n): readonly string[] {\n\tconst classColors: readonly string[] = Object.keys(styleClasses ?? {})\n\t\t.filter(isValidHexColor)\n\t\t.map(hexColorKey);\n\treturn [...palette, ...classColors];\n}\n\n// --- CSS Color Validation (broad format support for paste / API input) ---\n\n/** Matches `rgb(r, g, b)` and `rgba(r, g, b, a)` with integer or percentage values. */\nconst RGB_PATTERN: RegExp =\n\t/^rgba?\\(\\s*(\\d{1,3}%?\\s*,\\s*){2}\\d{1,3}%?(\\s*,\\s*(0|1|0?\\.\\d+))?\\s*\\)$/;\n\n/** Matches `hsl(h, s%, l%)` and `hsla(h, s%, l%, a)`. */\nconst HSL_PATTERN: RegExp =\n\t/^hsla?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}%\\s*,\\s*\\d{1,3}%(\\s*,\\s*(0|1|0?\\.\\d+))?\\s*\\)$/;\n\n/**\n * Complete set of CSS Level 4 named colors (including `transparent`).\n * Used as an allowlist — unknown names are rejected.\n */\nconst CSS_NAMED_COLORS: ReadonlySet<string> = new Set([\n\t'aliceblue',\n\t'antiquewhite',\n\t'aqua',\n\t'aquamarine',\n\t'azure',\n\t'beige',\n\t'bisque',\n\t'black',\n\t'blanchedalmond',\n\t'blue',\n\t'blueviolet',\n\t'brown',\n\t'burlywood',\n\t'cadetblue',\n\t'chartreuse',\n\t'chocolate',\n\t'coral',\n\t'cornflowerblue',\n\t'cornsilk',\n\t'crimson',\n\t'cyan',\n\t'darkblue',\n\t'darkcyan',\n\t'darkgoldenrod',\n\t'darkgray',\n\t'darkgreen',\n\t'darkgrey',\n\t'darkkhaki',\n\t'darkmagenta',\n\t'darkolivegreen',\n\t'darkorange',\n\t'darkorchid',\n\t'darkred',\n\t'darksalmon',\n\t'darkseagreen',\n\t'darkslateblue',\n\t'darkslategray',\n\t'darkslategrey',\n\t'darkturquoise',\n\t'darkviolet',\n\t'deeppink',\n\t'deepskyblue',\n\t'dimgray',\n\t'dimgrey',\n\t'dodgerblue',\n\t'firebrick',\n\t'floralwhite',\n\t'forestgreen',\n\t'fuchsia',\n\t'gainsboro',\n\t'ghostwhite',\n\t'gold',\n\t'goldenrod',\n\t'gray',\n\t'green',\n\t'greenyellow',\n\t'grey',\n\t'honeydew',\n\t'hotpink',\n\t'indianred',\n\t'indigo',\n\t'ivory',\n\t'khaki',\n\t'lavender',\n\t'lavenderblush',\n\t'lawngreen',\n\t'lemonchiffon',\n\t'lightblue',\n\t'lightcoral',\n\t'lightcyan',\n\t'lightgoldenrodyellow',\n\t'lightgray',\n\t'lightgreen',\n\t'lightgrey',\n\t'lightpink',\n\t'lightsalmon',\n\t'lightseagreen',\n\t'lightskyblue',\n\t'lightslategray',\n\t'lightslategrey',\n\t'lightsteelblue',\n\t'lightyellow',\n\t'lime',\n\t'limegreen',\n\t'linen',\n\t'magenta',\n\t'maroon',\n\t'mediumaquamarine',\n\t'mediumblue',\n\t'mediumorchid',\n\t'mediumpurple',\n\t'mediumseagreen',\n\t'mediumslateblue',\n\t'mediumspringgreen',\n\t'mediumturquoise',\n\t'mediumvioletred',\n\t'midnightblue',\n\t'mintcream',\n\t'mistyrose',\n\t'moccasin',\n\t'navajowhite',\n\t'navy',\n\t'oldlace',\n\t'olive',\n\t'olivedrab',\n\t'orange',\n\t'orangered',\n\t'orchid',\n\t'palegoldenrod',\n\t'palegreen',\n\t'paleturquoise',\n\t'palevioletred',\n\t'papayawhip',\n\t'peachpuff',\n\t'peru',\n\t'pink',\n\t'plum',\n\t'powderblue',\n\t'purple',\n\t'rebeccapurple',\n\t'red',\n\t'rosybrown',\n\t'royalblue',\n\t'saddlebrown',\n\t'salmon',\n\t'sandybrown',\n\t'seagreen',\n\t'seashell',\n\t'sienna',\n\t'silver',\n\t'skyblue',\n\t'slateblue',\n\t'slategray',\n\t'slategrey',\n\t'snow',\n\t'springgreen',\n\t'steelblue',\n\t'tan',\n\t'teal',\n\t'thistle',\n\t'tomato',\n\t'transparent',\n\t'turquoise',\n\t'violet',\n\t'wheat',\n\t'white',\n\t'whitesmoke',\n\t'yellow',\n\t'yellowgreen',\n]);\n\n/**\n * Returns `true` when `value` is a safe CSS color value.\n * Accepts hex (`#RGB`, `#RRGGBB`), `rgb()`, `rgba()`, `hsl()`, `hsla()`,\n * and CSS named colors. Rejects anything else — defense against CSS injection\n * via manipulated color values in `style` attributes.\n */\nexport function isValidCSSColor(value: string): boolean {\n\tif (!value) return false;\n\tconst trimmed: string = value.trim().toLowerCase();\n\tif (!trimmed) return false;\n\n\treturn (\n\t\tHEX_COLOR_PATTERN.test(trimmed) ||\n\t\tRGB_PATTERN.test(trimmed) ||\n\t\tHSL_PATTERN.test(trimmed) ||\n\t\tCSS_NAMED_COLORS.has(trimmed)\n\t);\n}\n\n/**\n * Validates, deduplicates, and normalizes a user-supplied color list.\n * Returns `fallbackPalette` when no custom colors are provided.\n *\n * @throws {Error} if any value is not a valid hex color code.\n */\nexport function resolveColors(\n\tcolors: readonly string[] | undefined,\n\tfallbackPalette: readonly string[],\n\tpluginName: string,\n): readonly string[] {\n\tif (!colors || colors.length === 0) return fallbackPalette;\n\n\tconst invalid: string[] = colors.filter((c) => !isValidHexColor(c));\n\tif (invalid.length > 0) {\n\t\tthrow new Error(\n\t\t\t`${pluginName}: invalid hex color(s): ${invalid.join(', ')}. Expected format: #RGB or #RRGGBB.`,\n\t\t);\n\t}\n\n\tconst seen: Set<string> = new Set();\n\tconst unique: string[] = [];\n\tfor (const color of colors) {\n\t\tconst normalized: string = color.toLowerCase();\n\t\tif (!seen.has(normalized)) {\n\t\t\tseen.add(normalized);\n\t\t\tunique.push(normalized);\n\t\t}\n\t}\n\treturn unique;\n}\n\n// --- Font Family Validation ---\n\n/** Characters that are never valid in a CSS font-family value. */\nconst FONT_FAMILY_FORBIDDEN: RegExp = /[{}<>;]|url\\(|expression\\(/i;\n\n/**\n * Returns `true` when `value` is a safe CSS `font-family` value.\n * Rejects values containing `{`, `}`, `;`, `<`, `>`, `url(`, or `expression(`\n * to defend against CSS injection.\n */\nexport function isValidCSSFontFamily(value: string): boolean {\n\tif (!value) return false;\n\tconst trimmed: string = value.trim();\n\tif (!trimmed) return false;\n\treturn !FONT_FAMILY_FORBIDDEN.test(trimmed);\n}\n\n// --- Font Size Validation ---\n\n/** Matches valid CSS font-size values: number with unit (px, pt, em, rem, %). */\nconst FONT_SIZE_PATTERN: RegExp = /^\\d+(\\.\\d+)?(px|pt|em|rem|%)$/i;\n\n/**\n * Returns `true` when `value` is a safe CSS `font-size` value.\n * Accepts values like `16px`, `1.5em`, `12pt`, `100%`, `0.875rem`.\n */\nexport function isValidCSSFontSize(value: string): boolean {\n\tif (!value) return false;\n\treturn FONT_SIZE_PATTERN.test(value.trim());\n}\n"],"mappings":"AAOA,IAAMA,EAA4B,gCAGlC,SAAgBC,EAAgBC,GAC/B,OAAOF,EAAkBG,KAAKD,EAC/B,CAMA,SAAgBE,EAAYC,GAC3B,IAAKJ,EAAgBI,GACpB,MAAM,IAAIC,UAAU,IAAID,sDAEzB,OAAOA,EAAIE,aACZ,CAOA,SAAgBC,EACfC,EACAC,GAKA,MAAO,IAAID,KAH4BE,OAAOC,KAAKF,GAAgB,CAAC,GAClEG,OAAOZ,GACPa,IAAIV,GAEP,CAKA,IAAMW,EACL,yEAGKC,EACL,gFAMKC,iBAAwC,IAAIC,IAAI,CACrD,YACA,eACA,OACA,aACA,QACA,QACA,SACA,QACA,iBACA,OACA,aACA,QACA,YACA,YACA,aACA,YACA,QACA,iBACA,WACA,UACA,OACA,WACA,WACA,gBACA,WACA,YACA,WACA,YACA,cACA,iBACA,aACA,aACA,UACA,aACA,eACA,gBACA,gBACA,gBACA,gBACA,aACA,WACA,cACA,UACA,UACA,aACA,YACA,cACA,cACA,UACA,YACA,aACA,OACA,YACA,OACA,QACA,cACA,OACA,WACA,UACA,YACA,SACA,QACA,QACA,WACA,gBACA,YACA,eACA,YACA,aACA,YACA,uBACA,YACA,aACA,YACA,YACA,cACA,gBACA,eACA,iBACA,iBACA,iBACA,cACA,OACA,YACA,QACA,UACA,SACA,mBACA,aACA,eACA,eACA,iBACA,kBACA,oBACA,kBACA,kBACA,eACA,YACA,YACA,WACA,cACA,OACA,UACA,QACA,YACA,SACA,YACA,SACA,gBACA,YACA,gBACA,gBACA,aACA,YACA,OACA,OACA,OACA,aACA,SACA,gBACA,MACA,YACA,YACA,cACA,SACA,aACA,WACA,WACA,SACA,SACA,UACA,YACA,YACA,YACA,OACA,cACA,YACA,MACA,OACA,UACA,SACA,cACA,YACA,SACA,QACA,QACA,aACA,SACA,gBASD,SAAgBC,EAAgBjB,GAC/B,IAAKA,EAAO,OAAO,EACnB,MAAMkB,EAAkBlB,EAAMmB,OAAOd,cACrC,QAAKa,IAGJpB,EAAkBG,KAAKiB,IACvBL,EAAYZ,KAAKiB,IACjBJ,EAAYb,KAAKiB,IACjBH,EAAiBK,IAAIF,GAEvB,CAQA,SAAgBG,EACfC,EACAC,EACAC,GAEA,IAAKF,GAA4B,IAAlBA,EAAOG,OAAc,OAAOF,EAE3C,MAAMG,EAAoBJ,EAAOX,OAAQgB,IAAO5B,EAAgB4B,IAChE,GAAID,EAAQD,OAAS,EACpB,MAAM,IAAIG,MACT,GAAGJ,4BAAqCE,EAAQG,KAAK,4CAIvD,MAAMC,iBAAoB,IAAId,IACxBe,EAAmB,GACzB,IAAK,MAAMC,KAASV,EAAQ,CAC3B,MAAMW,EAAqBD,EAAM3B,cAC5ByB,EAAKV,IAAIa,KACbH,EAAKI,IAAID,GACTF,EAAOI,KAAKF,GAEd,CACA,OAAOF,CACR,CAKA,IAAMK,EAAgC,8BAOtC,SAAgBC,EAAqBrC,GACpC,IAAKA,EAAO,OAAO,EACnB,MAAMkB,EAAkBlB,EAAMmB,OAC9B,QAAKD,IACGkB,EAAsBnC,KAAKiB,EACpC,CAKA,IAAMoB,EAA4B,iCAMlC,SAAgBC,EAAmBvC,GAClC,QAAKA,GACEsC,EAAkBrC,KAAKD,EAAMmB,OACrC,Q"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{A as t,B as n,D as o,E as e,N as r,g as c,h as i,k as s}from"./Document-ssR6hBzG.mjs";import{r as l}from"./NodeResolver-F4RtpoEd.mjs";import{c as f,d as u,f as d,i as a,n as k,o as b,p as m,u as h}from"./Selection-DC6AOGgF.mjs";import{r as I}from"./TypeBrands-Ch9856Gb.mjs";import{i as g,n as p,o as B,r as x}from"./NavigationQueries-CaKfccu7.mjs";import{C as N,b as S,c as v,w as O,y as j}from"./BlockInsertion-CXfXqUZl.mjs";import{t as A}from"./CursorMarks-CqHLzGNI.mjs";import{t as T}from"./ContentModel-dkGOh3N7.mjs";import{n as w,r as M,t as y}from"./NodeSelectionCommands-CAqIHW_6.mjs";function C(t,n){if("after"===n.side)return D(t,n);const o=t.getBlockOrder(),e=o.indexOf(n.blockId);if(e<=0)return null;const r=o[e-1];if(!r)return null;if(g(t,r)){const n=l(t.doc,r)??[];return t.transaction("input").setSelection(a(r,n)).build()}const c=t.getBlock(r);if(!c)return null;const i=s(c);return t.transaction("input").setSelection(k(r,i)).build()}function P(t,n){if("before"===n.side)return D(t,n);const o=t.getBlockOrder(),e=o.indexOf(n.blockId);if(e>=o.length-1)return null;const r=o[e+1];if(!r)return null;if(g(t,r)){const n=l(t.doc,r)??[];return t.transaction("input").setSelection(a(r,n)).build()}return t.transaction("input").setSelection(k(r,0)).build()}function D(t,n){const o=l(t.doc,n.blockId)??[],e=a(n.blockId,o);return y(t,e)}function _(t,n){const o=l(t.doc,n);if(!o||0===o.length)return-1;const e=o[0];return t.doc.children.findIndex(t=>t.id===e)}function E(t,n,o){const e=s(n),r=n.id===o.from.blockId?o.from.offset:0,c=n.id===o.to.blockId?o.to.offset:e;r<c&&t.deleteTextAt(n.id,r,c)}function Q(t,n,o){const r=/* @__PURE__ */new Map;let c;for(let s=o.length-1;s>=0;s--){const{parentPath:l,siblings:f,index:u}=O(t,o[s]);if(u<0)continue;const d=l.join("/"),a=r.get(d)??0;if(r.set(d,a+1),f.length-a>1){n.removeNode(l,u);continue}const k=e();n.insertNode(l,0,i(k)),n.removeNode(l,1),0===s&&(c=k)}return c}function R(t,o){return n(o)&&!g(t,o.id)}function q(t,o,r,c,f){const u=t.doc.children[c],d=t.doc.children[f];if(!u||!d)return;const a=t.getBlock(r.to.blockId);if(!a)return;const k=R(t,u),b=R(t,d),m=0===r.from.offset&&z(u)===r.from.blockId,h=r.to.offset===s(a)&&F(d)===r.to.blockId,I=!k&&(n(u)||m),g=!b&&(n(d)||h);let p;k?E(o,u,r):I||L(t,o,[u.id],u,l(t.doc,r.from.blockId)??[],r.from.blockId,r.from.offset),b?E(o,d,r):g||U(t,o,[d.id],d,l(t.doc,r.to.blockId)??[],r.to.blockId,r.to.offset);let B=0;I&&b?p=r.to.blockId:I&&(p=e(),o.insertNode([],c,i(p)),B=1);const x=[];I&&x.push(c);for(let n=c+1;n<f;n++)x.push(n);g&&x.push(f);for(let n=x.length-1;n>=0;n--)o.removeNode([],x[n]+B);return k&&b&&o.mergeBlocksAt(r.from.blockId,r.to.blockId),p}function z(t){if(n(t))return t.id;const e=o(t)[0];return e?z(e):t.id}function F(t){if(n(t))return t.id;const e=o(t),r=e[e.length-1];return r?F(r):t.id}function G(t,n){return!!t.schema.getNodeSpec?.(n.type)?.content&&T(t.schema,n.type,"paragraph")}function H(t,n,e,r,c,i){const s=o(r),l=G(t,r);for(let o=i-1;o>=c;o--){const r=s[o];r&&(l?n.removeNode(e,o):J(t,n,[...e,r.id],r))}}function J(t,r,c,l){if(n(l)){const t=s(l);return void(t>0&&r.deleteTextAt(l.id,0,t))}const f=o(l);if(!G(t,l))return void H(t,r,c,l,0,f.length);const u=1===f.length?f[0]:void 0;if(!u||!v(u)){for(let t=f.length-1;t>=0;t--)r.removeNode(c,t);r.insertNode(c,0,i(e()))}}function K(t,n){const e=n.indexOf(t.id),r=e>=0?n[e+1]:void 0;return o(t).findIndex(t=>t.id===r)}function L(t,n,e,r,c,i,l){const f=o(r),u=K(r,c);if(u<0)return;H(t,n,e,r,u+1,f.length);const d=f[u];if(d.id===i){const t=s(d);return void(l<t&&n.deleteTextAt(i,l,t))}L(t,n,[...e,d.id],d,c,i,l)}function U(t,n,e,r,c,i,s){const l=o(r),f=K(r,c);if(f<0)return;H(t,n,e,r,0,f);const u=l[f];u.id!==i?U(t,n,[...e,u.id],u,c,i,s):s>0&&n.deleteTextAt(i,0,s)}function V(n,o,c="input"){const s=n.selection;if(u(s))return M(n,s,o,c);if(h(s))return function(t,n,o,r){const{parentPath:c,siblings:s,index:l}=O(t,n.blockId),f="before"===n.side?Math.max(l,0):l>=0?l+1:s.length,u=e(),d=t.transaction(r);return d.insertNode(c,f,i(u)),d.insertText(u,0,o,[]),d.setSelection(k(u,o.length)),d.build()}(n,s,o,c);const l=n.transaction(c),a=function(n){if(n.storedMarks)return n.storedMarks;const o=n.selection;if(!d(o))return[];const e=n.getBlock(o.anchor.blockId);return e?f(o)?r(e,o.anchor.offset,t=>A(n.schema,t)):t(e,o.anchor.offset):[]}(n);let b;f(s)||(b=et(n,l));const m=N(s,n.getBlockOrder()),I=b??m.blockId,g=b?0:m.offset;return l.insertText(I,g,o,a),l.setSelection(k(I,g+o.length)),l.build()}function W(t){if(u(t.selection))return y(t,t.selection);if(h(t.selection))return null;if(f(t.selection))return null;if(function(t){if(!d(t.selection))return!1;const n=ot(t);if(!n)return!1;const o=m(t.selection,t.getBlockOrder());return o.from.blockId===n.from.blockId&&o.from.offset===n.from.offset&&o.to.blockId===n.to.blockId&&o.to.offset===n.to.offset}(t))return function(t){const n=e(),o=t.transaction("input"),r=t.doc.children.length;o.insertNode([],0,i(n));for(let e=r;e>=1;e--)o.removeNode([],e);return o.setSelection(k(n,0)),o.build()}(t);const n=t.transaction("input"),o=et(t,n),r=m(t.selection,t.getBlockOrder()),c=o??r.from.blockId,s=o?0:r.from.offset;return n.setSelection(k(c,s)),n.build()}function X(t){const n=t.selection;if(u(n))return w(t,n);if(h(n))return function(t,n){const{parentPath:o,index:r}=O(t,n.blockId);if(r<0)return null;const c="before"===n.side?r:r+1,s=e(),l=t.transaction("input");return l.insertNode(o,c,i(s)),l.setSelection(k(s,0)),l.build()}(t,n);const o=t.transaction("input");let r;f(n)||(r=et(t,o));const c=N(n,t.getBlockOrder()),s=r??c.blockId,l=r?0:c.offset,d=e();return o.splitBlock(s,l,d),o.setSelection(k(d,0)),o.build()}function Y(t){const n=t.selection;if(!d(n))return null;const o=t.transaction("input");let e;if(f(n)||(e=et(t,o)),e)o.insertInlineNode(e,0,c(I("hard_break"))),o.setSelection(k(e,1));else{const{blockId:e,offset:r}=N(n,t.getBlockOrder());o.insertInlineNode(e,r,c(I("hard_break"))),o.setSelection(k(e,r+1))}return o.build()}function Z(t){return tt(t,"backward")}function $(t){return tt(t,"forward")}function tt(t,n){const o=t.selection;if(!d(o))return null;const e=t.getBlockOrder(),r=e.indexOf(o.anchor.blockId),c="backward"===n?r-1:r+1;if(c<0||c>=e.length)return null;const i=e[c];if(!i)return null;if(x(t,o.anchor.blockId)||x(t,i))return null;const f=B(t,o.anchor.blockId,i);if(!f&&p(t,o.anchor.blockId))return null;if(g(t,i)){const n=l(t.doc,i)??[];return t.transaction("input").setSelection(a(i,n)).build()}if(!f)return null;if("backward"===n){const n=t.getBlock(i);if(!n)return null;const e=s(n);return t.transaction("input").mergeBlocksAt(i,o.anchor.blockId).setSelection(k(i,e)).build()}return t.transaction("input").mergeBlocksAt(o.anchor.blockId,i).setSelection(k(o.anchor.blockId,o.anchor.offset)).build()}function nt(t){const n=ot(t);return n?t.transaction("command").setSelection(b(n.from,n.to)).build():t.transaction("command").setSelection(t.selection).build()}function ot(t){const n=t.doc.children,o=n[0],e=n[n.length-1];if(!o||!e)return null;const r=j(o),c=S(e),i=t.getBlock(c);return{from:{blockId:r,offset:0},to:{blockId:c,offset:i?s(i):0}}}function et(t,n){if(!d(t.selection))return;const o=t.getBlockOrder(),r=m(t.selection,o),c=o.indexOf(r.from.blockId),s=o.indexOf(r.to.blockId);if(c===s)return void n.deleteTextAt(r.from.blockId,r.from.offset,r.to.offset);const l=_(t,r.from.blockId),f=_(t,r.to.blockId);return l===f||l<0||f<0?function(t,n,o,r,c,s){const l=o.slice(c,s+1),f=l.findIndex(n=>!g(t,n));if(f<0)return function(t,n,o){const r=o[0];if(!r)return;const{parentPath:c,index:s}=O(t,r);if(s<0)return;const l=Q(t,n,o);if(l)return l;const f=e();return n.insertNode(c,s,i(f)),f}(t,n,l);const u=l[f],d=[];let a,k=[];for(const e of l){a&&B(t,a,e)||(k=[],d.push(k)),g(t,e)||k.push(e),a=e;const o=t.getBlock(e);o&&E(n,o,r)}Q(t,n,l.filter(n=>g(t,n)));for(const[e,...i]of d)if(e)for(const t of i)n.mergeBlocksAt(e,t);return 0===f?void 0:u}(t,n,o,r,c,s):q(t,n,r,l,f)}export{Z as a,X as c,V as i,C as l,W as n,$ as o,Y as r,nt as s,et as t,P as u};
|
|
2
|
+
//# sourceMappingURL=Commands-Bk7Cl1nH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Commands-Bk7Cl1nH.mjs","names":["getBlockMarksAtOffset","isLeafBlock","getBlockChildren","generateBlockId","getCursorMarks","createInlineNode","createEmptyParagraph","getBlockLength","findNodePath","isCollapsed","isNodeSelection","isTextSelection","createNodeSelection","createCollapsedSelection","createSelection","selectionRange","isGapCursor","inlineType","isVoidBlock","isInsideIsolating","sharesParent","isIsolatingBlock","resolveInsertPoint","findLastLeafBlockId","isEmptyParagraph","resolveSiblingContext","findFirstLeafBlockId","isMarkInclusive","canContain","insertParagraphAfterNodeSelection","insertTextAfterNodeSelection","deleteNodeSelection","deleteBackwardAtGap","state","sel","side","deleteVoidAtGap","blockOrder","getBlockOrder","blockIdx","indexOf","blockId","prevId","path","doc","transaction","setSelection","build","prevBlock","getBlock","prevLen","deleteForwardAtGap","length","nextId","nodeSel","getRootBlockIndex","rootId","children","findIndex","c","id","deleteSelectedText","builder","block","range","from","offset","to","deleteTextAt","removeVoidBlocks","ids","removedPerParent","Map","swappedInForFirst","i","parentPath","siblings","index","parentKey","join","removedBefore","get","set","removeNode","replacementId","insertNode","isTextLeaf","deleteCrossRootRange","fromRootIdx","toRootIdx","fromRoot","toRoot","toLeaf","fromIsLeaf","toIsLeaf","fromAtStart","firstLeafId","toAtEnd","lastLeafId","fromWholesale","toWholesale","landingId","trimContainerTail","trimContainerHead","shift","removeIdxs","push","k","mergeBlocksAt","first","last","hasFlowContent","container","schema","getNodeSpec","type","content","deleteCoveredChildren","containerPath","removable","child","clearBlockContent","only","boundaryChildIndex","leafPath","pos","targetChildId","leafId","leafOffset","boundaryIdx","boundaryChild","len","insertTextCommand","text","origin","selection","insertIdx","Math","max","newId","insertText","insertTextAtGap","marks","storedMarks","anchor","resolveActiveMarks","addDeleteSelectionSteps","resolved","insertBlockId","insertOffset","deleteSelectionCommand","docRange","documentRange","selectionCoversDocument","newBlockId","originalCount","clearDocument","cursorBlockId","cursorOffset","splitBlockCommand","insertParagraphAtGap","splitBlock","insertHardBreakCommand","insertInlineNode","mergeBlockBackward","mergeAdjacentBlock","mergeBlockForward","direction","adjacentIdx","adjacentId","sameParent","selectAll","blocks","firstBlock","lastBlock","lastLeaf","fromIdx","toIdx","rangeIds","slice","survivorIdx","swappedIn","replaceVoidOnlyRange","survivorId","groups","previousId","group","filter","targetId","sourceIds","sourceId","deleteLeafRange"],"sources":["../../src/commands/GapCursorCommands.ts","../../src/commands/SelectionDeletion.ts","../../src/commands/Commands.ts"],"sourcesContent":["/**\n * Commands for GapCursor: deleting void blocks adjacent to gap cursors\n * and inserting paragraphs at gap positions.\n */\n\nimport { createEmptyParagraph, generateBlockId, getBlockLength } from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { GapCursorSelection, NodeSelection } from '../model/Selection.js';\nimport { createCollapsedSelection, createNodeSelection } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock } from '../state/NavigationQueries.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { resolveSiblingContext } from './CommandHelpers.js';\nimport { deleteNodeSelection } from './NodeSelectionCommands.js';\n\n/**\n * Deletes the void block adjacent to a GapCursor when pressing Backspace.\n *\n * - `side === 'after'` → void block is behind the cursor → delete it.\n * - `side === 'before'` → void block is ahead → navigate backward (to previous block).\n * - At document start with `side === 'before'` → `null` (no-op).\n */\nexport function deleteBackwardAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tif (sel.side === 'after') {\n\t\treturn deleteVoidAtGap(state, sel);\n\t}\n\n\t// side === 'before': navigate to previous block\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\n\tif (blockIdx <= 0) return null;\n\n\tconst prevId: BlockId | undefined = blockOrder[blockIdx - 1];\n\tif (!prevId) return null;\n\n\tif (isVoidBlock(state, prevId)) {\n\t\tconst path = findNodePath(state.doc, prevId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(prevId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\tconst prevBlock = state.getBlock(prevId);\n\tif (!prevBlock) return null;\n\tconst prevLen: number = getBlockLength(prevBlock);\n\treturn state.transaction('input').setSelection(createCollapsedSelection(prevId, prevLen)).build();\n}\n\n/**\n * Deletes the void block adjacent to a GapCursor when pressing Delete.\n *\n * - `side === 'before'` → void block is ahead of the cursor → delete it.\n * - `side === 'after'` → void block is behind → navigate forward (to next block).\n * - At document end with `side === 'after'` → `null` (no-op).\n */\nexport function deleteForwardAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tif (sel.side === 'before') {\n\t\treturn deleteVoidAtGap(state, sel);\n\t}\n\n\t// side === 'after': navigate to next block\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\n\tif (blockIdx >= blockOrder.length - 1) return null;\n\n\tconst nextId: BlockId | undefined = blockOrder[blockIdx + 1];\n\tif (!nextId) return null;\n\n\tif (isVoidBlock(state, nextId)) {\n\t\tconst path = findNodePath(state.doc, nextId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(nextId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\treturn state.transaction('input').setSelection(createCollapsedSelection(nextId, 0)).build();\n}\n\n/** Deletes the void block that the GapCursor is adjacent to, delegating to deleteNodeSelection. */\nfunction deleteVoidAtGap(state: EditorState, sel: GapCursorSelection): Transaction | null {\n\tconst path = (findNodePath(state.doc, sel.blockId) ?? []) as BlockId[];\n\tconst nodeSel: NodeSelection = createNodeSelection(sel.blockId, path);\n\treturn deleteNodeSelection(state, nodeSel);\n}\n\n/** Inserts a new paragraph at a GapCursor position (before or after the void block). */\nexport function insertParagraphAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tconst { parentPath, index } = resolveSiblingContext(state, sel.blockId);\n\tif (index < 0) return null;\n\n\tconst insertIdx: number = sel.side === 'before' ? index : index + 1;\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.setSelection(createCollapsedSelection(newId, 0));\n\treturn builder.build();\n}\n\n/** Inserts text in a new paragraph at a GapCursor position. */\nexport function insertTextAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n\ttext: string,\n\torigin: 'input' | 'paste',\n): Transaction {\n\tconst { parentPath, siblings, index } = resolveSiblingContext(state, sel.blockId);\n\tconst insertIdx: number =\n\t\tsel.side === 'before' ? Math.max(index, 0) : index >= 0 ? index + 1 : siblings.length;\n\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction(origin);\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.insertText(newId, 0, text, []);\n\tbuilder.setSelection(createCollapsedSelection(newId, text.length));\n\treturn builder.build();\n}\n","/**\n * Range-deletion helpers for multi-block text selections, split out of\n * Commands.ts. Handles two cases: a selection whose blocks share one root\n * ancestor (leaf range) and a selection spanning different root ancestors\n * (cross-root range).\n *\n * A void block (image, horizontal rule) at either end of a range is wholly\n * selected — it has no partial content and cannot host the caret — so it is\n * removed outright and never merged into (#224).\n *\n * Containers keep their shape: a free-flowing container (blockquote, list\n * item, table cell) loses the children a range covers, while a fixed-shape one\n * (a table, a table row) keeps every child and only has its content cleared.\n */\n\nimport { canContain } from '../model/ContentModel.js';\nimport type { BlockNode } from '../model/Document.js';\nimport {\n\tcreateEmptyParagraph,\n\tgenerateBlockId,\n\tgetBlockChildren,\n\tgetBlockLength,\n\tisLeafBlock,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock, sharesParent } from '../state/NavigationQueries.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { isEmptyParagraph } from './BlockInsertion.js';\nimport { resolveSiblingContext } from './CommandHelpers.js';\n\n/** A normalized text-selection range (document-order from/to positions). */\nexport interface DeletionRange {\n\treadonly from: { readonly blockId: BlockId; readonly offset: number };\n\treadonly to: { readonly blockId: BlockId; readonly offset: number };\n}\n\n/** Returns the root-level ancestor index in `doc.children` for a given block. */\nexport function getRootBlockIndex(state: EditorState, blockId: BlockId): number {\n\tconst path = findNodePath(state.doc, blockId);\n\tif (!path || path.length === 0) return -1;\n\tconst rootId: string = path[0] as string;\n\treturn state.doc.children.findIndex((c) => c.id === rootId);\n}\n\n/**\n * Deletes a multi-block selection where all blocks share the same root ancestor.\n *\n * Container boundaries survive: only consecutive leaves with the same immediate\n * parent merge into their group's first text leaf. Selected void blocks are\n * removed in place before any merges. Returns the first text leaf when it is\n * not the from-block (the caret then lands at offset 0), or the landing paragraph\n * swapped in when the range is void-only; undefined when the from-block survives.\n */\nexport function deleteLeafRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tblockOrder: readonly BlockId[],\n\trange: DeletionRange,\n\tfromIdx: number,\n\ttoIdx: number,\n): BlockId | undefined {\n\tconst rangeIds: readonly BlockId[] = blockOrder.slice(fromIdx, toIdx + 1);\n\tconst survivorIdx: number = rangeIds.findIndex((id) => !isVoidBlock(state, id));\n\tif (survivorIdx < 0) return replaceVoidOnlyRange(state, builder, rangeIds);\n\tconst survivorId: BlockId = rangeIds[survivorIdx] as BlockId;\n\n\t// Group the original leaf order, including voids: returning to a parent\n\t// after a nested container starts a new group, even if that container's\n\t// only leaf is a selected void that will be replaced below.\n\tconst groups: BlockId[][] = [];\n\tlet previousId: BlockId | undefined;\n\tlet group: BlockId[] = [];\n\tfor (const id of rangeIds) {\n\t\tif (!previousId || !sharesParent(state, previousId, id)) {\n\t\t\tgroup = [];\n\t\t\tgroups.push(group);\n\t\t}\n\t\tif (!isVoidBlock(state, id)) group.push(id);\n\t\tpreviousId = id;\n\t\tconst block: BlockNode | undefined = state.getBlock(id);\n\t\tif (block) deleteSelectedText(builder, block, range);\n\t}\n\t// Positional removals still refer to the original sibling indexes. All voids\n\t// must be removed (last first) before merging shifts any of those indexes.\n\tremoveVoidBlocks(\n\t\tstate,\n\t\tbuilder,\n\t\trangeIds.filter((id) => isVoidBlock(state, id)),\n\t);\n\tfor (const [targetId, ...sourceIds] of groups) {\n\t\tif (!targetId) continue;\n\t\tfor (const sourceId of sourceIds) builder.mergeBlocksAt(targetId, sourceId);\n\t}\n\n\treturn survivorIdx === 0 ? undefined : survivorId;\n}\n\n/** Deletes the part of `block`'s inline content that lies inside `range`. */\nfunction deleteSelectedText(\n\tbuilder: TransactionBuilder,\n\tblock: BlockNode,\n\trange: DeletionRange,\n): void {\n\tconst length: number = getBlockLength(block);\n\tconst from: number = block.id === range.from.blockId ? range.from.offset : 0;\n\tconst to: number = block.id === range.to.blockId ? range.to.offset : length;\n\tif (from < to) builder.deleteTextAt(block.id, from, to);\n}\n\n/**\n * Removes a range made only of void blocks and returns the empty paragraph\n * that takes their place and hosts the caret.\n */\nfunction replaceVoidOnlyRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tids: readonly BlockId[],\n): BlockId | undefined {\n\tconst first: BlockId | undefined = ids[0];\n\tif (!first) return undefined;\n\tconst { parentPath, index } = resolveSiblingContext(state, first);\n\tif (index < 0) return undefined;\n\n\tconst swappedIn: BlockId | undefined = removeVoidBlocks(state, builder, ids);\n\tif (swappedIn) return swappedIn;\n\n\t// Earlier siblings are untouched, so the first block's slot is still `index`.\n\tconst landingId: BlockId = generateBlockId();\n\tbuilder.insertNode(parentPath, index, createEmptyParagraph(landingId));\n\treturn landingId;\n}\n\n/**\n * Removes void blocks in place, last first so positional indexes stay valid.\n * A parent about to lose its last child keeps an empty paragraph instead, so\n * containers such as table cells never end up empty. Returns the paragraph\n * swapped in for the first block, if one was needed.\n */\nfunction removeVoidBlocks(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tids: readonly BlockId[],\n): BlockId | undefined {\n\tconst removedPerParent = new Map<string, number>();\n\tlet swappedInForFirst: BlockId | undefined;\n\n\tfor (let i = ids.length - 1; i >= 0; i--) {\n\t\tconst { parentPath, siblings, index } = resolveSiblingContext(state, ids[i] as BlockId);\n\t\tif (index < 0) continue;\n\t\tconst parentKey: string = parentPath.join('/');\n\t\tconst removedBefore: number = removedPerParent.get(parentKey) ?? 0;\n\t\tremovedPerParent.set(parentKey, removedBefore + 1);\n\n\t\tif (siblings.length - removedBefore > 1) {\n\t\t\tbuilder.removeNode(parentPath, index);\n\t\t\tcontinue;\n\t\t}\n\t\t// Last remaining child (so at index 0): swap in an empty paragraph.\n\t\tconst replacementId: BlockId = generateBlockId();\n\t\tbuilder.insertNode(parentPath, 0, createEmptyParagraph(replacementId));\n\t\tbuilder.removeNode(parentPath, 1);\n\t\tif (i === 0) swappedInForFirst = replacementId;\n\t}\n\n\treturn swappedInForFirst;\n}\n\n/** A leaf block that can hold a caret: any leaf except a void one. */\nfunction isTextLeaf(state: EditorState, block: BlockNode): boolean {\n\treturn isLeafBlock(block) && !isVoidBlock(state, block.id);\n}\n\n/**\n * Deletes a selection spanning different root-level ancestors.\n *\n * The selected span is deleted while every unselected leaf survives. A\n * composite/container root (a multi-block `list_item`, a `blockquote`, a\n * `table`) whose boundary sits *inside* it is trimmed, not wiped: the from-root\n * keeps everything before `range.from`, the to-root keeps everything after\n * `range.to`. Trimming keeps the shape of fixed-shape containers (see\n * {@link hasFlowContent}): the covered cells of a table are cleared, never\n * removed, so its rows keep equal cell counts. A container is removed wholesale\n * only when the boundary lands at its very edge (offset 0 of its first leaf, or\n * the end of its last leaf), so the whole container is genuinely inside the\n * selection. Root blocks strictly between the endpoints are always removed, and\n * a void root at either end is always removed wholesale.\n *\n * Returns the block hosting the caret when the from-root was removed wholesale\n * (its cursor block went with it): the surviving to-leaf, or a landing paragraph\n * inserted in the from-root's slot. Undefined otherwise, since the from boundary\n * leaf then survives and hosts the caret.\n */\nexport function deleteCrossRootRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\trange: DeletionRange,\n\tfromRootIdx: number,\n\ttoRootIdx: number,\n): BlockId | undefined {\n\tconst fromRoot = state.doc.children[fromRootIdx];\n\tconst toRoot = state.doc.children[toRootIdx];\n\tif (!fromRoot || !toRoot) return undefined;\n\n\tconst toLeaf = state.getBlock(range.to.blockId);\n\tif (!toLeaf) return undefined;\n\n\tconst fromIsLeaf: boolean = isTextLeaf(state, fromRoot);\n\tconst toIsLeaf: boolean = isTextLeaf(state, toRoot);\n\n\t// A non-text root is removed wholesale (rather than trimmed) when it is void,\n\t// or when the boundary sits at its very edge and so covers the whole\n\t// container: the from-root's edge is offset 0 of its first leaf, the\n\t// to-root's is the end of its last leaf.\n\tconst fromAtStart: boolean =\n\t\trange.from.offset === 0 && firstLeafId(fromRoot) === range.from.blockId;\n\tconst toAtEnd: boolean =\n\t\trange.to.offset === getBlockLength(toLeaf) && lastLeafId(toRoot) === range.to.blockId;\n\tconst fromWholesale: boolean = !fromIsLeaf && (isLeafBlock(fromRoot) || fromAtStart);\n\tconst toWholesale: boolean = !toIsLeaf && (isLeafBlock(toRoot) || toAtEnd);\n\n\t// --- from side: keep everything before range.from within the from-root ---\n\tif (fromIsLeaf) {\n\t\tdeleteSelectedText(builder, fromRoot, range);\n\t} else if (!fromWholesale) {\n\t\ttrimContainerTail(\n\t\t\tstate,\n\t\t\tbuilder,\n\t\t\t[fromRoot.id],\n\t\t\tfromRoot,\n\t\t\tfindNodePath(state.doc, range.from.blockId) ?? [],\n\t\t\trange.from.blockId,\n\t\t\trange.from.offset,\n\t\t);\n\t}\n\n\t// --- to side: keep everything after range.to within the to-root ---\n\tif (toIsLeaf) {\n\t\tdeleteSelectedText(builder, toRoot, range);\n\t} else if (!toWholesale) {\n\t\ttrimContainerHead(\n\t\t\tstate,\n\t\t\tbuilder,\n\t\t\t[toRoot.id],\n\t\t\ttoRoot,\n\t\t\tfindNodePath(state.doc, range.to.blockId) ?? [],\n\t\t\trange.to.blockId,\n\t\t\trange.to.offset,\n\t\t);\n\t}\n\n\t// --- root-level removals: middle roots always, endpoints only when wholesale ---\n\t// A wholesale-removed from-root takes its cursor block with it. A surviving\n\t// to-leaf slides into the from-root's slot and hosts the caret at its start;\n\t// otherwise a landing paragraph is inserted there for the caret and any\n\t// follow-up insert.\n\tlet landingId: BlockId | undefined;\n\tlet shift = 0;\n\tif (fromWholesale && toIsLeaf) {\n\t\tlandingId = range.to.blockId;\n\t} else if (fromWholesale) {\n\t\tlandingId = generateBlockId();\n\t\tbuilder.insertNode([], fromRootIdx, createEmptyParagraph(landingId));\n\t\tshift = 1;\n\t}\n\n\tconst removeIdxs: number[] = [];\n\tif (fromWholesale) removeIdxs.push(fromRootIdx);\n\tfor (let i = fromRootIdx + 1; i < toRootIdx; i++) removeIdxs.push(i);\n\tif (toWholesale) removeIdxs.push(toRootIdx);\n\t// Descending so each positional removal stays valid against the evolving doc.\n\tfor (let k = removeIdxs.length - 1; k >= 0; k--) {\n\t\tbuilder.removeNode([], (removeIdxs[k] as number) + shift);\n\t}\n\n\t// Join the boundary only when both roots are leaves: their inline content\n\t// merges into one block (the \"outta\" behavior). Merging across a composite\n\t// boundary is deliberately skipped — trimming already preserved every\n\t// unselected leaf, and there is no single valid block to merge into.\n\tif (fromIsLeaf && toIsLeaf) {\n\t\tbuilder.mergeBlocksAt(range.from.blockId, range.to.blockId);\n\t}\n\n\treturn landingId;\n}\n\n/** The id of a block's first leaf descendant (itself when already a leaf). */\nfunction firstLeafId(block: BlockNode): BlockId {\n\tif (isLeafBlock(block)) return block.id;\n\tconst first: BlockNode | undefined = getBlockChildren(block)[0];\n\treturn first ? firstLeafId(first) : block.id;\n}\n\n/** The id of a block's last leaf descendant (itself when already a leaf). */\nfunction lastLeafId(block: BlockNode): BlockId {\n\tif (isLeafBlock(block)) return block.id;\n\tconst children: readonly BlockNode[] = getBlockChildren(block);\n\tconst last: BlockNode | undefined = children[children.length - 1];\n\treturn last ? lastLeafId(last) : block.id;\n}\n\n/**\n * Whether a container's children are free-flowing blocks that a deletion may\n * remove one by one. That holds when its content rule admits a paragraph\n * (blockquote, list item, table cell), since an empty paragraph can always\n * stand in for removed content. Any other container has a fixed shape (a\n * table's rows, a row's cells, which must keep equal counts), so a deletion\n * clears its covered children instead. Without a content rule the shape is\n * unknown, and keeping it is the safe choice.\n */\nfunction hasFlowContent(state: EditorState, container: BlockNode): boolean {\n\tif (!state.schema.getNodeSpec?.(container.type)?.content) return false;\n\treturn canContain(state.schema, container.type, 'paragraph');\n}\n\n/**\n * Deletes the children of `container` in `[from, to)`, last first so positional\n * removals stay valid: a flow container removes them, a fixed-shape container\n * clears them in place (see {@link hasFlowContent}).\n */\nfunction deleteCoveredChildren(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tcontainerPath: readonly BlockId[],\n\tcontainer: BlockNode,\n\tfrom: number,\n\tto: number,\n): void {\n\tconst children: readonly BlockNode[] = getBlockChildren(container);\n\tconst removable: boolean = hasFlowContent(state, container);\n\tfor (let i = to - 1; i >= from; i--) {\n\t\tconst child: BlockNode | undefined = children[i];\n\t\tif (!child) continue;\n\t\tif (removable) builder.removeNode(containerPath, i);\n\t\telse clearBlockContent(state, builder, [...containerPath, child.id], child);\n\t}\n}\n\n/**\n * Empties a fully covered block while keeping the block itself: a flow\n * container ends up holding one empty paragraph (as a cut table cell does), a\n * fixed-shape container clears each child, and a text leaf loses its text. A\n * void leaf has no text (length 0), so it stays as it is.\n */\nfunction clearBlockContent(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tpath: readonly BlockId[],\n\tblock: BlockNode,\n): void {\n\tif (isLeafBlock(block)) {\n\t\tconst length: number = getBlockLength(block);\n\t\tif (length > 0) builder.deleteTextAt(block.id, 0, length);\n\t\treturn;\n\t}\n\n\tconst children: readonly BlockNode[] = getBlockChildren(block);\n\tif (!hasFlowContent(state, block)) {\n\t\tdeleteCoveredChildren(state, builder, path, block, 0, children.length);\n\t\treturn;\n\t}\n\tconst only: BlockNode | undefined = children.length === 1 ? children[0] : undefined;\n\tif (only && isEmptyParagraph(only)) return;\n\tfor (let i = children.length - 1; i >= 0; i--) builder.removeNode(path, i);\n\tbuilder.insertNode(path, 0, createEmptyParagraph(generateBlockId()));\n}\n\n/** Index of the child of `container` on the path to the boundary leaf, or -1. */\nfunction boundaryChildIndex(container: BlockNode, leafPath: readonly string[]): number {\n\tconst pos: number = leafPath.indexOf(container.id);\n\tconst targetChildId: string | undefined = pos >= 0 ? leafPath[pos + 1] : undefined;\n\treturn getBlockChildren(container).findIndex((c) => c.id === targetChildId);\n}\n\n/**\n * Trims a container to keep only content up to `(leafId, leafOffset)`, deleting\n * every child after the boundary at each level (see {@link deleteCoveredChildren})\n * and the boundary leaf's tail text. `containerPath` is the path to (and\n * including) `container`; `leafPath` is the boundary leaf's full node path, used\n * to descend to the boundary child.\n */\nfunction trimContainerTail(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tcontainerPath: readonly BlockId[],\n\tcontainer: BlockNode,\n\tleafPath: readonly string[],\n\tleafId: BlockId,\n\tleafOffset: number,\n): void {\n\tconst children: readonly BlockNode[] = getBlockChildren(container);\n\tconst boundaryIdx: number = boundaryChildIndex(container, leafPath);\n\tif (boundaryIdx < 0) return;\n\n\tdeleteCoveredChildren(state, builder, containerPath, container, boundaryIdx + 1, children.length);\n\n\tconst boundaryChild: BlockNode = children[boundaryIdx] as BlockNode;\n\tif (boundaryChild.id === leafId) {\n\t\tconst len: number = getBlockLength(boundaryChild);\n\t\tif (leafOffset < len) builder.deleteTextAt(leafId, leafOffset, len);\n\t\treturn;\n\t}\n\ttrimContainerTail(\n\t\tstate,\n\t\tbuilder,\n\t\t[...containerPath, boundaryChild.id],\n\t\tboundaryChild,\n\t\tleafPath,\n\t\tleafId,\n\t\tleafOffset,\n\t);\n}\n\n/**\n * Trims a container to keep only content from `(leafId, leafOffset)` onward,\n * deleting every child before the boundary at each level and the boundary\n * leaf's head text. Mirrors {@link trimContainerTail}.\n */\nfunction trimContainerHead(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tcontainerPath: readonly BlockId[],\n\tcontainer: BlockNode,\n\tleafPath: readonly string[],\n\tleafId: BlockId,\n\tleafOffset: number,\n): void {\n\tconst children: readonly BlockNode[] = getBlockChildren(container);\n\tconst boundaryIdx: number = boundaryChildIndex(container, leafPath);\n\tif (boundaryIdx < 0) return;\n\n\t// The boundary keeps its identity, so the descent below still finds it.\n\tdeleteCoveredChildren(state, builder, containerPath, container, 0, boundaryIdx);\n\n\tconst boundaryChild: BlockNode = children[boundaryIdx] as BlockNode;\n\tif (boundaryChild.id === leafId) {\n\t\tif (leafOffset > 0) builder.deleteTextAt(leafId, 0, leafOffset);\n\t\treturn;\n\t}\n\ttrimContainerHead(\n\t\tstate,\n\t\tbuilder,\n\t\t[...containerPath, boundaryChild.id],\n\t\tboundaryChild,\n\t\tleafPath,\n\t\tleafId,\n\t\tleafOffset,\n\t);\n}\n","/**\n * Core editor commands and barrel re-exports from submodules.\n *\n * This module contains text insertion, block splitting, block merging,\n * selection deletion, and select-all. Mark, delete, gap-cursor, node-selection,\n * and word-boundary commands are re-exported from their respective modules.\n */\n\nimport {\n\ttype Mark,\n\tcreateEmptyParagraph,\n\tcreateInlineNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tgetBlockMarksAtOffset,\n\tgetCursorMarks,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n\tisTextSelection,\n\tselectionRange,\n} from '../model/Selection.js';\nimport { type BlockId, inlineType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport {\n\tisInsideIsolating,\n\tisIsolatingBlock,\n\tisVoidBlock,\n\tsharesParent,\n} from '../state/NavigationQueries.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { resolveInsertPoint } from './CommandHelpers.js';\nimport { isMarkInclusive } from './CursorMarks.js';\nimport { insertParagraphAtGap, insertTextAtGap } from './GapCursorCommands.js';\nimport {\n\tdeleteNodeSelection,\n\tfindFirstLeafBlockId,\n\tfindLastLeafBlockId,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n} from './NodeSelectionCommands.js';\nimport { deleteCrossRootRange, deleteLeafRange, getRootBlockIndex } from './SelectionDeletion.js';\n\n// --- Re-exports from submodules ---\n\nexport {\n\tcanCrossBlockBoundary,\n\tisInsideIsolating,\n\tisIsolatingBlock,\n\tisVoidBlock,\n\tsharesParent,\n} from '../state/NavigationQueries.js';\n\nexport type { FeatureConfig } from './MarkCommands.js';\nexport {\n\tisMarkActive,\n\ttoggleBold,\n\ttoggleItalic,\n\ttoggleMark,\n\ttoggleUnderline,\n} from './MarkCommands.js';\n\nexport {\n\tdeleteBackward,\n\tdeleteForward,\n\tdeleteSoftLineBackward,\n\tdeleteSoftLineForward,\n\tdeleteWordBackward,\n\tdeleteWordForward,\n} from './DeleteCommands.js';\n\nexport {\n\tdeleteNodeSelection,\n\tfindFirstLeafBlockId,\n\tfindLastLeafBlockId,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n\tnavigateArrowIntoVoid,\n} from './NodeSelectionCommands.js';\n\nexport {\n\tdeleteBackwardAtGap,\n\tdeleteForwardAtGap,\n\tinsertParagraphAtGap,\n\tinsertTextAtGap,\n} from './GapCursorCommands.js';\n\nexport {\n\tfindWordBoundaryBackward,\n\tfindWordBoundaryForward,\n} from './WordBoundary.js';\n\nexport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from './AttributedMarkCommands.js';\n\nexport { forEachBlockIdInRange, forEachBlockInRange } from './RangeIterator.js';\n\n// --- Text Commands ---\n\n/** Inserts text at the current selection, replacing any selected range. */\nexport function insertTextCommand(\n\tstate: EditorState,\n\ttext: string,\n\torigin: 'input' | 'paste' = 'input',\n): Transaction {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert paragraph after void block with the text\n\tif (isNodeSelection(sel)) {\n\t\treturn insertTextAfterNodeSelection(state, sel, text, origin);\n\t}\n\n\t// GapCursor: insert paragraph at the gap position with the text\n\tif (isGapCursor(sel)) {\n\t\treturn insertTextAtGap(state, sel, text, origin);\n\t}\n\n\tconst builder = state.transaction(origin);\n\tconst marks = resolveActiveMarks(state);\n\n\tlet landingId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tlandingId = addDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst resolved = resolveInsertPoint(sel, state.getBlockOrder());\n\tconst insertBlockId: BlockId = landingId ?? resolved.blockId;\n\tconst insertOffset: number = landingId ? 0 : resolved.offset;\n\n\tbuilder.insertText(insertBlockId, insertOffset, text, marks);\n\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + text.length));\n\n\treturn builder.build();\n}\n\n/** Deletes the current selection. */\nexport function deleteSelectionCommand(state: EditorState): Transaction | null {\n\tif (isNodeSelection(state.selection)) {\n\t\treturn deleteNodeSelection(state, state.selection);\n\t}\n\tif (isGapCursor(state.selection)) return null;\n\tif (isCollapsed(state.selection)) return null;\n\n\t// Deleting a selection that spans the whole document resets it to the\n\t// canonical empty state (a single empty paragraph). Without this, the range\n\t// merge keeps the first block's type and attributes, leaving e.g. an empty\n\t// centered title behind so the placeholder never returns.\n\tif (selectionCoversDocument(state)) {\n\t\treturn clearDocument(state);\n\t}\n\n\tconst builder = state.transaction('input');\n\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\n\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\tconst cursorBlockId: BlockId = landingId ?? range.from.blockId;\n\tconst cursorOffset: number = landingId ? 0 : range.from.offset;\n\tbuilder.setSelection(createCollapsedSelection(cursorBlockId, cursorOffset));\n\n\treturn builder.build();\n}\n\n/** Splits the current block at the cursor position (Enter key). */\nexport function splitBlockCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert empty paragraph after the void block\n\tif (isNodeSelection(sel)) {\n\t\treturn insertParagraphAfterNodeSelection(state, sel);\n\t}\n\n\t// GapCursor: insert empty paragraph at the gap position\n\tif (isGapCursor(sel)) {\n\t\treturn insertParagraphAtGap(state, sel);\n\t}\n\n\tconst builder = state.transaction('input');\n\n\tlet landingId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tlandingId = addDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst resolved = resolveInsertPoint(sel, state.getBlockOrder());\n\tconst blockId: BlockId = landingId ?? resolved.blockId;\n\tconst offset: number = landingId ? 0 : resolved.offset;\n\tconst newBlockId = generateBlockId();\n\n\t// splitBlock operates at the same level in the tree — the StepApplication\n\t// handles this correctly because it looks up the block by ID recursively.\n\tbuilder.splitBlock(blockId, offset, newBlockId);\n\tbuilder.setSelection(createCollapsedSelection(newBlockId, 0));\n\n\treturn builder.build();\n}\n\n/** Inserts a hard line break (InlineNode) at the current cursor position. */\nexport function insertHardBreakCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (!isTextSelection(sel)) return null;\n\n\tconst builder = state.transaction('input');\n\n\tlet cursorBlockId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\t\tcursorBlockId = landingId;\n\t}\n\n\tif (cursorBlockId) {\n\t\t// Cross-root deletion replaced from-block; insert hard break in landing block\n\t\tbuilder.insertInlineNode(cursorBlockId, 0, createInlineNode(inlineType('hard_break')));\n\t\tbuilder.setSelection(createCollapsedSelection(cursorBlockId, 1));\n\t} else {\n\t\tconst { blockId: insertBlockId, offset: insertOffset } = resolveInsertPoint(\n\t\t\tsel,\n\t\t\tstate.getBlockOrder(),\n\t\t);\n\t\tbuilder.insertInlineNode(\n\t\t\tinsertBlockId,\n\t\t\tinsertOffset,\n\t\t\tcreateInlineNode(inlineType('hard_break')),\n\t\t);\n\t\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + 1));\n\t}\n\n\treturn builder.build();\n}\n\n/**\n * Merges the current block with the previous block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockBackward(state: EditorState): Transaction | null {\n\treturn mergeAdjacentBlock(state, 'backward');\n}\n\n/**\n * Merges the next block into the current block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockForward(state: EditorState): Transaction | null {\n\treturn mergeAdjacentBlock(state, 'forward');\n}\n\n/**\n * Shared implementation for merging adjacent blocks in either direction.\n * Validates selection, isolating boundaries, and void blocks before merging.\n */\nfunction mergeAdjacentBlock(\n\tstate: EditorState,\n\tdirection: 'backward' | 'forward',\n): Transaction | null {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return null;\n\n\tconst blockOrder = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.anchor.blockId);\n\n\tconst adjacentIdx: number = direction === 'backward' ? blockIdx - 1 : blockIdx + 1;\n\tif (adjacentIdx < 0 || adjacentIdx >= blockOrder.length) return null;\n\n\tconst adjacentId: BlockId | undefined = blockOrder[adjacentIdx];\n\tif (!adjacentId) return null;\n\n\tif (isIsolatingBlock(state, sel.anchor.blockId) || isIsolatingBlock(state, adjacentId)) {\n\t\treturn null;\n\t}\n\tconst sameParent: boolean = sharesParent(state, sel.anchor.blockId, adjacentId);\n\tif (!sameParent && isInsideIsolating(state, sel.anchor.blockId)) return null;\n\n\tif (isVoidBlock(state, adjacentId)) {\n\t\tconst path = findNodePath(state.doc, adjacentId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(adjacentId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\t// Text merges cannot cross container boundaries: their inverse split must\n\t// restore the source under the same parent as the target.\n\tif (!sameParent) return null;\n\n\tif (direction === 'backward') {\n\t\tconst prevBlock = state.getBlock(adjacentId);\n\t\tif (!prevBlock) return null;\n\t\tconst prevLen: number = getBlockLength(prevBlock);\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.mergeBlocksAt(adjacentId, sel.anchor.blockId)\n\t\t\t.setSelection(createCollapsedSelection(adjacentId, prevLen))\n\t\t\t.build();\n\t}\n\n\treturn state\n\t\t.transaction('input')\n\t\t.mergeBlocksAt(sel.anchor.blockId, adjacentId)\n\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, sel.anchor.offset))\n\t\t.build();\n}\n\n/** Selects all content in the editor, using leaf block endpoints. */\nexport function selectAll(state: EditorState): Transaction {\n\tconst docRange = documentRange(state);\n\tif (!docRange) return state.transaction('command').setSelection(state.selection).build();\n\n\treturn state\n\t\t.transaction('command')\n\t\t.setSelection(createSelection(docRange.from, docRange.to))\n\t\t.build();\n}\n\n// --- Internal Helpers ---\n\ninterface DocumentPosition {\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Endpoints of a full-document selection: the start of the first leaf block to\n * the end of the last leaf block. Returns `null` for an empty document.\n */\nfunction documentRange(\n\tstate: EditorState,\n): { from: DocumentPosition; to: DocumentPosition } | null {\n\tconst blocks = state.doc.children;\n\tconst firstBlock = blocks[0];\n\tconst lastBlock = blocks[blocks.length - 1];\n\tif (!firstBlock || !lastBlock) return null;\n\n\tconst firstLeafId: BlockId = findFirstLeafBlockId(firstBlock);\n\tconst lastLeafId: BlockId = findLastLeafBlockId(lastBlock);\n\tconst lastLeaf = state.getBlock(lastLeafId);\n\tconst lastLeafLen: number = lastLeaf ? getBlockLength(lastLeaf) : 0;\n\n\treturn {\n\t\tfrom: { blockId: firstLeafId, offset: 0 },\n\t\tto: { blockId: lastLeafId, offset: lastLeafLen },\n\t};\n}\n\n/** True when the current text selection spans the entire document. */\nfunction selectionCoversDocument(state: EditorState): boolean {\n\tif (!isTextSelection(state.selection)) return false;\n\tconst docRange = documentRange(state);\n\tif (!docRange) return false;\n\n\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\treturn (\n\t\trange.from.blockId === docRange.from.blockId &&\n\t\trange.from.offset === docRange.from.offset &&\n\t\trange.to.blockId === docRange.to.blockId &&\n\t\trange.to.offset === docRange.to.offset\n\t);\n}\n\n/**\n * Replaces the whole document with a single empty paragraph and places the\n * cursor inside it. The fresh paragraph is inserted before the originals are\n * removed so the document never passes through a zero-children state.\n */\nfunction clearDocument(state: EditorState): Transaction {\n\tconst newBlockId: BlockId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tconst originalCount: number = state.doc.children.length;\n\n\tbuilder.insertNode([], 0, createEmptyParagraph(newBlockId));\n\t// The originals shifted to indices 1..originalCount; remove them descending\n\t// so each index stays valid as the document shrinks.\n\tfor (let i = originalCount; i >= 1; i--) {\n\t\tbuilder.removeNode([], i);\n\t}\n\tbuilder.setSelection(createCollapsedSelection(newBlockId, 0));\n\n\treturn builder.build();\n}\n\nfunction resolveActiveMarks(state: EditorState): readonly Mark[] {\n\tif (state.storedMarks) return state.storedMarks;\n\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return [];\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return [];\n\n\t// A range replaced by typing inherits the marks at its anchor (raw content\n\t// marks); only a collapsed cursor honors right-boundary inclusivity.\n\tif (!isCollapsed(sel)) return getBlockMarksAtOffset(block, sel.anchor.offset);\n\n\treturn getCursorMarks(block, sel.anchor.offset, (type) => isMarkInclusive(state.schema, type));\n}\n\n/**\n * Adds steps to delete the current text selection.\n * Returns a replacement cursor block ID when the original from-block\n * was inside a composite root that got removed (undefined otherwise).\n */\nexport function addDeleteSelectionSteps(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n): BlockId | undefined {\n\tif (!isTextSelection(state.selection)) return undefined;\n\tconst blockOrder = state.getBlockOrder();\n\tconst range = selectionRange(state.selection, blockOrder);\n\tconst fromIdx = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx = blockOrder.indexOf(range.to.blockId);\n\n\tif (fromIdx === toIdx) {\n\t\tbuilder.deleteTextAt(range.from.blockId, range.from.offset, range.to.offset);\n\t\treturn undefined;\n\t}\n\n\tconst fromRootIdx: number = getRootBlockIndex(state, range.from.blockId);\n\tconst toRootIdx: number = getRootBlockIndex(state, range.to.blockId);\n\n\tif (fromRootIdx === toRootIdx || fromRootIdx < 0 || toRootIdx < 0) {\n\t\treturn deleteLeafRange(state, builder, blockOrder, range, fromIdx, toIdx);\n\t}\n\n\treturn deleteCrossRootRange(state, builder, range, fromRootIdx, toRootIdx);\n}\n"],"mappings":"Y,2kBAuBA,SAAgBgC,EACfC,EACAC,GAEA,GAAiB,UAAbA,EAAIC,KACP,OAAOC,EAAgBH,EAAOC,GAI/B,MAAMG,EAAiCJ,EAAMK,gBACvCC,EAAmBF,EAAWG,QAAQN,EAAIO,SAEhD,GAAIF,GAAY,EAAG,OAAO,KAE1B,MAAMG,EAA8BL,EAAWE,EAAW,GAC1D,IAAKG,EAAQ,OAAO,KAEpB,GAAIxB,EAAYe,EAAOS,GAAS,CAC/B,MAAMC,EAAOnC,EAAayB,EAAMW,IAAKF,IAAW,GAChD,OAAOT,EACLY,YAAY,SACZC,aAAalC,EAAoB8B,EAAQC,IACzCI,OACH,CAEA,MAAMC,EAAYf,EAAMgB,SAASP,GACjC,IAAKM,EAAW,OAAO,KACvB,MAAME,EAAkB3C,EAAeyC,GACvC,OAAOf,EAAMY,YAAY,SAASC,aAAajC,EAAyB6B,EAAQQ,IAAUH,OAC3F,CASA,SAAgBI,EACflB,EACAC,GAEA,GAAiB,WAAbA,EAAIC,KACP,OAAOC,EAAgBH,EAAOC,GAI/B,MAAMG,EAAiCJ,EAAMK,gBACvCC,EAAmBF,EAAWG,QAAQN,EAAIO,SAEhD,GAAIF,GAAYF,EAAWe,OAAS,EAAG,OAAO,KAE9C,MAAMC,EAA8BhB,EAAWE,EAAW,GAC1D,IAAKc,EAAQ,OAAO,KAEpB,GAAInC,EAAYe,EAAOoB,GAAS,CAC/B,MAAMV,EAAOnC,EAAayB,EAAMW,IAAKS,IAAW,GAChD,OAAOpB,EACLY,YAAY,SACZC,aAAalC,EAAoByC,EAAQV,IACzCI,OACH,CAEA,OAAOd,EAAMY,YAAY,SAASC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aa,EAAOwJ,EAAY7H,KACnD8H,EAAQ,GACRF,EAAO9E,KAAKgF,IAERxK,EAAYe,EAAO2B,IAAK8H,EAAMhF,KAAK9C,GACxC6H,EAAa7H,EACb,MAAMG,EAA+B9B,EAAMgB,SAASW,GAChDG,GAAOF,EAAmBC,EAASC,EAAOC,EAC/C,CAGAK,EACCpC,EACA6B,EACAoH,EAASS,OAAQ/H,GAAO1C,EAAYe,EAAO2B,KAE5C,IAAK,MAAOgI,KAAaC,KAAcL,EACtC,GAAKI,EACL,IAAK,MAAME,KAAYD,EAAW/H,EAAQ8C,cAAcgF,EAAUE,GAGnE,OAAuB,IAAhBV,OAAoB,EAAYG,CACxC,CC6USQ,CAAgB9J,EAAO6B,EAASzB,EAAY2B,EAAOgH,EAASC,GAG7D1F,EAAqBtD,EAAO6B,EAASE,EAAOwB,EAAaC,EACjE,Q"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{B as t,P as n,R as e,_ as o,p as r}from"./Document-ssR6hBzG.mjs";import{a as s}from"./TypeBrands-Ch9856Gb.mjs";function c(t,n,e){const o=t.getNodeSpec?.(n);if(!o?.content)return!0;const r=(t.getNodeSpec?.(e))?.group;for(const s of o.content.allow){if(s===e)return!0;if("text"!==s&&r&&s===r)return!0}return!1}function i(t,n,e){const o=t.getNodeSpec(n);if(!o?.content)return!0;const{min:r=0,max:s=Number.POSITIVE_INFINITY}=o.content,i=e.filter(t=>"text"!==t);if(i.length<r||i.length>s)return!1;for(const f of i)if(!c(t,n,f))return!1;return!0}function f(t,n){const e=[];let o=!1;for(const r of t.children){const{node:t,hoisted:s}=u(r,n);(t!==r||s.length>0)&&(o=!0),e.push(t,...s)}return o?{children:e}:t}function u(i,f){if(t(i))return{node:i,hoisted:[]};const d=[],p=[];let a=!1;const h=t=>{c(f,i.type,t.type)?d.push(t):(p.push(t),a=!0)};for(const t of i.children){if(!e(t)){d.push(t);continue}const n=u(t,f);n.node!==t&&(a=!0),h(n.node);for(const t of n.hoisted)h(t)}if(!a)return{node:i,hoisted:[]};const l=function(t,c,i){const f=(i.getNodeSpec(t.type)?.content?.allow)?.includes("text")??!1;if(0===c.length)return f?[o("")]:[r(s("paragraph"),[o("")])];const u=1===c.length?c[0]:void 0;if(f&&u&&e(u)&&"paragraph"===u.type&&!u.attrs&&!u.htmlId){const t=n(u);return t.length>0?[...t]:[o("")]}return c}(i,d,f);return{node:r(i.type,l,i.id,i.attrs,i.htmlId),hoisted:p}}export{f as n,i as r,c as t};
|
|
2
|
+
//# sourceMappingURL=ContentModel-dkGOh3N7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentModel-dkGOh3N7.mjs","names":["isLeafBlock","getInlineChildren","isBlockNode","createTextNode","createBlockNode","nodeType","canContain","registry","parentType","childType","parentSpec","getNodeSpec","content","childGroup","group","allowed","allow","validateContent","childTypes","min","max","Number","POSITIVE_INFINITY","blockChildTypes","filter","t","length","hoistDisallowedBlocks","doc","children","changed","block","node","hoisted","repairContainer","push","kept","place","candidate","type","child","repaired","bubbled","finalChildren","leafCapable","includes","only","attrs","htmlId","inline","resolveRepairedChildren","id"],"sources":["../../src/model/ContentModel.ts"],"sourcesContent":["/**\n * Content model validation for nested document structures.\n * Validates whether a parent node type can contain given child types.\n */\n\nimport type { BlockNode, ChildNode, Document } from './Document.js';\nimport {\n\tcreateBlockNode,\n\tcreateTextNode,\n\tgetInlineChildren,\n\tisBlockNode,\n\tisLeafBlock,\n} from './Document.js';\nimport type { NodeSpec } from './NodeSpec.js';\nimport type { SchemaRegistry } from './SchemaRegistry.js';\nimport { nodeType } from './TypeBrands.js';\n\n/** Content rules can be read from either a registry or an editor state's schema. */\nexport interface ContentSchema {\n\treadonly getNodeSpec?: (type: string) => NodeSpec | undefined;\n}\n\n/**\n * Checks if a parent node type can contain a child node type,\n * using the content rules and group system from NodeSpec.\n */\nexport function canContain(\n\tregistry: ContentSchema,\n\tparentType: string,\n\tchildType: string,\n): boolean {\n\tconst parentSpec = registry.getNodeSpec?.(parentType);\n\tif (!parentSpec?.content) return true; // No content rule = anything allowed\n\n\tconst childSpec = registry.getNodeSpec?.(childType);\n\tconst childGroup = childSpec?.group;\n\n\tfor (const allowed of parentSpec.content.allow) {\n\t\tif (allowed === childType) return true;\n\t\tif (allowed === 'text') continue; // 'text' refers to TextNodes, not BlockNodes\n\t\tif (childGroup && allowed === childGroup) return true;\n\t}\n\n\treturn false;\n}\n\n/**\n * Validates whether the given children types are valid for a parent node type.\n * Checks allow list, min/max constraints.\n */\nexport function validateContent(\n\tregistry: SchemaRegistry,\n\tparentType: string,\n\tchildTypes: readonly string[],\n): boolean {\n\tconst parentSpec = registry.getNodeSpec(parentType);\n\tif (!parentSpec?.content) return true;\n\n\tconst { min = 0, max = Number.POSITIVE_INFINITY } = parentSpec.content;\n\n\t// Check count constraints (only for block children, not text)\n\tconst blockChildTypes = childTypes.filter((t) => t !== 'text');\n\tif (blockChildTypes.length < min || blockChildTypes.length > max) return false;\n\n\t// Check each child is allowed\n\tfor (const childType of blockChildTypes) {\n\t\tif (!canContain(registry, parentType, childType)) return false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Repairs a parsed document so no container holds a block its content rule\n * forbids. A disallowed block (e.g. a `table` a Markdown/HTML importer nested\n * under a `list_item`, whose flat-with-indent model cannot hold it, #194)\n * bubbles up to the nearest ancestor that allows it, and to the document root\n * otherwise — the root imposes no content rule, so relocation is always\n * lossless. Order is preserved: a hoisted block lands immediately after the\n * subtree it escaped from. Runs only with a registry; identity is preserved when\n * nothing moves so callers can skip needless work.\n */\nexport function hoistDisallowedBlocks(doc: Document, registry: SchemaRegistry): Document {\n\tconst children: BlockNode[] = [];\n\tlet changed = false;\n\tfor (const block of doc.children) {\n\t\tconst { node, hoisted } = repairContainer(block, registry);\n\t\tif (node !== block || hoisted.length > 0) changed = true;\n\t\tchildren.push(node, ...hoisted);\n\t}\n\treturn changed ? { children } : doc;\n}\n\n/**\n * Repairs one block's subtree, returning the repaired node and any descendant\n * blocks that could not be placed within it (to be hoisted by the caller).\n */\nfunction repairContainer(\n\tblock: BlockNode,\n\tregistry: SchemaRegistry,\n): { readonly node: BlockNode; readonly hoisted: readonly BlockNode[] } {\n\tif (isLeafBlock(block)) return { node: block, hoisted: [] };\n\n\tconst kept: ChildNode[] = [];\n\tconst hoisted: BlockNode[] = [];\n\tlet changed = false;\n\n\tconst place = (candidate: BlockNode): void => {\n\t\tif (canContain(registry, block.type, candidate.type)) {\n\t\t\tkept.push(candidate);\n\t\t} else {\n\t\t\thoisted.push(candidate);\n\t\t\tchanged = true;\n\t\t}\n\t};\n\n\tfor (const child of block.children) {\n\t\tif (!isBlockNode(child)) {\n\t\t\tkept.push(child);\n\t\t\tcontinue;\n\t\t}\n\t\tconst repaired = repairContainer(child, registry);\n\t\tif (repaired.node !== child) changed = true;\n\t\tplace(repaired.node);\n\t\tfor (const bubbled of repaired.hoisted) place(bubbled);\n\t}\n\n\tif (!changed) return { node: block, hoisted: [] };\n\n\tconst finalChildren: readonly ChildNode[] = resolveRepairedChildren(block, kept, registry);\n\treturn {\n\t\tnode: createBlockNode(block.type, finalChildren, block.id, block.attrs, block.htmlId),\n\t\thoisted,\n\t};\n}\n\n/**\n * Settles a repaired container's children: an emptied container gets a valid\n * placeholder, and a hybrid (leaf-capable) container reduced to a single plain\n * paragraph collapses back to the canonical leaf shape — mirroring how the\n * importers keep a lone single-paragraph item a leaf (#194).\n */\nfunction resolveRepairedChildren(\n\tblock: BlockNode,\n\tkept: readonly ChildNode[],\n\tregistry: SchemaRegistry,\n): readonly ChildNode[] {\n\tconst allow: readonly string[] | undefined = registry.getNodeSpec(block.type)?.content?.allow;\n\tconst leafCapable: boolean = allow?.includes('text') ?? false;\n\n\tif (kept.length === 0) {\n\t\treturn leafCapable\n\t\t\t? [createTextNode('')]\n\t\t\t: [createBlockNode(nodeType('paragraph'), [createTextNode('')])];\n\t}\n\n\tconst only: ChildNode | undefined = kept.length === 1 ? kept[0] : undefined;\n\tif (\n\t\tleafCapable &&\n\t\tonly &&\n\t\tisBlockNode(only) &&\n\t\tonly.type === 'paragraph' &&\n\t\t!only.attrs &&\n\t\t!only.htmlId\n\t) {\n\t\tconst inline = getInlineChildren(only);\n\t\treturn inline.length > 0 ? [...inline] : [createTextNode('')];\n\t}\n\treturn kept;\n}\n"],"mappings":"Y,0GA0BA,SAAgBM,EACfC,EACAC,EACAC,GAEA,MAAMC,EAAaH,EAASI,cAAcH,GAC1C,IAAKE,GAAYE,QAAS,OAAO,EAGjC,MAAMC,GADYN,EAASI,cAAcF,KACXK,MAE9B,IAAK,MAAMC,KAAWL,EAAWE,QAAQI,MAAO,CAC/C,GAAID,IAAYN,EAAW,OAAO,EAClC,GAAgB,SAAZM,GACAF,GAAcE,IAAYF,EAAY,OAAO,CAClD,CAEA,OAAO,CACR,CAMA,SAAgBI,EACfV,EACAC,EACAU,GAEA,MAAMR,EAAaH,EAASI,YAAYH,GACxC,IAAKE,GAAYE,QAAS,OAAO,EAEjC,MAAMO,IAAEA,EAAM,EAAAC,IAAGA,EAAMC,OAAOC,mBAAsBZ,EAAWE,QAGzDW,EAAkBL,EAAWM,OAAQC,GAAY,SAANA,GACjD,GAAIF,EAAgBG,OAASP,GAAOI,EAAgBG,OAASN,EAAK,OAAO,EAGzE,IAAK,MAAMX,KAAac,EACvB,IAAKjB,EAAWC,EAAUC,EAAYC,GAAY,OAAO,EAG1D,OAAO,CACR,CAYA,SAAgBkB,EAAsBC,EAAerB,GACpD,MAAMsB,EAAwB,GAC9B,IAAIC,GAAU,EACd,IAAK,MAAMC,KAASH,EAAIC,SAAU,CACjC,MAAMG,KAAEA,EAAAC,QAAMA,GAAYC,EAAgBH,EAAOxB,IAC7CyB,IAASD,GAASE,EAAQP,OAAS,KAAGI,GAAU,GACpDD,EAASM,KAAKH,KAASC,EACxB,CACA,OAAOH,EAAU,CAAED,YAAaD,CACjC,CAMA,SAASM,EACRH,EACAxB,GAEA,GAAIP,EAAY+B,GAAQ,MAAO,CA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ursorMarks-
|
|
1
|
+
import{N as r}from"./Document-ssR6hBzG.mjs";import{c as t,f as o}from"./Selection-DC6AOGgF.mjs";function e(r,t){return!1!==r.getMarkSpec?.(t)?.inclusive}function n(n){if(n.storedMarks)return n.storedMarks;const s=n.selection;if(!o(s)||!t(s))return[];const c=n.getBlock(s.anchor.blockId);return c?r(c,s.anchor.offset,r=>e(n.schema,r)):[]}export{n,e as t};
|
|
2
|
+
//# sourceMappingURL=CursorMarks-CqHLzGNI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CursorMarks-CqHLzGNI.mjs","names":["getCursorMarks","isCollapsed","isTextSelection","isMarkInclusive","schema","type","getMarkSpec","inclusive","resolveCursorMarks","state","storedMarks","sel","selection","block","getBlock","anchor","blockId","offset"],"sources":["../../src/commands/CursorMarks.ts"],"sourcesContent":["/**\n * Resolves the marks active at a collapsed cursor for insertion and toolbar\n * state. Centralizes the `storedMarks ?? derived-marks` lookup that several\n * command modules previously duplicated, and makes that derivation honor\n * mark inclusivity (see {@link MarkSpec.inclusive}) so non-inclusive marks\n * such as links do not bleed onto text typed at their right boundary.\n */\n\nimport type { Mark } from '../model/Document.js';\nimport { getCursorMarks } from '../model/Document.js';\nimport type { Schema } from '../model/Schema.js';\nimport { isCollapsed, isTextSelection } from '../model/Selection.js';\nimport type { MarkTypeName } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\n\n/** A mark extends onto adjacent typing unless its spec opts out via `inclusive: false`. */\nexport function isMarkInclusive(schema: Schema, type: MarkTypeName): boolean {\n\treturn schema.getMarkSpec?.(type)?.inclusive !== false;\n}\n\n/**\n * Returns the marks a collapsed cursor carries: stored marks when present,\n * otherwise the inclusivity-aware marks derived from the surrounding content.\n * Returns an empty set for non-text or non-collapsed selections.\n */\nexport function resolveCursorMarks(state: EditorState): readonly Mark[] {\n\tif (state.storedMarks) return state.storedMarks;\n\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel) || !isCollapsed(sel)) return [];\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return [];\n\n\treturn getCursorMarks(block, sel.anchor.offset, (type) => isMarkInclusive(state.schema, type));\n}\n"],"mappings":"Y,oFAgBA,SAAgBG,EAAgBC,EAAgBC,GAC/C,OAAiD,IAA1CD,EAAOE,cAAcD,IAAOE,SACpC,CAOA,SAAgBC,EAAmBC,GAClC,GAAIA,EAAMC,YAAa,OAAOD,EAAMC,YAEpC,MAAMC,EAAMF,EAAMG,UAClB,IAAKV,EAAgBS,KAASV,EAAYU,GAAM,MAAO,GAEvD,MAAME,EAAQJ,EAAMK,SAASH,EAAII,OAAOC,SACxC,OAAKH,EAEEb,EAAea,EAAOF,EAAII,OAAOE,OAASZ,GAASF,EAAgBM,EAAML,OAAQC,IAFrE,EAGpB,Q"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{R as e}from"./Document-
|
|
1
|
+
import{R as e}from"./Document-ssR6hBzG.mjs";import{a as t}from"./Selection-DC6AOGgF.mjs";var o=Object.freeze({type:"identity"}),r=class{#e;constructor(e){this.#e=new Set(e),Object.freeze(this)}get size(){return this.#e.size}has(e){return this.#e.has(e)}entries(){return this.#e.entries()}keys(){return this.#e.keys()}values(){return this.#e.values()}[Symbol.iterator](){return this.#e[Symbol.iterator]()}forEach(e,t){for(const o of this.#e)e.call(t,o,o,this)}union(e){/* @__PURE__ */
|
|
2
2
|
return new Set([...this.#e,...n(e)])}intersection(e){const t=n(e),o=/* @__PURE__ */new Set;for(const r of this.#e)s(t,r)&&o.add(r);return o}difference(e){const t=n(e);return new Set([...this.#e].filter(e=>!s(t,e)))}symmetricDifference(e){const t=n(e),o=/* @__PURE__ */new Set;for(const r of this.#e)s(t,r)||o.add(r);for(const r of t)s(this.#e,r)||o.add(r);return o}isSubsetOf(e){const t=n(e);for(const o of this.#e)if(!t.has(o))return!1;return!0}isSupersetOf(e){for(const t of n(e))if(!s(this.#e,t))return!1;return!0}isDisjointFrom(e){for(const t of n(e))if(s(this.#e,t))return!1;return!0}};function n(e){const t=/* @__PURE__ */new Set,o=e.keys();for(let r=o.next();!r.done;r=o.next())t.add(r.value);return t}function s(e,t){return e.has(t)}function c(e){switch(e.type){case"identity":return o;case"blockRemoval":return Object.freeze({...e,removedBlockIds:new r(e.removedBlockIds),parentPath:Object.freeze([...e.parentPath])});case"childIndexShift":return Object.freeze({...e,parentPath:Object.freeze([...e.parentPath]),...e.insertedBlockIds?{insertedBlockIds:new r(e.insertedBlockIds)}:{}});case"moveNode":return Object.freeze({...e,fromParentPath:Object.freeze([...e.fromParentPath]),toParentPath:Object.freeze([...e.toParentPath])});default:return Object.freeze({...e})}}function f(t){const o=/* @__PURE__ */new Set,r=t=>{o.add(t.id);for(const o of t.children)e(o)&&r(o)};return r(t),o}function i(e,o,r=-1){switch(o.type){case"identity":case"childIndexShift":case"moveNode":return{pos:e,deleted:!1};case"shift":return function(e,t,o){if(e.blockId!==t.blockId)return{pos:e,deleted:!1};const r=t.newLen-(t.to-t.from),n=e.offset;if(n<t.from)return{pos:e,deleted:!1};if(n===t.from){if(t.from===t.to){const r=1===o?t.from+t.newLen:t.from;return r===n?{pos:e,deleted:!1}:{pos:d(e,r),deleted:!1}}return{pos:e,deleted:!1}}if(n<t.to)return{pos:d(e,1===o?t.from+t.newLen:t.from),deleted:!0};const s=n+r;return s===n?{pos:e,deleted:!1}:{pos:d(e,s),deleted:!1}}(e,o,r);case"split":return function(e,o,r){return e.blockId!==o.blockId||e.offset<o.offset?{pos:e,deleted:!1}:e.offset>o.offset?{pos:t(o.newBlockId,e.offset-o.offset),deleted:!1}:1===r?{pos:t(o.newBlockId,0),deleted:!1}:{pos:e,deleted:!1}}(e,o,r);case"merge":return function(e,o){return e.blockId!==o.sourceBlockId?{pos:e,deleted:!1}:{pos:t(o.targetBlockId,e.offset+o.targetLengthBefore),deleted:!1}}(e,o);case"blockRemoval":return function(e,t){return t.removedBlockIds.has(e.blockId)?{pos:e,deleted:!0}:{pos:e,deleted:!1}}(e,o)}}function d(e,o){return t(e.blockId,o,e.path)}var l=class e{static empty=new e([]);maps;constructor(e){this.maps=Object.freeze(e.map(c)),Object.freeze(this)}static from(t){const o=[];for(const e of t)"identity"!==e.type&&o.push(e);return 0===o.length?e.empty:new e(o)}appendMap(t){return"identity"===t.type?this:new e([...this.maps,t])}appendMapping(t){return 0===t.maps.length?this:0===this.maps.length?t:new e([...this.maps,...t.maps])}get isEmpty(){return 0===this.maps.length}map(e,t=-1){return this.mapResult(e,t).pos}mapResult(e,t=-1){let o=e,r=!1,n=!1;for(const s of this.maps){const e=i(o,s,t);o=e.pos,e.deleted?"blockRemoval"===s.type?n=!0:r=!0:"childIndexShift"===s.type&&s.insertedBlockIds?.has(o.blockId)&&(n=!1)}return{pos:o,deleted:r||n}}mapRange(e,t=-1,o=1){const r=this.mapResult(e.from,t),n=this.mapResult(e.to,o);return r.deleted&&n.deleted&&r.pos.blockId===n.pos.blockId&&r.pos.offset>=n.pos.offset?null:{from:r.pos,to:n.pos}}};function a(e,o,r,n,s=1,c=-1){if(n.isEmpty)return{blockId:e,from:o,to:r};const f=t(e,o),i=t(e,r),d=n.mapResult(f,s),l=n.mapResult(i,c);return d.deleted&&l.deleted||d.pos.blockId!==l.pos.blockId||d.pos.offset>l.pos.offset?null:{blockId:d.pos.blockId,from:d.pos.offset,to:l.pos.offset}}function u(e,o,r,n=-1){if(r.isEmpty)return{blockId:e,from:o,to:o};const s=t(e,o),c=r.mapResult(s,n);return c.deleted?null:{blockId:c.pos.blockId,from:c.pos.offset,to:c.pos.offset}}function h(e,t,o){return m(e,t,o,"existing")}function p(e,t,o){return m(e,t,o,"insertion")}function m(e,t,o,r){if(o.isEmpty)return t;let n=t;for(const s of o.maps){const t=k(e,n,s,r);if(null===t)return null;n=t}return n}function k(e,t,o,r){switch(o.type){case"identity":case"shift":case"split":case"merge":return t;case"blockRemoval":return I(e,o.parentPath)?t===o.index?"existing"===r?null:t:t>o.index?t-1:t:t;case"childIndexShift":return I(e,o.parentPath)&&t>=o.fromIndex?t+o.delta:t;case"moveNode":return function(e,t,o,r){const n=I(o.fromParentPath,o.toParentPath);if(n&&o.fromIndex===o.destinationIndex)return t;if("existing"===r&&n&&I(e,o.fromParentPath)&&t===o.fromIndex)return o.destinationIndex;let s=t;if(I(e,o.fromParentPath))if(s===o.fromIndex){if("existing"===r)return null}else s>o.fromIndex&&s--;return I(e,o.toParentPath)&&s>=o.destinationIndex&&s++,s}(e,t,o,r)}}function I(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}function b(e){switch(e.type){case"identity":return o;case"shift":return{type:"shift",blockId:e.blockId,from:e.from,to:e.from+e.newLen,newLen:e.to-e.from};case"split":return{type:"merge",targetBlockId:e.blockId,sourceBlockId:e.newBlockId,targetLengthBefore:e.offset};case"merge":return{type:"split",blockId:e.targetBlockId,offset:e.targetLengthBefore,newBlockId:e.sourceBlockId};case"blockRemoval":return{type:"childIndexShift",parentPath:e.parentPath,fromIndex:e.index,delta:1,insertedBlockIds:e.removedBlockIds};case"childIndexShift":return 1===e.delta&&e.insertedBlockIds?{type:"blockRemoval",removedBlockIds:e.insertedBlockIds,parentPath:e.parentPath,index:e.fromIndex}:o;case"moveNode":return{type:"moveNode",movedNodeId:e.movedNodeId,fromParentPath:e.toParentPath,fromIndex:e.destinationIndex,toParentPath:e.fromParentPath,destinationIndex:e.fromIndex}}}function y(e,t){if(e.type!==t.type)return!1;switch(e.type){case"identity":return!0;case"shift":{const o=t;return e.blockId===o.blockId&&e.from===o.from&&e.to===o.to&&e.newLen===o.newLen}case"split":{const o=t;return e.blockId===o.blockId&&e.offset===o.offset&&e.newBlockId===o.newBlockId}case"merge":{const o=t;return e.targetBlockId===o.targetBlockId&&e.sourceBlockId===o.sourceBlockId&&e.targetLengthBefore===o.targetLengthBefore}case"blockRemoval":{const o=t;if(e.index!==o.index)return!1;if(!I(e.parentPath,o.parentPath))return!1;if(e.removedBlockIds.size!==o.removedBlockIds.size)return!1;for(const t of e.removedBlockIds)if(!o.removedBlockIds.has(t))return!1;return!0}case"childIndexShift":{const o=t;return e.fromIndex===o.fromIndex&&e.delta===o.delta&&I(e.parentPath,o.parentPath)&&function(e,t){if(e===t)return!0;if(!e||!t||e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}(e.insertedBlockIds,o.insertedBlockIds)}case"moveNode":return"moveNode"===t.type&&e.movedNodeId===t.movedNodeId&&e.fromIndex===t.fromIndex&&e.destinationIndex===t.destinationIndex&&I(e.fromParentPath,t.fromParentPath)&&I(e.toParentPath,t.toParentPath)}}function g(e,o){switch(e.type){case"inline":return function(e,o){switch(o.type){case"identity":case"childIndexShift":case"moveNode":return e;case"shift":return function(e,o){if(e.blockId!==o.blockId)return e;const r=i(t(e.blockId,e.from),o,-1).pos,n=i(t(e.blockId,e.to),o,1).pos;return r.offset>=n.offset?null:r.offset===e.from&&n.offset===e.to?e:{...e,from:r.offset,to:n.offset}}(e,o);case"split":return function(e,t){return e.blockId!==t.blockId||e.to<=t.offset?e:e.from>=t.offset?{...e,blockId:t.newBlockId,from:e.from-t.offset,to:e.to-t.offset}:[{...e,to:t.offset},{...e,blockId:t.newBlockId,from:0,to:e.to-t.offset}]}(e,o);case"merge":return function(e,t){return e.blockId!==t.sourceBlockId?e:{...e,blockId:t.targetBlockId,from:e.from+t.targetLengthBefore,to:e.to+t.targetLengthBefore}}(e,o);case"blockRemoval":return o.removedBlockIds.has(e.blockId)?null:e}}(e,o);case"widget":return function(e,o){switch(o.type){case"identity":case"childIndexShift":case"moveNode":return e;case"shift":return function(e,o){if(e.blockId!==o.blockId)return e;const r=i(t(e.blockId,e.offset),o,e.side);return r.deleted?null:r.pos.offset===e.offset?e:{...e,offset:r.pos.offset}}(e,o);case"split":return function(e,o){if(e.blockId!==o.blockId)return e;const r=i(t(e.blockId,e.offset),o,e.side);return r.pos.blockId===e.blockId&&r.pos.offset===e.offset?e:{...e,blockId:r.pos.blockId,offset:r.pos.offset}}(e,o);case"merge":return function(e,t){return e.blockId!==t.sourceBlockId?e:{...e,blockId:t.targetBlockId,offset:e.offset+t.targetLengthBefore}}(e,o);case"blockRemoval":return o.removedBlockIds.has(e.blockId)?null:e}}(e,o);case"node":return function(e,t){switch(t.type){case"identity":case"shift":case"split":case"childIndexShift":case"moveNode":return e;case"merge":return e.blockId===t.sourceBlockId?null:e;case"blockRemoval":return t.removedBlockIds.has(e.blockId)?null:e}}(e,o)}}var B=Symbol("notectl.widget-callback-owner");function v(e){return e[B]}function w(e,t,o,r){return{type:"inline",blockId:e,from:t,to:o,attrs:r}}function P(e,t){return{type:"node",blockId:e,attrs:t}}function x(e,t,o,r){return{type:"widget",blockId:e,offset:t,toDOM:o,side:r?.side??-1,key:r?.key}}var S=class e{byBlock;static empty=new e(/* @__PURE__ */new Map);constructor(e){this.byBlock=e}static create(t){if(0===t.length)return e.empty;const o=/* @__PURE__ */new Map;for(const e of t){const t=o.get(e.blockId);t?t.push(e):o.set(e.blockId,[e])}return new e(o)}find(e){return this.byBlock.get(e)??[]}findInline(e){const t=this.byBlock.get(e);return t?t.filter(e=>"inline"===e.type):[]}findNode(e){const t=this.byBlock.get(e);return t?t.filter(e=>"node"===e.type):[]}findWidget(e){const t=this.byBlock.get(e);return t?t.filter(e=>"widget"===e.type):[]}add(t){if(0===t.length)return this;if(this.isEmpty)return e.create(t);const o=/* @__PURE__ */new Map;for(const[e,r]of this.byBlock)o.set(e,[...r]);for(const e of t){const t=o.get(e.blockId);t?t.push(e):o.set(e.blockId,[e])}return new e(o)}remove(t){const o=/* @__PURE__ */new Map;let r=!1;for(const[e,n]of this.byBlock){const s=n.filter(e=>!t(e));s.length!==n.length&&(r=!0),s.length>0&&o.set(e,s)}return r?0===o.size?e.empty:new e(o):this}merge(t){if(t.isEmpty)return this;if(this.isEmpty)return t;const o=/* @__PURE__ */new Map;for(const[e,r]of this.byBlock)o.set(e,[...r]);for(const[e,r]of t.byBlock){const t=o.get(e);t?t.push(...r):o.set(e,[...r])}return new e(o)}withWidgetOwner(t){let o=!1;const r=/* @__PURE__ */new Map;for(const[e,n]of this.byBlock){const s=n.map(e=>"widget"!==e.type?e:(o=!0,{...e,[B]:{pluginId:t,name:"widget"}}));r.set(e,s)}return o?new e(r):this}equals(e){if(this===e)return!0;if(this.byBlock.size!==e.byBlock.size)return!1;for(const[t,o]of this.byBlock){const r=e.byBlock.get(t);if(!r)return!1;if(!z(o,r))return!1}return!0}get isEmpty(){return 0===this.byBlock.size}map(t){if(this.isEmpty||t.mapping.isEmpty)return this;let o=[];for(const e of this.byBlock.values())for(const t of e)o.push(t);for(const e of t.mapping.maps){const t=[];for(const r of o){const o=g(r,e);if(null!==o)if(Array.isArray(o))for(const e of o)t.push(e);else t.push(o)}o=t}return 0===o.length?e.empty:e.create(o)}};function z(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++){const r=e[o],n=t[o];if(!r||!n||!O(r,n))return!1}return!0}function O(e,t){if(e.type!==t.type)return!1;if(e.blockId!==t.blockId)return!1;switch(e.type){case"inline":{const o=t;return e.from===o.from&&e.to===o.to&&R(e.attrs,o.attrs)}case"node":{const o=t;return R(e.attrs,o.attrs)}case"widget":{const o=t,r=void 0!==e.key||void 0!==o.key?e.key===o.key:e.toDOM===o.toDOM;return e.offset===o.offset&&e.side===o.side&&e.key===o.key&&r}}}function R(e,t){if(e===t)return!0;const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(const n of o)if(e[n]!==t[n])return!1;return!0}export{y as _,P as a,l as c,h as d,a as f,c as g,i as h,w as i,f as l,u as m,z as n,x as o,p,v as r,o as s,S as t,b as u};
|
|
3
|
-
//# sourceMappingURL=Decoration-
|
|
3
|
+
//# sourceMappingURL=Decoration-BoFcdSXk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Decoration-BoFcdSXk.mjs","names":["isBlockNode","createPosition","IDENTITY_MAP","Object","freeze","type","ImmutableReadonlySet","values","constructor","this","Set","size","has","value","entries","keys","Symbol","iterator","forEach","callback","thisArg","call","union","other","setLikeValues","intersection","otherValues","hasSetValue","add","difference","filter","symmetricDifference","isSubsetOf","isSupersetOf","isDisjointFrom","copy","next","done","snapshotStepMap","stepMap","removedBlockIds","parentPath","insertedBlockIds","fromParentPath","toParentPath","collectRemovedBlockIds","node","ids","walk","n","id","child","children","mapPositionThroughStep","pos","map","assoc","deleted","blockId","delta","newLen","to","from","off","offset","newOff","shiftedPos","mapPositionThroughShift","newBlockId","mapPositionThroughSplit","sourceBlockId","targetBlockId","targetLengthBefore","mapPositionThroughMerge","mapPositionThroughBlockRemoval","original","newOffset","path","Mapping","static","maps","filtered","m","push","length","empty","appendMap","appendMapping","isEmpty","mapResult","current","contentDeleted","structurallyDeleted","result","mapRange","range","assocFrom","assocTo","mapInBlockRange","mapping","fromPos","toPos","fromResult","toResult","mapOffsetInBlock","mapChildIndex","index","foldChildIndex","mapInsertionIndex","kind","mapChildIndexThroughStep","sameParentPath","fromIndex","sameParent","destinationIndex","mapChildIndexThroughMove","a","b","i","invertStepMap","movedNodeId","stepMapsEqual","bs","bm","br","cs","optionalIdSetsEqual","mapDecorationThroughStepMap","deco","mapInlineShift","mapInlineSplit","mapInlineMerge","mapInline","side","mapWidgetShift","mapWidgetSplit","mapWidgetMerge","mapWidget","mapNode","WIDGET_CALLBACK_OWNER","getWidgetCallbackOwner","decoration","inline","attrs","widget","toDOM","options","key","DecorationSet","byBlock","Map","create","decorations","existing","get","set","find","findInline","decos","d","findNode","findWidget","bid","remove","predicate","changed","merge","withWidgetOwner","pluginId","attributed","name","equals","otherDecos","decorationArraysEqual","tr","mapped","Array","isArray","r","ai","bi","decorationsEqual","attrsEqual","bn","bw","sameIdentity","aKeys","bKeys"],"sources":["../../src/state/Mapping.ts","../../src/decorations/PositionMapping.ts","../../src/decorations/Decoration.ts"],"sourcesContent":["/**\n * Generic position-mapping primitive.\n *\n * Each {@link Step} produces a {@link StepMap} that describes how positions\n * in `{blockId, offset}` space shift when the step is applied. A\n * {@link Mapping} composes a sequence of `StepMap`s — typically all the maps\n * of a transaction — into a single mapper, so any consumer (decorations,\n * comments, selections, remote cursors, history) can fold a position\n * through an entire change set without re-implementing per-step math.\n *\n * The model mirrors ProseMirror's `StepMap` / `Mapping`, adapted to\n * notectl's `{blockId, offset}` position space (positions are scoped to\n * blocks, not a flat document offset).\n *\n * ## Association (bias) semantics\n *\n * The optional `assoc` argument decides which side of a boundary a position\n * sticks to:\n *\n * - `assoc = -1` (\"sticky left\"): the position stays at the boundary when\n * content is inserted at, or split exactly at, the position. This is the\n * semantics expected by an inclusive-start range marker (a decoration's\n * `from`, the left edge of a selection).\n * - `assoc = +1` (\"sticky right\"): the position moves past inserted content\n * and migrates to the new block when its host block is split exactly at\n * the position. This is the semantics expected by an exclusive-end range\n * marker (a decoration's `to`, the right edge of a selection).\n *\n * The default is `-1`, matching the most common case (cursor and from-side\n * mappers).\n *\n * ## StepMap categories\n *\n * Every {@link Step} produces exactly one of six categories:\n *\n * 1. `identity` — no position shift (mark, attribute, schema, block-type).\n * 2. `shift` — within a single block, the range `[from, to)` is replaced\n * with content of length `newLen`. Covers `insertText`, `deleteText`,\n * `insertInlineNode`, `removeInlineNode` as a single primitive.\n * 3. `split` — a block is split at an offset; positions past the split\n * migrate to the new block with rebased offsets.\n * 4. `merge` — a source block is appended to a target block; positions in\n * the source block migrate to the target block with offsets shifted by\n * the target's previous length.\n * 5. `blockRemoval` — one block subtree vanishes; positions inside any\n * removed block are marked deleted, and sibling child-indices in the\n * same parent shift down by one past the removed index.\n * 6. `childIndexShift` — a new block was inserted at `fromIndex` in\n * `parentPath`'s children; sibling child-indices `≥ fromIndex` shift up.\n * Position space ({blockId, offset}) is unaffected.\n *\n * `blockRemoval` and `childIndexShift` are the two categories that carry\n * **structural** information about a parent's child list. They are\n * orthogonal to positions ({blockId, offset}) and are interpreted by\n * {@link mapChildIndex} when rebasing tree-structural steps\n * (`insertNode` / `removeNode`).\n */\n\nimport { isBlockNode } from '../model/Document.js';\nimport type { BlockNode } from '../model/Document.js';\nimport type { Position } from '../model/Selection.js';\nimport { createPosition } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\n\n/**\n * Result of mapping an `(blockId, [from, to))` range through a {@link Mapping}.\n *\n * Both endpoints are guaranteed to live in the same block. Callers can rely\n * on `from <= to` (the helper returns `null` rather than producing an\n * inverted range).\n */\nexport interface MappedInBlockRange {\n\treadonly blockId: BlockId;\n\treadonly from: number;\n\treadonly to: number;\n}\n\n/** Position-mapping bias at a boundary. */\nexport type Assoc = -1 | 1;\n\n// --- StepMap variants ---\n\n/** No-op map: positions pass through unchanged. */\nexport interface IdentityMap {\n\treadonly type: 'identity';\n}\n\n/**\n * Within `blockId`, the offset range `[from, to)` is replaced with content\n * of length `newLen`. Covers all in-block content edits with a single\n * primitive:\n *\n * - `insertText(blockId, off, text)` → `{from: off, to: off, newLen: text.length}`.\n * - `deleteText(blockId, f, t)` → `{from: f, to: t, newLen: 0}`.\n * - `insertInlineNode(blockId, off)` → `{from: off, to: off, newLen: 1}`.\n * - `removeInlineNode(blockId, off)` → `{from: off, to: off + 1, newLen: 0}`.\n */\nexport interface ShiftMap {\n\treadonly type: 'shift';\n\treadonly blockId: BlockId;\n\treadonly from: number;\n\treadonly to: number;\n\treadonly newLen: number;\n}\n\n/**\n * A block is split at `offset`. Content `[0, offset)` stays in `blockId`;\n * content `[offset, length)` migrates to `newBlockId` rebased to start at 0.\n */\nexport interface SplitMap {\n\treadonly type: 'split';\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n\treadonly newBlockId: BlockId;\n}\n\n/**\n * `sourceBlockId` is appended to `targetBlockId`. Positions in the source\n * block migrate to the target block with offset shifted by\n * `targetLengthBefore` (the target's length before the merge).\n */\nexport interface MergeMap {\n\treadonly type: 'merge';\n\treadonly targetBlockId: BlockId;\n\treadonly sourceBlockId: BlockId;\n\treadonly targetLengthBefore: number;\n}\n\n/**\n * A block subtree is removed from the document. Positions whose `blockId`\n * is in `removedBlockIds` are marked deleted; `removedBlockIds` covers the\n * removed root **plus all descendant block IDs** (see\n * {@link collectRemovedBlockIds}).\n *\n * `parentPath` and `index` carry the removal's structural coordinates so\n * sibling child-indices in the same parent can be rebased: any\n * `(parentPath, i)` with `i === index` becomes invalid (the block is gone),\n * and `i > index` shifts down by one. See {@link mapChildIndex}.\n */\nexport interface BlockRemovalMap {\n\treadonly type: 'blockRemoval';\n\treadonly removedBlockIds: ReadonlySet<BlockId>;\n\treadonly parentPath: readonly BlockId[];\n\treadonly index: number;\n}\n\n/**\n * A new block was inserted at `fromIndex` in `parentPath`'s child list.\n * Sibling child-indices `≥ fromIndex` shift up by `delta` (always `+1`\n * since {@link InsertNodeStep} inserts a single block). Position space\n * (`{blockId, offset}`) is unaffected — the new block has no prior\n * positions, and positions inside other siblings keep their offsets.\n *\n * Consumed by {@link mapChildIndex}, {@link mapInsertionIndex}, and exact\n * structural inverse detection during history replay.\n */\nexport interface ChildIndexShiftMap {\n\treadonly type: 'childIndexShift';\n\treadonly parentPath: readonly BlockId[];\n\treadonly fromIndex: number;\n\treadonly delta: number;\n\t/**\n\t * IDs introduced by an InsertNodeStep. Optional for synthetic/test maps;\n\t * when present it makes the map an exact structural inverse of the matching\n\t * BlockRemovalMap during history replay.\n\t */\n\treadonly insertedBlockIds?: ReadonlySet<BlockId>;\n}\n\n/**\n * One existing subtree moves between child lists. Positions inside the moved\n * subtree keep their block IDs and offsets; sibling child indices in both\n * parents are shifted by the removal followed by the insertion.\n */\nexport interface MoveNodeMap {\n\treadonly type: 'moveNode';\n\treadonly movedNodeId: BlockId;\n\treadonly fromParentPath: readonly BlockId[];\n\treadonly fromIndex: number;\n\treadonly toParentPath: readonly BlockId[];\n\t/** Destination index after removing the source node. */\n\treadonly destinationIndex: number;\n}\n\n/** Discriminated union of all StepMap variants. */\nexport type StepMap =\n\t| IdentityMap\n\t| ShiftMap\n\t| SplitMap\n\t| MergeMap\n\t| BlockRemovalMap\n\t| ChildIndexShiftMap\n\t| MoveNodeMap;\n\n// --- Map results ---\n\n/** Result of mapping a single position. */\nexport interface MapResult {\n\treadonly pos: Position;\n\t/** True if the input position fell inside content removed by the map. */\n\treadonly deleted: boolean;\n}\n\n/** A range expressed in `Position` space. */\nexport interface PositionRange {\n\treadonly from: Position;\n\treadonly to: Position;\n}\n\n// --- Singletons / factories ---\n\n/** The shared identity StepMap; reuse instead of allocating per step. */\nexport const IDENTITY_MAP: IdentityMap = Object.freeze({ type: 'identity' });\n\n/**\n * Runtime-immutable ReadonlySet facade.\n *\n * `Object.freeze(new Set())` only freezes the wrapper object; its internal\n * slots remain mutable through `add`, `delete`, and `clear`. Keeping the real\n * Set in an ECMAScript private field and exposing only ReadonlySet operations\n * makes structural StepMap snapshots immutable at runtime as well as by type.\n */\nclass ImmutableReadonlySet<T> implements ReadonlySet<T> {\n\treadonly #values: Set<T>;\n\n\tconstructor(values: Iterable<T>) {\n\t\tthis.#values = new Set(values);\n\t\tObject.freeze(this);\n\t}\n\n\tget size(): number {\n\t\treturn this.#values.size;\n\t}\n\n\thas(value: T): boolean {\n\t\treturn this.#values.has(value);\n\t}\n\n\tentries(): SetIterator<[T, T]> {\n\t\treturn this.#values.entries();\n\t}\n\n\tkeys(): SetIterator<T> {\n\t\treturn this.#values.keys();\n\t}\n\n\tvalues(): SetIterator<T> {\n\t\treturn this.#values.values();\n\t}\n\n\t[Symbol.iterator](): SetIterator<T> {\n\t\treturn this.#values[Symbol.iterator]();\n\t}\n\n\tforEach(callback: (value: T, value2: T, set: ReadonlySet<T>) => void, thisArg?: unknown): void {\n\t\tfor (const value of this.#values) callback.call(thisArg, value, value, this);\n\t}\n\n\tunion<U>(other: ReadonlySetLike<U>): Set<T | U> {\n\t\treturn new Set<T | U>([...this.#values, ...setLikeValues(other)]);\n\t}\n\n\tintersection<U>(other: ReadonlySetLike<U>): Set<T & U> {\n\t\tconst otherValues = setLikeValues(other);\n\t\tconst intersection = new Set<T & U>();\n\t\tfor (const value of this.#values) {\n\t\t\tif (hasSetValue(otherValues, value)) intersection.add(value as T & U);\n\t\t}\n\t\treturn intersection;\n\t}\n\n\tdifference<U>(other: ReadonlySetLike<U>): Set<T> {\n\t\tconst otherValues = setLikeValues(other);\n\t\treturn new Set([...this.#values].filter((value) => !hasSetValue(otherValues, value)));\n\t}\n\n\tsymmetricDifference<U>(other: ReadonlySetLike<U>): Set<T | U> {\n\t\tconst otherValues = setLikeValues(other);\n\t\tconst difference = new Set<T | U>();\n\t\tfor (const value of this.#values) {\n\t\t\tif (!hasSetValue(otherValues, value)) difference.add(value);\n\t\t}\n\t\tfor (const value of otherValues) {\n\t\t\tif (!hasSetValue(this.#values, value)) difference.add(value);\n\t\t}\n\t\treturn difference;\n\t}\n\n\tisSubsetOf(other: ReadonlySetLike<unknown>): boolean {\n\t\tconst otherValues = setLikeValues(other);\n\t\tfor (const value of this.#values) {\n\t\t\tif (!otherValues.has(value)) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tisSupersetOf(other: ReadonlySetLike<unknown>): boolean {\n\t\tfor (const value of setLikeValues(other)) {\n\t\t\tif (!hasSetValue(this.#values, value)) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tisDisjointFrom(other: ReadonlySetLike<unknown>): boolean {\n\t\tfor (const value of setLikeValues(other)) {\n\t\t\tif (hasSetValue(this.#values, value)) return false;\n\t\t}\n\t\treturn true;\n\t}\n}\n\nfunction setLikeValues<T>(values: ReadonlySetLike<T>): Set<T> {\n\tconst copy = new Set<T>();\n\tconst iterator = values.keys();\n\tfor (let next = iterator.next(); !next.done; next = iterator.next()) copy.add(next.value);\n\treturn copy;\n}\n\nfunction hasSetValue(values: ReadonlySetLike<unknown>, value: unknown): boolean {\n\treturn values.has(value);\n}\n\n/** Creates a detached, deeply immutable snapshot of a StepMap payload. */\nexport function snapshotStepMap(stepMap: StepMap): StepMap {\n\tswitch (stepMap.type) {\n\t\tcase 'identity':\n\t\t\treturn IDENTITY_MAP;\n\t\tcase 'blockRemoval':\n\t\t\treturn Object.freeze({\n\t\t\t\t...stepMap,\n\t\t\t\tremovedBlockIds: new ImmutableReadonlySet(stepMap.removedBlockIds),\n\t\t\t\tparentPath: Object.freeze([...stepMap.parentPath]),\n\t\t\t});\n\t\tcase 'childIndexShift':\n\t\t\treturn Object.freeze({\n\t\t\t\t...stepMap,\n\t\t\t\tparentPath: Object.freeze([...stepMap.parentPath]),\n\t\t\t\t...(stepMap.insertedBlockIds\n\t\t\t\t\t? { insertedBlockIds: new ImmutableReadonlySet(stepMap.insertedBlockIds) }\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\tcase 'moveNode':\n\t\t\treturn Object.freeze({\n\t\t\t\t...stepMap,\n\t\t\t\tfromParentPath: Object.freeze([...stepMap.fromParentPath]),\n\t\t\t\ttoParentPath: Object.freeze([...stepMap.toParentPath]),\n\t\t\t});\n\t\tdefault:\n\t\t\treturn Object.freeze({ ...stepMap });\n\t}\n}\n\n/**\n * Walks a block subtree and returns the set of its own ID plus every\n * descendant block ID. Used to build {@link BlockRemovalMap.removedBlockIds}.\n */\nexport function collectRemovedBlockIds(node: BlockNode): Set<BlockId> {\n\tconst ids = new Set<BlockId>();\n\tconst walk = (n: BlockNode): void => {\n\t\tids.add(n.id);\n\t\tfor (const child of n.children) {\n\t\t\tif (isBlockNode(child)) walk(child);\n\t\t}\n\t};\n\twalk(node);\n\treturn ids;\n}\n\n// --- Single-StepMap application ---\n\n/**\n * Maps a single position through one {@link StepMap}.\n *\n * @param pos input position\n * @param map the StepMap describing the change\n * @param assoc which side of a boundary to stick to (default `-1`)\n * @returns mapped position plus a `deleted` flag indicating whether `pos`\n * fell inside content that the step removed\n */\nexport function mapPositionThroughStep(pos: Position, map: StepMap, assoc: Assoc = -1): MapResult {\n\tswitch (map.type) {\n\t\tcase 'identity':\n\t\t\treturn { pos, deleted: false };\n\t\tcase 'shift':\n\t\t\treturn mapPositionThroughShift(pos, map, assoc);\n\t\tcase 'split':\n\t\t\treturn mapPositionThroughSplit(pos, map, assoc);\n\t\tcase 'merge':\n\t\t\treturn mapPositionThroughMerge(pos, map);\n\t\tcase 'blockRemoval':\n\t\t\treturn mapPositionThroughBlockRemoval(pos, map);\n\t\tcase 'childIndexShift':\n\t\t\t// Child-index shifts do not touch position space ({blockId, offset}):\n\t\t\t// a new sibling block has no prior positions to map, and existing\n\t\t\t// siblings keep their internal offsets even if their parent-relative\n\t\t\t// index changed. Consumed only by {@link mapChildIndex}.\n\t\t\treturn { pos, deleted: false };\n\t\tcase 'moveNode':\n\t\t\t// A move preserves block identity and in-block offsets. Structural\n\t\t\t// child-index consumers handle the parent-list shifts separately.\n\t\t\treturn { pos, deleted: false };\n\t}\n}\n\nfunction mapPositionThroughShift(pos: Position, map: ShiftMap, assoc: Assoc): MapResult {\n\tif (pos.blockId !== map.blockId) return { pos, deleted: false };\n\n\tconst delta: number = map.newLen - (map.to - map.from);\n\tconst off: number = pos.offset;\n\n\t// Strictly before the affected range\n\tif (off < map.from) return { pos, deleted: false };\n\n\t// At the start boundary\n\tif (off === map.from) {\n\t\t// Pure insertion (from === to): assoc decides whether we stick before\n\t\t// or after the inserted run.\n\t\tif (map.from === map.to) {\n\t\t\tconst newOff: number = assoc === 1 ? map.from + map.newLen : map.from;\n\t\t\treturn newOff === off\n\t\t\t\t? { pos, deleted: false }\n\t\t\t\t: { pos: shiftedPos(pos, newOff), deleted: false };\n\t\t}\n\t\t// Deletion starts at this point — position stays at `from` regardless\n\t\t// of assoc; nothing was inserted to skip past.\n\t\treturn { pos, deleted: false };\n\t}\n\n\t// Strictly inside [from, to): position fell into removed content\n\tif (off < map.to) {\n\t\tconst newOff: number = assoc === 1 ? map.from + map.newLen : map.from;\n\t\treturn { pos: shiftedPos(pos, newOff), deleted: true };\n\t}\n\n\t// At or past the end boundary: shift by delta\n\tconst newOff: number = off + delta;\n\treturn newOff === off\n\t\t? { pos, deleted: false }\n\t\t: { pos: shiftedPos(pos, newOff), deleted: false };\n}\n\nfunction mapPositionThroughSplit(pos: Position, map: SplitMap, assoc: Assoc): MapResult {\n\tif (pos.blockId !== map.blockId) return { pos, deleted: false };\n\n\tif (pos.offset < map.offset) return { pos, deleted: false };\n\n\tif (pos.offset > map.offset) {\n\t\treturn {\n\t\t\tpos: createPosition(map.newBlockId, pos.offset - map.offset),\n\t\t\tdeleted: false,\n\t\t};\n\t}\n\n\t// At the split boundary: assoc decides which side keeps the cursor.\n\tif (assoc === 1) {\n\t\treturn { pos: createPosition(map.newBlockId, 0), deleted: false };\n\t}\n\treturn { pos, deleted: false };\n}\n\nfunction mapPositionThroughMerge(pos: Position, map: MergeMap): MapResult {\n\tif (pos.blockId !== map.sourceBlockId) return { pos, deleted: false };\n\treturn {\n\t\tpos: createPosition(map.targetBlockId, pos.offset + map.targetLengthBefore),\n\t\tdeleted: false,\n\t};\n}\n\nfunction mapPositionThroughBlockRemoval(pos: Position, map: BlockRemovalMap): MapResult {\n\tif (map.removedBlockIds.has(pos.blockId)) {\n\t\treturn { pos, deleted: true };\n\t}\n\treturn { pos, deleted: false };\n}\n\n/** Allocates a new Position with the given offset, preserving an optional `path`. */\nfunction shiftedPos(original: Position, newOffset: number): Position {\n\treturn createPosition(original.blockId, newOffset, original.path);\n}\n\n// --- Mapping ---\n\n/**\n * Composes a sequence of {@link StepMap}s into a single mapper. A `Mapping`\n * is immutable; `appendMap` returns a new instance.\n *\n * Construction always normalizes by dropping identity maps — they're a\n * common case and would otherwise inflate every transaction's mapping\n * pipeline with no-ops.\n */\nexport class Mapping {\n\t/** Shared empty Mapping. */\n\tstatic readonly empty: Mapping = new Mapping([]);\n\n\treadonly maps: readonly StepMap[];\n\n\tprivate constructor(maps: readonly StepMap[]) {\n\t\tthis.maps = Object.freeze(maps.map(snapshotStepMap));\n\t\tObject.freeze(this);\n\t}\n\n\t/** Creates a Mapping from a list of StepMaps, dropping identity maps. */\n\tstatic from(maps: readonly StepMap[]): Mapping {\n\t\tconst filtered: StepMap[] = [];\n\t\tfor (const m of maps) {\n\t\t\tif (m.type !== 'identity') filtered.push(m);\n\t\t}\n\t\tif (filtered.length === 0) return Mapping.empty;\n\t\treturn new Mapping(filtered);\n\t}\n\n\t/** Returns a new Mapping with `map` appended. */\n\tappendMap(map: StepMap): Mapping {\n\t\tif (map.type === 'identity') return this;\n\t\treturn new Mapping([...this.maps, map]);\n\t}\n\n\t/** Concatenates two mappings into a new one. */\n\tappendMapping(other: Mapping): Mapping {\n\t\tif (other.maps.length === 0) return this;\n\t\tif (this.maps.length === 0) return other;\n\t\treturn new Mapping([...this.maps, ...other.maps]);\n\t}\n\n\t/** True if the mapping contains no position-changing maps. */\n\tget isEmpty(): boolean {\n\t\treturn this.maps.length === 0;\n\t}\n\n\t/**\n\t * Folds a position through every contained StepMap in order.\n\t * Returns the mapped position; the `deleted` flag is **not** preserved\n\t * (use {@link mapResult} when you need it).\n\t */\n\tmap(pos: Position, assoc: Assoc = -1): Position {\n\t\treturn this.mapResult(pos, assoc).pos;\n\t}\n\n\t/**\n\t * Like {@link map}, but returns whether the position is deleted in the final\n\t * frame. Content deletion remains sticky across every later map. Structural\n\t * deletion can be recovered by an `insertNode` map carrying the same block\n\t * ID; a later removal can mark that identity deleted again.\n\t */\n\tmapResult(pos: Position, assoc: Assoc = -1): MapResult {\n\t\tlet current: Position = pos;\n\t\tlet contentDeleted = false;\n\t\tlet structurallyDeleted = false;\n\t\tfor (const m of this.maps) {\n\t\t\tconst result: MapResult = mapPositionThroughStep(current, m, assoc);\n\t\t\tcurrent = result.pos;\n\t\t\tif (result.deleted) {\n\t\t\t\tif (m.type === 'blockRemoval') {\n\t\t\t\t\tstructurallyDeleted = true;\n\t\t\t\t} else {\n\t\t\t\t\tcontentDeleted = true;\n\t\t\t\t}\n\t\t\t} else if (m.type === 'childIndexShift' && m.insertedBlockIds?.has(current.blockId)) {\n\t\t\t\tstructurallyDeleted = false;\n\t\t\t}\n\t\t}\n\t\treturn { pos: current, deleted: contentDeleted || structurallyDeleted };\n\t}\n\n\t/**\n\t * Maps a range. By convention, `from` is mapped with `assoc = -1`\n\t * (inclusive-start) and `to` with `assoc = +1` (exclusive-end). The\n\t * caller may override either bias.\n\t *\n\t * Returns `null` when both endpoints land in deleted content **and** the\n\t * mapped range would collapse to length zero or negative — i.e. the\n\t * range no longer covers any live content.\n\t *\n\t * The returned `from`/`to` may live in different blocks (e.g. after a\n\t * `split` map). Callers that require an in-block range (decorations,\n\t * inline selections) must detect and split accordingly.\n\t */\n\tmapRange(range: PositionRange, assocFrom: Assoc = -1, assocTo: Assoc = 1): PositionRange | null {\n\t\tconst from: MapResult = this.mapResult(range.from, assocFrom);\n\t\tconst to: MapResult = this.mapResult(range.to, assocTo);\n\n\t\tif (from.deleted && to.deleted) {\n\t\t\tif (from.pos.blockId === to.pos.blockId && from.pos.offset >= to.pos.offset) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\treturn { from: from.pos, to: to.pos };\n\t}\n}\n\n// --- In-block range helpers (used by per-step Step→Step mapping) ---\n\n/**\n * Maps an `(blockId, [from, to))` range through `mapping`, asserting the\n * result lives in a single block.\n *\n * Returns `null` when the range no longer addresses live content in a single\n * block:\n *\n * - the host block was removed;\n * - the range was fully deleted (both endpoints flagged deleted and collapse);\n * - the endpoints migrated to different blocks (range fragmented, e.g. a\n * `split` map placed `from` and `to` on opposite sides of the cut).\n *\n * Default biases are **conservative for step rebasing**: `assocFrom = +1`,\n * `assocTo = -1`. An intervening insertion at either boundary therefore\n * does NOT expand the rebased range to cover the new content — the user's\n * original edit only addressed the original content, and the agent's\n * intervening insertion should be preserved across an undo/redo. This is\n * the opposite of {@link Mapping.mapRange}'s default biases, which model\n * selections (inclusive-start, exclusive-end) where boundary insertions\n * naturally extend the selection.\n */\nexport function mapInBlockRange(\n\tblockId: BlockId,\n\tfrom: number,\n\tto: number,\n\tmapping: Mapping,\n\tassocFrom: Assoc = 1,\n\tassocTo: Assoc = -1,\n): MappedInBlockRange | null {\n\tif (mapping.isEmpty) return { blockId, from, to };\n\n\tconst fromPos: Position = createPosition(blockId, from);\n\tconst toPos: Position = createPosition(blockId, to);\n\tconst fromResult: MapResult = mapping.mapResult(fromPos, assocFrom);\n\tconst toResult: MapResult = mapping.mapResult(toPos, assocTo);\n\n\t// If both endpoints fell inside removed/replaced content, the range no\n\t// longer addresses live document territory — abandon. A partial overlap\n\t// (one endpoint deleted, the other shifted) still survives clamped.\n\tif (fromResult.deleted && toResult.deleted) return null;\n\n\t// Range must remain within a single block. A split could have moved one\n\t// endpoint to the new block; that's a fragmentation we cannot represent\n\t// as a single in-block step.\n\tif (fromResult.pos.blockId !== toResult.pos.blockId) return null;\n\n\t// Defensive: a range whose endpoints inverted (from > to) is invalid.\n\t// An empty range with from === to is still valid (e.g. a pure-insertion\n\t// `shift` whose offset survived).\n\tif (fromResult.pos.offset > toResult.pos.offset) return null;\n\n\treturn {\n\t\tblockId: fromResult.pos.blockId,\n\t\tfrom: fromResult.pos.offset,\n\t\tto: toResult.pos.offset,\n\t};\n}\n\n/**\n * Maps an `(blockId, offset)` point through `mapping`, returning the\n * equivalent in-block position or `null` when the host block was removed.\n *\n * Convenience wrapper around {@link mapInBlockRange} for steps that carry a\n * single offset (`insertText`, `insertInlineNode`, `splitBlock`).\n */\nexport function mapOffsetInBlock(\n\tblockId: BlockId,\n\toffset: number,\n\tmapping: Mapping,\n\tassoc: Assoc = -1,\n): MappedInBlockRange | null {\n\tif (mapping.isEmpty) return { blockId, from: offset, to: offset };\n\n\tconst pos: Position = createPosition(blockId, offset);\n\tconst result: MapResult = mapping.mapResult(pos, assoc);\n\tif (result.deleted) return null;\n\treturn { blockId: result.pos.blockId, from: result.pos.offset, to: result.pos.offset };\n}\n\n// --- Child-index mapping (used by structural step rebasing) ---\n\n/**\n * Rebases a child-index `(parentPath, index)` through `mapping`. The\n * `index` is interpreted as the position of an **existing** child block:\n * if an intervening edit removed exactly that child, the result is\n * `null`. For an **insertion slot** (the target index of a future\n * `insertNode`), use {@link mapInsertionIndex} — slots stay valid even\n * when the block previously at that index is removed.\n *\n * Child-indices live in a coordinate space orthogonal to positions\n * (`{blockId, offset}`): they describe a slot in a parent's child list,\n * not a place inside text. Three {@link StepMap} categories carry\n * child-index-affecting information:\n *\n * - {@link ChildIndexShiftMap} (produced by `insertNode`): shifts\n * sibling indices `≥ fromIndex` by `delta` (always `+1` today).\n * - {@link BlockRemovalMap} (produced by `removeNode`): removes the child\n * at `index` (the input index becomes invalid → `null`), and shifts\n * sibling indices `> index` down by `1`.\n * - {@link MoveNodeMap} (produced by `moveNode`): combines the source removal\n * and destination insertion while preserving the moved subtree's identity.\n *\n * Maps whose `parentPath` differs from the input pass through; all\n * non-structural categories (`shift`, `split`, `merge`, `identity`) are\n * no-ops here.\n */\nexport function mapChildIndex(\n\tparentPath: readonly BlockId[],\n\tindex: number,\n\tmapping: Mapping,\n): number | null {\n\treturn foldChildIndex(parentPath, index, mapping, 'existing');\n}\n\n/**\n * Rebases an **insertion slot** `(parentPath, index)` through `mapping`.\n * An insertion slot lives in `[0, children.length]` (inclusive of the\n * end) and represents \"where to insert\", not an existing block. Slots\n * remain valid across intervening edits — even when the block previously\n * at that index is removed — so this function never returns `null`.\n *\n * Difference from {@link mapChildIndex}: for a `BlockRemovalMap` with\n * matching parent and `index === map.index`, this function keeps the\n * slot (returning `map.index`, which is the same numeric position in the\n * post-removal frame); {@link mapChildIndex} would return `null`.\n * {@link ChildIndexShiftMap} handling is identical.\n */\nexport function mapInsertionIndex(\n\tparentPath: readonly BlockId[],\n\tindex: number,\n\tmapping: Mapping,\n): number {\n\t// `foldChildIndex` with `'insertion'` provably never returns `null` —\n\t// the only path that would (BlockRemovalMap, matching parent, matching\n\t// index) is short-circuited inside `mapChildIndexThroughStep`. The\n\t// overload signature carries that invariant into the type system.\n\treturn foldChildIndex(parentPath, index, mapping, 'insertion');\n}\n\ntype ChildIndexKind = 'existing' | 'insertion';\n\nfunction foldChildIndex(\n\tparentPath: readonly BlockId[],\n\tindex: number,\n\tmapping: Mapping,\n\tkind: 'existing',\n): number | null;\nfunction foldChildIndex(\n\tparentPath: readonly BlockId[],\n\tindex: number,\n\tmapping: Mapping,\n\tkind: 'insertion',\n): number;\nfunction foldChildIndex(\n\tparentPath: readonly BlockId[],\n\tindex: number,\n\tmapping: Mapping,\n\tkind: ChildIndexKind,\n): number | null {\n\tif (mapping.isEmpty) return index;\n\n\tlet current: number = index;\n\tfor (const m of mapping.maps) {\n\t\tconst next: number | null = mapChildIndexThroughStep(parentPath, current, m, kind);\n\t\tif (next === null) return null;\n\t\tcurrent = next;\n\t}\n\treturn current;\n}\n\nfunction mapChildIndexThroughStep(\n\tparentPath: readonly BlockId[],\n\tindex: number,\n\tmap: StepMap,\n\tkind: ChildIndexKind,\n): number | null {\n\tswitch (map.type) {\n\t\tcase 'identity':\n\t\tcase 'shift':\n\t\tcase 'split':\n\t\tcase 'merge':\n\t\t\treturn index;\n\t\tcase 'blockRemoval':\n\t\t\tif (!sameParentPath(parentPath, map.parentPath)) return index;\n\t\t\tif (index === map.index) {\n\t\t\t\t// Existing-child semantics: that child is gone → invalid.\n\t\t\t\t// Insertion-slot semantics: the slot survives; nothing was\n\t\t\t\t// inserted/removed *to the left* of `index`, so the slot\n\t\t\t\t// number is unchanged in the post-removal frame.\n\t\t\t\treturn kind === 'existing' ? null : index;\n\t\t\t}\n\t\t\tif (index > map.index) return index - 1;\n\t\t\treturn index;\n\t\tcase 'childIndexShift':\n\t\t\tif (!sameParentPath(parentPath, map.parentPath)) return index;\n\t\t\tif (index >= map.fromIndex) return index + map.delta;\n\t\t\treturn index;\n\t\tcase 'moveNode':\n\t\t\treturn mapChildIndexThroughMove(parentPath, index, map, kind);\n\t}\n}\n\nfunction mapChildIndexThroughMove(\n\tparentPath: readonly BlockId[],\n\tindex: number,\n\tmap: MoveNodeMap,\n\tkind: ChildIndexKind,\n): number | null {\n\tconst sameParent: boolean = sameParentPath(map.fromParentPath, map.toParentPath);\n\tif (sameParent && map.fromIndex === map.destinationIndex) return index;\n\tif (\n\t\tkind === 'existing' &&\n\t\tsameParent &&\n\t\tsameParentPath(parentPath, map.fromParentPath) &&\n\t\tindex === map.fromIndex\n\t) {\n\t\treturn map.destinationIndex;\n\t}\n\n\tlet current: number = index;\n\tif (sameParentPath(parentPath, map.fromParentPath)) {\n\t\tif (current === map.fromIndex) {\n\t\t\tif (kind === 'existing') return null;\n\t\t} else if (current > map.fromIndex) {\n\t\t\tcurrent--;\n\t\t}\n\t}\n\n\tif (sameParentPath(parentPath, map.toParentPath) && current >= map.destinationIndex) {\n\t\tcurrent++;\n\t}\n\treturn current;\n}\n\nfunction sameParentPath(a: readonly BlockId[], b: readonly BlockId[]): boolean {\n\tif (a === b) return true;\n\tif (a.length !== b.length) return false;\n\tfor (let i = 0; i < a.length; i++) {\n\t\tif (a[i] !== b[i]) return false;\n\t}\n\treturn true;\n}\n\n// --- StepMap inversion (used by history's frame-walk cancellation) ---\n\n/**\n * Returns the {@link StepMap} that undoes `map` in position space — i.e.\n * composing `map` with `invertStepMap(map)` is content-preserving (though\n * the composed position-mapping is *not* a true identity in our framework:\n * positions interior to a delete-then-reinsert round-trip clamp to the\n * deletion start during the deletion half and don't return on the insert\n * half).\n *\n * Used by history to detect mutually-inverse stepmaps in the rebase chain\n * and cancel them, sidestepping the round-trip clamping for cases where\n * the rebase is a no-op in content terms.\n *\n * Structural maps include enough metadata to recover their exact inverse\n * where possible. Synthetic ChildIndexShiftMaps without inserted subtree IDs\n * remain position-only and therefore invert to {@link IDENTITY_MAP}.\n */\nexport function invertStepMap(map: StepMap): StepMap {\n\tswitch (map.type) {\n\t\tcase 'identity':\n\t\t\treturn IDENTITY_MAP;\n\t\tcase 'shift':\n\t\t\treturn {\n\t\t\t\ttype: 'shift',\n\t\t\t\tblockId: map.blockId,\n\t\t\t\tfrom: map.from,\n\t\t\t\tto: map.from + map.newLen,\n\t\t\t\tnewLen: map.to - map.from,\n\t\t\t};\n\t\tcase 'split':\n\t\t\treturn {\n\t\t\t\ttype: 'merge',\n\t\t\t\ttargetBlockId: map.blockId,\n\t\t\t\tsourceBlockId: map.newBlockId,\n\t\t\t\ttargetLengthBefore: map.offset,\n\t\t\t};\n\t\tcase 'merge':\n\t\t\treturn {\n\t\t\t\ttype: 'split',\n\t\t\t\tblockId: map.targetBlockId,\n\t\t\t\toffset: map.targetLengthBefore,\n\t\t\t\tnewBlockId: map.sourceBlockId,\n\t\t\t};\n\t\tcase 'blockRemoval':\n\t\t\treturn {\n\t\t\t\ttype: 'childIndexShift',\n\t\t\t\tparentPath: map.parentPath,\n\t\t\t\tfromIndex: map.index,\n\t\t\t\tdelta: 1,\n\t\t\t\tinsertedBlockIds: map.removedBlockIds,\n\t\t\t};\n\t\tcase 'childIndexShift':\n\t\t\tif (map.delta === 1 && map.insertedBlockIds) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: 'blockRemoval',\n\t\t\t\t\tremovedBlockIds: map.insertedBlockIds,\n\t\t\t\t\tparentPath: map.parentPath,\n\t\t\t\t\tindex: map.fromIndex,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn IDENTITY_MAP;\n\t\tcase 'moveNode':\n\t\t\treturn {\n\t\t\t\ttype: 'moveNode',\n\t\t\t\tmovedNodeId: map.movedNodeId,\n\t\t\t\tfromParentPath: map.toParentPath,\n\t\t\t\tfromIndex: map.destinationIndex,\n\t\t\t\ttoParentPath: map.fromParentPath,\n\t\t\t\tdestinationIndex: map.fromIndex,\n\t\t\t};\n\t}\n}\n\n/**\n * Structural equality for {@link StepMap}s. Used by history to recognize\n * cancelling pairs in the rebase chain ({@link invertStepMap}(a) ≡ b).\n */\nexport function stepMapsEqual(a: StepMap, b: StepMap): boolean {\n\tif (a.type !== b.type) return false;\n\tswitch (a.type) {\n\t\tcase 'identity':\n\t\t\treturn true;\n\t\tcase 'shift': {\n\t\t\tconst bs = b as ShiftMap;\n\t\t\treturn (\n\t\t\t\ta.blockId === bs.blockId && a.from === bs.from && a.to === bs.to && a.newLen === bs.newLen\n\t\t\t);\n\t\t}\n\t\tcase 'split': {\n\t\t\tconst bs = b as SplitMap;\n\t\t\treturn a.blockId === bs.blockId && a.offset === bs.offset && a.newBlockId === bs.newBlockId;\n\t\t}\n\t\tcase 'merge': {\n\t\t\tconst bm = b as MergeMap;\n\t\t\treturn (\n\t\t\t\ta.targetBlockId === bm.targetBlockId &&\n\t\t\t\ta.sourceBlockId === bm.sourceBlockId &&\n\t\t\t\ta.targetLengthBefore === bm.targetLengthBefore\n\t\t\t);\n\t\t}\n\t\tcase 'blockRemoval': {\n\t\t\tconst br = b as BlockRemovalMap;\n\t\t\tif (a.index !== br.index) return false;\n\t\t\tif (!sameParentPath(a.parentPath, br.parentPath)) return false;\n\t\t\tif (a.removedBlockIds.size !== br.removedBlockIds.size) return false;\n\t\t\tfor (const id of a.removedBlockIds) {\n\t\t\t\tif (!br.removedBlockIds.has(id)) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tcase 'childIndexShift': {\n\t\t\tconst cs = b as ChildIndexShiftMap;\n\t\t\treturn (\n\t\t\t\ta.fromIndex === cs.fromIndex &&\n\t\t\t\ta.delta === cs.delta &&\n\t\t\t\tsameParentPath(a.parentPath, cs.parentPath) &&\n\t\t\t\toptionalIdSetsEqual(a.insertedBlockIds, cs.insertedBlockIds)\n\t\t\t);\n\t\t}\n\t\tcase 'moveNode': {\n\t\t\tif (b.type !== 'moveNode') return false;\n\t\t\treturn (\n\t\t\t\ta.movedNodeId === b.movedNodeId &&\n\t\t\t\ta.fromIndex === b.fromIndex &&\n\t\t\t\ta.destinationIndex === b.destinationIndex &&\n\t\t\t\tsameParentPath(a.fromParentPath, b.fromParentPath) &&\n\t\t\t\tsameParentPath(a.toParentPath, b.toParentPath)\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction optionalIdSetsEqual(\n\ta: ReadonlySet<BlockId> | undefined,\n\tb: ReadonlySet<BlockId> | undefined,\n): boolean {\n\tif (a === b) return true;\n\tif (!a || !b || a.size !== b.size) return false;\n\tfor (const id of a) {\n\t\tif (!b.has(id)) return false;\n\t}\n\treturn true;\n}\n","/**\n * Thin decoration-specific adapters over the generic {@link StepMap}\n * primitive. Position-shift arithmetic lives in `state/Mapping.ts`; this\n * module only contains the decoration-shape concerns:\n *\n * - splitting an {@link InlineDecoration} into two when a `splitBlock`\n * crosses its range,\n * - dropping a {@link NodeDecoration} when its block disappears\n * (`removeNode`) or is absorbed by a merge,\n * - applying widget `side` as the mapping `assoc`.\n *\n * The legacy entry point `mapDecorationThroughStep(deco, step)` is\n * preserved as a thin shim over `mapDecorationThroughStepMap` so existing\n * tests keep working; new consumers should reach for `Transaction.mapping`\n * directly via `DecorationSet.map(tr)`.\n */\n\nimport type { Document } from '../model/Document.js';\nimport { createPosition } from '../model/Selection.js';\nimport type { MergeMap, ShiftMap, SplitMap, StepMap } from '../state/Mapping.js';\nimport { mapPositionThroughStep } from '../state/Mapping.js';\nimport { getStepMap } from '../state/StepHandlers.js';\nimport type { Step } from '../state/Transaction.js';\nimport type {\n\tDecoration,\n\tInlineDecoration,\n\tNodeDecoration,\n\tWidgetDecoration,\n} from './Decoration.js';\n\nconst EMPTY_DOC: Document = { children: [] };\n\n/**\n * Maps a decoration through a single {@link StepMap}. Returns:\n * - the (possibly identical) decoration,\n * - an array of two decorations when a `splitBlock` cuts an inline range,\n * - or `null` when the decoration was deleted.\n */\nexport function mapDecorationThroughStepMap(\n\tdeco: Decoration,\n\tstepMap: StepMap,\n): Decoration | readonly Decoration[] | null {\n\tswitch (deco.type) {\n\t\tcase 'inline':\n\t\t\treturn mapInline(deco, stepMap);\n\t\tcase 'widget':\n\t\t\treturn mapWidget(deco, stepMap);\n\t\tcase 'node':\n\t\t\treturn mapNode(deco, stepMap);\n\t}\n}\n\n/**\n * Legacy entry point — kept for backward compatibility with callers and\n * tests that hold a {@link Step} rather than a {@link StepMap}. Internally\n * converts step → StepMap (cheap, no doc state needed for any of the\n * shape categories used here) and delegates to\n * {@link mapDecorationThroughStepMap}.\n */\nexport function mapDecorationThroughStep(\n\tdeco: Decoration,\n\tstep: Step,\n): Decoration | readonly Decoration[] | null {\n\treturn mapDecorationThroughStepMap(deco, getStepMap(EMPTY_DOC, step));\n}\n\n// --- Inline ---\n\nfunction mapInline(\n\tdeco: InlineDecoration,\n\tstepMap: StepMap,\n): InlineDecoration | readonly InlineDecoration[] | null {\n\tswitch (stepMap.type) {\n\t\tcase 'identity':\n\t\t\treturn deco;\n\t\tcase 'shift':\n\t\t\treturn mapInlineShift(deco, stepMap);\n\t\tcase 'split':\n\t\t\treturn mapInlineSplit(deco, stepMap);\n\t\tcase 'merge':\n\t\t\treturn mapInlineMerge(deco, stepMap);\n\t\tcase 'blockRemoval':\n\t\t\treturn stepMap.removedBlockIds.has(deco.blockId) ? null : deco;\n\t\tcase 'childIndexShift':\n\t\tcase 'moveNode':\n\t\t\t// Sibling-index shifts don't move text positions.\n\t\t\treturn deco;\n\t}\n}\n\nfunction mapInlineShift(deco: InlineDecoration, map: ShiftMap): InlineDecoration | null {\n\tif (deco.blockId !== map.blockId) return deco;\n\n\tconst fromPos = mapPositionThroughStep(createPosition(deco.blockId, deco.from), map, -1).pos;\n\tconst toPos = mapPositionThroughStep(createPosition(deco.blockId, deco.to), map, 1).pos;\n\n\tif (fromPos.offset >= toPos.offset) return null;\n\tif (fromPos.offset === deco.from && toPos.offset === deco.to) return deco;\n\treturn { ...deco, from: fromPos.offset, to: toPos.offset };\n}\n\nfunction mapInlineSplit(\n\tdeco: InlineDecoration,\n\tmap: SplitMap,\n): InlineDecoration | readonly InlineDecoration[] {\n\tif (deco.blockId !== map.blockId) return deco;\n\n\tif (deco.to <= map.offset) return deco;\n\n\tif (deco.from >= map.offset) {\n\t\treturn {\n\t\t\t...deco,\n\t\t\tblockId: map.newBlockId,\n\t\t\tfrom: deco.from - map.offset,\n\t\t\tto: deco.to - map.offset,\n\t\t};\n\t}\n\n\t// Spans the split — return both halves\n\tconst left: InlineDecoration = { ...deco, to: map.offset };\n\tconst right: InlineDecoration = {\n\t\t...deco,\n\t\tblockId: map.newBlockId,\n\t\tfrom: 0,\n\t\tto: deco.to - map.offset,\n\t};\n\treturn [left, right];\n}\n\nfunction mapInlineMerge(deco: InlineDecoration, map: MergeMap): InlineDecoration {\n\tif (deco.blockId !== map.sourceBlockId) return deco;\n\treturn {\n\t\t...deco,\n\t\tblockId: map.targetBlockId,\n\t\tfrom: deco.from + map.targetLengthBefore,\n\t\tto: deco.to + map.targetLengthBefore,\n\t};\n}\n\n// --- Widget ---\n\nfunction mapWidget(deco: WidgetDecoration, stepMap: StepMap): WidgetDecoration | null {\n\tswitch (stepMap.type) {\n\t\tcase 'identity':\n\t\t\treturn deco;\n\t\tcase 'shift':\n\t\t\treturn mapWidgetShift(deco, stepMap);\n\t\tcase 'split':\n\t\t\treturn mapWidgetSplit(deco, stepMap);\n\t\tcase 'merge':\n\t\t\treturn mapWidgetMerge(deco, stepMap);\n\t\tcase 'blockRemoval':\n\t\t\treturn stepMap.removedBlockIds.has(deco.blockId) ? null : deco;\n\t\tcase 'childIndexShift':\n\t\tcase 'moveNode':\n\t\t\treturn deco;\n\t}\n}\n\nfunction mapWidgetShift(deco: WidgetDecoration, map: ShiftMap): WidgetDecoration | null {\n\tif (deco.blockId !== map.blockId) return deco;\n\n\tconst result = mapPositionThroughStep(createPosition(deco.blockId, deco.offset), map, deco.side);\n\t// A widget that lands strictly inside removed content is deleted.\n\tif (result.deleted) return null;\n\tif (result.pos.offset === deco.offset) return deco;\n\treturn { ...deco, offset: result.pos.offset };\n}\n\nfunction mapWidgetSplit(deco: WidgetDecoration, map: SplitMap): WidgetDecoration {\n\tif (deco.blockId !== map.blockId) return deco;\n\tconst result = mapPositionThroughStep(createPosition(deco.blockId, deco.offset), map, deco.side);\n\tif (result.pos.blockId === deco.blockId && result.pos.offset === deco.offset) return deco;\n\treturn { ...deco, blockId: result.pos.blockId, offset: result.pos.offset };\n}\n\nfunction mapWidgetMerge(deco: WidgetDecoration, map: MergeMap): WidgetDecoration {\n\tif (deco.blockId !== map.sourceBlockId) return deco;\n\treturn {\n\t\t...deco,\n\t\tblockId: map.targetBlockId,\n\t\toffset: deco.offset + map.targetLengthBefore,\n\t};\n}\n\n// --- Node ---\n\nfunction mapNode(deco: NodeDecoration, stepMap: StepMap): NodeDecoration | null {\n\tswitch (stepMap.type) {\n\t\tcase 'identity':\n\t\tcase 'shift':\n\t\tcase 'split':\n\t\t\t// Node decorations are bound to a block; in-block content edits\n\t\t\t// and splits don't affect them. Splits keep the decoration on the\n\t\t\t// original block (the new block has no decoration of its own).\n\t\t\treturn deco;\n\t\tcase 'merge':\n\t\t\t// Source block disappears as a separate block → its decoration is dropped.\n\t\t\treturn deco.blockId === stepMap.sourceBlockId ? null : deco;\n\t\tcase 'blockRemoval':\n\t\t\treturn stepMap.removedBlockIds.has(deco.blockId) ? null : deco;\n\t\tcase 'childIndexShift':\n\t\tcase 'moveNode':\n\t\t\treturn deco;\n\t}\n}\n","/**\n * Decoration types and DecorationSet for transient, view-only annotations.\n * Decorations are NOT part of the document model and do NOT affect undo/redo.\n */\n\nimport type { PluginCallbackRegistration } from '../model/PluginCallbackExecutor.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { mapDecorationThroughStepMap } from './PositionMapping.js';\n\n// --- Decoration Attrs ---\n\nexport interface DecorationAttrs {\n\treadonly class?: string;\n\treadonly style?: string;\n\treadonly nodeName?: string;\n\treadonly [key: string]: string | undefined;\n}\n\n// --- Decoration Types ---\n\nconst WIDGET_CALLBACK_OWNER: unique symbol = Symbol('notectl.widget-callback-owner');\n\nexport interface InlineDecoration {\n\treadonly type: 'inline';\n\treadonly blockId: BlockId;\n\treadonly from: number;\n\treadonly to: number;\n\treadonly attrs: DecorationAttrs;\n}\n\nexport interface NodeDecoration {\n\treadonly type: 'node';\n\treadonly blockId: BlockId;\n\treadonly attrs: DecorationAttrs;\n}\n\nexport interface WidgetDecoration {\n\treadonly type: 'widget';\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n\treadonly toDOM: () => HTMLElement;\n\treadonly side: -1 | 1;\n\treadonly key?: string;\n\t/** Plugin ownership attached by PluginLifecycle before the decoration reaches the view. */\n\treadonly [WIDGET_CALLBACK_OWNER]?: PluginCallbackRegistration;\n}\n\nexport type Decoration = InlineDecoration | NodeDecoration | WidgetDecoration;\n\n/** Returns lifecycle-owned attribution for a widget renderer, when available. */\nexport function getWidgetCallbackOwner(\n\tdecoration: WidgetDecoration,\n): PluginCallbackRegistration | undefined {\n\treturn decoration[WIDGET_CALLBACK_OWNER];\n}\n\n// --- Factory Functions ---\n\n/** Creates an inline decoration for a text range within a block. */\nexport function inline(\n\tblockId: BlockId,\n\tfrom: number,\n\tto: number,\n\tattrs: DecorationAttrs,\n): InlineDecoration {\n\treturn { type: 'inline', blockId, from, to, attrs };\n}\n\n/** Creates a node decoration that applies to a whole block element. */\nexport function node(blockId: BlockId, attrs: DecorationAttrs): NodeDecoration {\n\treturn { type: 'node', blockId, attrs };\n}\n\n/** Creates a widget decoration that inserts a DOM element at a position. */\nexport function widget(\n\tblockId: BlockId,\n\toffset: number,\n\ttoDOM: () => HTMLElement,\n\toptions?: { readonly side?: -1 | 1; readonly key?: string },\n): WidgetDecoration {\n\treturn {\n\t\ttype: 'widget',\n\t\tblockId,\n\t\toffset,\n\t\ttoDOM,\n\t\tside: options?.side ?? -1,\n\t\tkey: options?.key,\n\t};\n}\n\n// --- DecorationSet ---\n\n/**\n * Immutable set of decorations indexed by block ID.\n * Provides efficient lookup and merging of decoration collections.\n */\nexport class DecorationSet {\n\tstatic readonly empty: DecorationSet = new DecorationSet(new Map());\n\n\tprivate constructor(private readonly byBlock: ReadonlyMap<BlockId, readonly Decoration[]>) {}\n\n\t/** Creates a DecorationSet from a flat array of decorations. */\n\tstatic create(decorations: readonly Decoration[]): DecorationSet {\n\t\tif (decorations.length === 0) return DecorationSet.empty;\n\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tfor (const deco of decorations) {\n\t\t\tconst existing = map.get(deco.blockId);\n\t\t\tif (existing) {\n\t\t\t\texisting.push(deco);\n\t\t\t} else {\n\t\t\t\tmap.set(deco.blockId, [deco]);\n\t\t\t}\n\t\t}\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Returns all decorations for a given block. */\n\tfind(blockId: BlockId): readonly Decoration[] {\n\t\treturn this.byBlock.get(blockId) ?? [];\n\t}\n\n\t/** Returns only inline decorations for a given block. */\n\tfindInline(blockId: BlockId): readonly InlineDecoration[] {\n\t\tconst decos = this.byBlock.get(blockId);\n\t\tif (!decos) return [];\n\t\treturn decos.filter((d): d is InlineDecoration => d.type === 'inline');\n\t}\n\n\t/** Returns only node decorations for a given block. */\n\tfindNode(blockId: BlockId): readonly NodeDecoration[] {\n\t\tconst decos = this.byBlock.get(blockId);\n\t\tif (!decos) return [];\n\t\treturn decos.filter((d): d is NodeDecoration => d.type === 'node');\n\t}\n\n\t/** Returns only widget decorations for a given block. */\n\tfindWidget(blockId: BlockId): readonly WidgetDecoration[] {\n\t\tconst decos = this.byBlock.get(blockId);\n\t\tif (!decos) return [];\n\t\treturn decos.filter((d): d is WidgetDecoration => d.type === 'widget');\n\t}\n\n\t/** Returns a new DecorationSet with the given decorations added. */\n\tadd(decorations: readonly Decoration[]): DecorationSet {\n\t\tif (decorations.length === 0) return this;\n\t\tif (this.isEmpty) return DecorationSet.create(decorations);\n\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tmap.set(bid, [...decos]);\n\t\t}\n\t\tfor (const deco of decorations) {\n\t\t\tconst existing = map.get(deco.blockId);\n\t\t\tif (existing) {\n\t\t\t\texisting.push(deco);\n\t\t\t} else {\n\t\t\t\tmap.set(deco.blockId, [deco]);\n\t\t\t}\n\t\t}\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Returns a new DecorationSet with decorations matching the predicate removed. */\n\tremove(predicate: (d: Decoration) => boolean): DecorationSet {\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tlet changed = false;\n\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tconst filtered = decos.filter((d) => !predicate(d));\n\t\t\tif (filtered.length !== decos.length) changed = true;\n\t\t\tif (filtered.length > 0) {\n\t\t\t\tmap.set(bid, filtered);\n\t\t\t}\n\t\t}\n\n\t\tif (!changed) return this;\n\t\tif (map.size === 0) return DecorationSet.empty;\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Returns a new DecorationSet merging this set with another. */\n\tmerge(other: DecorationSet): DecorationSet {\n\t\tif (other.isEmpty) return this;\n\t\tif (this.isEmpty) return other;\n\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tmap.set(bid, [...decos]);\n\t\t}\n\t\tfor (const [bid, decos] of other.byBlock) {\n\t\t\tconst existing = map.get(bid);\n\t\t\tif (existing) {\n\t\t\t\texisting.push(...decos);\n\t\t\t} else {\n\t\t\t\tmap.set(bid, [...decos]);\n\t\t\t}\n\t\t}\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Attaches plugin attribution to widget callbacks without mutating plugin-owned objects. */\n\twithWidgetOwner(pluginId: string): DecorationSet {\n\t\tlet changed = false;\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tfor (const [bid, decorations] of this.byBlock) {\n\t\t\tconst attributed = decorations.map((decoration): Decoration => {\n\t\t\t\tif (decoration.type !== 'widget') return decoration;\n\t\t\t\tchanged = true;\n\t\t\t\treturn {\n\t\t\t\t\t...decoration,\n\t\t\t\t\t[WIDGET_CALLBACK_OWNER]: { pluginId, name: 'widget' },\n\t\t\t\t};\n\t\t\t});\n\t\t\tmap.set(bid, attributed);\n\t\t}\n\t\treturn changed ? new DecorationSet(map) : this;\n\t}\n\n\t/** Checks equality — reference first, then structural comparison. */\n\tequals(other: DecorationSet): boolean {\n\t\tif (this === other) return true;\n\t\tif (this.byBlock.size !== other.byBlock.size) return false;\n\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tconst otherDecos = other.byBlock.get(bid);\n\t\t\tif (!otherDecos) return false;\n\t\t\tif (!decorationArraysEqual(decos, otherDecos)) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** True if the set contains no decorations. */\n\tget isEmpty(): boolean {\n\t\treturn this.byBlock.size === 0;\n\t}\n\n\t/**\n\t * Maps decorations through document changes described by a transaction.\n\t * Decorations that become invalid (e.g. fully deleted range) are removed.\n\t * Decorations that span a split point are split into two.\n\t *\n\t * Iterates over `tr.mapping.maps` (the position-space {@link StepMap}s)\n\t * rather than `tr.steps`. This means selection-only or other identity\n\t * transactions short-circuit (`tr.mapping.isEmpty`) without rebuilding\n\t * the set, and the decoration-specific shape concerns (split-into-two,\n\t * drop-on-block-removal) are the only logic that lives here.\n\t */\n\tmap(tr: Transaction): DecorationSet {\n\t\tif (this.isEmpty || tr.mapping.isEmpty) return this;\n\n\t\tlet mapped: Decoration[] = [];\n\t\tfor (const decos of this.byBlock.values()) {\n\t\t\tfor (const d of decos) {\n\t\t\t\tmapped.push(d);\n\t\t\t}\n\t\t}\n\n\t\tfor (const stepMap of tr.mapping.maps) {\n\t\t\tconst next: Decoration[] = [];\n\t\t\tfor (const deco of mapped) {\n\t\t\t\tconst result = mapDecorationThroughStepMap(deco, stepMap);\n\t\t\t\tif (result === null) continue;\n\t\t\t\tif (Array.isArray(result)) {\n\t\t\t\t\tfor (const r of result) {\n\t\t\t\t\t\tnext.push(r);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tnext.push(result as Decoration);\n\t\t\t\t}\n\t\t\t}\n\t\t\tmapped = next;\n\t\t}\n\n\t\tif (mapped.length === 0) return DecorationSet.empty;\n\t\treturn DecorationSet.create(mapped);\n\t}\n}\n\n// --- Helpers ---\n\n/** Compares two decoration arrays for structural equality. */\nexport function decorationArraysEqual(a: readonly Decoration[], b: readonly Decoration[]): boolean {\n\tif (a === b) return true;\n\tif (a.length !== b.length) return false;\n\n\tfor (let i = 0; i < a.length; i++) {\n\t\tconst ai = a[i];\n\t\tconst bi = b[i];\n\t\tif (!ai || !bi || !decorationsEqual(ai, bi)) return false;\n\t}\n\treturn true;\n}\n\n/** Compares two individual decorations for structural equality. */\nfunction decorationsEqual(a: Decoration, b: Decoration): boolean {\n\tif (a.type !== b.type) return false;\n\tif (a.blockId !== b.blockId) return false;\n\n\tswitch (a.type) {\n\t\tcase 'inline': {\n\t\t\tconst bi = b as InlineDecoration;\n\t\t\treturn a.from === bi.from && a.to === bi.to && attrsEqual(a.attrs, bi.attrs);\n\t\t}\n\t\tcase 'node': {\n\t\t\tconst bn = b as NodeDecoration;\n\t\t\treturn attrsEqual(a.attrs, bn.attrs);\n\t\t}\n\t\tcase 'widget': {\n\t\t\tconst bw = b as WidgetDecoration;\n\t\t\tconst sameIdentity: boolean =\n\t\t\t\ta.key !== undefined || bw.key !== undefined ? a.key === bw.key : a.toDOM === bw.toDOM;\n\t\t\treturn a.offset === bw.offset && a.side === bw.side && a.key === bw.key && sameIdentity;\n\t\t}\n\t}\n}\n\n/** Compares two DecorationAttrs objects. */\nfunction attrsEqual(a: DecorationAttrs, b: DecorationAttrs): boolean {\n\tif (a === b) return true;\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\tif (aKeys.length !== bKeys.length) return false;\n\tfor (const key of aKeys) {\n\t\tif (a[key] !== b[key]) return false;\n\t}\n\treturn true;\n}\n"],"mappings":"Y,6EAoNA,IAAaE,EAA4BC,OAAOC,OAAO,CAAEC,KAAM,aAUzDC,EAAN,MACCC,GAEA,WAAAC,CAAYD,GACXE,MAAKF,EAAU,IAAIG,IAAIH,GACvBJ,OAAOC,OAAOK,KACf,CAEA,QAAIE,GACH,OAAOF,MAAKF,EAAQI,IACrB,CAEA,GAAAC,CAAIC,GACH,OAAOJ,MAAKF,EAAQK,IAAIC,EACzB,CAEA,OAAAC,GACC,OAAOL,MAAKF,EAAQO,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,OAAQ,OAAO,EAC1C,IAAK,MAAM+D,KAAOuC,EACjB,GAAItE,EAAE+B,KAAS9B,EAAE8B,GAAM,OAAO,EAE/B,OAAO,CACR,Q"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{R as r}from"./Document-
|
|
2
|
-
//# sourceMappingURL=DirectionDetection-
|
|
1
|
+
import{R as r}from"./Document-ssR6hBzG.mjs";var t=/[\p{Script=Hebrew}\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}\p{Script=Nko}\p{Script=Samaritan}\p{Script=Adlam}\p{Script=Hanifi_Rohingya}\p{Script=Mende_Kikakui}\p{Script=Yezidi}\p{Script=Old_South_Arabian}\p{Script=Old_North_Arabian}\p{Script=Avestan}\p{Script=Imperial_Aramaic}\p{Script=Phoenician}\p{Script=Lydian}\u200F\u061C]/u,i=/[\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}\p{Script=Armenian}\p{Script=Devanagari}\p{Script=Bengali}\p{Script=Gurmukhi}\p{Script=Gujarati}\p{Script=Oriya}\p{Script=Tamil}\p{Script=Telugu}\p{Script=Kannada}\p{Script=Malayalam}\p{Script=Sinhala}\p{Script=Thai}\p{Script=Lao}\p{Script=Tibetan}\p{Script=Myanmar}\p{Script=Georgian}\p{Script=Hangul}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}\p{Script=Ethiopic}\p{Script=Cherokee}\p{Script=Khmer}\u200E]/u;function p(r){const p=r.search(t),a=r.search(i);return-1===p&&-1===a?null:-1===p?"ltr":-1===a||p<a?"rtl":"ltr"}function a(r){const t=r.attrs?.dir;return"ltr"===t||"rtl"===t?t:"auto"}function c(t,i,p){const a=function(t,i){if(0===i.length)return t.doc.children;const p=i[i.length-1];if(!p)return[];const a=t.getBlock(p);return a?a.children.filter(r):[]}(t,i);for(let r=p-1;r>=0;r--){const t=a[r]?.attrs?.dir;if("ltr"===t||"rtl"===t)return t}for(let r=p;r<a.length;r++){const t=a[r]?.attrs?.dir;if("ltr"===t||"rtl"===t)return t}}export{c as n,a as r,p as t};
|
|
2
|
+
//# sourceMappingURL=DirectionDetection-a-1iksmh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DirectionDetection-a-1iksmh.mjs","names":["isBlockNode","RTL_CHAR_RE","LTR_CHAR_RE","detectTextDirection","text","rtlIdx","search","ltrIdx","getBlockDir","block","dir","attrs","findSiblingDirection","state","parentPath","index","siblings","length","doc","children","parentId","parent","getBlock","filter","getSiblings","i"],"sources":["../../src/plugins/text-direction/DirectionDetection.ts"],"sourcesContent":["/**\n * Direction detection utilities for the TextDirectionPlugin.\n * Detects text direction based on the first strong directional character\n * and finds sibling block direction for inheritance.\n */\n\nimport { type BlockNode, isBlockNode } from '../../model/Document.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { TextDirection } from './TextDirectionPlugin.js';\n\n// --- RTL Detection ---\n\n/**\n * Regex matching strong RTL characters using Unicode Script property escapes.\n * Auto-maintained by the Unicode standard — no manual code-point ranges needed.\n * Covers all RTL scripts: Hebrew, Arabic, Syriac, Thaana, N'Ko, Samaritan,\n * Mandaic, Adlam, Hanifi Rohingya, Mende Kikakui, Yezidi, and historic scripts.\n * Includes U+200F (RLM) and U+061C (ALM) as strong directional markers.\n */\nconst RTL_CHAR_RE: RegExp =\n\t/[\\p{Script=Hebrew}\\p{Script=Arabic}\\p{Script=Syriac}\\p{Script=Thaana}\\p{Script=Mandaic}\\p{Script=Nko}\\p{Script=Samaritan}\\p{Script=Adlam}\\p{Script=Hanifi_Rohingya}\\p{Script=Mende_Kikakui}\\p{Script=Yezidi}\\p{Script=Old_South_Arabian}\\p{Script=Old_North_Arabian}\\p{Script=Avestan}\\p{Script=Imperial_Aramaic}\\p{Script=Phoenician}\\p{Script=Lydian}\\u200F\\u061C]/u;\n\n/**\n * Regex matching strong LTR characters using Unicode Script property escapes.\n * Covers all major LTR scripts: Latin, Greek, Cyrillic, Armenian, Indic scripts,\n * Southeast Asian scripts, East Asian scripts, Georgian, Ethiopic, and more.\n * Includes U+200E (LRM) as a strong directional marker.\n */\nconst LTR_CHAR_RE: RegExp =\n\t/[\\p{Script=Latin}\\p{Script=Greek}\\p{Script=Cyrillic}\\p{Script=Armenian}\\p{Script=Devanagari}\\p{Script=Bengali}\\p{Script=Gurmukhi}\\p{Script=Gujarati}\\p{Script=Oriya}\\p{Script=Tamil}\\p{Script=Telugu}\\p{Script=Kannada}\\p{Script=Malayalam}\\p{Script=Sinhala}\\p{Script=Thai}\\p{Script=Lao}\\p{Script=Tibetan}\\p{Script=Myanmar}\\p{Script=Georgian}\\p{Script=Hangul}\\p{Script=Hiragana}\\p{Script=Katakana}\\p{Script=Han}\\p{Script=Ethiopic}\\p{Script=Cherokee}\\p{Script=Khmer}\\u200E]/u;\n\n/**\n * Detects the dominant text direction based on the first strong directional character.\n * Returns `null` if no strong character is found (all neutral/numeric/whitespace).\n */\nexport function detectTextDirection(text: string): TextDirection | null {\n\tconst rtlIdx: number = text.search(RTL_CHAR_RE);\n\tconst ltrIdx: number = text.search(LTR_CHAR_RE);\n\n\tif (rtlIdx === -1 && ltrIdx === -1) return null;\n\tif (rtlIdx === -1) return 'ltr';\n\tif (ltrIdx === -1) return 'rtl';\n\treturn rtlIdx < ltrIdx ? 'rtl' : 'ltr';\n}\n\n// --- Block Direction Accessor ---\n\n/** Returns the current `dir` attribute of a block, defaulting to `'auto'`. */\nexport function getBlockDir(block: BlockNode): TextDirection {\n\tconst dir: unknown = block.attrs?.dir;\n\tif (dir === 'ltr' || dir === 'rtl') return dir;\n\treturn 'auto';\n}\n\n// --- Sibling Direction Lookup ---\n\n/**\n * Finds the `dir` attribute of the nearest sibling with an explicit direction\n * (not `'auto'`) before the insert position, walking backwards.\n */\nexport function findSiblingDirection(\n\tstate: EditorState,\n\tparentPath: readonly BlockId[],\n\tindex: number,\n): TextDirection | undefined {\n\tconst siblings: readonly BlockNode[] = getSiblings(state, parentPath);\n\n\t// Walk backward first (preceding siblings take priority)\n\tfor (let i: number = index - 1; i >= 0; i--) {\n\t\tconst dir: unknown = siblings[i]?.attrs?.dir;\n\t\tif (dir === 'ltr' || dir === 'rtl') return dir;\n\t}\n\n\t// Walk forward when no backward sibling has explicit direction\n\tfor (let i: number = index; i < siblings.length; i++) {\n\t\tconst dir: unknown = siblings[i]?.attrs?.dir;\n\t\tif (dir === 'ltr' || dir === 'rtl') return dir;\n\t}\n\n\treturn undefined;\n}\n\n/** Returns the sibling list for the given parent path. */\nfunction getSiblings(state: EditorState, parentPath: readonly BlockId[]): readonly BlockNode[] {\n\tif (parentPath.length === 0) {\n\t\treturn state.doc.children;\n\t}\n\n\tconst parentId: BlockId | undefined = parentPath[parentPath.length - 1];\n\tif (!parentId) return [];\n\tconst parent: BlockNode | undefined = state.getBlock(parentId);\n\tif (!parent) return [];\n\n\treturn parent.children.filter(isBlockNode);\n}\n"],"mappings":"Y,gCAoBA,IAAMC,EACL,wWAQKC,EACL,udAMD,SAAgBC,EAAoBC,GACnC,MAAMC,EAAiBD,EAAKE,OAAOL,GAC7BM,EAAiBH,EAAKE,OAAOJ,GAEnC,OAAe,IAAXG,IAA4B,IAAXE,EAAsB,MAC5B,IAAXF,EAAsB,OACX,IAAXE,GACGF,EAASE,EADU,MACO,KAClC,CAKA,SAAgBC,EAAYC,GAC3B,MAAMC,EAAeD,EAAME,OAAOD,IAClC,MAAY,QAARA,GAAyB,QAARA,EAAsBA,EACpC,MACR,CAQA,SAAgBE,EACfC,EACAC,EACAC,GAEA,MAAMC,EAkBP,SAAqBH,EAAoBC,GACxC,GAA0B,IAAtBA,EAAWG,OACd,OAAOJ,EAAMK,IAAIC,SAGlB,MAAMC,EAAgCN,EAAWA,EAAWG,OAAS,GACrE,IAAKG,EAAU,MAAO,GACtB,MAAMC,EAAgCR,EAAMS,SAASF,GACrD,OAAKC,EAEEA,EAAOF,SAASI,OAAOvB,GAFV,EAGrB,CA7BwCwB,CAAYX,EAAOC,GAG1D,IAAK,IAAIW,EAAYV,EAAQ,EAAGU,GAAK,EAAGA,IAAK,CAC5C,MAAMf,EAAeM,EAASS,IAAId,OAAOD,IACzC,GAAY,QAARA,GAAyB,QAARA,EAAe,OAAOA,CAC5C,CAGA,IAAK,IAAIe,EAAYV,EAAOU,EAAIT,EAASC,OAAQQ,IAAK,CACrD,MAAMf,EAAeM,EAASS,IAAId,OAAOD,IACzC,GAAY,QAARA,GAAyB,QAARA,EAAe,OAAOA,CAC5C,CAGD,Q"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectionIcons-Bbawl9ei.mjs","names":[],"sources":["../../src/plugins/text-direction/DirectionIcons.ts"],"sourcesContent":["/**\n * Direction icon SVGs shared between `TextDirectionPlugin` (block-level\n * dropdown) and `BidiIsolationPlugin` (inline dropdown items).\n */\n\nimport type { TextDirection } from './TextDirectionService.js';\n\nexport const DIRECTION_ICONS: Readonly<Record<TextDirection, string>> = {\n\tltr: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M9 10v5h2V4h2v11h2V4h2V2H9C6.79 2 5 3.79 5 6s1.79 4 4 4zm12 8l-4-4v3H5v2h12v3l4-4z\"/></svg>',\n\trtl: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M10 10v5h2V4h2v11h2V4h2V2h-8C7.79 2 6 3.79 6 6s1.79 4 4 4zM8 14l-4 4 4 4v-3h12v-2H8v-3z\"/></svg>',\n\tauto: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M9 10v5h2V4h2v11h2V4h2V2H9C6.79 2 5 3.79 5 6s1.79 4 4 4zm3 8l-4-4v3H3v2h5v3l4-4zm7 0v-3l4 4-4 4v-3h-5v-2h5z\"/></svg>',\n};\n"],"mappings":"AAOA,
|
|
1
|
+
{"version":3,"file":"DirectionIcons-Bbawl9ei.mjs","names":["DIRECTION_ICONS","ltr","rtl","auto"],"sources":["../../src/plugins/text-direction/DirectionIcons.ts"],"sourcesContent":["/**\n * Direction icon SVGs shared between `TextDirectionPlugin` (block-level\n * dropdown) and `BidiIsolationPlugin` (inline dropdown items).\n */\n\nimport type { TextDirection } from './TextDirectionService.js';\n\nexport const DIRECTION_ICONS: Readonly<Record<TextDirection, string>> = {\n\tltr: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M9 10v5h2V4h2v11h2V4h2V2H9C6.79 2 5 3.79 5 6s1.79 4 4 4zm12 8l-4-4v3H5v2h12v3l4-4z\"/></svg>',\n\trtl: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M10 10v5h2V4h2v11h2V4h2V2h-8C7.79 2 6 3.79 6 6s1.79 4 4 4zM8 14l-4 4 4 4v-3h12v-2H8v-3z\"/></svg>',\n\tauto: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M9 10v5h2V4h2v11h2V4h2V2H9C6.79 2 5 3.79 5 6s1.79 4 4 4zm3 8l-4-4v3H3v2h5v3l4-4zm7 0v-3l4 4-4 4v-3h-5v-2h5z\"/></svg>',\n};\n"],"mappings":"AAOA,IAAaA,EAA2D,CACvEC,IAAK,mKACLC,IAAK,wKACLC,KAAM,oM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=Document-
|
|
1
|
+
import{c as t}from"./HTMLUtils-DTpsjZyK.mjs";function e(t,e=[]){return{kind:"text",text:t,marks:e}}function n(t){return{kind:"inline",node:t}}function r(t,e,n){const r=[];return s(t,e,n,{onText(t,e){r.push({kind:"text",text:t,marks:e})},onInline(t){r.push({kind:"inline",node:t})}}),r}function s(t,e,n,r){for(const{child:s,from:o,to:c}of rt(u(t)))if(!(c<=e||o>=n))if(i(s))r.onInline?.(s);else{const t=Math.max(0,e-o),i=Math.min(s.text.length,n-o),c=s.text.slice(t,i);c.length>0&&r.onText(c,s.marks)}}function o(t){return"object"==typeof t&&null!==t&&"text"===t.type&&"string"==typeof t.text}function i(t){return"object"==typeof t&&null!==t&&"inline"===t.type&&"string"==typeof t.inlineType}function c(t){return"object"==typeof t&&null!==t&&"string"==typeof t.id&&"string"==typeof t.type&&"text"!==t.type&&"inline"!==t.type&&Array.isArray(t.children)}function f(t){return t.children.every(t=>o(t)||i(t))}function a(t){return t.children.filter(t=>o(t))}function u(t){return t.children.filter(t=>o(t)||i(t))}function l(t){return t.children.filter(t=>c(t))}function h(){return`block-${crypto.randomUUID()}`}function d(t){return{children:t?[...t]:[y("paragraph")]}}function y(e,n,r,s,o){const i=t(o);return{id:r??h(),...i?{htmlId:i}:{},type:e,...s?{attrs:H(s)}:{},children:n?[...n]:[k("")]}}function k(t,e){return{type:"text",text:t,marks:S(e??[])}}function m(t,e,n){return{type:"inline",inlineType:t,attrs:e?{...e}:{},marks:S(n??[])}}function p(t){return y("paragraph",[k("")],t)}var b=/* @__PURE__ */new WeakSet,j=/* @__PURE__ */new WeakSet,g=/* @__PURE__ */new WeakSet,O=/* @__PURE__ */new WeakSet,x=/* @__PURE__ */new WeakSet,z=/* @__PURE__ */new WeakSet,A=/* @__PURE__ */new WeakSet,F=/* @__PURE__ */new WeakSet;function v(t){return{...t,children:t.children.map(w)}}function w(t){const e=t.attrs?H(t.attrs):void 0;return{...t,...e?{attrs:e}:{},children:t.children.map(D)}}function S(t){return t.map(W)}function W(t){return{...t,...t.attrs?{attrs:{...t.attrs}}:{}}}function T(t){return{...t,attrs:{...t.attrs},marks:S(t.marks)}}function I(t){return"text"===t.kind?{...t,marks:S(t.marks)}:{...t,node:T(t.node)}}function M(t){return t.map(I)}function U(t){if(b.has(t))return t;for(const e of t.children)L(e);return Object.isFrozen(t.children)||Object.freeze(t.children),Object.isFrozen(t)||Object.freeze(t),b.add(t),t}function D(t){if(o(t)){const e=Array.isArray(t.marks)?S(t.marks):void 0;return{...t,...e?{marks:e}:{}}}return i(t)?T(t):w(t)}function H(t){const e={};for(const[n,r]of Object.entries(t))e[n]=Array.isArray(r)?[...r]:r;return e}function L(t){if(!j.has(t)){t.attrs&&q(t.attrs);for(const e of t.children)o(e)||i(e)?J(e):L(e);Object.isFrozen(t.children)||Object.freeze(t.children),Object.isFrozen(t)||Object.freeze(t),j.add(t)}}function q(t){if(!g.has(t)){for(const e of Object.values(t))Array.isArray(e)&&!Object.isFrozen(e)&&Object.freeze(e);Object.isFrozen(t)||Object.freeze(t),g.add(t)}}function B(t){O.has(t)||(t.attrs&&!Object.isFrozen(t.attrs)&&Object.freeze(t.attrs),Object.isFrozen(t)||Object.freeze(t),O.add(t))}function C(t){if(!x.has(t)){for(const e of t)B(e);Object.isFrozen(t)||Object.freeze(t),x.add(t)}}function E(t){z.has(t)||(Object.isFrozen(t.attrs)||Object.freeze(t.attrs),C(t.marks),Object.isFrozen(t)||Object.freeze(t),z.add(t))}function G(t){if(!F.has(t)){for(const e of t)"text"===e.kind?C(e.marks):E(e.node),Object.isFrozen(e)||Object.freeze(e);Object.isFrozen(t)||Object.freeze(t),F.add(t)}}function J(t){i(t)?E(t):A.has(t)||(C(t.marks),Object.isFrozen(t)||Object.freeze(t),A.add(t))}function K(t){const e=u(t);let n="";for(const r of e)o(r)&&(n+=r.text);return n}function N(t){let e=0;for(const{to:n}of rt(u(t)))e=n;return e}function P(t,e){const n=u(t);for(const{child:r,from:s,to:o}of rt(n))if(i(r)){if(e===s)return[]}else{if(e>=s&&e<o)return r.marks;if(e===s&&0===r.text.length)return r.marks}for(let r=n.length-1;r>=0;r--){const t=n[r];if(t&&o(t))return t.marks}return[]}function R(t,e,n){const r=P(t,e);if(0===r.length)return r;const s=function(t,e){for(const{child:n,from:r,to:s}of rt(u(t)))if(i(n)){if(e===r)return[]}else if(e>=r&&e<s)return n.marks;return[]}(t,e);return r.filter(t=>n(t.type)||s.some(e=>V(e,t)))}function V(t,e){if(t.type!==e.type)return!1;const n=t.attrs,r=e.attrs;if(!n&&!r)return!0;if(!n||!r)return!1;const s=Object.keys(n),o=Object.keys(r);return s.length===o.length&&s.every(t=>n[t]===r[t])}function $(t,e){return t===e||void 0!==t&&void 0!==e&&null!==t&&null!==e&&!(!Array.isArray(t)&&!Array.isArray(e))&&!(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length)&&t.every((t,n)=>t===e[n])}function _(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(n=>$(t[n],e[n]))}function Q(t,e){return t.length===e.length&&t.every(t=>e.some(e=>V(t,e)))}function X(t,e){return t.some(t=>t.type===e)}function Y(t,e){return X(t,e.type)?t:[...t,e]}function Z(t,e){return t.filter(t=>t.type!==e)}function tt(t){if(0===t.length)return[k("")];if(t.every(t=>o(t)))return function(t){if(0===t.length)return[k("")];const e=[];for(const n of t){const t=e[e.length-1];t&&Q(t.marks,n.marks)?e[e.length-1]=k(t.text+n.text,t.marks):(n.text.length>0||0===e.length)&&e.push(n)}return 0===e.length?[k("")]:e}(t);const e=[];for(const r of t){if(i(r)){e.push(r);continue}const t=e[e.length-1];t&&o(t)&&Q(t.marks,r.marks)?e[e.length-1]=k(t.text+r.text,t.marks):(r.text.length>0||0===e.length)&&e.push(r)}const n=e.filter((t,n)=>{if(i(t))return!0;if(t.text.length>0)return!0;if(1===e.length)return!0;const r=e[n-1],s=e[n+1];return!(r&&i(r)||s&&i(s))});return 0===n.length?[k("")]:n.some(t=>o(t))?n:[k(""),...n]}function et(t){return"inline"===t.kind?t.node:k(t.text,t.marks)}function nt(t){return tt(t.map(et))}function*rt(t){let e=0;for(const n of t){const t=i(n)?1:n.text.length;yield{child:n,from:e,to:e+t},e+=t}}function st(t,e){let n=0;for(const{child:r,from:s,to:o}of rt(u(t)))if(i(r)){if(s>=e)return n}else{if(o>=e)return n+(e-s);n+=r.text.length}return n}function ot(t,e){const n=u(t);for(const{child:r,from:s}of rt(n)){if(i(r)){if(e===s)return{kind:"inline",node:r};continue}const t=e-s;if(t>=0&&t<r.text.length)return{kind:"text",char:r.text[t]??"",marks:r.marks}}return null}export{P as A,f as B,E as C,l as D,h as E,a as F,Z as G,Q as H,X as I,rt as J,nt as K,n as L,ot as M,R as N,r as O,u as P,c as R,U as S,C as T,V as U,o as V,tt as W,k as _,H as a,L as b,v as c,S as d,et as f,m as g,p as h,st as i,K as j,N as k,T as l,d as m,$ as n,w as o,y as p,e as q,_ as r,M as s,Y as t,W as u,s as v,B as w,G as x,q as y,i as z};
|
|
2
|
+
//# sourceMappingURL=Document-ssR6hBzG.mjs.map
|