@notectl/core 2.0.7 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chunks/AlignmentPlugin-D1wmhWE6.mjs +2 -0
- package/dist/chunks/AlignmentPlugin-D1wmhWE6.mjs.map +1 -0
- package/dist/chunks/{AttributedMarkCommands-D_PYkbBt.mjs → AttributedMarkCommands-35jTbVRg.mjs} +2 -2
- package/dist/chunks/{AttributedMarkCommands-D_PYkbBt.mjs.map → AttributedMarkCommands-35jTbVRg.mjs.map} +1 -1
- package/dist/chunks/{BlockInsertion-DaG_4D31.mjs → BlockInsertion-DsnHLcvM.mjs} +2 -2
- package/dist/chunks/{BlockInsertion-DaG_4D31.mjs.map → BlockInsertion-DsnHLcvM.mjs.map} +1 -1
- package/dist/chunks/BlockquotePlugin-Bwny0CP6.mjs +2 -0
- package/dist/chunks/BlockquotePlugin-Bwny0CP6.mjs.map +1 -0
- package/dist/chunks/CaretNavigationPlugin-C-rCDbu0.mjs +2 -0
- package/dist/chunks/CaretNavigationPlugin-C-rCDbu0.mjs.map +1 -0
- package/dist/chunks/CodeBlockPlugin-CNC290_q.mjs +2 -0
- package/dist/chunks/CodeBlockPlugin-CNC290_q.mjs.map +1 -0
- package/dist/chunks/{ColorGrid-BNDaG3b2.mjs → ColorGrid-BUSIBKZH.mjs} +1 -1
- package/dist/chunks/{ColorGrid-BNDaG3b2.mjs.map → ColorGrid-BUSIBKZH.mjs.map} +1 -1
- package/dist/chunks/{ColorPickerPopup-BwU_WZHh.mjs → ColorPickerPopup-CvE90IAu.mjs} +2 -2
- package/dist/chunks/{ColorPickerPopup-BwU_WZHh.mjs.map → ColorPickerPopup-CvE90IAu.mjs.map} +1 -1
- package/dist/chunks/{CommandHelpers-BoRO1KfE.mjs → CommandHelpers-DTlQcGv5.mjs} +2 -2
- package/dist/chunks/{CommandHelpers-BoRO1KfE.mjs.map → CommandHelpers-DTlQcGv5.mjs.map} +1 -1
- package/dist/chunks/Commands-BuYF23lf.mjs +2 -0
- package/dist/chunks/Commands-BuYF23lf.mjs.map +1 -0
- package/dist/chunks/FontPlugin-z0QF1M5q.mjs +2 -0
- package/dist/chunks/FontPlugin-z0QF1M5q.mjs.map +1 -0
- package/dist/chunks/FontSizePlugin-DYKvhu9w.mjs +2 -0
- package/dist/chunks/FontSizePlugin-DYKvhu9w.mjs.map +1 -0
- package/dist/chunks/{GapCursorNavigation-PhJeqELx.mjs → GapCursorNavigation-BaXDnjFf.mjs} +2 -2
- package/dist/chunks/{GapCursorNavigation-PhJeqELx.mjs.map → GapCursorNavigation-BaXDnjFf.mjs.map} +1 -1
- package/dist/chunks/GapCursorPlugin-uxw7W7vj.mjs +2 -0
- package/dist/chunks/GapCursorPlugin-uxw7W7vj.mjs.map +1 -0
- package/dist/chunks/{HardBreakPlugin-BzAU3DoJ.mjs → HardBreakPlugin-BpXipf8h.mjs} +2 -2
- package/dist/chunks/{HardBreakPlugin-BzAU3DoJ.mjs.map → HardBreakPlugin-BpXipf8h.mjs.map} +1 -1
- package/dist/chunks/HeadingPlugin-CUN746aD.mjs +2 -0
- package/dist/chunks/{HeadingPlugin-1BVn57NF.mjs.map → HeadingPlugin-CUN746aD.mjs.map} +1 -1
- package/dist/chunks/HighlightPlugin-bbAi6W6k.mjs +2 -0
- package/dist/chunks/HighlightPlugin-bbAi6W6k.mjs.map +1 -0
- package/dist/chunks/HorizontalRulePlugin-D8w6paMa.mjs +2 -0
- package/dist/chunks/HorizontalRulePlugin-D8w6paMa.mjs.map +1 -0
- package/dist/chunks/ImagePlugin-De7lWcZ7.mjs +2 -0
- package/dist/chunks/ImagePlugin-De7lWcZ7.mjs.map +1 -0
- package/dist/chunks/InlineCodePlugin-DKQIYhTb.mjs +2 -0
- package/dist/chunks/InlineCodePlugin-DKQIYhTb.mjs.map +1 -0
- package/dist/chunks/LinkPlugin-BD7mcRHS.mjs +2 -0
- package/dist/chunks/LinkPlugin-BD7mcRHS.mjs.map +1 -0
- package/dist/chunks/ListPlugin-DbixSqMH.mjs +2 -0
- package/dist/chunks/{ListPlugin-Datp4nPR.mjs.map → ListPlugin-DbixSqMH.mjs.map} +1 -1
- package/dist/chunks/{NavigationQueries-_xQtPALX.mjs → NavigationQueries-CgYPG6oY.mjs} +1 -1
- package/dist/chunks/{NavigationQueries-_xQtPALX.mjs.map → NavigationQueries-CgYPG6oY.mjs.map} +1 -1
- package/dist/chunks/NodeSelectionCommands-Ddxu5Qck.mjs +2 -0
- package/dist/chunks/NodeSelectionCommands-Ddxu5Qck.mjs.map +1 -0
- package/dist/chunks/PluginHelpers-D1QF-YaF.mjs +2 -0
- package/dist/chunks/PluginHelpers-D1QF-YaF.mjs.map +1 -0
- package/dist/chunks/{shared-BLU27F7-.mjs → PopupKeyboardPatterns-DhcUe29m.mjs} +1 -1
- package/dist/chunks/PopupKeyboardPatterns-DhcUe29m.mjs.map +1 -0
- package/dist/chunks/PrintPlugin-DVRybXSN.mjs +2 -0
- package/dist/chunks/PrintPlugin-DVRybXSN.mjs.map +1 -0
- package/dist/chunks/{RangeIterator-CVUeIB4P.mjs → RangeIterator-DytL1lUT.mjs} +1 -1
- package/dist/chunks/{RangeIterator-CVUeIB4P.mjs.map → RangeIterator-DytL1lUT.mjs.map} +1 -1
- package/dist/chunks/SmartPastePlugin-i96yAnXZ.mjs +2 -0
- package/dist/chunks/SmartPastePlugin-i96yAnXZ.mjs.map +1 -0
- package/dist/chunks/StrikethroughPlugin-RGZATXUZ.mjs +2 -0
- package/dist/chunks/StrikethroughPlugin-RGZATXUZ.mjs.map +1 -0
- package/dist/chunks/SuperSubPlugin-BOWFP1Kr.mjs +2 -0
- package/dist/chunks/SuperSubPlugin-BOWFP1Kr.mjs.map +1 -0
- package/dist/chunks/TablePlugin-DZTMBkyu.mjs +2 -0
- package/dist/chunks/TablePlugin-DZTMBkyu.mjs.map +1 -0
- package/dist/chunks/TextColorPlugin-CB3RpTSQ.mjs +2 -0
- package/dist/chunks/TextColorPlugin-CB3RpTSQ.mjs.map +1 -0
- package/dist/chunks/{TextDirectionCorePlugin-CXCxX532.mjs → TextDirectionCorePlugin-tNecTcrX.mjs} +2 -2
- package/dist/chunks/{TextDirectionCorePlugin-CXCxX532.mjs.map → TextDirectionCorePlugin-tNecTcrX.mjs.map} +1 -1
- package/dist/chunks/TextDirectionLocale-_AUfZu9j.mjs +2 -0
- package/dist/chunks/{TextDirectionLocale-Kh3r4XQS.mjs.map → TextDirectionLocale-_AUfZu9j.mjs.map} +1 -1
- package/dist/chunks/TextFormattingPlugin-CZ6D-luc.mjs +2 -0
- package/dist/chunks/TextFormattingPlugin-CZ6D-luc.mjs.map +1 -0
- package/dist/chunks/ToolbarPlugin-2K96zYut.mjs +2 -0
- package/dist/chunks/ToolbarPlugin-2K96zYut.mjs.map +1 -0
- package/dist/chunks/WordBoundary-BE2u997Q.mjs +2 -0
- package/dist/chunks/WordBoundary-BE2u997Q.mjs.map +1 -0
- package/dist/chunks/XmlSupport-DG8PEZhO.mjs +2 -0
- package/dist/chunks/XmlSupport-DG8PEZhO.mjs.map +1 -0
- package/dist/chunks/ar--dzNQRg4.mjs +2 -0
- package/dist/chunks/{ar-DLxmSv7R.mjs.map → ar--dzNQRg4.mjs.map} +1 -1
- package/dist/chunks/{color-picker-D4Vi72Z_.mjs → color-picker-ChYYdC-r.mjs} +1 -1
- package/dist/chunks/{color-picker-D4Vi72Z_.mjs.map → color-picker-ChYYdC-r.mjs.map} +1 -1
- package/dist/chunks/de-C7Grl0t1.mjs +2 -0
- package/dist/chunks/de-C7Grl0t1.mjs.map +1 -0
- package/dist/chunks/{es-BL7KuLOg.mjs → es-BwmzRdDZ.mjs} +2 -2
- package/dist/chunks/es-BwmzRdDZ.mjs.map +1 -0
- package/dist/chunks/{fonts-B3hiRKxQ.mjs → fonts-CG_dDwvT.mjs} +1 -1
- package/dist/chunks/{fonts-B3hiRKxQ.mjs.map → fonts-CG_dDwvT.mjs.map} +1 -1
- package/dist/chunks/fr-CC7TYK5K.mjs +2 -0
- package/dist/chunks/{fr-GSoPohxY.mjs.map → fr-CC7TYK5K.mjs.map} +1 -1
- package/dist/chunks/full-B9IqlP6u.mjs +2 -0
- package/dist/chunks/{full-DCZ8MMpe.mjs.map → full-B9IqlP6u.mjs.map} +1 -1
- package/dist/chunks/{hi-CTb2tu17.mjs → hi-BtN2T9la.mjs} +2 -2
- package/dist/chunks/{hi-CTb2tu17.mjs.map → hi-BtN2T9la.mjs.map} +1 -1
- package/dist/chunks/minimal-J-u7e_pr.mjs +2 -0
- package/dist/chunks/{minimal-DmYfqOxb.mjs.map → minimal-J-u7e_pr.mjs.map} +1 -1
- package/dist/chunks/{pt-BattAVOq.mjs → pt-B59gJzMS.mjs} +2 -2
- package/dist/chunks/pt-B59gJzMS.mjs.map +1 -0
- package/dist/chunks/{ru-U-UhwubV.mjs → ru-KBX9Y7TT.mjs} +2 -2
- package/dist/chunks/{ru-U-UhwubV.mjs.map → ru-KBX9Y7TT.mjs.map} +1 -1
- package/dist/chunks/src-DPhUQ25M.mjs +2 -0
- package/dist/chunks/src-DPhUQ25M.mjs.map +1 -0
- package/dist/chunks/{text-direction-advanced-CkFu0K_I.mjs → text-direction-advanced-S4MgVMLX.mjs} +2 -2
- package/dist/chunks/{text-direction-advanced-CkFu0K_I.mjs.map → text-direction-advanced-S4MgVMLX.mjs.map} +1 -1
- package/dist/chunks/{zh-TXVgSc3H.mjs → zh-D4eu30KQ.mjs} +2 -2
- package/dist/chunks/{zh-TXVgSc3H.mjs.map → zh-D4eu30KQ.mjs.map} +1 -1
- package/dist/commands/CommandHelpers.d.ts +13 -0
- package/dist/commands/CommandHelpers.d.ts.map +1 -1
- package/dist/commands/DeleteCommands.d.ts.map +1 -1
- package/dist/editor/EditorConfig.d.ts +7 -0
- package/dist/editor/EditorConfig.d.ts.map +1 -1
- package/dist/editor/EditorLocale.d.ts.map +1 -1
- package/dist/editor/styles/code-block.d.ts.map +1 -1
- package/dist/fonts.mjs +1 -1
- package/dist/full.mjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/notectl-core.mjs +1 -1
- package/dist/notectl-core.umd.js +1 -1
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/CommandRegistry.d.ts +3 -0
- package/dist/plugins/CommandRegistry.d.ts.map +1 -1
- package/dist/plugins/EventBus.d.ts +3 -0
- package/dist/plugins/EventBus.d.ts.map +1 -1
- package/dist/plugins/Logger.d.ts +50 -0
- package/dist/plugins/Logger.d.ts.map +1 -0
- package/dist/plugins/MiddlewareChain.d.ts +3 -0
- package/dist/plugins/MiddlewareChain.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/PluginLifecycle.d.ts +3 -1
- package/dist/plugins/PluginLifecycle.d.ts.map +1 -1
- package/dist/plugins/PluginManager.d.ts +14 -1
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentLocale.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/blockquote/BlockquoteLocale.d.ts.map +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation/CaretNavigationLocale.d.ts.map +1 -1
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockCommands.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockLocale.d.ts +4 -0
- package/dist/plugins/code-block/CodeBlockLocale.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts +13 -1
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockService.d.ts +2 -2
- package/dist/plugins/code-block/CodeBlockService.d.ts.map +1 -1
- package/dist/plugins/code-block/LanguagePicker.d.ts +14 -0
- package/dist/plugins/code-block/LanguagePicker.d.ts.map +1 -0
- package/dist/plugins/code-block/highlighter/RegexTokenizer.d.ts.map +1 -1
- package/dist/plugins/code-block/highlighter/TokenizerTypes.d.ts +1 -1
- package/dist/plugins/code-block/highlighter/TokenizerTypes.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/ar.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/de.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/es.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/fr.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/hi.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/pt.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/ru.d.ts.map +1 -1
- package/dist/plugins/code-block/locales/zh.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font/FontLocale.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeLocale.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/gap-cursor/GapCursorLocale.d.ts.map +1 -1
- package/dist/plugins/gap-cursor.mjs +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/HeadingLocale.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight/HighlightLocale.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts.map +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/ImageLocale.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/inline-code/InlineCodeLocale.d.ts.map +1 -1
- package/dist/plugins/inline-code.mjs +1 -1
- package/dist/plugins/language.mjs +1 -1
- package/dist/plugins/link/LinkLocale.d.ts.map +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/list/ListLocale.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/print/PrintLocale.d.ts.map +1 -1
- package/dist/plugins/print.mjs +1 -1
- package/dist/plugins/shared/LocaleLoader.d.ts +49 -0
- package/dist/plugins/shared/LocaleLoader.d.ts.map +1 -0
- 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/SmartPasteLocale.d.ts.map +1 -1
- package/dist/plugins/smart-paste.mjs +1 -1
- package/dist/plugins/strikethrough/StrikethroughLocale.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub/SuperSubLocale.d.ts.map +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/table/TableCommands.d.ts.map +1 -1
- package/dist/plugins/table/TableLocale.d.ts.map +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-color/TextColorLocale.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +1 -1
- package/dist/plugins/text-direction/TextDirectionLocale.d.ts.map +1 -1
- package/dist/plugins/text-direction-advanced.mjs +1 -1
- package/dist/plugins/text-direction.mjs +1 -1
- package/dist/plugins/text-formatting/TextFormattingLocale.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -1
- package/dist/plugins/toolbar.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/state/EditorState.d.ts +2 -0
- package/dist/state/EditorState.d.ts.map +1 -1
- package/dist/view/EditorView.d.ts +11 -1
- package/dist/view/EditorView.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/chunks/AlignmentPlugin-CD11uRY3.mjs +0 -2
- package/dist/chunks/AlignmentPlugin-CD11uRY3.mjs.map +0 -1
- package/dist/chunks/BlockquotePlugin-DpMA33pk.mjs +0 -2
- package/dist/chunks/BlockquotePlugin-DpMA33pk.mjs.map +0 -1
- package/dist/chunks/CaretNavigationPlugin-BxU2lMwX.mjs +0 -2
- package/dist/chunks/CaretNavigationPlugin-BxU2lMwX.mjs.map +0 -1
- package/dist/chunks/CodeBlockPlugin-CSb6Fxce.mjs +0 -2
- package/dist/chunks/CodeBlockPlugin-CSb6Fxce.mjs.map +0 -1
- package/dist/chunks/Commands-C7zBYmhA.mjs +0 -2
- package/dist/chunks/Commands-C7zBYmhA.mjs.map +0 -1
- package/dist/chunks/FontPlugin-CUVcS-40.mjs +0 -2
- package/dist/chunks/FontPlugin-CUVcS-40.mjs.map +0 -1
- package/dist/chunks/FontSizePlugin-a8YyFsjf.mjs +0 -2
- package/dist/chunks/FontSizePlugin-a8YyFsjf.mjs.map +0 -1
- package/dist/chunks/GapCursorPlugin-9V0Ne0Sw.mjs +0 -2
- package/dist/chunks/GapCursorPlugin-9V0Ne0Sw.mjs.map +0 -1
- package/dist/chunks/HeadingPlugin-1BVn57NF.mjs +0 -2
- package/dist/chunks/HighlightPlugin-7S6Y_IFY.mjs +0 -2
- package/dist/chunks/HighlightPlugin-7S6Y_IFY.mjs.map +0 -1
- package/dist/chunks/HorizontalRulePlugin-bZ4nat7E.mjs +0 -2
- package/dist/chunks/HorizontalRulePlugin-bZ4nat7E.mjs.map +0 -1
- package/dist/chunks/ImagePlugin-wz0SBhFQ.mjs +0 -2
- package/dist/chunks/ImagePlugin-wz0SBhFQ.mjs.map +0 -1
- package/dist/chunks/InlineCodePlugin-DW5_oiac.mjs +0 -2
- package/dist/chunks/InlineCodePlugin-DW5_oiac.mjs.map +0 -1
- package/dist/chunks/LinkPlugin-pWzPs-dS.mjs +0 -2
- package/dist/chunks/LinkPlugin-pWzPs-dS.mjs.map +0 -1
- package/dist/chunks/ListPlugin-Datp4nPR.mjs +0 -2
- package/dist/chunks/NodeSelectionCommands-BFHLrE5I.mjs +0 -2
- package/dist/chunks/NodeSelectionCommands-BFHLrE5I.mjs.map +0 -1
- package/dist/chunks/PluginHelpers-Db50-BRE.mjs +0 -2
- package/dist/chunks/PluginHelpers-Db50-BRE.mjs.map +0 -1
- package/dist/chunks/PrintPlugin-Dv8_E40e.mjs +0 -2
- package/dist/chunks/PrintPlugin-Dv8_E40e.mjs.map +0 -1
- package/dist/chunks/SmartPastePlugin-PCLFN5yA.mjs +0 -2
- package/dist/chunks/SmartPastePlugin-PCLFN5yA.mjs.map +0 -1
- package/dist/chunks/StrikethroughPlugin-J5eDn_sY.mjs +0 -2
- package/dist/chunks/StrikethroughPlugin-J5eDn_sY.mjs.map +0 -1
- package/dist/chunks/SuperSubPlugin-uSLscUwN.mjs +0 -2
- package/dist/chunks/SuperSubPlugin-uSLscUwN.mjs.map +0 -1
- package/dist/chunks/TablePlugin-DJHHWTD2.mjs +0 -2
- package/dist/chunks/TablePlugin-DJHHWTD2.mjs.map +0 -1
- package/dist/chunks/TextColorPlugin-CawTv5pV.mjs +0 -2
- package/dist/chunks/TextColorPlugin-CawTv5pV.mjs.map +0 -1
- package/dist/chunks/TextDirectionLocale-Kh3r4XQS.mjs +0 -2
- package/dist/chunks/TextFormattingPlugin-DKgwX4Gy.mjs +0 -2
- package/dist/chunks/TextFormattingPlugin-DKgwX4Gy.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-BipA0zez.mjs +0 -2
- package/dist/chunks/ToolbarPlugin-BipA0zez.mjs.map +0 -1
- package/dist/chunks/WordBoundary-DI0G6Wk2.mjs +0 -2
- package/dist/chunks/WordBoundary-DI0G6Wk2.mjs.map +0 -1
- package/dist/chunks/XmlSupport-UA-iNWTl.mjs +0 -2
- package/dist/chunks/XmlSupport-UA-iNWTl.mjs.map +0 -1
- package/dist/chunks/ar-DLxmSv7R.mjs +0 -2
- package/dist/chunks/de-BnhP65y3.mjs +0 -2
- package/dist/chunks/de-BnhP65y3.mjs.map +0 -1
- package/dist/chunks/es-BL7KuLOg.mjs.map +0 -1
- package/dist/chunks/fr-GSoPohxY.mjs +0 -2
- package/dist/chunks/full-DCZ8MMpe.mjs +0 -2
- package/dist/chunks/minimal-DmYfqOxb.mjs +0 -2
- package/dist/chunks/pt-BattAVOq.mjs.map +0 -1
- package/dist/chunks/shared-BLU27F7-.mjs.map +0 -1
- package/dist/chunks/src-CgbuJfYr.mjs +0 -2
- package/dist/chunks/src-CgbuJfYr.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Commands-BuYF23lf.mjs","names":[],"sources":["../../src/model/Schema.ts","../../src/commands/GapCursorCommands.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 { 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}\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};\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 { extractParentPath, findSiblingIndex, getSiblings } 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 path = findNodePath(state.doc, sel.blockId);\n\tif (!path) return null;\n\n\tconst parentPath: BlockId[] = extractParentPath(path);\n\tconst siblings = getSiblings(state, parentPath);\n\n\tconst index: number = findSiblingIndex(siblings, 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 path = findNodePath(state.doc, sel.blockId);\n\tconst parentPath: BlockId[] = extractParentPath(path);\n\tconst siblings = getSiblings(state, parentPath);\n\n\tconst index: number = findSiblingIndex(siblings, 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 * 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\tgetBlockMarksAtOffset,\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 { 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 = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\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\tif (state.storedMarks) {\n\t\t\treturn hasMark(state.storedMarks, markType);\n\t\t}\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block) return false;\n\t\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\t\treturn hasMark(marks, markType);\n\t}\n\n\treturn isMarkActiveInRange(state, markType);\n}\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\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\tif (!isMarkActiveInBlock(block, from, to, markType)) return false;\n\t}\n\n\treturn true;\n}\n\nfunction isMarkActiveInBlock(\n\tblock: BlockNode,\n\tfrom: number,\n\tto: number,\n\tmarkType: MarkTypeName,\n): boolean {\n\tif (from === to) return false;\n\tlet pos = 0;\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\tif (!hasMark(child.marks, markType)) return false;\n\t\t\t}\n\t\t\tpos = childEnd;\n\t\t} else {\n\t\t\t// InlineNode: skip (width 1, no marks)\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn true;\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\tisLeafBlock,\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 { insertParagraphAtGap, insertTextAtGap } from './GapCursorCommands.js';\nimport {\n\tdeleteNodeSelection,\n\tfindFirstLeafBlockId,\n\tfindLastLeafBlockId,\n\tinsertParagraphAfterNodeSelection,\n\tinsertTextAfterNodeSelection,\n} from './NodeSelectionCommands.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\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 blocks = state.doc.children;\n\tconst firstBlock = blocks[0];\n\tconst lastBlock = blocks[blocks.length - 1];\n\tif (!firstBlock || !lastBlock)\n\t\treturn state.transaction('command').setSelection(state.selection).build();\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 state\n\t\t.transaction('command')\n\t\t.setSelection(\n\t\t\tcreateSelection(\n\t\t\t\t{ blockId: firstLeafId, offset: 0 },\n\t\t\t\t{ blockId: lastLeafId, offset: lastLeafLen },\n\t\t\t),\n\t\t)\n\t\t.build();\n}\n\n// --- Internal Helpers ---\n\nfunction resolveActiveMarks(state: EditorState): readonly Mark[] {\n\tif (state.storedMarks) return state.storedMarks;\n\tif (!isTextSelection(state.selection)) return [];\n\n\tconst block = state.getBlock(state.selection.anchor.blockId);\n\tif (!block) return [];\n\n\treturn getBlockMarksAtOffset(block, state.selection.anchor.offset);\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\n/** Returns the root-level ancestor index in doc.children for a given block. */\nfunction 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. */\nfunction deleteLeafRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\tblockOrder: readonly BlockId[],\n\trange: {\n\t\treadonly from: { readonly blockId: BlockId; readonly offset: number };\n\t\treadonly to: { readonly blockId: BlockId; readonly offset: number };\n\t},\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 */\nfunction deleteCrossRootRange(\n\tstate: EditorState,\n\tbuilder: TransactionBuilder,\n\trange: {\n\t\treadonly from: { readonly blockId: BlockId; readonly offset: number };\n\t\treadonly to: { readonly blockId: BlockId; readonly offset: number };\n\t},\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"],"mappings":"wpBAgBA,SAAgB,IACf,MAAO,CACN,UAAW,CAAC,aACZ,UAAW,CAAC,OAAQ,SAAU,aAC9B,YAAA,QAKF,SAAgB,EAAmB,GAClC,MAAO,CACN,UAAW,EAAS,eACpB,UAAW,EAAS,eACpB,YAAc,GAAiB,EAAS,YAAY,IAKtD,SAAgB,EAAc,EAAgB,GAC7C,OAAO,EAAO,UAAU,SAAS,GAIlC,SAAgB,EAAkB,EAAgB,GACjD,OAAO,EAAO,UAAU,SAAS,GCjBlC,SAAgB,EACf,EACA,GAEA,GAAiB,UAA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,SAAS,EAAM,KAAK,SAC7C,IAAK,EAAY,OACjB,MAAM,EAAW,EAAe,GAE5B,EAAM,KAAK,OAAS,GACvB,EAAQ,aAAa,EAAM,KAAK,QAAS,EAAM,KAAK,OAAQ,GAGzD,EAAM,GAAG,OAAS,GACrB,EAAQ,aAAa,EAAM,GAAG,QAAS,EAAG,EAAM,GAAG,QAGpD,IAAK,IAAI,EAAI,EAAU,EAAG,EAAI,EAAO,IAAK,CACzC,MAAM,EAAa,EAAW,GAC9B,IAAK,EAAY,SACjB,MAAM,EAAW,EAAM,SAAS,GAChC,IAAK,EAAU,SACf,MAAM,EAAS,EAAe,GAC1B,EAAS,GACZ,EAAQ,aAAa,EAAY,EAAG,GAErC,EAAQ,cAAc,EAAM,KAAK,QAAS,GAG3C,EAAQ,cAAc,EAAM,KAAK,QAAS,EAAM,GAAG,SAnDlD,CAAgB,EAAO,EAAS,EAAY,EAAO,EAAS,GAQ9D,SAAS,GAAkB,EAAoB,GAC9C,MAAM,EAAO,EAAa,EAAM,IAAK,GACrC,IAAK,GAAwB,IAAhB,EAAK,OAAc,OAAO,EACvC,MAAM,EAAiB,EAAK,GAC5B,OAAO,EAAM,IAAI,SAAS,UAAW,GAAM,EAAE,KAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as t}from"./TypeBrands-BZDKMjR-.mjs";import{r as e}from"./HTMLUtils-B8xj8Z1x.mjs";import{i as n,n as o,r as i,t as r}from"./AttributedMarkCommands-35jTbVRg.mjs";import{r as s,s as a}from"./StyleRuntime-D3d1XFFe.mjs";import{i as l,o as c}from"./PluginHelpers-D1QF-YaF.mjs";import{n as m}from"./ColorValidation-CiGxVsqd.mjs";var p={label:"Font",tooltip:"Font Family"},f=/* @__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-D57VZrg2.mjs"),"./locales/de.ts":()=>import("./de-Ds6tfD71.mjs"),"./locales/es.ts":()=>import("./es-BpgE28ol.mjs"),"./locales/fr.ts":()=>import("./fr-zO4UIZj_.mjs"),"./locales/hi.ts":()=>import("./hi-CSatC6e_.mjs"),"./locales/pt.ts":()=>import("./pt-B65Mk0F_.mjs"),"./locales/ru.ts":()=>import("./ru-CmlYwIPH.mjs"),"./locales/zh.ts":()=>import("./zh-B3geJFGW.mjs")});async function d(t){return c(f,t,p)}var h=class{id="font";name="Font";priority=22;config;locale;injectedStyleElement=null;context=null;constructor(t){this.config=t}async init(t){this.locale=await l(t,this.config.locale,p,d),t.registerStyleSheet("\n/* Font Select — Width overrides for combobox button */\n.notectl-toolbar-btn--font {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Font Picker Popup */\n.notectl-font-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-font-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-font-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-font-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-font-picker__label {\n\tflex: 1;\n}\n\n.notectl-font-picker__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 8px;\n}\n"),this.context=t,this.registerMarkSpec(t),this.registerCommands(t),this.config.fonts.length>0&&this.registerToolbarItem(t),this.injectFontFaces()}destroy(){this.injectedStyleElement?.remove(),this.injectedStyleElement=null,this.context=null}registerMarkSpec(t){t.registerMarkSpec({type:"font",rank:6,attrs:{family:{default:""}},toDOM(t){const e=document.createElement("span"),n=t.attrs?.family??"";return n&&a(e,"fontFamily",n),e},toHTMLString:(t,n,o)=>{const i=String(t.attrs?.family??"");if(!i||!m(i))return n;const r=`font-family: ${e(i)}`;return`<span${o?.styleAttr(r)??` style="${r}"`}>${n}</span>`},toHTMLStyle:t=>{const n=String(t.attrs?.family??"");return n&&m(n)?`font-family: ${e(n)}`:null},parseHTML:[{tag:"span",getAttrs:t=>{const e=t.style.fontFamily;return!!e&&{family:e.replace(/"/g,"'")}}}],sanitize:{tags:["span"]}})}registerCommands(t){t.registerCommand("removeFont",()=>{const e=t.getState();return this.removeFont(t,e)}),t.registerCommand("setFont",()=>!1)}get defaultFont(){if(this.config.defaultFont){const t=this.config.fonts.find(t=>t.name===this.config.defaultFont);if(t)return t}return this.config.fonts[0]}registerToolbarItem(t){t.registerToolbarItem({id:"font",group:"format",label:this.locale.label,tooltip:this.locale.tooltip,command:"removeFont",popupType:"combobox",getLabel:t=>this.resolveFontName(this.getActiveFont(t)),renderPopup:(t,e,n)=>{this.renderFontPopup(t,e,n)},isActive:t=>this.isFontActive(t)})}resolveFontName(t){return t?this.config.fonts.find(e=>e.family===t)?.name??(t.split(",")[0]??"").trim().replace(/['"]/g,""):this.defaultFont?.name??this.locale.label}isFontActive(t){return i(t,"font")}getActiveFont(t){return o(t,"font",t=>t.attrs.family??null)}applyFont(e,n,o){const i=r(n,{type:t("font"),attrs:{family:o}});return!!i&&(e.dispatch(i),!0)}removeFont(e,o){const i=n(o,t("font"));return!!i&&(e.dispatch(i),!0)}injectFontFaces(){const t=[];for(const o of this.config.fonts)if(o.fontFaces?.length)for(const e of o.fontFaces){const n=[`font-family: '${(o.family.split(",")[0]??"").trim().replace(/['"]/g,"")}'`,`src: ${e.src}`];e.weight&&n.push(`font-weight: ${e.weight}`),e.style&&n.push(`font-style: ${e.style}`),n.push(`font-display: ${e.display??"swap"}`),t.push(`@font-face {\n\t${n.join(";\n\t")};\n}`)}if(0===t.length)return;const e=document.createElement("style");e.setAttribute("data-notectl-fonts","");const n=this.context?s(this.context.getContainer()):void 0;n&&e.setAttribute("nonce",n),e.textContent=t.join("\n\n"),document.head.appendChild(e),this.injectedStyleElement=e}renderFontPopup(t,e,n){t.classList.add("notectl-font-picker");const o=e.getState(),i=this.getActiveFont(o),r=this.defaultFont?.family,s=e.getContainer(),a=document.createElement("div");a.className="notectl-font-picker__list",a.setAttribute("role","listbox"),a.setAttribute("aria-label",this.locale.label);for(const l of this.config.fonts){const t=void 0!==r&&l.family===r,o=t&&!i||i===l.family,c=this.createFontItem(l.name,l.family,o,o=>{o.preventDefault(),o.stopPropagation(),t?e.executeCommand("removeFont"):this.applyFont(e,e.getState(),l.family),n({restoreFocusTo:s})});l.category&&c.setAttribute("data-category",l.category),a.appendChild(c)}t.appendChild(a)}createFontItem(t,e,n,o){const i=document.createElement("button");i.type="button",i.className="notectl-font-picker__item",i.setAttribute("role","option"),i.setAttribute("aria-selected",String(n)),n&&i.classList.add("notectl-font-picker__item--active");const r=document.createElement("span");r.className="notectl-font-picker__check",r.textContent=n?"✓":"",i.appendChild(r);const s=document.createElement("span");return s.className="notectl-font-picker__label",s.textContent=t,e&&a(s,"fontFamily",e),i.appendChild(s),i.addEventListener("mousedown",o),i}};export{p as n,d as r,h as t};
|
|
2
|
+
//# sourceMappingURL=FontPlugin-z0QF1M5q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontPlugin-z0QF1M5q.mjs","names":[],"sources":["../../src/editor/styles/font-select.ts","../../src/plugins/font/FontLocale.ts","../../src/plugins/font/FontPlugin.ts"],"sourcesContent":["/** Font picker toolbar combobox + popup styles. */\nexport const FONT_SELECT_CSS = `\n/* Font Select — Width overrides for combobox button */\n.notectl-toolbar-btn--font {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Font Picker Popup */\n.notectl-font-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-font-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-font-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-font-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-font-picker__label {\n\tflex: 1;\n}\n\n.notectl-font-picker__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 8px;\n}\n`;\n","/** Locale interface and default English locale for the FontPlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface FontLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n}\n\n// --- Default English Locale ---\n\nexport const FONT_LOCALE_EN: FontLocale = {\n\tlabel: 'Font',\n\ttooltip: 'Font Family',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<FontLocale> = import.meta.glob<{\n\tdefault: FontLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadFontLocale(lang: string): Promise<FontLocale> {\n\treturn loadLocaleModule(localeModules, lang, FONT_LOCALE_EN);\n}\n","/**\n * FontPlugin: registers a font-family mark, a combobox-style toolbar selector\n * for font selection, and a developer-friendly API for registering custom fonts\n * (WOFF2, TTF, OTF).\n */\n\nimport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from '../../commands/AttributedMarkCommands.js';\nimport { FONT_SELECT_CSS } from '../../editor/styles/font-select.js';\nimport { escapeHTML } from '../../model/HTMLUtils.js';\nimport type { HTMLExportContext } from '../../model/NodeSpec.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { getStyleNonceForNode, setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isValidCSSFontFamily } from '../shared/ColorValidation.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport { FONT_LOCALE_EN, type FontLocale, loadFontLocale } from './FontLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfont: { family: string };\n\t}\n}\n\n// --- Public Types ---\n\n/** Describes a single @font-face source. */\nexport interface FontFaceDescriptor {\n\t/** CSS `src` value, e.g. `\"url('/fonts/My.woff2') format('woff2')\"`. */\n\treadonly src: string;\n\t/** Font weight, e.g. `'400'` or `'300 700'` for variable fonts. */\n\treadonly weight?: string;\n\t/** Font style, e.g. `'normal'` or `'italic'`. */\n\treadonly style?: string;\n\t/** Font display strategy. Defaults to `'swap'`. */\n\treadonly display?: string;\n}\n\n/** Defines a font available in the editor. */\nexport interface FontDefinition {\n\t/** Display name shown in the toolbar dropdown. */\n\treadonly name: string;\n\t/** CSS `font-family` value, e.g. `\"'Fira Code', monospace\"`. */\n\treadonly family: string;\n\t/** Font category for grouping in the UI. */\n\treadonly category?: 'serif' | 'sans-serif' | 'monospace' | 'display' | 'handwriting';\n\t/**\n\t * Optional `@font-face` descriptors. When provided, the plugin\n\t * auto-injects the corresponding CSS rules into the document.\n\t */\n\treadonly fontFaces?: readonly FontFaceDescriptor[];\n}\n\n// --- Configuration ---\n\nexport interface FontConfig {\n\t/**\n\t * Fonts available in the editor. System fonts require no `fontFaces`.\n\t * Custom fonts with `fontFaces` get their `@font-face` rules auto-injected.\n\t *\n\t * Use `STARTER_FONTS` for a pre-configured set of fonts:\n\t * ```ts\n\t * new FontPlugin({ fonts: [...STARTER_FONTS] })\n\t * ```\n\t */\n\treadonly fonts: readonly FontDefinition[];\n\t/**\n\t * Name of the font that acts as the editor's default.\n\t * Selecting this font removes the mark (since the editor already uses it).\n\t * Defaults to the first font in the list.\n\t */\n\treadonly defaultFont?: string;\n\treadonly locale?: FontLocale;\n}\n\n// --- Plugin ---\n\nexport class FontPlugin implements Plugin {\n\treadonly id = 'font';\n\treadonly name = 'Font';\n\treadonly priority = 22;\n\n\tprivate readonly config: FontConfig;\n\tprivate locale!: FontLocale;\n\tprivate injectedStyleElement: HTMLStyleElement | null = null;\n\tprivate context: PluginContext | null = null;\n\n\tconstructor(config: FontConfig) {\n\t\tthis.config = config;\n\t}\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(context, this.config.locale, FONT_LOCALE_EN, loadFontLocale);\n\n\t\tcontext.registerStyleSheet(FONT_SELECT_CSS);\n\t\tthis.context = context;\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tif (this.config.fonts.length > 0) {\n\t\t\tthis.registerToolbarItem(context);\n\t\t}\n\t\tthis.injectFontFaces();\n\t}\n\n\tdestroy(): void {\n\t\tthis.injectedStyleElement?.remove();\n\t\tthis.injectedStyleElement = null;\n\t\tthis.context = null;\n\t}\n\n\t// --- Schema ---\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: 'font',\n\t\t\trank: 6,\n\t\t\tattrs: {\n\t\t\t\tfamily: { default: '' },\n\t\t\t},\n\t\t\ttoDOM(mark) {\n\t\t\t\tconst span: HTMLElement = document.createElement('span');\n\t\t\t\tconst family: string = mark.attrs?.family ?? '';\n\t\t\t\tif (family) {\n\t\t\t\t\tsetStyleProperty(span, 'fontFamily', family);\n\t\t\t\t}\n\t\t\t\treturn span;\n\t\t\t},\n\t\t\ttoHTMLString: (mark, content, ctx?: HTMLExportContext) => {\n\t\t\t\tconst family: string = String(mark.attrs?.family ?? '');\n\t\t\t\tif (!family || !isValidCSSFontFamily(family)) return content;\n\t\t\t\tconst decl: string = `font-family: ${escapeHTML(family)}`;\n\t\t\t\tconst attr: string = ctx?.styleAttr(decl) ?? ` style=\"${decl}\"`;\n\t\t\t\treturn `<span${attr}>${content}</span>`;\n\t\t\t},\n\t\t\ttoHTMLStyle: (mark) => {\n\t\t\t\tconst family: string = String(mark.attrs?.family ?? '');\n\t\t\t\tif (!family || !isValidCSSFontFamily(family)) return null;\n\t\t\t\treturn `font-family: ${escapeHTML(family)}`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'span',\n\t\t\t\t\tgetAttrs: (el) => {\n\t\t\t\t\t\tconst family: string = el.style.fontFamily;\n\t\t\t\t\t\tif (!family) return false;\n\t\t\t\t\t\t// Browsers normalize CSS quotes to double-quotes;\n\t\t\t\t\t\t// our internal convention uses single-quotes.\n\t\t\t\t\t\tconst normalized: string = family.replace(/\"/g, \"'\");\n\t\t\t\t\t\treturn { family: normalized };\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['span'] },\n\t\t});\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeFont', () => {\n\t\t\tconst state: EditorState = context.getState();\n\t\t\treturn this.removeFont(context, state);\n\t\t});\n\n\t\tcontext.registerCommand('setFont', () => {\n\t\t\treturn false;\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate get defaultFont(): FontDefinition | undefined {\n\t\tif (this.config.defaultFont) {\n\t\t\tconst found: FontDefinition | undefined = this.config.fonts.find(\n\t\t\t\t(f) => f.name === this.config.defaultFont,\n\t\t\t);\n\t\t\tif (found) return found;\n\t\t}\n\t\treturn this.config.fonts[0];\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'font',\n\t\t\tgroup: 'format',\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeFont',\n\t\t\tpopupType: 'combobox',\n\t\t\tgetLabel: (state: EditorState): string => this.resolveFontName(this.getActiveFont(state)),\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\tthis.renderFontPopup(container, ctx, onClose);\n\t\t\t},\n\t\t\tisActive: (state) => this.isFontActive(state),\n\t\t});\n\t}\n\n\tprivate resolveFontName(family: string | null): string {\n\t\tif (!family) return this.defaultFont?.name ?? this.locale.label;\n\t\tconst match: FontDefinition | undefined = this.config.fonts.find((f) => f.family === family);\n\t\treturn match?.name ?? (family.split(',')[0] ?? '').trim().replace(/['\"]/g, '');\n\t}\n\n\t// --- State Queries ---\n\n\tprivate isFontActive(state: EditorState): boolean {\n\t\treturn isAttributedMarkActive(state, 'font');\n\t}\n\n\tgetActiveFont(state: EditorState): string | null {\n\t\treturn getMarkAttrAtSelection(state, 'font', (m) => m.attrs.family ?? null);\n\t}\n\n\t// --- Font Application ---\n\n\tapplyFont(context: PluginContext, state: EditorState, family: string): boolean {\n\t\tconst mark = { type: markType('font'), attrs: { family } };\n\t\tconst tr = applyAttributedMark(state, mark);\n\t\tif (!tr) return false;\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tprivate removeFont(context: PluginContext, state: EditorState): boolean {\n\t\tconst tr = removeAttributedMark(state, markType('font'));\n\t\tif (!tr) return false;\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\t// --- @font-face Injection ---\n\n\tprivate injectFontFaces(): void {\n\t\tconst rules: string[] = [];\n\n\t\tfor (const font of this.config.fonts) {\n\t\t\tif (!font.fontFaces?.length) continue;\n\n\t\t\tfor (const face of font.fontFaces) {\n\t\t\t\tconst familyName: string = (font.family.split(',')[0] ?? '').trim().replace(/['\"]/g, '');\n\t\t\t\tconst declarations: string[] = [`font-family: '${familyName}'`, `src: ${face.src}`];\n\t\t\t\tif (face.weight) {\n\t\t\t\t\tdeclarations.push(`font-weight: ${face.weight}`);\n\t\t\t\t}\n\t\t\t\tif (face.style) {\n\t\t\t\t\tdeclarations.push(`font-style: ${face.style}`);\n\t\t\t\t}\n\t\t\t\tdeclarations.push(`font-display: ${face.display ?? 'swap'}`);\n\n\t\t\t\trules.push(`@font-face {\\n\\t${declarations.join(';\\n\\t')};\\n}`);\n\t\t\t}\n\t\t}\n\n\t\tif (rules.length === 0) return;\n\n\t\tconst style: HTMLStyleElement = document.createElement('style');\n\t\tstyle.setAttribute('data-notectl-fonts', '');\n\t\tconst nonce = this.context ? getStyleNonceForNode(this.context.getContainer()) : undefined;\n\t\tif (nonce) {\n\t\t\tstyle.setAttribute('nonce', nonce);\n\t\t}\n\t\tstyle.textContent = rules.join('\\n\\n');\n\t\tdocument.head.appendChild(style);\n\t\tthis.injectedStyleElement = style;\n\t}\n\n\t// --- Popup Rendering ---\n\n\tprivate renderFontPopup(\n\t\tcontainer: HTMLElement,\n\t\tcontext: PluginContext,\n\t\tonClose: (options?: PopupCloseOptions) => void,\n\t): void {\n\t\tcontainer.classList.add('notectl-font-picker');\n\n\t\tconst state: EditorState = context.getState();\n\t\tconst activeFont: string | null = this.getActiveFont(state);\n\t\tconst defaultFamily: string | undefined = this.defaultFont?.family;\n\t\tconst contentElement: HTMLElement = context.getContainer();\n\n\t\tconst list: HTMLDivElement = document.createElement('div');\n\t\tlist.className = 'notectl-font-picker__list';\n\t\tlist.setAttribute('role', 'listbox');\n\t\tlist.setAttribute('aria-label', this.locale.label);\n\n\t\tfor (const font of this.config.fonts) {\n\t\t\tconst isDefault: boolean = defaultFamily !== undefined && font.family === defaultFamily;\n\t\t\tconst isActive: boolean = isDefault\n\t\t\t\t? !activeFont || activeFont === font.family\n\t\t\t\t: activeFont === font.family;\n\n\t\t\tconst item: HTMLButtonElement = this.createFontItem(\n\t\t\t\tfont.name,\n\t\t\t\tfont.family,\n\t\t\t\tisActive,\n\t\t\t\t(e: MouseEvent) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\tif (isDefault) {\n\t\t\t\t\t\tcontext.executeCommand('removeFont');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.applyFont(context, context.getState(), font.family);\n\t\t\t\t\t}\n\t\t\t\t\tonClose({ restoreFocusTo: contentElement });\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tif (font.category) {\n\t\t\t\titem.setAttribute('data-category', font.category);\n\t\t\t}\n\n\t\t\tlist.appendChild(item);\n\t\t}\n\n\t\tcontainer.appendChild(list);\n\t}\n\n\tprivate createFontItem(\n\t\tname: string,\n\t\tfamily: string,\n\t\tisActive: boolean,\n\t\thandler: (e: MouseEvent) => void,\n\t): HTMLButtonElement {\n\t\tconst item: HTMLButtonElement = document.createElement('button');\n\t\titem.type = 'button';\n\t\titem.className = 'notectl-font-picker__item';\n\t\titem.setAttribute('role', 'option');\n\t\titem.setAttribute('aria-selected', String(isActive));\n\n\t\tif (isActive) {\n\t\t\titem.classList.add('notectl-font-picker__item--active');\n\t\t}\n\n\t\t// Checkmark indicator\n\t\tconst check: HTMLSpanElement = document.createElement('span');\n\t\tcheck.className = 'notectl-font-picker__check';\n\t\tcheck.textContent = isActive ? '\\u2713' : '';\n\t\titem.appendChild(check);\n\n\t\t// Font name label (rendered in the font itself for preview)\n\t\tconst label: HTMLSpanElement = document.createElement('span');\n\t\tlabel.className = 'notectl-font-picker__label';\n\t\tlabel.textContent = name;\n\t\tif (family) {\n\t\t\tsetStyleProperty(label, 'fontFamily', family);\n\t\t}\n\t\titem.appendChild(label);\n\n\t\titem.addEventListener('mousedown', handler);\n\t\treturn item;\n\t}\n}\n"],"mappings":"4UACA,ICYa,EAA6B,CACzC,MAAO,OACP,QAAS,eAKJ,iBAA6C,OAAA,OAAA,CAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,uBAInD,eAAsB,EAAe,GACpC,OAAO,EAAiB,EAAe,EAAM,GC4D9C,IAAa,EAAb,MACC,GAAc,OACd,KAAgB,OAChB,SAAoB,GAEpB,OACA,OACA,qBAAwD,KACxD,QAAwC,KAExC,WAAA,CAAY,GACX,KAAK,OAAS,EAGf,UAAM,CAAK,GACV,KAAK,aAAe,EAAc,EAAS,KAAK,OAAO,OAAQ,EAAgB,GAE/E,EAAQ,mBFrGqB,y4CEsG7B,KAAK,QAAU,EACf,KAAK,iBAAiB,GACtB,KAAK,iBAAiB,GAClB,KAAK,OAAO,MAAM,OAAS,GAC9B,KAAK,oBAAoB,GAE1B,KAAK,kBAGN,OAAA,GACC,KAAK,sBAAsB,SAC3B,KAAK,qBAAuB,KAC5B,KAAK,QAAU,KAKhB,gBAAA,CAAyB,GACxB,EAAQ,iBAAiB,CACxB,KAAM,OACN,KAAM,EACN,MAAO,CACN,OAAQ,CAAE,QAAS,KAEpB,KAAA,CAAM,GACL,MAAM,EAAoB,SAAS,cAAc,QAC3C,EAAiB,EAAK,OAAO,QAAU,GAI7C,OAHI,GACH,EAA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4BACjB,EAAK,aAAa,OAAQ,WAC1B,EAAK,aAAa,aAAc,KAAK,OAAO,OAE5C,IAAK,MAAM,KAAQ,KAAK,OAAO,MAAO,CACrC,MAAM,OAAuC,IAAlB,GAA+B,EAAK,SAAW,EACpE,EAAoB,IACtB,GACD,IAAe,EAAK,OAEjB,EAA0B,KAAK,eACpC,EAAK,KACL,EAAK,OACL,EACC,IACA,EAAE,iBACF,EAAE,kBACE,EACH,EAAQ,eAAe,cAEvB,KAAK,UAAU,EAAS,EAAQ,WAAY,EAAK,QAElD,EAAQ,CAAE,eAAgB,MAIxB,EAAK,UACR,EAAK,aAAa,gBAAiB,EAAK,UAGzC,EAAK,YAAY,GAGlB,EAAU,YAAY,GAGvB,cAAA,CACC,EACA,EACA,EACA,GAEA,MAAM,EAA0B,SAAS,cAAc,UACvD,EAAK,KAAO,SACZ,EAAK,UAAY,4BACjB,EAAK,aAAa,OAAQ,UAC1B,EAAK,aAAa,gBAAiB,OAAO,IAEtC,GACH,EAAK,UAAU,IAAI,qCAIpB,MAAM,EAAyB,SAAS,cAAc,QACtD,EAAM,UAAY,6BAClB,EAAM,YAAc,EAAW,IAAW,GAC1C,EAAK,YAAY,GAGjB,MAAM,EAAyB,SAAS,cAAc,QAStD,OARA,EAAM,UAAY,6BAClB,EAAM,YAAc,EAChB,GACH,EAAiB,EAAO,aAAc,GAEvC,EAAK,YAAY,GAEjB,EAAK,iBAAiB,YAAa,GAC5B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as t}from"./TypeBrands-BZDKMjR-.mjs";import{r as e}from"./HTMLUtils-B8xj8Z1x.mjs";import{i as n,n as o,r as i,t as r}from"./AttributedMarkCommands-35jTbVRg.mjs";import{s}from"./StyleRuntime-D3d1XFFe.mjs";import{i as a,o as l}from"./PluginHelpers-D1QF-YaF.mjs";import{r as c}from"./ColorValidation-CiGxVsqd.mjs";var p={label:"Font Size",tooltip:"Font Size",customFontSizeAria:"Custom font size",fontSizesAria:"Font sizes"},u=/* @__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-izXCtb2I.mjs"),"./locales/de.ts":()=>import("./de-DhenqH4M.mjs"),"./locales/es.ts":()=>import("./es-DcYIJR0T.mjs"),"./locales/fr.ts":()=>import("./fr-BQaiAAa6.mjs"),"./locales/hi.ts":()=>import("./hi-Bo_sc83d.mjs"),"./locales/pt.ts":()=>import("./pt-Cx3gdB5p.mjs"),"./locales/ru.ts":()=>import("./ru-BscEW-yr.mjs"),"./locales/zh.ts":()=>import("./zh-CcMLjYrk.mjs")});async function f(t){return l(u,t,p)}function m(t,e){const n=function(t){return o(t,"fontSize",t=>t.attrs.size??null)}(t);if(!n)return e;const i=Number.parseInt(n,10);return Number.isNaN(i)?e:i}function d(e,n,o){const i=r(n,{type:t("fontSize"),attrs:{size:o}});return!!i&&(e.dispatch(i),!0)}function z(e,o){const i=n(o,t("fontSize"));return!!i&&(e.dispatch(i),!0)}function g(t,e,n,o,i){const r=function(t,e,n){if("up"===e){for(const e of n)if(e>t)return e;return null}for(let o=n.length-1;o>=0;o--){const e=n[o];if(void 0!==e&&e<t)return e}return null}(m(e,i),n,o);return null!==r&&(r===i?z(t,e):d(t,e,`${r}px`))}function h(t,e,n){e===n?t.executeCommand("removeFontSize"):d(t,t.getState(),`${e}px`)}function S(t,e){const n=document.createElement("button");n.type="button",n.id=`notectl-font-size-option-${t}`,n.className="notectl-font-size-picker__item",n.setAttribute("role","option"),n.setAttribute("aria-selected",String(e)),e&&n.classList.add("notectl-font-size-picker__item--active");const o=document.createElement("span");o.className="notectl-font-size-picker__check",o.textContent=e?"✓":"",n.appendChild(o);const i=document.createElement("span");return i.className="notectl-font-size-picker__label",i.textContent=String(t),n.appendChild(i),n}var b=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,64,72,96],v=class{id="fontSize";name="Font Size";priority=21;config;sizes;defaultSize;locale;constructor(t){var e;this.config={...t},this.sizes=function(t){if(!t||0===t.length)return b;const e=[...new Set(t)].filter(t=>Number.isInteger(t)&&t>0);return e.sort((t,e)=>t-e),e.length>0?e:b}(t?.sizes),this.defaultSize=(e=t?.defaultSize,void 0===e?16:Number.isInteger(e)&&e>0?e:16)}async init(t){this.locale=await a(t,this.config.locale,p,f),t.registerStyleSheet("\n/* Font Size Select — Width overrides for combobox button */\n.notectl-toolbar-btn--fontSize {\n\tmin-width: 60px;\n\tmax-width: 80px;\n}\n\n/* Font Size Picker Popup */\n.notectl-font-size-picker {\n\tmin-width: 140px;\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.notectl-font-size-picker__input-wrapper {\n\tpadding: 8px 8px 4px;\n}\n\n.notectl-font-size-picker__input {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tfont-family: inherit;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-surface-overlay);\n\toutline: none;\n\tbox-sizing: border-box;\n\t-moz-appearance: textfield;\n}\n\n.notectl-font-size-picker__input::-webkit-inner-spin-button,\n.notectl-font-size-picker__input::-webkit-outer-spin-button {\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.notectl-font-size-picker__input:focus {\n\tborder-color: var(--notectl-border-focus);\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-font-size-picker__list {\n\tmax-height: 280px;\n\toverflow-y: auto;\n\tpadding: 4px 0;\n}\n\n.notectl-font-size-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n\toutline: none;\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--focused {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-font-size-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-font-size-picker__label {\n\tflex: 1;\n}\n"),this.registerMarkSpec(t),this.registerCommands(t),this.registerKeymaps(t),this.registerToolbarItem(t),this.applyDefaultSizeToContainer(t)}destroy(){}registerMarkSpec(t){t.registerMarkSpec({type:"fontSize",rank:4,attrs:{size:{default:""}},toDOM(t){const e=document.createElement("span"),n=t.attrs?.size??"";return n&&s(e,"fontSize",n),e},toHTMLString:(t,n,o)=>{const i=String(t.attrs?.size??"");if(!i||!c(i))return n;const r=`font-size: ${e(i)}`;return`<span${o?.styleAttr(r)??` style="${r}"`}>${n}</span>`},toHTMLStyle:t=>{const n=String(t.attrs?.size??"");return n&&c(n)?`font-size: ${e(n)}`:null},parseHTML:[{tag:"span",getAttrs:t=>{const e=t.style.fontSize;return!!e&&{size:e}}}],sanitize:{tags:["span"]}})}registerCommands(t){t.registerCommand("removeFontSize",()=>z(t,t.getState())),t.registerCommand("setFontSize",()=>!1),t.registerCommand("increaseFontSize",()=>g(t,t.getState(),"up",this.sizes,this.defaultSize)),t.registerCommand("decreaseFontSize",()=>g(t,t.getState(),"down",this.sizes,this.defaultSize))}registerKeymaps(t){t.registerKeymap({"Mod-Shift-+":()=>g(t,t.getState(),"up",this.sizes,this.defaultSize),"Mod-Shift-_":()=>g(t,t.getState(),"down",this.sizes,this.defaultSize)})}registerToolbarItem(t){t.registerToolbarItem({id:"fontSize",group:"format",label:this.locale.label,tooltip:this.locale.tooltip,command:"removeFontSize",popupType:"combobox",getLabel:t=>String(m(t,this.defaultSize)),renderPopup:(t,e,n)=>{!function(t,e,n){t.classList.add("notectl-font-size-picker");const o=m(e.getState(),n.defaultSize),i=function(t,e){const n=document.createElement("input");return n.type="number",n.className="notectl-font-size-picker__input",n.min=String(1),n.max=String(400),n.value=String(t),n.setAttribute("aria-label",e.locale.customFontSizeAria),n}(o,n);!function(t,e){const n=document.createElement("div");n.className="notectl-font-size-picker__input-wrapper",n.appendChild(e),t.appendChild(n)}(t,i);const{list:r,items:s}=function(t,e,n,o){const i=document.createElement("div");i.className="notectl-font-size-picker__list",i.setAttribute("role","listbox"),i.setAttribute("aria-label",o.locale.fontSizesAria);const r=[];for(const s of t){const t=S(s,s===e);t.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),h(n,s,o.defaultSize),o.onClose({restoreFocusTo:o.contentElement})}),r.push(t),i.appendChild(t)}return{list:i,items:r}}(n.sizes,o,e,n);t.appendChild(r),function(t,e,n,o){const i=e.indexOf(n);if(i<0)return;const r=t[i];r&&(requestAnimationFrame(()=>{r.scrollIntoView({block:"nearest"})}),o.setAttribute("aria-activedescendant",r.id))}(s,n.sizes,o,r),function(t,e,n,o,i){let r=-1;const s=t=>{r>=0&&r<n.length&&n[r]?.classList.remove("notectl-font-size-picker__item--focused"),r=t;const o=n[r];r>=0&&r<n.length&&o&&(o.classList.add("notectl-font-size-picker__item--focused"),o.scrollIntoView({block:"nearest"}),e.setAttribute("aria-activedescendant",o.id))};t.addEventListener("keydown",e=>{if("Enter"===e.key){e.preventDefault();const n=Number.parseInt(t.value,10);!Number.isNaN(n)&&n>=1&&n<=400&&(h(o,n,i.defaultSize),i.onClose({restoreFocusTo:i.contentElement}))}else"ArrowDown"===e.key?(e.preventDefault(),s(0),n[0]?.focus()):"Escape"===e.key&&(e.preventDefault(),i.onClose({restoreFocusTo:i.contentElement}))}),e.addEventListener("keydown",e=>{if("ArrowDown"===e.key)e.preventDefault(),r<n.length-1&&(s(r+1),n[r]?.focus());else if("ArrowUp"===e.key)e.preventDefault(),r>0?(s(r-1),n[r]?.focus()):(s(-1),t.focus());else if("Enter"===e.key){e.preventDefault();const t=i.sizes[r];r>=0&&r<i.sizes.length&&void 0!==t&&(h(o,t,i.defaultSize),i.onClose({restoreFocusTo:i.contentElement}))}else"Escape"===e.key&&(e.preventDefault(),i.onClose({restoreFocusTo:i.contentElement}))})}(i,r,s,e,n)}(t,e,{sizes:this.sizes,defaultSize:this.defaultSize,onClose:n,contentElement:e.getContainer(),locale:this.locale})},isActive:t=>function(t){return i(t,"fontSize")}(t)})}applyDefaultSizeToContainer(t){s(t.getContainer(),"fontSize",`${this.defaultSize}px`)}};export{p as n,f as r,v as t};
|
|
2
|
+
//# sourceMappingURL=FontSizePlugin-DYKvhu9w.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontSizePlugin-DYKvhu9w.mjs","names":[],"sources":["../../src/editor/styles/font-size-select.ts","../../src/plugins/font-size/FontSizeLocale.ts","../../src/plugins/font-size/FontSizeOperations.ts","../../src/plugins/font-size/FontSizePopup.ts","../../src/plugins/font-size/FontSizePlugin.ts"],"sourcesContent":["/** Font size picker toolbar combobox + popup styles. */\nexport const FONT_SIZE_SELECT_CSS = `\n/* Font Size Select — Width overrides for combobox button */\n.notectl-toolbar-btn--fontSize {\n\tmin-width: 60px;\n\tmax-width: 80px;\n}\n\n/* Font Size Picker Popup */\n.notectl-font-size-picker {\n\tmin-width: 140px;\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.notectl-font-size-picker__input-wrapper {\n\tpadding: 8px 8px 4px;\n}\n\n.notectl-font-size-picker__input {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tfont-family: inherit;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-surface-overlay);\n\toutline: none;\n\tbox-sizing: border-box;\n\t-moz-appearance: textfield;\n}\n\n.notectl-font-size-picker__input::-webkit-inner-spin-button,\n.notectl-font-size-picker__input::-webkit-outer-spin-button {\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.notectl-font-size-picker__input:focus {\n\tborder-color: var(--notectl-border-focus);\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-font-size-picker__list {\n\tmax-height: 280px;\n\toverflow-y: auto;\n\tpadding: 4px 0;\n}\n\n.notectl-font-size-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n\toutline: none;\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-font-size-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-font-size-picker__item--focused {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-font-size-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-font-size-picker__label {\n\tflex: 1;\n}\n`;\n","/** Locale interface and default English locale for the FontSizePlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface FontSizeLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly customFontSizeAria: string;\n\treadonly fontSizesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const FONT_SIZE_LOCALE_EN: FontSizeLocale = {\n\tlabel: 'Font Size',\n\ttooltip: 'Font Size',\n\tcustomFontSizeAria: 'Custom font size',\n\tfontSizesAria: 'Font sizes',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<FontSizeLocale> = import.meta.glob<{\n\tdefault: FontSizeLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadFontSizeLocale(lang: string): Promise<FontSizeLocale> {\n\treturn loadLocaleModule(localeModules, lang, FONT_SIZE_LOCALE_EN);\n}\n","/**\n * Pure business logic for font-size state queries and transaction builders.\n * All functions are DOM-free and operate on EditorState / PluginContext.\n *\n * Delegates to the generic AttributedMarkCommands helpers for the\n * collapsed-vs-range branching logic.\n */\n\nimport {\n\tapplyAttributedMark,\n\tgetMarkAttrAtSelection,\n\tisAttributedMarkActive,\n\tremoveAttributedMark,\n} from '../../commands/AttributedMarkCommands.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\n\n// --- State Queries ---\n\n/** Returns the raw fontSize CSS value at the current selection, or null. */\nexport function getActiveSize(state: EditorState): string | null {\n\treturn getMarkAttrAtSelection(state, 'fontSize', (m) => m.attrs.size ?? null);\n}\n\n/** Returns the active font size as a number, falling back to defaultSize. */\nexport function getActiveSizeNumeric(state: EditorState, defaultSize: number): number {\n\tconst raw: string | null = getActiveSize(state);\n\tif (!raw) return defaultSize;\n\tconst parsed: number = Number.parseInt(raw, 10);\n\treturn Number.isNaN(parsed) ? defaultSize : parsed;\n}\n\n/** Returns true when the selection carries a fontSize mark. */\nexport function isFontSizeActive(state: EditorState): boolean {\n\treturn isAttributedMarkActive(state, 'fontSize');\n}\n\n// --- Commands ---\n\n/** Applies a fontSize mark with the given CSS size string to the selection. */\nexport function applyFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst mark = { type: markType('fontSize'), attrs: { size } };\n\tconst tr = applyAttributedMark(state, mark);\n\tif (!tr) return false;\n\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n/** Removes the fontSize mark from the current selection. */\nexport function removeFontSize(context: PluginContext, state: EditorState): boolean {\n\tconst tr = removeAttributedMark(state, markType('fontSize'));\n\tif (!tr) return false;\n\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n/** Steps the font size up or down through the preset list. */\nexport function stepFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n\tdefaultSize: number,\n): boolean {\n\tconst current: number = getActiveSizeNumeric(state, defaultSize);\n\tconst next: number | null = getNextPresetSize(current, direction, sizes);\n\tif (next === null) return false;\n\n\tif (next === defaultSize) {\n\t\treturn removeFontSize(context, state);\n\t}\n\treturn applyFontSize(context, state, `${next}px`);\n}\n\n/**\n * Selects a specific font size: removes the mark when size equals the\n * default, otherwise applies the new size.\n */\nexport function selectSize(context: PluginContext, size: number, defaultSize: number): void {\n\tif (size === defaultSize) {\n\t\tcontext.executeCommand('removeFontSize');\n\t} else {\n\t\tapplyFontSize(context, context.getState(), `${size}px`);\n\t}\n}\n\n// --- Helpers ---\n\n/** Finds the next preset size in the given direction, or null at boundaries. */\nexport function getNextPresetSize(\n\tcurrent: number,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n): number | null {\n\tif (direction === 'up') {\n\t\tfor (const size of sizes) {\n\t\t\tif (size > current) return size;\n\t\t}\n\t\treturn null;\n\t}\n\tfor (let i: number = sizes.length - 1; i >= 0; i--) {\n\t\tconst size: number | undefined = sizes[i];\n\t\tif (size !== undefined && size < current) return size;\n\t}\n\treturn null;\n}\n","/**\n * Renders the font-size picker popup with a custom numeric input\n * and an accessible preset list with keyboard navigation.\n */\n\nimport type { PluginContext } from '../Plugin.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport type { FontSizeLocale } from './FontSizeLocale.js';\nimport { getActiveSizeNumeric, selectSize } from './FontSizeOperations.js';\n\n// --- Constants ---\n\nconst MIN_CUSTOM_SIZE = 1;\nconst MAX_CUSTOM_SIZE = 400;\n\n// --- Config ---\n\nexport interface FontSizePopupConfig {\n\treadonly sizes: readonly number[];\n\treadonly defaultSize: number;\n\treadonly onClose: (options?: PopupCloseOptions) => void;\n\treadonly contentElement: HTMLElement;\n\treadonly locale: FontSizeLocale;\n}\n\n// --- Public Entry Point ---\n\n/** Builds the font-size picker DOM inside the given container. */\nexport function renderFontSizePopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tcontainer.classList.add('notectl-font-size-picker');\n\n\tconst currentSize: number = getActiveSizeNumeric(context.getState(), config.defaultSize);\n\n\tconst input: HTMLInputElement = buildCustomInput(currentSize, config);\n\tappendInputWrapper(container, input);\n\n\tconst { list, items } = buildSizeList(config.sizes, currentSize, context, config);\n\tcontainer.appendChild(list);\n\n\tscrollActiveIntoView(items, config.sizes, currentSize, list);\n\tattachKeyboardNavigation(input, list, items, context, config);\n}\n\n// --- Custom Input ---\n\nfunction buildCustomInput(currentSize: number, config: FontSizePopupConfig): HTMLInputElement {\n\tconst input: HTMLInputElement = document.createElement('input');\n\tinput.type = 'number';\n\tinput.className = 'notectl-font-size-picker__input';\n\tinput.min = String(MIN_CUSTOM_SIZE);\n\tinput.max = String(MAX_CUSTOM_SIZE);\n\tinput.value = String(currentSize);\n\tinput.setAttribute('aria-label', config.locale.customFontSizeAria);\n\treturn input;\n}\n\nfunction appendInputWrapper(container: HTMLElement, input: HTMLInputElement): void {\n\tconst wrapper: HTMLDivElement = document.createElement('div');\n\twrapper.className = 'notectl-font-size-picker__input-wrapper';\n\twrapper.appendChild(input);\n\tcontainer.appendChild(wrapper);\n}\n\n// --- Size List ---\n\ninterface SizeListResult {\n\treadonly list: HTMLDivElement;\n\treadonly items: HTMLButtonElement[];\n}\n\nfunction buildSizeList(\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): SizeListResult {\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-font-size-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', config.locale.fontSizesAria);\n\n\tconst items: HTMLButtonElement[] = [];\n\n\tfor (const size of sizes) {\n\t\tconst isActive: boolean = size === currentSize;\n\t\tconst item: HTMLButtonElement = buildSizeItem(size, isActive);\n\n\t\titem.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tselectSize(context, size, config.defaultSize);\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t});\n\n\t\titems.push(item);\n\t\tlist.appendChild(item);\n\t}\n\n\treturn { list, items };\n}\n\nfunction buildSizeItem(size: number, isActive: boolean): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.id = `notectl-font-size-option-${size}`;\n\titem.className = 'notectl-font-size-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-font-size-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-font-size-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst label: HTMLSpanElement = document.createElement('span');\n\tlabel.className = 'notectl-font-size-picker__label';\n\tlabel.textContent = String(size);\n\titem.appendChild(label);\n\n\treturn item;\n}\n\n// --- Scroll ---\n\nfunction scrollActiveIntoView(\n\titems: HTMLButtonElement[],\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tlist: HTMLDivElement,\n): void {\n\tconst activeIdx: number = sizes.indexOf(currentSize);\n\tif (activeIdx < 0) return;\n\n\tconst activeItem: HTMLButtonElement | undefined = items[activeIdx];\n\tif (!activeItem) return;\n\n\trequestAnimationFrame(() => {\n\t\tactiveItem.scrollIntoView({ block: 'nearest' });\n\t});\n\tlist.setAttribute('aria-activedescendant', activeItem.id);\n}\n\n// --- Keyboard Navigation ---\n\nfunction attachKeyboardNavigation(\n\tinput: HTMLInputElement,\n\tlist: HTMLDivElement,\n\titems: HTMLButtonElement[],\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tlet focusedIndex = -1;\n\n\tconst setFocused = (idx: number): void => {\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length) {\n\t\t\titems[focusedIndex]?.classList.remove('notectl-font-size-picker__item--focused');\n\t\t}\n\t\tfocusedIndex = idx;\n\t\tconst el: HTMLButtonElement | undefined = items[focusedIndex];\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length && el) {\n\t\t\tel.classList.add('notectl-font-size-picker__item--focused');\n\t\t\tel.scrollIntoView({ block: 'nearest' });\n\t\t\tlist.setAttribute('aria-activedescendant', el.id);\n\t\t}\n\t};\n\n\tinput.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\t\t\tconst val: number = Number.parseInt(input.value, 10);\n\t\t\tif (!Number.isNaN(val) && val >= MIN_CUSTOM_SIZE && val <= MAX_CUSTOM_SIZE) {\n\t\t\t\tselectSize(context, val, config.defaultSize);\n\t\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t\t}\n\t\t} else if (e.key === 'ArrowDown') {\n\t\t\te.preventDefault();\n\t\t\tsetFocused(0);\n\t\t\titems[0]?.focus();\n\t\t} else if (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t}\n\t});\n\n\tlist.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'ArrowDown') {\n\t\t\te.preventDefault();\n\t\t\tif (focusedIndex < items.length - 1) {\n\t\t\t\tsetFocused(focusedIndex + 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t}\n\t\t} else if (e.key === 'ArrowUp') {\n\t\t\te.preventDefault();\n\t\t\tif (focusedIndex > 0) {\n\t\t\t\tsetFocused(focusedIndex - 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t} else {\n\t\t\t\tsetFocused(-1);\n\t\t\t\tinput.focus();\n\t\t\t}\n\t\t} else if (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\t\t\tconst selectedSize: number | undefined = config.sizes[focusedIndex];\n\t\t\tif (focusedIndex >= 0 && focusedIndex < config.sizes.length && selectedSize !== undefined) {\n\t\t\t\tselectSize(context, selectedSize, config.defaultSize);\n\t\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t\t}\n\t\t} else if (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tconfig.onClose({ restoreFocusTo: config.contentElement });\n\t\t}\n\t});\n}\n","/**\n * FontSizePlugin: registers a fontSize mark with attrs, a combobox-style\n * toolbar selector with WCAG-accessible popup, and commands for\n * increasing / decreasing font size.\n */\n\nimport { FONT_SIZE_SELECT_CSS } from '../../editor/styles/font-size-select.js';\nimport { escapeHTML } from '../../model/HTMLUtils.js';\nimport type { HTMLExportContext } from '../../model/NodeSpec.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { isValidCSSFontSize } from '../shared/ColorValidation.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport { FONT_SIZE_LOCALE_EN, type FontSizeLocale, loadFontSizeLocale } from './FontSizeLocale.js';\nimport {\n\tgetActiveSizeNumeric,\n\tisFontSizeActive,\n\tremoveFontSize,\n\tstepFontSize,\n} from './FontSizeOperations.js';\nimport { renderFontSizePopup } from './FontSizePopup.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfontSize: { size: string };\n\t}\n}\n\n// --- Constants ---\n\n/** Default preset sizes shown in the font size dropdown. */\nexport const DEFAULT_FONT_SIZES: readonly number[] = [\n\t8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96,\n];\n\nconst DEFAULT_FONT_SIZE = 16;\n\n// --- Configuration ---\n\nexport interface FontSizeConfig {\n\t/**\n\t * Preset sizes shown in the font size dropdown.\n\t * Must contain positive integers. Values are sorted and deduplicated automatically.\n\t * Defaults to {@link DEFAULT_FONT_SIZES} when omitted or empty.\n\t */\n\treadonly sizes?: readonly number[];\n\t/**\n\t * The base font size that text has when no fontSize mark is applied.\n\t * Shown as the initial value in the toolbar combo and used as the\n\t * \"neutral\" size — selecting it removes the mark instead of applying one.\n\t * Defaults to 16.\n\t */\n\treadonly defaultSize?: number;\n\treadonly locale?: FontSizeLocale;\n}\n\n// --- Plugin ---\n\nexport class FontSizePlugin implements Plugin {\n\treadonly id = 'fontSize';\n\treadonly name = 'Font Size';\n\treadonly priority = 21;\n\n\tprivate readonly config: FontSizeConfig;\n\tprivate readonly sizes: readonly number[];\n\tprivate readonly defaultSize: number;\n\tprivate locale!: FontSizeLocale;\n\n\tconstructor(config?: Partial<FontSizeConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.sizes = resolveSizes(config?.sizes);\n\t\tthis.defaultSize = resolveDefaultSize(config?.defaultSize);\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\tFONT_SIZE_LOCALE_EN,\n\t\t\tloadFontSizeLocale,\n\t\t);\n\n\t\tcontext.registerStyleSheet(FONT_SIZE_SELECT_CSS);\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.applyDefaultSizeToContainer(context);\n\t}\n\n\tdestroy(): void {\n\t\t// no-op: nothing to clean up\n\t}\n\n\t// --- Schema ---\n\n\tprivate registerMarkSpec(context: PluginContext): void {\n\t\tcontext.registerMarkSpec({\n\t\t\ttype: 'fontSize',\n\t\t\trank: 4,\n\t\t\tattrs: {\n\t\t\t\tsize: { default: '' },\n\t\t\t},\n\t\t\ttoDOM(mark) {\n\t\t\t\tconst span: HTMLElement = document.createElement('span');\n\t\t\t\tconst size: string = mark.attrs?.size ?? '';\n\t\t\t\tif (size) {\n\t\t\t\t\tsetStyleProperty(span, 'fontSize', size);\n\t\t\t\t}\n\t\t\t\treturn span;\n\t\t\t},\n\t\t\ttoHTMLString: (mark, content, ctx?: HTMLExportContext) => {\n\t\t\t\tconst size: string = String(mark.attrs?.size ?? '');\n\t\t\t\tif (!size || !isValidCSSFontSize(size)) return content;\n\t\t\t\tconst decl: string = `font-size: ${escapeHTML(size)}`;\n\t\t\t\tconst attr: string = ctx?.styleAttr(decl) ?? ` style=\"${decl}\"`;\n\t\t\t\treturn `<span${attr}>${content}</span>`;\n\t\t\t},\n\t\t\ttoHTMLStyle: (mark) => {\n\t\t\t\tconst size: string = String(mark.attrs?.size ?? '');\n\t\t\t\tif (!size || !isValidCSSFontSize(size)) return null;\n\t\t\t\treturn `font-size: ${escapeHTML(size)}`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'span',\n\t\t\t\t\tgetAttrs: (el) => {\n\t\t\t\t\t\tconst size: string = el.style.fontSize;\n\t\t\t\t\t\tif (!size) return false;\n\t\t\t\t\t\treturn { size };\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['span'] },\n\t\t});\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeFontSize', () => {\n\t\t\treturn removeFontSize(context, context.getState());\n\t\t});\n\n\t\tcontext.registerCommand('setFontSize', () => {\n\t\t\treturn false;\n\t\t});\n\n\t\tcontext.registerCommand('increaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t});\n\n\t\tcontext.registerCommand('decreaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t});\n\t}\n\n\t// --- Keymaps ---\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-+': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t\t'Mod-Shift-_': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'fontSize',\n\t\t\tgroup: 'format',\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\n\t\t\tcommand: 'removeFontSize',\n\t\t\tpopupType: 'combobox',\n\t\t\tgetLabel: (state: EditorState): string =>\n\t\t\t\tString(getActiveSizeNumeric(state, this.defaultSize)),\n\t\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\t\trenderFontSizePopup(container, ctx, {\n\t\t\t\t\tsizes: this.sizes,\n\t\t\t\t\tdefaultSize: this.defaultSize,\n\t\t\t\t\tonClose,\n\t\t\t\t\tcontentElement: ctx.getContainer(),\n\t\t\t\t\tlocale: this.locale,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state) => isFontSizeActive(state),\n\t\t});\n\t}\n\n\t/**\n\t * Sets the configured default font size on the editor content container\n\t * so that unformatted text renders at the correct size instead of the\n\t * browser default (16px).\n\t */\n\tprivate applyDefaultSizeToContainer(context: PluginContext): void {\n\t\tconst container: HTMLElement = context.getContainer();\n\t\tsetStyleProperty(container, 'fontSize', `${this.defaultSize}px`);\n\t}\n}\n\n// --- Helpers ---\n\nfunction resolveSizes(sizes: readonly number[] | undefined): readonly number[] {\n\tif (!sizes || sizes.length === 0) return DEFAULT_FONT_SIZES;\n\tconst unique: number[] = [...new Set(sizes)].filter((n) => Number.isInteger(n) && n > 0);\n\tunique.sort((a, b) => a - b);\n\treturn unique.length > 0 ? unique : DEFAULT_FONT_SIZES;\n}\n\nfunction resolveDefaultSize(size: number | undefined): number {\n\tif (size === undefined) return DEFAULT_FONT_SIZE;\n\treturn Number.isInteger(size) && size > 0 ? size : DEFAULT_FONT_SIZE;\n}\n"],"mappings":"gUACA,ICca,EAAsC,CAClD,MAAO,YACP,QAAS,YACT,mBAAoB,mBACpB,cAAe,cAKV,iBAAiD,OAAA,OAAA,CAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,uBAIvD,eAAsB,EAAmB,GACxC,OAAO,EAAiB,EAAe,EAAM,GCH9C,SAAgB,EAAqB,EAAoB,GACxD,MAAM,EANP,SAA8B,GAC7B,OAAO,EAAuB,EAAO,WAAa,GAAM,EAAE,MAAM,MAAQ,MAK7C,CAAc,GACzC,IAAK,EAAK,OAAO,EACjB,MAAM,EAAiB,OAAO,SAAS,EAAK,IAC5C,OAAO,OAAO,MAAM,GAAU,EAAc,EAW7C,SAAgB,EAAc,EAAwB,EAAoB,GAEzE,MAAM,EAAK,EAAoB,EADlB,CAAE,KAAM,EAAS,YAAa,MAAO,CAAE,UAEpD,QAAK,IAEL,EAAQ,SAAS,IACV,GAIR,SAAgB,EAAe,EAAwB,GACtD,MAAM,EAAK,EAAqB,EAAO,EAAS,aAChD,QAAK,IAEL,EAAQ,SAAS,IACV,GAIR,SAAgB,EACf,EACA,EACA,EACA,EACA,GAGA,MAAM,EAwBP,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AY,IACjC,GAAc,cAAV,EAAE,IACL,EAAE,iBACE,EAAe,EAAM,OAAS,IACjC,EAAW,EAAe,GAC1B,EAAM,IAAe,iBAEF,YAAV,EAAE,IACZ,EAAE,iBACE,EAAe,GAClB,EAAW,EAAe,GAC1B,EAAM,IAAe,UAErB,GAAW,GACX,EAAM,iBAEa,UAAV,EAAE,IAAiB,CAC7B,EAAE,iBACF,MAAM,EAAmC,EAAO,MAAM,GAClD,GAAgB,GAAK,EAAe,EAAO,MAAM,aAA2B,IAAjB,IAC9D,EAAW,EAAS,EAAc,EAAO,aACzC,EAAO,QAAQ,CAAE,eAAgB,EAAO,sBAErB,WAAV,EAAE,MACZ,EAAE,iBACF,EAAO,QAAQ,CAAE,eAAgB,EAAO,oBA7K1C,CAAyB,EAAO,EAAM,EAAO,EAAS,GC8InD,CAAoB,EAAW,EAAK,CACnC,MAAO,KAAK,MACZ,YAAa,KAAK,YAClB,UACA,eAAgB,EAAI,eACpB,OAAQ,KAAK,UAGf,SAAW,GFhKd,SAAiC,GAChC,OAAO,EAAuB,EAAO,YE+Jd,CAAiB,KASxC,2BAAA,CAAoC,GAEnC,EAD+B,EAAQ,eACX,WAAY,GAAG,KAAK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as t}from"./Document-_qdGR4vh.mjs";import{a as e,c as r,r as n,t as o}from"./Selection-aeiSsvhe.mjs";import{n as s}from"./NodeResolver-DVPpO5nC.mjs";import{i}from"./NavigationQueries-
|
|
2
|
-
//# sourceMappingURL=GapCursorNavigation-
|
|
1
|
+
import{d as t}from"./Document-_qdGR4vh.mjs";import{a as e,c as r,r as n,t as o}from"./Selection-aeiSsvhe.mjs";import{n as s}from"./NodeResolver-DVPpO5nC.mjs";import{i}from"./NavigationQueries-CgYPG6oY.mjs";import{t as l}from"./Platform-D9TRT4Mn.mjs";function u(t,e,r){return t.transaction("input").setSelection(o(e,r)).setStoredMarks(null,t.storedMarks).build()}function c(t,e){const r=s(t.doc,e)??[];return t.transaction("input").setSelection(n(e,r)).setStoredMarks(null,t.storedMarks).build()}function f(t,r,n,o,s){return t.transaction("input").setSelection(e({blockId:r,offset:n},{blockId:o,offset:s})).setStoredMarks(null,t.storedMarks).build()}function a(e,n,o){const s=e.selection;if(!r(s))return null;const f=e.getBlockOrder(),a=f.indexOf(s.blockId);if(a<0)return null;const d=function(t,e,r){if(!r)return t;if("left"!==t&&"right"!==t)return t;const n=r.querySelector(`[data-block-id="${e}"]`);return n instanceof HTMLElement?"rtl"!==l(n)?t:"left"===t?"right":"left":t}(n,s.blockId,o);if("before"===s.side&&("right"===d||"down"===d)||"after"===s.side&&("left"===d||"up"===d))return c(e,s.blockId);const m="before"===s.side?a-1:a+1;if(m<0||m>=f.length)return null;const k=f[m];if(!k)return null;if(i(e,k))return c(e,k);const b=e.getBlock(k);return b?u(e,k,"left"===d||"up"===d?t(b):0):null}export{c as i,f as n,u as r,a as t};
|
|
2
|
+
//# sourceMappingURL=GapCursorNavigation-BaXDnjFf.mjs.map
|
package/dist/chunks/{GapCursorNavigation-PhJeqELx.mjs.map → GapCursorNavigation-BaXDnjFf.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GapCursorNavigation-
|
|
1
|
+
{"version":3,"file":"GapCursorNavigation-BaXDnjFf.mjs","names":[],"sources":["../../src/state/SelectionTransactions.ts","../../src/view/GapCursorNavigation.ts"],"sourcesContent":["/**\n * Shared transaction builders for cursor and selection movement.\n *\n * These helpers encapsulate the common pattern of building a transaction\n * that sets a new selection and clears storedMarks.\n */\n\nimport { findNodePath } from '../model/NodeResolver.js';\nimport {\n\tcreateCollapsedSelection,\n\tcreateNodeSelection,\n\tcreateSelection,\n} from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { EditorState } from './EditorState.js';\nimport type { Transaction } from './Transaction.js';\n\n/** Builds a collapsed-cursor transaction that clears storedMarks. */\nexport function moveTx(state: EditorState, blockId: BlockId, offset: number): Transaction {\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(createCollapsedSelection(blockId, offset))\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n\n/** Builds a NodeSelection transaction that clears storedMarks. */\nexport function nodeSelTx(state: EditorState, targetId: BlockId): Transaction {\n\tconst path: BlockId[] = (findNodePath(state.doc, targetId) ?? []) as BlockId[];\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(createNodeSelection(targetId, path))\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n\n/** Builds a range-selection transaction that clears storedMarks. */\nexport function extendTx(\n\tstate: EditorState,\n\tanchorBlockId: BlockId,\n\tanchorOffset: number,\n\theadBlockId: BlockId,\n\theadOffset: number,\n): Transaction {\n\treturn state\n\t\t.transaction('input')\n\t\t.setSelection(\n\t\t\tcreateSelection(\n\t\t\t\t{ blockId: anchorBlockId, offset: anchorOffset },\n\t\t\t\t{ blockId: headBlockId, offset: headOffset },\n\t\t\t),\n\t\t)\n\t\t.setStoredMarks(null, state.storedMarks)\n\t\t.build();\n}\n","import { getBlockLength } from '../model/Document.js';\nimport { isGapCursor } from '../model/Selection.js';\nimport type { BlockId } from '../model/TypeBrands.js';\nimport { getTextDirection } from '../platform/Platform.js';\nimport type { EditorState } from '../state/EditorState.js';\nimport { isVoidBlock } from '../state/NavigationQueries.js';\nimport { moveTx, nodeSelTx } from '../state/SelectionTransactions.js';\nimport type { Transaction } from '../state/Transaction.js';\n\nexport type GapCursorDirection = 'left' | 'right' | 'up' | 'down';\n\n/**\n * Navigates from a GapCursor position.\n *\n * - Arrow toward the adjacent void block -> NodeSelection of that block.\n * - Arrow away from the void block -> find next block: void -> NodeSelection,\n * text -> TextSelection, document boundary -> no-op.\n */\nexport function navigateFromGapCursor(\n\tstate: EditorState,\n\tdirection: GapCursorDirection,\n\tcontainer?: HTMLElement,\n): Transaction | null {\n\tconst sel = state.selection;\n\tif (!isGapCursor(sel)) return null;\n\n\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\tconst blockIdx: number = blockOrder.indexOf(sel.blockId);\n\tif (blockIdx < 0) return null;\n\n\t// Resolve effective horizontal direction for RTL blocks\n\tconst effectiveDir: GapCursorDirection = resolveEffectiveDirection(\n\t\tdirection,\n\t\tsel.blockId,\n\t\tcontainer,\n\t);\n\n\tconst towardVoid: boolean =\n\t\t(sel.side === 'before' && (effectiveDir === 'right' || effectiveDir === 'down')) ||\n\t\t(sel.side === 'after' && (effectiveDir === 'left' || effectiveDir === 'up'));\n\n\tif (towardVoid) return nodeSelTx(state, sel.blockId);\n\n\t// Moving away from the void block - find the neighbor in the other direction\n\tconst awayIdx: number = sel.side === 'before' ? blockIdx - 1 : blockIdx + 1;\n\tif (awayIdx < 0 || awayIdx >= blockOrder.length) return null;\n\n\tconst targetId: BlockId | undefined = blockOrder[awayIdx];\n\tif (!targetId) return null;\n\n\tif (isVoidBlock(state, targetId)) return nodeSelTx(state, targetId);\n\n\t// Text block: place cursor at start or end\n\tconst targetBlock = state.getBlock(targetId);\n\tif (!targetBlock) return null;\n\n\tconst targetOffset: number =\n\t\teffectiveDir === 'left' || effectiveDir === 'up' ? getBlockLength(targetBlock) : 0;\n\treturn moveTx(state, targetId, targetOffset);\n}\n\n/**\n * Resolves the effective navigation direction by flipping left/right\n * when the block is RTL. Vertical directions are unaffected.\n */\nfunction resolveEffectiveDirection(\n\tdirection: GapCursorDirection,\n\tblockId: BlockId,\n\tcontainer?: HTMLElement,\n): GapCursorDirection {\n\tif (!container) return direction;\n\tif (direction !== 'left' && direction !== 'right') return direction;\n\n\tconst blockEl: Element | null = container.querySelector(`[data-block-id=\"${blockId}\"]`);\n\tif (!(blockEl instanceof HTMLElement)) return direction;\n\n\tconst isRtl: boolean = getTextDirection(blockEl) === 'rtl';\n\tif (!isRtl) return direction;\n\n\treturn direction === 'left' ? 'right' : 'left';\n}\n"],"mappings":"0PAkBA,SAAgB,EAAO,EAAoB,EAAkB,GAC5D,OAAO,EACL,YAAY,SACZ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EAAe,GAAe,GAHzD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as t}from"./Selection-aeiSsvhe.mjs";import{t as e}from"./GapCursorNavigation-BaXDnjFf.mjs";import{i as n,o}from"./PluginHelpers-D1QF-YaF.mjs";var r={gapCursorActive:"Gap cursor active. Type to insert new paragraph."},s=/* @__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-DW0Inc7r.mjs"),"./locales/de.ts":()=>import("./de-BzjqF_j0.mjs"),"./locales/es.ts":()=>import("./es-DEo4yDI6.mjs"),"./locales/fr.ts":()=>import("./fr-hUF51sR5.mjs"),"./locales/hi.ts":()=>import("./hi-Bj-wENIe.mjs"),"./locales/pt.ts":()=>import("./pt-X4oj0zCg.mjs"),"./locales/ru.ts":()=>import("./ru-BhXqR_wI.mjs"),"./locales/zh.ts":()=>import("./zh-CZCIluI_.mjs")});async function i(t){return o(s,t,r)}var a=class{id="gap-cursor";name="Gap Cursor";priority=5;context=null;activeCursorBlockId=null;activeCursorSide=null;locale=r;async init(o){this.locale=await n(o,void 0,r,i),this.context=o,o.registerStyleSheet("\n.notectl-gap-cursor--before,\n.notectl-gap-cursor--after {\n\tposition: relative;\n}\n.notectl-gap-cursor--before::before {\n\tcontent: '';\n\tdisplay: block;\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 0;\n\twidth: 100%;\n\theight: 1px;\n\tbackground: currentColor;\n\ttransform: translateY(-50%);\n\tpointer-events: none;\n\tz-index: 1;\n\tanimation: notectl-gap-blink 1.1s step-end infinite;\n}\n.notectl-gap-cursor--after::after {\n\tcontent: '';\n\tdisplay: block;\n\tposition: absolute;\n\tbottom: 0;\n\tinset-inline-start: 0;\n\twidth: 100%;\n\theight: 1px;\n\tbackground: currentColor;\n\ttransform: translateY(50%);\n\tpointer-events: none;\n\tz-index: 1;\n\tanimation: notectl-gap-blink 1.1s step-end infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n\t.notectl-gap-cursor--before::before,\n\t.notectl-gap-cursor--after::after {\n\t\tanimation: none;\n\t}\n}\n@keyframes notectl-gap-blink {\n\t50% { opacity: 0; }\n}\n");const s={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down"},a={};for(const[n,r]of Object.entries(s))a[n]=()=>{const n=o.getState();if(!t(n.selection))return!1;const s=e(n,r,o.getContainer());return!!s&&(o.dispatch(s),!0)};o.registerKeymap(a,{priority:"navigation"})}onReady(){this.context&&this.syncCursorClass(this.context.getState())}onStateChange(e,n,o){this.context&&(this.syncCursorClass(n),!t(e.selection)&&t(n.selection)&&this.context.announce(this.locale.gapCursorActive))}destroy(){this.clearCursorClass(),this.context=null}syncCursorClass(e){if(this.clearCursorClass(),!t(e.selection)||!this.context)return;const n="before"===e.selection.side?"notectl-gap-cursor--before":"notectl-gap-cursor--after",o=this.context.getContainer().querySelector(`[data-block-id="${e.selection.blockId}"]`);o instanceof HTMLElement&&(o.classList.add(n),this.activeCursorBlockId=e.selection.blockId,this.activeCursorSide=e.selection.side)}clearCursorClass(){if(!this.context||!this.activeCursorBlockId||!this.activeCursorSide)return;const t=this.context.getContainer().querySelector(`[data-block-id="${this.activeCursorBlockId}"]`);t instanceof HTMLElement&&t.classList.remove("notectl-gap-cursor--before","notectl-gap-cursor--after"),this.activeCursorBlockId=null,this.activeCursorSide=null}};export{a as t};
|
|
2
|
+
//# sourceMappingURL=GapCursorPlugin-uxw7W7vj.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GapCursorPlugin-uxw7W7vj.mjs","names":[],"sources":["../../src/plugins/gap-cursor/GapCursorLocale.ts","../../src/plugins/gap-cursor/GapCursorPlugin.ts"],"sourcesContent":["/** Locale interface and default English locale for the GapCursorPlugin. */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface GapCursorLocale {\n\treadonly gapCursorActive: string;\n}\n\n// --- Default English Locale ---\n\nexport const GAP_CURSOR_LOCALE_EN: GapCursorLocale = {\n\tgapCursorActive: 'Gap cursor active. Type to insert new paragraph.',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<GapCursorLocale> = import.meta.glob<{\n\tdefault: GapCursorLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadGapCursorLocale(lang: string): Promise<GapCursorLocale> {\n\treturn loadLocaleModule(localeModules, lang, GAP_CURSOR_LOCALE_EN);\n}\n","/**\n * GapCursorPlugin: renders a virtual cursor at boundaries of void blocks\n * where no native browser caret can exist (e.g. between two HRs or at\n * the document edge adjacent to a void block).\n */\n\nimport { isGapCursor } 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 { navigateFromGapCursor } from '../../view/GapCursorNavigation.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport {\n\tGAP_CURSOR_LOCALE_EN,\n\ttype GapCursorLocale,\n\tloadGapCursorLocale,\n} from './GapCursorLocale.js';\n\nconst GAP_CURSOR_CSS = `\n.notectl-gap-cursor--before,\n.notectl-gap-cursor--after {\n\tposition: relative;\n}\n.notectl-gap-cursor--before::before {\n\tcontent: '';\n\tdisplay: block;\n\tposition: absolute;\n\ttop: 0;\n\tinset-inline-start: 0;\n\twidth: 100%;\n\theight: 1px;\n\tbackground: currentColor;\n\ttransform: translateY(-50%);\n\tpointer-events: none;\n\tz-index: 1;\n\tanimation: notectl-gap-blink 1.1s step-end infinite;\n}\n.notectl-gap-cursor--after::after {\n\tcontent: '';\n\tdisplay: block;\n\tposition: absolute;\n\tbottom: 0;\n\tinset-inline-start: 0;\n\twidth: 100%;\n\theight: 1px;\n\tbackground: currentColor;\n\ttransform: translateY(50%);\n\tpointer-events: none;\n\tz-index: 1;\n\tanimation: notectl-gap-blink 1.1s step-end infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n\t.notectl-gap-cursor--before::before,\n\t.notectl-gap-cursor--after::after {\n\t\tanimation: none;\n\t}\n}\n@keyframes notectl-gap-blink {\n\t50% { opacity: 0; }\n}\n`;\n\nexport class GapCursorPlugin implements Plugin {\n\treadonly id = 'gap-cursor';\n\treadonly name = 'Gap Cursor';\n\treadonly priority = 5;\n\n\tprivate context: PluginContext | null = null;\n\tprivate activeCursorBlockId: BlockId | null = null;\n\tprivate activeCursorSide: 'before' | 'after' | null = null;\n\tprivate locale: GapCursorLocale = GAP_CURSOR_LOCALE_EN;\n\n\tasync init(context: PluginContext): Promise<void> {\n\t\tthis.locale = await resolveLocale(\n\t\t\tcontext,\n\t\t\tundefined,\n\t\t\tGAP_CURSOR_LOCALE_EN,\n\t\t\tloadGapCursorLocale,\n\t\t);\n\n\t\tthis.context = context;\n\n\t\tcontext.registerStyleSheet(GAP_CURSOR_CSS);\n\n\t\tconst directions: Record<string, 'left' | 'right' | 'up' | 'down'> = {\n\t\t\tArrowLeft: 'left',\n\t\t\tArrowRight: 'right',\n\t\t\tArrowUp: 'up',\n\t\t\tArrowDown: 'down',\n\t\t};\n\n\t\tconst keymap: Record<string, () => boolean> = {};\n\t\tfor (const [key, dir] of Object.entries(directions)) {\n\t\t\tkeymap[key] = (): boolean => {\n\t\t\t\tconst state: EditorState = context.getState();\n\t\t\t\tif (!isGapCursor(state.selection)) return false;\n\n\t\t\t\tconst container: HTMLElement = context.getContainer();\n\t\t\t\tconst tr: Transaction | null = navigateFromGapCursor(state, dir, container);\n\t\t\t\tif (tr) {\n\t\t\t\t\tcontext.dispatch(tr);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t};\n\t\t}\n\n\t\tcontext.registerKeymap(keymap, { priority: 'navigation' });\n\t}\n\n\tonReady(): void {\n\t\tif (!this.context) return;\n\t\tthis.syncCursorClass(this.context.getState());\n\t}\n\n\tonStateChange(oldState: EditorState, newState: EditorState, _tr: Transaction): void {\n\t\tif (!this.context) return;\n\n\t\tthis.syncCursorClass(newState);\n\n\t\tif (!isGapCursor(oldState.selection) && isGapCursor(newState.selection)) {\n\t\t\tthis.context.announce(this.locale.gapCursorActive);\n\t\t}\n\t}\n\n\tdestroy(): void {\n\t\tthis.clearCursorClass();\n\t\tthis.context = null;\n\t}\n\n\tprivate syncCursorClass(state: EditorState): void {\n\t\tthis.clearCursorClass();\n\t\tif (!isGapCursor(state.selection) || !this.context) return;\n\n\t\tconst className: string =\n\t\t\tstate.selection.side === 'before'\n\t\t\t\t? 'notectl-gap-cursor--before'\n\t\t\t\t: 'notectl-gap-cursor--after';\n\n\t\tconst blockEl: Element | null = this.context\n\t\t\t.getContainer()\n\t\t\t.querySelector(`[data-block-id=\"${state.selection.blockId}\"]`);\n\t\tif (!(blockEl instanceof HTMLElement)) return;\n\n\t\tblockEl.classList.add(className);\n\t\tthis.activeCursorBlockId = state.selection.blockId;\n\t\tthis.activeCursorSide = state.selection.side;\n\t}\n\n\tprivate clearCursorClass(): void {\n\t\tif (!this.context || !this.activeCursorBlockId || !this.activeCursorSide) return;\n\n\t\tconst blockEl: Element | null = this.context\n\t\t\t.getContainer()\n\t\t\t.querySelector(`[data-block-id=\"${this.activeCursorBlockId}\"]`);\n\t\tif (blockEl instanceof HTMLElement) {\n\t\t\tblockEl.classList.remove('notectl-gap-cursor--before', 'notectl-gap-cursor--after');\n\t\t}\n\n\t\tthis.activeCursorBlockId = null;\n\t\tthis.activeCursorSide = null;\n\t}\n}\n"],"mappings":"uJAYA,IAAa,EAAwC,CACpD,gBAAiB,oDAKZ,iBAAkD,OAAA,OAAA,CAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,qBAAA,kBAAA,IAAA,OAAA,uBAIxD,eAAsB,EAAoB,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,yBACpC,aAAmB,aACtB,EAAQ,UAAU,OAAO,6BAA8B,6BAGxD,KAAK,oBAAsB,KAC3B,KAAK,iBAAmB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./Commands-
|
|
2
|
-
//# sourceMappingURL=HardBreakPlugin-
|
|
1
|
+
import{r as e}from"./Commands-BuYF23lf.mjs";var r=class{id="hard-break";name="Hard Break";priority=10;init(e){this.registerInlineNodeSpec(e),this.registerCommands(e),this.registerKeymap(e)}registerInlineNodeSpec(e){e.registerInlineNodeSpec({type:"hard_break",toDOM:()=>document.createElement("br"),toHTMLString:()=>"<br>",parseHTML:[{tag:"br"}],sanitize:{tags:["br"]}})}registerCommands(r){r.registerCommand("insertHardBreak",()=>{const t=e(r.getState());return!!t&&(r.dispatch(t),!0)})}registerKeymap(r){r.registerKeymap({"Shift-Enter":()=>{const t=e(r.getState());return!!t&&(r.dispatch(t),!0)}})}};export{r as t};
|
|
2
|
+
//# sourceMappingURL=HardBreakPlugin-BpXipf8h.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HardBreakPlugin-
|
|
1
|
+
{"version":3,"file":"HardBreakPlugin-BpXipf8h.mjs","names":[],"sources":["../../src/plugins/hard-break/HardBreakPlugin.ts"],"sourcesContent":["/**\n * HardBreakPlugin: registers a hard line break (Shift+Enter → `<br>`)\n * as an InlineNode, with command and keymap bindings.\n */\n\nimport { insertHardBreakCommand } from '../../commands/Commands.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface InlineNodeAttrRegistry {\n\t\thard_break: Record<string, never>;\n\t}\n}\n\n// --- Plugin ---\n\nexport class HardBreakPlugin implements Plugin {\n\treadonly id = 'hard-break';\n\treadonly name = 'Hard Break';\n\treadonly priority = 10;\n\n\tinit(context: PluginContext): void {\n\t\tthis.registerInlineNodeSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymap(context);\n\t}\n\n\tprivate registerInlineNodeSpec(context: PluginContext): void {\n\t\tcontext.registerInlineNodeSpec({\n\t\t\ttype: 'hard_break',\n\t\t\ttoDOM() {\n\t\t\t\treturn document.createElement('br');\n\t\t\t},\n\t\t\ttoHTMLString() {\n\t\t\t\treturn '<br>';\n\t\t\t},\n\t\t\tparseHTML: [{ tag: 'br' }],\n\t\t\tsanitize: { tags: ['br'] },\n\t\t});\n\t}\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('insertHardBreak', () => {\n\t\t\tconst state = context.getState();\n\t\t\tconst tr = insertHardBreakCommand(state);\n\t\t\tif (!tr) return false;\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t});\n\t}\n\n\tprivate registerKeymap(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Shift-Enter': () => {\n\t\t\t\tconst state = context.getState();\n\t\t\t\tconst tr = insertHardBreakCommand(state);\n\t\t\t\tif (!tr) return false;\n\t\t\t\tcontext.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t});\n\t}\n}\n"],"mappings":"4CAkBA,IAAa,EAAb,MACC,GAAc,aACd,KAAgB,aAChB,SAAoB,GAEpB,IAAA,CAAK,GACJ,KAAK,uBAAuB,GAC5B,KAAK,iBAAiB,GACtB,KAAK,eAAe,GAGrB,sBAAA,CAA+B,GAC9B,EAAQ,uBAAuB,CAC9B,KAAM,aACN,MAAA,IACQ,SAAS,cAAc,MAE/B,aAAA,IACQ,OAER,UAAW,CAAC,CAAE,IAAK,OACnB,SAAU,CAAE,KAAM,CAAC,SAIrB,gBAAA,CAAyB,GACxB,EAAQ,gBAAgB,kBAAA,KAEvB,MAAM,EAAK,EADG,EAAQ,YAEtB,QAAK,IACL,EAAQ,SAAS,IACV,KAIT,cAAA,CAAuB,GACtB,EAAQ,eAAe,CACtB,cAAA,KAEC,MAAM,EAAK,EADG,EAAQ,YAEtB,QAAK,IACL,EAAQ,SAAS,IACV"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{S as t,c as e,d as n,g as o,m as i}from"./Document-_qdGR4vh.mjs";import{o as r,t as a,u as s}from"./Selection-aeiSsvhe.mjs";import{a as c}from"./TypeBrands-BZDKMjR-.mjs";import{n as l}from"./DomUtils-RKbAVBQz.mjs";import{o as g}from"./StyleRuntime-D3d1XFFe.mjs";import{i as p,o as d}from"./PluginHelpers-D1QF-YaF.mjs";function h(t,e,n,o){const i=document.createElement("button");i.type="button",i.className="notectl-heading-picker__item",i.setAttribute("role","option"),i.setAttribute("aria-selected",String(e)),e&&i.classList.add("notectl-heading-picker__item--active");const r=document.createElement("span");r.className="notectl-heading-picker__check",r.textContent=e?"✓":"",i.appendChild(r);const a=document.createElement("span");return a.className="notectl-heading-picker__label",a.textContent=t,o&&g(a,{fontSize:o.fontSize,fontWeight:o.fontWeight}),i.appendChild(a),i.addEventListener("mousedown",n),i}function u(t,e){return t[`heading${e}`]}function m(t,e){const n=t.getState();if(!s(n.selection))return!1;const o=n.getBlock(n.selection.anchor.blockId);return!!o&&(o.type===e?k(t,c("paragraph")):k(t,c(e)))}function f(t,e){const n=t.getState(),o=n.selection;if(!s(o))return!1;const i=n.getBlock(o.anchor.blockId);return!!i&&("heading"===i.type&&i.attrs?.level===e?k(t,c("paragraph")):k(t,c("heading"),{level:e}))}function k(e,i,r){const a=e.getState(),c=a.selection;if(!s(c))return!1;const l=a.getBlock(c.anchor.blockId);if(!l)return!1;const g=a.transaction("command"),p=e.getSchemaRegistry().getNodeSpec(i);p?.excludeMarks&&p.excludeMarks.length>0&&(function(e,i,r){if(0===n(i))return;const a=new Set(r),s=o(i);let c=0;for(const n of s)if(t(n)){if(n.text.length>0)for(const t of n.marks)a.has(t.type)&&e.removeMark(i.id,c,c+n.text.length,t);c+=n.text.length}else c+=1}(g,l,p.excludeMarks),function(t,e,n){if(!e.storedMarks)return;const o=new Set(n),i=e.storedMarks.filter(t=>!o.has(t.type));i.length!==e.storedMarks.length&&t.setStoredMarks(i.length>0?i:null,e.storedMarks)}(g,a,p.excludeMarks));const d=g.setBlockType(c.anchor.blockId,i,r).setSelection(c).build();return e.dispatch(d),!0}var b=new Set(["heading","title","subtitle"]);var y={paragraph:"Paragraph",title:"Title",subtitle:"Subtitle",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",blockTypeLabel:"Block Type",blockTypesAria:"Block types"},v=/* @__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-CL-NsFoh.mjs"),"./locales/de.ts":()=>import("./de-oeen0lTL.mjs"),"./locales/es.ts":()=>import("./es-BtTQw2t5.mjs"),"./locales/fr.ts":()=>import("./fr-BR61Uevp.mjs"),"./locales/hi.ts":()=>import("./hi-DTUY7wlZ.mjs"),"./locales/pt.ts":()=>import("./pt-FnLj_fwL.mjs"),"./locales/ru.ts":()=>import("./ru-B2dlVf3F.mjs"),"./locales/zh.ts":()=>import("./zh-BkwaMj9a.mjs")});async function x(t){return d(v,t,y)}var S={levels:[1,2,3,4,5,6]},T={1:"h1",2:"h2",3:"h3",4:"h4",5:"h5",6:"h6"},B=class{id="heading";name="Heading";priority=30;config;locale;constructor(t){this.config={...S,...t}}async init(t){this.locale=await p(t,this.config.locale,y,x),t.registerStyleSheet("\n/* Heading Select — Width overrides for combobox button */\n.notectl-toolbar-btn--heading {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Heading Picker Popup */\n.notectl-heading-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-heading-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-heading-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-heading-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-heading-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__label {\n\tflex: 1;\n}\n"),this.registerNodeSpecs(t),function(t,e){t.registerCommand("setTitle",()=>m(t,"title")),t.registerCommand("setSubtitle",()=>m(t,"subtitle"));for(const n of e.levels)t.registerCommand(`setHeading${n}`,()=>f(t,n));t.registerCommand("toggleHeading",()=>f(t,1)),t.registerCommand("setParagraph",()=>k(t,c("paragraph")))}(t,this.config),function(t,o){const l={Enter:()=>function(t){return function(t,e){const n=t.getState();if(!s(n.selection))return!1;const o=n.selection;if(!r(o))return!1;const i=n.getBlock(o.anchor.blockId);return!(!i||!b.has(i.type))&&e({state:n,block:i,blockId:o.anchor.blockId,offset:o.anchor.offset})}(t,o=>{if(""===i(o.block)){const e=o.state.transaction("input").setBlockType(o.blockId,c("paragraph")).setSelection(o.state.selection).build();return t.dispatch(e),!0}const r=n(o.block);if(o.offset>=r){const n=e(),i=o.state.transaction("input").splitBlock(o.blockId,o.offset,n).setBlockType(n,c("paragraph")).setSelection(a(n,0)).build();return t.dispatch(i),!0}return!1})}(t)};for(const e of o.levels)e<=6&&(l[`Mod-Shift-${e}`]=()=>t.executeCommand(`setHeading${e}`));t.registerKeymap(l)}(t,this.config),function(t,e){for(const n of e.levels){const e="#".repeat(n),o=new RegExp(`^${e} $`);t.registerInputRule({pattern:o,handler(t,e,o,i){const l=t.selection;if(!s(l))return null;if(!r(l))return null;const g=t.getBlock(l.anchor.blockId);return g&&"paragraph"===g.type?t.transaction("input").deleteTextAt(l.anchor.blockId,o,o+n+1).setBlockType(l.anchor.blockId,c("heading"),{level:n}).setSelection(a(l.anchor.blockId,0)).build():null}})}}(t,this.config),function(t,e,n){t.registerBlockTypePickerEntry({id:"paragraph",label:n.paragraph,command:"setParagraph",priority:10,isActive:t=>!!s(t.selection)&&"paragraph"===t.getBlock(t.selection.anchor.blockId)?.type}),t.registerBlockTypePickerEntry({id:"title",label:n.title,command:"setTitle",priority:20,style:{fontSize:"1.6em",fontWeight:"700"},isActive:t=>!!s(t.selection)&&"title"===t.getBlock(t.selection.anchor.blockId)?.type}),t.registerBlockTypePickerEntry({id:"subtitle",label:n.subtitle,command:"setSubtitle",priority:30,style:{fontSize:"1.3em",fontWeight:"500"},isActive:t=>!!s(t.selection)&&"subtitle"===t.getBlock(t.selection.anchor.blockId)?.type});for(const o of e.levels)t.registerBlockTypePickerEntry({id:`heading-${o}`,label:u(n,o),command:`setHeading${o}`,priority:100+o,style:{fontSize:1.4-.1*o+"em",fontWeight:"600"},isActive:t=>{if(!s(t.selection))return!1;const e=t.getBlock(t.selection.anchor.blockId);return"heading"===e?.type&&e.attrs?.level===o}})}(t,this.config,this.locale),function(t,e){t.registerToolbarItem({id:"heading",group:"block",label:e.blockTypeLabel,tooltip:e.blockTypeLabel,command:"setParagraph",popupType:"combobox",getLabel:n=>function(t,e,n){if(!s(t.selection))return n.paragraph;const o=e.getBlockTypePickerRegistry().getBlockTypePickerEntries();for(const i of o)if(i.isActive(t))return i.label;return n.paragraph}(n,t,e),renderPopup:(t,n,o)=>{!function(t,e,n,o){t.classList.add("notectl-heading-picker");const i=e.getState();if(!s(i.selection))return;const r=e.getContainer(),a=document.createElement("div");a.className="notectl-heading-picker__list",a.setAttribute("role","listbox"),a.setAttribute("aria-label",n.blockTypesAria);const c=e.getBlockTypePickerRegistry().getBlockTypePickerEntries();for(const s of c){const t=s.isActive(i);a.appendChild(h(s.label,t,t=>{t.preventDefault(),t.stopPropagation(),e.executeCommand(s.command),o({restoreFocusTo:r})},s.style))}t.appendChild(a)}(t,n,e,o)},isActive:e=>t.getBlockTypePickerRegistry().getBlockTypePickerEntries().some(t=>"paragraph"!==t.id&&t.isActive(e))})}(t,this.locale)}registerNodeSpecs(t){t.registerNodeSpec({type:"title",group:"block",content:{allow:["text"]},excludeMarks:["fontSize"],toDOM(t){const e=l("h1",t.id);return e.classList.add("notectl-title"),e},toHTML:(t,e)=>`<h1 class="notectl-title">${e||"<br>"}</h1>`,parseHTML:[{tag:"h1",priority:60,getAttrs:t=>!!t.classList.contains("notectl-title")&&{}}],sanitize:{tags:["h1"],attrs:["class"]}}),t.registerNodeSpec({type:"subtitle",group:"block",content:{allow:["text"]},excludeMarks:["fontSize"],toDOM(t){const e=l("h2",t.id);return e.classList.add("notectl-subtitle"),e},toHTML:(t,e)=>`<h2 class="notectl-subtitle">${e||"<br>"}</h2>`,parseHTML:[{tag:"h2",priority:60,getAttrs:t=>!!t.classList.contains("notectl-subtitle")&&{}}],sanitize:{tags:["h2"],attrs:["class"]}}),t.registerNodeSpec({type:"heading",group:"block",content:{allow:["text"]},excludeMarks:["fontSize"],attrs:{level:{default:1}},toDOM:t=>l(T[t.attrs?.level??1]??"h1",t.id),toHTML(t,e){const n=T[t.attrs?.level??1]??"h1";return`<${n}>${e||"<br>"}</${n}>`},parseHTML:[{tag:"h1",getAttrs:()=>({level:1})},{tag:"h2",getAttrs:()=>({level:2})},{tag:"h3",getAttrs:()=>({level:3})},{tag:"h4",getAttrs:()=>({level:4})},{tag:"h5",getAttrs:()=>({level:5})},{tag:"h6",getAttrs:()=>({level:6})}],sanitize:{tags:["h1","h2","h3","h4","h5","h6"]}})}};export{y as n,x as r,B as t};
|
|
2
|
+
//# sourceMappingURL=HeadingPlugin-CUN746aD.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadingPlugin-1BVn57NF.mjs","names":[],"sources":["../../src/editor/styles/heading-select.ts","../../src/plugins/heading/HeadingBlockTypePicker.ts","../../src/plugins/heading/HeadingCommands.ts","../../src/plugins/heading/HeadingInputRules.ts","../../src/plugins/heading/HeadingKeyboardHandlers.ts","../../src/plugins/heading/HeadingLocale.ts","../../src/plugins/heading/HeadingPlugin.ts"],"sourcesContent":["/** Heading picker toolbar combobox + popup styles. */\nexport const HEADING_SELECT_CSS = `\n/* Heading Select — Width overrides for combobox button */\n.notectl-toolbar-btn--heading {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Heading Picker Popup */\n.notectl-heading-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-heading-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-heading-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-heading-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-heading-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__label {\n\tflex: 1;\n}\n`;\n","/**\n * Block type picker entries and toolbar dropdown for heading block types.\n * Registers picker entries for paragraph, title, subtitle, and all heading levels,\n * plus a combobox-style toolbar item with a custom popup.\n */\n\nimport { isTextSelection } from '../../model/Selection.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperties } from '../../style/StyleRuntime.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport type { PickerEntryStyle } from './BlockTypePickerEntry.js';\nimport type { HeadingLocale } from './HeadingLocale.js';\nimport type { HeadingConfig } from './HeadingPlugin.js';\nimport type { HeadingLevel } from './HeadingPlugin.js';\n\n// --- Picker Entry Registration ---\n\n/** Registers block type picker entries for paragraph, title, subtitle, and heading levels. */\nexport function registerHeadingPickerEntries(\n\tcontext: PluginContext,\n\tconfig: HeadingConfig,\n\tlocale: HeadingLocale,\n): void {\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'paragraph',\n\t\tlabel: locale.paragraph,\n\t\tcommand: 'setParagraph',\n\t\tpriority: 10,\n\t\tisActive: (state) => {\n\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'paragraph';\n\t\t},\n\t});\n\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'title',\n\t\tlabel: locale.title,\n\t\tcommand: 'setTitle',\n\t\tpriority: 20,\n\t\tstyle: { fontSize: '1.6em', fontWeight: '700' },\n\t\tisActive: (state) => {\n\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'title';\n\t\t},\n\t});\n\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'subtitle',\n\t\tlabel: locale.subtitle,\n\t\tcommand: 'setSubtitle',\n\t\tpriority: 30,\n\t\tstyle: { fontSize: '1.3em', fontWeight: '500' },\n\t\tisActive: (state) => {\n\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'subtitle';\n\t\t},\n\t});\n\n\tfor (const level of config.levels) {\n\t\tcontext.registerBlockTypePickerEntry({\n\t\t\tid: `heading-${level}`,\n\t\t\tlabel: getHeadingLabel(locale, level),\n\t\t\tcommand: `setHeading${level}`,\n\t\t\tpriority: 100 + level,\n\t\t\tstyle: { fontSize: `${1.4 - level * 0.1}em`, fontWeight: '600' },\n\t\t\tisActive: (state) => {\n\t\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\t\treturn block?.type === 'heading' && block.attrs?.level === level;\n\t\t\t},\n\t\t});\n\t}\n}\n\n// --- Toolbar Item ---\n\n/** Registers the heading toolbar dropdown with a combobox picker popup. */\nexport function registerHeadingToolbarItem(context: PluginContext, locale: HeadingLocale): void {\n\tcontext.registerToolbarItem({\n\t\tid: 'heading',\n\t\tgroup: 'block',\n\t\tlabel: locale.blockTypeLabel,\n\t\ttooltip: locale.blockTypeLabel,\n\t\tcommand: 'setParagraph',\n\t\tpopupType: 'combobox',\n\t\tgetLabel: (state: EditorState): string => getActiveLabel(state, context, locale),\n\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\trenderHeadingPopup(container, ctx, locale, onClose);\n\t\t},\n\t\tisActive: (state) => {\n\t\t\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\t\t\treturn entries.some((entry) => entry.id !== 'paragraph' && entry.isActive(state));\n\t\t},\n\t});\n}\n\n// --- Popup Rendering ---\n\nfunction renderHeadingPopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tlocale: HeadingLocale,\n\tonClose: (options?: PopupCloseOptions) => void,\n): void {\n\tcontainer.classList.add('notectl-heading-picker');\n\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return;\n\n\tconst contentElement: HTMLElement = context.getContainer();\n\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-heading-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', locale.blockTypesAria);\n\n\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\tfor (const entry of entries) {\n\t\tconst active: boolean = entry.isActive(state);\n\t\tlist.appendChild(\n\t\t\tcreatePickerItem(\n\t\t\t\tentry.label,\n\t\t\t\tactive,\n\t\t\t\t(e: MouseEvent) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\tcontext.executeCommand(entry.command);\n\t\t\t\t\tonClose({ restoreFocusTo: contentElement });\n\t\t\t\t},\n\t\t\t\tentry.style,\n\t\t\t),\n\t\t);\n\t}\n\n\tcontainer.appendChild(list);\n}\n\nfunction createPickerItem(\n\tlabel: string,\n\tisActive: boolean,\n\thandler: (e: MouseEvent) => void,\n\tstyle?: PickerEntryStyle,\n): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.className = 'notectl-heading-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-heading-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-heading-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst labelSpan: HTMLSpanElement = document.createElement('span');\n\tlabelSpan.className = 'notectl-heading-picker__label';\n\tlabelSpan.textContent = label;\n\tif (style) {\n\t\tsetStyleProperties(labelSpan, {\n\t\t\tfontSize: style.fontSize,\n\t\t\tfontWeight: style.fontWeight,\n\t\t});\n\t}\n\titem.appendChild(labelSpan);\n\n\titem.addEventListener('mousedown', handler);\n\treturn item;\n}\n\n// --- Helpers ---\n\nfunction getHeadingLabel(locale: HeadingLocale, level: HeadingLevel): string {\n\tconst key = `heading${level}` as keyof HeadingLocale;\n\treturn locale[key] as string;\n}\n\nfunction getActiveLabel(state: EditorState, context: PluginContext, locale: HeadingLocale): string {\n\tif (!isTextSelection(state.selection)) return locale.paragraph;\n\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\tfor (const entry of entries) {\n\t\tif (entry.isActive(state)) return entry.label;\n\t}\n\treturn locale.paragraph;\n}\n","/**\n * Command registration and implementations for heading block types.\n * Handles toggle between heading/title/subtitle and paragraph,\n * plus excluded-mark stripping when switching block types.\n */\n\nimport type { BlockNode, Mark } from '../../model/Document.js';\nimport { getBlockLength, getInlineChildren, isTextNode } from '../../model/Document.js';\nimport { isTextSelection } from '../../model/Selection.js';\nimport { type NodeTypeName, nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { TransactionBuilder } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig, HeadingLevel } from './HeadingPlugin.js';\n\n/** Registers all heading commands (setTitle, setSubtitle, setHeadingN, toggleHeading, setParagraph). */\nexport function registerHeadingCommands(context: PluginContext, config: HeadingConfig): void {\n\tcontext.registerCommand('setTitle', () => toggleSpecialBlock(context, 'title'));\n\n\tcontext.registerCommand('setSubtitle', () => toggleSpecialBlock(context, 'subtitle'));\n\n\tfor (const level of config.levels) {\n\t\tcontext.registerCommand(`setHeading${level}`, () => toggleHeading(context, level));\n\t}\n\n\tcontext.registerCommand('toggleHeading', () => toggleHeading(context, 1));\n\n\tcontext.registerCommand('setParagraph', () => setBlockType(context, nodeType('paragraph')));\n}\n\n// --- Command Implementations ---\n\n/**\n * Toggles between a special block type (title/subtitle) and paragraph.\n * If the block is already that type, resets to paragraph.\n */\nfunction toggleSpecialBlock(context: PluginContext, type: string): boolean {\n\tconst state: EditorState = 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 === type) {\n\t\treturn setBlockType(context, nodeType('paragraph'));\n\t}\n\n\treturn setBlockType(context, nodeType(type) as NodeTypeName);\n}\n\n/**\n * Toggles between heading (at given level) and paragraph.\n * If the block is already a heading at the same level, resets to paragraph.\n */\nfunction toggleHeading(context: PluginContext, level: HeadingLevel): boolean {\n\tconst state: EditorState = 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) return false;\n\n\tif (block.type === 'heading' && block.attrs?.level === level) {\n\t\treturn setBlockType(context, nodeType('paragraph'));\n\t}\n\n\treturn setBlockType(context, nodeType('heading'), { level });\n}\n\nfunction setBlockType(\n\tcontext: PluginContext,\n\ttype: NodeTypeName,\n\tattrs?: Record<string, string | number | boolean>,\n): boolean {\n\tconst state: EditorState = 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) return false;\n\n\tconst builder: TransactionBuilder = state.transaction('command');\n\n\tconst spec = context.getSchemaRegistry().getNodeSpec(type);\n\tif (spec?.excludeMarks && spec.excludeMarks.length > 0) {\n\t\tstripExcludedMarks(builder, block, spec.excludeMarks);\n\t\tclearExcludedStoredMarks(builder, state, spec.excludeMarks);\n\t}\n\n\tconst tr = builder.setBlockType(sel.anchor.blockId, type, attrs).setSelection(sel).build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n// --- Mark Stripping Helpers ---\n\n/**\n * Adds removeMark steps for each excluded mark type found\n * on the block's inline text content.\n */\nfunction stripExcludedMarks(\n\tbuilder: TransactionBuilder,\n\tblock: BlockNode,\n\texcludeMarks: readonly string[],\n): void {\n\tconst blockLength: number = getBlockLength(block);\n\tif (blockLength === 0) return;\n\n\tconst excludeSet: Set<string> = new Set(excludeMarks);\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\tif (excludeSet.has(mark.type)) {\n\t\t\t\t\t\tbuilder.removeMark(block.id, offset, offset + child.text.length, mark);\n\t\t\t\t\t}\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/**\n * Clears excluded mark types from stored marks so that\n * subsequent typing does not reintroduce them.\n */\nfunction clearExcludedStoredMarks(\n\tbuilder: TransactionBuilder,\n\tstate: EditorState,\n\texcludeMarks: readonly string[],\n): void {\n\tif (!state.storedMarks) return;\n\n\tconst excludeSet: Set<string> = new Set(excludeMarks);\n\tconst filtered: readonly Mark[] = state.storedMarks.filter((m: Mark) => !excludeSet.has(m.type));\n\n\tif (filtered.length !== state.storedMarks.length) {\n\t\tbuilder.setStoredMarks(filtered.length > 0 ? filtered : null, state.storedMarks);\n\t}\n}\n","/**\n * Input rule registration for heading block types.\n * Converts `# `, `## `, etc. at the start of a paragraph into headings.\n */\n\nimport { createCollapsedSelection, isCollapsed, isTextSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig } from './HeadingPlugin.js';\n\n/** Registers markdown-style input rules (e.g. `# ` → H1) for configured heading levels. */\nexport function registerHeadingInputRules(context: PluginContext, config: HeadingConfig): void {\n\tfor (const level of config.levels) {\n\t\tconst hashes: string = '#'.repeat(level);\n\t\tconst pattern: RegExp = new RegExp(`^${hashes} $`);\n\n\t\tcontext.registerInputRule({\n\t\t\tpattern,\n\t\t\thandler(state, _match, start, _end) {\n\t\t\t\tconst sel = state.selection;\n\t\t\t\tif (!isTextSelection(sel)) return null;\n\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, start, start + level + 1)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('heading'), { level })\n\t\t\t\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0))\n\t\t\t\t\t.build();\n\t\t\t},\n\t\t});\n\t}\n}\n","/**\n * Keyboard handlers for heading block types.\n * Handles Enter key behavior: empty heading → paragraph, cursor at end → split + paragraph.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockLength, getBlockText } from '../../model/Document.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 { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig } from './HeadingPlugin.js';\n\n// --- Context Guard ---\n\nconst HEADING_TYPES: ReadonlySet<string> = new Set(['heading', 'title', 'subtitle']);\n\ninterface HeadingContext {\n\treadonly state: EditorState;\n\treadonly block: BlockNode;\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Guards against NodeSelection, non-collapsed selections, and non-heading blocks.\n * Returns false (not handled) if the cursor is not inside a heading-type block.\n */\nfunction withHeadingContext(\n\tcontext: PluginContext,\n\thandler: (ctx: HeadingContext) => boolean,\n): boolean {\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return false;\n\n\tconst sel = state.selection;\n\tif (!isCollapsed(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block || !HEADING_TYPES.has(block.type)) return false;\n\n\treturn handler({\n\t\tstate,\n\t\tblock,\n\t\tblockId: sel.anchor.blockId,\n\t\toffset: sel.anchor.offset,\n\t});\n}\n\n/** Registers all heading keyboard handlers (Enter, Mod-Shift-N shortcuts). */\nexport function registerHeadingKeymaps(context: PluginContext, config: HeadingConfig): void {\n\tconst keymap: Record<string, () => boolean> = {\n\t\tEnter: () => handleEnter(context),\n\t};\n\n\tfor (const level of config.levels) {\n\t\tif (level <= 6) {\n\t\t\tkeymap[`Mod-Shift-${level}`] = () => context.executeCommand(`setHeading${level}`);\n\t\t}\n\t}\n\n\tcontext.registerKeymap(keymap);\n}\n\n// --- Enter Handler ---\n\n/**\n * Handles Enter inside a heading block.\n * Empty heading → convert to paragraph.\n * Cursor at end → split and convert new block to paragraph.\n * Cursor in middle → normal split (both stay heading).\n */\nfunction handleEnter(context: PluginContext): boolean {\n\treturn withHeadingContext(context, (ctx) => {\n\t\tconst text: string = getBlockText(ctx.block);\n\n\t\tif (text === '') {\n\t\t\tconst tr = ctx.state\n\t\t\t\t.transaction('input')\n\t\t\t\t.setBlockType(ctx.blockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(ctx.state.selection)\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst blockLength: number = getBlockLength(ctx.block);\n\n\t\tif (ctx.offset >= blockLength) {\n\t\t\tconst newBlockId = generateBlockId();\n\t\t\tconst tr = ctx.state\n\t\t\t\t.transaction('input')\n\t\t\t\t.splitBlock(ctx.blockId, ctx.offset, newBlockId)\n\t\t\t\t.setBlockType(newBlockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(createCollapsedSelection(newBlockId, 0))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n","/**\n * Locale interface and default English locale for the HeadingPlugin.\n */\n\n// --- Locale Interface ---\n\nexport interface HeadingLocale {\n\treadonly paragraph: string;\n\treadonly title: string;\n\treadonly subtitle: string;\n\treadonly heading1: string;\n\treadonly heading2: string;\n\treadonly heading3: string;\n\treadonly heading4: string;\n\treadonly heading5: string;\n\treadonly heading6: string;\n\treadonly blockTypeLabel: string;\n\treadonly blockTypesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const HEADING_LOCALE_EN: HeadingLocale = {\n\tparagraph: 'Paragraph',\n\ttitle: 'Title',\n\tsubtitle: 'Subtitle',\n\theading1: 'Heading 1',\n\theading2: 'Heading 2',\n\theading3: 'Heading 3',\n\theading4: 'Heading 4',\n\theading5: 'Heading 5',\n\theading6: 'Heading 6',\n\tblockTypeLabel: 'Block Type',\n\tblockTypesAria: 'Block types',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: Record<string, () => Promise<{ default: HeadingLocale }>> = import.meta.glob<{\n\tdefault: HeadingLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadHeadingLocale(lang: string): Promise<HeadingLocale> {\n\tif (lang === 'en') return HEADING_LOCALE_EN;\n\tconst loader = localeModules[`./locales/${lang}.ts`];\n\tif (!loader) return HEADING_LOCALE_EN;\n\ttry {\n\t\tconst mod = await loader();\n\t\treturn mod.default;\n\t} catch {\n\t\treturn HEADING_LOCALE_EN;\n\t}\n}\n","/**\n * HeadingPlugin: registers Title, Subtitle, and H1–H6 heading block types\n * with NodeSpec, toggle commands, keyboard shortcuts, input rules, and a\n * combobox-style toolbar dropdown that reflects the current block type.\n *\n * This file is a thin orchestrator — command logic, input rules, keyboard\n * handlers, and picker/toolbar rendering are delegated to dedicated modules.\n */\n\nimport { HEADING_SELECT_CSS } from '../../editor/styles/heading-select.js';\nimport type { BlockAlignment } from '../../model/BlockAlignment.js';\nimport { createBlockElement } from '../../view/DomUtils.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport {\n\tregisterHeadingPickerEntries,\n\tregisterHeadingToolbarItem,\n} from './HeadingBlockTypePicker.js';\nimport { registerHeadingCommands } from './HeadingCommands.js';\nimport { registerHeadingInputRules } from './HeadingInputRules.js';\nimport { registerHeadingKeymaps } from './HeadingKeyboardHandlers.js';\nimport { HEADING_LOCALE_EN, type HeadingLocale, loadHeadingLocale } from './HeadingLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\theading: { level: HeadingLevel; align?: BlockAlignment };\n\t\ttitle: { align?: BlockAlignment };\n\t\tsubtitle: { align?: BlockAlignment };\n\t}\n}\n\n// --- Configuration ---\n\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport interface HeadingConfig {\n\t/** Which heading levels to enable. Defaults to [1, 2, 3, 4, 5, 6]. */\n\treadonly levels: readonly HeadingLevel[];\n\treadonly locale?: HeadingLocale;\n}\n\nconst DEFAULT_CONFIG: HeadingConfig = {\n\tlevels: [1, 2, 3, 4, 5, 6],\n};\n\n// --- Heading Tag Mapping ---\n\nconst HEADING_TAGS: Record<HeadingLevel, string> = {\n\t1: 'h1',\n\t2: 'h2',\n\t3: 'h3',\n\t4: 'h4',\n\t5: 'h5',\n\t6: 'h6',\n};\n\n// --- Plugin ---\n\nexport class HeadingPlugin implements Plugin {\n\treadonly id = 'heading';\n\treadonly name = 'Heading';\n\treadonly priority = 30;\n\n\tprivate readonly config: HeadingConfig;\n\tprivate locale!: HeadingLocale;\n\n\tconstructor(config?: Partial<HeadingConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\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\tHEADING_LOCALE_EN,\n\t\t\tloadHeadingLocale,\n\t\t);\n\t\tcontext.registerStyleSheet(HEADING_SELECT_CSS);\n\n\t\tthis.registerNodeSpecs(context);\n\t\tregisterHeadingCommands(context, this.config);\n\t\tregisterHeadingKeymaps(context, this.config);\n\t\tregisterHeadingInputRules(context, this.config);\n\t\tregisterHeadingPickerEntries(context, this.config, this.locale);\n\t\tregisterHeadingToolbarItem(context, this.locale);\n\t}\n\n\tprivate registerNodeSpecs(context: PluginContext): void {\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'title',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\ttoDOM(node) {\n\t\t\t\tconst el = createBlockElement('h1', node.id);\n\t\t\t\tel.classList.add('notectl-title');\n\t\t\t\treturn el;\n\t\t\t},\n\t\t\ttoHTML(_node, content) {\n\t\t\t\treturn `<h1 class=\"notectl-title\">${content || '<br>'}</h1>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'h1',\n\t\t\t\t\tpriority: 60,\n\t\t\t\t\tgetAttrs: (el) => (el.classList.contains('notectl-title') ? {} : false),\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['h1'], attrs: ['class'] },\n\t\t});\n\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'subtitle',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\ttoDOM(node) {\n\t\t\t\tconst el = createBlockElement('h2', node.id);\n\t\t\t\tel.classList.add('notectl-subtitle');\n\t\t\t\treturn el;\n\t\t\t},\n\t\t\ttoHTML(_node, content) {\n\t\t\t\treturn `<h2 class=\"notectl-subtitle\">${content || '<br>'}</h2>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'h2',\n\t\t\t\t\tpriority: 60,\n\t\t\t\t\tgetAttrs: (el) => (el.classList.contains('notectl-subtitle') ? {} : false),\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['h2'], attrs: ['class'] },\n\t\t});\n\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'heading',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\tattrs: {\n\t\t\t\tlevel: { default: 1 },\n\t\t\t},\n\t\t\ttoDOM(node) {\n\t\t\t\tconst level = node.attrs?.level ?? 1;\n\t\t\t\tconst tag = HEADING_TAGS[level] ?? 'h1';\n\t\t\t\treturn createBlockElement(tag, node.id);\n\t\t\t},\n\t\t\ttoHTML(node, content) {\n\t\t\t\tconst level = (node.attrs?.level ?? 1) as HeadingLevel;\n\t\t\t\tconst tag: string = HEADING_TAGS[level] ?? 'h1';\n\t\t\t\treturn `<${tag}>${content || '<br>'}</${tag}>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{ tag: 'h1', getAttrs: () => ({ level: 1 }) },\n\t\t\t\t{ tag: 'h2', getAttrs: () => ({ level: 2 }) },\n\t\t\t\t{ tag: 'h3', getAttrs: () => ({ level: 3 }) },\n\t\t\t\t{ tag: 'h4', getAttrs: () => ({ level: 4 }) },\n\t\t\t\t{ tag: 'h5', getAttrs: () => ({ level: 5 }) },\n\t\t\t\t{ tag: 'h6', getAttrs: () => ({ level: 6 }) },\n\t\t\t],\n\t\t\tsanitize: { tags: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] },\n\t\t});\n\t}\n}\n"],"mappings":"8TC6IA,SAAS,EACR,EACA,EACA,EACA,GAEA,MAAM,EAA0B,SAAS,cAAc,UACvD,EAAK,KAAO,SACZ,EAAK,UAAY,+BACjB,EAAK,aAAa,OAAQ,UAC1B,EAAK,aAAa,gBAAiB,OAAO,IAEtC,GACH,EAAK,UAAU,IAAI,wCAGpB,MAAM,EAAyB,SAAS,cAAc,QACtD,EAAM,UAAY,gCAClB,EAAM,YAAc,EAAW,IAAW,GAC1C,EAAK,YAAY,GAEjB,MAAM,EAA6B,SAAS,cAAc,QAY1D,OAXA,EAAU,UAAY,gCACtB,EAAU,YAAc,EACpB,GACH,EAAmB,EAAW,CAC7B,SAAU,EAAM,SAChB,WAAY,EAAM,aAGpB,EAAK,YAAY,GAEjB,EAAK,iBAAiB,YAAa,GAC5B,EAKR,SAAS,EAAgB,EAAuB,GAE/C,OAAO,EADK,UAAU,KChJvB,SAAS,EAAmB,EAAwB,GACnD,MAAM,EAAqB,EAAQ,WACnC,IAAK,EAAgB,EAAM,WAAY,OAAO,EAE9C,MAAM,EAA+B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vC,CAAE,IAAK,KAAM,SAAA,KAAA,CAAmB,MAAO,KACvC,CAAE,IAAK,KAAM,SAAA,KAAA,CAAmB,MAAO,MAExC,SAAU,CAAE,KAAM,CAAC,KAAM,KAAM,KAAM,KAAM,KAAM"}
|
|
1
|
+
{"version":3,"file":"HeadingPlugin-CUN746aD.mjs","names":[],"sources":["../../src/editor/styles/heading-select.ts","../../src/plugins/heading/HeadingBlockTypePicker.ts","../../src/plugins/heading/HeadingCommands.ts","../../src/plugins/heading/HeadingInputRules.ts","../../src/plugins/heading/HeadingKeyboardHandlers.ts","../../src/plugins/heading/HeadingLocale.ts","../../src/plugins/heading/HeadingPlugin.ts"],"sourcesContent":["/** Heading picker toolbar combobox + popup styles. */\nexport const HEADING_SELECT_CSS = `\n/* Heading Select — Width overrides for combobox button */\n.notectl-toolbar-btn--heading {\n\tmin-width: 100px;\n\tmax-width: 160px;\n}\n\n/* Heading Picker Popup */\n.notectl-heading-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-heading-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-heading-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\ttext-align: start;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item:hover {\n\t\tbackground: var(--notectl-hover-bg);\n\t}\n}\n\n.notectl-heading-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n@media (hover: hover) {\n\t.notectl-heading-picker__item--active:hover {\n\t\tbackground: var(--notectl-active-bg);\n\t}\n}\n\n.notectl-heading-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__label {\n\tflex: 1;\n}\n`;\n","/**\n * Block type picker entries and toolbar dropdown for heading block types.\n * Registers picker entries for paragraph, title, subtitle, and all heading levels,\n * plus a combobox-style toolbar item with a custom popup.\n */\n\nimport { isTextSelection } from '../../model/Selection.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport { setStyleProperties } from '../../style/StyleRuntime.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\nimport type { PickerEntryStyle } from './BlockTypePickerEntry.js';\nimport type { HeadingLocale } from './HeadingLocale.js';\nimport type { HeadingConfig } from './HeadingPlugin.js';\nimport type { HeadingLevel } from './HeadingPlugin.js';\n\n// --- Picker Entry Registration ---\n\n/** Registers block type picker entries for paragraph, title, subtitle, and heading levels. */\nexport function registerHeadingPickerEntries(\n\tcontext: PluginContext,\n\tconfig: HeadingConfig,\n\tlocale: HeadingLocale,\n): void {\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'paragraph',\n\t\tlabel: locale.paragraph,\n\t\tcommand: 'setParagraph',\n\t\tpriority: 10,\n\t\tisActive: (state) => {\n\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'paragraph';\n\t\t},\n\t});\n\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'title',\n\t\tlabel: locale.title,\n\t\tcommand: 'setTitle',\n\t\tpriority: 20,\n\t\tstyle: { fontSize: '1.6em', fontWeight: '700' },\n\t\tisActive: (state) => {\n\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'title';\n\t\t},\n\t});\n\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'subtitle',\n\t\tlabel: locale.subtitle,\n\t\tcommand: 'setSubtitle',\n\t\tpriority: 30,\n\t\tstyle: { fontSize: '1.3em', fontWeight: '500' },\n\t\tisActive: (state) => {\n\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'subtitle';\n\t\t},\n\t});\n\n\tfor (const level of config.levels) {\n\t\tcontext.registerBlockTypePickerEntry({\n\t\t\tid: `heading-${level}`,\n\t\t\tlabel: getHeadingLabel(locale, level),\n\t\t\tcommand: `setHeading${level}`,\n\t\t\tpriority: 100 + level,\n\t\t\tstyle: { fontSize: `${1.4 - level * 0.1}em`, fontWeight: '600' },\n\t\t\tisActive: (state) => {\n\t\t\t\tif (!isTextSelection(state.selection)) return false;\n\t\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\t\treturn block?.type === 'heading' && block.attrs?.level === level;\n\t\t\t},\n\t\t});\n\t}\n}\n\n// --- Toolbar Item ---\n\n/** Registers the heading toolbar dropdown with a combobox picker popup. */\nexport function registerHeadingToolbarItem(context: PluginContext, locale: HeadingLocale): void {\n\tcontext.registerToolbarItem({\n\t\tid: 'heading',\n\t\tgroup: 'block',\n\t\tlabel: locale.blockTypeLabel,\n\t\ttooltip: locale.blockTypeLabel,\n\t\tcommand: 'setParagraph',\n\t\tpopupType: 'combobox',\n\t\tgetLabel: (state: EditorState): string => getActiveLabel(state, context, locale),\n\t\trenderPopup: (container, ctx, onClose) => {\n\t\t\trenderHeadingPopup(container, ctx, locale, onClose);\n\t\t},\n\t\tisActive: (state) => {\n\t\t\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\t\t\treturn entries.some((entry) => entry.id !== 'paragraph' && entry.isActive(state));\n\t\t},\n\t});\n}\n\n// --- Popup Rendering ---\n\nfunction renderHeadingPopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tlocale: HeadingLocale,\n\tonClose: (options?: PopupCloseOptions) => void,\n): void {\n\tcontainer.classList.add('notectl-heading-picker');\n\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return;\n\n\tconst contentElement: HTMLElement = context.getContainer();\n\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-heading-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', locale.blockTypesAria);\n\n\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\tfor (const entry of entries) {\n\t\tconst active: boolean = entry.isActive(state);\n\t\tlist.appendChild(\n\t\t\tcreatePickerItem(\n\t\t\t\tentry.label,\n\t\t\t\tactive,\n\t\t\t\t(e: MouseEvent) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\tcontext.executeCommand(entry.command);\n\t\t\t\t\tonClose({ restoreFocusTo: contentElement });\n\t\t\t\t},\n\t\t\t\tentry.style,\n\t\t\t),\n\t\t);\n\t}\n\n\tcontainer.appendChild(list);\n}\n\nfunction createPickerItem(\n\tlabel: string,\n\tisActive: boolean,\n\thandler: (e: MouseEvent) => void,\n\tstyle?: PickerEntryStyle,\n): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.className = 'notectl-heading-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-heading-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-heading-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst labelSpan: HTMLSpanElement = document.createElement('span');\n\tlabelSpan.className = 'notectl-heading-picker__label';\n\tlabelSpan.textContent = label;\n\tif (style) {\n\t\tsetStyleProperties(labelSpan, {\n\t\t\tfontSize: style.fontSize,\n\t\t\tfontWeight: style.fontWeight,\n\t\t});\n\t}\n\titem.appendChild(labelSpan);\n\n\titem.addEventListener('mousedown', handler);\n\treturn item;\n}\n\n// --- Helpers ---\n\nfunction getHeadingLabel(locale: HeadingLocale, level: HeadingLevel): string {\n\tconst key = `heading${level}` as keyof HeadingLocale;\n\treturn locale[key] as string;\n}\n\nfunction getActiveLabel(state: EditorState, context: PluginContext, locale: HeadingLocale): string {\n\tif (!isTextSelection(state.selection)) return locale.paragraph;\n\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\tfor (const entry of entries) {\n\t\tif (entry.isActive(state)) return entry.label;\n\t}\n\treturn locale.paragraph;\n}\n","/**\n * Command registration and implementations for heading block types.\n * Handles toggle between heading/title/subtitle and paragraph,\n * plus excluded-mark stripping when switching block types.\n */\n\nimport type { BlockNode, Mark } from '../../model/Document.js';\nimport { getBlockLength, getInlineChildren, isTextNode } from '../../model/Document.js';\nimport { isTextSelection } from '../../model/Selection.js';\nimport { type NodeTypeName, nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { TransactionBuilder } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig, HeadingLevel } from './HeadingPlugin.js';\n\n/** Registers all heading commands (setTitle, setSubtitle, setHeadingN, toggleHeading, setParagraph). */\nexport function registerHeadingCommands(context: PluginContext, config: HeadingConfig): void {\n\tcontext.registerCommand('setTitle', () => toggleSpecialBlock(context, 'title'));\n\n\tcontext.registerCommand('setSubtitle', () => toggleSpecialBlock(context, 'subtitle'));\n\n\tfor (const level of config.levels) {\n\t\tcontext.registerCommand(`setHeading${level}`, () => toggleHeading(context, level));\n\t}\n\n\tcontext.registerCommand('toggleHeading', () => toggleHeading(context, 1));\n\n\tcontext.registerCommand('setParagraph', () => setBlockType(context, nodeType('paragraph')));\n}\n\n// --- Command Implementations ---\n\n/**\n * Toggles between a special block type (title/subtitle) and paragraph.\n * If the block is already that type, resets to paragraph.\n */\nfunction toggleSpecialBlock(context: PluginContext, type: string): boolean {\n\tconst state: EditorState = 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 === type) {\n\t\treturn setBlockType(context, nodeType('paragraph'));\n\t}\n\n\treturn setBlockType(context, nodeType(type) as NodeTypeName);\n}\n\n/**\n * Toggles between heading (at given level) and paragraph.\n * If the block is already a heading at the same level, resets to paragraph.\n */\nfunction toggleHeading(context: PluginContext, level: HeadingLevel): boolean {\n\tconst state: EditorState = 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) return false;\n\n\tif (block.type === 'heading' && block.attrs?.level === level) {\n\t\treturn setBlockType(context, nodeType('paragraph'));\n\t}\n\n\treturn setBlockType(context, nodeType('heading'), { level });\n}\n\nfunction setBlockType(\n\tcontext: PluginContext,\n\ttype: NodeTypeName,\n\tattrs?: Record<string, string | number | boolean>,\n): boolean {\n\tconst state: EditorState = 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) return false;\n\n\tconst builder: TransactionBuilder = state.transaction('command');\n\n\tconst spec = context.getSchemaRegistry().getNodeSpec(type);\n\tif (spec?.excludeMarks && spec.excludeMarks.length > 0) {\n\t\tstripExcludedMarks(builder, block, spec.excludeMarks);\n\t\tclearExcludedStoredMarks(builder, state, spec.excludeMarks);\n\t}\n\n\tconst tr = builder.setBlockType(sel.anchor.blockId, type, attrs).setSelection(sel).build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n// --- Mark Stripping Helpers ---\n\n/**\n * Adds removeMark steps for each excluded mark type found\n * on the block's inline text content.\n */\nfunction stripExcludedMarks(\n\tbuilder: TransactionBuilder,\n\tblock: BlockNode,\n\texcludeMarks: readonly string[],\n): void {\n\tconst blockLength: number = getBlockLength(block);\n\tif (blockLength === 0) return;\n\n\tconst excludeSet: Set<string> = new Set(excludeMarks);\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\tif (excludeSet.has(mark.type)) {\n\t\t\t\t\t\tbuilder.removeMark(block.id, offset, offset + child.text.length, mark);\n\t\t\t\t\t}\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/**\n * Clears excluded mark types from stored marks so that\n * subsequent typing does not reintroduce them.\n */\nfunction clearExcludedStoredMarks(\n\tbuilder: TransactionBuilder,\n\tstate: EditorState,\n\texcludeMarks: readonly string[],\n): void {\n\tif (!state.storedMarks) return;\n\n\tconst excludeSet: Set<string> = new Set(excludeMarks);\n\tconst filtered: readonly Mark[] = state.storedMarks.filter((m: Mark) => !excludeSet.has(m.type));\n\n\tif (filtered.length !== state.storedMarks.length) {\n\t\tbuilder.setStoredMarks(filtered.length > 0 ? filtered : null, state.storedMarks);\n\t}\n}\n","/**\n * Input rule registration for heading block types.\n * Converts `# `, `## `, etc. at the start of a paragraph into headings.\n */\n\nimport { createCollapsedSelection, isCollapsed, isTextSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig } from './HeadingPlugin.js';\n\n/** Registers markdown-style input rules (e.g. `# ` → H1) for configured heading levels. */\nexport function registerHeadingInputRules(context: PluginContext, config: HeadingConfig): void {\n\tfor (const level of config.levels) {\n\t\tconst hashes: string = '#'.repeat(level);\n\t\tconst pattern: RegExp = new RegExp(`^${hashes} $`);\n\n\t\tcontext.registerInputRule({\n\t\t\tpattern,\n\t\t\thandler(state, _match, start, _end) {\n\t\t\t\tconst sel = state.selection;\n\t\t\t\tif (!isTextSelection(sel)) return null;\n\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, start, start + level + 1)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('heading'), { level })\n\t\t\t\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0))\n\t\t\t\t\t.build();\n\t\t\t},\n\t\t});\n\t}\n}\n","/**\n * Keyboard handlers for heading block types.\n * Handles Enter key behavior: empty heading → paragraph, cursor at end → split + paragraph.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockLength, getBlockText } from '../../model/Document.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 { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig } from './HeadingPlugin.js';\n\n// --- Context Guard ---\n\nconst HEADING_TYPES: ReadonlySet<string> = new Set(['heading', 'title', 'subtitle']);\n\ninterface HeadingContext {\n\treadonly state: EditorState;\n\treadonly block: BlockNode;\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Guards against NodeSelection, non-collapsed selections, and non-heading blocks.\n * Returns false (not handled) if the cursor is not inside a heading-type block.\n */\nfunction withHeadingContext(\n\tcontext: PluginContext,\n\thandler: (ctx: HeadingContext) => boolean,\n): boolean {\n\tconst state: EditorState = context.getState();\n\tif (!isTextSelection(state.selection)) return false;\n\n\tconst sel = state.selection;\n\tif (!isCollapsed(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block || !HEADING_TYPES.has(block.type)) return false;\n\n\treturn handler({\n\t\tstate,\n\t\tblock,\n\t\tblockId: sel.anchor.blockId,\n\t\toffset: sel.anchor.offset,\n\t});\n}\n\n/** Registers all heading keyboard handlers (Enter, Mod-Shift-N shortcuts). */\nexport function registerHeadingKeymaps(context: PluginContext, config: HeadingConfig): void {\n\tconst keymap: Record<string, () => boolean> = {\n\t\tEnter: () => handleEnter(context),\n\t};\n\n\tfor (const level of config.levels) {\n\t\tif (level <= 6) {\n\t\t\tkeymap[`Mod-Shift-${level}`] = () => context.executeCommand(`setHeading${level}`);\n\t\t}\n\t}\n\n\tcontext.registerKeymap(keymap);\n}\n\n// --- Enter Handler ---\n\n/**\n * Handles Enter inside a heading block.\n * Empty heading → convert to paragraph.\n * Cursor at end → split and convert new block to paragraph.\n * Cursor in middle → normal split (both stay heading).\n */\nfunction handleEnter(context: PluginContext): boolean {\n\treturn withHeadingContext(context, (ctx) => {\n\t\tconst text: string = getBlockText(ctx.block);\n\n\t\tif (text === '') {\n\t\t\tconst tr = ctx.state\n\t\t\t\t.transaction('input')\n\t\t\t\t.setBlockType(ctx.blockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(ctx.state.selection)\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst blockLength: number = getBlockLength(ctx.block);\n\n\t\tif (ctx.offset >= blockLength) {\n\t\t\tconst newBlockId = generateBlockId();\n\t\t\tconst tr = ctx.state\n\t\t\t\t.transaction('input')\n\t\t\t\t.splitBlock(ctx.blockId, ctx.offset, newBlockId)\n\t\t\t\t.setBlockType(newBlockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(createCollapsedSelection(newBlockId, 0))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n","/**\n * Locale interface and default English locale for the HeadingPlugin.\n */\n\nimport { type LocaleModuleMap, loadLocaleModule } from '../shared/LocaleLoader.js';\n\n// --- Locale Interface ---\n\nexport interface HeadingLocale {\n\treadonly paragraph: string;\n\treadonly title: string;\n\treadonly subtitle: string;\n\treadonly heading1: string;\n\treadonly heading2: string;\n\treadonly heading3: string;\n\treadonly heading4: string;\n\treadonly heading5: string;\n\treadonly heading6: string;\n\treadonly blockTypeLabel: string;\n\treadonly blockTypesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const HEADING_LOCALE_EN: HeadingLocale = {\n\tparagraph: 'Paragraph',\n\ttitle: 'Title',\n\tsubtitle: 'Subtitle',\n\theading1: 'Heading 1',\n\theading2: 'Heading 2',\n\theading3: 'Heading 3',\n\theading4: 'Heading 4',\n\theading5: 'Heading 5',\n\theading6: 'Heading 6',\n\tblockTypeLabel: 'Block Type',\n\tblockTypesAria: 'Block types',\n};\n\n// --- Lazy Locale Loader ---\n\nconst localeModules: LocaleModuleMap<HeadingLocale> = import.meta.glob<{\n\tdefault: HeadingLocale;\n}>('./locales/*.ts', { eager: false });\n\nexport async function loadHeadingLocale(lang: string): Promise<HeadingLocale> {\n\treturn loadLocaleModule(localeModules, lang, HEADING_LOCALE_EN);\n}\n","/**\n * HeadingPlugin: registers Title, Subtitle, and H1–H6 heading block types\n * with NodeSpec, toggle commands, keyboard shortcuts, input rules, and a\n * combobox-style toolbar dropdown that reflects the current block type.\n *\n * This file is a thin orchestrator — command logic, input rules, keyboard\n * handlers, and picker/toolbar rendering are delegated to dedicated modules.\n */\n\nimport { HEADING_SELECT_CSS } from '../../editor/styles/heading-select.js';\nimport type { BlockAlignment } from '../../model/BlockAlignment.js';\nimport { createBlockElement } from '../../view/DomUtils.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { resolveLocale } from '../shared/PluginHelpers.js';\nimport {\n\tregisterHeadingPickerEntries,\n\tregisterHeadingToolbarItem,\n} from './HeadingBlockTypePicker.js';\nimport { registerHeadingCommands } from './HeadingCommands.js';\nimport { registerHeadingInputRules } from './HeadingInputRules.js';\nimport { registerHeadingKeymaps } from './HeadingKeyboardHandlers.js';\nimport { HEADING_LOCALE_EN, type HeadingLocale, loadHeadingLocale } from './HeadingLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\theading: { level: HeadingLevel; align?: BlockAlignment };\n\t\ttitle: { align?: BlockAlignment };\n\t\tsubtitle: { align?: BlockAlignment };\n\t}\n}\n\n// --- Configuration ---\n\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport interface HeadingConfig {\n\t/** Which heading levels to enable. Defaults to [1, 2, 3, 4, 5, 6]. */\n\treadonly levels: readonly HeadingLevel[];\n\treadonly locale?: HeadingLocale;\n}\n\nconst DEFAULT_CONFIG: HeadingConfig = {\n\tlevels: [1, 2, 3, 4, 5, 6],\n};\n\n// --- Heading Tag Mapping ---\n\nconst HEADING_TAGS: Record<HeadingLevel, string> = {\n\t1: 'h1',\n\t2: 'h2',\n\t3: 'h3',\n\t4: 'h4',\n\t5: 'h5',\n\t6: 'h6',\n};\n\n// --- Plugin ---\n\nexport class HeadingPlugin implements Plugin {\n\treadonly id = 'heading';\n\treadonly name = 'Heading';\n\treadonly priority = 30;\n\n\tprivate readonly config: HeadingConfig;\n\tprivate locale!: HeadingLocale;\n\n\tconstructor(config?: Partial<HeadingConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\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\tHEADING_LOCALE_EN,\n\t\t\tloadHeadingLocale,\n\t\t);\n\t\tcontext.registerStyleSheet(HEADING_SELECT_CSS);\n\n\t\tthis.registerNodeSpecs(context);\n\t\tregisterHeadingCommands(context, this.config);\n\t\tregisterHeadingKeymaps(context, this.config);\n\t\tregisterHeadingInputRules(context, this.config);\n\t\tregisterHeadingPickerEntries(context, this.config, this.locale);\n\t\tregisterHeadingToolbarItem(context, this.locale);\n\t}\n\n\tprivate registerNodeSpecs(context: PluginContext): void {\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'title',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\ttoDOM(node) {\n\t\t\t\tconst el = createBlockElement('h1', node.id);\n\t\t\t\tel.classList.add('notectl-title');\n\t\t\t\treturn el;\n\t\t\t},\n\t\t\ttoHTML(_node, content) {\n\t\t\t\treturn `<h1 class=\"notectl-title\">${content || '<br>'}</h1>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'h1',\n\t\t\t\t\tpriority: 60,\n\t\t\t\t\tgetAttrs: (el) => (el.classList.contains('notectl-title') ? {} : false),\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['h1'], attrs: ['class'] },\n\t\t});\n\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'subtitle',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\ttoDOM(node) {\n\t\t\t\tconst el = createBlockElement('h2', node.id);\n\t\t\t\tel.classList.add('notectl-subtitle');\n\t\t\t\treturn el;\n\t\t\t},\n\t\t\ttoHTML(_node, content) {\n\t\t\t\treturn `<h2 class=\"notectl-subtitle\">${content || '<br>'}</h2>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'h2',\n\t\t\t\t\tpriority: 60,\n\t\t\t\t\tgetAttrs: (el) => (el.classList.contains('notectl-subtitle') ? {} : false),\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['h2'], attrs: ['class'] },\n\t\t});\n\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'heading',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\tattrs: {\n\t\t\t\tlevel: { default: 1 },\n\t\t\t},\n\t\t\ttoDOM(node) {\n\t\t\t\tconst level = node.attrs?.level ?? 1;\n\t\t\t\tconst tag = HEADING_TAGS[level] ?? 'h1';\n\t\t\t\treturn createBlockElement(tag, node.id);\n\t\t\t},\n\t\t\ttoHTML(node, content) {\n\t\t\t\tconst level = (node.attrs?.level ?? 1) as HeadingLevel;\n\t\t\t\tconst tag: string = HEADING_TAGS[level] ?? 'h1';\n\t\t\t\treturn `<${tag}>${content || '<br>'}</${tag}>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{ tag: 'h1', getAttrs: () => ({ level: 1 }) },\n\t\t\t\t{ tag: 'h2', getAttrs: () => ({ level: 2 }) },\n\t\t\t\t{ tag: 'h3', getAttrs: () => ({ level: 3 }) },\n\t\t\t\t{ tag: 'h4', getAttrs: () => ({ level: 4 }) },\n\t\t\t\t{ tag: 'h5', getAttrs: () => ({ level: 5 }) },\n\t\t\t\t{ tag: 'h6', getAttrs: () => ({ level: 6 }) },\n\t\t\t],\n\t\t\tsanitize: { tags: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] },\n\t\t});\n\t}\n}\n"],"mappings":"qUC6IA,SAAS,EACR,EACA,EACA,EACA,GAEA,MAAM,EAA0B,SAAS,cAAc,UACvD,EAAK,KAAO,SACZ,EAAK,UAAY,+BACjB,EAAK,aAAa,OAAQ,UAC1B,EAAK,aAAa,gBAAiB,OAAO,IAEtC,GACH,EAAK,UAAU,IAAI,wCAGpB,MAAM,EAAyB,SAAS,cAAc,QACtD,EAAM,UAAY,gCAClB,EAAM,YAAc,EAAW,IAAW,GAC1C,EAAK,YAAY,GAEjB,MAAM,EAA6B,SAAS,cAAc,QAY1D,OAXA,EAAU,UAAY,gCACtB,EAAU,YAAc,EACpB,GACH,EAAmB,EAAW,CAC7B,SAAU,EAAM,SAChB,WAAY,EAAM,aAGpB,EAAK,YAAY,GAEjB,EAAK,iBAAiB,YAAa,GAC5B,EAKR,SAAS,EAAgB,EAAuB,GAE/C,OAAO,EADK,UAAU,KChJvB,SAAS,EAAmB,EAAwB,GACnD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K,KAAM,SAAA,KAAA,CAAmB,MAAO,KACvC,CAAE,IAAK,KAAM,SAAA,KAAA,CAAmB,MAAO,MAExC,SAAU,CAAE,KAAM,CAAC,KAAM,KAAM,KAAM,KAAM,KAAM"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./HTMLUtils-B8xj8Z1x.mjs";import{s as t}from"./StyleRuntime-D3d1XFFe.mjs";import{i as r,o}from"./PluginHelpers-D1QF-YaF.mjs";import{a as s,t as a}from"./ColorValidation-CiGxVsqd.mjs";import{t as i}from"./color-picker-ChYYdC-r.mjs";import{a as l,i as f,t as c}from"./ColorPickerPopup-CvE90IAu.mjs";var g={label:"Highlight",tooltip:"Highlight Color",resetLabel:"None",ariaLabelPrefix:"Highlight color"},h=/* @__PURE__ */Object.assign({"./locales/ar.ts":()=>import("./ar-CsH2S6Vd.mjs"),"./locales/de.ts":()=>import("./de-CqJFzINs.mjs"),"./locales/es.ts":()=>import("./es-C49UmQIT.mjs"),"./locales/fr.ts":()=>import("./fr-wqbTMwkj.mjs"),"./locales/hi.ts":()=>import("./hi-Co2ThMh7.mjs"),"./locales/pt.ts":()=>import("./pt-DxTZELCn.mjs"),"./locales/ru.ts":()=>import("./ru-B278yBd4.mjs"),"./locales/zh.ts":()=>import("./zh-B4p7M6XB.mjs")});async function m(e){return o(h,e,g)}var n=["#fff176","#aed581","#4dd0e1","#64b5f6","#ce93d8","#f48fb1","#ffab91","#ff8a65","#e6ee9c","#80cbc4","#fff9c4","#dcedc8","#e0f7fa","#e3f2fd","#f3e5f5","#fce4ec","#fff3e0","#fbe9e7","#f9fbe7","#e0f2f1","#fff59d","#c5e1a5","#80deea","#90caf9","#e1bee7","#f8bbd0","#ffcc80","#ffab91","#e6ee9c","#a5d6a7","#ffee58","#9ccc65","#26c6da","#42a5f5","#ab47bc","#ec407a","#ffa726","#ff7043","#d4e157","#66bb6a","#ffffff","#fafafa","#f5f5f5","#eeeeee","#e0e0e0","#bdbdbd","#e8eaf6","#efebe9","#eceff1","#fafafa"],p=class{id="highlight";name="Highlight";priority=24;config;colors;locale;constructor(e){this.config={...e},this.colors=s(e?.colors,n,"HighlightPlugin")}async init(e){this.locale=await r(e,this.config.locale,g,m),e.registerStyleSheet(i),this.registerMarkSpec(e),this.registerCommands(e),this.registerToolbarItem(e)}registerMarkSpec(r){r.registerMarkSpec({type:"highlight",rank:4,attrs:{color:{default:""}},toDOM(e){const r=document.createElement("span");return t(r,"backgroundColor",e.attrs?.color??""),r},toHTMLString:(t,r,o)=>{const s=String(t.attrs?.color??"");if(!s||!a(s))return r;const i=`background-color: ${e(s)}`;return`<span${o?.styleAttr(i)??` style="${i}"`}>${r}</span>`},toHTMLStyle:t=>{const r=String(t.attrs?.color??"");return r&&a(r)?`background-color: ${e(r)}`:null},parseHTML:[{tag:"span",getAttrs:e=>{const t=e.style.backgroundColor;return!(!t||!a(t))&&{color:t}}}],sanitize:{tags:["span"]}})}registerCommands(e){e.registerCommand("removeHighlight",()=>l(e,e.getState(),"highlight"))}registerToolbarItem(e){const t=['<svg xmlns="http://www.w3.org/2000/svg"',' viewBox="0 0 24 24">','<path d="M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2zm-1.38 9L12 5.67 14.38 12H9.62z"/>','<rect x="3" y="17" width="18" height="6"',' rx="0.5" fill="#fff176"/>',"</svg>"].join("");e.registerToolbarItem({id:"highlight",group:"format",icon:t,label:this.locale.label,tooltip:this.locale.tooltip,command:"removeHighlight",popupType:"custom",renderPopup:(e,t,r)=>{c(e,t,{markType:"highlight",colors:this.colors,columns:10,resetLabel:this.locale.resetLabel,resetCommand:"removeHighlight",ariaLabelPrefix:this.locale.ariaLabelPrefix,onClose:r})},isActive:e=>f(e,"highlight")})}};export{g as n,m as r,p as t};
|
|
2
|
+
//# sourceMappingURL=HighlightPlugin-bbAi6W6k.mjs.map
|