@notectl/core 2.2.6 → 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-DeD4C4EP.mjs → AlignmentPlugin--xAFlRqE.mjs} +2 -2
- package/dist/chunks/{AlignmentPlugin-DeD4C4EP.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-DPNiXxpD.mjs → ColorGrid-C9RQoEWF.mjs} +2 -2
- package/dist/chunks/{ColorGrid-DPNiXxpD.mjs.map → ColorGrid-C9RQoEWF.mjs.map} +1 -1
- package/dist/chunks/ColorPickerPopup-DiA68Pzz.mjs +2 -0
- package/dist/chunks/{ColorPickerPopup-lcf3jS6G.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-DQMj65Bc.mjs → FontPlugin-By-TGrQo.mjs} +2 -2
- package/dist/chunks/{FontPlugin-DQMj65Bc.mjs.map → FontPlugin-By-TGrQo.mjs.map} +1 -1
- package/dist/chunks/{FontSizePlugin-9StCjEfN.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-BuGoM9Rz.mjs.map → HeadingPlugin-uMAjPOk5.mjs.map} +1 -1
- package/dist/chunks/{HighlightPlugin-C6pHifVz.mjs → HighlightPlugin-Bj7FPkIQ.mjs} +2 -2
- package/dist/chunks/{HighlightPlugin-C6pHifVz.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-KpkuE2LH.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-C6LJT7kp.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-DUtaK3WX.mjs → PopupManager-CT-fMZJn.mjs} +2 -2
- package/dist/chunks/{PopupManager-DUtaK3WX.mjs.map → PopupManager-CT-fMZJn.mjs.map} +1 -1
- package/dist/chunks/PopupPositioning-BFh6Ed1D.mjs +2 -0
- package/dist/chunks/{PopupPositioning-BB97-__N.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/{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-CEfZQ6Md.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-DVGrFf8v.mjs → ToolbarPlugin-DtfGTO_V.mjs} +2 -2
- package/dist/chunks/{ToolbarPlugin-DVGrFf8v.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-BBl7mvwH.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-CtnR4dqp.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 +24 -0
- 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.map +1 -1
- package/dist/plugins/print/PrintServiceImpl.d.ts +5 -1
- package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -1
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
- 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/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-3V2K3RBe.mjs +0 -2
- package/dist/chunks/CodeBlockPlugin-3V2K3RBe.mjs.map +0 -1
- package/dist/chunks/ColorPickerPopup-lcf3jS6G.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/FontSizePlugin-9StCjEfN.mjs.map +0 -1
- package/dist/chunks/FormulaPlugin-CV5VUxkb.mjs +0 -2
- package/dist/chunks/FormulaPlugin-CV5VUxkb.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-BuGoM9Rz.mjs +0 -2
- package/dist/chunks/HorizontalRulePlugin-0FjHPZuA.mjs +0 -2
- package/dist/chunks/HorizontalRulePlugin-0FjHPZuA.mjs.map +0 -1
- package/dist/chunks/ImagePlugin-KpkuE2LH.mjs +0 -2
- package/dist/chunks/InlineCodePlugin-DMr4O7c7.mjs.map +0 -1
- package/dist/chunks/InlineStyleMarkSpec-C6LJT7kp.mjs +0 -2
- package/dist/chunks/LinkPlugin-DvZ3MPgL.mjs +0 -2
- package/dist/chunks/LinkPlugin-DvZ3MPgL.mjs.map +0 -1
- package/dist/chunks/ListPlugin-2yl6KiTK.mjs +0 -2
- package/dist/chunks/ListPlugin-2yl6KiTK.mjs.map +0 -1
- package/dist/chunks/NodeSelectionCommands-Dj4VxLdD.mjs +0 -2
- package/dist/chunks/PluginHelpers-KDuTlmXm.mjs +0 -2
- package/dist/chunks/PopupPositioning-BB97-__N.mjs +0 -2
- package/dist/chunks/PrintPlugin-DyIZDY3Q.mjs +0 -2
- package/dist/chunks/PrintPlugin-DyIZDY3Q.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-BFKu52mS.mjs +0 -2
- package/dist/chunks/StyleRuntime-BFKu52mS.mjs.map +0 -1
- package/dist/chunks/TablePlugin-BTH9VRZq.mjs +0 -2
- package/dist/chunks/TablePlugin-BTH9VRZq.mjs.map +0 -1
- package/dist/chunks/TextColorPlugin-CEfZQ6Md.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-B3uf1Dwp.mjs +0 -2
- package/dist/chunks/VideoPlugin-B3uf1Dwp.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-BBl7mvwH.mjs +0 -2
- package/dist/chunks/hi-C9fvG91d.mjs +0 -2
- package/dist/chunks/hi-C9fvG91d.mjs.map +0 -1
- package/dist/chunks/minimal-CtnR4dqp.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-C89Cw7ni.mjs +0 -2
- package/dist/chunks/src-C89Cw7ni.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":"CodeBlockPlugin-3V2K3RBe.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,KAAM,KAEhC,EAAqD,IAAI,IAE9D,EAAiB,OAAQ,GAAiB,YAAX,EAAE,MAAoB,IAAK,GAAM,CAAC,EAAE,MAAO,KC7B3E,IAAM,EAAgB,IAAI,IAAI,CAAC,IAAK,IAAK,MACnC,EAA2D,CAChE,IAAK,IACL,IAAK,IACL,IAAK,KAIN,SAAgB,EAAa,EAAc,GAC1C,MA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,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-DPNiXxpD.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-lcf3jS6G.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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Commands-BIIpx_Zd.mjs","names":[],"sources":["../../src/model/Schema.ts","../../src/commands/GapCursorCommands.ts","../../src/commands/SelectionDeletion.ts","../../src/commands/MarkCommands.ts","../../src/commands/DeleteCommands.ts","../../src/commands/Commands.ts"],"sourcesContent":["/**\n * Schema definition for the Notectl editor.\n * Defines which node types and marks are allowed.\n */\n\nimport type { InlineNodeSpec } from './InlineNodeSpec.js';\nimport type { MarkSpec } from './MarkSpec.js';\nimport type { NodeSpec } from './NodeSpec.js';\nimport type { SchemaRegistry } from './SchemaRegistry.js';\n\nexport interface Schema {\n\treadonly nodeTypes: readonly string[];\n\treadonly markTypes: readonly string[];\n\t/** Looks up the full NodeSpec for a given type. Available when created via schemaFromRegistry. */\n\treadonly getNodeSpec?: (type: string) => NodeSpec | undefined;\n\t/** Looks up the full InlineNodeSpec for a given type. Available via schemaFromRegistry. */\n\treadonly getInlineNodeSpec?: (type: string) => InlineNodeSpec | undefined;\n\t/** Looks up the full MarkSpec for a given type. Available via schemaFromRegistry. */\n\treadonly getMarkSpec?: (type: string) => MarkSpec | undefined;\n}\n\n/** Creates the default schema with paragraph nodes and bold/italic/underline marks. */\nexport function defaultSchema(): Schema {\n\treturn {\n\t\tnodeTypes: ['paragraph'],\n\t\tmarkTypes: ['bold', 'italic', 'underline'],\n\t\tgetNodeSpec: () => undefined,\n\t};\n}\n\n/** Derives a Schema from a SchemaRegistry's registered specs. */\nexport function schemaFromRegistry(registry: SchemaRegistry): Schema {\n\treturn {\n\t\tnodeTypes: registry.getNodeTypes(),\n\t\tmarkTypes: registry.getMarkTypes(),\n\t\tgetNodeSpec: (type: string) => registry.getNodeSpec(type),\n\t\tgetInlineNodeSpec: (type: string) => registry.getInlineNodeSpec(type),\n\t\tgetMarkSpec: (type: string) => registry.getMarkSpec(type),\n\t};\n}\n\n/** Checks whether the given mark type is allowed by the schema. */\nexport function isMarkAllowed(schema: Schema, markType: string): boolean {\n\treturn schema.markTypes.includes(markType);\n}\n\n/** Checks whether the given node type is allowed by the schema. */\nexport function isNodeTypeAllowed(schema: Schema, nodeType: string): boolean {\n\treturn schema.nodeTypes.includes(nodeType);\n}\n","/**\n * Commands for GapCursor: deleting void blocks adjacent to gap cursors\n * and inserting paragraphs at gap positions.\n */\n\nimport { createEmptyParagraph, generateBlockId, getBlockLength } from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { GapCursorSelection, NodeSelection } from '../model/Selection.js';\nimport { createCollapsedSelection, createNodeSelection } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock } from '../state/NavigationQueries.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { resolveSiblingContext } from './CommandHelpers.js';\nimport { deleteNodeSelection } from './NodeSelectionCommands.js';\n\n/**\n * Deletes the void block adjacent to a GapCursor when pressing Backspace.\n *\n * - `side === 'after'` → void block is behind the cursor → delete it.\n * - `side === 'before'` → void block is ahead → navigate backward (to previous block).\n * - At document start with `side === 'before'` → `null` (no-op).\n */\nexport function deleteBackwardAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tif (sel.side === 'after') {\n\t\treturn deleteVoidAtGap(state, sel);\n\t}\n\n\t// side === 'before': navigate to previous block\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\n\tif (blockIdx <= 0) return null;\n\n\tconst prevId: BlockId | undefined = blockOrder[blockIdx - 1];\n\tif (!prevId) return null;\n\n\tif (isVoidBlock(state, prevId)) {\n\t\tconst path = findNodePath(state.doc, prevId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(prevId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\tconst prevBlock = state.getBlock(prevId);\n\tif (!prevBlock) return null;\n\tconst prevLen: number = getBlockLength(prevBlock);\n\treturn state.transaction('input').setSelection(createCollapsedSelection(prevId, prevLen)).build();\n}\n\n/**\n * Deletes the void block adjacent to a GapCursor when pressing Delete.\n *\n * - `side === 'before'` → void block is ahead of the cursor → delete it.\n * - `side === 'after'` → void block is behind → navigate forward (to next block).\n * - At document end with `side === 'after'` → `null` (no-op).\n */\nexport function deleteForwardAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tif (sel.side === 'before') {\n\t\treturn deleteVoidAtGap(state, sel);\n\t}\n\n\t// side === 'after': navigate to next block\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\n\tif (blockIdx >= blockOrder.length - 1) return null;\n\n\tconst nextId: BlockId | undefined = blockOrder[blockIdx + 1];\n\tif (!nextId) return null;\n\n\tif (isVoidBlock(state, nextId)) {\n\t\tconst path = findNodePath(state.doc, nextId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(nextId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\treturn state.transaction('input').setSelection(createCollapsedSelection(nextId, 0)).build();\n}\n\n/** Deletes the void block that the GapCursor is adjacent to, delegating to deleteNodeSelection. */\nfunction deleteVoidAtGap(state: EditorState, sel: GapCursorSelection): Transaction | null {\n\tconst path = (findNodePath(state.doc, sel.blockId) ?? []) as BlockId[];\n\tconst nodeSel: NodeSelection = createNodeSelection(sel.blockId, path);\n\treturn deleteNodeSelection(state, nodeSel);\n}\n\n/** Inserts a new paragraph at a GapCursor position (before or after the void block). */\nexport function insertParagraphAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n): Transaction | null {\n\tconst { parentPath, index } = resolveSiblingContext(state, sel.blockId);\n\tif (index < 0) return null;\n\n\tconst insertIdx: number = sel.side === 'before' ? index : index + 1;\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.setSelection(createCollapsedSelection(newId, 0));\n\treturn builder.build();\n}\n\n/** Inserts text in a new paragraph at a GapCursor position. */\nexport function insertTextAtGap(\n\tstate: EditorState,\n\tsel: GapCursorSelection,\n\ttext: string,\n\torigin: 'input' | 'paste',\n): Transaction {\n\tconst { parentPath, siblings, index } = resolveSiblingContext(state, sel.blockId);\n\tconst insertIdx: number =\n\t\tsel.side === 'before' ? Math.max(index, 0) : index >= 0 ? index + 1 : siblings.length;\n\n\tconst newId = generateBlockId();\n\tconst builder = state.transaction(origin);\n\tbuilder.insertNode(parentPath, insertIdx, createEmptyParagraph(newId));\n\tbuilder.insertText(newId, 0, text, []);\n\tbuilder.setSelection(createCollapsedSelection(newId, text.length));\n\treturn builder.build();\n}\n","/**\n * Range-deletion helpers for multi-block text selections, split out of\n * Commands.ts. Handles two cases: a selection whose blocks share one root\n * ancestor (leaf range) and a selection spanning different root ancestors\n * (cross-root range).\n */\n\nimport {\n\tcreateEmptyParagraph,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tisLeafBlock,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\n\n/** A normalized text-selection range (document-order from/to positions). */\nexport interface DeletionRange {\n\treadonly from: { readonly blockId: BlockId; readonly offset: number };\n\treadonly to: { readonly blockId: BlockId; readonly offset: number };\n}\n\n/** Returns the root-level ancestor index in `doc.children` for a given block. */\nexport function getRootBlockIndex(state: EditorState, blockId: BlockId): number {\n\tconst path = findNodePath(state.doc, blockId);\n\tif (!path || path.length === 0) return -1;\n\tconst rootId: string = path[0] as string;\n\treturn state.doc.children.findIndex((c) => c.id === rootId);\n}\n\n/** Deletes a multi-block selection where all blocks share the same root ancestor. */\nexport function deleteLeafRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tblockOrder: readonly BlockId[],\n\trange: DeletionRange,\n\tfromIdx: number,\n\ttoIdx: number,\n): void {\n\tconst firstBlock = state.getBlock(range.from.blockId);\n\tif (!firstBlock) return;\n\tconst firstLen = getBlockLength(firstBlock);\n\n\tif (range.from.offset < firstLen) {\n\t\tbuilder.deleteTextAt(range.from.blockId, range.from.offset, firstLen);\n\t}\n\n\tif (range.to.offset > 0) {\n\t\tbuilder.deleteTextAt(range.to.blockId, 0, range.to.offset);\n\t}\n\n\tfor (let i = fromIdx + 1; i < toIdx; i++) {\n\t\tconst midBlockId = blockOrder[i];\n\t\tif (!midBlockId) continue;\n\t\tconst midBlock = state.getBlock(midBlockId);\n\t\tif (!midBlock) continue;\n\t\tconst midLen = getBlockLength(midBlock);\n\t\tif (midLen > 0) {\n\t\t\tbuilder.deleteTextAt(midBlockId, 0, midLen);\n\t\t}\n\t\tbuilder.mergeBlocksAt(range.from.blockId, midBlockId);\n\t}\n\n\tbuilder.mergeBlocksAt(range.from.blockId, range.to.blockId);\n}\n\n/**\n * Deletes a selection spanning different root-level ancestors.\n * Removes intermediate and composite root blocks, merges leaf roots.\n * Returns a replacement cursor block ID if from was inside a removed composite.\n */\nexport function deleteCrossRootRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\trange: DeletionRange,\n\tfromRootIdx: number,\n\ttoRootIdx: number,\n): BlockId | undefined {\n\tconst fromRoot = state.doc.children[fromRootIdx];\n\tconst toRoot = state.doc.children[toRootIdx];\n\tif (!fromRoot || !toRoot) return undefined;\n\n\tconst fromIsLeaf: boolean = isLeafBlock(fromRoot);\n\tconst toIsLeaf: boolean = isLeafBlock(toRoot);\n\n\t// When from is inside a composite root, insert a landing paragraph\n\t// so callers can reference a surviving block for cursor/insert.\n\tlet landingId: BlockId | undefined;\n\tlet indexShift = 0;\n\n\tif (!fromIsLeaf) {\n\t\tlandingId = generateBlockId();\n\t\tbuilder.insertNode([], fromRootIdx, createEmptyParagraph(landingId));\n\t\tindexShift = 1;\n\t}\n\n\t// Delete text in from-leaf (only for leaf roots; composite roots are removed entirely)\n\tif (fromIsLeaf) {\n\t\tconst fromBlock = state.getBlock(range.from.blockId);\n\t\tif (fromBlock) {\n\t\t\tconst fromLen: number = getBlockLength(fromBlock);\n\t\t\tif (range.from.offset < fromLen) {\n\t\t\t\tbuilder.deleteTextAt(range.from.blockId, range.from.offset, fromLen);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Delete text in to-leaf (only for leaf roots)\n\tif (toIsLeaf && range.to.offset > 0) {\n\t\tbuilder.deleteTextAt(range.to.blockId, 0, range.to.offset);\n\t}\n\n\t// Remove root-level blocks in descending index order.\n\t// Keep from-root if it's a leaf; remove if composite (shifted by indexShift).\n\t// Keep to-root if it's a leaf (will merge into from); remove if composite.\n\tconst removeEnd: number = toIsLeaf ? toRootIdx - 1 + indexShift : toRootIdx + indexShift;\n\tconst removeStart: number = fromIsLeaf ? fromRootIdx + 1 : fromRootIdx + indexShift;\n\n\tfor (let i = removeEnd; i >= removeStart; i--) {\n\t\tbuilder.removeNode([], i);\n\t}\n\n\t// Merge to-root into from if both are leaf roots\n\tif (fromIsLeaf && toIsLeaf) {\n\t\tbuilder.mergeBlocksAt(range.from.blockId, range.to.blockId);\n\t}\n\n\treturn landingId;\n}\n","/**\n * Mark-related commands: toggling bold/italic/underline and checking\n * whether a mark is active.\n */\n\nimport {\n\ttype BlockNode,\n\ttype Mark,\n\tgetBlockLength,\n\tgetInlineChildren,\n\thasMark,\n\tisTextNode,\n} from '../model/Document.js';\nimport { isMarkAllowed } from '../model/Schema.js';\nimport { isCollapsed, isTextSelection, selectionRange } from '../model/Selection.js';\nimport type { MarkTypeName } from '../model/TypeBrands.js';\nimport { markType as mkType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { resolveCursorMarks } from './CursorMarks.js';\nimport { forEachBlockInRange } from './RangeIterator.js';\n\n// --- Feature Configuration ---\n\nexport interface FeatureConfig {\n\treadonly bold: boolean;\n\treadonly italic: boolean;\n\treadonly underline: boolean;\n}\n\nconst defaultFeatures: FeatureConfig = { bold: true, italic: true, underline: true };\n\n/**\n * Toggles a mark on the current selection.\n * If collapsed, toggles stored marks. If range, applies/removes from text.\n */\nexport function toggleMark(\n\tstate: EditorState,\n\tmarkType: MarkTypeName,\n\tfeatures: FeatureConfig = defaultFeatures,\n): Transaction | null {\n\tif (isFeatureGated(markType, features)) return null;\n\tif (!isMarkAllowed(state.schema, markType)) return null;\n\tif (!isTextSelection(state.selection)) return null;\n\n\tconst mark: Mark = { type: markType };\n\tconst sel = state.selection;\n\n\tif (isCollapsed(sel)) {\n\t\t// Toggle stored marks\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return null;\n\t\tconst currentMarks = resolveCursorMarks(state);\n\t\tconst hasIt = hasMark(currentMarks, markType);\n\t\tconst newMarks = hasIt\n\t\t\t? currentMarks.filter((m) => m.type !== markType)\n\t\t\t: [...currentMarks, mark];\n\n\t\treturn state\n\t\t\t.transaction('command')\n\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t}\n\n\t// Range selection — apply/remove mark to all blocks in range\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\n\t// Determine if we should add or remove\n\tconst shouldRemove = isMarkActiveInRange(state, markType);\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tif (shouldRemove) {\n\t\t\tbuilder.removeMark(blockId, from, to, mark);\n\t\t} else {\n\t\t\tbuilder.addMark(blockId, from, to, mark);\n\t\t}\n\t});\n\n\tbuilder.setSelection(sel);\n\treturn builder.build();\n}\n\nexport function toggleBold(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('bold'), features);\n}\n\nexport function toggleItalic(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('italic'), features);\n}\n\nexport function toggleUnderline(state: EditorState, features?: FeatureConfig): Transaction | null {\n\treturn toggleMark(state, mkType('underline'), features);\n}\n\n/** Checks if a mark is active at the current selection. */\nexport function isMarkActive(state: EditorState, markType: MarkTypeName): boolean {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\n\tif (isCollapsed(sel)) {\n\t\treturn hasMark(resolveCursorMarks(state), markType);\n\t}\n\n\treturn isMarkActiveInRange(state, markType);\n}\n\n/** Per-slice result of scanning a block for a mark. */\ntype SliceMarkStatus = 'present' | 'missing' | 'empty';\n\n/** Checks if a mark is active across the entire selection range. */\nfunction isMarkActiveInRange(state: EditorState, markType: MarkTypeName): boolean {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return false;\n\tconst blockOrder = state.getBlockOrder();\n\tconst range = selectionRange(sel, blockOrder);\n\n\tconst fromIdx = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx = blockOrder.indexOf(range.to.blockId);\n\n\tlet sawMarkedText = false;\n\tfor (let i = fromIdx; i <= toIdx; i++) {\n\t\tconst blockId = blockOrder[i];\n\t\tif (!blockId) continue;\n\t\tconst block = state.getBlock(blockId);\n\t\tif (!block) continue;\n\t\tconst blockLen = getBlockLength(block);\n\t\tconst from = i === fromIdx ? range.from.offset : 0;\n\t\tconst to = i === toIdx ? range.to.offset : blockLen;\n\n\t\tconst status = markStatusInBlock(block, from, to, markType);\n\t\tif (status === 'missing') return false;\n\t\tif (status === 'present') sawMarkedText = true;\n\t}\n\n\t// Active only when the range actually contains text that carries the mark.\n\t// A range with no markable text (only empty blocks, or a void block such as a\n\t// lone display formula on Ctrl+A) is NOT active — returning true there would\n\t// light up every toolbar format button.\n\treturn sawMarkedText;\n}\n\n/**\n * Scans a block's `[from, to)` slice for `markType`. Returns:\n * - `missing` when some text character in the slice lacks the mark,\n * - `present` when the slice has text and all of it carries the mark,\n * - `empty` when the slice has no markable text (empty slice or only InlineNodes).\n *\n * An `empty` slice is neutral: it neither activates nor inverts the range check,\n * so an empty paragraph in the middle of a multi-block selection does not flip\n * the result (regression #130).\n */\nfunction markStatusInBlock(\n\tblock: BlockNode,\n\tfrom: number,\n\tto: number,\n\tmarkType: MarkTypeName,\n): SliceMarkStatus {\n\tlet pos = 0;\n\tlet sawText = false;\n\tfor (const child of getInlineChildren(block)) {\n\t\tif (isTextNode(child)) {\n\t\t\tconst childEnd = pos + child.text.length;\n\t\t\tif (childEnd > from && pos < to) {\n\t\t\t\tsawText = true;\n\t\t\t\tif (!hasMark(child.marks, markType)) return 'missing';\n\t\t\t}\n\t\t\tpos = childEnd;\n\t\t} else {\n\t\t\t// InlineNode: atomic, width 1, carries no marks.\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn sawText ? 'present' : 'empty';\n}\n\nfunction isFeatureGated(type: MarkTypeName, features: FeatureConfig): boolean {\n\tconst key = type as string;\n\tif (key === 'bold') return !features.bold;\n\tif (key === 'italic') return !features.italic;\n\tif (key === 'underline') return !features.underline;\n\treturn false;\n}\n","/**\n * Delete commands: character, word, and soft-line deletion in both directions.\n */\n\nimport {\n\ttype BlockNode,\n\tblockOffsetToTextOffset,\n\tgetBlockLength,\n\tgetBlockText,\n\tgetContentAtOffset,\n} from '../model/Document.js';\nimport { nextGraphemeSize, prevGraphemeSize } from '../model/GraphemeUtils.js';\nimport {\n\tcreateCollapsedSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../model/Selection.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { deleteSelectionCommand, mergeBlockBackward, mergeBlockForward } from './Commands.js';\nimport { deleteNodeSelection } from './NodeSelectionCommands.js';\nimport { findWordBoundaryBackward, findWordBoundaryForward } from './WordBoundary.js';\n\ninterface DeleteConfig {\n\treadonly merge: (state: EditorState) => Transaction | null;\n\treadonly range: (block: BlockNode, offset: number) => readonly [number, number] | null;\n}\n\nfunction deleteInDirection(state: EditorState, config: DeleteConfig): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (isNodeSelection(sel)) return deleteNodeSelection(state, sel);\n\tif (isGapCursor(sel)) return null;\n\tif (!isCollapsed(sel)) return deleteSelectionCommand(state);\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\n\tconst range = config.range(block, sel.anchor.offset);\n\tif (!range) return config.merge(state);\n\n\tconst [from, to] = range;\n\treturn state\n\t\t.transaction('input')\n\t\t.deleteTextAt(block.id, from, to)\n\t\t.setSelection(createCollapsedSelection(block.id, from))\n\t\t.build();\n}\n\n/** Handles backspace key. */\nexport function deleteBackward(state: EditorState): Transaction | null {\n\treturn deleteInDirection(state, {\n\t\tmerge: mergeBlockBackward,\n\t\trange: (block, offset) => {\n\t\t\tif (offset <= 0) return null;\n\t\t\tconst content = getContentAtOffset(block, offset - 1);\n\t\t\tif (content?.kind === 'inline') return [offset - 1, offset];\n\t\t\tconst text: string = getBlockText(block);\n\t\t\tconst textOffset: number = blockOffsetToTextOffset(block, offset);\n\t\t\tconst step: number = prevGraphemeSize(text, textOffset) || 1;\n\t\t\treturn [offset - step, offset];\n\t\t},\n\t});\n}\n\n/** Handles delete key. */\nexport function deleteForward(state: EditorState): Transaction | null {\n\treturn deleteInDirection(state, {\n\t\tmerge: mergeBlockForward,\n\t\trange: (block, offset) => {\n\t\t\tconst len: number = getBlockLength(block);\n\t\t\tif (offset >= len) return null;\n\t\t\tconst content = getContentAtOffset(block, offset);\n\t\t\tif (content?.kind === 'inline') return [offset, offset + 1];\n\t\t\tconst text: string = getBlockText(block);\n\t\t\tconst textOffset: number = blockOffsetToTextOffset(block, offset);\n\t\t\tconst step: number = nextGraphemeSize(text, textOffset) || 1;\n\t\t\treturn [offset, offset + step];\n\t\t},\n\t});\n}\n\n/** Handles Ctrl+Backspace: delete word backward. */\nexport function deleteWordBackward(state: EditorState): Transaction | null {\n\treturn deleteInDirection(state, {\n\t\tmerge: mergeBlockBackward,\n\t\trange: (block, offset) =>\n\t\t\toffset > 0 ? [findWordBoundaryBackward(block, offset), offset] : null,\n\t});\n}\n\n/** Handles Ctrl+Delete: delete word forward. */\nexport function deleteWordForward(state: EditorState): Transaction | null {\n\treturn deleteInDirection(state, {\n\t\tmerge: mergeBlockForward,\n\t\trange: (block, offset) => {\n\t\t\tconst len = getBlockLength(block);\n\t\t\treturn offset < len ? [offset, findWordBoundaryForward(block, offset)] : null;\n\t\t},\n\t});\n}\n\n/** Handles Cmd+Backspace: delete to start of line/block. */\nexport function deleteSoftLineBackward(state: EditorState): Transaction | null {\n\treturn deleteInDirection(state, {\n\t\tmerge: mergeBlockBackward,\n\t\trange: (_block, offset) => (offset > 0 ? [0, offset] : null),\n\t});\n}\n\n/** Handles Cmd+Delete: delete to end of line/block. */\nexport function deleteSoftLineForward(state: EditorState): Transaction | null {\n\treturn deleteInDirection(state, {\n\t\tmerge: mergeBlockForward,\n\t\trange: (block, offset) => {\n\t\t\tconst len = getBlockLength(block);\n\t\t\treturn offset < len ? [offset, len] : null;\n\t\t},\n\t});\n}\n","/**\n * Core editor commands and barrel re-exports from submodules.\n *\n * This module contains text insertion, block splitting, block merging,\n * selection deletion, and select-all. Mark, delete, gap-cursor, node-selection,\n * and word-boundary commands are re-exported from their respective modules.\n */\n\nimport {\n\ttype Mark,\n\tcreateEmptyParagraph,\n\tcreateInlineNode,\n\tgenerateBlockId,\n\tgetBlockLength,\n\tgetBlockMarksAtOffset,\n\tgetCursorMarks,\n} from '../model/Document.js';\nimport { findNodePath } from '../model/NodeResolver.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n\tisTextSelection,\n\tselectionRange,\n} from '../model/Selection.js';\nimport { type BlockId, inlineType } from '../model/TypeBrands.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport {\n\tisInsideIsolating,\n\tisIsolatingBlock,\n\tisVoidBlock,\n\tsharesParent,\n} from '../state/NavigationQueries.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport type { TransactionBuilder } from '../state/Transaction.js';\nimport { resolveInsertPoint } from './CommandHelpers.js';\nimport { isMarkInclusive } from './CursorMarks.js';\nimport { insertParagraphAtGap, insertTextAtGap } from './GapCursorCommands.js';\nimport {\n\tdeleteNodeSelection,\n\tfindFirstLeafBlockId,\n\tfindLastLeafBlockId,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n} from './NodeSelectionCommands.js';\nimport { deleteCrossRootRange, deleteLeafRange, getRootBlockIndex } from './SelectionDeletion.js';\n\n// --- Re-exports from submodules ---\n\nexport {\n\tcanCrossBlockBoundary,\n\tisInsideIsolating,\n\tisIsolatingBlock,\n\tisVoidBlock,\n\tsharesParent,\n} from '../state/NavigationQueries.js';\n\nexport type { FeatureConfig } from './MarkCommands.js';\nexport {\n\tisMarkActive,\n\ttoggleBold,\n\ttoggleItalic,\n\ttoggleMark,\n\ttoggleUnderline,\n} from './MarkCommands.js';\n\nexport {\n\tdeleteBackward,\n\tdeleteForward,\n\tdeleteSoftLineBackward,\n\tdeleteSoftLineForward,\n\tdeleteWordBackward,\n\tdeleteWordForward,\n} from './DeleteCommands.js';\n\nexport {\n\tdeleteNodeSelection,\n\tfindFirstLeafBlockId,\n\tfindLastLeafBlockId,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n\tnavigateArrowIntoVoid,\n} from './NodeSelectionCommands.js';\n\nexport {\n\tdeleteBackwardAtGap,\n\tdeleteForwardAtGap,\n\tinsertParagraphAtGap,\n\tinsertTextAtGap,\n} from './GapCursorCommands.js';\n\nexport {\n\tfindWordBoundaryBackward,\n\tfindWordBoundaryForward,\n} from './WordBoundary.js';\n\nexport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from './AttributedMarkCommands.js';\n\nexport { forEachBlockIdInRange, forEachBlockInRange } from './RangeIterator.js';\n\n// --- Text Commands ---\n\n/** Inserts text at the current selection, replacing any selected range. */\nexport function insertTextCommand(\n\tstate: EditorState,\n\ttext: string,\n\torigin: 'input' | 'paste' = 'input',\n): Transaction {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert paragraph after void block with the text\n\tif (isNodeSelection(sel)) {\n\t\treturn insertTextAfterNodeSelection(state, sel, text, origin);\n\t}\n\n\t// GapCursor: insert paragraph at the gap position with the text\n\tif (isGapCursor(sel)) {\n\t\treturn insertTextAtGap(state, sel, text, origin);\n\t}\n\n\tconst builder = state.transaction(origin);\n\tconst marks = resolveActiveMarks(state);\n\n\tlet landingId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tlandingId = addDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst resolved = resolveInsertPoint(sel, state.getBlockOrder());\n\tconst insertBlockId: BlockId = landingId ?? resolved.blockId;\n\tconst insertOffset: number = landingId ? 0 : resolved.offset;\n\n\tbuilder.insertText(insertBlockId, insertOffset, text, marks);\n\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + text.length));\n\n\treturn builder.build();\n}\n\n/** Deletes the current selection. */\nexport function deleteSelectionCommand(state: EditorState): Transaction | null {\n\tif (isNodeSelection(state.selection)) {\n\t\treturn deleteNodeSelection(state, state.selection);\n\t}\n\tif (isGapCursor(state.selection)) return null;\n\tif (isCollapsed(state.selection)) return null;\n\n\t// Deleting a selection that spans the whole document resets it to the\n\t// canonical empty state (a single empty paragraph). Without this, the range\n\t// merge keeps the first block's type and attributes, leaving e.g. an empty\n\t// centered title behind so the placeholder never returns.\n\tif (selectionCoversDocument(state)) {\n\t\treturn clearDocument(state);\n\t}\n\n\tconst builder = state.transaction('input');\n\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\n\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\tconst cursorBlockId: BlockId = landingId ?? range.from.blockId;\n\tconst cursorOffset: number = landingId ? 0 : range.from.offset;\n\tbuilder.setSelection(createCollapsedSelection(cursorBlockId, cursorOffset));\n\n\treturn builder.build();\n}\n\n/** Splits the current block at the cursor position (Enter key). */\nexport function splitBlockCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\t// NodeSelection: insert empty paragraph after the void block\n\tif (isNodeSelection(sel)) {\n\t\treturn insertParagraphAfterNodeSelection(state, sel);\n\t}\n\n\t// GapCursor: insert empty paragraph at the gap position\n\tif (isGapCursor(sel)) {\n\t\treturn insertParagraphAtGap(state, sel);\n\t}\n\n\tconst builder = state.transaction('input');\n\n\tlet landingId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tlandingId = addDeleteSelectionSteps(state, builder);\n\t}\n\n\tconst resolved = resolveInsertPoint(sel, state.getBlockOrder());\n\tconst blockId: BlockId = landingId ?? resolved.blockId;\n\tconst offset: number = landingId ? 0 : resolved.offset;\n\tconst newBlockId = generateBlockId();\n\n\t// splitBlock operates at the same level in the tree — the StepApplication\n\t// handles this correctly because it looks up the block by ID recursively.\n\tbuilder.splitBlock(blockId, offset, newBlockId);\n\tbuilder.setSelection(createCollapsedSelection(newBlockId, 0));\n\n\treturn builder.build();\n}\n\n/** Inserts a hard line break (InlineNode) at the current cursor position. */\nexport function insertHardBreakCommand(state: EditorState): Transaction | null {\n\tconst sel = state.selection;\n\n\tif (!isTextSelection(sel)) return null;\n\n\tconst builder = state.transaction('input');\n\n\tlet cursorBlockId: BlockId | undefined;\n\tif (!isCollapsed(sel)) {\n\t\tconst landingId: BlockId | undefined = addDeleteSelectionSteps(state, builder);\n\t\tcursorBlockId = landingId;\n\t}\n\n\tif (cursorBlockId) {\n\t\t// Cross-root deletion replaced from-block; insert hard break in landing block\n\t\tbuilder.insertInlineNode(cursorBlockId, 0, createInlineNode(inlineType('hard_break')));\n\t\tbuilder.setSelection(createCollapsedSelection(cursorBlockId, 1));\n\t} else {\n\t\tconst { blockId: insertBlockId, offset: insertOffset } = resolveInsertPoint(\n\t\t\tsel,\n\t\t\tstate.getBlockOrder(),\n\t\t);\n\t\tbuilder.insertInlineNode(\n\t\t\tinsertBlockId,\n\t\t\tinsertOffset,\n\t\t\tcreateInlineNode(inlineType('hard_break')),\n\t\t);\n\t\tbuilder.setSelection(createCollapsedSelection(insertBlockId, insertOffset + 1));\n\t}\n\n\treturn builder.build();\n}\n\n/**\n * Merges the current block with the previous block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockBackward(state: EditorState): Transaction | null {\n\treturn mergeAdjacentBlock(state, 'backward');\n}\n\n/**\n * Merges the next block into the current block, respecting\n * isolating boundaries and void blocks.\n */\nexport function mergeBlockForward(state: EditorState): Transaction | null {\n\treturn mergeAdjacentBlock(state, 'forward');\n}\n\n/**\n * Shared implementation for merging adjacent blocks in either direction.\n * Validates selection, isolating boundaries, and void blocks before merging.\n */\nfunction mergeAdjacentBlock(\n\tstate: EditorState,\n\tdirection: 'backward' | 'forward',\n): Transaction | null {\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return null;\n\n\tconst blockOrder = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.anchor.blockId);\n\n\tconst adjacentIdx: number = direction === 'backward' ? blockIdx - 1 : blockIdx + 1;\n\tif (adjacentIdx < 0 || adjacentIdx >= blockOrder.length) return null;\n\n\tconst adjacentId: BlockId | undefined = blockOrder[adjacentIdx];\n\tif (!adjacentId) return null;\n\n\tif (isIsolatingBlock(state, sel.anchor.blockId) || isIsolatingBlock(state, adjacentId)) {\n\t\treturn null;\n\t}\n\tif (!sharesParent(state, sel.anchor.blockId, adjacentId)) {\n\t\tif (isInsideIsolating(state, sel.anchor.blockId)) return null;\n\t}\n\n\tif (isVoidBlock(state, adjacentId)) {\n\t\tconst path = findNodePath(state.doc, adjacentId) ?? [];\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.setSelection(createNodeSelection(adjacentId, path as BlockId[]))\n\t\t\t.build();\n\t}\n\n\tif (direction === 'backward') {\n\t\tconst prevBlock = state.getBlock(adjacentId);\n\t\tif (!prevBlock) return null;\n\t\tconst prevLen: number = getBlockLength(prevBlock);\n\t\treturn state\n\t\t\t.transaction('input')\n\t\t\t.mergeBlocksAt(adjacentId, sel.anchor.blockId)\n\t\t\t.setSelection(createCollapsedSelection(adjacentId, prevLen))\n\t\t\t.build();\n\t}\n\n\treturn state\n\t\t.transaction('input')\n\t\t.mergeBlocksAt(sel.anchor.blockId, adjacentId)\n\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, sel.anchor.offset))\n\t\t.build();\n}\n\n/** Selects all content in the editor, using leaf block endpoints. */\nexport function selectAll(state: EditorState): Transaction {\n\tconst docRange = documentRange(state);\n\tif (!docRange) return state.transaction('command').setSelection(state.selection).build();\n\n\treturn state\n\t\t.transaction('command')\n\t\t.setSelection(createSelection(docRange.from, docRange.to))\n\t\t.build();\n}\n\n// --- Internal Helpers ---\n\ninterface DocumentPosition {\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Endpoints of a full-document selection: the start of the first leaf block to\n * the end of the last leaf block. Returns `null` for an empty document.\n */\nfunction documentRange(\n\tstate: EditorState,\n): { from: DocumentPosition; to: DocumentPosition } | null {\n\tconst blocks = state.doc.children;\n\tconst firstBlock = blocks[0];\n\tconst lastBlock = blocks[blocks.length - 1];\n\tif (!firstBlock || !lastBlock) return null;\n\n\tconst firstLeafId: BlockId = findFirstLeafBlockId(firstBlock);\n\tconst lastLeafId: BlockId = findLastLeafBlockId(lastBlock);\n\tconst lastLeaf = state.getBlock(lastLeafId);\n\tconst lastLeafLen: number = lastLeaf ? getBlockLength(lastLeaf) : 0;\n\n\treturn {\n\t\tfrom: { blockId: firstLeafId, offset: 0 },\n\t\tto: { blockId: lastLeafId, offset: lastLeafLen },\n\t};\n}\n\n/** True when the current text selection spans the entire document. */\nfunction selectionCoversDocument(state: EditorState): boolean {\n\tif (!isTextSelection(state.selection)) return false;\n\tconst docRange = documentRange(state);\n\tif (!docRange) return false;\n\n\tconst range = selectionRange(state.selection, state.getBlockOrder());\n\treturn (\n\t\trange.from.blockId === docRange.from.blockId &&\n\t\trange.from.offset === docRange.from.offset &&\n\t\trange.to.blockId === docRange.to.blockId &&\n\t\trange.to.offset === docRange.to.offset\n\t);\n}\n\n/**\n * Replaces the whole document with a single empty paragraph and places the\n * cursor inside it. The fresh paragraph is inserted before the originals are\n * removed so the document never passes through a zero-children state.\n */\nfunction clearDocument(state: EditorState): Transaction {\n\tconst newBlockId: BlockId = generateBlockId();\n\tconst builder = state.transaction('input');\n\tconst originalCount: number = state.doc.children.length;\n\n\tbuilder.insertNode([], 0, createEmptyParagraph(newBlockId));\n\t// The originals shifted to indices 1..originalCount; remove them descending\n\t// so each index stays valid as the document shrinks.\n\tfor (let i = originalCount; i >= 1; i--) {\n\t\tbuilder.removeNode([], i);\n\t}\n\tbuilder.setSelection(createCollapsedSelection(newBlockId, 0));\n\n\treturn builder.build();\n}\n\nfunction resolveActiveMarks(state: EditorState): readonly Mark[] {\n\tif (state.storedMarks) return state.storedMarks;\n\n\tconst sel = state.selection;\n\tif (!isTextSelection(sel)) return [];\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return [];\n\n\t// A range replaced by typing inherits the marks at its anchor (raw content\n\t// marks); only a collapsed cursor honors right-boundary inclusivity.\n\tif (!isCollapsed(sel)) return getBlockMarksAtOffset(block, sel.anchor.offset);\n\n\treturn getCursorMarks(block, sel.anchor.offset, (type) => isMarkInclusive(state.schema, type));\n}\n\n/**\n * Adds steps to delete the current text selection.\n * Returns a replacement cursor block ID when the original from-block\n * was inside a composite root that got removed (undefined otherwise).\n */\nexport function addDeleteSelectionSteps(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n): BlockId | undefined {\n\tif (!isTextSelection(state.selection)) return undefined;\n\tconst blockOrder = state.getBlockOrder();\n\tconst range = selectionRange(state.selection, blockOrder);\n\tconst fromIdx = blockOrder.indexOf(range.from.blockId);\n\tconst toIdx = blockOrder.indexOf(range.to.blockId);\n\n\tif (fromIdx === toIdx) {\n\t\tbuilder.deleteTextAt(range.from.blockId, range.from.offset, range.to.offset);\n\t\treturn undefined;\n\t}\n\n\tconst fromRootIdx: number = getRootBlockIndex(state, range.from.blockId);\n\tconst toRootIdx: number = getRootBlockIndex(state, range.to.blockId);\n\n\tif (fromRootIdx === toRootIdx || fromRootIdx < 0 || toRootIdx < 0) {\n\t\tdeleteLeafRange(state, builder, blockOrder, range, fromIdx, toIdx);\n\t\treturn undefined;\n\t}\n\n\treturn deleteCrossRootRange(state, builder, range, fromRootIdx, toRootIdx);\n}\n"],"mappings":"ktBAsBA,SAAgB,IACf,MAAO,CACN,UAAW,CAAC,aACZ,UAAW,CAAC,OAAQ,SAAU,aAC9B,YAAA,OAEF,CAGA,SAAgB,EAAmB,GAClC,MAAO,CACN,UAAW,EAAS,eACpB,UAAW,EAAS,eACpB,YAAc,GAAiB,EAAS,YAAY,GACpD,kBAAoB,GAAiB,EAAS,kBAAkB,GAChE,YAAc,GAAiB,EAAS,YAAY,GAEtD,CAGA,SAAgB,EAAc,EAAgB,GAC7C,OAAO,EAAO,UAAU,SAAS,EAClC,CAGA,SAAgB,EAAkB,EAAgB,GACjD,OAAO,EAAO,UAAU,SAAS,EAClC,CC1BA,SAAgB,EACf,EACA,GAEA,GAAiB,UAAb,EAAI,KACP,OAAO,EAAgB,EAAO,GAI/B,MAAM,EAAiC,EAAM,gBACvC,EAAmB,EAAW,QAAQ,EAAI,SAEhD,GAAI,GAAY,EAAG,OAAO,KAE1B,MAAM,EAA8B,EAAW,EAAW,GAC1D,IAAK,EAAQ,OAAO,KAEpB,GAAI,EAAY,EAAO,GAAS,CAC/B,MAAM,EAAO,EAAa,EAAM,IAAK,IAAW,GAChD,OAAO,EACL,YAAY,SACZ,aAAa,EAAoB,EAAQ,IACzC,OACH,CAEA,MAAM,EAAY,EAAM,SAA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-
import{C as t,D as e,O as o,S as n,T as r,c as s,f as c,g as l,h as f,i,j as d,k as u,m as a,p,r as k,t as m,v as h}from"./Document-r7vLOAGA.mjs";import{i as I}from"./Selection-HYoVFpAx.mjs";import{a as b}from"./TypeBrands-Ch9856Gb.mjs";import{n as y,o as g,s as B}from"./NodeResolver-ChgLF_IP.mjs";var v={type:"identity"};function x(t){const e=/* @__PURE__ */new Set,o=t=>{e.add(t.id);for(const e of t.children)n(e)&&o(e)};return o(t),e}function w(t,e,o=-1){switch(e.type){case"identity":case"childIndexShift":return{pos:t,deleted:!1};case"shift":return function(t,e,o){if(t.blockId!==e.blockId)return{pos:t,deleted:!1};const n=e.newLen-(e.to-e.from),r=t.offset;if(r<e.from)return{pos:t,deleted:!1};if(r===e.from){if(e.from===e.to){const n=1===o?e.from+e.newLen:e.from;return n===r?{pos:t,deleted:!1}:{pos:M(t,n),deleted:!1}}return{pos:t,deleted:!1}}if(r<e.to)return{pos:M(t,1===o?e.from+e.newLen:e.from),deleted:!0};const s=r+n;return s===r?{pos:t,deleted:!1}:{pos:M(t,s),deleted:!1}}(t,e,o);case"split":return function(t,e,o){return t.blockId!==e.blockId||t.offset<e.offset?{pos:t,deleted:!1}:t.offset>e.offset?{pos:I(e.newBlockId,t.offset-e.offset),deleted:!1}:1===o?{pos:I(e.newBlockId,0),deleted:!1}:{pos:t,deleted:!1}}(t,e,o);case"merge":return function(t,e){return t.blockId!==e.sourceBlockId?{pos:t,deleted:!1}:{pos:I(e.targetBlockId,t.offset+e.targetLengthBefore),deleted:!1}}(t,e);case"blockRemoval":return function(t,e){return e.removedBlockIds.has(t.blockId)?{pos:t,deleted:!0}:{pos:t,deleted:!1}}(t,e)}}function M(t,e){return I(t.blockId,e,t.path)}var T=class t{static empty=new t([]);maps;constructor(t){this.maps=t}static from(e){const o=[];for(const t of e)"identity"!==t.type&&o.push(t);return 0===o.length?t.empty:new t(o)}appendMap(e){return"identity"===e.type?this:new t([...this.maps,e])}appendMapping(e){return 0===e.maps.length?this:0===this.maps.length?e:new t([...this.maps,...e.maps])}get isEmpty(){return 0===this.maps.length}map(t,e=-1){return this.mapResult(t,e).pos}mapResult(t,e=-1){let o=t,n=!1;for(const r of this.maps){const t=w(o,r,e);o=t.pos,t.deleted&&(n=!0)}return{pos:o,deleted:n}}mapRange(t,e=-1,o=1){const n=this.mapResult(t.from,e),r=this.mapResult(t.to,o);return n.deleted&&r.deleted&&n.pos.blockId===r.pos.blockId&&n.pos.offset>=r.pos.offset?null:{from:n.pos,to:r.pos}}};function N(t,e,o,n,r=1,s=-1){if(n.isEmpty)return{blockId:t,from:e,to:o};const c=I(t,e),l=I(t,o),f=n.mapResult(c,r),i=n.mapResult(l,s);return f.deleted&&i.deleted||f.pos.blockId!==i.pos.blockId||f.pos.offset>i.pos.offset?null:{blockId:f.pos.blockId,from:f.pos.offset,to:i.pos.offset}}function A(t,e,o,n=-1){if(o.isEmpty)return{blockId:t,from:e,to:e};const r=I(t,e),s=o.mapResult(r,n);return s.deleted?null:{blockId:s.pos.blockId,from:s.pos.offset,to:s.pos.offset}}function P(t,e,o){return R(t,e,o,"existing")}function L(t,e,o){return R(t,e,o,"insertion")}function R(t,e,o,n){if(o.isEmpty)return e;let r=e;for(const s of o.maps){const e=S(t,r,s,n);if(null===e)return null;r=e}return r}function S(t,e,o,n){switch(o.type){case"identity":case"shift":case"split":case"merge":return e;case"blockRemoval":return E(t,o.parentPath)?e===o.index?"existing"===n?null:e:e>o.index?e-1:e:e;case"childIndexShift":return E(t,o.parentPath)&&e>=o.fromIndex?e+o.delta:e}}function E(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(t[o]!==e[o])return!1;return!0}function j(t){switch(t.type){case"identity":case"blockRemoval":case"childIndexShift":return v;case"shift":return{type:"shift",blockId:t.blockId,from:t.from,to:t.from+t.newLen,newLen:t.to-t.from};case"split":return{type:"merge",targetBlockId:t.blockId,sourceBlockId:t.newBlockId,targetLengthBefore:t.offset};case"merge":return{type:"split",blockId:t.targetBlockId,offset:t.targetLengthBefore,newBlockId:t.sourceBlockId}}}function O(t,e){if(t.type!==e.type)return!1;switch(t.type){case"identity":return!0;case"shift":{const o=e;return t.blockId===o.blockId&&t.from===o.from&&t.to===o.to&&t.newLen===o.newLen}case"split":{const o=e;return t.blockId===o.blockId&&t.offset===o.offset&&t.newBlockId===o.newBlockId}case"merge":{const o=e;return t.targetBlockId===o.targetBlockId&&t.sourceBlockId===o.sourceBlockId&&t.targetLengthBefore===o.targetLengthBefore}case"blockRemoval":{const o=e;if(t.index!==o.index)return!1;if(!E(t.parentPath,o.parentPath))return!1;if(t.removedBlockIds.size!==o.removedBlockIds.size)return!1;for(const e of t.removedBlockIds)if(!o.removedBlockIds.has(e))return!1;return!0}case"childIndexShift":{const o=e;return t.fromIndex===o.fromIndex&&t.delta===o.delta&&E(t.parentPath,o.parentPath)}}}function z(t,e,o){return{children:D(t.children,e,o)}}function D(t,e,o){let r=!1;const s=t.map(t=>{if(!n(t))return t;if(t.id===e)return r=!0,o(t);const s=D(t.children,e,o);return s===t.children?t:(r=!0,{...t,children:s})});return r?s:t}function C(t,e,o){if(0===e.length)return t;const r=e[0];return r?{children:t.children.map(t=>n(t)&&t.id===r?1===e.length?o(t):q(t,e,1,o):t)}:t}function q(t,e,o,r){const s=e[o];if(!s)return t;const c=t.children.map(t=>n(t)&&t.id===s?o===e.length-1?r(t):q(t,e,o+1,r):t);return{...t,children:c}}function W(t,e,o){if(e(t))return o(t);let r=!1;const s=t.map(t=>{if(!n(t))return t;const s=W(t.children,e,o);return s?(r=!0,{...t,children:s}):t});return r?s:null}function _(e,o,n){const r=[];let c=0,l=!1;for(const f of e){if(t(f)){l||o!==c||(r.push(...n()),l=!0),r.push(f),c+=1;continue}const e=c+f.text.length;if(!l&&o>=c&&o<=e){const t=o-c,e=f.text.slice(0,t),i=f.text.slice(t);e&&r.push(s(e,f.marks)),r.push(...n()),i&&r.push(s(i,f.marks)),l=!0}else r.push(f);c=e}return l||r.push(...n()),r}function F(e,o,n){const r=[];let c=0;for(const l of e){if(t(l)){const t=c+1;t>o&&c<n&&r.push(l),c=t;continue}const e=c+l.text.length;if(e<=o||c>=n);else{const t=Math.max(0,o-c),e=Math.min(l.text.length,n-c),f=l.text.slice(t,e);f.length>0&&r.push(s(f,l.marks))}c=e}return 0===r.length&&r.push(s("")),r}function G(e,o,n,r,c){const l=[];let f=0;for(const i of e){if(t(i)){l.push(i),f+=1;continue}const e=f+i.text.length;if(e<=o||f>=n)l.push(i);else if(f>=o&&e<=n){const t=c?m(i.marks,r):u(i.marks,r.type);l.push(s(i.text,t))}else{const t=Math.max(0,o-f),e=Math.min(i.text.length,n-f),d=i.text.slice(0,t),a=i.text.slice(t,e),p=i.text.slice(e);if(d&&l.push(s(d,i.marks)),a){const t=c?m(i.marks,r):u(i.marks,r.type);l.push(s(a,t))}p&&l.push(s(p,i.marks))}f=e}return l}function H(e,o,n,r){const s=[];if(o>=n)return s;let c=null,l=0;const f=()=>{c&&(s.push(c),c=null)};for(const i of e){const e=l+(t(i)?1:i.text.length);if(e<=o||l>=n){l=e;continue}const s=Math.max(l,o),d=Math.min(e,n);t(i)?c&&(c.to=d):i.marks.some(t=>t.type===r)?f():c?c.to=d:c={from:s,to:d},l=e}return f(),s}function J(o,n,r,s){const c=[];if(n>=r)return c;let l=null,f=0;const i=()=>{l&&(c.push(l),l=null)};for(const d of o){const o=f+(t(d)?1:d.text.length);if(o<=n||f>=r){f=o;continue}const c=Math.max(f,n),u=Math.min(o,r);if(t(d))l&&(l.to=u);else{const t=d.marks.find(t=>t.type===s);t?l&&e(l.mark,t)?l.to=u:(i(),l={from:c,to:u,mark:t}):i()}f=o}return i(),c}function K(e,o){if(e.every(e=>r(e)||t(e)))return o;const n=e.filter(e=>!r(e)&&!t(e));return[...o,...n]}function Q(t,e,n,r=!0){return z(t,e,t=>{const e=n(h(t));return{...t,children:K(t.children,r?o(e):e)}})}function U(t){return t.reduce((t,e)=>t+("inline"===e.kind?1:e.text.length),0)}function V(t){return{blocks:t.split(/\r?\n/).map(t=>({type:b("paragraph"),segments:[d(t)]}))}}function X(t){return t.segments?U(t.segments):t.text.length}function Y(t){return t.path?{path:t.path}:{}}function Z(t){for(const e of t.steps)if("setStoredMarks"===e.type)return e.previousMarks;return t.storedMarksAfter}function $(t,e,o){return o?t!==e?{}:{path:o}:{}}function tt(t,e){if(e.isEmpty)return!0;for(const o of t){const t=e.mapResult({blockId:o,offset:0},-1);if(t.deleted)return!1;if(t.pos.blockId!==o)return!1}return!0}function et(t,e){return e.blockId===t.blockId&&e.from===t.from&&e.to===t.to}function ot(t,e){if(t===e)return!0;if(!t||!e)return!1;const o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(const r of o)if(t[r]!==e[r])return!1;return!0}var nt={insertText:{apply:function(t,e){return Q(t,e.blockId,t=>{return e.segments?(o=t,n=e.offset,r=e.segments,_(o,n,()=>r.map(k))):function(t,e,o,n){return _(t,e,()=>[s(o,n)])}(t,e.offset,e.text,e.marks);var o,n,r})},invert:function(t){return{type:"deleteText",blockId:t.blockId,from:t.offset,to:t.offset+X(t),deletedText:t.text,deletedMarks:t.marks,deletedSegments:t.segments??[d(t.text,[...t.marks])],...Y(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.offset,to:e.offset,newLen:X(e)}},map:function(t,e,o){const n=A(t.blockId,t.offset,e,-1);return n?n.blockId===t.blockId&&n.from===t.offset?t:{type:"insertText",blockId:n.blockId,offset:n.from,text:t.text,marks:t.marks,...t.segments?{segments:t.segments}:{},...$(t.blockId,n.blockId,t.path)}:null}},deleteText:{apply:function(e,o){return Q(e,o.blockId,e=>function(e,o,n){const r=[];let c=0;for(const l of e){if(t(l)){const t=c+1;(t<=o||c>=n)&&r.push(l),c=t;continue}const e=c+l.text.length;if(e<=o||c>=n)r.push(l);else{const t=Math.max(0,o-c),e=Math.min(l.text.length,n-c),f=l.text.slice(0,t)+l.text.slice(e);f.length>0&&r.push(s(f,l.marks))}c=e}return r}(e,o.from,o.to))},invert:function(t){return{type:"insertText",blockId:t.blockId,offset:t.from,text:t.deletedText,marks:t.deletedMarks,segments:t.deletedSegments,...Y(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.from,to:e.to,newLen:0}},map:function(t,e,o){const n=N(t.blockId,t.from,t.to,e);if(!n)return null;if(et({blockId:t.blockId,from:t.from,to:t.to},n))return t;const r=y(o,n.blockId);if(!r)return null;const s=f(r).slice(n.from,n.to),l=a(r,n.from),i=c(r,n.from,n.to);return{type:"deleteText",blockId:n.blockId,from:n.from,to:n.to,deletedText:s,deletedMarks:l,deletedSegments:i,...$(t.blockId,n.blockId,t.path)}}},splitBlock:{apply:function(t,e){const r=W(t.children,t=>t.some(t=>n(t)&&t.id===e.blockId),t=>{const r=t.findIndex(t=>n(t)&&t.id===e.blockId);if(-1===r)return t;const s=t[r],c=h(s),l=p(s),f=F(c,0,e.offset),d=F(c,e.offset,l),u={...s,children:o(f)},a=void 0!==e.newBlockType,k=e.newBlockType??s.type,m=a?e.newBlockAttrs:s.attrs,I=i(k,o(d),e.newBlockId,m),b=[...t];return b.splice(r,1,u,I),b});return r?{children:r}:t},invert:function(t){return{type:"mergeBlocks",targetBlockId:t.blockId,sourceBlockId:t.newBlockId,targetLengthBefore:t.offset,...void 0!==t.newBlockType?{sourceType:t.newBlockType}:{},...t.newBlockAttrs?{sourceAttrs:t.newBlockAttrs}:{},...Y(t)}},getMap:function(t,e){return{type:"split",blockId:e.blockId,offset:e.offset,newBlockId:e.newBlockId}},map:function(t,e,o){const n=A(t.blockId,t.offset,e,-1);return n?n.blockId===t.blockId&&n.from===t.offset?t:{type:"splitBlock",blockId:n.blockId,offset:n.from,newBlockId:t.newBlockId,...void 0!==t.newBlockType?{newBlockType:t.newBlockType}:{},...t.newBlockAttrs?{newBlockAttrs:t.newBlockAttrs}:{},...$(t.blockId,n.blockId,t.path)}:null}},mergeBlocks:{apply:function(t,e){const r=W(t.children,t=>t.some(t=>n(t)&&t.id===e.targetBlockId)&&t.some(t=>n(t)&&t.id===e.sourceBlockId),t=>{const r=t.findIndex(t=>n(t)&&t.id===e.targetBlockId),s=t.findIndex(t=>n(t)&&t.id===e.sourceBlockId);if(-1===r||-1===s)return t;const c=t[r],l=t[s],f=h(c),i=h(l),d=o([...f,...i]),u={...c,children:d};return t.filter(t=>!n(t)||t.id!==e.sourceBlockId).map(t=>n(t)&&t.id===e.targetBlockId?u:t)});return r?{children:r}:t},invert:function(t){return{type:"splitBlock",blockId:t.targetBlockId,offset:t.targetLengthBefore,newBlockId:t.sourceBlockId,...void 0!==t.sourceType?{newBlockType:t.sourceType}:{},...t.sourceAttrs?{newBlockAttrs:t.sourceAttrs}:{},...Y(t)}},getMap:function(t,e){return{type:"merge",targetBlockId:e.targetBlockId,sourceBlockId:e.sourceBlockId,targetLengthBefore:e.targetLengthBefore}},map:function(t,e,o){if(e.isEmpty)return t;const n=e.mapResult({blockId:t.targetBlockId,offset:0},-1),r=e.mapResult({blockId:t.sourceBlockId,offset:0},-1);if(n.deleted||r.deleted)return null;const s=n.pos.blockId,c=r.pos.blockId;if(s===c)return null;const l=y(o,s);if(!l)return null;const f=p(l);return s===t.targetBlockId&&c===t.sourceBlockId&&f===t.targetLengthBefore?t:{type:"mergeBlocks",targetBlockId:s,sourceBlockId:c,targetLengthBefore:f,...void 0!==t.sourceType?{sourceType:t.sourceType}:{},...t.sourceAttrs?{sourceAttrs:t.sourceAttrs}:{},...$(t.targetBlockId,s,t.path)}}},addMark:{apply:function(t,e){return Q(t,e.blockId,t=>G(t,e.from,e.to,e.mark,!0))},invert:function(t){return{type:"removeMark",blockId:t.blockId,from:t.from,to:t.to,mark:t.mark,...Y(t)}},getMap:function(t,e){return v},map:function(t,e,o){const n=N(t.blockId,t.from,t.to,e);return n?et({blockId:t.blockId,from:t.from,to:t.to},n)?t:{type:"addMark",blockId:n.blockId,from:n.from,to:n.to,mark:t.mark,...$(t.blockId,n.blockId,t.path)}:null}},removeMark:{apply:function(t,e){return Q(t,e.blockId,t=>G(t,e.from,e.to,e.mark,!1))},invert:function(t){return{type:"addMark",blockId:t.blockId,from:t.from,to:t.to,mark:t.mark,...Y(t)}},getMap:function(t,e){return v},map:function(t,e,o){const n=N(t.blockId,t.from,t.to,e);return n?et({blockId:t.blockId,from:t.from,to:t.to},n)?t:{type:"removeMark",blockId:n.blockId,from:n.from,to:n.to,mark:t.mark,...$(t.blockId,n.blockId,t.path)}:null}},setStoredMarks:{apply:function(t){return t},invert:function(t){return{type:"setStoredMarks",marks:t.previousMarks,previousMarks:t.marks}},getMap:function(t,e){return v},map:function(t,e,o){return t}},setBlockType:{apply:function(t,e){return z(t,e.blockId,t=>{const{attrs:o,...n}=t;return{...n,type:e.nodeType,...e.attrs?{attrs:e.attrs}:{}}})},invert:function(t){return{type:"setBlockType",blockId:t.blockId,nodeType:t.previousNodeType,attrs:t.previousAttrs,previousNodeType:t.nodeType,previousAttrs:t.attrs,...Y(t)}},getMap:function(t,e){return v},map:function(t,e,o){if(e.isEmpty)return t;const n=e.mapResult({blockId:t.blockId,offset:0},-1);if(n.deleted)return null;const r=n.pos.blockId,s=y(o,r);return s?r===t.blockId&&s.type===t.previousNodeType&&ot(s.attrs,t.previousAttrs)?t:{type:"setBlockType",blockId:r,nodeType:t.nodeType,...t.attrs?{attrs:t.attrs}:{},previousNodeType:s.type,...s.attrs?{previousAttrs:s.attrs}:{},...$(t.blockId,r,t.path)}:null}},insertNode:{apply:function(t,e){if(0===e.parentPath.length){const o=[...t.children];return o.splice(e.index,0,e.node),{children:o}}return C(t,e.parentPath,t=>{const o=[...t.children];return o.splice(e.index,0,e.node),{...t,children:o}})},invert:function(t){return{type:"removeNode",parentPath:t.parentPath,index:t.index,removedNode:t.node}},getMap:function(t,e){return{type:"childIndexShift",parentPath:e.parentPath,fromIndex:e.index,delta:1}},map:function(t,e,o){if(!tt(t.parentPath,e))return null;const n=L(t.parentPath,t.index,e);return n===t.index?t:{type:"insertNode",parentPath:t.parentPath,index:n,node:t.node}}},removeNode:{apply:function(t,e){if(0===e.parentPath.length){const o=[...t.children];return o.splice(e.index,1),{children:o}}return C(t,e.parentPath,t=>{const o=[...t.children];return o.splice(e.index,1),{...t,children:o}})},invert:function(t){return{type:"insertNode",parentPath:t.parentPath,index:t.index,node:t.removedNode}},getMap:function(t,e){return{type:"blockRemoval",removedBlockIds:x(e.removedNode),parentPath:e.parentPath,index:e.index}},map:function(t,e,o){if(!tt(t.parentPath,e))return null;const n=e.mapResult({blockId:t.removedNode.id,offset:0},-1);if(n.deleted)return null;if(n.pos.blockId!==t.removedNode.id)return null;const r=P(t.parentPath,t.index,e);if(null===r)return null;const s=g(o,t.parentPath,r);return s?s.id!==t.removedNode.id?null:r===t.index&&s===t.removedNode?t:{type:"removeNode",parentPath:t.parentPath,index:r,removedNode:s}:null}},setNodeAttr:{apply:function(t,e){const o=e.path[e.path.length-1];return o?z(t,o,t=>({...t,attrs:e.attrs})):t},invert:function(t){return{type:"setNodeAttr",path:t.path,attrs:t.previousAttrs,previousAttrs:t.attrs}},getMap:function(t,e){return v},map:function(t,e,o){if(e.isEmpty)return t;if(!tt(t.path,e))return null;const n=B(o,t.path);return n?{type:"setNodeAttr",path:t.path,attrs:t.attrs,...n.attrs?{previousAttrs:n.attrs}:{}}:null}},insertInlineNode:{apply:function(e,o){return Q(e,o.blockId,e=>function(e,o,n){const r=[];let c=0,l=!1;for(const f of e){if(t(f)){l||o!==c||(r.push(n),l=!0),r.push(f),c+=1;continue}const e=c+f.text.length;if(!l&&o>=c&&o<=e){const t=o-c,e=f.text.slice(0,t),i=f.text.slice(t);e&&r.push(s(e,f.marks)),r.push(n),i&&r.push(s(i,f.marks)),l=!0}else r.push(f);c=e}return l||r.push(n),r}(e,o.offset,o.node))},invert:function(t){return{type:"removeInlineNode",blockId:t.blockId,offset:t.offset,removedNode:t.node,...Y(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.offset,to:e.offset,newLen:1}},map:function(t,e,o){const n=A(t.blockId,t.offset,e,-1);return n?n.blockId===t.blockId&&n.from===t.offset?t:{type:"insertInlineNode",blockId:n.blockId,offset:n.from,node:t.node,...$(t.blockId,n.blockId,t.path)}:null}},removeInlineNode:{apply:function(e,o){return Q(e,o.blockId,e=>function(e,o){const n=[];let r=0;for(const s of e)t(s)?(r!==o&&n.push(s),r+=1):(n.push(s),r+=s.text.length);return n}(e,o.offset))},invert:function(t){return{type:"insertInlineNode",blockId:t.blockId,offset:t.offset,node:t.removedNode,...Y(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.offset,to:e.offset+1,newLen:0}},map:function(e,o,n){const r=N(e.blockId,e.offset,e.offset+1,o,1,1);if(!r)return null;if(r.to-r.from!==1)return null;const s=y(n,r.blockId);if(!s)return null;const c=l(s,r.from);return c&&"inline"===c.kind&&t(c.node)?(f=e.removedNode)===(i=c.node)||f.inlineType===i.inlineType&&ot(f.attrs,i.attrs)?r.blockId===e.blockId&&r.from===e.offset?e:{type:"removeInlineNode",blockId:r.blockId,offset:r.from,removedNode:c.node,...$(e.blockId,r.blockId,e.path)}:null:null;var f,i}},setInlineNodeAttr:{apply:function(e,o){return Q(e,o.blockId,e=>function(e,o,n){const r=[];let s=0;for(const c of e)t(c)?(s===o?r.push({...c,attrs:n}):r.push(c),s+=1):(r.push(c),s+=c.text.length);return r}(e,o.offset,o.attrs),!1)},invert:function(t){return{type:"setInlineNodeAttr",blockId:t.blockId,offset:t.offset,attrs:t.previousAttrs,previousAttrs:t.attrs,...Y(t)}},getMap:function(t,e){return v},map:function(e,o,n){const r=N(e.blockId,e.offset,e.offset+1,o,1,1);if(!r)return null;if(r.to-r.from!==1)return null;if(r.blockId===e.blockId&&r.from===e.offset)return e;const s=y(n,r.blockId);if(!s)return null;const c=l(s,r.from);return c&&"inline"===c.kind&&t(c.node)?{type:"setInlineNodeAttr",blockId:r.blockId,offset:r.from,attrs:e.attrs,previousAttrs:c.node.attrs,...$(e.blockId,r.blockId,e.path)}:null}}};function rt(t){return nt[t.type]}function st(t,e){return rt(e).apply(t,e)}function ct(t){return rt(t).invert(t)}function lt(t,e){return rt(e).getMap(t,e)}function ft(t,e,o){return e.isEmpty?t:rt(t).map(t,e,o)}function it(t){const e=t.steps.map(ct).reverse();return{steps:e,selectionBefore:t.selectionAfter,selectionAfter:t.selectionBefore,storedMarksAfter:Z(t),mapping:T.empty,forwardStepMaps:e.map(()=>v),metadata:{origin:"history",timestamp:Date.now()}}}function dt(t,e){switch(t.type){case"inline":return function(t,e){switch(e.type){case"identity":case"childIndexShift":return t;case"shift":return function(t,e){if(t.blockId!==e.blockId)return t;const o=w(I(t.blockId,t.from),e,-1).pos,n=w(I(t.blockId,t.to),e,1).pos;return o.offset>=n.offset?null:o.offset===t.from&&n.offset===t.to?t:{...t,from:o.offset,to:n.offset}}(t,e);case"split":return function(t,e){return t.blockId!==e.blockId||t.to<=e.offset?t:t.from>=e.offset?{...t,blockId:e.newBlockId,from:t.from-e.offset,to:t.to-e.offset}:[{...t,to:e.offset},{...t,blockId:e.newBlockId,from:0,to:t.to-e.offset}]}(t,e);case"merge":return function(t,e){return t.blockId!==e.sourceBlockId?t:{...t,blockId:e.targetBlockId,from:t.from+e.targetLengthBefore,to:t.to+e.targetLengthBefore}}(t,e);case"blockRemoval":return e.removedBlockIds.has(t.blockId)?null:t}}(t,e);case"widget":return function(t,e){switch(e.type){case"identity":case"childIndexShift":return t;case"shift":return function(t,e){if(t.blockId!==e.blockId)return t;const o=w(I(t.blockId,t.offset),e,t.side);return o.deleted?null:o.pos.offset===t.offset?t:{...t,offset:o.pos.offset}}(t,e);case"split":return function(t,e){if(t.blockId!==e.blockId)return t;const o=w(I(t.blockId,t.offset),e,t.side);return o.pos.blockId===t.blockId&&o.pos.offset===t.offset?t:{...t,blockId:o.pos.blockId,offset:o.pos.offset}}(t,e);case"merge":return function(t,e){return t.blockId!==e.sourceBlockId?t:{...t,blockId:e.targetBlockId,offset:t.offset+e.targetLengthBefore}}(t,e);case"blockRemoval":return e.removedBlockIds.has(t.blockId)?null:t}}(t,e);case"node":return function(t,e){switch(e.type){case"identity":case"shift":case"split":case"childIndexShift":return t;case"merge":return t.blockId===e.sourceBlockId?null:t;case"blockRemoval":return e.removedBlockIds.has(t.blockId)?null:t}}(t,e)}}function ut(t,e,o,n){return{type:"inline",blockId:t,from:e,to:o,attrs:n}}function at(t,e){return{type:"node",blockId:t,attrs:e}}function pt(t,e,o,n){return{type:"widget",blockId:t,offset:e,toDOM:o,side:n?.side??-1,key:n?.key}}var kt=class t{byBlock;static empty=new t(/* @__PURE__ */new Map);constructor(t){this.byBlock=t}static create(e){if(0===e.length)return t.empty;const o=/* @__PURE__ */new Map;for(const t of e){const e=o.get(t.blockId);e?e.push(t):o.set(t.blockId,[t])}return new t(o)}find(t){return this.byBlock.get(t)??[]}findInline(t){const e=this.byBlock.get(t);return e?e.filter(t=>"inline"===t.type):[]}findNode(t){const e=this.byBlock.get(t);return e?e.filter(t=>"node"===t.type):[]}findWidget(t){const e=this.byBlock.get(t);return e?e.filter(t=>"widget"===t.type):[]}add(e){if(0===e.length)return this;if(this.isEmpty)return t.create(e);const o=/* @__PURE__ */new Map;for(const[t,n]of this.byBlock)o.set(t,[...n]);for(const t of e){const e=o.get(t.blockId);e?e.push(t):o.set(t.blockId,[t])}return new t(o)}remove(e){const o=/* @__PURE__ */new Map;let n=!1;for(const[t,r]of this.byBlock){const s=r.filter(t=>!e(t));s.length!==r.length&&(n=!0),s.length>0&&o.set(t,s)}return n?0===o.size?t.empty:new t(o):this}merge(e){if(e.isEmpty)return this;if(this.isEmpty)return e;const o=/* @__PURE__ */new Map;for(const[t,n]of this.byBlock)o.set(t,[...n]);for(const[t,n]of e.byBlock){const e=o.get(t);e?e.push(...n):o.set(t,[...n])}return new t(o)}equals(t){if(this===t)return!0;if(this.byBlock.size!==t.byBlock.size)return!1;for(const[e,o]of this.byBlock){const n=t.byBlock.get(e);if(!n)return!1;if(!mt(o,n))return!1}return!0}get isEmpty(){return 0===this.byBlock.size}map(e){if(this.isEmpty||e.mapping.isEmpty)return this;let o=[];for(const t of this.byBlock.values())for(const e of t)o.push(e);for(const t of e.mapping.maps){const e=[];for(const n of o){const o=dt(n,t);if(null!==o)if(Array.isArray(o))for(const t of o)e.push(t);else e.push(o)}o=e}return 0===o.length?t.empty:t.create(o)}};function mt(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let o=0;o<t.length;o++){const n=t[o],r=e[o];if(!n||!r||!ht(n,r))return!1}return!0}function ht(t,e){if(t.type!==e.type)return!1;if(t.blockId!==e.blockId)return!1;switch(t.type){case"inline":{const o=e;return t.from===o.from&&t.to===o.to&&It(t.attrs,o.attrs)}case"node":{const o=e;return It(t.attrs,o.attrs)}case"widget":{const o=e;return t.offset===o.offset&&t.side===o.side&&t.key===o.key&&t.toDOM===o.toDOM}}}function It(t,e){if(t===e)return!0;const o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(const r of o)if(t[r]!==e[r])return!1;return!0}export{O as C,w as S,T as _,pt as a,P as b,ct as c,Z as d,V as f,v as g,J as h,at as i,it as l,H as m,mt as n,st as o,U as p,ut as r,lt as s,kt as t,ft as u,x as v,L as x,j as y};
|
|
2
|
-
//# sourceMappingURL=Decoration-ZeyVfwJB.mjs.map
|