@notectl/core 2.2.5 → 2.3.1
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/dist/chunks/{AlignmentPlugin-BCHxo16v.mjs → AlignmentPlugin--xAFlRqE.mjs} +2 -2
- package/dist/chunks/{AlignmentPlugin-BCHxo16v.mjs.map → AlignmentPlugin--xAFlRqE.mjs.map} +1 -1
- package/dist/chunks/{AttrRegistry-DcDVyzLm.mjs → AttrRegistry-B3zB02z9.mjs} +2 -2
- package/dist/chunks/AttrRegistry-B3zB02z9.mjs.map +1 -0
- package/dist/chunks/{AttributedMarkCommands-D4W2Jgpj.mjs → AttributedMarkCommands-bagbH8Qt.mjs} +2 -2
- package/dist/chunks/{AttributedMarkCommands-D4W2Jgpj.mjs.map → AttributedMarkCommands-bagbH8Qt.mjs.map} +1 -1
- package/dist/chunks/{BidiIsolationPlugin-BddRbDCN.mjs → BidiIsolationPlugin-DBXyXpgm.mjs} +2 -2
- package/dist/chunks/{BidiIsolationPlugin-BddRbDCN.mjs.map → BidiIsolationPlugin-DBXyXpgm.mjs.map} +1 -1
- package/dist/chunks/BlockInsertion-CJusvrDL.mjs +2 -0
- package/dist/chunks/BlockInsertion-CJusvrDL.mjs.map +1 -0
- package/dist/chunks/BlockquotePlugin-Bz2glHwX.mjs +2 -0
- package/dist/chunks/{BlockquotePlugin-4V7KV_Sb.mjs.map → BlockquotePlugin-Bz2glHwX.mjs.map} +1 -1
- package/dist/chunks/{CaretNavigationPlugin-C6XBwp0N.mjs → CaretNavigationPlugin-CNsT0eb4.mjs} +2 -2
- package/dist/chunks/{CaretNavigationPlugin-C6XBwp0N.mjs.map → CaretNavigationPlugin-CNsT0eb4.mjs.map} +1 -1
- package/dist/chunks/CodeBlockPlugin-C1hrdbSZ.mjs +2 -0
- package/dist/chunks/CodeBlockPlugin-C1hrdbSZ.mjs.map +1 -0
- package/dist/chunks/{ColorGrid-CXRdpP_n.mjs → ColorGrid-C9RQoEWF.mjs} +2 -2
- package/dist/chunks/{ColorGrid-CXRdpP_n.mjs.map → ColorGrid-C9RQoEWF.mjs.map} +1 -1
- package/dist/chunks/ColorPickerPopup-DiA68Pzz.mjs +2 -0
- package/dist/chunks/{ColorPickerPopup-C_74bqid.mjs.map → ColorPickerPopup-DiA68Pzz.mjs.map} +1 -1
- package/dist/chunks/Commands-1dFFldi7.mjs +2 -0
- package/dist/chunks/Commands-1dFFldi7.mjs.map +1 -0
- package/dist/chunks/ContentModel-NpAj7vGW.mjs +2 -0
- package/dist/chunks/ContentModel-NpAj7vGW.mjs.map +1 -0
- package/dist/chunks/Decoration-BpoEOANl.mjs +2 -0
- package/dist/chunks/Decoration-BpoEOANl.mjs.map +1 -0
- package/dist/chunks/{DirectionDetection-C7XE0nxW.mjs → DirectionDetection-CDVSEWQ6.mjs} +2 -2
- package/dist/chunks/{DirectionDetection-C7XE0nxW.mjs.map → DirectionDetection-CDVSEWQ6.mjs.map} +1 -1
- package/dist/chunks/Document-827l3P80.mjs +2 -0
- package/dist/chunks/Document-827l3P80.mjs.map +1 -0
- package/dist/chunks/DocumentParser-D2tr3ZKn.mjs +2 -0
- package/dist/chunks/DocumentParser-D2tr3ZKn.mjs.map +1 -0
- package/dist/chunks/EditorEventBoundary-zpYRxryo.mjs +2 -0
- package/dist/chunks/EditorEventBoundary-zpYRxryo.mjs.map +1 -0
- package/dist/chunks/FontPlugin-By-TGrQo.mjs +2 -0
- package/dist/chunks/{FontPlugin-DB1_bgam.mjs.map → FontPlugin-By-TGrQo.mjs.map} +1 -1
- package/dist/chunks/{FontSizePlugin-DFvp7Ki9.mjs → FontSizePlugin-Dln-tYXV.mjs} +2 -2
- package/dist/chunks/FontSizePlugin-Dln-tYXV.mjs.map +1 -0
- package/dist/chunks/FormulaPlugin-By1befrR.mjs +2 -0
- package/dist/chunks/FormulaPlugin-By1befrR.mjs.map +1 -0
- package/dist/chunks/GapCursorNavigation-BuXngVu-.mjs +2 -0
- package/dist/chunks/{GapCursorNavigation-ycNzuQVH.mjs.map → GapCursorNavigation-BuXngVu-.mjs.map} +1 -1
- package/dist/chunks/{GapCursorPlugin-Zvxjnr82.mjs → GapCursorPlugin-DAxVzXRs.mjs} +2 -2
- package/dist/chunks/{GapCursorPlugin-Zvxjnr82.mjs.map → GapCursorPlugin-DAxVzXRs.mjs.map} +1 -1
- package/dist/chunks/HTMLUtils-Bhg3_P8B.mjs +2 -0
- package/dist/chunks/HTMLUtils-Bhg3_P8B.mjs.map +1 -0
- package/dist/chunks/{HardBreakPlugin-9DOyCyyM.mjs → HardBreakPlugin-DlbSlrdq.mjs} +2 -2
- package/dist/chunks/{HardBreakPlugin-9DOyCyyM.mjs.map → HardBreakPlugin-DlbSlrdq.mjs.map} +1 -1
- package/dist/chunks/HeadingPlugin-uMAjPOk5.mjs +2 -0
- package/dist/chunks/{HeadingPlugin-D9yvG2Aw.mjs.map → HeadingPlugin-uMAjPOk5.mjs.map} +1 -1
- package/dist/chunks/{HighlightPlugin-D4gh4RP7.mjs → HighlightPlugin-Bj7FPkIQ.mjs} +2 -2
- package/dist/chunks/{HighlightPlugin-D4gh4RP7.mjs.map → HighlightPlugin-Bj7FPkIQ.mjs.map} +1 -1
- package/dist/chunks/HorizontalRulePlugin-DUVmTQpX.mjs +2 -0
- package/dist/chunks/HorizontalRulePlugin-DUVmTQpX.mjs.map +1 -0
- package/dist/chunks/ImagePlugin-FToCOjd5.mjs +2 -0
- package/dist/chunks/{ImagePlugin-Cp_RINtc.mjs.map → ImagePlugin-FToCOjd5.mjs.map} +1 -1
- package/dist/chunks/{InlineCodePlugin-DMr4O7c7.mjs → InlineCodePlugin-pISIoGQE.mjs} +2 -2
- package/dist/chunks/InlineCodePlugin-pISIoGQE.mjs.map +1 -0
- package/dist/chunks/InlineStyleMarkSpec-CjSRj4f_.mjs +2 -0
- package/dist/chunks/{InlineStyleMarkSpec-4R6DC7ij.mjs.map → InlineStyleMarkSpec-CjSRj4f_.mjs.map} +1 -1
- package/dist/chunks/LinkPlugin-Ct5Z180S.mjs +2 -0
- package/dist/chunks/LinkPlugin-Ct5Z180S.mjs.map +1 -0
- package/dist/chunks/ListPlugin-DAY5ezNs.mjs +2 -0
- package/dist/chunks/ListPlugin-DAY5ezNs.mjs.map +1 -0
- package/dist/chunks/MarkInputRule-Bdi8KPus.mjs +2 -0
- package/dist/chunks/MarkInputRule-Bdi8KPus.mjs.map +1 -0
- package/dist/chunks/MarkdownHTMLRegistry-CKEx7LkR.mjs +2 -0
- package/dist/chunks/MarkdownHTMLRegistry-CKEx7LkR.mjs.map +1 -0
- package/dist/chunks/MarkdownParser-CWt3M6jR.mjs +2 -0
- package/dist/chunks/MarkdownParser-CWt3M6jR.mjs.map +1 -0
- package/dist/chunks/MarkdownSerializer-J-i28out.mjs +2 -0
- package/dist/chunks/MarkdownSerializer-J-i28out.mjs.map +1 -0
- package/dist/chunks/{NodeResolver-ChgLF_IP.mjs → NodeResolver-Dleih-8R.mjs} +2 -2
- package/dist/chunks/{NodeResolver-ChgLF_IP.mjs.map → NodeResolver-Dleih-8R.mjs.map} +1 -1
- package/dist/chunks/NodeSelectionCommands-1PjwUDTJ.mjs +2 -0
- package/dist/chunks/{NodeSelectionCommands-Dj4VxLdD.mjs.map → NodeSelectionCommands-1PjwUDTJ.mjs.map} +1 -1
- package/dist/chunks/PluginHelpers-Dx_0hfDe.mjs +2 -0
- package/dist/chunks/{PluginHelpers-KDuTlmXm.mjs.map → PluginHelpers-Dx_0hfDe.mjs.map} +1 -1
- package/dist/chunks/{PopupManager-CyOfZUab.mjs → PopupManager-CT-fMZJn.mjs} +2 -2
- package/dist/chunks/{PopupManager-CyOfZUab.mjs.map → PopupManager-CT-fMZJn.mjs.map} +1 -1
- package/dist/chunks/PopupPositioning-BFh6Ed1D.mjs +2 -0
- package/dist/chunks/{PopupPositioning-DtUrY9bh.mjs.map → PopupPositioning-BFh6Ed1D.mjs.map} +1 -1
- package/dist/chunks/PrintPlugin-7zz9mhhU.mjs +2 -0
- package/dist/chunks/PrintPlugin-7zz9mhhU.mjs.map +1 -0
- package/dist/chunks/{PrintTypes-WdtgSj74.mjs → PrintTypes-CxU69qu3.mjs} +3 -2
- package/dist/chunks/PrintTypes-CxU69qu3.mjs.map +1 -0
- package/dist/chunks/{RangeIterator-o8v3msQe.mjs → RangeIterator-DP7Ud3Gp.mjs} +2 -2
- package/dist/chunks/{RangeIterator-o8v3msQe.mjs.map → RangeIterator-DP7Ud3Gp.mjs.map} +1 -1
- package/dist/chunks/SchemaRegistry-CkBN-1yW.mjs +2 -0
- package/dist/chunks/SchemaRegistry-CkBN-1yW.mjs.map +1 -0
- package/dist/chunks/{SimpleMark-CaQtFAau.mjs → SimpleMark-7CQcA4RK.mjs} +2 -2
- package/dist/chunks/{SimpleMark-CaQtFAau.mjs.map → SimpleMark-7CQcA4RK.mjs.map} +1 -1
- package/dist/chunks/{SmartPastePlugin-Bi_wpTCV.mjs → SmartPastePlugin-CYa_nD9v.mjs} +2 -2
- package/dist/chunks/{SmartPastePlugin-Bi_wpTCV.mjs.map → SmartPastePlugin-CYa_nD9v.mjs.map} +1 -1
- package/dist/chunks/StrikethroughPlugin-C2oWvGc3.mjs +2 -0
- package/dist/chunks/StrikethroughPlugin-C2oWvGc3.mjs.map +1 -0
- package/dist/chunks/StyleRuntime-DW6omotc.mjs +2 -0
- package/dist/chunks/StyleRuntime-DW6omotc.mjs.map +1 -0
- package/dist/chunks/{SuperSubPlugin-DVP7VnIz.mjs → SuperSubPlugin-D1xaKrSu.mjs} +2 -2
- package/dist/chunks/{SuperSubPlugin-DVP7VnIz.mjs.map → SuperSubPlugin-D1xaKrSu.mjs.map} +1 -1
- package/dist/chunks/TableDimensions-BBhjHNjQ.mjs +2 -0
- package/dist/chunks/TableDimensions-BBhjHNjQ.mjs.map +1 -0
- package/dist/chunks/TablePlugin-PJe3zwr-.mjs +2 -0
- package/dist/chunks/TablePlugin-PJe3zwr-.mjs.map +1 -0
- package/dist/chunks/TextColorPlugin-CTd9tfeG.mjs +2 -0
- package/dist/chunks/{TextColorPlugin-C1qpzEOa.mjs.map → TextColorPlugin-CTd9tfeG.mjs.map} +1 -1
- package/dist/chunks/TextDirectionAutoPlugin-CPnKVVuI.mjs +2 -0
- package/dist/chunks/{TextDirectionAutoPlugin-CzWJjrvG.mjs.map → TextDirectionAutoPlugin-CPnKVVuI.mjs.map} +1 -1
- package/dist/chunks/{TextDirectionPlugin-DHB88HKf.mjs → TextDirectionPlugin-Bns_03vL.mjs} +2 -2
- package/dist/chunks/{TextDirectionPlugin-DHB88HKf.mjs.map → TextDirectionPlugin-Bns_03vL.mjs.map} +1 -1
- package/dist/chunks/TextDirectionService-BcX07mw2.mjs +2 -0
- package/dist/chunks/{TextDirectionService-OFOU6r_s.mjs.map → TextDirectionService-BcX07mw2.mjs.map} +1 -1
- package/dist/chunks/TextFormattingPlugin-DBVlePqj.mjs +2 -0
- package/dist/chunks/TextFormattingPlugin-DBVlePqj.mjs.map +1 -0
- package/dist/chunks/{ToolbarPlugin-CLz2wa2c.mjs → ToolbarPlugin-DtfGTO_V.mjs} +2 -2
- package/dist/chunks/{ToolbarPlugin-CLz2wa2c.mjs.map → ToolbarPlugin-DtfGTO_V.mjs.map} +1 -1
- package/dist/chunks/VideoPlugin-BrR8g6Rz.mjs +2 -0
- package/dist/chunks/VideoPlugin-BrR8g6Rz.mjs.map +1 -0
- package/dist/chunks/WordBoundary-CFpIJDNP.mjs +2 -0
- package/dist/chunks/{WordBoundary-DxeMBRyP.mjs.map → WordBoundary-CFpIJDNP.mjs.map} +1 -1
- package/dist/chunks/ar-Dg9PdDet.mjs +2 -0
- package/dist/chunks/ar-Dg9PdDet.mjs.map +1 -0
- package/dist/chunks/ar-eOA3UmiE.mjs +2 -0
- package/dist/chunks/{ar-BTShmP2E.mjs.map → ar-eOA3UmiE.mjs.map} +1 -1
- package/dist/chunks/de-DJ5EkXQo.mjs +2 -0
- package/dist/chunks/de-DJ5EkXQo.mjs.map +1 -0
- package/dist/chunks/{de-C--bRmjW.mjs → de-DRbhnS4T.mjs} +2 -2
- package/dist/chunks/{de-C--bRmjW.mjs.map → de-DRbhnS4T.mjs.map} +1 -1
- package/dist/chunks/{es-DFUVd7eO.mjs → es-BQ9dox_E.mjs} +2 -2
- package/dist/chunks/{es-DFUVd7eO.mjs.map → es-BQ9dox_E.mjs.map} +1 -1
- package/dist/chunks/es-CEAJj7aB.mjs +2 -0
- package/dist/chunks/es-CEAJj7aB.mjs.map +1 -0
- package/dist/chunks/fr-DhWQzZy3.mjs +2 -0
- package/dist/chunks/fr-DhWQzZy3.mjs.map +1 -0
- package/dist/chunks/{fr-BaXKyPmX.mjs → fr-NVOinLyF.mjs} +2 -2
- package/dist/chunks/{fr-BaXKyPmX.mjs.map → fr-NVOinLyF.mjs.map} +1 -1
- package/dist/chunks/full-DSWM4cKQ.mjs +2 -0
- package/dist/chunks/{full-Cah3qjCT.mjs.map → full-DSWM4cKQ.mjs.map} +1 -1
- package/dist/chunks/hi-BsZzSMfL.mjs +2 -0
- package/dist/chunks/hi-BsZzSMfL.mjs.map +1 -0
- package/dist/chunks/{hi-aH9HZG23.mjs → hi-DrC2H81d.mjs} +2 -2
- package/dist/chunks/{hi-aH9HZG23.mjs.map → hi-DrC2H81d.mjs.map} +1 -1
- package/dist/chunks/minimal-CFkkPXef.mjs +2 -0
- package/dist/chunks/{minimal-DqATlnAL.mjs.map → minimal-CFkkPXef.mjs.map} +1 -1
- package/dist/chunks/pt-BuZ7acHF.mjs +2 -0
- package/dist/chunks/pt-BuZ7acHF.mjs.map +1 -0
- package/dist/chunks/{pt-Hy-0Xnnc.mjs → pt-CFrcl1v_.mjs} +2 -2
- package/dist/chunks/{pt-Hy-0Xnnc.mjs.map → pt-CFrcl1v_.mjs.map} +1 -1
- package/dist/chunks/rolldown-runtime-H_PjY6_i.mjs +1 -0
- package/dist/chunks/ru-CsP6mLxp.mjs +2 -0
- package/dist/chunks/ru-CsP6mLxp.mjs.map +1 -0
- package/dist/chunks/{ru-BFpEOrVp.mjs → ru-gxbzqLL8.mjs} +2 -2
- package/dist/chunks/{ru-BFpEOrVp.mjs.map → ru-gxbzqLL8.mjs.map} +1 -1
- package/dist/chunks/src-DiAOfuOT.mjs +2 -0
- package/dist/chunks/src-DiAOfuOT.mjs.map +1 -0
- package/dist/chunks/zh-BFZOM3lF.mjs +2 -0
- package/dist/chunks/{zh-BjoyjClN.mjs.map → zh-BFZOM3lF.mjs.map} +1 -1
- package/dist/chunks/zh-CiIyOm6U.mjs +2 -0
- package/dist/chunks/zh-CiIyOm6U.mjs.map +1 -0
- package/dist/commands/BlockInsertion.d.ts +5 -3
- package/dist/commands/BlockInsertion.d.ts.map +1 -1
- package/dist/commands/SelectionDeletion.d.ts +13 -2
- package/dist/commands/SelectionDeletion.d.ts.map +1 -1
- package/dist/editor/ContentSerializer.d.ts +21 -0
- package/dist/editor/ContentSerializer.d.ts.map +1 -1
- package/dist/editor/EditorConfig.d.ts +17 -0
- package/dist/editor/EditorConfig.d.ts.map +1 -1
- package/dist/editor/EditorConfigController.d.ts +10 -0
- package/dist/editor/EditorConfigController.d.ts.map +1 -1
- package/dist/editor/EditorInitializer.d.ts +4 -0
- package/dist/editor/EditorInitializer.d.ts.map +1 -1
- package/dist/editor/EditorLocale.d.ts +2 -0
- package/dist/editor/EditorLocale.d.ts.map +1 -1
- package/dist/editor/MarkdownMode.d.ts +46 -0
- package/dist/editor/MarkdownMode.d.ts.map +1 -0
- package/dist/editor/NotectlEditor.d.ts +46 -3
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/locales/ar.d.ts.map +1 -1
- package/dist/editor/locales/de.d.ts.map +1 -1
- package/dist/editor/locales/es.d.ts.map +1 -1
- package/dist/editor/locales/fr.d.ts.map +1 -1
- package/dist/editor/locales/hi.d.ts.map +1 -1
- package/dist/editor/locales/pt.d.ts.map +1 -1
- package/dist/editor/locales/ru.d.ts.map +1 -1
- package/dist/editor/locales/zh.d.ts.map +1 -1
- package/dist/editor/styles/list.d.ts +1 -1
- package/dist/editor/styles/list.d.ts.map +1 -1
- package/dist/editor/styles/table.d.ts +1 -1
- package/dist/editor/styles/table.d.ts.map +1 -1
- package/dist/full.mjs +1 -1
- package/dist/html.d.ts +1 -0
- package/dist/html.d.ts.map +1 -1
- package/dist/html.mjs +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts +2 -0
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/InputHandler.d.ts +7 -0
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/InputManager.d.ts +10 -0
- package/dist/input/InputManager.d.ts.map +1 -1
- package/dist/input/KeyboardHandler.d.ts.map +1 -1
- package/dist/input/MarkdownPasteDetector.d.ts +26 -0
- package/dist/input/MarkdownPasteDetector.d.ts.map +1 -0
- package/dist/input/PasteHTMLHandler.d.ts +18 -1
- package/dist/input/PasteHTMLHandler.d.ts.map +1 -1
- package/dist/input/PasteHandler.d.ts +30 -0
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/input/PasteRichBlockHandler.d.ts.map +1 -1
- package/dist/input/SelectionDocument.d.ts +2 -1
- package/dist/input/SelectionDocument.d.ts.map +1 -1
- package/dist/markdown.d.ts +17 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.mjs +1 -0
- package/dist/model/AttrRegistry.d.ts +2 -2
- package/dist/model/AttrRegistry.d.ts.map +1 -1
- package/dist/model/ContentModel.d.ts +12 -0
- package/dist/model/ContentModel.d.ts.map +1 -1
- package/dist/model/Document.d.ts +28 -3
- package/dist/model/Document.d.ts.map +1 -1
- package/dist/model/HTMLUtils.d.ts +15 -0
- package/dist/model/HTMLUtils.d.ts.map +1 -1
- package/dist/model/InlineNodeSpec.d.ts +7 -1
- package/dist/model/InlineNodeSpec.d.ts.map +1 -1
- package/dist/model/InputRule.d.ts +11 -0
- package/dist/model/InputRule.d.ts.map +1 -1
- package/dist/model/MarkSpec.d.ts +7 -1
- package/dist/model/MarkSpec.d.ts.map +1 -1
- package/dist/model/MarkdownSyntaxRegistry.d.ts +51 -0
- package/dist/model/MarkdownSyntaxRegistry.d.ts.map +1 -0
- package/dist/model/NodeSpec.d.ts +47 -1
- package/dist/model/NodeSpec.d.ts.map +1 -1
- package/dist/model/RichBlockData.d.ts +2 -0
- package/dist/model/RichBlockData.d.ts.map +1 -1
- package/dist/model/SchemaRegistry.d.ts.map +1 -1
- package/dist/model/TableDimensions.d.ts +11 -0
- package/dist/model/TableDimensions.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/platform/EditorEventBoundary.d.ts +12 -0
- package/dist/platform/EditorEventBoundary.d.ts.map +1 -0
- package/dist/plugins/Plugin.d.ts +7 -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/PluginManager.d.ts +2 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/bidi-isolation.mjs +1 -1
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts +2 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +2 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/formula/DisplayMathNodeSpec.d.ts.map +1 -1
- package/dist/plugins/formula/FormulaInputRules.d.ts.map +1 -1
- package/dist/plugins/formula/FormulaMarkdownSyntax.d.ts +4 -0
- package/dist/plugins/formula/FormulaMarkdownSyntax.d.ts.map +1 -0
- package/dist/plugins/formula/FormulaPlugin.d.ts.map +1 -1
- package/dist/plugins/formula/FormulaTypes.d.ts +2 -0
- package/dist/plugins/formula/FormulaTypes.d.ts.map +1 -1
- package/dist/plugins/formula/InlineMathNodeSpec.d.ts.map +1 -1
- package/dist/plugins/formula.mjs +1 -1
- package/dist/plugins/gap-cursor.mjs +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/HeadingPlugin.d.ts +2 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +2 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts +14 -0
- 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/LinkPlugin.d.ts +14 -0
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/list/ListCommands.d.ts +5 -1
- package/dist/plugins/list/ListCommands.d.ts.map +1 -1
- package/dist/plugins/list/ListInputRules.d.ts.map +1 -1
- package/dist/plugins/list/ListItemContext.d.ts +27 -0
- package/dist/plugins/list/ListItemContext.d.ts.map +1 -0
- package/dist/plugins/list/ListKeyboardHandlers.d.ts.map +1 -1
- package/dist/plugins/list/ListPlugin.d.ts +2 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list/ListToolbarItems.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -1
- package/dist/plugins/print/PrintDestinationBridge.d.ts +23 -0
- package/dist/plugins/print/PrintDestinationBridge.d.ts.map +1 -0
- package/dist/plugins/print/PrintHostStyles.d.ts +50 -0
- package/dist/plugins/print/PrintHostStyles.d.ts.map +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -1
- package/dist/plugins/print/PrintServiceImpl.d.ts +76 -3
- package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -1
- package/dist/plugins/print/PrintStyleCollector.d.ts +150 -21
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
- package/dist/plugins/print/StaticHostMarker.d.ts +18 -0
- package/dist/plugins/print/StaticHostMarker.d.ts.map +1 -0
- package/dist/plugins/print.mjs +1 -1
- package/dist/plugins/shared/MarkInputRule.d.ts +9 -0
- package/dist/plugins/shared/MarkInputRule.d.ts.map +1 -0
- package/dist/plugins/shared/PopupPositioning.d.ts +2 -0
- package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -1
- package/dist/plugins/shared/index.d.ts +1 -0
- package/dist/plugins/shared/index.d.ts.map +1 -1
- package/dist/plugins/shared.mjs +1 -1
- package/dist/plugins/smart-paste.mjs +1 -1
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +2 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/table/TableClipboard.d.ts +8 -0
- package/dist/plugins/table/TableClipboard.d.ts.map +1 -0
- package/dist/plugins/table/TableCommands.d.ts.map +1 -1
- package/dist/plugins/table/TableContextMenu.d.ts +11 -1
- package/dist/plugins/table/TableContextMenu.d.ts.map +1 -1
- package/dist/plugins/table/TableControls.d.ts +6 -1
- package/dist/plugins/table/TableControls.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsDOM.d.ts +11 -2
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsLayout.d.ts +12 -3
- package/dist/plugins/table/TableControlsLayout.d.ts.map +1 -1
- package/dist/plugins/table/TableGrid.d.ts +57 -0
- package/dist/plugins/table/TableGrid.d.ts.map +1 -0
- package/dist/plugins/table/TableHelpers.d.ts +4 -0
- package/dist/plugins/table/TableHelpers.d.ts.map +1 -1
- package/dist/plugins/table/TableLocale.d.ts +30 -0
- package/dist/plugins/table/TableLocale.d.ts.map +1 -1
- package/dist/plugins/table/TableNavigation.d.ts +5 -1
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
- package/dist/plugins/table/TableNodeViews.d.ts +13 -1
- package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
- package/dist/plugins/table/TablePlugin.d.ts +21 -1
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
- package/dist/plugins/table/TableSelection.d.ts.map +1 -1
- package/dist/plugins/table/TableSizeEditor.d.ts +11 -0
- package/dist/plugins/table/TableSizeEditor.d.ts.map +1 -0
- package/dist/plugins/table/TableSizing.d.ts +70 -0
- package/dist/plugins/table/TableSizing.d.ts.map +1 -0
- package/dist/plugins/table/index.d.ts +3 -1
- package/dist/plugins/table/index.d.ts.map +1 -1
- package/dist/plugins/table/locales/ar.d.ts.map +1 -1
- package/dist/plugins/table/locales/de.d.ts.map +1 -1
- package/dist/plugins/table/locales/es.d.ts.map +1 -1
- package/dist/plugins/table/locales/fr.d.ts.map +1 -1
- package/dist/plugins/table/locales/hi.d.ts.map +1 -1
- package/dist/plugins/table/locales/pt.d.ts.map +1 -1
- package/dist/plugins/table/locales/ru.d.ts.map +1 -1
- package/dist/plugins/table/locales/zh.d.ts.map +1 -1
- package/dist/plugins/table.mjs +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/TextFormattingPlugin.d.ts +9 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/plugins/video/VideoCommands.d.ts.map +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/serialization/DocumentParser.d.ts.map +1 -1
- package/dist/serialization/DocumentSerializer.d.ts +2 -0
- package/dist/serialization/DocumentSerializer.d.ts.map +1 -1
- package/dist/serialization/HTMLSanitization.d.ts +15 -0
- package/dist/serialization/HTMLSanitization.d.ts.map +1 -0
- package/dist/serialization/MarkSerializer.d.ts +12 -0
- package/dist/serialization/MarkSerializer.d.ts.map +1 -1
- package/dist/serialization/MarkdownParser.d.ts +6 -0
- package/dist/serialization/MarkdownParser.d.ts.map +1 -0
- package/dist/serialization/MarkdownSerializer.d.ts +12 -0
- package/dist/serialization/MarkdownSerializer.d.ts.map +1 -0
- package/dist/serialization/MarkdownTypes.d.ts +59 -0
- package/dist/serialization/MarkdownTypes.d.ts.map +1 -0
- package/dist/serialization/TableDimensions.d.ts +37 -0
- package/dist/serialization/TableDimensions.d.ts.map +1 -0
- package/dist/serialization/markdown/BlockSerializers.d.ts +7 -0
- package/dist/serialization/markdown/BlockSerializers.d.ts.map +1 -0
- package/dist/serialization/markdown/BlockTokenizer.d.ts +54 -0
- package/dist/serialization/markdown/BlockTokenizer.d.ts.map +1 -0
- package/dist/serialization/markdown/GfmAutolink.d.ts +20 -0
- package/dist/serialization/markdown/GfmAutolink.d.ts.map +1 -0
- package/dist/serialization/markdown/GfmTableParser.d.ts +26 -0
- package/dist/serialization/markdown/GfmTableParser.d.ts.map +1 -0
- package/dist/serialization/markdown/InlineAst.d.ts +34 -0
- package/dist/serialization/markdown/InlineAst.d.ts.map +1 -0
- package/dist/serialization/markdown/InlineSerializers.d.ts +5 -0
- package/dist/serialization/markdown/InlineSerializers.d.ts.map +1 -0
- package/dist/serialization/markdown/InlineTokenizer.d.ts +5 -0
- package/dist/serialization/markdown/InlineTokenizer.d.ts.map +1 -0
- package/dist/serialization/markdown/LinkReferenceExtractor.d.ts +37 -0
- package/dist/serialization/markdown/LinkReferenceExtractor.d.ts.map +1 -0
- package/dist/serialization/markdown/MarkdownContext.d.ts +32 -0
- package/dist/serialization/markdown/MarkdownContext.d.ts.map +1 -0
- package/dist/serialization/markdown/MarkdownEntities.d.ts +33 -0
- package/dist/serialization/markdown/MarkdownEntities.d.ts.map +1 -0
- package/dist/serialization/markdown/MarkdownEscape.d.ts +33 -0
- package/dist/serialization/markdown/MarkdownEscape.d.ts.map +1 -0
- package/dist/serialization/markdown/MarkdownHTMLRegistry.d.ts +4 -0
- package/dist/serialization/markdown/MarkdownHTMLRegistry.d.ts.map +1 -0
- package/dist/serialization/markdown/MarkdownParseContext.d.ts +23 -0
- package/dist/serialization/markdown/MarkdownParseContext.d.ts.map +1 -0
- package/dist/state/Mapping.d.ts +33 -10
- package/dist/state/Mapping.d.ts.map +1 -1
- package/dist/state/StepApplication.d.ts +3 -1
- package/dist/state/StepApplication.d.ts.map +1 -1
- package/dist/state/StepHandlers.d.ts.map +1 -1
- package/dist/state/StepInversion.d.ts +2 -1
- package/dist/state/StepInversion.d.ts.map +1 -1
- package/dist/state/StepMapping.d.ts +3 -2
- package/dist/state/StepMapping.d.ts.map +1 -1
- package/dist/state/StepMaps.d.ts +3 -2
- package/dist/state/StepMaps.d.ts.map +1 -1
- package/dist/state/Steps.d.ts +34 -2
- package/dist/state/Steps.d.ts.map +1 -1
- package/dist/state/TransactionBuilder.d.ts +7 -1
- package/dist/state/TransactionBuilder.d.ts.map +1 -1
- package/dist/style/StyleRuntime.d.ts +7 -0
- package/dist/style/StyleRuntime.d.ts.map +1 -1
- package/dist/test/MarkdownConformanceUtils.d.ts +12 -0
- package/dist/test/MarkdownConformanceUtils.d.ts.map +1 -0
- package/dist/view/BlockRendering.d.ts +5 -0
- package/dist/view/BlockRendering.d.ts.map +1 -1
- package/dist/view/DecorationRendering.d.ts +6 -0
- package/dist/view/DecorationRendering.d.ts.map +1 -1
- package/dist/view/EditorViewEvents.d.ts.map +1 -1
- package/dist/view/Reconciler.d.ts.map +1 -1
- package/package.json +14 -1
- package/dist/chunks/AttrRegistry-DcDVyzLm.mjs.map +0 -1
- package/dist/chunks/BlockInsertion-6rR9tIGP.mjs +0 -2
- package/dist/chunks/BlockInsertion-6rR9tIGP.mjs.map +0 -1
- package/dist/chunks/BlockquotePlugin-4V7KV_Sb.mjs +0 -2
- package/dist/chunks/CodeBlockPlugin-DC0-BnNy.mjs +0 -2
- package/dist/chunks/CodeBlockPlugin-DC0-BnNy.mjs.map +0 -1
- package/dist/chunks/ColorPickerPopup-C_74bqid.mjs +0 -2
- package/dist/chunks/Commands-BIIpx_Zd.mjs +0 -2
- package/dist/chunks/Commands-BIIpx_Zd.mjs.map +0 -1
- package/dist/chunks/Decoration-ZeyVfwJB.mjs +0 -2
- package/dist/chunks/Decoration-ZeyVfwJB.mjs.map +0 -1
- package/dist/chunks/Document-r7vLOAGA.mjs +0 -2
- package/dist/chunks/Document-r7vLOAGA.mjs.map +0 -1
- package/dist/chunks/DocumentParser-CcTSeT1B.mjs +0 -2
- package/dist/chunks/DocumentParser-CcTSeT1B.mjs.map +0 -1
- package/dist/chunks/FontPlugin-DB1_bgam.mjs +0 -2
- package/dist/chunks/FontSizePlugin-DFvp7Ki9.mjs.map +0 -1
- package/dist/chunks/FormulaPlugin-BLEcyazj.mjs +0 -2
- package/dist/chunks/FormulaPlugin-BLEcyazj.mjs.map +0 -1
- package/dist/chunks/GapCursorNavigation-ycNzuQVH.mjs +0 -2
- package/dist/chunks/HTMLUtils-C6B4UT00.mjs +0 -2
- package/dist/chunks/HTMLUtils-C6B4UT00.mjs.map +0 -1
- package/dist/chunks/HeadingPlugin-D9yvG2Aw.mjs +0 -2
- package/dist/chunks/HorizontalRulePlugin-0FjHPZuA.mjs +0 -2
- package/dist/chunks/HorizontalRulePlugin-0FjHPZuA.mjs.map +0 -1
- package/dist/chunks/ImagePlugin-Cp_RINtc.mjs +0 -2
- package/dist/chunks/InlineCodePlugin-DMr4O7c7.mjs.map +0 -1
- package/dist/chunks/InlineStyleMarkSpec-4R6DC7ij.mjs +0 -2
- package/dist/chunks/LinkPlugin-DvZ3MPgL.mjs +0 -2
- package/dist/chunks/LinkPlugin-DvZ3MPgL.mjs.map +0 -1
- package/dist/chunks/ListPlugin-CVId2dE0.mjs +0 -2
- package/dist/chunks/ListPlugin-CVId2dE0.mjs.map +0 -1
- package/dist/chunks/NodeSelectionCommands-Dj4VxLdD.mjs +0 -2
- package/dist/chunks/PluginHelpers-KDuTlmXm.mjs +0 -2
- package/dist/chunks/PopupPositioning-DtUrY9bh.mjs +0 -2
- package/dist/chunks/PrintPlugin-C6gOJT6d.mjs +0 -2
- package/dist/chunks/PrintPlugin-C6gOJT6d.mjs.map +0 -1
- package/dist/chunks/PrintTypes-WdtgSj74.mjs.map +0 -1
- package/dist/chunks/StrikethroughPlugin-BLKDRWtf.mjs +0 -2
- package/dist/chunks/StrikethroughPlugin-BLKDRWtf.mjs.map +0 -1
- package/dist/chunks/StyleRuntime-BAutwDZT.mjs +0 -2
- package/dist/chunks/StyleRuntime-BAutwDZT.mjs.map +0 -1
- package/dist/chunks/TablePlugin-D93RR5xH.mjs +0 -2
- package/dist/chunks/TablePlugin-D93RR5xH.mjs.map +0 -1
- package/dist/chunks/TextColorPlugin-C1qpzEOa.mjs +0 -2
- package/dist/chunks/TextDirectionAutoPlugin-CzWJjrvG.mjs +0 -2
- package/dist/chunks/TextDirectionService-OFOU6r_s.mjs +0 -2
- package/dist/chunks/TextFormattingPlugin-Cubp3e7f.mjs +0 -2
- package/dist/chunks/TextFormattingPlugin-Cubp3e7f.mjs.map +0 -1
- package/dist/chunks/VideoPlugin-D9rQZol6.mjs +0 -2
- package/dist/chunks/VideoPlugin-D9rQZol6.mjs.map +0 -1
- package/dist/chunks/WordBoundary-DxeMBRyP.mjs +0 -2
- package/dist/chunks/ar-BTShmP2E.mjs +0 -2
- package/dist/chunks/ar-jbplYWkC.mjs +0 -2
- package/dist/chunks/ar-jbplYWkC.mjs.map +0 -1
- package/dist/chunks/de-DN-e6G5A.mjs +0 -2
- package/dist/chunks/de-DN-e6G5A.mjs.map +0 -1
- package/dist/chunks/es-CM55WeEN.mjs +0 -2
- package/dist/chunks/es-CM55WeEN.mjs.map +0 -1
- package/dist/chunks/fr-C_2i5Ono.mjs +0 -2
- package/dist/chunks/fr-C_2i5Ono.mjs.map +0 -1
- package/dist/chunks/full-Cah3qjCT.mjs +0 -2
- package/dist/chunks/hi-C9fvG91d.mjs +0 -2
- package/dist/chunks/hi-C9fvG91d.mjs.map +0 -1
- package/dist/chunks/minimal-DqATlnAL.mjs +0 -2
- package/dist/chunks/pt-GqLw5tN0.mjs +0 -2
- package/dist/chunks/pt-GqLw5tN0.mjs.map +0 -1
- package/dist/chunks/ru-4g_qsaLr.mjs +0 -2
- package/dist/chunks/ru-4g_qsaLr.mjs.map +0 -1
- package/dist/chunks/src-YY6n2SmV.mjs +0 -2
- package/dist/chunks/src-YY6n2SmV.mjs.map +0 -1
- package/dist/chunks/zh-BjoyjClN.mjs +0 -2
- package/dist/chunks/zh-DeZP08HI.mjs +0 -2
- package/dist/chunks/zh-DeZP08HI.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockInsertion-6rR9tIGP.mjs","names":[],"sources":["../../src/model/ContentModel.ts","../../src/commands/CommandHelpers.ts","../../src/commands/BlockInsertion.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 { SchemaRegistry } from './SchemaRegistry.js';\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: SchemaRegistry,\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 * Shared helpers used across multiple command modules.\n *\n * - {@link getSiblings} — resolves a parent path to its child list\n * - {@link resolveInsertPoint} — normalizes a text selection to a single insert position\n */\n\nimport type { BlockNode, ChildNode, Document } from '../model/Document.js';\nimport { getBlockLength, isBlockNode, isLeafBlock } from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tisCollapsed,\n\tselectionRange,\n} from '../model/Selection.js';\nimport type { EditorSelection, Selection } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock } from '../state/NavigationQueries.js';\n\n/** The resolved insert position within a single block. */\nexport interface InsertPoint {\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/** Resolves the children of a parent path: doc root or a nested block. */\nexport function getSiblings(\n\tstate: EditorState,\n\tparentPath: readonly BlockId[],\n): readonly ChildNode[] {\n\tif (parentPath.length === 0) return state.doc.children;\n\tconst parent: BlockNode | undefined = state.getBlock(\n\t\tparentPath[parentPath.length - 1] as BlockId,\n\t);\n\treturn parent ? parent.children : [];\n}\n\n/**\n * Normalizes a text selection to a single insert point.\n *\n * - Collapsed selection → anchor position.\n * - Range selection → normalized `from` position (document-order start).\n */\nexport function resolveInsertPoint(sel: Selection, blockOrder: readonly BlockId[]): InsertPoint {\n\tif (isCollapsed(sel)) {\n\t\treturn { blockId: sel.anchor.blockId, offset: sel.anchor.offset };\n\t}\n\tconst range = selectionRange(sel, blockOrder);\n\treturn { blockId: range.from.blockId, offset: range.from.offset };\n}\n\n/** Extracts the parent path from a full node path (all elements except the last). */\nexport function extractParentPath(path: readonly string[] | undefined): BlockId[] {\n\treturn path && path.length > 1 ? (path.slice(0, -1) as BlockId[]) : [];\n}\n\n/** Finds the index of a block by ID within a sibling list. */\nexport function findSiblingIndex(siblings: readonly ChildNode[], targetId: BlockId): number {\n\treturn siblings.findIndex((c) => isBlockNode(c) && c.id === targetId);\n}\n\n/** A block's parent path, its sibling list, and its index within that list. */\nexport interface SiblingContext {\n\treadonly parentPath: BlockId[];\n\treadonly siblings: readonly ChildNode[];\n\treadonly index: number;\n}\n\n/**\n * Resolves a node's parent path, sibling list, and index among its siblings.\n * `index` is `-1` when the node is not found; callers that require the node to\n * exist should guard on `index < 0`.\n */\nexport function resolveSiblingContext(state: EditorState, nodeId: BlockId): SiblingContext {\n\tconst parentPath: BlockId[] = extractParentPath(findNodePath(state.doc, nodeId));\n\tconst siblings: readonly ChildNode[] = getSiblings(state, parentPath);\n\tconst index: number = findSiblingIndex(siblings, nodeId);\n\treturn { parentPath, siblings, index };\n}\n\n/** Finds the first leaf block ID in a subtree. */\nexport function findFirstLeafBlockId(node: BlockNode): BlockId {\n\tif (isLeafBlock(node)) return node.id;\n\n\tfor (const child of node.children) {\n\t\tif (!isBlockNode(child)) continue;\n\t\treturn findFirstLeafBlockId(child);\n\t}\n\n\treturn node.id;\n}\n\n/** Finds the last leaf block ID in a subtree. */\nexport function findLastLeafBlockId(node: BlockNode): BlockId {\n\tif (isLeafBlock(node)) return node.id;\n\n\tfor (let i = node.children.length - 1; i >= 0; i--) {\n\t\tconst child = node.children[i];\n\t\tif (child && isBlockNode(child)) {\n\t\t\treturn findLastLeafBlockId(child);\n\t\t}\n\t}\n\n\treturn node.id;\n}\n\n/**\n * Resolves a valid editor selection at the start or end of a block subtree.\n * Void blocks become NodeSelections; text-capable blocks resolve to leaf cursors.\n */\nexport function createSelectionForBlockBoundary(\n\tstate: EditorState,\n\tblockId: BlockId,\n\tboundary: 'start' | 'end',\n): EditorSelection | null {\n\tconst block = state.getBlock(blockId);\n\tif (!block) return null;\n\n\tif (isVoidBlock(state, blockId)) {\n\t\tconst path = state.getNodePath(blockId);\n\t\treturn path ? createNodeSelection(blockId, path) : null;\n\t}\n\n\tconst leafId: BlockId =\n\t\tboundary === 'start' ? findFirstLeafBlockId(block) : findLastLeafBlockId(block);\n\tconst leaf = state.getBlock(leafId);\n\tif (!leaf) return null;\n\n\tconst offset = boundary === 'start' ? 0 : getBlockLength(leaf);\n\treturn createCollapsedSelection(leafId, offset);\n}\n\n/**\n * Resolves a valid editor selection anywhere in the document, starting from\n * the first (or last) top-level block and deferring per-block resolution to\n * {@link createSelectionForBlockBoundary}. Useful as a last-resort fallback\n * after deletions when neighbouring siblings cannot provide a selection.\n *\n * @param state The editor state to query.\n * @param boundary `'start'` walks document order; `'end'` walks reverse.\n * @param excludeBlockId Optional block id to skip (e.g. the block about to\n * be removed by the caller's transaction).\n * @returns A valid selection, or `null` if no selectable block exists.\n */\nexport function createSelectionForDocumentBoundary(\n\tstate: EditorState,\n\tboundary: 'start' | 'end',\n\texcludeBlockId?: BlockId,\n): EditorSelection | null {\n\tconst children: readonly ChildNode[] = state.doc.children;\n\tconst indices: readonly number[] =\n\t\tboundary === 'start'\n\t\t\t? children.map((_, i) => i)\n\t\t\t: children.map((_, i) => children.length - 1 - i);\n\n\tfor (const i of indices) {\n\t\tconst child = children[i];\n\t\tif (!child || !isBlockNode(child)) continue;\n\t\tif (excludeBlockId !== undefined && child.id === excludeBlockId) continue;\n\n\t\tconst sel = createSelectionForBlockBoundary(state, child.id, boundary);\n\t\tif (sel) return sel;\n\t}\n\n\treturn null;\n}\n\n/** Returns the root-level block IDs in document order. */\nexport function getRootBlockIds(doc: Document): readonly BlockId[] {\n\treturn doc.children.map((child) => child.id);\n}\n","/**\n * Block insertion utilities for paste/clipboard operations and block-object\n * commands (table, image, horizontal rule, display formula).\n *\n * Provides context resolution (parent path, anchor index, empty detection)\n * for inserting blocks into the document tree — both at root level and\n * inside table cells — plus the shared primitive that drops a block-level\n * object onto its own line. Also contains pure helpers for block cloning,\n * recursive lookup, and attribute sanitization against a NodeSpec.\n */\n\nimport { canContain } from '../model/ContentModel.js';\nimport type { ContentSlice, SliceBlock } from '../model/ContentSlice.js';\nimport {\n\ttype BlockAttrs,\n\ttype BlockNode,\n\ttype ChildNode,\n\ttype ContentSegment,\n\ttype InlineNode,\n\ttype Mark,\n\ttype TextNode,\n\tcreateBlockNode,\n\tcreateInlineNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tgetBlockText,\n\tinlineSegment,\n\tisBlockNode,\n\tsegmentsToInlineChildren,\n\ttextSegment,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { AttrSpec } from '../model/NodeSpec.js';\nimport type { RichBlockData, RichSegment } from '../model/RichBlockData.js';\nimport type { SchemaRegistry } from '../model/SchemaRegistry.js';\nimport type { EditorSelection } from '../model/Selection.js';\nimport { isGapCursor, isNodeSelection } from '../model/Selection.js';\nimport type { BlockId, NodeTypeName } from '../model/TypeBrands.js';\nimport { inlineType, nodeType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock } from '../state/NavigationQueries.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { extractParentPath, findSiblingIndex, getSiblings } from './CommandHelpers.js';\n\n/**\n * Resolved insertion target within the document tree.\n * Contains everything needed to insert blocks at a specific anchor position.\n */\nexport interface InsertionContext {\n\treadonly parentPath: readonly BlockId[];\n\treadonly anchorIndex: number;\n\treadonly isAnchorEmpty: boolean;\n}\n\n/**\n * Resolves an insertion context for root-level (or nested-parent-level) insertion.\n * Computes the parent path, anchor index among siblings, and whether the anchor is empty.\n */\nexport function resolveRootInsertionContext(\n\tstate: EditorState,\n\tanchorBlockId: BlockId,\n\tschemaRegistry?: SchemaRegistry,\n): InsertionContext | undefined {\n\tconst path: readonly string[] | undefined = findNodePath(state.doc, anchorBlockId);\n\tconst parentPath: BlockId[] = extractParentPath(path);\n\n\tconst siblings: readonly ChildNode[] = getSiblings(state, parentPath);\n\tconst anchorIndex: number = findSiblingIndex(siblings, anchorBlockId);\n\tif (anchorIndex < 0) return undefined;\n\n\tconst isAnchorEmpty: boolean = isBlockEmpty(state, anchorBlockId, schemaRegistry);\n\treturn { parentPath, anchorIndex, isAnchorEmpty };\n}\n\n/**\n * Resolves an insertion context within a table cell.\n * The parent path points to the cell itself; siblings are the cell's children.\n */\nexport function resolveCellInsertionContext(\n\tstate: EditorState,\n\tanchorBlockId: BlockId,\n\tcellId: BlockId,\n\tschemaRegistry?: SchemaRegistry,\n): InsertionContext | undefined {\n\tconst cellPath: BlockId[] | undefined = findNodePath(state.doc, cellId) as BlockId[] | undefined;\n\tif (!cellPath) return undefined;\n\n\tconst cell: BlockNode | undefined = state.getBlock(cellId);\n\tif (!cell) return undefined;\n\n\tconst anchorIndex: number = cell.children.findIndex(\n\t\t(c) => isBlockNode(c) && c.id === anchorBlockId,\n\t);\n\n\tconst isAnchorEmpty: boolean = isBlockEmpty(state, anchorBlockId, schemaRegistry);\n\treturn { parentPath: cellPath, anchorIndex, isAnchorEmpty };\n}\n\n/**\n * Finds a table_cell ancestor for the given block.\n * Walks the node path upward, returning the first table_cell BlockId found.\n */\nexport function findTableCellAncestor(state: EditorState, blockId: BlockId): BlockId | undefined {\n\tconst block: BlockNode | undefined = state.getBlock(blockId);\n\tif (block?.type === 'table_cell') return blockId;\n\n\tconst path: BlockId[] | undefined = findNodePath(state.doc, blockId) as BlockId[] | undefined;\n\tif (!path) return undefined;\n\n\tfor (const id of path) {\n\t\tconst node: BlockNode | undefined = state.getBlock(id as BlockId);\n\t\tif (node?.type === 'table_cell') return id as BlockId;\n\t}\n\treturn undefined;\n}\n\n/**\n * Resolves the anchor block ID from the current editor selection.\n * Handles text selection, node selection, and gap cursor uniformly.\n */\nexport function resolveAnchorBlockId(selection: EditorSelection): BlockId {\n\tif (isNodeSelection(selection)) return selection.nodeId;\n\tif (isGapCursor(selection)) return selection.blockId;\n\treturn selection.anchor.blockId;\n}\n\n/**\n * Inserts a block node after the anchor position, resolving cell vs root context.\n * Removes the anchor block if it is empty (matching standard paste behavior).\n * Returns true on success, false if context resolution fails.\n */\nexport function insertBlockAfterAnchor(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tanchorBlockId: BlockId,\n\tblock: BlockNode,\n\tselection: EditorSelection,\n\tschemaRegistry?: SchemaRegistry,\n): boolean {\n\tconst cellId: BlockId | undefined = findTableCellAncestor(state, anchorBlockId);\n\n\tif (cellId) {\n\t\tconst ctx: InsertionContext | undefined = resolveCellInsertionContext(\n\t\t\tstate,\n\t\t\tanchorBlockId,\n\t\t\tcellId,\n\t\t\tschemaRegistry,\n\t\t);\n\t\tif (!ctx) return false;\n\n\t\tconst insertIndex: number = ctx.anchorIndex + 1;\n\t\tbuilder.insertNode(ctx.parentPath, insertIndex, block);\n\n\t\tif (ctx.isAnchorEmpty && ctx.anchorIndex >= 0) {\n\t\t\tbuilder.removeNode(ctx.parentPath, ctx.anchorIndex);\n\t\t}\n\t} else {\n\t\tconst ctx: InsertionContext | undefined = resolveRootInsertionContext(\n\t\t\tstate,\n\t\t\tanchorBlockId,\n\t\t\tschemaRegistry,\n\t\t);\n\t\tif (!ctx) return false;\n\n\t\tconst insertOffset: number = isGapCursor(selection) && selection.side === 'before' ? 0 : 1;\n\t\tbuilder.insertNode(ctx.parentPath, ctx.anchorIndex + insertOffset, block);\n\n\t\tif (ctx.isAnchorEmpty && !isGapCursor(selection)) {\n\t\t\tbuilder.removeNode(ctx.parentPath, ctx.anchorIndex);\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Document-root index of the top-level block that contains `blockId` — the block\n * itself when it already lives at the document root. Returns -1 when the block is\n * not part of the document. Block-level objects always live at the root, so an\n * insertion triggered from inside a container (e.g. a table cell) escapes to the\n * top level via this lookup.\n */\nexport function topLevelBlockIndex(state: EditorState, blockId: BlockId): number {\n\tconst path: readonly string[] | undefined = findNodePath(state.doc, blockId);\n\tconst topId: BlockId = path && path.length > 0 ? (path[0] as BlockId) : blockId;\n\treturn state.doc.children.findIndex((b) => b.id === topId);\n}\n\n/**\n * True when a container of `containerType` may hold every block in `blocks`,\n * per its {@link import('../model/NodeSpec.js').NodeSpec} content rule. An\n * undefined `containerType` denotes the document root, which imposes no\n * restriction. Used to keep paste from creating schema-invalid nesting, such as\n * a `table` dropped into a `table_cell` (#166).\n */\nexport function canContainerHoldBlocks(\n\tregistry: SchemaRegistry,\n\tcontainerType: string | undefined,\n\tblocks: readonly BlockNode[],\n): boolean {\n\tif (!containerType) return true;\n\treturn blocks.every((block) => canContain(registry, containerType, block.type));\n}\n\n/**\n * Insertion context that escapes to the document root: blocks are placed after\n * the top-level ancestor of `anchorBlockId` (e.g. the outer table when the caret\n * sits inside a cell). The anchor is never treated as empty, so the originating\n * container keeps its own content. Returns undefined when the anchor is not part\n * of the document.\n */\nexport function resolveRootEscapeContext(\n\tstate: EditorState,\n\tanchorBlockId: BlockId,\n): InsertionContext | undefined {\n\tconst topIndex: number = topLevelBlockIndex(state, anchorBlockId);\n\tif (topIndex === -1) return undefined;\n\treturn { parentPath: [], anchorIndex: topIndex, isAnchorEmpty: false };\n}\n\n/**\n * True when the block is a blank-line paragraph. Inline-aware: a paragraph that\n * holds only an atomic inline node (e.g. an inline formula) has width > 0 and is\n * therefore never treated as blank, so it is never silently removed.\n */\nexport function isEmptyParagraph(block: BlockNode): boolean {\n\treturn block.type === 'paragraph' && getBlockLength(block) === 0;\n}\n\n/**\n * Places a block-level object on its own line at the document root: the object\n * followed by a trailing empty paragraph, so a void/atomic object always has an\n * editable line after it. The object is inserted after the top-level ancestor of\n * the current selection; when that ancestor is a blank-line paragraph it is\n * consumed, so the object is never preceded by a stray empty paragraph (#152).\n *\n * Only an empty *paragraph* is consumed — an empty heading or list item is\n * deliberate structure — and the emptiness test is inline-aware (see\n * {@link isEmptyParagraph}). This is intentionally stricter than\n * {@link insertBlockAfterAnchor}, which the paste pipeline uses with a text-only\n * emptiness notion.\n *\n * A void anchor (image, display formula) already owns a trailing empty paragraph\n * as its escape line. In that case the object is placed before that paragraph and\n * the paragraph is reused as the object's trailing line, so a second blank line\n * never stacks up (#158).\n *\n * Selection is the caller's concern, since objects differ (a cursor inside a new\n * table vs. a node selection on an image or display formula). Returns the\n * trailing paragraph after the object, or undefined when the selection has no\n * resolvable anchor.\n */\nexport function insertBlockObjectOnOwnLine(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tanchorBlockId: BlockId,\n\tobject: BlockNode,\n): BlockNode | undefined {\n\treturn insertBlockObjectsOnOwnLines(state, builder, anchorBlockId, [object]);\n}\n\n/**\n * Places a sequence of block-level objects on their own lines at the document\n * root, sharing a single trailing empty paragraph. Generalizes\n * {@link insertBlockObjectOnOwnLine} for inserting several objects at once (e.g.\n * pasting two or more standalone formulas, #159); for a single object the two\n * behave identically. The anchor-consumption (#152) and void-anchor trailing\n * reuse (#158) rules apply once, around the whole run.\n *\n * Returns the trailing paragraph after the last object, or undefined when the\n * anchor or object list is empty.\n */\nexport function insertBlockObjectsOnOwnLines(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tanchorBlockId: BlockId,\n\tobjects: readonly BlockNode[],\n): BlockNode | undefined {\n\tif (objects.length === 0) return undefined;\n\n\tconst topIndex: number = topLevelBlockIndex(state, anchorBlockId);\n\tif (topIndex === -1) return undefined;\n\n\tconst anchor: BlockNode | undefined = state.doc.children[topIndex];\n\tconst following: BlockNode | undefined = state.doc.children[topIndex + 1];\n\n\tlet insertAt: number = topIndex + 1;\n\tfor (const object of objects) {\n\t\tbuilder.insertNode([], insertAt, object);\n\t\tinsertAt++;\n\t}\n\n\t// A void anchor already owns a trailing empty paragraph as its escape line;\n\t// reuse it so a second blank line never stacks up (#158). Otherwise add one.\n\tconst reusableTrailing: BlockNode | undefined =\n\t\tanchor && isVoidBlock(state, anchor.id) && following && isEmptyParagraph(following)\n\t\t\t? following\n\t\t\t: undefined;\n\tlet trailing: BlockNode;\n\tif (reusableTrailing) {\n\t\ttrailing = reusableTrailing;\n\t} else {\n\t\ttrailing = createBlockNode(nodeType('paragraph'));\n\t\tbuilder.insertNode([], insertAt, trailing);\n\t}\n\n\t// Drop a blank-line paragraph anchor so the objects are not preceded by a\n\t// stray empty paragraph (#152).\n\tif (anchor && isEmptyParagraph(anchor)) {\n\t\tbuilder.removeNode([], topIndex);\n\t}\n\n\treturn trailing;\n}\n\n/** Recursively clones a block tree, assigning new IDs to all block nodes. */\nexport function cloneBlockWithNewIds(block: BlockNode, newId: BlockId): BlockNode {\n\tconst children = block.children.map((child) => {\n\t\tif (isBlockNode(child)) {\n\t\t\treturn cloneBlockWithNewIds(child, generateBlockId());\n\t\t}\n\t\treturn child;\n\t});\n\treturn createBlockNode(block.type, children, newId, block.attrs);\n}\n\n/** Recursively searches a block tree for a block with the given ID (DFS). */\nexport function findBlockRecursive(block: BlockNode, blockId: BlockId): BlockNode | undefined {\n\tif (block.id === blockId) return block;\n\tfor (const child of block.children) {\n\t\tif (!isBlockNode(child)) continue;\n\t\tconst found: BlockNode | undefined = findBlockRecursive(child, blockId);\n\t\tif (found) return found;\n\t}\n\treturn undefined;\n}\n\n/**\n * Validates incoming attributes against the declared AttrSpec.\n * Only keys declared in the spec are kept; non-primitive values fall back to defaults.\n */\nexport function sanitizeAttrs(\n\tincoming: Record<string, unknown> | undefined,\n\tspecAttrs: Readonly<Record<string, AttrSpec>> | undefined,\n): Record<string, string | number | boolean> | undefined {\n\tif (!specAttrs) return undefined;\n\n\tconst result: Record<string, string | number | boolean> = {};\n\tlet hasKeys = false;\n\n\tfor (const key of Object.keys(specAttrs)) {\n\t\tconst spec: AttrSpec = specAttrs[key] as AttrSpec;\n\t\tconst raw: unknown = incoming?.[key];\n\n\t\tif (typeof raw === 'string' || typeof raw === 'number' || typeof raw === 'boolean') {\n\t\t\tresult[key] = raw;\n\t\t} else if (spec.default !== undefined) {\n\t\t\tresult[key] = spec.default;\n\t\t}\n\t\tif (key in result) hasKeys = true;\n\t}\n\n\treturn hasKeys ? result : undefined;\n}\n\n/** Checks whether a block is empty (has no text and is not a void block). */\nfunction isBlockEmpty(\n\tstate: EditorState,\n\tblockId: BlockId,\n\tschemaRegistry?: SchemaRegistry,\n): boolean {\n\tconst block: BlockNode | undefined = state.getBlock(blockId);\n\tif (!block) return false;\n\n\tconst spec = schemaRegistry?.getNodeSpec(block.type);\n\treturn !spec?.isVoid && getBlockText(block) === '';\n}\n\n// --- Rich block creation ---\n\n/**\n * Validates a rich block against the schema registry.\n * Returns undefined for blocks with unknown types; sanitizes attributes\n * against the declared spec.\n */\nexport function validateRichBlockData(\n\traw: RichBlockData,\n\tschemaRegistry?: SchemaRegistry,\n): RichBlockData | undefined {\n\tif (!raw.type) return undefined;\n\tif (!schemaRegistry) return raw;\n\n\tconst spec = schemaRegistry.getNodeSpec(raw.type);\n\tif (!spec) return undefined;\n\n\tconst attrs: Record<string, string | number | boolean> | undefined = sanitizeAttrs(\n\t\traw.attrs,\n\t\tspec.attrs,\n\t);\n\tconst segments: RichSegment[] | undefined = raw.segments\n\t\t? sanitizeRichSegments(raw.segments, schemaRegistry)\n\t\t: undefined;\n\treturn {\n\t\t...raw,\n\t\t...(attrs ? { attrs } : {}),\n\t\t...(segments ? { segments } : raw.segments ? { segments: [] } : {}),\n\t};\n}\n\n/**\n * Creates a BlockNode from validated rich block data.\n * Converts segments or plain text into inline children.\n */\nexport function createBlockFromRichData(blockData: RichBlockData): BlockNode {\n\tconst newId: BlockId = generateBlockId();\n\tconst children: readonly (TextNode | InlineNode)[] | undefined =\n\t\tcreateChildrenFromRichBlock(blockData);\n\tconst attrs: BlockAttrs | undefined = blockData.attrs\n\t\t? (blockData.attrs as BlockAttrs)\n\t\t: undefined;\n\n\treturn createBlockNode(nodeType(blockData.type) as NodeTypeName, children, newId, attrs);\n}\n\n/**\n * Creates inline children from rich block data.\n * Uses mark-preserving segments when available, falls back to plain text.\n * Returns undefined for content-free blocks (e.g. void blocks).\n */\nfunction createChildrenFromRichBlock(\n\tblockData: RichBlockData,\n): readonly (TextNode | InlineNode)[] | undefined {\n\tconst segments: readonly ContentSegment[] = richBlockToContentSegments(blockData);\n\tif (segments.length === 0) return undefined;\n\treturn segmentsToInlineChildren(segments);\n}\n\n/**\n * Converts rich block data into a paste {@link ContentSlice}. Blocks that fail\n * schema validation (unknown type or filtered attributes) are dropped, so the\n * resulting slice can be fed straight into the canonical paste strategy\n * ({@link import('./PasteCommand.js').pasteSlice}).\n */\nexport function richBlocksToSlice(\n\tblocks: readonly RichBlockData[],\n\tschemaRegistry?: SchemaRegistry,\n): ContentSlice {\n\tconst sliceBlocks: SliceBlock[] = [];\n\tfor (const raw of blocks) {\n\t\tconst blockData: RichBlockData | undefined = validateRichBlockData(raw, schemaRegistry);\n\t\tif (!blockData) continue;\n\t\tsliceBlocks.push(richBlockToSliceBlock(blockData));\n\t}\n\treturn { blocks: sliceBlocks };\n}\n\n/** Converts a single validated rich block into a {@link SliceBlock}. */\nfunction richBlockToSliceBlock(blockData: RichBlockData): SliceBlock {\n\tconst attrs: BlockAttrs | undefined = blockData.attrs\n\t\t? (blockData.attrs as BlockAttrs)\n\t\t: undefined;\n\treturn {\n\t\ttype: nodeType(blockData.type) as NodeTypeName,\n\t\t...(attrs ? { attrs } : {}),\n\t\tsegments: richBlockToContentSegments(blockData),\n\t};\n}\n\n/** Builds content segments from a rich block, falling back to plain text. */\nfunction richBlockToContentSegments(blockData: RichBlockData): readonly ContentSegment[] {\n\tif (blockData.segments && blockData.segments.length > 0) {\n\t\treturn richSegmentsToContentSegments(blockData.segments);\n\t}\n\tconst text: string = blockData.text ?? '';\n\treturn text ? [textSegment(text)] : [];\n}\n\n/** Converts rich segments into content segments (marked text and inline nodes). */\nfunction richSegmentsToContentSegments(\n\tsegments: readonly RichSegment[],\n): readonly ContentSegment[] {\n\tconst result: ContentSegment[] = [];\n\tfor (const seg of segments) {\n\t\tif (seg.kind === 'inline') {\n\t\t\tresult.push(\n\t\t\t\tinlineSegment(\n\t\t\t\t\tcreateInlineNode(\n\t\t\t\t\t\tinlineType(seg.inlineType),\n\t\t\t\t\t\tseg.attrs as Readonly<Record<string, string | number | boolean>> | undefined,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tif (seg.text.length === 0) continue;\n\t\tconst marks: readonly Mark[] = seg.marks.map((m) => ({\n\t\t\ttype: m.type as Mark['type'],\n\t\t\t...(m.attrs ? { attrs: m.attrs as Mark['attrs'] } : {}),\n\t\t}));\n\t\tresult.push(textSegment(seg.text, marks));\n\t}\n\treturn result;\n}\n\nfunction sanitizeRichSegments(\n\tsegments: readonly RichSegment[],\n\tschemaRegistry: SchemaRegistry,\n): RichSegment[] {\n\tconst sanitized: RichSegment[] = [];\n\tfor (const segment of segments) {\n\t\tif (segment.kind === 'inline') {\n\t\t\tconst spec = schemaRegistry.getInlineNodeSpec(segment.inlineType);\n\t\t\tif (!spec) continue;\n\t\t\tconst attrs = sanitizeAttrs(segment.attrs, spec.attrs);\n\t\t\tsanitized.push({\n\t\t\t\tkind: 'inline',\n\t\t\t\tinlineType: segment.inlineType,\n\t\t\t\t...(attrs ? { attrs } : {}),\n\t\t\t});\n\t\t\tcontinue;\n\t\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,MAAQ,GACvC,OAAO,EAAO,CAAC,EAAY,IAAS,EACrC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{d as t,i as e,o,p as n,u as r}from"./Document-r7vLOAGA.mjs";import{d as i,o as c,t as s,u as l}from"./Selection-HYoVFpAx.mjs";import{a}from"./TypeBrands-Ch9856Gb.mjs";import{n as u}from"./DomUtils-Bf7JLFlx.mjs";import{a as d,c as h,t as m}from"./NodeResolver-ChgLF_IP.mjs";import{c as p,o as g}from"./PluginHelpers-KDuTlmXm.mjs";import{t as f}from"./ShortcutFormatting-TwiufqeV.mjs";function b(t,e){const o=t.getNodePath(e)?.[0];return o?t.doc.children.findIndex(t=>t.id===o):-1}function q(t,o,n,c){const s=i(n,t.getBlockOrder()),l=b(t,s.from.blockId),a=b(t,s.to.blockId);if(l<0||a<0)return null;const u=Math.min(l,a),d=Math.max(l,a),h=t.doc.children.slice(u,d+1),m=c??(()=>!0),p=[];let g=[],f=!1;const q=()=>{0!==g.length&&(p.push(e(o,g,r())),f=!0,g=[])};for(const e of h)m(e)?g.push(e):(q(),p.push(e));if(q(),!f)return null;const k=t.transaction("command");for(let e=d;e>=u;e--)k.removeNode([],e);return p.forEach((t,e)=>{k.insertNode([],u+e,t)}),k.setSelection(n),k.build()}function k(e,o){const n=e.getState();if(!l(n.selection))return!1;const r=n.selection;if(!c(r))return!1;const i=r.anchor.blockId,s=n.getParent(i);if(!s||"blockquote"!==s.type)return!1;const a=n.getBlock(i);if(!a)return!1;const u=n.getNodePath(s.id);if(!u)return!1;const d=h(n.doc,u);if(!d)return!1;const m=t(s),p=m.findIndex(t=>t.id===i);return!(p<0)&&o({state:n,quotePath:u,quoteParentPath:u.slice(0,-1),quoteIndex:d.index,child:a,childIndex:p,childCount:m.length,offset:r.anchor.offset})}var I={label:"Blockquote",tooltip:t=>`Blockquote (${t})`},x=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-sGZ-oZqB.mjs"),"./locales/de.ts":()=>import("./de-uKR7koQe.mjs"),"./locales/es.ts":()=>import("./es-DrJyl38L.mjs"),"./locales/fr.ts":()=>import("./fr-BRXUnq3R.mjs"),"./locales/hi.ts":()=>import("./hi-SECtQQzq.mjs"),"./locales/pt.ts":()=>import("./pt-Cv6q7x5x.mjs"),"./locales/ru.ts":()=>import("./ru-DSRv3_Rg.mjs"),"./locales/zh.ts":()=>import("./zh-DYD476c5.mjs")});async function v(t){return p(x,t,I)}var N={},P=class{id="blockquote";name="Blockquote";priority=35;config;locale;constructor(t){this.config={...N,...t}}async init(t){this.locale=await g(t,this.config.locale,I,v),t.registerStyleSheet("\n.notectl-content blockquote {\n\tmargin: 0;\n\tpadding: 2px 0;\n\tpadding-inline-start: 16px;\n\tborder-inline-start: 3px solid var(--notectl-blockquote-border, var(--notectl-border));\n\tbackground: var(--notectl-blockquote-bg, transparent);\n\tcolor: var(--notectl-blockquote-fg, inherit);\n\tmin-height: 1.6em;\n}\n"),this.registerNodeSpec(t),this.registerCommands(t),this.registerKeymap(t),this.registerInputRule(t),this.registerToolbarItem(t)}registerNodeSpec(t){t.registerNodeSpec({type:"blockquote",group:"block",content:{allow:["paragraph","heading","list_item","blockquote","horizontal_rule","code_block"],min:1},toDOM(t){const e=u("blockquote",t.id);return e.setAttribute("part","blockquote"),e},toHTML:(t,e)=>`<blockquote>${e||"<br>"}</blockquote>`,parseHTML:[{tag:"blockquote"}],sanitize:{tags:["blockquote"]}})}registerCommands(t){t.registerCommand("toggleBlockquote",()=>this.toggleBlockquote(t)),t.registerCommand("setBlockquote",()=>this.wrapInBlockquote(t))}registerKeymap(t){t.registerKeymap({"Mod-Shift->":()=>t.executeCommand("toggleBlockquote")}),function(t){t.registerKeymap({Enter:()=>function(t){return k(t,e=>{if("list_item"===e.child.type)return!1;if(e.childIndex!==e.childCount-1||n(e.child)>0)return!1;const r=o(),i=e.state.transaction("input");return 1===e.childCount?(i.removeNode(e.quoteParentPath,e.quoteIndex),i.insertNode(e.quoteParentPath,e.quoteIndex,r)):(i.removeNode(e.quotePath,e.childIndex),i.insertNode(e.quoteParentPath,e.quoteIndex+1,r)),i.setSelection(s(r.id,0)),t.dispatch(i.build()),!0})}(t),Backspace:()=>function(t){return k(t,e=>{if(0!==e.offset||0!==e.childIndex)return!1;if("list_item"===e.child.type)return!1;const o=e.state.transaction("input");return 1===e.childCount?(o.removeNode(e.quoteParentPath,e.quoteIndex),o.insertNode(e.quoteParentPath,e.quoteIndex,e.child)):(o.removeNode(e.quotePath,0),o.insertNode(e.quoteParentPath,e.quoteIndex,e.child)),o.setSelection(s(e.child.id,0)),t.dispatch(o.build()),!0})}(t)},{priority:"context"})}(t)}registerInputRule(t){t.registerInputRule({pattern:/^> $/,handler(t,o,n,i){const s=t.selection;if(!l(s))return null;if(!c(s))return null;const u=t.getBlock(s.anchor.blockId);if(!u||"paragraph"!==u.type)return null;const d=t.doc.children.findIndex(t=>t.id===u.id);if(d<0)return null;const h=e(a("blockquote"),[u],r());return t.transaction("input").removeNode([],d).insertNode([],d,h).deleteTextAt(s.anchor.blockId,n,n+2).setSelection(s).build()}})}registerToolbarItem(t){t.registerToolbarItem({id:"blockquote",group:"block",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"/></svg>',label:this.locale.label,tooltip:this.locale.tooltip(f("Mod-Shift->")),command:"toggleBlockquote",isActive:t=>!!l(t.selection)&&d(t.doc,t.selection.anchor.blockId,"blockquote")})}toggleBlockquote(e){const o=e.getState(),n=o.selection;if(!l(n))return!1;const r=d(o.doc,n.anchor.blockId,"blockquote")?function(e,o,n){const r=m(e.doc,n.anchor.blockId,o);if(!r||1!==r.path.length)return null;const i=e.doc.children.findIndex(t=>t.id===r.node.id);if(i<0)return null;const c=t(r.node),s=e.transaction("command");return s.removeNode([],i),c.forEach((t,e)=>{s.insertNode([],i+e,t)}),s.setSelection(n),s.build()}(o,a("blockquote"),n):q(o,a("blockquote"),n,this.isQuoteChild(e));return!!r&&(e.dispatch(r),!0)}wrapInBlockquote(t){const e=t.getState(),o=e.selection;if(!l(o))return!1;const n=q(e,a("blockquote"),o,this.isQuoteChild(t));return!!n&&(t.dispatch(n),!0)}isQuoteChild(t){const e=t.getSchemaRegistry(),o=new Set(e.getNodeSpec(a("blockquote"))?.content?.allow??[]);return t=>{if(o.has(t.type))return!0;const n=e.getNodeSpec(t.type)?.group;return void 0!==n&&o.has(n)}}};export{I as n,v as r,P as t};
|
|
2
|
-
//# sourceMappingURL=BlockquotePlugin-4V7KV_Sb.mjs.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as t,T as e,h as n,o,p as r,u as c,v as s}from"./Document-r7vLOAGA.mjs";import{a as i,d as a,i as l,o as d,s as u,t as g,u as p}from"./Selection-HYoVFpAx.mjs";import{t as f}from"./Commands-BIIpx_Zd.mjs";import{a as h}from"./TypeBrands-Ch9856Gb.mjs";import{n as k}from"./DomUtils-Bf7JLFlx.mjs";import{r as b}from"./HTMLUtils-C6B4UT00.mjs";import{r as m}from"./NodeResolver-ChgLF_IP.mjs";import{C as v,S as x,_ as C,v as y,y as S}from"./BlockInsertion-6rR9tIGP.mjs";import{i as w,r as _,t as I}from"./Decoration-ZeyVfwJB.mjs";import{s as B}from"./StyleRuntime-BAutwDZT.mjs";import{n as A}from"./TypedKeys-CA4bfw9O.mjs";import{t as T}from"./SyntaxTokenTypes-BUCOMtL8.mjs";import{c as L,o as M}from"./PluginHelpers-KDuTlmXm.mjs";import{t as P}from"./ShortcutFormatting-TwiufqeV.mjs";import{t as O}from"./PopupManager-CyOfZUab.mjs";import{c as N,l as j}from"./XmlDetector-D7TQpw-e.mjs";import{a as E,r as z,s as $,t as D}from"./XmlSupport-BYiRwlkK.mjs";import{n as q}from"./PopupKeyboardPatterns-tUrT9TyV.mjs";var H=`\n/* Code Block — uses theme custom properties */\n.notectl-code-block {\n\tposition: relative;\n\tmargin: 8px 0;\n\tborder-radius: 6px;\n\tbackground: var(--notectl-code-block-bg);\n\tcolor: var(--notectl-code-block-color);\n\tfont-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace;\n\tfont-size: 14px;\n\tline-height: 1.5;\n\toverflow: hidden;\n}\n\n.notectl-code-block__header {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tpadding: 6px 12px;\n\tbackground: var(--notectl-code-block-header-bg);\n\tborder-bottom: 1px solid var(--notectl-code-block-header-border);\n\tfont-size: 12px;\n\tcolor: var(--notectl-code-block-header-color);\n\tuser-select: none;\n}\n\n.notectl-code-block__language-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 4px;\n\tborder: none;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcolor: var(--notectl-code-block-header-color);\n\tcursor: pointer;\n\tpadding: 2px 6px;\n\tfont-size: inherit;\n\tfont-family: inherit;\n\ttransition: background 0.15s;\n}\n\n.notectl-code-block__language-btn:hover {\n\tbackground: rgba(128, 128, 128, 0.15);\n}\n\n.notectl-code-block__language-btn:focus-visible {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 1px;\n}\n\n.notectl-code-block__language {\n\tfont-weight: 500;\n\tletter-spacing: 0.02em;\n}\n\n.notectl-code-block__chevron {\n\tdisplay: inline-flex;\n\talign-items: center;\n\topacity: 0.6;\n}\n\n.notectl-code-block__actions {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 2px;\n}\n\n.notectl-code-block__copy,\n.notectl-code-block__delete {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 24px;\n\theight: 24px;\n\tborder: none;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcolor: var(--notectl-code-block-header-color);\n\tcursor: pointer;\n\tpadding: 0;\n\ttransition: background 0.15s, color 0.15s;\n}\n\n.notectl-code-block__copy:hover,\n.notectl-code-block__delete:hover {\n\tbackground: rgba(128, 128, 128, 0.15);\n\tcolor: var(--notectl-code-block-color);\n}\n\n.notectl-code-block__copy svg,\n.notectl-code-block__delete svg {\n\tfill: currentColor;\n}\n\n.notectl-code-block__content {\n\tdisplay: block;\n\tpadding: 12px 16px;\n\twhite-space: pre-wrap;\n\tword-wrap: break-word;\n\ttab-size: 4;\n\t-moz-tab-size: 4;\n\toutline: none;\n\tmin-height: 1.5em;\n}\n\n.notectl-code-block--selected {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n}\n\n.notectl-code-block__esc-hint {\n\tdisplay: none;\n\tposition: absolute;\n\tbottom: 4px;\n\tinset-inline-end: 8px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-code-block-header-color);\n\topacity: 0.5;\n\tpointer-events: none;\n\tuser-select: none;\n\tfont-family: system-ui, sans-serif;\n}\n\n.notectl-code-block--focused .notectl-code-block__esc-hint {\n\tdisplay: block;\n}\n\n/* Language picker popup */\n.notectl-language-picker {\n\tmin-width: 120px;\n\tmax-height: 200px;\n\toverflow-y: auto;\n\tpadding: 4px;\n\tbackground: var(--notectl-surface-raised, #fff);\n\tborder: 1px solid var(--notectl-border, #e0e0e0);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);\n}\n\n.notectl-language-picker__option {\n\tpadding: 6px 10px;\n\tborder-radius: 4px;\n\tcursor: pointer;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg, #333);\n\twhite-space: nowrap;\n}\n\n.notectl-language-picker__option:hover {\n\tbackground: rgba(128, 128, 128, 0.1);\n}\n\n.notectl-language-picker__option:focus {\n\toutline: none;\n\tbackground: rgba(128, 128, 128, 0.15);\n}\n\n.notectl-language-picker__option[aria-selected="true"] {\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary, #2563eb);\n}\n\n/* Syntax highlighting token classes — generated from canonical token type list */\n${T.map(t=>`.notectl-token--${t} {\n\tcolor: var(--notectl-code-token-${t});\n\tfont-style: var(--notectl-code-token-${t}-font-style, inherit);\n\tfont-weight: var(--notectl-code-token-${t}-font-weight, inherit);\n}`).join("\n")}\n`,R=[{open:"(",close:")",kind:"bracket"},{open:"[",close:"]",kind:"bracket"},{open:"{",close:"}",kind:"bracket"},{open:'"',close:'"',kind:"quote"},{open:"'",close:"'",kind:"quote"},{open:"`",close:"`",kind:"quote"}],V=new Map(R.map(t=>[t.open,t])),F=new Map(R.filter(t=>"bracket"===t.kind).map(t=>[t.close,t]));var K=new Set(["{","[","("]),W={"}":"{","]":"[",")":"("};function U(t,e){const n=t.lastIndexOf("\n",e-1)+1,o=t.indexOf("\n",e);return{start:n,end:-1===o?t.length:o}}function X(t,e){const{start:n,end:o}=U(t,e);let r=n;for(;r<o;){const e=t[r];if(" "!==e&&"\t"!==e)break;r++}return t.slice(n,r)}function J(t,e){return t?" ".repeat(e):"\t"}function Q(t,e,n){if(0===t.length)return{removed:"",rest:t};if(!e&&"\t"===t[0])return{removed:"\t",rest:t.slice(1)};let o=0;for(;o<n&&" "===t[o];)o++;return{removed:t.slice(0,o),rest:t.slice(o)}}var Z=class{buckets=/* @__PURE__ */new Map;push(t,e){const n=this.buckets.get(t.blockId)??[];n.push({pos:t,char:e}),this.buckets.set(t.blockId,n)}take(t,e){const n=this.buckets.get(t);if(n)for(let o=n.length-1;o>=0;o--){const r=n[o];if(r&&r.pos.offset===e)return n.splice(o,1),0===n.length&&this.buckets.delete(t),r}}peek(t,e){const n=this.buckets.get(t);if(n)for(let o=n.length-1;o>=0;o--){const t=n[o];if(t&&t.pos.offset===e)return t}}clearBlock(t){this.buckets.delete(t)}clear(){this.buckets.clear()}sizeForBlock(t){return this.buckets.get(t)?.length??0}get size(){let t=0;for(const e of this.buckets.values())t+=e.length;return t}migrate(t){if(t.isEmpty)return;const e=/* @__PURE__ */new Map;for(const n of this.buckets.values())for(const o of n){const n=t.mapResult(o.pos,1);if(n.deleted)continue;const r={pos:n.pos,char:o.char},c=n.pos.blockId,s=e.get(c)??[];s.push(r),e.set(c,s)}this.buckets.clear();for(const[n,o]of e)this.buckets.set(n,o)}static makePos(t,e){return l(t,e)}},G=class{resolvedIndent;resolvedPairing;getTokenAt;getCompositionState;pairs=new Z;pendingPairOps=[];constructor(t){this.resolvedIndent=t.resolvedIndent,this.resolvedPairing=t.resolvedPairing,this.getTokenAt=t.getTokenAt,this.getCompositionState=t.getCompositionState}get pairStack(){return this.pairs}clear(){this.pairs.clear(),this.pendingPairOps.length=0}syncOnStateChange(t,e){this.pairs.size>0&&!e.mapping.isEmpty&&this.pairs.migrate(e.mapping);for(const n of this.pendingPairOps)"push"===n.kind?this.pairs.push(l(n.blockId,n.offset),n.char):this.pairs.take(n.blockId,n.offset);this.pendingPairOps.length=0;for(const n of e.steps){if("setBlockType"!==n.type)continue;const e=t.getBlock(n.blockId);e&&"code_block"===e.type||this.pairs.clearBlock(n.blockId)}}handleTextInput=(t,e)=>{this.pendingPairOps.length=0;const o=this.getCompositionState();if(!o)return null;if(o.isComposing)return null;if(!p(e.selection))return null;if(1!==t.length)return null;const r=e.selection,c=e.getBlock(r.anchor.blockId);if(!c||"code_block"!==c.type)return null;const s=this.tryDedentOnCloseBracket(e,c,t);if(s)return s;const i=function(t){const{state:e,char:o,config:r}=t;if(!p(e.selection))return{kind:"passthrough"};const c=e.selection,s=V.get(o);if(s&&!d(c)&&function(t,e){switch(e.surround){case"never":return!1;case"brackets":return"bracket"===t.kind;case"quotes":return"quote"===t.kind;case"languageDefined":return!0}}(s,r)){const e=function(t,e,n){const{state:o}=n,r=a(e,o.getBlockOrder());return r.from.blockId!==r.to.blockId||r.from.blockId!==n.blockId?null:{kind:"wrap",open:t.open,close:t.close}}(s,c,t);if(e)return e}return d(c)?r.overtype&&function(t,e){if(!function(t){const e=V.get(t);return"quote"===e?.kind?e:F.get(t)}(e))return!1;const o=t.state.selection;if(!p(o))return!1;const r=n(t.block),c=o.anchor.offset;if(r[c]!==e)return!1;const s=t.pairStack.peek(t.blockId,c);return Boolean(s&&s.char===e)}(t,o)?{kind:"overtype"}:s&&function(t,e){const o="quote"===t.kind?e.config.quotes:e.config.brackets;if("never"===o)return!1;const r=e.state.selection;if(!p(r))return!0;const c=n(e.block),s=r.anchor.offset;if("quote"===t.kind&&"'"===t.open&&function(t,e){if(e<=0)return!1;const n=t[e-1];return!!n&&/[A-Za-z0-9_]/.test(n)}(c,s))return!1;if("always"===o)return!0;if("beforeWhitespace"===o)return function(t,e){if(e>=t.length)return!0;const n=t[e];return!n||!!/\s/.test(n)||!!F.has(n)}(c,s);if("quote"===t.kind){const t=e.getTokenAt(e.blockId,s);return!t||"string"!==t.type&&"comment"!==t.type}return!0}(s,t)?{kind:"pair",close:s.close}:{kind:"passthrough"}:{kind:"passthrough"}}({state:e,block:c,blockId:r.anchor.blockId,char:t,config:this.resolvedPairing,pairStack:this.pairs,getTokenAt:this.getTokenAt});switch(i.kind){case"pair":return this.buildAutoPairTransaction(e,r.anchor.blockId,i.close,t);case"overtype":return this.buildOvertypeTransaction(e,r.anchor.blockId);case"wrap":return this.buildWrapTransaction(e,r.anchor.blockId,i.open,i.close);case"passthrough":return null}};tryDedentOnCloseBracket(t,e,o){if("brackets"!==this.resolvedIndent.mode)return null;if("}"!==o&&"]"!==o&&")"!==o)return null;const r=t.selection;if(!p(r)||!d(r))return null;const c=n(e),s=r.anchor.offset;if(!function(t,e){const{start:n}=U(t,e);for(let o=n;o<e;o++){const e=t[o];if(" "!==e&&"\t"!==e)return!1}return!0}(c,s))return null;const{start:i}=U(c,s);if(i===s)return null;const a=r.anchor.blockId,l=this.findTrackedCloseAfter(c,s,o,a);if(null!==l)return t.transaction("input").deleteTextAt(a,i,l).setSelection(g(a,i+1)).build();const u=Q(c.slice(i,s),this.resolvedIndent.useSpaces,this.resolvedIndent.spaceCount);if(0===u.removed.length)return null;const f=s-u.removed.length;return t.transaction("input").deleteTextAt(a,f,s).insertText(a,f,o,[]).setSelection(g(a,f+1)).build()}findTrackedCloseAfter(t,e,n,o){for(let r=e;r<t.length;r++){const e=t[r];if(" "!==e&&"\t"!==e&&"\n"!==e){if(e===n){const t=this.pairs.peek(o,r);if(t&&t.char===n)return r}return null}}return null}buildAutoPairTransaction(t,e,n,o){const r=t.selection;if(!p(r))throw new Error("buildAutoPairTransaction requires a text selection");const c=r.anchor.offset,s=`${o}${n}`,i=t.transaction("input").insertText(e,c,s,[]).setSelection(g(e,c+1)).build();return this.pendingPairOps.push({kind:"push",blockId:e,offset:c+1,char:n}),i}buildOvertypeTransaction(t,e){const n=t.selection;if(!p(n))throw new Error("buildOvertypeTransaction requires a text selection");const o=n.anchor.offset;return this.pendingPairOps.push({kind:"take",blockId:e,offset:o}),t.transaction("input").setSelection(g(e,o+1)).build()}buildWrapTransaction(t,e,n,o){const r=t.selection;if(!p(r))throw new Error("buildWrapTransaction requires a text selection");const c=function(t,e){const n=a(t,e);return{fromOffset:n.from.offset,toOffset:n.to.offset}}(r,t.getBlockOrder()),s=a(r,t.getBlockOrder()).from===r.anchor,i=c.fromOffset+1,l=c.toOffset+1,d=s?i:l,u=s?l:i;return t.transaction("input").insertText(e,c.toOffset,o,[]).insertText(e,c.fromOffset,n,[]).setSelection({anchor:{blockId:e,offset:d},head:{blockId:e,offset:u}}).build()}};function Y(t,e){const n=t.getState();if(!p(n.selection))return!1;const o=n.selection,r=n.getBlock(o.anchor.blockId);return!(!r||"code_block"!==r.type)&&e({state:n,sel:o,block:r,blockId:o.anchor.blockId,offset:o.anchor.offset})}function tt(t,e,o,r){const s={Enter:()=>function(t,e){return Y(t,({state:o,block:r,blockId:s,offset:i})=>{if(!d(o.selection))return!1;const a=n(r);if(a.endsWith("\n")&&i===a.length)return function(t,e,n){const o=t.getState(),r=n.length-1,s=c(),i=o.transaction("input").deleteTextAt(e,r,n.length).splitBlock(e,r,s).setBlockType(s,h("paragraph")).setSelection(g(s,0)).build();return t.dispatch(i),!0}(t,s,a);const l=J(e.indent.useSpaces,e.indent.spaceCount);if("brackets"===e.indent.mode&&function(t,e){return function(t,e){if(e<=0||e>=t.length)return!1;const n=t[e-1],o=t[e];return!(!n||!o)&&W[o]===n}(t,e)}(a,i)){const e=X(a,i),n=`\n${e}${l}\n${e}`,r=i+1+e.length+l.length,c=o.transaction("input").insertText(s,i,n,[]).setSelection(g(s,r)).build();return t.dispatch(c),!0}const u=`\n${function(t,e,n,o){if("none"===n)return"";const r=X(t,e);return"keep"===n?r:function(t,e){const n=function(t,e){const{start:n}=U(t,e);for(let o=e-1;o>=n;o--){const e=t[o];if(e&&" "!==e&&"\t"!==e)return e}return""}(t,e);return K.has(n)}(t,e)?r+o:r}(a,i,e.indent.mode,l)}`,p=o.transaction("input").insertText(s,i,u,[]).setSelection(g(s,i+u.length)).build();return t.dispatch(p),!0})}(t,r),Backspace:()=>function(t,e){return Y(t,({state:o,block:r,blockId:c,offset:s})=>{if(!d(o.selection))return!1;if(e.pairing.deletePair&&s>0){const i=n(r),a=i[s-1],l=i[s];if(a&&l&&function(t,e){switch(t){case"(":return")"===e;case"[":return"]"===e;case"{":return"}"===e;case'"':case"'":case"`":return e===t;default:return!1}}(a,l)){const n=e.pairStack.peek(c,s);if(n&&n.char===l){const e=o.transaction("input").deleteTextAt(c,s-1,s+1).setSelection(g(c,s-1)).build();return t.dispatch(e),!0}}}if(0!==s)return!1;const i=o.transaction("input").setBlockType(c,h("paragraph")).setSelection(o.selection).build();return t.dispatch(i),!0})}(t,r),Tab:()=>function(t,e){return Y(t,({state:o,sel:r,block:c,blockId:s,offset:l})=>{const p=J(e.indent.useSpaces,e.indent.spaceCount);if(d(r)){const e=o.transaction("input").insertText(s,l,p,[]).setSelection(g(s,l+p.length)).build();return t.dispatch(e),!0}if(r.anchor.blockId!==s||r.head.blockId!==s)return!1;const f=n(c),h=a(r,o.getBlockOrder()),k=h.from.offset,b=h.to.offset;if(!f.slice(k,b).includes("\n")){const e=o.transaction("input").deleteTextAt(s,k,b).insertText(s,k,p,[]).setSelection(g(s,k+p.length)).build();return t.dispatch(e),!0}const m=function(t,e,n,o){const r=t.lastIndexOf("\n",e-1)+1,c=[];let s=0,i=r;for(;i<n;){c.push({offset:i,text:o}),s++;const e=t.indexOf("\n",i);if(-1===e||e>=n)break;i=e+1}return{inserts:c,totalInserted:s*o.length,lineCount:s,lineStart:r}}(f,k,b,p),v=o.transaction("input");for(let t=m.inserts.length-1;t>=0;t--){const e=m.inserts[t];e&&v.insertText(s,e.offset,e.text,[])}const x=u(r,o.getBlockOrder()),C=m.lineStart,y=b+m.totalInserted,S=x?C:y,w=x?y:C;return v.setSelection(i({blockId:s,offset:S},{blockId:s,offset:w})),t.dispatch(v.build()),m.lineCount>=2&&t.announce(e.locale().indentedNLines(m.lineCount)),!0})}(t,r),"Shift-Tab":()=>function(t,e){return Y(t,({state:o,sel:r,block:c,blockId:s,offset:l})=>{const g=n(c);if(d(r))return et(t,o,s,l,g,e);if(r.anchor.blockId!==s||r.head.blockId!==s)return!1;const p=a(r,o.getBlockOrder()),f=p.from.offset,h=p.to.offset;if(!g.slice(f,h).includes("\n"))return et(t,o,s,l,g,e);const k=function(t,e,n,o,r){const c=t.lastIndexOf("\n",e-1)+1,s=[];let i=0,a=0,l=c;for(;l<n;){a++;const e=Q(t.slice(l),o,r);e.removed.length>0&&(s.push({from:l,to:l+e.removed.length}),i+=e.removed.length);const c=t.indexOf("\n",l);if(-1===c||c>=n)break;l=c+1}return{deletes:s,totalRemoved:i,lineCount:a,lineStart:c}}(g,f,h,e.indent.useSpaces,e.indent.spaceCount);if(0===k.totalRemoved)return!0;const b=o.transaction("input");for(let t=k.deletes.length-1;t>=0;t--){const e=k.deletes[t];e&&b.deleteTextAt(s,e.from,e.to)}const m=u(r,o.getBlockOrder()),v=k.lineStart,x=h-k.totalRemoved,C=m?v:Math.max(v,x),y=m?Math.max(v,x):v;return b.setSelection(i({blockId:s,offset:C},{blockId:s,offset:y})),t.dispatch(b.build()),k.lineCount>=2&&t.announce(e.locale().dedentedNLines(k.lineCount)),!0})}(t,r),Escape:()=>nt(t),ArrowDown:()=>function(t){return Y(t,({state:e,block:o,blockId:r,offset:c})=>!!d(e.selection)&&-1===n(o).indexOf("\n",c)&&(rt(t,e,r),!0))}(t),ArrowUp:()=>function(t){return Y(t,({state:e,block:o,blockId:r,offset:c})=>{if(!d(e.selection))return!1;const s=n(o).indexOf("\n");return!(-1!==s&&c>s)&&ct(t,e,r)})}(t),ArrowRight:()=>function(t){return Y(t,({state:e,block:o,blockId:r,offset:c})=>!!d(e.selection)&&c===n(o).length&&(rt(t,e,r),!0))}(t),ArrowLeft:()=>function(t){return Y(t,({state:e,blockId:n,offset:o})=>!!d(e.selection)&&0===o&&ct(t,e,n))}(t)},{insertAfter:l,toggle:p}=o;l&&(s[l]=()=>function(t){return Y(t,({blockId:e})=>(ot(t,e),!0))}(t)),p&&(s[p]=()=>t.executeCommand("toggleCodeBlock")),t.registerKeymap(s,{priority:"context"})}function et(t,e,n,o,r,c){const{start:s}=U(r,o),i=Q(r.slice(s),c.indent.useSpaces,c.indent.spaceCount);if(0===i.removed.length)return!0;const a=e.transaction("input").deleteTextAt(n,s,s+i.removed.length).setSelection(g(n,Math.max(s,o-i.removed.length))).build();return t.dispatch(a),!0}function nt(t){return Y(t,({state:e,blockId:n})=>(rt(t,e,n),!0))}function ot(t,e){const n=t.getState(),o=n.getBlock(e);if(!o)return;const s=r(o),i=c(),a=n.transaction("command").splitBlock(e,s,i).setBlockType(i,h("paragraph")).setSelection(g(i,0)).build();t.dispatch(a)}function rt(t,e,n){const o=e.getBlockOrder(),r=o.indexOf(n);if(r<o.length-1){const n=o[r+1],c=e.transaction("command").setSelection(g(n,0)).build();return void t.dispatch(c)}ot(t,n)}function ct(t,e,n){const o=e.getBlockOrder(),c=o.indexOf(n);if(c<=0)return!1;const s=o[c-1],i=e.getBlock(s),a=i?r(i):0,l=e.transaction("command").setSelection(g(s,a)).build();return t.dispatch(l),!0}function st(t,n){const o=t.getState(),c=o.selection;if(!p(c))return!1;const i=o.getBlock(c.anchor.blockId);if(!i||"code_block"===i.type)return!1;const a={language:n.defaultLanguage??"",backgroundColor:""},l=o.transaction("command");return function(t,n){if(0===r(n))return;const o=s(n);let c=0;for(const r of o)if(e(r)){if(r.text.length>0)for(const e of r.marks)t.removeMark(n.id,c,c+r.text.length,e);c+=r.text.length}else c+=1}(l,i),l.setBlockType(c.anchor.blockId,h("code_block"),a).setSelection(g(c.anchor.blockId,0)),t.dispatch(l.build()),!0}function it(e,n){const r=m(e.doc,n);if(!r)return null;const s=S(r),i=v(e,s),a=x(i,n);if(a<0)return null;const l=e.transaction("command");if(1===i.length){const t=c();return l.insertNode(s,0,o(t)),l.removeNode(s,1),l.setSelection(g(t,0)),l.build()}l.removeNode(s,a);const d=function(e,n,r,s){const i=r[s-1];if(i&&t(i)){const t=C(e,i.id,"end");if(t)return t}const a=r[s+1];if(a&&t(a)){const t=C(e,a.id,"start");if(t)return t}const l=r[s],d=y(e,"start",l&&t(l)?l.id:void 0);if(d)return d;const u=c();return n.insertNode([],0,o(u)),g(u,0)}(e,l,i,a);return l.setSelection(d),l.build()}var at=class{bundles=/* @__PURE__ */new Map;listeners=[];register(t){this.bundles.set(t.id,t);for(const e of this.listeners)e(t)}onRegister(t){this.listeners.push(t);for(const e of this.bundles.values())t(e)}get(t){return this.bundles.get(t)}getAll(){return[...this.bundles.values()]}},lt={insertAfter:"Mod-Enter",toggle:"Mod-Shift-M"},dt={defaultLanguage:"",useSpaces:!1,spaceCount:2,showCopyButton:!0},ut=new A("codeBlock"),gt=new A("syntaxHighlighter"),pt=class{languageMap=/* @__PURE__ */new Map;constructor(t){if(t)for(const e of t)this.registerLanguageInternal(e)}registerLanguage(t){this.registerLanguageInternal(t)}tokenize(t,e){const n=this.languageMap.get(e.toLowerCase());if(!n)return[];const o=[];for(const r of N(t,n))o.push({from:r.from,to:r.to,type:r.type});return o}getSupportedLanguages(){const t=/* @__PURE__ */new Set;for(const e of this.languageMap.values()){t.add(e.name);for(const n of e.aliases)t.add(n)}return[...t]}registerLanguageInternal(t){this.languageMap.set(t.name.toLowerCase(),t);for(const e of t.aliases)this.languageMap.set(e.toLowerCase(),t)}},ft={label:"Code Block",tooltip:t=>t?`Code Block (${t})`:"Code Block",enteredCodeBlock:"Entered code block. Press Escape to exit.",leftCodeBlock:"Left code block.",copyCodeAria:"Copy code",escToExit:"Esc to exit",codeBlockAriaLabel:t=>`${t} code block. Press Escape to exit.`,copiedToClipboard:"Copied to clipboard",copyFailed:"Failed to copy code",deleteCodeBlockAria:"Delete code block",deletedCodeBlock:"Code block deleted",selectLanguageAria:"Select language",languageChanged:t=>`Language changed to ${t}`,plainText:"plain",indentedNLines:t=>1===t?"1 line indented":`${t} lines indented`,dedentedNLines:t=>1===t?"1 line dedented":`${t} lines dedented`},ht=/* #__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar--Isa9OHJ.mjs"),"./locales/de.ts":()=>import("./de-Dl4QFHMa.mjs"),"./locales/es.ts":()=>import("./es-DD01rZ6N.mjs"),"./locales/fr.ts":()=>import("./fr-CfhyYN-t.mjs"),"./locales/hi.ts":()=>import("./hi-B2YB3Bo4.mjs"),"./locales/pt.ts":()=>import("./pt-DYMyMgKQ.mjs"),"./locales/ru.ts":()=>import("./ru-l73diFXn.mjs"),"./locales/zh.ts":()=>import("./zh-Baxh6v0j.mjs")});async function kt(t){return L(ht,t,ft)}var bt='[role="option"]';function mt(t,e,n,o){const r=document.createElement("div");r.className="notectl-language-picker__option",r.setAttribute("role","option"),r.setAttribute("data-language",n),r.setAttribute("aria-selected",String(o)),r.setAttribute("tabindex",o?"0":"-1"),r.textContent=e,t.appendChild(r)}function vt(t,e,n,o){const r=t.getState(),c=r.getBlock(e);if(!c||"code_block"!==c.type)return;const s=r.getNodePath(e);if(!s)return;const i={...c.attrs,[n]:o},a=r.transaction("command").setNodeAttr(s,i).build();t.dispatch(a)}var xt=class{entries=/* @__PURE__ */new Map;getTokens(t,e,n,o){const r=this.entries.get(t);if(r&&r.text===e&&r.language===n)return r.tokens;const c=o?.tokenize(e,n)??[];return this.entries.set(t,{text:e,language:n,tokens:c}),c}findTokenAt(t,e){const n=this.entries.get(t);if(!n)return;const o=n.tokens;let r=0,c=o.length-1;for(;r<=c;){const t=r+c>>>1,n=o[t];if(!n)return;if(e<n.from)c=t-1;else{if(!(e>=n.to))return n;r=t+1}}}retain(t){for(const e of this.entries.keys())t.has(e)||this.entries.delete(e)}clear(){this.entries.clear()}},Ct=class{id="code-block";name="Code Block";priority=36;config;resolvedIndent;resolvedPairing;resolvedKeymap;context=null;locale;highlighter=null;tokenCache=new xt;autoPair;constructor(t){this.config={...dt,...t},this.resolvedIndent=function(t){const e=t.indent?.useSpaces??t.useSpaces??false,n=t.indent?.spaceCount??t.spaceCount??2,o=Math.max(1,Math.min(16,Math.trunc(n)));return{mode:t.indent?.mode??"brackets",useSpaces:e,spaceCount:o}}(this.config),this.resolvedPairing=function(t){const e=t.pairing;return{brackets:e?.brackets??"languageDefined",quotes:e?.quotes??"languageDefined",overtype:e?.overtype??true,deletePair:e?.deletePair??true,surround:e?.surround??"languageDefined"}}(this.config),this.resolvedKeymap={...lt,...t?.keymap},this.autoPair=new G({resolvedIndent:this.resolvedIndent,resolvedPairing:this.resolvedPairing,getTokenAt:(t,e)=>this.tokenCache.findTokenAt(t,e),getCompositionState:()=>this.context?.getCompositionState()??null})}async init(t){this.locale=await M(t,this.config.locale,ft,kt),t.registerStyleSheet(H),this.context=t,this.highlighter=function(t,e,n){const o=e.highlighter??new pt,r=new at;return r.onRegister(t=>{t.highlighting&&o.registerLanguage&&(o.registerLanguage(t.highlighting),n.clear())}),t.registerService(j,r),r.register($),r.register(E),r.register(z),r.register(D),t.registerService(gt,{registerLanguage:t=>{o.registerLanguage?.(t),n.clear()},getSupportedLanguages:()=>o.getSupportedLanguages(),tokenize:(t,e)=>o.tokenize(t,e),getTokenAt:(t,e)=>n.findTokenAt(t,e)}),o}(t,this.config,this.tokenCache),function(t){t.registerNodeSpec({type:"code_block",group:"block",content:{allow:["text"]},selectable:!0,attrs:{language:{default:""},backgroundColor:{default:""}},toDOM(t){const e=k("pre",t.id);e.className="notectl-code-block",e.setAttribute("dir","ltr"),e.setAttribute("part","code-block");const n=document.createElement("code");return n.className="notectl-code-block__content",n.setAttribute("part","code-block-content"),e.appendChild(n),e},toHTML(t,e,n){const o=b(t.attrs?.language??""),r=b(t.attrs?.backgroundColor??""),c=o?` class="language-${o}"`:"";return`<pre dir="ltr"${r?n?.styleAttr(`background-color: ${r}`)??` style="background-color: ${r}"`:""}><code${c}>${e||""}</code></pre>`},parseHTML:[{tag:"pre",getAttrs(t){const e=t.querySelector("code"),n=e?.className.match(/language-(\S+)/)?.[1]??"";return{language:(e?.getAttribute("data-language")??"")||n}}}],sanitize:{tags:["pre","code"],attrs:["data-language","class","style"]}})}(t),this.registerNodeView(t),function(t,e){t.registerCommand("toggleCodeBlock",()=>function(t,e){const n=t.getState();if(!p(n.selection))return!1;const o=n.getBlock(n.selection.anchor.blockId);if(!o)return!1;if("code_block"===o.type){const e=n.transaction("command").setBlockType(n.selection.anchor.blockId,h("paragraph")).setSelection(n.selection).build();return t.dispatch(e),!0}return st(t,e)}(t,e)),t.registerCommand("insertCodeBlock",()=>st(t,e)),t.registerCommand("setCodeBlockLanguage",()=>!1),t.registerCommand("setCodeBlockBackground",()=>!1),t.registerCommand("exitCodeBlock",()=>nt(t)),t.registerCommand("deleteCodeBlock",()=>function(t){const e=t.getState();if(!p(e.selection))return!1;const n=e.getBlock(e.selection.anchor.blockId);if(!n||"code_block"!==n.type)return!1;const o=it(e,n.id);return!!o&&(t.dispatch(o),!0)}(t))}(t,this.config),tt(t,this.config,this.resolvedKeymap,{indent:this.resolvedIndent,pairing:this.resolvedPairing,pairStack:this.autoPair.pairStack,locale:()=>this.locale}),function(t){t.registerInputRule({pattern:/^```(\w*) $/,handler:(t,e,n,o)=>{const r=t.selection;if(!p(r))return null;if(!d(r))return null;const c=t.getBlock(r.anchor.blockId);if(!c||"paragraph"!==c.type)return null;const s={language:e[1]??"",backgroundColor:""};return t.transaction("input").deleteTextAt(r.anchor.blockId,n,n+e[0].length).setBlockType(r.anchor.blockId,h("code_block"),s).setSelection(g(r.anchor.blockId,0)).build()}})}(t),function(t,e,n){t.registerToolbarItem({id:"code_block",group:"block",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z"/><path d="M11 14.17L8.83 12 11 9.83 9.59 8.41 6 12l3.59 3.59L11 14.17zm3.41 1.42L18 12l-3.59-3.59L13 9.83 15.17 12 13 14.17l1.41 1.42z"/></svg>',label:e.label,tooltip:e.tooltip(n?P(n):void 0),command:"toggleCodeBlock",isActive:t=>!!p(t.selection)&&"code_block"===t.getBlock(t.selection.anchor.blockId)?.type})}(t,this.locale,this.resolvedKeymap.toggle),function(t){t.registerMiddleware((t,e,n)=>{if(!t.steps.some(t=>"addMark"===t.type&&"code_block"===e.getBlock(t.blockId)?.type))return void n(t);const o=t.steps.filter(t=>"addMark"!==t.type||"code_block"!==e.getBlock(t.blockId)?.type);n({...t,steps:o})},{name:"code-block:mark-guard",priority:50})}(t),function(t,e,n){t.registerService(ut,{setLanguage(e,n){vt(t,e,"language",n)},getLanguage(t){const e=n();if(!e)return"";const o=e.getState().getBlock(t);return o&&"code_block"===o.type?o.attrs?.language??"":""},setBackground(e,n){vt(t,e,"backgroundColor",n)},getBackground(t){const e=n();if(!e)return"";const o=e.getState().getBlock(t);return o&&"code_block"===o.type?o.attrs?.backgroundColor??"":""},isCodeBlock(t){const e=n();return!!e&&"code_block"===e.getState().getBlock(t)?.type},getSupportedLanguages(){const t=e();return t?t.getSupportedLanguages():[]}})}(t,()=>this.highlighter,()=>this.context),function(t){t.registerPasteInterceptor((t,e,n)=>{if(!t)return null;if(!p(n.selection))return null;const o=n.getBlock(n.selection.anchor.blockId);if(!o||"code_block"!==o.type)return null;const r=n.transaction("paste");let c=n.selection.anchor.blockId,s=n.selection.anchor.offset;if(!d(n.selection)){const t=f(n,r);t&&(c=t,s=0)}return r.insertText(c,s,t,[]),r.setSelection(g(c,s+t.length)),r.build()},{name:"code-block:paste",priority:10})}(t),t.registerTextInputInterceptor(this.autoPair.handleTextInput,{name:"code-block:auto-pair",priority:10}),function(t){const e=t.getSchemaRegistry(),n=e.getNodeSpec("table_cell");if(!n?.content)return;const o=n.content.allow??[];o.includes("code_block")||(e.removeNodeSpec("table_cell"),e.registerNodeSpec({...n,content:{...n.content,allow:[...o,"code_block"]}}))}(t)}destroy(){this.context=null,this.highlighter=null,this.tokenCache.clear(),this.autoPair.clear()}onStateChange(t,e,n){if(this.autoPair.syncOnStateChange(e,n),!this.context)return;const o=p(t.selection)?t.selection.anchor.blockId:null,r=p(e.selection)?e.selection.anchor.blockId:null,c=o?t.getBlock(o):void 0,s=r?e.getBlock(r):void 0,i="code_block"===c?.type,a="code_block"===s?.type;!i&&a?this.context.announce(this.locale.enteredCodeBlock):i&&!a&&this.context.announce(this.locale.leftCodeBlock)}decorations(t){return function(t,e){const o=[],r=function(t){if(!p(t.selection))return null;const e=t.selection.anchor.blockId;return"code_block"===t.getBlock(e)?.type?e:null}(t);if(r&&o.push(w(r,{class:"notectl-code-block--focused"})),e.highlighter){const r=/* @__PURE__ */new Set;for(const c of t.getBlockOrder()){const s=t.getBlock(c);if(!s||"code_block"!==s.type)continue;const i=s.attrs?.language??"";if(!i)continue;const a=n(s);if(!a)continue;r.add(c);const l=e.tokenCache.getTokens(c,a,i,e.highlighter);for(const t of l)o.push(_(c,t.from,t.to,{class:`notectl-token--${t.type}`}))}e.tokenCache.retain(r)}return 0===o.length?I.empty:I.create(o)}(t,{highlighter:this.highlighter,tokenCache:this.tokenCache})}registerNodeView(t){const e=new O(t.getContainer()),o=this.highlighter,r={popupManager:e,getSupportedLanguages:()=>o?.getSupportedLanguages()??[]};t.registerNodeView("code_block",function(t,e=ft,o){return(r,c,s)=>{const i=document.createElement("pre");i.className="notectl-code-block",i.setAttribute("data-block-id",r.id),i.setAttribute("dir","ltr"),i.setAttribute("role","group"),i.setAttribute("aria-roledescription","code block"),i.setAttribute("part","code-block");const a=document.createElement("div");a.className="notectl-code-block__header",a.setAttribute("contenteditable","false"),a.setAttribute("part","code-block-header");const l=document.createElement("button");l.className="notectl-code-block__language-btn",l.type="button",l.setAttribute("aria-haspopup","listbox"),l.setAttribute("aria-expanded","false"),l.setAttribute("aria-label",e.selectLanguageAria);let d=null;!1!==t.showCopyButton&&(d=document.createElement("button"),d.className="notectl-code-block__copy",d.setAttribute("aria-label",e.copyCodeAria),d.setAttribute("data-notectl-no-print",""),d.type="button",d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>');const u=document.createElement("button");u.className="notectl-code-block__delete",u.setAttribute("aria-label",e.deleteCodeBlockAria),u.title=e.deleteCodeBlockAria,u.setAttribute("data-notectl-no-print",""),u.type="button",u.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>';const g=document.createElement("span");g.className="notectl-sr-only",g.setAttribute("aria-live","assertive"),g.setAttribute("aria-atomic","true");const p=document.createElement("div");p.className="notectl-code-block__actions",d&&p.appendChild(d),p.appendChild(u),a.appendChild(l),a.appendChild(p),a.appendChild(g);const f=document.createElement("code");f.className="notectl-code-block__content",f.setAttribute("part","code-block-content");const h=document.createElement("div");h.className="notectl-code-block__esc-hint",h.setAttribute("contenteditable","false"),h.setAttribute("aria-hidden","true"),h.setAttribute("data-notectl-no-print",""),h.textContent=e.escToExit,i.appendChild(a),i.appendChild(f),i.appendChild(h),t.background&&B(i,"--notectl-code-block-bg",t.background),t.headerBackground&&B(i,"--notectl-code-block-header-bg",t.headerBackground),t.textColor&&B(i,"--notectl-code-block-color",t.textColor),t.headerColor&&B(i,"--notectl-code-block-header-color",t.headerColor);let k=r.id;function b(t){const n=t.attrs?.language??"",r=n||e.plainText;l.innerHTML="";const c=document.createElement("span");if(c.className="notectl-code-block__language",c.textContent=r,l.appendChild(c),o){const t=document.createElement("span");t.className="notectl-code-block__chevron",t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="10" height="10"><path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',l.appendChild(t)}i.setAttribute("aria-label",e.codeBlockAriaLabel(r)),n?f.setAttribute("data-language",n):f.removeAttribute("data-language"),B(i,"backgroundColor",(t.attrs?.backgroundColor??"")||"")}function m(t){g.textContent=t,setTimeout(()=>{g.textContent=""},1e3)}return b(r),d&&d.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const o=c().getBlock(k);o&&function(t){const e=globalThis.navigator?.clipboard;return e&&"function"==typeof e.writeText?e.writeText(t):Promise.reject(/* @__PURE__ */new Error("Clipboard API unavailable"))}(n(o)).then(()=>m(e.copiedToClipboard),()=>m(e.copyFailed))}),u.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const n=it(c(),k);n&&(g.textContent=e.deletedCodeBlock,s(n))}),o&&l.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const n=c().getBlock(k);if(!n)return;const r=n.attrs?.language??"";!function(t){const{anchor:e,languages:n,currentLanguage:o,onSelect:r,popupManager:c,locale:s}=t;c.open({anchor:e,ariaRole:"listbox",ariaLabel:s.selectLanguageAria,className:"notectl-language-picker",position:"below-start",restoreFocusTo:e,content(t,e){const c=o.toLowerCase();mt(t,s.plainText,"",""===c);const i=[...n].sort((t,e)=>t.localeCompare(e));for(const n of i)mt(t,n,n,c===n.toLowerCase());q({container:t,itemSelector:bt,onSelect(t){r(t.getAttribute("data-language")??""),e()},onClose(){e()}}),t.addEventListener("click",t=>{const n=t.target.closest(bt);n&&(r(n.getAttribute("data-language")??""),e())})},onClose(){e.setAttribute("aria-expanded","false")}}),e.setAttribute("aria-expanded","true")}({anchor:l,languages:o.getSupportedLanguages(),currentLanguage:r,locale:e,popupManager:o.popupManager,onSelect(t){if(t===r)return;const n=c(),o=n.getBlock(k);if(!o)return;const i=n.getNodePath(k);if(!i)return;const a={...o.attrs,language:t};s(n.transaction("command").setNodeAttr(i,a).build());const l=t||e.plainText;m(e.languageChanged(l))}})}),{dom:i,contentDOM:f,update:t=>"code_block"===t.type&&(k=t.id,i.setAttribute("data-block-id",t.id),b(t),!0),selectNode(){i.classList.add("notectl-code-block--selected")},deselectNode(){i.classList.remove("notectl-code-block--selected")},destroy(){}}}}(this.config,this.locale,r))}};export{ut as a,pt as i,ft as n,gt as o,kt as r,Ct as t};
|
|
2
|
-
//# sourceMappingURL=CodeBlockPlugin-DC0-BnNy.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockPlugin-DC0-BnNy.mjs","names":[],"sources":["../../src/editor/styles/code-block.ts","../../src/plugins/code-block/BracketPairing.ts","../../src/plugins/code-block/IndentHelpers.ts","../../src/plugins/code-block/PairStack.ts","../../src/plugins/code-block/AutoPairController.ts","../../src/plugins/code-block/CodeBlockKeyboardHandlers.ts","../../src/plugins/code-block/CodeBlockCommands.ts","../../src/plugins/code-block/CodeBlockDecorations.ts","../../src/plugins/language/LanguageRegistry.ts","../../src/plugins/code-block/CodeBlockTypes.ts","../../src/plugins/code-block/highlighter/RegexTokenizer.ts","../../src/plugins/code-block/CodeBlockHighlighting.ts","../../src/plugins/code-block/CodeBlockLocale.ts","../../src/plugins/code-block/LanguagePicker.ts","../../src/plugins/code-block/CodeBlockNodeView.ts","../../src/plugins/code-block/CodeBlockSchema.ts","../../src/plugins/code-block/CodeBlockService.ts","../../src/plugins/code-block/TokenCache.ts","../../src/plugins/code-block/CodeBlockPlugin.ts"],"sourcesContent":["import { SYNTAX_TOKEN_TYPES } from '../theme/SyntaxTokenTypes.js';\n\n/** Generates per-token CSS rules from the canonical token type list. */\nfunction generateTokenCSS(): string {\n\treturn SYNTAX_TOKEN_TYPES.map(\n\t\t(type) =>\n\t\t\t`.notectl-token--${type} {\\n\\tcolor: var(--notectl-code-token-${type});\\n\\tfont-style: var(--notectl-code-token-${type}-font-style, inherit);\\n\\tfont-weight: var(--notectl-code-token-${type}-font-weight, inherit);\\n}`,\n\t).join('\\n');\n}\n\n/** Code block styles — syntax highlighting container, header, copy button. */\nexport const CODE_BLOCK_CSS = `\n/* Code Block — uses theme custom properties */\n.notectl-code-block {\n\tposition: relative;\n\tmargin: 8px 0;\n\tborder-radius: 6px;\n\tbackground: var(--notectl-code-block-bg);\n\tcolor: var(--notectl-code-block-color);\n\tfont-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace;\n\tfont-size: 14px;\n\tline-height: 1.5;\n\toverflow: hidden;\n}\n\n.notectl-code-block__header {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tpadding: 6px 12px;\n\tbackground: var(--notectl-code-block-header-bg);\n\tborder-bottom: 1px solid var(--notectl-code-block-header-border);\n\tfont-size: 12px;\n\tcolor: var(--notectl-code-block-header-color);\n\tuser-select: none;\n}\n\n.notectl-code-block__language-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 4px;\n\tborder: none;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcolor: var(--notectl-code-block-header-color);\n\tcursor: pointer;\n\tpadding: 2px 6px;\n\tfont-size: inherit;\n\tfont-family: inherit;\n\ttransition: background 0.15s;\n}\n\n.notectl-code-block__language-btn:hover {\n\tbackground: rgba(128, 128, 128, 0.15);\n}\n\n.notectl-code-block__language-btn:focus-visible {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 1px;\n}\n\n.notectl-code-block__language {\n\tfont-weight: 500;\n\tletter-spacing: 0.02em;\n}\n\n.notectl-code-block__chevron {\n\tdisplay: inline-flex;\n\talign-items: center;\n\topacity: 0.6;\n}\n\n.notectl-code-block__actions {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 2px;\n}\n\n.notectl-code-block__copy,\n.notectl-code-block__delete {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 24px;\n\theight: 24px;\n\tborder: none;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcolor: var(--notectl-code-block-header-color);\n\tcursor: pointer;\n\tpadding: 0;\n\ttransition: background 0.15s, color 0.15s;\n}\n\n.notectl-code-block__copy:hover,\n.notectl-code-block__delete:hover {\n\tbackground: rgba(128, 128, 128, 0.15);\n\tcolor: var(--notectl-code-block-color);\n}\n\n.notectl-code-block__copy svg,\n.notectl-code-block__delete svg {\n\tfill: currentColor;\n}\n\n.notectl-code-block__content {\n\tdisplay: block;\n\tpadding: 12px 16px;\n\twhite-space: pre-wrap;\n\tword-wrap: break-word;\n\ttab-size: 4;\n\t-moz-tab-size: 4;\n\toutline: none;\n\tmin-height: 1.5em;\n}\n\n.notectl-code-block--selected {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n}\n\n.notectl-code-block__esc-hint {\n\tdisplay: none;\n\tposition: absolute;\n\tbottom: 4px;\n\tinset-inline-end: 8px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-code-block-header-color);\n\topacity: 0.5;\n\tpointer-events: none;\n\tuser-select: none;\n\tfont-family: system-ui, sans-serif;\n}\n\n.notectl-code-block--focused .notectl-code-block__esc-hint {\n\tdisplay: block;\n}\n\n/* Language picker popup */\n.notectl-language-picker {\n\tmin-width: 120px;\n\tmax-height: 200px;\n\toverflow-y: auto;\n\tpadding: 4px;\n\tbackground: var(--notectl-surface-raised, #fff);\n\tborder: 1px solid var(--notectl-border, #e0e0e0);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);\n}\n\n.notectl-language-picker__option {\n\tpadding: 6px 10px;\n\tborder-radius: 4px;\n\tcursor: pointer;\n\tfont-size: 13px;\n\tcolor: var(--notectl-fg, #333);\n\twhite-space: nowrap;\n}\n\n.notectl-language-picker__option:hover {\n\tbackground: rgba(128, 128, 128, 0.1);\n}\n\n.notectl-language-picker__option:focus {\n\toutline: none;\n\tbackground: rgba(128, 128, 128, 0.15);\n}\n\n.notectl-language-picker__option[aria-selected=\"true\"] {\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary, #2563eb);\n}\n\n/* Syntax highlighting token classes — generated from canonical token type list */\n${generateTokenCSS()}\n`;\n","/**\n * BracketPairing: resolves the action that should be taken when the user\n * types a printable character that could trigger auto-pairing, overtype,\n * surround, or quote suppression inside a code block.\n *\n * The resolver is a pure function — it consumes the current state, the\n * incoming char, a token lookup and the auto-pair stack, and returns a\n * typed action that the keyboard / interceptor layer applies. No DOM, no\n * dispatch.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockText } from '../../model/Document.js';\nimport {\n\ttype Selection,\n\tisCollapsed,\n\tisTextSelection,\n\tselectionRange,\n} from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { ResolvedPairingConfig, SyntaxToken } from './CodeBlockTypes.js';\nimport type { PairStack } from './PairStack.js';\n\n// --- Pair definitions ---\n\nexport interface PairDefinition {\n\treadonly open: string;\n\treadonly close: string;\n\treadonly kind: 'bracket' | 'quote';\n}\n\nexport const PAIR_DEFINITIONS: readonly PairDefinition[] = [\n\t{ open: '(', close: ')', kind: 'bracket' },\n\t{ open: '[', close: ']', kind: 'bracket' },\n\t{ open: '{', close: '}', kind: 'bracket' },\n\t{ open: '\"', close: '\"', kind: 'quote' },\n\t{ open: \"'\", close: \"'\", kind: 'quote' },\n\t{ open: '`', close: '`', kind: 'quote' },\n];\n\nconst OPEN_TO_PAIR: ReadonlyMap<string, PairDefinition> = new Map(\n\tPAIR_DEFINITIONS.map((d) => [d.open, d]),\n);\nconst CLOSE_TO_PAIR: ReadonlyMap<string, PairDefinition> = new Map(\n\t// For brackets close !== open, for quotes close === open\n\tPAIR_DEFINITIONS.filter((d) => d.kind === 'bracket').map((d) => [d.close, d]),\n);\n\n// --- Action variants ---\n\nexport type PairAction =\n\t| { readonly kind: 'pair'; readonly close: string }\n\t| { readonly kind: 'overtype' }\n\t| { readonly kind: 'wrap'; readonly open: string; readonly close: string }\n\t| { readonly kind: 'passthrough' };\n\n// --- Lookups injected by the caller ---\n\nexport type TokenLookup = (blockId: BlockId, offset: number) => SyntaxToken | undefined;\n\n// --- Resolver ---\n\nexport interface ResolvePairContext {\n\treadonly state: EditorState;\n\treadonly block: BlockNode;\n\treadonly blockId: BlockId;\n\treadonly char: string;\n\treadonly config: ResolvedPairingConfig;\n\treadonly pairStack: PairStack;\n\treadonly getTokenAt: TokenLookup;\n}\n\n/**\n * Decides what to do when the user types `char` inside a code block.\n * Returns a `PairAction` describing the next step.\n */\nexport function resolvePairAction(ctx: ResolvePairContext): PairAction {\n\tconst { state, char, config } = ctx;\n\tif (!isTextSelection(state.selection)) return { kind: 'passthrough' };\n\n\tconst sel = state.selection;\n\tconst definition: PairDefinition | undefined = OPEN_TO_PAIR.get(char);\n\n\t// Wrap takes precedence over suppression when there is a range selection.\n\tif (definition && !isCollapsed(sel) && surroundEnabled(definition, config)) {\n\t\tconst wrap = tryWrapAction(definition, sel, ctx);\n\t\tif (wrap) return wrap;\n\t}\n\n\tif (!isCollapsed(sel)) return { kind: 'passthrough' };\n\n\t// Overtype: user typed a close char that matches the next char and was\n\t// auto-inserted by us.\n\tif (config.overtype && shouldOvertype(ctx, char)) {\n\t\treturn { kind: 'overtype' };\n\t}\n\n\tif (!definition) return { kind: 'passthrough' };\n\n\t// Suppression checks for collapsed-cursor auto-pair.\n\tif (!pairingAllowed(definition, ctx)) return { kind: 'passthrough' };\n\n\treturn { kind: 'pair', close: definition.close };\n}\n\nfunction tryWrapAction(\n\tdef: PairDefinition,\n\tsel: Selection,\n\tctx: ResolvePairContext,\n): PairAction | null {\n\tconst { state } = ctx;\n\tconst order = state.getBlockOrder();\n\tconst range = selectionRange(sel, order);\n\tif (range.from.blockId !== range.to.blockId) return null;\n\tif (range.from.blockId !== ctx.blockId) return null;\n\treturn { kind: 'wrap', open: def.open, close: def.close };\n}\n\nfunction shouldOvertype(ctx: ResolvePairContext, char: string): boolean {\n\tconst closeDef: PairDefinition | undefined = closeDefinitionFor(char);\n\tif (!closeDef) return false;\n\n\tconst sel = ctx.state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tconst text: string = getBlockText(ctx.block);\n\tconst offset: number = sel.anchor.offset;\n\tif (text[offset] !== char) return false;\n\n\t// Only overtype if this exact close char was recorded by an auto-pair.\n\tconst entry = ctx.pairStack.peek(ctx.blockId, offset);\n\treturn Boolean(entry && entry.char === char);\n}\n\n/**\n * Returns the pair definition where `char` is a close char. Quotes are\n * symmetric, so `OPEN_TO_PAIR` is checked first for them.\n */\nfunction closeDefinitionFor(char: string): PairDefinition | undefined {\n\tconst symmetric = OPEN_TO_PAIR.get(char);\n\tif (symmetric?.kind === 'quote') return symmetric;\n\treturn CLOSE_TO_PAIR.get(char);\n}\n\nfunction surroundEnabled(def: PairDefinition, config: ResolvedPairingConfig): boolean {\n\tswitch (config.surround) {\n\t\tcase 'never':\n\t\t\treturn false;\n\t\tcase 'brackets':\n\t\t\treturn def.kind === 'bracket';\n\t\tcase 'quotes':\n\t\t\treturn def.kind === 'quote';\n\t\tcase 'languageDefined':\n\t\t\treturn true;\n\t}\n}\n\nfunction pairingAllowed(def: PairDefinition, ctx: ResolvePairContext): boolean {\n\tconst mode: 'always' | 'languageDefined' | 'beforeWhitespace' | 'never' =\n\t\tdef.kind === 'quote' ? ctx.config.quotes : ctx.config.brackets;\n\tif (mode === 'never') return false;\n\n\tconst sel = ctx.state.selection;\n\tif (!isTextSelection(sel)) return true;\n\tconst text: string = getBlockText(ctx.block);\n\tconst offset: number = sel.anchor.offset;\n\n\tif (def.kind === 'quote' && def.open === \"'\" && isApostropheContext(text, offset)) {\n\t\treturn false;\n\t}\n\n\tif (mode === 'always') return true;\n\tif (mode === 'beforeWhitespace') {\n\t\treturn isFollowingCharCompatibleForPair(text, offset);\n\t}\n\t// languageDefined\n\tif (def.kind === 'quote') {\n\t\tconst token = ctx.getTokenAt(ctx.blockId, offset);\n\t\tif (!token) {\n\t\t\t// Cache miss: fall back to always-allow (safe default).\n\t\t\treturn true;\n\t\t}\n\t\tif (token.type === 'string' || token.type === 'comment') return false;\n\t\treturn true;\n\t}\n\t// Brackets always pair under languageDefined\n\treturn true;\n}\n\n/**\n * VS-Code-style apostrophe suppression: `'` directly after a word char\n * `[A-Za-z0-9_]` is *not* paired (so `don't`, `it's` work).\n */\nfunction isApostropheContext(text: string, offset: number): boolean {\n\tif (offset <= 0) return false;\n\tconst prev = text[offset - 1];\n\tif (!prev) return false;\n\treturn /[A-Za-z0-9_]/.test(prev);\n}\n\nfunction isFollowingCharCompatibleForPair(text: string, offset: number): boolean {\n\tif (offset >= text.length) return true;\n\tconst next = text[offset];\n\tif (!next) return true;\n\tif (/\\s/.test(next)) return true;\n\tif (CLOSE_TO_PAIR.has(next)) return true;\n\treturn false;\n}\n\n/**\n * Wrap-selection helper: given the open/close chars and a selection, returns\n * the offsets where the chars should be inserted in document order.\n */\nexport interface WrapPlan {\n\treadonly fromOffset: number;\n\treadonly toOffset: number;\n}\n\nexport function wrapSelectionPlan(sel: Selection, blockOrder: readonly BlockId[]): WrapPlan {\n\tconst range = selectionRange(sel, blockOrder);\n\treturn { fromOffset: range.from.offset, toOffset: range.to.offset };\n}\n","/**\n * Pure helpers for indent and bracket analysis inside code blocks.\n *\n * All helpers operate on the raw block text plus an offset; no editor state,\n * no transactions. This keeps them trivially testable and reusable from\n * keyboard handlers and the text-input interceptor alike.\n */\n\nexport interface ResolvedIndent {\n\t/** Active indent unit ('\\t' or N spaces). */\n\treadonly unit: string;\n\t/** Whether spaces are used (mirrors config). */\n\treadonly useSpaces: boolean;\n\t/** Effective indent width in characters. */\n\treadonly width: number;\n}\n\nconst OPEN_BRACKETS = new Set(['{', '[', '(']);\nconst CLOSE_BRACKETS_TO_OPEN: Readonly<Record<string, string>> = {\n\t'}': '{',\n\t']': '[',\n\t')': '(',\n};\n\n/** Returns the inclusive line range `[start, end)` covering `offset`. */\nexport function getLineRange(text: string, offset: number): { start: number; end: number } {\n\tconst start: number = text.lastIndexOf('\\n', offset - 1) + 1;\n\tconst nlIndex: number = text.indexOf('\\n', offset);\n\tconst end: number = nlIndex === -1 ? text.length : nlIndex;\n\treturn { start, end };\n}\n\n/** Returns the leading whitespace (tabs/spaces only) of the line covering `offset`. */\nexport function getCurrentLineIndent(text: string, offset: number): string {\n\tconst { start, end } = getLineRange(text, offset);\n\tlet i: number = start;\n\twhile (i < end) {\n\t\tconst ch = text[i];\n\t\tif (ch !== ' ' && ch !== '\\t') break;\n\t\ti++;\n\t}\n\treturn text.slice(start, i);\n}\n\n/**\n * Returns the last non-whitespace character of `text` in the range\n * `[lineStart, cursorOffset)`, or `''` if the entire prefix is whitespace.\n * The cursor itself is excluded.\n */\nexport function lastNonWhitespaceCharBeforeCursor(text: string, cursorOffset: number): string {\n\tconst { start } = getLineRange(text, cursorOffset);\n\tfor (let i = cursorOffset - 1; i >= start; i--) {\n\t\tconst ch = text[i];\n\t\tif (ch && ch !== ' ' && ch !== '\\t') return ch;\n\t}\n\treturn '';\n}\n\n/** True if the prefix `[lineStart, cursorOffset)` contains only whitespace. */\nexport function isWhitespaceOnlyBeforeOffset(text: string, cursorOffset: number): boolean {\n\tconst { start } = getLineRange(text, cursorOffset);\n\tfor (let i = start; i < cursorOffset; i++) {\n\t\tconst ch = text[i];\n\t\tif (ch !== ' ' && ch !== '\\t') return false;\n\t}\n\treturn true;\n}\n\n/**\n * True if the prefix up to `cursorOffset` ends with an open bracket\n * (`{`, `[`, `(`) — ignoring trailing whitespace.\n */\nexport function endsWithOpenBracket(text: string, cursorOffset: number): boolean {\n\tconst last: string = lastNonWhitespaceCharBeforeCursor(text, cursorOffset);\n\treturn OPEN_BRACKETS.has(last);\n}\n\n/**\n * True if the user just typed Enter between a matching open/close pair\n * (e.g. `{|}`, `[|]`, `(|)`). Checks the next char at cursor against the\n * char before the cursor; only matches direct pairs without intervening\n * whitespace.\n */\nexport function isBetweenBracketPair(text: string, cursorOffset: number): boolean {\n\tif (cursorOffset <= 0 || cursorOffset >= text.length) return false;\n\tconst before = text[cursorOffset - 1];\n\tconst after = text[cursorOffset];\n\tif (!before || !after) return false;\n\tconst expectedOpen: string | undefined = CLOSE_BRACKETS_TO_OPEN[after];\n\treturn expectedOpen === before;\n}\n\n/**\n * Returns the unit string for the resolved indent config.\n * `'\\t'` for tabs, `' '.repeat(spaceCount)` for spaces.\n */\nexport function resolveIndentUnit(useSpaces: boolean, spaceCount: number): string {\n\treturn useSpaces ? ' '.repeat(spaceCount) : '\\t';\n}\n\n/**\n * Removes exactly one indent unit from the start of `line`. If `line`\n * does not start with a full unit, removes whatever leading whitespace\n * exists up to the unit length (so a partially-indented line still loses\n * its leading whitespace). Returns `{ removed, rest }`.\n */\nexport function dedentOnce(\n\tline: string,\n\tuseSpaces: boolean,\n\tspaceCount: number,\n): { removed: string; rest: string } {\n\tif (line.length === 0) return { removed: '', rest: line };\n\tif (!useSpaces) {\n\t\tif (line[0] === '\\t') return { removed: '\\t', rest: line.slice(1) };\n\t\t// fall through: try removing up to `spaceCount` leading spaces\n\t}\n\tlet i = 0;\n\twhile (i < spaceCount && line[i] === ' ') i++;\n\treturn { removed: line.slice(0, i), rest: line.slice(i) };\n}\n\n/**\n * Returns the indentation that should be inserted *after* the newline when\n * the user presses Enter on the line covering `cursorOffset`. Combines the\n * line's existing leading whitespace with an extra indent step if the\n * prefix ends with an open bracket and `mode === 'brackets'`.\n */\nexport function nextIndentLevel(\n\ttext: string,\n\tcursorOffset: number,\n\tmode: 'none' | 'keep' | 'brackets',\n\tunit: string,\n): string {\n\tif (mode === 'none') return '';\n\tconst base: string = getCurrentLineIndent(text, cursorOffset);\n\tif (mode === 'keep') return base;\n\tif (endsWithOpenBracket(text, cursorOffset)) return base + unit;\n\treturn base;\n}\n\n/**\n * True if the prefix triggers the 3-line block-pattern: `{|}` (or `[|]`,\n * `(|)`) where cursor is exactly between an open/close pair. Used by the\n * Enter handler to expand the cursor onto its own indented line.\n */\nexport function shouldOpenIndentBlock(text: string, cursorOffset: number): boolean {\n\treturn isBetweenBracketPair(text, cursorOffset);\n}\n","/**\n * Auto-pair tracking stack: records the position of each auto-inserted\n * close character so that overtype (Bracket-Skip) and pair-delete only\n * fire on chars *we* produced — never on chars the user typed themselves.\n *\n * Positions are migrated through `Transaction.mapping` after every state\n * change. The single non-trivial choice is the association bias for\n * `mapResult`: we use `+1` (\"sticky right\") so an insert *at* the close\n * char's position lands left of the close char, matching the user\n * intuition \"I'm typing before this auto-paired `)`\".\n */\n\nimport type { Position } from '../../model/Selection.js';\nimport { createPosition } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { Mapping } from '../../state/Mapping.js';\n\nexport interface PairEntry {\n\treadonly pos: Position;\n\treadonly char: string;\n}\n\n/** Per-block stack of auto-pair entries. */\nexport class PairStack {\n\tprivate readonly buckets = new Map<BlockId, PairEntry[]>();\n\n\t/** Records a new auto-inserted close char at `pos`. */\n\tpush(pos: Position, char: string): void {\n\t\tconst bucket: PairEntry[] = this.buckets.get(pos.blockId) ?? [];\n\t\tbucket.push({ pos, char });\n\t\tthis.buckets.set(pos.blockId, bucket);\n\t}\n\n\t/**\n\t * Finds (and removes) an entry whose position matches `blockId`/`offset`\n\t * exactly. Returns the entry or `undefined` if no match.\n\t */\n\ttake(blockId: BlockId, offset: number): PairEntry | undefined {\n\t\tconst bucket: PairEntry[] | undefined = this.buckets.get(blockId);\n\t\tif (!bucket) return undefined;\n\t\tfor (let i = bucket.length - 1; i >= 0; i--) {\n\t\t\tconst entry: PairEntry | undefined = bucket[i];\n\t\t\tif (entry && entry.pos.offset === offset) {\n\t\t\t\tbucket.splice(i, 1);\n\t\t\t\tif (bucket.length === 0) this.buckets.delete(blockId);\n\t\t\t\treturn entry;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Returns (without removing) an entry whose position matches. */\n\tpeek(blockId: BlockId, offset: number): PairEntry | undefined {\n\t\tconst bucket: PairEntry[] | undefined = this.buckets.get(blockId);\n\t\tif (!bucket) return undefined;\n\t\tfor (let i = bucket.length - 1; i >= 0; i--) {\n\t\t\tconst entry: PairEntry | undefined = bucket[i];\n\t\t\tif (entry && entry.pos.offset === offset) return entry;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Clears all entries for the given block (used on code_block → paragraph). */\n\tclearBlock(blockId: BlockId): void {\n\t\tthis.buckets.delete(blockId);\n\t}\n\n\t/** Drops every recorded entry — used on plugin destroy/HMR. */\n\tclear(): void {\n\t\tthis.buckets.clear();\n\t}\n\n\t/** Number of recorded entries for a block; primarily for diagnostics/tests. */\n\tsizeForBlock(blockId: BlockId): number {\n\t\treturn this.buckets.get(blockId)?.length ?? 0;\n\t}\n\n\t/** Aggregate size across all blocks. */\n\tget size(): number {\n\t\tlet total = 0;\n\t\tfor (const bucket of this.buckets.values()) total += bucket.length;\n\t\treturn total;\n\t}\n\n\t/**\n\t * Migrates every recorded position through `mapping`. Entries that fall\n\t * inside removed content (or whose host block has vanished) are dropped.\n\t * Entries that change block (e.g. via split) get re-bucketed.\n\t */\n\tmigrate(mapping: Mapping): void {\n\t\tif (mapping.isEmpty) return;\n\t\tconst next = new Map<BlockId, PairEntry[]>();\n\t\tfor (const bucket of this.buckets.values()) {\n\t\t\tfor (const entry of bucket) {\n\t\t\t\tconst result = mapping.mapResult(entry.pos, +1);\n\t\t\t\tif (result.deleted) continue;\n\t\t\t\tconst migrated: PairEntry = { pos: result.pos, char: entry.char };\n\t\t\t\tconst bid: BlockId = result.pos.blockId;\n\t\t\t\tconst target: PairEntry[] = next.get(bid) ?? [];\n\t\t\t\ttarget.push(migrated);\n\t\t\t\tnext.set(bid, target);\n\t\t\t}\n\t\t}\n\t\tthis.buckets.clear();\n\t\tfor (const [bid, entries] of next) this.buckets.set(bid, entries);\n\t}\n\n\t/** Builds a position with the same shape as auto-pair entries. */\n\tstatic makePos(blockId: BlockId, offset: number): Position {\n\t\treturn createPosition(blockId, offset);\n\t}\n}\n","/**\n * Owns the auto-pairing behavior of the code-block plugin: bracket/quote\n * pairing, overtype-on-close, selection wrapping, and dedent-on-close-bracket.\n *\n * Encapsulates the mutable pair state ({@link PairStack} plus the deferred\n * push/take queue) so the plugin stays a thin orchestrator. Positions in the\n * deferred queue are expressed in *post-transaction* space and are reconciled\n * in {@link AutoPairController.syncOnStateChange} after the transaction's\n * mapping migration has run.\n */\n\nimport type { CompositionState } from '../../model/CompositionState.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockText } from '../../model/Document.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreatePosition,\n\tisCollapsed,\n\tisTextSelection,\n\tselectionRange,\n} from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { TextInputInterceptor } from '../Plugin.js';\nimport {\n\ttype PairAction,\n\ttype TokenLookup,\n\tresolvePairAction,\n\twrapSelectionPlan,\n} from './BracketPairing.js';\nimport type { ResolvedIndentConfig, ResolvedPairingConfig } from './CodeBlockTypes.js';\nimport { dedentOnce, getLineRange, isWhitespaceOnlyBeforeOffset } from './IndentHelpers.js';\nimport { PairStack } from './PairStack.js';\n\ninterface AutoPairDeps {\n\treadonly resolvedIndent: ResolvedIndentConfig;\n\treadonly resolvedPairing: ResolvedPairingConfig;\n\treadonly getTokenAt: TokenLookup;\n\t/** Returns the live composition state, or `null` when the editor is not ready. */\n\treadonly getCompositionState: () => CompositionState | null;\n}\n\ntype PendingPairOp =\n\t| {\n\t\t\treadonly kind: 'push';\n\t\t\treadonly blockId: BlockId;\n\t\t\treadonly offset: number;\n\t\t\treadonly char: string;\n\t }\n\t| { readonly kind: 'take'; readonly blockId: BlockId; readonly offset: number };\n\nexport class AutoPairController {\n\tprivate readonly resolvedIndent: ResolvedIndentConfig;\n\tprivate readonly resolvedPairing: ResolvedPairingConfig;\n\tprivate readonly getTokenAt: TokenLookup;\n\tprivate readonly getCompositionState: () => CompositionState | null;\n\n\tprivate readonly pairs = new PairStack();\n\tprivate readonly pendingPairOps: PendingPairOp[] = [];\n\n\tconstructor(deps: AutoPairDeps) {\n\t\tthis.resolvedIndent = deps.resolvedIndent;\n\t\tthis.resolvedPairing = deps.resolvedPairing;\n\t\tthis.getTokenAt = deps.getTokenAt;\n\t\tthis.getCompositionState = deps.getCompositionState;\n\t}\n\n\t/**\n\t * The shared pair-tracking stack. Exposed read-only so the keyboard handlers\n\t * can consult it for Backspace pair-delete; all mutation flows through this\n\t * controller's interceptor and {@link AutoPairController.syncOnStateChange}.\n\t */\n\tget pairStack(): PairStack {\n\t\treturn this.pairs;\n\t}\n\n\tclear(): void {\n\t\tthis.pairs.clear();\n\t\tthis.pendingPairOps.length = 0;\n\t}\n\n\t/**\n\t * Reconciles the pair stack after a transaction has been applied: migrates\n\t * tracked positions through the transaction mapping, applies the deferred\n\t * push/take ops recorded by the interceptor, then drops entries whose host\n\t * block is no longer a code block.\n\t */\n\tsyncOnStateChange(state: EditorState, tr: Transaction): void {\n\t\tif (this.pairs.size > 0 && !tr.mapping.isEmpty) {\n\t\t\tthis.pairs.migrate(tr.mapping);\n\t\t}\n\n\t\t// Apply any pending push/take operations recorded by the interceptor.\n\t\t// Positions in `pendingPairOps` are already expressed in *post-transaction*\n\t\t// space, so they must be applied AFTER the migration above (otherwise the\n\t\t// migration would shift them again).\n\t\tfor (const op of this.pendingPairOps) {\n\t\t\tif (op.kind === 'push') {\n\t\t\t\tthis.pairs.push(createPosition(op.blockId, op.offset), op.char);\n\t\t\t} else {\n\t\t\t\tthis.pairs.take(op.blockId, op.offset);\n\t\t\t}\n\t\t}\n\t\tthis.pendingPairOps.length = 0;\n\n\t\t// Clear entries whose host block is no longer a code block.\n\t\tfor (const step of tr.steps) {\n\t\t\tif (step.type !== 'setBlockType') continue;\n\t\t\tconst block: BlockNode | undefined = state.getBlock(step.blockId);\n\t\t\tif (!block || block.type !== 'code_block') {\n\t\t\t\tthis.pairs.clearBlock(step.blockId);\n\t\t\t}\n\t\t}\n\t}\n\n\treadonly handleTextInput: TextInputInterceptor = (\n\t\ttext: string,\n\t\tstate: EditorState,\n\t): Transaction | null => {\n\t\t// Drop any pending pair ops left over from a previously suppressed\n\t\t// transaction. `onStateChange` only fires when a tr reaches `state.apply`;\n\t\t// if middleware blocked the last tr, its queued ops would otherwise leak\n\t\t// into the next successful cycle with stale offsets.\n\t\tthis.pendingPairOps.length = 0;\n\n\t\tconst composition: CompositionState | null = this.getCompositionState();\n\t\tif (!composition) return null;\n\t\tif (composition.isComposing) return null;\n\t\tif (!isTextSelection(state.selection)) return null;\n\t\t// Only single-char inputs trigger pair logic.\n\t\tif (text.length !== 1) return null;\n\n\t\tconst sel = state.selection;\n\t\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\t\tif (!block || block.type !== 'code_block') return null;\n\n\t\t// Dedent-on-close-bracket: typing `}`, `]`, `)` on a whitespace-only line\n\t\t// reduces leading indent by one step before inserting the char.\n\t\tconst dedentTr: Transaction | null = this.tryDedentOnCloseBracket(state, block, text);\n\t\tif (dedentTr) return dedentTr;\n\n\t\tconst action: PairAction = resolvePairAction({\n\t\t\tstate,\n\t\t\tblock,\n\t\t\tblockId: sel.anchor.blockId,\n\t\t\tchar: text,\n\t\t\tconfig: this.resolvedPairing,\n\t\t\tpairStack: this.pairs,\n\t\t\tgetTokenAt: this.getTokenAt,\n\t\t});\n\n\t\tswitch (action.kind) {\n\t\t\tcase 'pair':\n\t\t\t\treturn this.buildAutoPairTransaction(state, sel.anchor.blockId, action.close, text);\n\t\t\tcase 'overtype':\n\t\t\t\treturn this.buildOvertypeTransaction(state, sel.anchor.blockId);\n\t\t\tcase 'wrap':\n\t\t\t\treturn this.buildWrapTransaction(state, sel.anchor.blockId, action.open, action.close);\n\t\t\tcase 'passthrough':\n\t\t\t\treturn null;\n\t\t}\n\t};\n\n\tprivate tryDedentOnCloseBracket(\n\t\tstate: EditorState,\n\t\tblock: BlockNode,\n\t\tchar: string,\n\t): Transaction | null {\n\t\tif (this.resolvedIndent.mode !== 'brackets') return null;\n\t\tif (char !== '}' && char !== ']' && char !== ')') return null;\n\n\t\tconst sel = state.selection;\n\t\tif (!isTextSelection(sel) || !isCollapsed(sel)) return null;\n\n\t\tconst text: string = getBlockText(block);\n\t\tconst offset: number = sel.anchor.offset;\n\t\tif (!isWhitespaceOnlyBeforeOffset(text, offset)) return null;\n\n\t\tconst { start } = getLineRange(text, offset);\n\t\tif (start === offset) return null; // no leading indent on this line\n\n\t\tconst blockId: BlockId = sel.anchor.blockId;\n\n\t\t// Combined dedent + overtype: when the next non-whitespace char ahead of\n\t\t// the cursor (across any newlines) is a tracked auto-paired close of the\n\t\t// same kind, collapse the gap so the user's typed close consumes the\n\t\t// auto-paired one instead of producing a duplicate.\n\t\tconst trackedClosePos: number | null = this.findTrackedCloseAfter(text, offset, char, blockId);\n\t\tif (trackedClosePos !== null) {\n\t\t\treturn state\n\t\t\t\t.transaction('input')\n\t\t\t\t.deleteTextAt(blockId, start, trackedClosePos)\n\t\t\t\t.setSelection(createCollapsedSelection(blockId, start + 1))\n\t\t\t\t.build();\n\t\t}\n\n\t\tconst lineSlice: string = text.slice(start, offset);\n\t\tconst result = dedentOnce(\n\t\t\tlineSlice,\n\t\t\tthis.resolvedIndent.useSpaces,\n\t\t\tthis.resolvedIndent.spaceCount,\n\t\t);\n\t\tif (result.removed.length === 0) return null;\n\n\t\tconst newOffset: number = offset - result.removed.length;\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.deleteTextAt(blockId, newOffset, offset)\n\t\t\t.insertText(blockId, newOffset, char, [])\n\t\t\t.setSelection(createCollapsedSelection(blockId, newOffset + 1))\n\t\t\t.build();\n\t}\n\n\t/**\n\t * Scans forward from `offset` through whitespace and newlines for a tracked\n\t * auto-paired close char matching `char`. Returns its position or `null` if\n\t * any other char (or end-of-text) is encountered first.\n\t */\n\tprivate findTrackedCloseAfter(\n\t\ttext: string,\n\t\toffset: number,\n\t\tchar: string,\n\t\tblockId: BlockId,\n\t): number | null {\n\t\tfor (let i = offset; i < text.length; i++) {\n\t\t\tconst ch: string | undefined = text[i];\n\t\t\tif (ch === ' ' || ch === '\\t' || ch === '\\n') continue;\n\t\t\tif (ch === char) {\n\t\t\t\tconst entry = this.pairs.peek(blockId, i);\n\t\t\t\tif (entry && entry.char === char) return i;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate buildAutoPairTransaction(\n\t\tstate: EditorState,\n\t\tblockId: BlockId,\n\t\tcloseChar: string,\n\t\topenChar: string,\n\t): Transaction {\n\t\tconst sel = state.selection;\n\t\tif (!isTextSelection(sel)) {\n\t\t\tthrow new Error('buildAutoPairTransaction requires a text selection');\n\t\t}\n\t\tconst offset: number = sel.anchor.offset;\n\t\tconst inserted = `${openChar}${closeChar}`;\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('input')\n\t\t\t.insertText(blockId, offset, inserted, [])\n\t\t\t.setSelection(createCollapsedSelection(blockId, offset + 1))\n\t\t\t.build();\n\t\t// Record the auto-inserted close char so overtype/pair-delete can target it.\n\t\t// The position is expressed in post-transaction space; the actual push\n\t\t// happens in `syncOnStateChange` after the mapping migration runs.\n\t\tthis.pendingPairOps.push({\n\t\t\tkind: 'push',\n\t\t\tblockId,\n\t\t\toffset: offset + 1,\n\t\t\tchar: closeChar,\n\t\t});\n\t\treturn tr;\n\t}\n\n\tprivate buildOvertypeTransaction(state: EditorState, blockId: BlockId): Transaction {\n\t\tconst sel = state.selection;\n\t\tif (!isTextSelection(sel)) {\n\t\t\tthrow new Error('buildOvertypeTransaction requires a text selection');\n\t\t}\n\t\tconst offset: number = sel.anchor.offset;\n\t\t// Schedule the take so it survives the migration phase (the entry's\n\t\t// position is in pre-transaction space, so migration will preserve it).\n\t\tthis.pendingPairOps.push({ kind: 'take', blockId, offset });\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createCollapsedSelection(blockId, offset + 1))\n\t\t\t.build();\n\t}\n\n\tprivate buildWrapTransaction(\n\t\tstate: EditorState,\n\t\tblockId: BlockId,\n\t\topenChar: string,\n\t\tcloseChar: string,\n\t): Transaction {\n\t\tconst sel = state.selection;\n\t\tif (!isTextSelection(sel)) {\n\t\t\tthrow new Error('buildWrapTransaction requires a text selection');\n\t\t}\n\t\tconst plan = wrapSelectionPlan(sel, state.getBlockOrder());\n\t\tconst range = selectionRange(sel, state.getBlockOrder());\n\t\tconst wasForward: boolean = range.from === sel.anchor;\n\t\tconst newFrom: number = plan.fromOffset + 1;\n\t\tconst newTo: number = plan.toOffset + 1;\n\t\tconst anchorOff: number = wasForward ? newFrom : newTo;\n\t\tconst headOff: number = wasForward ? newTo : newFrom;\n\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.insertText(blockId, plan.toOffset, closeChar, [])\n\t\t\t.insertText(blockId, plan.fromOffset, openChar, [])\n\t\t\t.setSelection({\n\t\t\t\tanchor: { blockId, offset: anchorOff },\n\t\t\t\thead: { blockId, offset: headOff },\n\t\t\t})\n\t\t\t.build();\n\t}\n}\n","/**\n * Keyboard handlers for code-block navigation and editing.\n * Handles Enter (with auto-indent + block-pattern), Backspace (with pair-delete),\n * Tab, Shift-Tab (with multi-line range handling), Escape, Arrow keys, and\n * configurable shortcuts (Mod+Enter, toggle).\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockLength, getBlockText } from '../../model/Document.js';\nimport {\n\ttype Selection,\n\tcreateCollapsedSelection,\n\tcreateSelection,\n\tisCollapsed,\n\tisForward,\n\tisTextSelection,\n\tselectionRange,\n} from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { CodeBlockLocale } from './CodeBlockLocale.js';\nimport type {\n\tCodeBlockConfig,\n\tCodeBlockKeymap,\n\tResolvedIndentConfig,\n\tResolvedPairingConfig,\n} from './CodeBlockTypes.js';\nimport {\n\tdedentOnce,\n\tgetCurrentLineIndent,\n\tgetLineRange,\n\tnextIndentLevel,\n\tresolveIndentUnit,\n\tshouldOpenIndentBlock,\n} from './IndentHelpers.js';\nimport type { PairStack } from './PairStack.js';\n\n// --- Context Guard ---\n\ninterface CodeBlockContext {\n\treadonly state: EditorState;\n\treadonly sel: Selection;\n\treadonly block: BlockNode;\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\nfunction withCodeBlockContext(\n\tcontext: PluginContext,\n\thandler: (ctx: CodeBlockContext) => boolean,\n): boolean {\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return false;\n\n\tconst sel: Selection = state.selection;\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block || block.type !== 'code_block') return false;\n\n\treturn handler({\n\t\tstate,\n\t\tsel,\n\t\tblock,\n\t\tblockId: sel.anchor.blockId,\n\t\toffset: sel.anchor.offset,\n\t});\n}\n\n/** Dependencies for the keyboard handlers. */\nexport interface CodeBlockKeyboardDeps {\n\treadonly indent: ResolvedIndentConfig;\n\treadonly pairing: ResolvedPairingConfig;\n\treadonly pairStack: PairStack;\n\treadonly locale: () => CodeBlockLocale;\n}\n\n/** Registers all code-block keyboard handlers. */\nexport function registerCodeBlockKeymaps(\n\tcontext: PluginContext,\n\tconfig: CodeBlockConfig,\n\tresolvedKeymap: Readonly<Record<keyof CodeBlockKeymap, string | null>>,\n\tdeps: CodeBlockKeyboardDeps,\n): void {\n\tconst keymap: Record<string, () => boolean> = {\n\t\tEnter: () => handleEnter(context, deps),\n\t\tBackspace: () => handleBackspace(context, deps),\n\t\tTab: () => handleTab(context, deps),\n\t\t'Shift-Tab': () => handleShiftTab(context, deps),\n\t\tEscape: () => handleEscape(context),\n\t\tArrowDown: () => handleArrowDown(context),\n\t\tArrowUp: () => handleArrowUp(context),\n\t\tArrowRight: () => handleArrowRight(context),\n\t\tArrowLeft: () => handleArrowLeft(context),\n\t};\n\n\tconst { insertAfter, toggle } = resolvedKeymap;\n\n\tif (insertAfter) {\n\t\tkeymap[insertAfter] = () => handleModEnter(context);\n\t}\n\tif (toggle) {\n\t\tkeymap[toggle] = () => context.executeCommand('toggleCodeBlock');\n\t}\n\n\tcontext.registerKeymap(keymap, { priority: 'context' });\n\n\t// `config` is kept in the signature for future language-defined indent rules.\n\tvoid config;\n}\n\n// --- Handler Functions ---\n\nfunction handleBackspace(context: PluginContext, deps: CodeBlockKeyboardDeps): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\t// Pair-delete: backspace between an auto-paired empty pair removes both chars.\n\t\tif (deps.pairing.deletePair && offset > 0) {\n\t\t\tconst text: string = getBlockText(block);\n\t\t\tconst before = text[offset - 1];\n\t\t\tconst after = text[offset];\n\t\t\tif (before && after && isMatchingPair(before, after)) {\n\t\t\t\tconst entry = deps.pairStack.peek(blockId, offset);\n\t\t\t\tif (entry && entry.char === after) {\n\t\t\t\t\tconst tr: Transaction = state\n\t\t\t\t\t\t.transaction('input')\n\t\t\t\t\t\t.deleteTextAt(blockId, offset - 1, offset + 1)\n\t\t\t\t\t\t.setSelection(createCollapsedSelection(blockId, offset - 1))\n\t\t\t\t\t\t.build();\n\t\t\t\t\tcontext.dispatch(tr);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (offset !== 0) return false;\n\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('input')\n\t\t\t.setBlockType(blockId, nodeType('paragraph'))\n\t\t\t.setSelection(state.selection)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n\nfunction handleEnter(context: PluginContext, deps: CodeBlockKeyboardDeps): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tif (text.endsWith('\\n') && offset === text.length) {\n\t\t\treturn exitOnDoubleEnter(context, blockId, text);\n\t\t}\n\n\t\tconst unit: string = resolveIndentUnit(deps.indent.useSpaces, deps.indent.spaceCount);\n\n\t\t// Block-pattern: cursor between matching open/close → 3-line layout.\n\t\tif (deps.indent.mode === 'brackets' && shouldOpenIndentBlock(text, offset)) {\n\t\t\tconst baseIndent: string = getCurrentLineIndent(text, offset);\n\t\t\tconst insert = `\\n${baseIndent}${unit}\\n${baseIndent}`;\n\t\t\tconst cursorOffset: number = offset + 1 + baseIndent.length + unit.length;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('input')\n\t\t\t\t.insertText(blockId, offset, insert, [])\n\t\t\t\t.setSelection(createCollapsedSelection(blockId, cursorOffset))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst indent: string = nextIndentLevel(text, offset, deps.indent.mode, unit);\n\t\tconst insert = `\\n${indent}`;\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('input')\n\t\t\t.insertText(blockId, offset, insert, [])\n\t\t\t.setSelection(createCollapsedSelection(blockId, offset + insert.length))\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n\nfunction handleTab(context: PluginContext, deps: CodeBlockKeyboardDeps): boolean {\n\treturn withCodeBlockContext(context, ({ state, sel, block, blockId, offset }) => {\n\t\tconst unit: string = resolveIndentUnit(deps.indent.useSpaces, deps.indent.spaceCount);\n\n\t\tif (isCollapsed(sel)) {\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('input')\n\t\t\t\t.insertText(blockId, offset, unit, [])\n\t\t\t\t.setSelection(createCollapsedSelection(blockId, offset + unit.length))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Range selection — must be within this code block.\n\t\tif (sel.anchor.blockId !== blockId || sel.head.blockId !== blockId) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tconst range = selectionRange(sel, state.getBlockOrder());\n\t\tconst fromOffset: number = range.from.offset;\n\t\tconst toOffset: number = range.to.offset;\n\t\tconst spansLine: boolean = text.slice(fromOffset, toOffset).includes('\\n');\n\n\t\tif (!spansLine) {\n\t\t\t// VS Code-style: replace selection with one indent unit.\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('input')\n\t\t\t\t.deleteTextAt(blockId, fromOffset, toOffset)\n\t\t\t\t.insertText(blockId, fromOffset, unit, [])\n\t\t\t\t.setSelection(createCollapsedSelection(blockId, fromOffset + unit.length))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Multi-line indent.\n\t\tconst result = indentLineRange(text, fromOffset, toOffset, unit);\n\t\tconst builder = state.transaction('input');\n\t\t// Apply in reverse so earlier offsets remain valid after each insert.\n\t\tfor (let i = result.inserts.length - 1; i >= 0; i--) {\n\t\t\tconst insert = result.inserts[i];\n\t\t\tif (!insert) continue;\n\t\t\tbuilder.insertText(blockId, insert.offset, insert.text, []);\n\t\t}\n\t\tconst wasForward: boolean = isForward(sel, state.getBlockOrder());\n\t\tconst newFrom: number = result.lineStart;\n\t\tconst newTo: number = toOffset + result.totalInserted;\n\t\tconst anchorOff: number = wasForward ? newFrom : newTo;\n\t\tconst headOff: number = wasForward ? newTo : newFrom;\n\t\tbuilder.setSelection(\n\t\t\tcreateSelection({ blockId, offset: anchorOff }, { blockId, offset: headOff }),\n\t\t);\n\t\tcontext.dispatch(builder.build());\n\n\t\tif (result.lineCount >= 2) {\n\t\t\tcontext.announce(deps.locale().indentedNLines(result.lineCount));\n\t\t}\n\t\treturn true;\n\t});\n}\n\nfunction handleShiftTab(context: PluginContext, deps: CodeBlockKeyboardDeps): boolean {\n\treturn withCodeBlockContext(context, ({ state, sel, block, blockId, offset }) => {\n\t\tconst text: string = getBlockText(block);\n\n\t\tif (isCollapsed(sel)) {\n\t\t\treturn dedentSingleLine(context, state, blockId, offset, text, deps);\n\t\t}\n\n\t\tif (sel.anchor.blockId !== blockId || sel.head.blockId !== blockId) return false;\n\n\t\tconst range = selectionRange(sel, state.getBlockOrder());\n\t\tconst fromOffset: number = range.from.offset;\n\t\tconst toOffset: number = range.to.offset;\n\t\tconst spansLine: boolean = text.slice(fromOffset, toOffset).includes('\\n');\n\n\t\tif (!spansLine) {\n\t\t\treturn dedentSingleLine(context, state, blockId, offset, text, deps);\n\t\t}\n\n\t\tconst result = dedentLineRange(\n\t\t\ttext,\n\t\t\tfromOffset,\n\t\t\ttoOffset,\n\t\t\tdeps.indent.useSpaces,\n\t\t\tdeps.indent.spaceCount,\n\t\t);\n\t\tif (result.totalRemoved === 0) {\n\t\t\t// Nothing to remove — consume the event so the browser does not move focus.\n\t\t\treturn true;\n\t\t}\n\n\t\tconst builder = state.transaction('input');\n\t\tfor (let i = result.deletes.length - 1; i >= 0; i--) {\n\t\t\tconst del = result.deletes[i];\n\t\t\tif (!del) continue;\n\t\t\tbuilder.deleteTextAt(blockId, del.from, del.to);\n\t\t}\n\t\tconst wasForward: boolean = isForward(sel, state.getBlockOrder());\n\t\tconst newFrom: number = result.lineStart;\n\t\tconst newTo: number = toOffset - result.totalRemoved;\n\t\tconst anchorOff: number = wasForward ? newFrom : Math.max(newFrom, newTo);\n\t\tconst headOff: number = wasForward ? Math.max(newFrom, newTo) : newFrom;\n\t\tbuilder.setSelection(\n\t\t\tcreateSelection({ blockId, offset: anchorOff }, { blockId, offset: headOff }),\n\t\t);\n\t\tcontext.dispatch(builder.build());\n\n\t\tif (result.lineCount >= 2) {\n\t\t\tcontext.announce(deps.locale().dedentedNLines(result.lineCount));\n\t\t}\n\t\treturn true;\n\t});\n}\n\nfunction dedentSingleLine(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tblockId: BlockId,\n\toffset: number,\n\ttext: string,\n\tdeps: CodeBlockKeyboardDeps,\n): boolean {\n\tconst { start } = getLineRange(text, offset);\n\tconst lineText: string = text.slice(start);\n\tconst removed = dedentOnce(lineText, deps.indent.useSpaces, deps.indent.spaceCount);\n\tif (removed.removed.length === 0) return true;\n\n\tconst tr: Transaction = state\n\t\t.transaction('input')\n\t\t.deleteTextAt(blockId, start, start + removed.removed.length)\n\t\t.setSelection(\n\t\t\tcreateCollapsedSelection(blockId, Math.max(start, offset - removed.removed.length)),\n\t\t)\n\t\t.build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n/**\n * Exits the code block to the next block or creates a new paragraph.\n * Exported for use by the `exitCodeBlock` command.\n */\nexport function handleEscape(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, blockId }) => {\n\t\tmoveToNextBlockOrInsertParagraph(context, state, blockId);\n\t\treturn true;\n\t});\n}\n\nfunction handleArrowDown(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tconst nextNewline: number = text.indexOf('\\n', offset);\n\t\tif (nextNewline !== -1) return false;\n\n\t\tmoveToNextBlockOrInsertParagraph(context, state, blockId);\n\t\treturn true;\n\t});\n}\n\nfunction handleArrowUp(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tconst firstNewline: number = text.indexOf('\\n');\n\t\tif (firstNewline !== -1 && offset > firstNewline) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn moveToPreviousBlockEnd(context, state, blockId);\n\t});\n}\n\nfunction handleArrowRight(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tif (offset !== text.length) return false;\n\n\t\tmoveToNextBlockOrInsertParagraph(context, state, blockId);\n\t\treturn true;\n\t});\n}\n\nfunction handleArrowLeft(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\t\tif (offset !== 0) return false;\n\n\t\treturn moveToPreviousBlockEnd(context, state, blockId);\n\t});\n}\n\nfunction handleModEnter(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ blockId }) => {\n\t\tinsertParagraphAfter(context, blockId);\n\t\treturn true;\n\t});\n}\n\n// --- Multi-line indent helpers ---\n\ninterface IndentRangeResult {\n\treadonly inserts: readonly { offset: number; text: string }[];\n\treadonly totalInserted: number;\n\treadonly lineCount: number;\n\treadonly lineStart: number;\n}\n\nfunction indentLineRange(text: string, from: number, to: number, unit: string): IndentRangeResult {\n\tconst lineStart: number = text.lastIndexOf('\\n', from - 1) + 1;\n\tconst inserts: { offset: number; text: string }[] = [];\n\tlet lineCount = 0;\n\n\tlet pos: number = lineStart;\n\twhile (pos < to) {\n\t\tinserts.push({ offset: pos, text: unit });\n\t\tlineCount++;\n\t\tconst nl: number = text.indexOf('\\n', pos);\n\t\tif (nl === -1 || nl >= to) break;\n\t\tpos = nl + 1;\n\t}\n\n\treturn {\n\t\tinserts,\n\t\ttotalInserted: lineCount * unit.length,\n\t\tlineCount,\n\t\tlineStart,\n\t};\n}\n\ninterface DedentRangeResult {\n\treadonly deletes: readonly { from: number; to: number }[];\n\treadonly totalRemoved: number;\n\treadonly lineCount: number;\n\treadonly lineStart: number;\n}\n\nfunction dedentLineRange(\n\ttext: string,\n\tfrom: number,\n\tto: number,\n\tuseSpaces: boolean,\n\tspaceCount: number,\n): DedentRangeResult {\n\tconst lineStart: number = text.lastIndexOf('\\n', from - 1) + 1;\n\tconst deletes: { from: number; to: number }[] = [];\n\tlet totalRemoved = 0;\n\tlet lineCount = 0;\n\n\tlet pos: number = lineStart;\n\twhile (pos < to) {\n\t\tlineCount++;\n\t\tconst lineSlice: string = text.slice(pos);\n\t\tconst result = dedentOnce(lineSlice, useSpaces, spaceCount);\n\t\tif (result.removed.length > 0) {\n\t\t\tdeletes.push({ from: pos, to: pos + result.removed.length });\n\t\t\ttotalRemoved += result.removed.length;\n\t\t}\n\t\tconst nl: number = text.indexOf('\\n', pos);\n\t\tif (nl === -1 || nl >= to) break;\n\t\tpos = nl + 1;\n\t}\n\n\treturn {\n\t\tdeletes,\n\t\ttotalRemoved,\n\t\tlineCount,\n\t\tlineStart,\n\t};\n}\n\n// --- Other helpers ---\n\nfunction isMatchingPair(open: string, close: string): boolean {\n\tswitch (open) {\n\t\tcase '(':\n\t\t\treturn close === ')';\n\t\tcase '[':\n\t\t\treturn close === ']';\n\t\tcase '{':\n\t\t\treturn close === '}';\n\t\tcase '\"':\n\t\tcase \"'\":\n\t\tcase '`':\n\t\t\treturn close === open;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction insertParagraphAfter(context: PluginContext, bid: BlockId): void {\n\tconst state: EditorState = context.getState();\n\tconst block: BlockNode | undefined = state.getBlock(bid);\n\tif (!block) return;\n\n\tconst blockLength: number = getBlockLength(block);\n\tconst newId: BlockId = generateBlockId();\n\n\tconst tr: Transaction = state\n\t\t.transaction('command')\n\t\t.splitBlock(bid, blockLength, newId)\n\t\t.setBlockType(newId, nodeType('paragraph'))\n\t\t.setSelection(createCollapsedSelection(newId, 0))\n\t\t.build();\n\n\tcontext.dispatch(tr);\n}\n\n/**\n * Moves the cursor to the start of the following block, or appends a fresh\n * paragraph when the code block is the last block. Shared exit tail for\n * Escape / ArrowDown / ArrowRight at the end of the code block.\n */\nfunction moveToNextBlockOrInsertParagraph(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tbid: BlockId,\n): void {\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst idx: number = blockOrder.indexOf(bid);\n\n\tif (idx < blockOrder.length - 1) {\n\t\tconst nextId: BlockId = blockOrder[idx + 1] as BlockId;\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('command')\n\t\t\t.setSelection(createCollapsedSelection(nextId, 0))\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn;\n\t}\n\n\tinsertParagraphAfter(context, bid);\n}\n\n/**\n * Moves the cursor to the end of the preceding block. Shared tail for\n * ArrowUp / ArrowLeft at the start of the code block. Returns `false` when the\n * code block is already the first block (no movement performed).\n */\nfunction moveToPreviousBlockEnd(context: PluginContext, state: EditorState, bid: BlockId): boolean {\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst idx: number = blockOrder.indexOf(bid);\n\tif (idx <= 0) return false;\n\n\tconst prevId: BlockId = blockOrder[idx - 1] as BlockId;\n\tconst prevBlock: BlockNode | undefined = state.getBlock(prevId);\n\tconst prevLen: number = prevBlock ? getBlockLength(prevBlock) : 0;\n\tconst tr: Transaction = state\n\t\t.transaction('command')\n\t\t.setSelection(createCollapsedSelection(prevId, prevLen))\n\t\t.build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\nfunction exitOnDoubleEnter(context: PluginContext, bid: BlockId, text: string): boolean {\n\tconst state: EditorState = context.getState();\n\tconst trimmedLen: number = text.length - 1;\n\tconst newId: BlockId = generateBlockId();\n\n\tconst tr: Transaction = state\n\t\t.transaction('input')\n\t\t.deleteTextAt(bid, trimmedLen, text.length)\n\t\t.splitBlock(bid, trimmedLen, newId)\n\t\t.setBlockType(newId, nodeType('paragraph'))\n\t\t.setSelection(createCollapsedSelection(newId, 0))\n\t\t.build();\n\n\tcontext.dispatch(tr);\n\treturn true;\n}\n","/**\n * Command registration and implementations for code blocks.\n * Handles toggle, insert, exit, and mark stripping.\n */\n\nimport {\n\tcreateSelectionForBlockBoundary,\n\tcreateSelectionForDocumentBoundary,\n\textractParentPath,\n\tfindSiblingIndex,\n\tgetSiblings,\n} from '../../commands/CommandHelpers.js';\nimport type { BlockNode, ChildNode } from '../../model/Document.js';\nimport {\n\tcreateEmptyParagraph,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tgetInlineChildren,\n\tisBlockNode,\n\tisTextNode,\n} from '../../model/Document.js';\nimport { findNodePath } from '../../model/NodeResolver.js';\nimport type { EditorSelection } from '../../model/Selection.js';\nimport { createCollapsedSelection, isTextSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction, TransactionBuilder } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { handleEscape } from './CodeBlockKeyboardHandlers.js';\nimport type { CodeBlockConfig } from './CodeBlockTypes.js';\n\n/** Registers all code-block commands. */\nexport function registerCodeBlockCommands(context: PluginContext, config: CodeBlockConfig): void {\n\tcontext.registerCommand('toggleCodeBlock', () => toggleCodeBlock(context, config));\n\n\tcontext.registerCommand('insertCodeBlock', () => insertCodeBlock(context, config));\n\n\tcontext.registerCommand('setCodeBlockLanguage', () => false);\n\n\tcontext.registerCommand('setCodeBlockBackground', () => false);\n\n\tcontext.registerCommand('exitCodeBlock', () => handleEscape(context));\n\n\tcontext.registerCommand('deleteCodeBlock', () => deleteCodeBlock(context));\n}\n\n// --- Command Implementations ---\n\nfunction toggleCodeBlock(context: PluginContext, config: CodeBlockConfig): boolean {\n\tconst state = context.getState();\n\tif (!isTextSelection(state.selection)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(state.selection.anchor.blockId);\n\tif (!block) return false;\n\n\tif (block.type === 'code_block') {\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('command')\n\t\t\t.setBlockType(state.selection.anchor.blockId, nodeType('paragraph'))\n\t\t\t.setSelection(state.selection)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\treturn insertCodeBlock(context, config);\n}\n\nfunction insertCodeBlock(context: PluginContext, config: CodeBlockConfig): boolean {\n\tconst state = context.getState();\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block || block.type === 'code_block') return false;\n\n\tconst attrs: Record<string, string | number | boolean> = {\n\t\tlanguage: config.defaultLanguage ?? '',\n\t\tbackgroundColor: '',\n\t};\n\n\tconst builder: TransactionBuilder = state.transaction('command');\n\tstripAllMarks(builder, block);\n\tbuilder\n\t\t.setBlockType(sel.anchor.blockId, nodeType('code_block'), attrs)\n\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0));\n\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** Deletes the code block at the current cursor position. */\nfunction deleteCodeBlock(context: PluginContext): boolean {\n\tconst state = context.getState();\n\tif (!isTextSelection(state.selection)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(state.selection.anchor.blockId);\n\tif (!block || block.type !== 'code_block') return false;\n\n\tconst tr: Transaction | null = createDeleteCodeBlockTransaction(state, block.id);\n\tif (!tr) return false;\n\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n/** Builds a transaction that removes a code block and repositions the cursor. */\nexport function createDeleteCodeBlockTransaction(\n\tstate: EditorState,\n\tblockId: BlockId,\n): Transaction | null {\n\tconst path: string[] | undefined = findNodePath(state.doc, blockId);\n\tif (!path) return null;\n\n\tconst parentPath: BlockId[] = extractParentPath(path);\n\tconst siblings = getSiblings(state, parentPath);\n\tconst index: number = findSiblingIndex(siblings, blockId);\n\tif (index < 0) return null;\n\n\tconst builder = state.transaction('command');\n\n\tif (siblings.length === 1) {\n\t\tconst newId: BlockId = generateBlockId();\n\t\tbuilder.insertNode(parentPath, 0, createEmptyParagraph(newId));\n\t\tbuilder.removeNode(parentPath, 1);\n\t\tbuilder.setSelection(createCollapsedSelection(newId, 0));\n\t\treturn builder.build();\n\t}\n\n\tbuilder.removeNode(parentPath, index);\n\n\tconst selection: EditorSelection = resolvePostDeleteSelection(state, builder, siblings, index);\n\tbuilder.setSelection(selection);\n\treturn builder.build();\n}\n\n/**\n * Determines the cursor position after a code block has been removed.\n *\n * Fallback chain — the first successful step wins, guaranteeing the caller\n * always receives a valid selection:\n * 1. End of the previous block sibling.\n * 2. Start of the next block sibling.\n * 3. Start of any other selectable block in the document.\n * 4. A freshly inserted empty paragraph at the document root.\n */\nfunction resolvePostDeleteSelection(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tsiblings: readonly ChildNode[],\n\tremovedIndex: number,\n): EditorSelection {\n\tconst prevSibling = siblings[removedIndex - 1];\n\tif (prevSibling && isBlockNode(prevSibling)) {\n\t\tconst sel = createSelectionForBlockBoundary(state, prevSibling.id, 'end');\n\t\tif (sel) return sel;\n\t}\n\n\tconst nextSibling = siblings[removedIndex + 1];\n\tif (nextSibling && isBlockNode(nextSibling)) {\n\t\tconst sel = createSelectionForBlockBoundary(state, nextSibling.id, 'start');\n\t\tif (sel) return sel;\n\t}\n\n\tconst removed = siblings[removedIndex];\n\tconst excludeId: BlockId | undefined = removed && isBlockNode(removed) ? removed.id : undefined;\n\tconst docSel = createSelectionForDocumentBoundary(state, 'start', excludeId);\n\tif (docSel) return docSel;\n\n\tconst newId: BlockId = generateBlockId();\n\tbuilder.insertNode([], 0, createEmptyParagraph(newId));\n\treturn createCollapsedSelection(newId, 0);\n}\n\n/**\n * Strips all marks from a block's inline content.\n * Used when converting to code_block so no formatting carries over.\n */\nfunction stripAllMarks(builder: TransactionBuilder, block: BlockNode): void {\n\tconst blockLength: number = getBlockLength(block);\n\tif (blockLength === 0) return;\n\n\tconst inlineChildren = getInlineChildren(block);\n\tlet offset = 0;\n\n\tfor (const child of inlineChildren) {\n\t\tif (isTextNode(child)) {\n\t\t\tif (child.text.length > 0) {\n\t\t\t\tfor (const mark of child.marks) {\n\t\t\t\t\tbuilder.removeMark(block.id, offset, offset + child.text.length, mark);\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += child.text.length;\n\t\t} else {\n\t\t\toffset += 1;\n\t\t}\n\t}\n}\n","/**\n * Builds the decoration set for code blocks: a focus highlight on the block\n * containing the caret plus per-token syntax-highlight decorations sourced from\n * the {@link TokenCache}.\n */\n\nimport type { Decoration } from '../../decorations/Decoration.js';\nimport {\n\tDecorationSet,\n\tinline as inlineDecoration,\n\tnode as nodeDecoration,\n} from '../../decorations/Decoration.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockText } from '../../model/Document.js';\nimport { isTextSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { SyntaxHighlighter, SyntaxToken } from './CodeBlockTypes.js';\nimport type { TokenCache } from './TokenCache.js';\n\ninterface CodeBlockDecorationDeps {\n\treadonly highlighter: SyntaxHighlighter | null;\n\treadonly tokenCache: TokenCache;\n}\n\n/**\n * Produces the focus + syntax-highlight decorations for all code blocks in\n * `state`. As a side effect, prunes cache entries for blocks that no longer\n * carry highlightable content so the cache tracks the live document.\n */\nexport function createCodeBlockDecorations(\n\tstate: EditorState,\n\tdeps: CodeBlockDecorationDeps,\n): DecorationSet {\n\tconst decorations: Decoration[] = [];\n\n\tconst focusedBlockId: BlockId | null = getFocusedCodeBlockId(state);\n\tif (focusedBlockId) {\n\t\tdecorations.push(nodeDecoration(focusedBlockId, { class: 'notectl-code-block--focused' }));\n\t}\n\n\tif (deps.highlighter) {\n\t\tconst activeBlockIds = new Set<BlockId>();\n\t\tfor (const bid of state.getBlockOrder()) {\n\t\t\tconst block: BlockNode | undefined = state.getBlock(bid);\n\t\t\tif (!block || block.type !== 'code_block') continue;\n\n\t\t\tconst lang: string = (block.attrs?.language as string) ?? '';\n\t\t\tif (!lang) continue;\n\n\t\t\tconst text: string = getBlockText(block);\n\t\t\tif (!text) continue;\n\n\t\t\tactiveBlockIds.add(bid);\n\t\t\tconst tokens: readonly SyntaxToken[] = deps.tokenCache.getTokens(\n\t\t\t\tbid,\n\t\t\t\ttext,\n\t\t\t\tlang,\n\t\t\t\tdeps.highlighter,\n\t\t\t);\n\t\t\tfor (const token of tokens) {\n\t\t\t\tdecorations.push(\n\t\t\t\t\tinlineDecoration(bid, token.from, token.to, {\n\t\t\t\t\t\tclass: `notectl-token--${token.type}`,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tdeps.tokenCache.retain(activeBlockIds);\n\t}\n\n\tif (decorations.length === 0) return DecorationSet.empty;\n\treturn DecorationSet.create(decorations);\n}\n\nfunction getFocusedCodeBlockId(state: EditorState): BlockId | null {\n\tif (!isTextSelection(state.selection)) return null;\n\tconst blockId: BlockId = state.selection.anchor.blockId;\n\tconst block: BlockNode | undefined = state.getBlock(blockId);\n\tif (block?.type === 'code_block') return blockId;\n\treturn null;\n}\n","/**\n * Internal registry that stores LanguageSupport bundles and notifies\n * subscribers with replay semantics for late subscribers.\n */\n\nimport type {\n\tLanguageRegistryListener,\n\tLanguageRegistryService,\n\tLanguageSupport,\n} from './LanguageTypes.js';\n\nexport class LanguageRegistry implements LanguageRegistryService {\n\tprivate readonly bundles = new Map<string, LanguageSupport>();\n\tprivate readonly listeners: LanguageRegistryListener[] = [];\n\n\tregister(support: LanguageSupport): void {\n\t\tthis.bundles.set(support.id, support);\n\t\tfor (const listener of this.listeners) {\n\t\t\tlistener(support);\n\t\t}\n\t}\n\n\t/**\n\t * Subscribes to language registrations.\n\t * The listener is immediately called for all already-registered bundles\n\t * (replay semantics), then called for each future registration.\n\t */\n\tonRegister(listener: LanguageRegistryListener): void {\n\t\tthis.listeners.push(listener);\n\t\tfor (const support of this.bundles.values()) {\n\t\t\tlistener(support);\n\t\t}\n\t}\n\n\tget(id: string): LanguageSupport | undefined {\n\t\treturn this.bundles.get(id);\n\t}\n\n\tgetAll(): readonly LanguageSupport[] {\n\t\treturn [...this.bundles.values()];\n\t}\n}\n","/**\n * Types, interfaces, and constants for the code-block plugin.\n */\n\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { ServiceKey } from '../Plugin.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\tcode_block: {\n\t\t\tlanguage: string;\n\t\t\tbackgroundColor: string;\n\t\t};\n\t}\n}\n\n// --- Syntax Highlighting Types ---\n\nimport type { SyntaxTokenType } from '../../editor/theme/SyntaxTokenTypes.js';\n\nexport interface SyntaxToken {\n\treadonly from: number;\n\treadonly to: number;\n\treadonly type: SyntaxTokenType | (string & {});\n}\n\nexport interface SyntaxHighlighter {\n\ttokenize(code: string, language: string): readonly SyntaxToken[];\n\tgetSupportedLanguages(): readonly string[];\n\tregisterLanguage?(def: import('./highlighter/TokenizerTypes.js').LanguageDefinition): void;\n}\n\n// --- Configuration ---\n\n/**\n * Configurable keyboard bindings for CodeBlockPlugin actions.\n * Omit a slot to use the default; set to `null` to disable the binding.\n *\n * Key descriptor format: `'Mod-Enter'`, `'Mod-Shift-M'`, etc.\n * `Mod` resolves to Cmd on macOS, Ctrl on Windows/Linux.\n */\nexport interface CodeBlockKeymap {\n\t/**\n\t * Insert a new paragraph below the code block and move the cursor there.\n\t * @default 'Mod-Enter'\n\t */\n\treadonly insertAfter?: string | null;\n\n\t/**\n\t * Toggle the current block between code block and paragraph.\n\t * @default 'Mod-Shift-M'\n\t */\n\treadonly toggle?: string | null;\n}\n\nexport const DEFAULT_KEYMAP: Readonly<Record<keyof CodeBlockKeymap, string>> = {\n\tinsertAfter: 'Mod-Enter',\n\ttoggle: 'Mod-Shift-M',\n};\n\n/** Auto-indent configuration block. All fields optional. */\nexport interface CodeBlockIndentConfig {\n\t/** Indent mode: `none` disables Enter-driven indent, `keep` only inherits the\n\t * previous line's indent, `brackets` additionally adds an extra step after\n\t * `{`, `[`, `(` and dedents on close chars. Default `'brackets'`. */\n\treadonly mode?: 'none' | 'keep' | 'brackets';\n\t/** Use spaces instead of a literal tab character. Default `false`. */\n\treadonly useSpaces?: boolean;\n\t/** Spaces per indent unit (clamped to [1, 16]). Default `2`. */\n\treadonly spaceCount?: number;\n}\n\n/** Auto-pair configuration block. All fields optional. */\nexport interface CodeBlockPairingConfig {\n\t/** Auto-pair behavior for brackets. Default `'languageDefined'`. */\n\treadonly brackets?: 'always' | 'languageDefined' | 'beforeWhitespace' | 'never';\n\t/** Auto-pair behavior for quotes. Default `'languageDefined'`. */\n\treadonly quotes?: 'always' | 'languageDefined' | 'beforeWhitespace' | 'never';\n\t/** Skip-over for auto-inserted close chars. Default `true`. */\n\treadonly overtype?: boolean;\n\t/** Backspace removes leftover empty auto-pair. Default `true`. */\n\treadonly deletePair?: boolean;\n\t/** Wrap-selection scope. Default `'languageDefined'` (= brackets + quotes). */\n\treadonly surround?: 'languageDefined' | 'quotes' | 'brackets' | 'never';\n}\n\n/**\n * Fully-resolved indent config seen by the keyboard handlers.\n * Differs from `CodeBlockIndentConfig` only in that all fields are required\n * after the constructor merge + clamp.\n */\nexport interface ResolvedIndentConfig {\n\treadonly mode: 'none' | 'keep' | 'brackets';\n\treadonly useSpaces: boolean;\n\treadonly spaceCount: number;\n}\n\n/** Fully-resolved pairing config — all fields required. */\nexport interface ResolvedPairingConfig {\n\treadonly brackets: 'always' | 'languageDefined' | 'beforeWhitespace' | 'never';\n\treadonly quotes: 'always' | 'languageDefined' | 'beforeWhitespace' | 'never';\n\treadonly overtype: boolean;\n\treadonly deletePair: boolean;\n\treadonly surround: 'languageDefined' | 'quotes' | 'brackets' | 'never';\n}\n\nexport interface CodeBlockConfig {\n\treadonly highlighter?: SyntaxHighlighter;\n\treadonly defaultLanguage?: string;\n\t/**\n\t * @deprecated Use `indent.useSpaces` instead. Read as a fallback when\n\t * `indent.useSpaces` is unset.\n\t */\n\treadonly useSpaces?: boolean;\n\t/**\n\t * @deprecated Use `indent.spaceCount` instead. Read as a fallback when\n\t * `indent.spaceCount` is unset.\n\t */\n\treadonly spaceCount?: number;\n\treadonly showCopyButton?: boolean;\n\t/** Default body background color (overrides --notectl-code-block-bg). */\n\treadonly background?: string;\n\t/** Default header background color (overrides --notectl-code-block-header-bg). */\n\treadonly headerBackground?: string;\n\t/** Default text color (overrides --notectl-code-block-color). */\n\treadonly textColor?: string;\n\t/** Default header/label text color (overrides --notectl-code-block-header-color). */\n\treadonly headerColor?: string;\n\t/** Customize keyboard bindings for code block actions. */\n\treadonly keymap?: CodeBlockKeymap;\n\t/** Locale override for user-facing strings. */\n\treadonly locale?: import('./CodeBlockLocale.js').CodeBlockLocale;\n\t/** Auto-indent settings. */\n\treadonly indent?: CodeBlockIndentConfig;\n\t/** Bracket-pairing settings. */\n\treadonly pairing?: CodeBlockPairingConfig;\n}\n\nexport const DEFAULT_CONFIG: CodeBlockConfig = {\n\tdefaultLanguage: '',\n\tuseSpaces: false,\n\tspaceCount: 2,\n\tshowCopyButton: true,\n};\n\n/** Default values applied during config merge (see CodeBlockPlugin.constructor). */\nexport const DEFAULT_INDENT: ResolvedIndentConfig = {\n\tmode: 'brackets',\n\tuseSpaces: false,\n\tspaceCount: 2,\n};\n\nexport const DEFAULT_PAIRING: ResolvedPairingConfig = {\n\tbrackets: 'languageDefined',\n\tquotes: 'languageDefined',\n\tovertype: true,\n\tdeletePair: true,\n\tsurround: 'languageDefined',\n};\n\nexport const MIN_SPACE_COUNT = 1;\nexport const MAX_SPACE_COUNT = 16;\n\n// --- Service Types ---\n\nexport interface CodeBlockService {\n\tsetLanguage(blockId: BlockId, language: string): void;\n\tgetLanguage(blockId: BlockId): string;\n\tsetBackground(blockId: BlockId, color: string): void;\n\tgetBackground(blockId: BlockId): string;\n\tisCodeBlock(blockId: BlockId): boolean;\n\tgetSupportedLanguages(): readonly string[];\n}\n\nexport const CODE_BLOCK_SERVICE_KEY = new ServiceKey<CodeBlockService>('codeBlock');\n\n// --- Syntax Highlighter Service ---\n\nexport interface SyntaxHighlighterService {\n\tregisterLanguage(def: import('./highlighter/TokenizerTypes.js').LanguageDefinition): void;\n\tgetSupportedLanguages(): readonly string[];\n\ttokenize(code: string, language: string): readonly SyntaxToken[];\n\t/**\n\t * Returns the cached token whose range covers `offset` in `blockId`, or\n\t * `undefined` if no token is registered at that position (e.g. cache miss,\n\t * whitespace between tokens, or block not yet tokenized). Uses binary\n\t * search over the per-block token cache; never triggers a fresh tokenize.\n\t */\n\tgetTokenAt(blockId: BlockId, offset: number): SyntaxToken | undefined;\n}\n\nexport const SYNTAX_HIGHLIGHTER_SERVICE_KEY = new ServiceKey<SyntaxHighlighterService>(\n\t'syntaxHighlighter',\n);\n\n// --- SVG Icon ---\n\nexport const CODE_BLOCK_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z\"/><path d=\"M11 14.17L8.83 12 11 9.83 9.59 8.41 6 12l3.59 3.59L11 14.17zm3.41 1.42L18 12l-3.59-3.59L13 9.83 15.17 12 13 14.17l1.41 1.42z\"/></svg>';\n","/**\n * Regex-based syntax tokenizer.\n * Implements the SyntaxHighlighter interface using linear regex scanning\n * with sticky (`y`-flagged) regexes to avoid O(n) substring allocations per position.\n */\n\nimport type { SyntaxHighlighter, SyntaxToken } from '../CodeBlockTypes.js';\nimport { iterateTokens } from './TokenIteration.js';\nimport type { LanguageDefinition } from './TokenizerTypes.js';\n\nexport class RegexTokenizer implements SyntaxHighlighter {\n\tprivate readonly languageMap = new Map<string, LanguageDefinition>();\n\n\tconstructor(languages?: readonly LanguageDefinition[]) {\n\t\tif (languages) {\n\t\t\tfor (const lang of languages) {\n\t\t\t\tthis.registerLanguageInternal(lang);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Registers a language definition. Overwrites existing definitions for the same name/aliases. */\n\tregisterLanguage(def: LanguageDefinition): void {\n\t\tthis.registerLanguageInternal(def);\n\t}\n\n\t/** Tokenizes code using the specified language. Returns empty array for unknown languages. */\n\ttokenize(code: string, language: string): readonly SyntaxToken[] {\n\t\tconst lang: LanguageDefinition | undefined = this.languageMap.get(language.toLowerCase());\n\t\tif (!lang) return [];\n\n\t\tconst tokens: SyntaxToken[] = [];\n\t\tfor (const token of iterateTokens(code, lang)) {\n\t\t\ttokens.push({ from: token.from, to: token.to, type: token.type });\n\t\t}\n\t\treturn tokens;\n\t}\n\n\t/** Returns all registered language names and aliases. */\n\tgetSupportedLanguages(): readonly string[] {\n\t\tconst names = new Set<string>();\n\t\tfor (const lang of this.languageMap.values()) {\n\t\t\tnames.add(lang.name);\n\t\t\tfor (const alias of lang.aliases) {\n\t\t\t\tnames.add(alias);\n\t\t\t}\n\t\t}\n\t\treturn [...names];\n\t}\n\n\tprivate registerLanguageInternal(def: LanguageDefinition): void {\n\t\tthis.languageMap.set(def.name.toLowerCase(), def);\n\t\tfor (const alias of def.aliases) {\n\t\t\tthis.languageMap.set(alias.toLowerCase(), def);\n\t\t}\n\t}\n}\n","/**\n * Wires up syntax highlighting for the code-block plugin: selects the active\n * highlighter (the configured one or the built-in {@link RegexTokenizer}),\n * registers the language registry with its bundled languages, and exposes the\n * `SyntaxHighlighterService`. The shared {@link TokenCache} is invalidated\n * whenever a new language is registered.\n */\n\nimport type { PluginContext } from '../Plugin.js';\nimport { LanguageRegistry } from '../language/LanguageRegistry.js';\nimport { LANGUAGE_REGISTRY_SERVICE_KEY } from '../language/LanguageTypes.js';\nimport {\n\tJAVA_SUPPORT,\n\tJSON_SUPPORT,\n\tTYPESCRIPT_SUPPORT,\n\tXML_SUPPORT,\n} from '../language/bundles/index.js';\nimport type { CodeBlockConfig, SyntaxHighlighter } from './CodeBlockTypes.js';\nimport { SYNTAX_HIGHLIGHTER_SERVICE_KEY } from './CodeBlockTypes.js';\nimport type { TokenCache } from './TokenCache.js';\nimport { RegexTokenizer } from './highlighter/RegexTokenizer.js';\n\n/**\n * Sets up the highlighter, language registry, and syntax-highlighter service.\n * Returns the active highlighter so the plugin can hand it to the node view and\n * decoration builder.\n */\nexport function setupHighlighting(\n\tcontext: PluginContext,\n\tconfig: CodeBlockConfig,\n\ttokenCache: TokenCache,\n): SyntaxHighlighter {\n\tconst highlighter: SyntaxHighlighter = config.highlighter ?? new RegexTokenizer();\n\n\tconst languageRegistry = new LanguageRegistry();\n\tlanguageRegistry.onRegister((support) => {\n\t\tif (support.highlighting && highlighter.registerLanguage) {\n\t\t\thighlighter.registerLanguage(support.highlighting);\n\t\t\ttokenCache.clear();\n\t\t}\n\t});\n\tcontext.registerService(LANGUAGE_REGISTRY_SERVICE_KEY, languageRegistry);\n\n\tlanguageRegistry.register(JAVA_SUPPORT);\n\tlanguageRegistry.register(JSON_SUPPORT);\n\tlanguageRegistry.register(TYPESCRIPT_SUPPORT);\n\tlanguageRegistry.register(XML_SUPPORT);\n\n\tcontext.registerService(SYNTAX_HIGHLIGHTER_SERVICE_KEY, {\n\t\tregisterLanguage: (def) => {\n\t\t\thighlighter.registerLanguage?.(def);\n\t\t\ttokenCache.clear();\n\t\t},\n\t\tgetSupportedLanguages: () => highlighter.getSupportedLanguages(),\n\t\ttokenize: (code, language) => highlighter.tokenize(code, language),\n\t\tgetTokenAt: (blockId, offset) => tokenCache.findTokenAt(blockId, offset),\n\t});\n\n\treturn highlighter;\n}\n","/** Locale interface and default English locale for the CodeBlockPlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface CodeBlockLocale {\n\treadonly label: string;\n\treadonly tooltip: (shortcut?: string) => string;\n\treadonly enteredCodeBlock: string;\n\treadonly leftCodeBlock: string;\n\treadonly copyCodeAria: string;\n\treadonly escToExit: string;\n\treadonly codeBlockAriaLabel: (lang: string) => string;\n\treadonly copiedToClipboard: string;\n\treadonly copyFailed: string;\n\treadonly deleteCodeBlockAria: string;\n\treadonly deletedCodeBlock: string;\n\treadonly selectLanguageAria: string;\n\treadonly languageChanged: (lang: string) => string;\n\treadonly plainText: string;\n\t/** Screen-reader announcement after multi-line Tab indent. */\n\treadonly indentedNLines: (n: number) => string;\n\t/** Screen-reader announcement after multi-line Shift-Tab dedent. */\n\treadonly dedentedNLines: (n: number) => string;\n}\n\n// --- Default English Locale ---\n\nexport const CODE_BLOCK_LOCALE_EN: CodeBlockLocale = {\n\tlabel: 'Code Block',\n\ttooltip: (shortcut?: string) => (shortcut ? `Code Block (${shortcut})` : 'Code Block'),\n\tenteredCodeBlock: 'Entered code block. Press Escape to exit.',\n\tleftCodeBlock: 'Left code block.',\n\tcopyCodeAria: 'Copy code',\n\tescToExit: 'Esc to exit',\n\tcodeBlockAriaLabel: (lang: string) => `${lang} code block. Press Escape to exit.`,\n\tcopiedToClipboard: 'Copied to clipboard',\n\tcopyFailed: 'Failed to copy code',\n\tdeleteCodeBlockAria: 'Delete code block',\n\tdeletedCodeBlock: 'Code block deleted',\n\tselectLanguageAria: 'Select language',\n\tlanguageChanged: (lang: string) => `Language changed to ${lang}`,\n\tplainText: 'plain',\n\tindentedNLines: (n: number) => (n === 1 ? '1 line indented' : `${n} lines indented`),\n\tdedentedNLines: (n: number) => (n === 1 ? '1 line dedented' : `${n} lines dedented`),\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<CodeBlockLocale> = import.meta.glob<{\n\tdefault: CodeBlockLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadCodeBlockLocale(lang: string): Promise<CodeBlockLocale> {\n\treturn loadLocaleModule(localeModules, lang, CODE_BLOCK_LOCALE_EN);\n}\n","/**\n * Language picker popup for code blocks.\n * Opens a listbox dropdown anchored to the language button,\n * allowing users to select a syntax highlighting language.\n */\n\nimport { attachListboxKeyboard } from '../shared/PopupKeyboardPatterns.js';\nimport type { PopupServiceAPI } from '../shared/PopupManager.js';\nimport type { CodeBlockLocale } from './CodeBlockLocale.js';\n\n/** Configuration for opening the language picker popup. */\nexport interface LanguagePickerConfig {\n\treadonly anchor: HTMLElement;\n\treadonly languages: readonly string[];\n\treadonly currentLanguage: string;\n\treadonly onSelect: (language: string) => void;\n\treadonly popupManager: PopupServiceAPI;\n\treadonly locale: CodeBlockLocale;\n}\n\nconst OPTION_SELECTOR = '[role=\"option\"]';\n\n/** Opens a language picker popup anchored to the given element. */\nexport function openLanguagePicker(config: LanguagePickerConfig): void {\n\tconst { anchor, languages, currentLanguage, onSelect, popupManager, locale } = config;\n\n\tpopupManager.open({\n\t\tanchor,\n\t\tariaRole: 'listbox',\n\t\tariaLabel: locale.selectLanguageAria,\n\t\tclassName: 'notectl-language-picker',\n\t\tposition: 'below-start',\n\t\trestoreFocusTo: anchor,\n\t\tcontent(container, close) {\n\t\t\tconst normalizedCurrent: string = currentLanguage.toLowerCase();\n\n\t\t\t// \"plain\" option is always first\n\t\t\tappendOption(container, locale.plainText, '', normalizedCurrent === '');\n\n\t\t\t// Language options sorted alphabetically\n\t\t\tconst sorted: readonly string[] = [...languages].sort((a, b) => a.localeCompare(b));\n\t\t\tfor (const lang of sorted) {\n\t\t\t\tappendOption(container, lang, lang, normalizedCurrent === lang.toLowerCase());\n\t\t\t}\n\n\t\t\tattachListboxKeyboard({\n\t\t\t\tcontainer,\n\t\t\t\titemSelector: OPTION_SELECTOR,\n\t\t\t\tonSelect(item) {\n\t\t\t\t\tconst value: string = item.getAttribute('data-language') ?? '';\n\t\t\t\t\tonSelect(value);\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t\tonClose() {\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tcontainer.addEventListener('click', (e: Event) => {\n\t\t\t\tconst target: HTMLElement | null = (e.target as HTMLElement).closest(OPTION_SELECTOR);\n\t\t\t\tif (!target) return;\n\t\t\t\tconst value: string = target.getAttribute('data-language') ?? '';\n\t\t\t\tonSelect(value);\n\t\t\t\tclose();\n\t\t\t});\n\t\t},\n\t\tonClose() {\n\t\t\tanchor.setAttribute('aria-expanded', 'false');\n\t\t},\n\t});\n\n\tanchor.setAttribute('aria-expanded', 'true');\n}\n\nfunction appendOption(\n\tcontainer: HTMLElement,\n\tlabel: string,\n\tvalue: string,\n\tselected: boolean,\n): void {\n\tconst option: HTMLDivElement = document.createElement('div');\n\toption.className = 'notectl-language-picker__option';\n\toption.setAttribute('role', 'option');\n\toption.setAttribute('data-language', value);\n\toption.setAttribute('aria-selected', String(selected));\n\toption.setAttribute('tabindex', selected ? '0' : '-1');\n\toption.textContent = label;\n\tcontainer.appendChild(option);\n}\n","/**\n * NodeView factory for code blocks.\n * Renders <pre> with a non-editable header (language label + action buttons)\n * and a <code> content area where the Reconciler renders text.\n */\n\nimport type { BlockAttrs, BlockNode } from '../../model/Document.js';\nimport { getBlockText } from '../../model/Document.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { NodeView, NodeViewFactory } from '../../view/NodeView.js';\nimport type { PopupServiceAPI } from '../shared/PopupManager.js';\nimport { createDeleteCodeBlockTransaction } from './CodeBlockCommands.js';\nimport { CODE_BLOCK_LOCALE_EN, type CodeBlockLocale } from './CodeBlockLocale.js';\nimport type { CodeBlockConfig } from './CodeBlockTypes.js';\nimport { openLanguagePicker } from './LanguagePicker.js';\n\n/** How long a screen-reader announcement stays in the live region before clearing. */\nconst ANNOUNCE_CLEAR_MS = 1000;\n\n/** Dependencies for the language picker in the code block header. */\nexport interface LanguagePickerDeps {\n\treadonly popupManager: PopupServiceAPI;\n\treadonly getSupportedLanguages: () => readonly string[];\n}\n\nconst COPY_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"14\" height=\"14\"><path d=\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z\"/></svg>';\n\nconst DELETE_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"14\" height=\"14\"><path d=\"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z\"/></svg>';\n\nconst CHEVRON_ICON =\n\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" width=\"10\" height=\"10\"><path d=\"M4 6l4 4 4-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>';\n\n/**\n * Copies text to the clipboard, rejecting when the Clipboard API is unavailable\n * (e.g. insecure context, missing permissions) or when the write itself fails.\n * Callers must handle rejection to give the user accurate feedback.\n */\nexport function copyTextToClipboard(text: string): Promise<void> {\n\tconst clipboard: Clipboard | undefined = globalThis.navigator?.clipboard;\n\tif (!clipboard || typeof clipboard.writeText !== 'function') {\n\t\treturn Promise.reject(new Error('Clipboard API unavailable'));\n\t}\n\treturn clipboard.writeText(text);\n}\n\n/** Creates a NodeViewFactory for code_block nodes. */\nexport function createCodeBlockNodeViewFactory(\n\tconfig: CodeBlockConfig,\n\tlocale: CodeBlockLocale = CODE_BLOCK_LOCALE_EN,\n\tpickerDeps?: LanguagePickerDeps,\n): NodeViewFactory {\n\treturn (\n\t\tnode: BlockNode,\n\t\tgetState: () => EditorState,\n\t\tdispatch: (tr: Transaction) => void,\n\t): NodeView => {\n\t\t// --- DOM Construction ---\n\t\tconst pre: HTMLElement = document.createElement('pre');\n\t\tpre.className = 'notectl-code-block';\n\t\tpre.setAttribute('data-block-id', node.id);\n\t\tpre.setAttribute('dir', 'ltr');\n\t\tpre.setAttribute('role', 'group');\n\t\tpre.setAttribute('aria-roledescription', 'code block');\n\t\tpre.setAttribute('part', 'code-block');\n\n\t\t// Header (non-editable)\n\t\tconst header: HTMLDivElement = document.createElement('div');\n\t\theader.className = 'notectl-code-block__header';\n\t\theader.setAttribute('contenteditable', 'false');\n\t\theader.setAttribute('part', 'code-block-header');\n\n\t\tconst langBtn: HTMLButtonElement = document.createElement('button');\n\t\tlangBtn.className = 'notectl-code-block__language-btn';\n\t\tlangBtn.type = 'button';\n\t\tlangBtn.setAttribute('aria-haspopup', 'listbox');\n\t\tlangBtn.setAttribute('aria-expanded', 'false');\n\t\tlangBtn.setAttribute('aria-label', locale.selectLanguageAria);\n\n\t\tconst showCopy: boolean = config.showCopyButton !== false;\n\t\tlet copyBtn: HTMLButtonElement | null = null;\n\n\t\tif (showCopy) {\n\t\t\tcopyBtn = document.createElement('button');\n\t\t\tcopyBtn.className = 'notectl-code-block__copy';\n\t\t\tcopyBtn.setAttribute('aria-label', locale.copyCodeAria);\n\t\t\tcopyBtn.setAttribute('data-notectl-no-print', '');\n\t\t\tcopyBtn.type = 'button';\n\t\t\tcopyBtn.innerHTML = COPY_ICON;\n\t\t}\n\n\t\t// Delete button\n\t\tconst deleteBtn: HTMLButtonElement = document.createElement('button');\n\t\tdeleteBtn.className = 'notectl-code-block__delete';\n\t\tdeleteBtn.setAttribute('aria-label', locale.deleteCodeBlockAria);\n\t\tdeleteBtn.title = locale.deleteCodeBlockAria;\n\t\tdeleteBtn.setAttribute('data-notectl-no-print', '');\n\t\tdeleteBtn.type = 'button';\n\t\tdeleteBtn.innerHTML = DELETE_ICON;\n\n\t\t// Screen reader live region for action feedback\n\t\tconst announcer: HTMLSpanElement = document.createElement('span');\n\t\tannouncer.className = 'notectl-sr-only';\n\t\tannouncer.setAttribute('aria-live', 'assertive');\n\t\tannouncer.setAttribute('aria-atomic', 'true');\n\n\t\t// Actions wrapper groups buttons on the right side\n\t\tconst actions: HTMLDivElement = document.createElement('div');\n\t\tactions.className = 'notectl-code-block__actions';\n\t\tif (copyBtn) {\n\t\t\tactions.appendChild(copyBtn);\n\t\t}\n\t\tactions.appendChild(deleteBtn);\n\n\t\theader.appendChild(langBtn);\n\t\theader.appendChild(actions);\n\t\theader.appendChild(announcer);\n\n\t\t// Content area (Reconciler target)\n\t\tconst code: HTMLElement = document.createElement('code');\n\t\tcode.className = 'notectl-code-block__content';\n\t\tcode.setAttribute('part', 'code-block-content');\n\n\t\t// Escape hint (visible only when focused, CSS-driven)\n\t\tconst escHint: HTMLDivElement = document.createElement('div');\n\t\tescHint.className = 'notectl-code-block__esc-hint';\n\t\tescHint.setAttribute('contenteditable', 'false');\n\t\tescHint.setAttribute('aria-hidden', 'true');\n\t\tescHint.setAttribute('data-notectl-no-print', '');\n\t\tescHint.textContent = locale.escToExit;\n\n\t\tpre.appendChild(header);\n\t\tpre.appendChild(code);\n\t\tpre.appendChild(escHint);\n\n\t\t// Apply config-level color overrides as CSS custom properties\n\t\tif (config.background) {\n\t\t\tsetStyleProperty(pre, '--notectl-code-block-bg', config.background);\n\t\t}\n\t\tif (config.headerBackground) {\n\t\t\tsetStyleProperty(pre, '--notectl-code-block-header-bg', config.headerBackground);\n\t\t}\n\t\tif (config.textColor) {\n\t\t\tsetStyleProperty(pre, '--notectl-code-block-color', config.textColor);\n\t\t}\n\t\tif (config.headerColor) {\n\t\t\tsetStyleProperty(pre, '--notectl-code-block-header-color', config.headerColor);\n\t\t}\n\n\t\tlet currentNodeId: BlockId = node.id;\n\n\t\t// --- Attribute Application ---\n\n\t\tfunction applyAttrs(n: BlockNode): void {\n\t\t\tconst lang: string = (n.attrs?.language as string) ?? '';\n\t\t\tconst langName: string = lang || locale.plainText;\n\t\t\tlangBtn.innerHTML = '';\n\t\t\tconst labelSpan: HTMLSpanElement = document.createElement('span');\n\t\t\tlabelSpan.className = 'notectl-code-block__language';\n\t\t\tlabelSpan.textContent = langName;\n\t\t\tlangBtn.appendChild(labelSpan);\n\t\t\tif (pickerDeps) {\n\t\t\t\tconst chevron: HTMLSpanElement = document.createElement('span');\n\t\t\t\tchevron.className = 'notectl-code-block__chevron';\n\t\t\t\tchevron.innerHTML = CHEVRON_ICON;\n\t\t\t\tlangBtn.appendChild(chevron);\n\t\t\t}\n\t\t\tpre.setAttribute('aria-label', locale.codeBlockAriaLabel(langName));\n\n\t\t\tif (lang) {\n\t\t\t\tcode.setAttribute('data-language', lang);\n\t\t\t} else {\n\t\t\t\tcode.removeAttribute('data-language');\n\t\t\t}\n\n\t\t\tconst bg: string = (n.attrs?.backgroundColor as string) ?? '';\n\t\t\tsetStyleProperty(pre, 'backgroundColor', bg || '');\n\t\t}\n\n\t\tapplyAttrs(node);\n\n\t\t// --- Copy Button Handler ---\n\n\t\tfunction announce(message: string): void {\n\t\t\tannouncer.textContent = message;\n\t\t\tsetTimeout(() => {\n\t\t\t\tannouncer.textContent = '';\n\t\t\t}, ANNOUNCE_CLEAR_MS);\n\t\t}\n\n\t\tif (copyBtn) {\n\t\t\tcopyBtn.addEventListener('click', (e: MouseEvent) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tconst state: EditorState = getState();\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(currentNodeId);\n\t\t\t\tif (!block) return;\n\n\t\t\t\tconst text: string = getBlockText(block);\n\t\t\t\tcopyTextToClipboard(text).then(\n\t\t\t\t\t() => announce(locale.copiedToClipboard),\n\t\t\t\t\t() => announce(locale.copyFailed),\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\t// --- Delete Button Handler ---\n\n\t\tdeleteBtn.addEventListener('click', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\n\t\t\tconst state: EditorState = getState();\n\t\t\tconst tr: Transaction | null = createDeleteCodeBlockTransaction(state, currentNodeId);\n\t\t\tif (!tr) return;\n\n\t\t\tannouncer.textContent = locale.deletedCodeBlock;\n\t\t\tdispatch(tr);\n\t\t});\n\n\t\t// --- Language Picker Handler ---\n\n\t\tif (pickerDeps) {\n\t\t\tlangBtn.addEventListener('click', (e: MouseEvent) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tconst state: EditorState = getState();\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(currentNodeId);\n\t\t\t\tif (!block) return;\n\n\t\t\t\tconst currentLang: string = (block.attrs?.language as string) ?? '';\n\t\t\t\topenLanguagePicker({\n\t\t\t\t\tanchor: langBtn,\n\t\t\t\t\tlanguages: pickerDeps.getSupportedLanguages(),\n\t\t\t\t\tcurrentLanguage: currentLang,\n\t\t\t\t\tlocale,\n\t\t\t\t\tpopupManager: pickerDeps.popupManager,\n\t\t\t\t\tonSelect(language: string) {\n\t\t\t\t\t\tif (language === currentLang) return;\n\n\t\t\t\t\t\tconst latest: EditorState = getState();\n\t\t\t\t\t\tconst latestBlock: BlockNode | undefined = latest.getBlock(currentNodeId);\n\t\t\t\t\t\tif (!latestBlock) return;\n\n\t\t\t\t\t\tconst path: BlockId[] | undefined = latest.getNodePath(currentNodeId);\n\t\t\t\t\t\tif (!path) return;\n\n\t\t\t\t\t\tconst newAttrs: BlockAttrs = { ...latestBlock.attrs, language };\n\t\t\t\t\t\tconst tr: Transaction = latest\n\t\t\t\t\t\t\t.transaction('command')\n\t\t\t\t\t\t\t.setNodeAttr(path, newAttrs)\n\t\t\t\t\t\t\t.build();\n\t\t\t\t\t\tdispatch(tr);\n\n\t\t\t\t\t\tconst langName: string = language || locale.plainText;\n\t\t\t\t\t\tannounce(locale.languageChanged(langName));\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\t// --- NodeView Interface ---\n\n\t\treturn {\n\t\t\tdom: pre,\n\t\t\tcontentDOM: code,\n\n\t\t\tupdate(updatedNode: BlockNode): boolean {\n\t\t\t\tif (updatedNode.type !== 'code_block') return false;\n\t\t\t\tcurrentNodeId = updatedNode.id;\n\t\t\t\tpre.setAttribute('data-block-id', updatedNode.id);\n\t\t\t\tapplyAttrs(updatedNode);\n\t\t\t\treturn true;\n\t\t\t},\n\n\t\t\tselectNode(): void {\n\t\t\t\tpre.classList.add('notectl-code-block--selected');\n\t\t\t},\n\n\t\t\tdeselectNode(): void {\n\t\t\t\tpre.classList.remove('notectl-code-block--selected');\n\t\t\t},\n\n\t\t\tdestroy(): void {\n\t\t\t\t// No cleanup needed\n\t\t\t},\n\t\t};\n\t};\n}\n","/**\n * Static editor registrations for the code-block plugin: the `code_block`\n * NodeSpec, the ```` ```lang ```` input rule, the toolbar item, the mark-guard\n * middleware, the paste interceptor, and the table-cell content patch.\n *\n * These are pure registration helpers with no per-instance state, mirroring the\n * `registerCodeBlockCommands` / `registerCodeBlockKeymaps` pattern.\n */\n\nimport { addDeleteSelectionSteps } from '../../commands/Commands.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { escapeHTML } from '../../model/HTMLUtils.js';\nimport type { HTMLExportContext } from '../../model/NodeSpec.js';\nimport { createCollapsedSelection, isCollapsed, isTextSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport { createBlockElement } from '../../view/DomUtils.js';\nimport type { PasteInterceptor, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../shared/ShortcutFormatting.js';\nimport type { CodeBlockLocale } from './CodeBlockLocale.js';\nimport { CODE_BLOCK_ICON } from './CodeBlockTypes.js';\n\nexport function registerCodeBlockNodeSpec(context: PluginContext): void {\n\tcontext.registerNodeSpec({\n\t\ttype: 'code_block',\n\t\tgroup: 'block',\n\t\tcontent: { allow: ['text'] },\n\t\tselectable: true,\n\t\tattrs: {\n\t\t\tlanguage: { default: '' },\n\t\t\tbackgroundColor: { default: '' },\n\t\t},\n\t\ttoDOM(node) {\n\t\t\tconst pre: HTMLElement = createBlockElement('pre', node.id);\n\t\t\tpre.className = 'notectl-code-block';\n\t\t\tpre.setAttribute('dir', 'ltr');\n\t\t\tpre.setAttribute('part', 'code-block');\n\t\t\tconst code: HTMLElement = document.createElement('code');\n\t\t\tcode.className = 'notectl-code-block__content';\n\t\t\tcode.setAttribute('part', 'code-block-content');\n\t\t\tpre.appendChild(code);\n\t\t\treturn pre;\n\t\t},\n\t\ttoHTML(node, content, ctx?: HTMLExportContext) {\n\t\t\tconst lang: string = escapeHTML((node.attrs?.language as string) ?? '');\n\t\t\tconst bg: string = escapeHTML((node.attrs?.backgroundColor as string) ?? '');\n\t\t\tconst langClass: string = lang ? ` class=\"language-${lang}\"` : '';\n\t\t\tconst bgAttr: string = bg\n\t\t\t\t? (ctx?.styleAttr(`background-color: ${bg}`) ?? ` style=\"background-color: ${bg}\"`)\n\t\t\t\t: '';\n\t\t\treturn `<pre dir=\"ltr\"${bgAttr}><code${langClass}>${content || ''}</code></pre>`;\n\t\t},\n\t\tparseHTML: [\n\t\t\t{\n\t\t\t\ttag: 'pre',\n\t\t\t\tgetAttrs(el: HTMLElement) {\n\t\t\t\t\tconst code: HTMLElement | null = el.querySelector('code');\n\t\t\t\t\tconst langClass: string = code?.className.match(/language-(\\S+)/)?.[1] ?? '';\n\t\t\t\t\tconst dataLang: string = code?.getAttribute('data-language') ?? '';\n\t\t\t\t\treturn {\n\t\t\t\t\t\tlanguage: dataLang || langClass,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tsanitize: {\n\t\t\ttags: ['pre', 'code'],\n\t\t\tattrs: ['data-language', 'class', 'style'],\n\t\t},\n\t});\n}\n\nexport function registerCodeBlockInputRule(context: PluginContext): void {\n\tcontext.registerInputRule({\n\t\tpattern: /^```(\\w*) $/,\n\t\thandler: (state, match, start, _end) => {\n\t\t\tconst sel = state.selection;\n\t\t\tif (!isTextSelection(sel)) return null;\n\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\tconst language: string = match[1] ?? '';\n\t\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t\tlanguage,\n\t\t\t\tbackgroundColor: '',\n\t\t\t};\n\n\t\t\treturn state\n\t\t\t\t.transaction('input')\n\t\t\t\t.deleteTextAt(sel.anchor.blockId, start, start + match[0].length)\n\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('code_block'), attrs)\n\t\t\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0))\n\t\t\t\t.build();\n\t\t},\n\t});\n}\n\nexport function registerCodeBlockToolbarItem(\n\tcontext: PluginContext,\n\tlocale: CodeBlockLocale,\n\ttoggleKey: string | null,\n): void {\n\tcontext.registerToolbarItem({\n\t\tid: 'code_block',\n\t\tgroup: 'block',\n\t\ticon: CODE_BLOCK_ICON,\n\t\tlabel: locale.label,\n\t\ttooltip: locale.tooltip(toggleKey ? formatShortcut(toggleKey) : undefined),\n\t\tcommand: 'toggleCodeBlock',\n\t\tisActive: (state) => {\n\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\tconst block: BlockNode | undefined = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'code_block';\n\t\t},\n\t});\n}\n\n/** Strips `addMark` steps targeting a code block so inline marks never apply there. */\nexport function registerCodeBlockMarkGuard(context: PluginContext): void {\n\tcontext.registerMiddleware(\n\t\t(tr, state, next) => {\n\t\t\tconst hasMarkInCodeBlock: boolean = tr.steps.some((step) => {\n\t\t\t\tif (step.type !== 'addMark') return false;\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(step.blockId);\n\t\t\t\treturn block?.type === 'code_block';\n\t\t\t});\n\n\t\t\tif (!hasMarkInCodeBlock) {\n\t\t\t\tnext(tr);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst filtered = tr.steps.filter((step) => {\n\t\t\t\tif (step.type !== 'addMark') return true;\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(step.blockId);\n\t\t\t\treturn block?.type !== 'code_block';\n\t\t\t});\n\n\t\t\tnext({ ...tr, steps: filtered });\n\t\t},\n\t\t{ name: 'code-block:mark-guard', priority: 50 },\n\t);\n}\n\nexport function registerCodeBlockPasteInterceptor(context: PluginContext): void {\n\tconst handleCodeBlockPaste: PasteInterceptor = (\n\t\tplainText: string,\n\t\t_html: string,\n\t\tstate: EditorState,\n\t): Transaction | null => {\n\t\tif (!plainText) return null;\n\t\tif (!isTextSelection(state.selection)) return null;\n\n\t\tconst block: BlockNode | undefined = state.getBlock(state.selection.anchor.blockId);\n\t\tif (!block || block.type !== 'code_block') return null;\n\n\t\tconst builder = state.transaction('paste');\n\n\t\tlet insertBlockId: BlockId = state.selection.anchor.blockId;\n\t\tlet insertOffset: number = state.selection.anchor.offset;\n\n\t\tif (!isCollapsed(state.selection)) {\n\t\t\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\t\t\tif (landingId) {\n\t\t\t\tinsertBlockId = landingId;\n\t\t\t\tinsertOffset = 0;\n\t\t\t}\n\t\t}\n\n\t\tbuilder.insertText(insertBlockId, insertOffset, plainText, []);\n\t\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + plainText.length));\n\n\t\treturn builder.build();\n\t};\n\n\tcontext.registerPasteInterceptor(handleCodeBlockPaste, {\n\t\tname: 'code-block:paste',\n\t\tpriority: 10,\n\t});\n}\n\n/** Extends `table_cell` content to allow nested code blocks, if not already allowed. */\nexport function patchTableCellContent(context: PluginContext): void {\n\tconst registry = context.getSchemaRegistry();\n\tconst cellSpec = registry.getNodeSpec('table_cell');\n\tif (!cellSpec?.content) return;\n\n\tconst currentAllow: readonly string[] = cellSpec.content.allow ?? [];\n\tif (currentAllow.includes('code_block')) return;\n\n\tregistry.removeNodeSpec('table_cell');\n\tregistry.registerNodeSpec({\n\t\t...cellSpec,\n\t\tcontent: {\n\t\t\t...cellSpec.content,\n\t\t\tallow: [...currentAllow, 'code_block'],\n\t\t},\n\t});\n}\n","/**\n * Service API for code blocks.\n * Provides language/background getters and setters.\n */\n\nimport type { BlockAttrs, BlockNode } from '../../model/Document.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { SyntaxHighlighter } from './CodeBlockTypes.js';\nimport { CODE_BLOCK_SERVICE_KEY } from './CodeBlockTypes.js';\n\n/** Registers the CodeBlockService on the given context. */\nexport function registerCodeBlockService(\n\tcontext: PluginContext,\n\tgetHighlighter: () => SyntaxHighlighter | null,\n\tgetContext: () => PluginContext | null,\n): void {\n\tcontext.registerService(CODE_BLOCK_SERVICE_KEY, {\n\t\tsetLanguage(bid: BlockId, language: string): void {\n\t\t\tsetAttr(context, bid, 'language', language);\n\t\t},\n\n\t\tgetLanguage(bid: BlockId): string {\n\t\t\tconst ctx: PluginContext | null = getContext();\n\t\t\tif (!ctx) return '';\n\t\t\tconst block: BlockNode | undefined = ctx.getState().getBlock(bid);\n\t\t\tif (!block || block.type !== 'code_block') return '';\n\t\t\treturn (block.attrs?.language as string) ?? '';\n\t\t},\n\n\t\tsetBackground(bid: BlockId, color: string): void {\n\t\t\tsetAttr(context, bid, 'backgroundColor', color);\n\t\t},\n\n\t\tgetBackground(bid: BlockId): string {\n\t\t\tconst ctx: PluginContext | null = getContext();\n\t\t\tif (!ctx) return '';\n\t\t\tconst block: BlockNode | undefined = ctx.getState().getBlock(bid);\n\t\t\tif (!block || block.type !== 'code_block') return '';\n\t\t\treturn (block.attrs?.backgroundColor as string) ?? '';\n\t\t},\n\n\t\tisCodeBlock(bid: BlockId): boolean {\n\t\t\tconst ctx: PluginContext | null = getContext();\n\t\t\tif (!ctx) return false;\n\t\t\tconst block: BlockNode | undefined = ctx.getState().getBlock(bid);\n\t\t\treturn block?.type === 'code_block';\n\t\t},\n\n\t\tgetSupportedLanguages(): readonly string[] {\n\t\t\tconst highlighter: SyntaxHighlighter | null = getHighlighter();\n\t\t\tif (!highlighter) return [];\n\t\t\treturn highlighter.getSupportedLanguages();\n\t\t},\n\t});\n}\n\n// --- Helper ---\n\nfunction setAttr(context: PluginContext, bid: BlockId, key: string, value: string): void {\n\tconst state = context.getState();\n\tconst block: BlockNode | undefined = state.getBlock(bid);\n\tif (!block || block.type !== 'code_block') return;\n\n\tconst path: BlockId[] | undefined = state.getNodePath(bid);\n\tif (!path) return;\n\n\tconst newAttrs: BlockAttrs = { ...block.attrs, [key]: value };\n\tconst tr: Transaction = state.transaction('command').setNodeAttr(path, newAttrs).build();\n\n\tcontext.dispatch(tr);\n}\n","/**\n * Per-block syntax-token cache for the code-block plugin.\n *\n * Holds the tokens produced by the active {@link SyntaxHighlighter} keyed by\n * block id, re-tokenizing only when a block's text or language changes. Lookups\n * use binary search over the cached, range-ordered token list and never trigger\n * a fresh tokenize.\n */\n\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { SyntaxHighlighter, SyntaxToken } from './CodeBlockTypes.js';\n\ninterface CacheEntry {\n\treadonly text: string;\n\treadonly language: string;\n\treadonly tokens: readonly SyntaxToken[];\n}\n\nexport class TokenCache {\n\tprivate readonly entries = new Map<BlockId, CacheEntry>();\n\n\t/**\n\t * Returns the cached tokens for `blockId`, re-tokenizing via `highlighter`\n\t * when the block's text or language has changed since the last call.\n\t * Returns an empty list when no highlighter is available.\n\t */\n\tgetTokens(\n\t\tblockId: BlockId,\n\t\ttext: string,\n\t\tlanguage: string,\n\t\thighlighter: SyntaxHighlighter | null,\n\t): readonly SyntaxToken[] {\n\t\tconst cached: CacheEntry | undefined = this.entries.get(blockId);\n\t\tif (cached && cached.text === text && cached.language === language) {\n\t\t\treturn cached.tokens;\n\t\t}\n\t\tconst tokens: readonly SyntaxToken[] = highlighter?.tokenize(text, language) ?? [];\n\t\tthis.entries.set(blockId, { text, language, tokens });\n\t\treturn tokens;\n\t}\n\n\t/**\n\t * Binary-searches the cached token list for the token whose range covers\n\t * `offset`. Returns `undefined` on cache miss or if the offset lies in a gap\n\t * between tokens.\n\t */\n\tfindTokenAt(blockId: BlockId, offset: number): SyntaxToken | undefined {\n\t\tconst cached: CacheEntry | undefined = this.entries.get(blockId);\n\t\tif (!cached) return undefined;\n\t\tconst tokens: readonly SyntaxToken[] = cached.tokens;\n\t\tlet low = 0;\n\t\tlet high = tokens.length - 1;\n\t\twhile (low <= high) {\n\t\t\tconst mid: number = (low + high) >>> 1;\n\t\t\tconst token: SyntaxToken | undefined = tokens[mid];\n\t\t\tif (!token) return undefined;\n\t\t\tif (offset < token.from) {\n\t\t\t\thigh = mid - 1;\n\t\t\t} else if (offset >= token.to) {\n\t\t\t\tlow = mid + 1;\n\t\t\t} else {\n\t\t\t\treturn token;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Drops cache entries whose block id is not in `activeIds`. */\n\tretain(activeIds: ReadonlySet<BlockId>): void {\n\t\tfor (const cachedId of this.entries.keys()) {\n\t\t\tif (!activeIds.has(cachedId)) {\n\t\t\t\tthis.entries.delete(cachedId);\n\t\t\t}\n\t\t}\n\t}\n\n\tclear(): void {\n\t\tthis.entries.clear();\n\t}\n}\n","/**\n * CodeBlockPlugin: orchestrates code-block registration by composing focused\n * collaborators — {@link TokenCache} (syntax-token caching), {@link AutoPairController}\n * (bracket/quote pairing), the highlighting setup, the decoration builder, and\n * the static schema/keyboard/command/service registrars.\n *\n * The plugin itself only wires these together and forwards the lifecycle hooks\n * (`decorations`, `onStateChange`, `destroy`).\n */\n\nimport type { DecorationSet } from '../../decorations/Decoration.js';\nimport { CODE_BLOCK_CSS } from '../../editor/styles/code-block.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { isTextSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { PopupManager } from '../shared/PopupManager.js';\nimport { AutoPairController } from './AutoPairController.js';\nimport { registerCodeBlockCommands } from './CodeBlockCommands.js';\nimport { createCodeBlockDecorations } from './CodeBlockDecorations.js';\nimport { setupHighlighting } from './CodeBlockHighlighting.js';\nimport { registerCodeBlockKeymaps } from './CodeBlockKeyboardHandlers.js';\nimport {\n\tCODE_BLOCK_LOCALE_EN,\n\ttype CodeBlockLocale,\n\tloadCodeBlockLocale,\n} from './CodeBlockLocale.js';\nimport { type LanguagePickerDeps, createCodeBlockNodeViewFactory } from './CodeBlockNodeView.js';\nimport {\n\tpatchTableCellContent,\n\tregisterCodeBlockInputRule,\n\tregisterCodeBlockMarkGuard,\n\tregisterCodeBlockNodeSpec,\n\tregisterCodeBlockPasteInterceptor,\n\tregisterCodeBlockToolbarItem,\n} from './CodeBlockSchema.js';\nimport { registerCodeBlockService } from './CodeBlockService.js';\nimport type {\n\tCodeBlockConfig,\n\tCodeBlockKeymap,\n\tResolvedIndentConfig,\n\tResolvedPairingConfig,\n\tSyntaxHighlighter,\n} from './CodeBlockTypes.js';\nimport {\n\tDEFAULT_CONFIG,\n\tDEFAULT_INDENT,\n\tDEFAULT_KEYMAP,\n\tDEFAULT_PAIRING,\n\tMAX_SPACE_COUNT,\n\tMIN_SPACE_COUNT,\n} from './CodeBlockTypes.js';\nimport { TokenCache } from './TokenCache.js';\n\nexport class CodeBlockPlugin implements Plugin {\n\treadonly id = 'code-block';\n\treadonly name = 'Code Block';\n\treadonly priority = 36;\n\n\tprivate readonly config: CodeBlockConfig;\n\tprivate readonly resolvedIndent: ResolvedIndentConfig;\n\tprivate readonly resolvedPairing: ResolvedPairingConfig;\n\tprivate readonly resolvedKeymap: Readonly<Record<keyof CodeBlockKeymap, string | null>>;\n\tprivate context: PluginContext | null = null;\n\tprivate locale!: CodeBlockLocale;\n\tprivate highlighter: SyntaxHighlighter | null = null;\n\tprivate readonly tokenCache = new TokenCache();\n\tprivate readonly autoPair: AutoPairController;\n\n\tconstructor(config?: Partial<CodeBlockConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t\tthis.resolvedIndent = resolveIndentConfig(this.config);\n\t\tthis.resolvedPairing = resolvePairingConfig(this.config);\n\t\tthis.resolvedKeymap = {\n\t\t\t...DEFAULT_KEYMAP,\n\t\t\t...config?.keymap,\n\t\t};\n\t\tthis.autoPair = new AutoPairController({\n\t\t\tresolvedIndent: this.resolvedIndent,\n\t\t\tresolvedPairing: this.resolvedPairing,\n\t\t\tgetTokenAt: (blockId, offset) => this.tokenCache.findTokenAt(blockId, offset),\n\t\t\tgetCompositionState: () => this.context?.getCompositionState() ?? null,\n\t\t});\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tthis.config.locale,\n\t\t\tCODE_BLOCK_LOCALE_EN,\n\t\t\tloadCodeBlockLocale,\n\t\t);\n\t\tcontext.registerStyleSheet(CODE_BLOCK_CSS);\n\t\tthis.context = context;\n\n\t\tthis.highlighter = setupHighlighting(context, this.config, this.tokenCache);\n\t\tregisterCodeBlockNodeSpec(context);\n\t\tthis.registerNodeView(context);\n\t\tregisterCodeBlockCommands(context, this.config);\n\t\tregisterCodeBlockKeymaps(context, this.config, this.resolvedKeymap, {\n\t\t\tindent: this.resolvedIndent,\n\t\t\tpairing: this.resolvedPairing,\n\t\t\tpairStack: this.autoPair.pairStack,\n\t\t\tlocale: () => this.locale,\n\t\t});\n\t\tregisterCodeBlockInputRule(context);\n\t\tregisterCodeBlockToolbarItem(context, this.locale, this.resolvedKeymap.toggle);\n\t\tregisterCodeBlockMarkGuard(context);\n\t\tregisterCodeBlockService(\n\t\t\tcontext,\n\t\t\t() => this.highlighter,\n\t\t\t() => this.context,\n\t\t);\n\t\tregisterCodeBlockPasteInterceptor(context);\n\t\tcontext.registerTextInputInterceptor(this.autoPair.handleTextInput, {\n\t\t\tname: 'code-block:auto-pair',\n\t\t\tpriority: 10,\n\t\t});\n\t\tpatchTableCellContent(context);\n\t}\n\n\tdestroy(): void {\n\t\tthis.context = null;\n\t\tthis.highlighter = null;\n\t\tthis.tokenCache.clear();\n\t\tthis.autoPair.clear();\n\t}\n\n\tonStateChange(oldState: EditorState, newState: EditorState, tr: Transaction): void {\n\t\tthis.autoPair.syncOnStateChange(newState, tr);\n\n\t\tif (!this.context) return;\n\n\t\tconst oldBlockId: BlockId | null = !isTextSelection(oldState.selection)\n\t\t\t? null\n\t\t\t: oldState.selection.anchor.blockId;\n\t\tconst newBlockId: BlockId | null = !isTextSelection(newState.selection)\n\t\t\t? null\n\t\t\t: newState.selection.anchor.blockId;\n\n\t\tconst oldBlock: BlockNode | undefined = oldBlockId ? oldState.getBlock(oldBlockId) : undefined;\n\t\tconst newBlock: BlockNode | undefined = newBlockId ? newState.getBlock(newBlockId) : undefined;\n\n\t\tconst wasInCode: boolean = oldBlock?.type === 'code_block';\n\t\tconst nowInCode: boolean = newBlock?.type === 'code_block';\n\n\t\tif (!wasInCode && nowInCode) {\n\t\t\tthis.context.announce(this.locale.enteredCodeBlock);\n\t\t} else if (wasInCode && !nowInCode) {\n\t\t\tthis.context.announce(this.locale.leftCodeBlock);\n\t\t}\n\t}\n\n\tdecorations(state: EditorState): DecorationSet {\n\t\treturn createCodeBlockDecorations(state, {\n\t\t\thighlighter: this.highlighter,\n\t\t\ttokenCache: this.tokenCache,\n\t\t});\n\t}\n\n\tprivate registerNodeView(context: PluginContext): void {\n\t\tconst popupManager: PopupManager = new PopupManager(context.getContainer());\n\t\tconst highlighter = this.highlighter;\n\t\tconst pickerDeps: LanguagePickerDeps = {\n\t\t\tpopupManager,\n\t\t\tgetSupportedLanguages: () => highlighter?.getSupportedLanguages() ?? [],\n\t\t};\n\n\t\tcontext.registerNodeView(\n\t\t\t'code_block',\n\t\t\tcreateCodeBlockNodeViewFactory(this.config, this.locale, pickerDeps),\n\t\t);\n\t}\n}\n\n/**\n * Merges `indent.*` overrides with deprecated top-level `useSpaces`/`spaceCount`\n * fallbacks, and clamps `spaceCount` once into [MIN_SPACE_COUNT, MAX_SPACE_COUNT].\n */\nfunction resolveIndentConfig(config: CodeBlockConfig): ResolvedIndentConfig {\n\tconst useSpaces: boolean =\n\t\tconfig.indent?.useSpaces ?? config.useSpaces ?? DEFAULT_INDENT.useSpaces;\n\tconst rawSpaceCount: number =\n\t\tconfig.indent?.spaceCount ?? config.spaceCount ?? DEFAULT_INDENT.spaceCount;\n\tconst spaceCount: number = Math.max(\n\t\tMIN_SPACE_COUNT,\n\t\tMath.min(MAX_SPACE_COUNT, Math.trunc(rawSpaceCount)),\n\t);\n\tconst mode: 'none' | 'keep' | 'brackets' = config.indent?.mode ?? DEFAULT_INDENT.mode;\n\treturn { mode, useSpaces, spaceCount };\n}\n\nfunction resolvePairingConfig(config: CodeBlockConfig): ResolvedPairingConfig {\n\tconst p = config.pairing;\n\treturn {\n\t\tbrackets: p?.brackets ?? DEFAULT_PAIRING.brackets,\n\t\tquotes: p?.quotes ?? DEFAULT_PAIRING.quotes,\n\t\tovertype: p?.overtype ?? DEFAULT_PAIRING.overtype,\n\t\tdeletePair: p?.deletePair ?? DEFAULT_PAIRING.deletePair,\n\t\tsurround: p?.surround ?? DEFAULT_PAIRING.surround,\n\t};\n}\n"],"mappings":"s/BAWA,IAAa,EAAiB,4tHAPtB,EAAmB,IACxB,GACA,mBAAmB,0CAA6C,+CAAkD,oEAAuE,+BACzL,KAAK,UCyBK,EAA8C,CAC1D,CAAE,KAAM,IAAK,MAAO,IAAK,KAAM,WAC/B,CAAE,KAAM,IAAK,MAAO,IAAK,KAAM,WAC/B,CAAE,KAAM,IAAK,MAAO,IAAK,KAAM,WAC/B,CAAE,KAAM,IAAK,MAAO,IAAK,KAAM,SAC/B,CAAE,KAAM,IAAK,MAAO,IAAK,KAAM,SAC/B,CAAE,KAAM,IAAK,MAAO,IAAK,KAAM,UAG1B,EAAoD,IAAI,IAC7D,EAAiB,IAAK,GAAM,CAAC,EAAE,KAA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ChE,IAEL,EADsB,EAAO,aAAa,kBAAoB,IAE9D,MAEF,EACA,OAAA,GACC,EAAO,aAAa,gBAAiB,QACtC,IAGD,EAAO,aAAa,gBAAiB,OACtC,CCqKI,CAAmB,CAClB,OAAQ,EACR,UAAW,EAAW,wBACtB,gBAAiB,EACjB,SACA,aAAc,EAAW,aACzB,QAAA,CAAS,GACR,GAAI,IAAa,EAAa,OAE9B,MAAM,EAAsB,IACtB,EAAqC,EAAO,SAAS,GAC3D,IAAK,EAAa,OAElB,MAAM,EAA8B,EAAO,YAAY,GACvD,IAAK,EAAM,OAEX,MAAM,EAAuB,IAAK,EAAY,MAAO,YAKrD,EAJwB,EACtB,YAAY,WACZ,YAAY,EAAM,GAClB,SAGF,MAAM,EAAmB,GAAY,EAAO,UAC5C,EAAS,EAAO,gBAAgB,GACjC,MAOI,CACN,IAAK,EACL,WAAY,EAEZ,OAAO,GACmB,eAArB,EAAY,OAChB,EAAgB,EAAY,GAC5B,EAAI,aAAa,gBAAiB,EAAY,IAC9C,EAAW,IACJ,GAGR,UAAA,GACC,EAAI,UAAU,IAAI,+BACnB,EAEA,YAAA,GACC,EAAI,UAAU,OAAO,+BACtB,EAEA,OAAA,GAEA,GAGH,CIzHG,CAA+B,KAAK,OAAQ,KAAK,OAAQ,GAE3D"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./TypeBrands-Ch9856Gb.mjs";import{i as t,n as o,t as r}from"./AttributedMarkCommands-D4W2Jgpj.mjs";import{t as a}from"./ColorValidation-DAijTjG9.mjs";import{t as n}from"./ColorGrid-CXRdpP_n.mjs";function s(e,t){return o(e,t,e=>e.attrs.color??null)}function l(e,t){return null!==s(e,t)}function i(t,o,n,s){if(!a(s))return!1;const l=r(o,{type:e(n),attrs:{color:s}});return!!l&&(t.dispatch(l),!0)}function c(o,r,a){const n=t(r,e(a));return!!n&&(o.dispatch(n),!0)}function m(e,t,o){e.classList.add("notectl-color-picker");const r=s(t.getState(),o.markType),a=o.columns||10,l=t.getContainer(),c=document.createElement("button");c.type="button",c.className="notectl-color-picker__default",c.textContent=o.resetLabel,c.addEventListener("mousedown",e=>{e.preventDefault(),e.stopPropagation(),t.executeCommand(o.resetCommand),o.onClose({restoreFocusTo:l})}),c.addEventListener("keydown",e=>{"Escape"===e.key&&(e.preventDefault(),o.onClose())}),e.appendChild(c),n(e,{colors:o.colors,columns:a,ariaLabel:`${o.ariaLabelPrefix} color picker`,ariaLabelPrefix:o.ariaLabelPrefix,activeColor:r,onSelect:e=>{i(t,t.getState(),o.markType,e),o.onClose({restoreFocusTo:l})},onClose:o.onClose})}export{c as a,l as i,i as n,s as r,m as t};
|
|
2
|
-
//# sourceMappingURL=ColorPickerPopup-C_74bqid.mjs.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{T as t,_ as n,b as e,g as o,h as r,m as c,n as s,o as i,p as l,s as u,u as f,v as a,w as d}from"./Document-r7vLOAGA.mjs";import{i as m,n as k,r as b,t as g}from"./WordBoundary-DxeMBRyP.mjs";import{a as p,c as I,d as h,l as S,o as B,r as x,t as T,u as O}from"./Selection-HYoVFpAx.mjs";import{i as N,r as y}from"./TypeBrands-Ch9856Gb.mjs";import{r as A}from"./NodeResolver-ChgLF_IP.mjs";import{T as M,b as j,w as v,x as w}from"./BlockInsertion-6rR9tIGP.mjs";import{i as _,n as C,o as P,r as R}from"./NavigationQueries-Bt4zZ17v.mjs";import{a as D,o as Q}from"./AttributedMarkCommands-D4W2Jgpj.mjs";import{n as W,r as q,t as z}from"./NodeSelectionCommands-Dj4VxLdD.mjs";import{n as E}from"./RangeIterator-o8v3msQe.mjs";function F(){return{nodeTypes:["paragraph"],markTypes:["bold","italic","underline"],getNodeSpec:()=>{}}}function G(t){return{nodeTypes:t.getNodeTypes(),markTypes:t.getMarkTypes(),getNodeSpec:n=>t.getNodeSpec(n),getInlineNodeSpec:n=>t.getInlineNodeSpec(n),getMarkSpec:n=>t.getMarkSpec(n)}}function H(t,n){return t.markTypes.includes(n)}function J(t,n){return t.nodeTypes.includes(n)}function K(t,n){if("after"===n.side)return U(t,n);const e=t.getBlockOrder(),o=e.indexOf(n.blockId);if(o<=0)return null;const r=e[o-1];if(!r)return null;if(_(t,r)){const n=A(t.doc,r)??[];return t.transaction("input").setSelection(x(r,n)).build()}const c=t.getBlock(r);if(!c)return null;const s=l(c);return t.transaction("input").setSelection(T(r,s)).build()}function L(t,n){if("before"===n.side)return U(t,n);const e=t.getBlockOrder(),o=e.indexOf(n.blockId);if(o>=e.length-1)return null;const r=e[o+1];if(!r)return null;if(_(t,r)){const n=A(t.doc,r)??[];return t.transaction("input").setSelection(x(r,n)).build()}return t.transaction("input").setSelection(T(r,0)).build()}function U(t,n){const e=A(t.doc,n.blockId)??[];return z(t,x(n.blockId,e))}function V(t,n){const e=A(t.doc,n);if(!e||0===e.length)return-1;const o=e[0];return t.doc.children.findIndex(t=>t.id===o)}var X={bold:!0,italic:!0,underline:!0};function Y(t,n,o=X){if(function(t,n){const e=t;return"bold"===e?!n.bold:"italic"===e?!n.italic:"underline"===e&&!n.underline}(n,o))return null;if(!H(t.schema,n))return null;if(!O(t.selection))return null;const r={type:n},c=t.selection;if(B(c)){if(!t.getBlock(c.anchor.blockId))return null;const o=Q(t),s=e(o,n)?o.filter(t=>t.type!==n):[...o,r];return t.transaction("command").setStoredMarks(s,t.storedMarks).setSelection(c).build()}const s=h(c,t.getBlockOrder()),i=t.transaction("command"),l=et(t,n);return E(t,s,(t,n,e)=>{l?i.removeMark(t,n,e,r):i.addMark(t,n,e,r)}),i.setSelection(c),i.build()}function Z(t,n){return Y(t,N("bold"),n)}function $(t,n){return Y(t,N("italic"),n)}function tt(t,n){return Y(t,N("underline"),n)}function nt(t,n){const o=t.selection;return!!O(o)&&(B(o)?e(Q(t),n):et(t,n))}function et(t,n){const e=t.selection;if(!O(e))return!1;const o=t.getBlockOrder(),r=h(e,o),c=o.indexOf(r.from.blockId),s=o.indexOf(r.to.blockId);let i=!1;for(let u=c;u<=s;u++){const e=o[u];if(!e)continue;const f=t.getBlock(e);if(!f)continue;const a=l(f),d=ot(f,u===c?r.from.offset:0,u===s?r.to.offset:a,n);if("missing"===d)return!1;"present"===d&&(i=!0)}return i}function ot(n,o,r,c){let s=0,i=!1;for(const l of a(n))if(t(l)){const t=s+l.text.length;if(t>o&&s<r&&(i=!0,!e(l.marks,c)))return"missing";s=t}else s+=1;return i?"present":"empty"}function rt(t,n){const e=t.selection;if(S(e))return z(t,e);if(I(e))return null;if(!B(e))return dt(t);const o=t.getBlock(e.anchor.blockId);if(!o)return null;const r=n.range(o,e.anchor.offset);if(!r)return n.merge(t);const[c,s]=r;return t.transaction("input").deleteTextAt(o.id,c,s).setSelection(T(o.id,c)).build()}function ct(t){return rt(t,{merge:bt,range:(t,n)=>n<=0?null:"inline"===o(t,n-1)?.kind?[n-1,n]:[n-(m(r(t),s(t,n))||1),n]})}function st(t){return rt(t,{merge:gt,range:(t,n)=>n>=l(t)?null:"inline"===o(t,n)?.kind?[n,n+1]:[n,n+(b(r(t),s(t,n))||1)]})}function it(t){return rt(t,{merge:bt,range:(t,n)=>n>0?[g(t,n),n]:null})}function lt(t){return rt(t,{merge:gt,range:(t,n)=>n<l(t)?[n,k(t,n)]:null})}function ut(t){return rt(t,{merge:bt,range:(t,n)=>n>0?[0,n]:null})}function ft(t){return rt(t,{merge:gt,range:(t,n)=>{const e=l(t);return n<e?[n,e]:null}})}function at(t,e,o="input"){const r=t.selection;if(S(r))return q(t,r,e,o);if(I(r))return function(t,n,e,o){const{parentPath:r,siblings:c,index:s}=M(t,n.blockId),l="before"===n.side?Math.max(s,0):s>=0?s+1:c.length,u=f(),a=t.transaction(o);return a.insertNode(r,l,i(u)),a.insertText(u,0,e,[]),a.setSelection(T(u,e.length)),a.build()}(t,r,e,o);const s=t.transaction(o),l=function(t){if(t.storedMarks)return t.storedMarks;const e=t.selection;if(!O(e))return[];const o=t.getBlock(e.anchor.blockId);return o?B(e)?n(o,e.anchor.offset,n=>D(t.schema,n)):c(o,e.anchor.offset):[]}(t);let u;B(r)||(u=St(t,s));const a=v(r,t.getBlockOrder()),d=u??a.blockId,m=u?0:a.offset;return s.insertText(d,m,e,l),s.setSelection(T(d,m+e.length)),s.build()}function dt(t){if(S(t.selection))return z(t,t.selection);if(I(t.selection))return null;if(B(t.selection))return null;if(function(t){if(!O(t.selection))return!1;const n=ht(t);if(!n)return!1;const e=h(t.selection,t.getBlockOrder());return e.from.blockId===n.from.blockId&&e.from.offset===n.from.offset&&e.to.blockId===n.to.blockId&&e.to.offset===n.to.offset}(t))return function(t){const n=f(),e=t.transaction("input"),o=t.doc.children.length;e.insertNode([],0,i(n));for(let r=o;r>=1;r--)e.removeNode([],r);return e.setSelection(T(n,0)),e.build()}(t);const n=t.transaction("input"),e=St(t,n),o=h(t.selection,t.getBlockOrder()),r=e??o.from.blockId,c=e?0:o.from.offset;return n.setSelection(T(r,c)),n.build()}function mt(t){const n=t.selection;if(S(n))return W(t,n);if(I(n))return function(t,n){const{parentPath:e,index:o}=M(t,n.blockId);if(o<0)return null;const r="before"===n.side?o:o+1,c=f(),s=t.transaction("input");return s.insertNode(e,r,i(c)),s.setSelection(T(c,0)),s.build()}(t,n);const e=t.transaction("input");let o;B(n)||(o=St(t,e));const r=v(n,t.getBlockOrder()),c=o??r.blockId,s=o?0:r.offset,l=f();return e.splitBlock(c,s,l),e.setSelection(T(l,0)),e.build()}function kt(t){const n=t.selection;if(!O(n))return null;const e=t.transaction("input");let o;if(B(n)||(o=St(t,e)),o)e.insertInlineNode(o,0,u(y("hard_break"))),e.setSelection(T(o,1));else{const{blockId:o,offset:r}=v(n,t.getBlockOrder());e.insertInlineNode(o,r,u(y("hard_break"))),e.setSelection(T(o,r+1))}return e.build()}function bt(t){return pt(t,"backward")}function gt(t){return pt(t,"forward")}function pt(t,n){const e=t.selection;if(!O(e))return null;const o=t.getBlockOrder(),r=o.indexOf(e.anchor.blockId),c="backward"===n?r-1:r+1;if(c<0||c>=o.length)return null;const s=o[c];if(!s)return null;if(R(t,e.anchor.blockId)||R(t,s))return null;if(!P(t,e.anchor.blockId,s)&&C(t,e.anchor.blockId))return null;if(_(t,s)){const n=A(t.doc,s)??[];return t.transaction("input").setSelection(x(s,n)).build()}if("backward"===n){const n=t.getBlock(s);if(!n)return null;const o=l(n);return t.transaction("input").mergeBlocksAt(s,e.anchor.blockId).setSelection(T(s,o)).build()}return t.transaction("input").mergeBlocksAt(e.anchor.blockId,s).setSelection(T(e.anchor.blockId,e.anchor.offset)).build()}function It(t){const n=ht(t);return n?t.transaction("command").setSelection(p(n.from,n.to)).build():t.transaction("command").setSelection(t.selection).build()}function ht(t){const n=t.doc.children,e=n[0],o=n[n.length-1];if(!e||!o)return null;const r=j(e),c=w(o),s=t.getBlock(c);return{from:{blockId:r,offset:0},to:{blockId:c,offset:s?l(s):0}}}function St(t,n){if(!O(t.selection))return;const e=t.getBlockOrder(),o=h(t.selection,e),r=e.indexOf(o.from.blockId),c=e.indexOf(o.to.blockId);if(r===c)return void n.deleteTextAt(o.from.blockId,o.from.offset,o.to.offset);const s=V(t,o.from.blockId),u=V(t,o.to.blockId);if(!(s===u||s<0||u<0))return function(t,n,e,o,r){const c=t.doc.children[o],s=t.doc.children[r];if(!c||!s)return;const u=d(c),a=d(s);let m,k=0;if(u||(m=f(),n.insertNode([],o,i(m)),k=1),u){const o=t.getBlock(e.from.blockId);if(o){const t=l(o);e.from.offset<t&&n.deleteTextAt(e.from.blockId,e.from.offset,t)}}a&&e.to.offset>0&&n.deleteTextAt(e.to.blockId,0,e.to.offset);const b=u?o+1:o+k;for(let i=a?r-1+k:r+k;i>=b;i--)n.removeNode([],i);return u&&a&&n.mergeBlocksAt(e.from.blockId,e.to.blockId),m}(t,n,o,s,u);!function(t,n,e,o,r,c){const s=t.getBlock(o.from.blockId);if(!s)return;const i=l(s);o.from.offset<i&&n.deleteTextAt(o.from.blockId,o.from.offset,i),o.to.offset>0&&n.deleteTextAt(o.to.blockId,0,o.to.offset);for(let u=r+1;u<c;u++){const r=e[u];if(!r)continue;const c=t.getBlock(r);if(!c)continue;const s=l(c);s>0&&n.deleteTextAt(r,0,s),n.mergeBlocksAt(o.from.blockId,r)}n.mergeBlocksAt(o.from.blockId,o.to.blockId)}(t,n,e,o,r,c)}export{J as C,H as S,Y as _,bt as a,L as b,ct as c,ft as d,it as f,$ as g,Z as h,at as i,st as l,nt as m,dt as n,It as o,lt as p,kt as r,mt as s,St as t,ut as u,tt as v,G as w,F as x,K as y};
|
|
2
|
-
//# sourceMappingURL=Commands-BIIpx_Zd.mjs.map
|