@notectl/core 1.0.4 → 1.0.6
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 +52 -148
- package/dist/chunks/AttrRegistry-DTsHyDVA.mjs +16 -0
- package/dist/chunks/AttrRegistry-DTsHyDVA.mjs.map +1 -0
- package/dist/chunks/Commands-DLP85Mp5.mjs +461 -0
- package/dist/chunks/Commands-DLP85Mp5.mjs.map +1 -0
- package/dist/chunks/Document-CI3iCwEP.mjs +177 -0
- package/dist/chunks/Document-CI3iCwEP.mjs.map +1 -0
- package/dist/chunks/HTMLUtils-0wvCRvJc.mjs +7 -0
- package/dist/chunks/HTMLUtils-0wvCRvJc.mjs.map +1 -0
- package/dist/chunks/NodeResolver-D68ZLXti.mjs +81 -0
- package/dist/chunks/NodeResolver-D68ZLXti.mjs.map +1 -0
- package/dist/chunks/NodeSpec-NZVvcCuH.mjs +8 -0
- package/dist/chunks/NodeSpec-NZVvcCuH.mjs.map +1 -0
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs +15 -0
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +1 -0
- package/dist/chunks/Selection-D5ZjXoB7.mjs +44 -0
- package/dist/chunks/Selection-D5ZjXoB7.mjs.map +1 -0
- package/dist/chunks/ToolbarItem-ugDymuXi.mjs +7 -0
- package/dist/chunks/ToolbarItem-ugDymuXi.mjs.map +1 -0
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs +398 -0
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs.map +1 -0
- package/dist/chunks/TypeBrands-C09nE2qO.mjs +27 -0
- package/dist/chunks/TypeBrands-C09nE2qO.mjs.map +1 -0
- package/dist/chunks/color-picker-Csf0wx5a.mjs +5 -0
- package/dist/chunks/color-picker-Csf0wx5a.mjs.map +1 -0
- package/dist/chunks/index-QvKiO9_4.mjs +538 -0
- package/dist/chunks/index-QvKiO9_4.mjs.map +1 -0
- package/dist/commands/Commands.d.ts +71 -0
- package/dist/commands/Commands.d.ts.map +1 -0
- package/dist/commands/PasteCommand.d.ts +9 -0
- package/dist/commands/PasteCommand.d.ts.map +1 -0
- package/dist/decorations/Decoration.d.ts +76 -0
- package/dist/decorations/Decoration.d.ts.map +1 -0
- package/dist/decorations/PositionMapping.d.ts +9 -0
- package/dist/decorations/PositionMapping.d.ts.map +1 -0
- package/dist/editor/Announcer.d.ts +12 -0
- package/dist/editor/Announcer.d.ts.map +1 -0
- package/dist/editor/DocumentParser.d.ts +5 -0
- package/dist/editor/DocumentParser.d.ts.map +1 -0
- package/dist/editor/DocumentSerializer.d.ts +5 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -0
- package/dist/editor/EditorDOM.d.ts +18 -0
- package/dist/editor/EditorDOM.d.ts.map +1 -0
- package/dist/editor/EditorThemeController.d.ts +21 -0
- package/dist/editor/EditorThemeController.d.ts.map +1 -0
- package/dist/editor/NotectlEditor.d.ts +135 -0
- package/dist/editor/NotectlEditor.d.ts.map +1 -0
- package/dist/editor/styles/base.d.ts +3 -0
- package/dist/editor/styles/base.d.ts.map +1 -0
- package/dist/editor/styles/code-block.d.ts +3 -0
- package/dist/editor/styles/code-block.d.ts.map +1 -0
- package/dist/editor/styles/color-picker.d.ts +3 -0
- package/dist/editor/styles/color-picker.d.ts.map +1 -0
- package/dist/editor/styles/font-select.d.ts +3 -0
- package/dist/editor/styles/font-select.d.ts.map +1 -0
- package/dist/editor/styles/font-size-select.d.ts +3 -0
- package/dist/editor/styles/font-size-select.d.ts.map +1 -0
- package/dist/editor/styles/heading-select.d.ts +3 -0
- package/dist/editor/styles/heading-select.d.ts.map +1 -0
- package/dist/editor/styles/image.d.ts +3 -0
- package/dist/editor/styles/image.d.ts.map +1 -0
- package/dist/editor/styles/list.d.ts +3 -0
- package/dist/editor/styles/list.d.ts.map +1 -0
- package/dist/editor/styles/reduced-motion.d.ts +3 -0
- package/dist/editor/styles/reduced-motion.d.ts.map +1 -0
- package/dist/editor/styles/table.d.ts +3 -0
- package/dist/editor/styles/table.d.ts.map +1 -0
- package/dist/editor/styles/toolbar.d.ts +3 -0
- package/dist/editor/styles/toolbar.d.ts.map +1 -0
- package/dist/editor/styles.d.ts +12 -0
- package/dist/editor/styles.d.ts.map +1 -0
- package/dist/editor/theme/ThemeEngine.d.ts +6 -0
- package/dist/editor/theme/ThemeEngine.d.ts.map +1 -0
- package/dist/editor/theme/ThemeTokens.d.ts +73 -0
- package/dist/editor/theme/ThemeTokens.d.ts.map +1 -0
- package/dist/fonts.d.ts +17 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.mjs +7 -0
- package/dist/fonts.mjs.map +1 -0
- package/dist/index.d.ts +83 -2360
- package/dist/index.d.ts.map +1 -0
- package/dist/input/ClipboardHandler.d.ts +29 -0
- package/dist/input/ClipboardHandler.d.ts.map +1 -0
- package/dist/input/InputHandler.d.ts +32 -0
- package/dist/input/InputHandler.d.ts.map +1 -0
- package/dist/input/InputRule.d.ts +9 -0
- package/dist/input/InputRule.d.ts.map +1 -0
- package/dist/input/InternalClipboard.d.ts +23 -0
- package/dist/input/InternalClipboard.d.ts.map +1 -0
- package/dist/input/KeyboardHandler.d.ts +42 -0
- package/dist/input/KeyboardHandler.d.ts.map +1 -0
- package/dist/input/Keymap.d.ts +11 -0
- package/dist/input/Keymap.d.ts.map +1 -0
- package/dist/input/PasteHandler.d.ts +38 -0
- package/dist/input/PasteHandler.d.ts.map +1 -0
- package/dist/input/SourceNormalizer.d.ts +7 -0
- package/dist/input/SourceNormalizer.d.ts.map +1 -0
- package/dist/model/AttrRegistry.d.ts +39 -0
- package/dist/model/AttrRegistry.d.ts.map +1 -0
- package/dist/model/BuiltinSpecs.d.ts +4 -0
- package/dist/model/BuiltinSpecs.d.ts.map +1 -0
- package/dist/model/ContentModel.d.ts +12 -0
- package/dist/model/ContentModel.d.ts.map +1 -0
- package/dist/model/ContentSlice.d.ts +17 -0
- package/dist/model/ContentSlice.d.ts.map +1 -0
- package/dist/model/Document.d.ts +127 -0
- package/dist/model/Document.d.ts.map +1 -0
- package/dist/model/HTMLParser.d.ts +36 -0
- package/dist/model/HTMLParser.d.ts.map +1 -0
- package/dist/model/HTMLUtils.d.ts +6 -0
- package/dist/model/HTMLUtils.d.ts.map +1 -0
- package/dist/model/InlineNodeSpec.d.ts +20 -0
- package/dist/model/InlineNodeSpec.d.ts.map +1 -0
- package/dist/model/MarkSpec.d.ts +22 -0
- package/dist/model/MarkSpec.d.ts.map +1 -0
- package/dist/model/NodeResolver.d.ts +36 -0
- package/dist/model/NodeResolver.d.ts.map +1 -0
- package/dist/model/NodeSpec.d.ts +67 -0
- package/dist/model/NodeSpec.d.ts.map +1 -0
- package/dist/model/ParseRule.d.ts +11 -0
- package/dist/model/ParseRule.d.ts.map +1 -0
- package/dist/model/SanitizeConfig.d.ts +9 -0
- package/dist/model/SanitizeConfig.d.ts.map +1 -0
- package/dist/model/Schema.d.ts +17 -0
- package/dist/model/Schema.d.ts.map +1 -0
- package/dist/model/SchemaRegistry.d.ts +81 -0
- package/dist/model/SchemaRegistry.d.ts.map +1 -0
- package/dist/model/Selection.d.ts +52 -0
- package/dist/model/Selection.d.ts.map +1 -0
- package/dist/model/TypeBrands.d.ts +28 -0
- package/dist/model/TypeBrands.d.ts.map +1 -0
- package/dist/notectl-core.mjs +2715 -11109
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +6894 -0
- package/dist/notectl-core.umd.js.map +1 -0
- package/dist/plugins/EventBus.d.ts +13 -0
- package/dist/plugins/EventBus.d.ts.map +1 -0
- package/dist/plugins/Plugin.d.ts +85 -0
- package/dist/plugins/Plugin.d.ts.map +1 -0
- package/dist/plugins/PluginManager.d.ts +68 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts +48 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -0
- package/dist/plugins/alignment/index.d.ts +2 -0
- package/dist/plugins/alignment/index.d.ts.map +1 -0
- package/dist/plugins/alignment.mjs +92 -0
- package/dist/plugins/alignment.mjs.map +1 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts +30 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -0
- package/dist/plugins/blockquote/index.d.ts +2 -0
- package/dist/plugins/blockquote/index.d.ts.map +1 -0
- package/dist/plugins/blockquote.mjs +58 -0
- package/dist/plugins/blockquote.mjs.map +1 -0
- package/dist/plugins/code-block/CodeBlockCommands.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockCommands.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts +10 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +27 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockService.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockService.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +69 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -0
- package/dist/plugins/code-block/index.d.ts +2 -0
- package/dist/plugins/code-block/index.d.ts.map +1 -0
- package/dist/plugins/code-block.mjs +6 -0
- package/dist/plugins/code-block.mjs.map +1 -0
- package/dist/plugins/font/FontPlugin.d.ts +85 -0
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -0
- package/dist/plugins/font/StarterFonts.d.ts +10 -0
- package/dist/plugins/font/StarterFonts.d.ts.map +1 -0
- package/dist/plugins/font/index.d.ts +2 -0
- package/dist/plugins/font/index.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizeOperations.d.ts +22 -0
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts +56 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts +9 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -0
- package/dist/plugins/font-size/index.d.ts +2 -0
- package/dist/plugins/font-size/index.d.ts.map +1 -0
- package/dist/plugins/font-size.mjs +204 -0
- package/dist/plugins/font-size.mjs.map +1 -0
- package/dist/plugins/font.mjs +186 -0
- package/dist/plugins/font.mjs.map +1 -0
- package/dist/plugins/hard-break/HardBreakPlugin.d.ts +16 -0
- package/dist/plugins/hard-break/HardBreakPlugin.d.ts.map +1 -0
- package/dist/plugins/hard-break/index.d.ts +2 -0
- package/dist/plugins/hard-break/index.d.ts.map +1 -0
- package/dist/plugins/hard-break.mjs +28 -0
- package/dist/plugins/hard-break.mjs.map +1 -0
- package/dist/plugins/heading/BlockTypePickerEntry.d.ts +20 -0
- package/dist/plugins/heading/BlockTypePickerEntry.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +78 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -0
- package/dist/plugins/heading/index.d.ts +3 -0
- package/dist/plugins/heading/index.d.ts.map +1 -0
- package/dist/plugins/heading.mjs +188 -0
- package/dist/plugins/heading.mjs.map +1 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts +37 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -0
- package/dist/plugins/highlight/index.d.ts +2 -0
- package/dist/plugins/highlight/index.d.ts.map +1 -0
- package/dist/plugins/highlight.mjs +126 -0
- package/dist/plugins/highlight.mjs.map +1 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +29 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule/index.d.ts +2 -0
- package/dist/plugins/horizontal-rule/index.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule.mjs +59 -0
- package/dist/plugins/horizontal-rule.mjs.map +1 -0
- package/dist/plugins/image/ImageCommands.d.ts +26 -0
- package/dist/plugins/image/ImageCommands.d.ts.map +1 -0
- package/dist/plugins/image/ImageNodeView.d.ts +6 -0
- package/dist/plugins/image/ImageNodeView.d.ts.map +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts +43 -0
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -0
- package/dist/plugins/image/ImageUpload.d.ts +48 -0
- package/dist/plugins/image/ImageUpload.d.ts.map +1 -0
- package/dist/plugins/image/index.d.ts +3 -0
- package/dist/plugins/image/index.d.ts.map +1 -0
- package/dist/plugins/image.mjs +381 -0
- package/dist/plugins/image.mjs.map +1 -0
- package/dist/plugins/link/LinkPlugin.d.ts +32 -0
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -0
- package/dist/plugins/link/index.d.ts +2 -0
- package/dist/plugins/link/index.d.ts.map +1 -0
- package/dist/plugins/link.mjs +127 -0
- package/dist/plugins/link.mjs.map +1 -0
- package/dist/plugins/list/ListPlugin.d.ts +51 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -0
- package/dist/plugins/list/index.d.ts +2 -0
- package/dist/plugins/list/index.d.ts.map +1 -0
- package/dist/plugins/list.mjs +193 -0
- package/dist/plugins/list.mjs.map +1 -0
- package/dist/plugins/print/PrintContentPreparer.d.ts +12 -0
- package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts +12 -0
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -0
- package/dist/plugins/print/PrintServiceImpl.d.ts +7 -0
- package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts +10 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -0
- package/dist/plugins/print/PrintTypes.d.ts +56 -0
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +23 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -0
- package/dist/plugins/strikethrough/index.d.ts +2 -0
- package/dist/plugins/strikethrough/index.d.ts.map +1 -0
- package/dist/plugins/strikethrough.mjs +35 -0
- package/dist/plugins/strikethrough.mjs.map +1 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts +44 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -0
- package/dist/plugins/super-sub/index.d.ts +2 -0
- package/dist/plugins/super-sub/index.d.ts.map +1 -0
- package/dist/plugins/super-sub.mjs +81 -0
- package/dist/plugins/super-sub.mjs.map +1 -0
- package/dist/plugins/table/TableCommands.d.ts +50 -0
- package/dist/plugins/table/TableCommands.d.ts.map +1 -0
- package/dist/plugins/table/TableControls.d.ts +10 -0
- package/dist/plugins/table/TableControls.d.ts.map +1 -0
- package/dist/plugins/table/TableControlsDOM.d.ts +18 -0
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -0
- package/dist/plugins/table/TableControlsLayout.d.ts +34 -0
- package/dist/plugins/table/TableControlsLayout.d.ts.map +1 -0
- package/dist/plugins/table/TableHelpers.d.ts +39 -0
- package/dist/plugins/table/TableHelpers.d.ts.map +1 -0
- package/dist/plugins/table/TableNavigation.d.ts +4 -0
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -0
- package/dist/plugins/table/TableNodeViews.d.ts +18 -0
- package/dist/plugins/table/TableNodeViews.d.ts.map +1 -0
- package/dist/plugins/table/TablePlugin.d.ts +39 -0
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -0
- package/dist/plugins/table/TableSelection.d.ts +26 -0
- package/dist/plugins/table/TableSelection.d.ts.map +1 -0
- package/dist/plugins/table/TableTestUtils.d.ts +45 -0
- package/dist/plugins/table/TableTestUtils.d.ts.map +1 -0
- package/dist/plugins/table/index.d.ts +4 -0
- package/dist/plugins/table/index.d.ts.map +1 -0
- package/dist/plugins/table.mjs +663 -0
- package/dist/plugins/table.mjs.map +1 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts +37 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -0
- package/dist/plugins/text-color/index.d.ts +2 -0
- package/dist/plugins/text-color/index.d.ts.map +1 -0
- package/dist/plugins/text-color.mjs +126 -0
- package/dist/plugins/text-color.mjs.map +1 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +34 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -0
- package/dist/plugins/text-formatting/index.d.ts +2 -0
- package/dist/plugins/text-formatting/index.d.ts.map +1 -0
- package/dist/plugins/text-formatting.mjs +52 -0
- package/dist/plugins/text-formatting.mjs.map +1 -0
- package/dist/plugins/toolbar/ToolbarItem.d.ts +66 -0
- package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarKeyboardNav.d.ts +25 -0
- package/dist/plugins/toolbar/ToolbarKeyboardNav.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +47 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts +25 -0
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarRenderers.d.ts +19 -0
- package/dist/plugins/toolbar/ToolbarRenderers.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarTooltip.d.ts +17 -0
- package/dist/plugins/toolbar/ToolbarTooltip.d.ts.map +1 -0
- package/dist/plugins/toolbar/index.d.ts +4 -0
- package/dist/plugins/toolbar/index.d.ts.map +1 -0
- package/dist/plugins/toolbar.mjs +8 -0
- package/dist/plugins/toolbar.mjs.map +1 -0
- package/dist/state/EditorState.d.ts +40 -0
- package/dist/state/EditorState.d.ts.map +1 -0
- package/dist/state/History.d.ts +38 -0
- package/dist/state/History.d.ts.map +1 -0
- package/dist/state/StepApplication.d.ts +5 -0
- package/dist/state/StepApplication.d.ts.map +1 -0
- package/dist/state/Transaction.d.ts +185 -0
- package/dist/state/Transaction.d.ts.map +1 -0
- package/dist/test/PluginTestUtils.d.ts +127 -0
- package/dist/test/PluginTestUtils.d.ts.map +1 -0
- package/dist/test/TestUtils.d.ts +153 -0
- package/dist/test/TestUtils.d.ts.map +1 -0
- package/dist/view/EditorView.d.ts +74 -0
- package/dist/view/EditorView.d.ts.map +1 -0
- package/dist/view/NodeView.d.ts +18 -0
- package/dist/view/NodeView.d.ts.map +1 -0
- package/dist/view/Reconciler.d.ts +23 -0
- package/dist/view/Reconciler.d.ts.map +1 -0
- package/dist/view/SelectionSync.d.ts +8 -0
- package/dist/view/SelectionSync.d.ts.map +1 -0
- package/package.json +112 -11
- package/dist/notectl-core.js +0 -1463
- package/dist/notectl-core.js.map +0 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { t } from "../chunks/Commands-DLP85Mp5.mjs";
|
|
2
|
+
import { b as n } from "../chunks/AttrRegistry-DTsHyDVA.mjs";
|
|
3
|
+
import { e, h as o, v as r } from "../chunks/Document-CI3iCwEP.mjs";
|
|
4
|
+
import { i, a as s, s as a } from "../chunks/Selection-D5ZjXoB7.mjs";
|
|
5
|
+
import { m as c } from "../chunks/TypeBrands-C09nE2qO.mjs";
|
|
6
|
+
import { a as l } from "../chunks/ToolbarPlugin-sJTiZr-S.mjs";
|
|
7
|
+
class f {
|
|
8
|
+
id = "font";
|
|
9
|
+
name = "Font";
|
|
10
|
+
priority = 22;
|
|
11
|
+
config;
|
|
12
|
+
injectedStyleElement = null;
|
|
13
|
+
context = null;
|
|
14
|
+
comboLabel = null;
|
|
15
|
+
constructor(t2) {
|
|
16
|
+
this.config = t2;
|
|
17
|
+
}
|
|
18
|
+
init(t2) {
|
|
19
|
+
t2.registerStyleSheet("\n/* Font Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--font {\n width: auto;\n min-width: 100px;\n max-width: 160px;\n padding: 0 8px;\n gap: 4px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n background: var(--notectl-bg);\n}\n\n.notectl-toolbar-btn--font:hover {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--font.notectl-toolbar-btn--active {\n background: var(--notectl-bg);\n border-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--font .notectl-toolbar-btn__icon {\n display: flex;\n align-items: center;\n gap: 4px;\n width: 100%;\n overflow: hidden;\n}\n\n.notectl-toolbar-btn--font .notectl-toolbar-btn__icon svg {\n display: none;\n}\n\n.notectl-font-select__label {\n flex: 1;\n font-size: 13px;\n font-weight: 500;\n color: var(--notectl-fg);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-align: left;\n line-height: 30px;\n}\n\n.notectl-font-select__arrow {\n flex-shrink: 0;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n line-height: 30px;\n}\n\n/* Font Picker Popup */\n.notectl-font-picker {\n min-width: 200px;\n max-height: 320px;\n overflow-y: auto;\n}\n\n.notectl-font-picker__list {\n padding: 4px 0;\n}\n\n.notectl-font-picker__item {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 7px 12px;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n line-height: 1.4;\n text-align: left;\n white-space: nowrap;\n font-family: inherit;\n transition: background 0.1s;\n}\n\n.notectl-font-picker__item:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-font-picker__item--active {\n background: var(--notectl-active-bg);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-font-picker__item--active:hover {\n background: var(--notectl-active-bg);\n}\n\n.notectl-font-picker__check {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n flex-shrink: 0;\n font-size: 13px;\n font-weight: 600;\n color: var(--notectl-primary-fg);\n}\n\n.notectl-font-picker__label {\n flex: 1;\n}\n\n.notectl-font-picker__separator {\n height: 1px;\n background: var(--notectl-border);\n margin: 4px 8px;\n}\n"), this.context = t2, this.registerMarkSpec(t2), this.registerCommands(t2), this.registerToolbarItem(t2), this.injectFontFaces();
|
|
20
|
+
}
|
|
21
|
+
destroy() {
|
|
22
|
+
this.injectedStyleElement?.remove(), this.injectedStyleElement = null, this.context = null, this.comboLabel = null;
|
|
23
|
+
}
|
|
24
|
+
onStateChange(t2, n2, e2) {
|
|
25
|
+
this.updateComboLabel(n2);
|
|
26
|
+
}
|
|
27
|
+
registerMarkSpec(t2) {
|
|
28
|
+
t2.registerMarkSpec({ type: "font", rank: 6, attrs: { family: { default: "" } }, toDOM(t3) {
|
|
29
|
+
const n2 = document.createElement("span"), e2 = t3.attrs?.family ?? "";
|
|
30
|
+
return e2 && (n2.style.fontFamily = e2), n2;
|
|
31
|
+
}, toHTMLString: (t3, n2) => {
|
|
32
|
+
const e2 = String(t3.attrs?.family ?? "");
|
|
33
|
+
return e2 ? `<span style="font-family: ${e2}">${n2}</span>` : n2;
|
|
34
|
+
}, parseHTML: [{ tag: "span", getAttrs: (t3) => {
|
|
35
|
+
const n2 = t3.style.fontFamily;
|
|
36
|
+
return !!n2 && { family: n2 };
|
|
37
|
+
} }], sanitize: { tags: ["span"] } });
|
|
38
|
+
}
|
|
39
|
+
registerCommands(t2) {
|
|
40
|
+
t2.registerCommand("removeFont", () => {
|
|
41
|
+
const n2 = t2.getState();
|
|
42
|
+
return this.removeFont(t2, n2);
|
|
43
|
+
}), t2.registerCommand("setFont", () => false);
|
|
44
|
+
}
|
|
45
|
+
get defaultFont() {
|
|
46
|
+
if (this.config.defaultFont) {
|
|
47
|
+
const t3 = this.config.fonts.find((t4) => t4.name === this.config.defaultFont);
|
|
48
|
+
if (t3) return t3;
|
|
49
|
+
}
|
|
50
|
+
const t2 = this.config.fonts[0];
|
|
51
|
+
if (!t2) throw new Error("FontPlugin: fonts list is empty");
|
|
52
|
+
return t2;
|
|
53
|
+
}
|
|
54
|
+
registerToolbarItem(t2) {
|
|
55
|
+
const n2 = `<span class="notectl-font-select__label" data-font-label>${this.defaultFont.name}</span><span class="notectl-font-select__arrow">▾</span>`;
|
|
56
|
+
t2.registerToolbarItem({ id: "font", group: "format", icon: n2, label: "Font", tooltip: "Font Family", command: "removeFont", priority: 5, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (t3, n3) => {
|
|
57
|
+
this.renderFontPopup(t3, n3);
|
|
58
|
+
}, isActive: (t3) => this.isFontActive(t3) });
|
|
59
|
+
}
|
|
60
|
+
updateComboLabel(t2) {
|
|
61
|
+
if (!this.comboLabel) {
|
|
62
|
+
const t3 = this.context?.getPluginContainer("top");
|
|
63
|
+
if (!t3) return;
|
|
64
|
+
if (this.comboLabel = t3.querySelector("[data-font-label]") ?? null, !this.comboLabel) return;
|
|
65
|
+
}
|
|
66
|
+
const n2 = this.getActiveFont(t2), e2 = this.resolveFontName(n2);
|
|
67
|
+
this.comboLabel.textContent = e2;
|
|
68
|
+
}
|
|
69
|
+
resolveFontName(t2) {
|
|
70
|
+
if (!t2) return this.defaultFont.name;
|
|
71
|
+
const n2 = this.config.fonts.find((n3) => n3.family === t2);
|
|
72
|
+
return n2?.name ?? (t2.split(",")[0] ?? "").trim().replace(/'/g, "");
|
|
73
|
+
}
|
|
74
|
+
isFontActive(t2) {
|
|
75
|
+
return null !== this.getActiveFont(t2);
|
|
76
|
+
}
|
|
77
|
+
getActiveFont(t2) {
|
|
78
|
+
const o2 = t2.selection;
|
|
79
|
+
if (i(o2)) return null;
|
|
80
|
+
if (s(o2)) {
|
|
81
|
+
if (t2.storedMarks) {
|
|
82
|
+
const e2 = t2.storedMarks.find((t3) => "font" === t3.type);
|
|
83
|
+
return e2 && n(e2, "font") ? e2.attrs.family ?? null : null;
|
|
84
|
+
}
|
|
85
|
+
const r3 = t2.getBlock(o2.anchor.blockId);
|
|
86
|
+
if (!r3) return null;
|
|
87
|
+
const i2 = e(r3, o2.anchor.offset).find((t3) => "font" === t3.type);
|
|
88
|
+
return i2 && n(i2, "font") ? i2.attrs.family ?? null : null;
|
|
89
|
+
}
|
|
90
|
+
const r2 = t2.getBlock(o2.anchor.blockId);
|
|
91
|
+
if (!r2) return null;
|
|
92
|
+
const a2 = e(r2, o2.anchor.offset).find((t3) => "font" === t3.type);
|
|
93
|
+
return a2 && n(a2, "font") ? a2.attrs.family ?? null : null;
|
|
94
|
+
}
|
|
95
|
+
applyFont(n2, o2, r2) {
|
|
96
|
+
const l2 = o2.selection;
|
|
97
|
+
if (i(l2)) return false;
|
|
98
|
+
if (s(l2)) {
|
|
99
|
+
const t2 = o2.getBlock(l2.anchor.blockId);
|
|
100
|
+
if (!t2) return false;
|
|
101
|
+
const i2 = [...(o2.storedMarks ?? e(t2, l2.anchor.offset)).filter((t3) => "font" !== t3.type), { type: c("font"), attrs: { family: r2 } }], s2 = o2.transaction("command").setStoredMarks(i2, o2.storedMarks).setSelection(l2).build();
|
|
102
|
+
return n2.dispatch(s2), true;
|
|
103
|
+
}
|
|
104
|
+
const f2 = a(l2, o2.getBlockOrder()), p = o2.transaction("command"), m = { type: c("font"), attrs: { family: r2 } };
|
|
105
|
+
return t(o2, f2, (t2, n3, e2) => {
|
|
106
|
+
const r3 = o2.getBlock(t2);
|
|
107
|
+
if (r3) {
|
|
108
|
+
const o3 = this.findFontMarkInRange(r3, n3, e2);
|
|
109
|
+
o3 && p.removeMark(t2, n3, e2, o3);
|
|
110
|
+
}
|
|
111
|
+
p.addMark(t2, n3, e2, m);
|
|
112
|
+
}), p.setSelection(l2), n2.dispatch(p.build()), true;
|
|
113
|
+
}
|
|
114
|
+
removeFont(n2, r2) {
|
|
115
|
+
const l2 = r2.selection;
|
|
116
|
+
if (i(l2)) return false;
|
|
117
|
+
if (s(l2)) {
|
|
118
|
+
const t2 = r2.getBlock(l2.anchor.blockId);
|
|
119
|
+
if (!t2) return false;
|
|
120
|
+
const i2 = r2.storedMarks ?? e(t2, l2.anchor.offset);
|
|
121
|
+
if (!o(i2, c("font"))) return false;
|
|
122
|
+
const s2 = i2.filter((t3) => "font" !== t3.type), a2 = r2.transaction("command").setStoredMarks(s2, r2.storedMarks).setSelection(l2).build();
|
|
123
|
+
return n2.dispatch(a2), true;
|
|
124
|
+
}
|
|
125
|
+
const f2 = a(l2, r2.getBlockOrder()), p = r2.transaction("command");
|
|
126
|
+
return t(r2, f2, (t2, n3, e2) => {
|
|
127
|
+
const o2 = r2.getBlock(t2);
|
|
128
|
+
if (o2) {
|
|
129
|
+
const r3 = this.findFontMarkInRange(o2, n3, e2);
|
|
130
|
+
r3 && p.removeMark(t2, n3, e2, r3);
|
|
131
|
+
}
|
|
132
|
+
}), p.setSelection(l2), n2.dispatch(p.build()), true;
|
|
133
|
+
}
|
|
134
|
+
findFontMarkInRange(t2, n2, e2) {
|
|
135
|
+
const o2 = r(t2);
|
|
136
|
+
let i2 = 0;
|
|
137
|
+
for (const t3 of o2) {
|
|
138
|
+
const o3 = i2 + t3.text.length;
|
|
139
|
+
if (o3 > n2 && i2 < e2) {
|
|
140
|
+
const n3 = t3.marks.find((t4) => "font" === t4.type);
|
|
141
|
+
if (n3) return n3;
|
|
142
|
+
}
|
|
143
|
+
i2 = o3;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
injectFontFaces() {
|
|
147
|
+
const t2 = [];
|
|
148
|
+
for (const n3 of this.config.fonts) if (n3.fontFaces?.length) for (const e2 of n3.fontFaces) {
|
|
149
|
+
const o2 = [`font-family: '${(n3.family.split(",")[0] ?? "").trim().replace(/'/g, "")}'`, `src: ${e2.src}`];
|
|
150
|
+
e2.weight && o2.push(`font-weight: ${e2.weight}`), e2.style && o2.push(`font-style: ${e2.style}`), o2.push(`font-display: ${e2.display ?? "swap"}`), t2.push(`@font-face {
|
|
151
|
+
${o2.join(";\n ")};
|
|
152
|
+
}`);
|
|
153
|
+
}
|
|
154
|
+
if (0 === t2.length) return;
|
|
155
|
+
const n2 = document.createElement("style");
|
|
156
|
+
n2.setAttribute("data-notectl-fonts", ""), n2.textContent = t2.join("\n\n"), document.head.appendChild(n2), this.injectedStyleElement = n2;
|
|
157
|
+
}
|
|
158
|
+
dismissPopup() {
|
|
159
|
+
const t2 = this.context?.getService(l);
|
|
160
|
+
t2?.closePopup();
|
|
161
|
+
}
|
|
162
|
+
renderFontPopup(t2, n2) {
|
|
163
|
+
t2.classList.add("notectl-font-picker");
|
|
164
|
+
const e2 = n2.getState(), o2 = this.getActiveFont(e2), r2 = this.defaultFont.family, i2 = document.createElement("div");
|
|
165
|
+
i2.className = "notectl-font-picker__list";
|
|
166
|
+
for (const t3 of this.config.fonts) {
|
|
167
|
+
const e3 = t3.family === r2, s2 = e3 && !o2 || o2 === t3.family, a2 = this.createFontItem(t3.name, t3.family, s2, (o3) => {
|
|
168
|
+
o3.preventDefault(), o3.stopPropagation(), e3 ? n2.executeCommand("removeFont") : this.applyFont(n2, n2.getState(), t3.family), this.dismissPopup();
|
|
169
|
+
});
|
|
170
|
+
t3.category && a2.setAttribute("data-category", t3.category), i2.appendChild(a2);
|
|
171
|
+
}
|
|
172
|
+
t2.appendChild(i2);
|
|
173
|
+
}
|
|
174
|
+
createFontItem(t2, n2, e2, o2) {
|
|
175
|
+
const r2 = document.createElement("button");
|
|
176
|
+
r2.type = "button", r2.className = "notectl-font-picker__item", e2 && r2.classList.add("notectl-font-picker__item--active");
|
|
177
|
+
const i2 = document.createElement("span");
|
|
178
|
+
i2.className = "notectl-font-picker__check", i2.textContent = e2 ? "✓" : "", r2.appendChild(i2);
|
|
179
|
+
const s2 = document.createElement("span");
|
|
180
|
+
return s2.className = "notectl-font-picker__label", s2.textContent = t2, n2 && (s2.style.fontFamily = n2), r2.appendChild(s2), r2.addEventListener("mousedown", o2), r2;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
export {
|
|
184
|
+
f as FontPlugin
|
|
185
|
+
};
|
|
186
|
+
//# sourceMappingURL=font.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font.mjs","sources":["../../src/plugins/font/FontPlugin.ts","../../src/editor/styles/font-select.ts"],"sourcesContent":["/**\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 { forEachBlockInRange } from '../../commands/Commands.js';\nimport { FONT_SELECT_CSS } from '../../editor/styles/font-select.js';\nimport { isMarkOfType } from '../../model/AttrRegistry.js';\nimport { getBlockMarksAtOffset, getTextChildren, hasMark } from '../../model/Document.js';\nimport type { BlockNode, Mark } from '../../model/Document.js';\nimport { isCollapsed, isNodeSelection, selectionRange } from '../../model/Selection.js';\nimport { markType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { ToolbarServiceKey } from '../toolbar/ToolbarPlugin.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\t/** When true, a separator is rendered after the font toolbar item. */\n\treadonly separatorAfter?: boolean;\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 injectedStyleElement: HTMLStyleElement | null = null;\n\tprivate context: PluginContext | null = null;\n\tprivate comboLabel: HTMLSpanElement | null = null;\n\n\tconstructor(config: FontConfig) {\n\t\tthis.config = config;\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tcontext.registerStyleSheet(FONT_SELECT_CSS);\n\t\tthis.context = context;\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerToolbarItem(context);\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\tthis.comboLabel = null;\n\t}\n\n\tonStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void {\n\t\tthis.updateComboLabel(newState);\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\tspan.style.fontFamily = family;\n\t\t\t\t}\n\t\t\t\treturn span;\n\t\t\t},\n\t\t\ttoHTMLString: (mark, content) => {\n\t\t\t\tconst family: string = String(mark.attrs?.family ?? '');\n\t\t\t\tif (!family) return content;\n\t\t\t\treturn `<span style=\"font-family: ${family}\">${content}</span>`;\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\treturn { family };\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 {\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\tconst first: FontDefinition | undefined = this.config.fonts[0];\n\t\tif (!first) throw new Error('FontPlugin: fonts list is empty');\n\t\treturn first;\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\t// The icon content renders as a combobox label + dropdown arrow.\n\t\t// The actual label text is updated via onStateChange → updateComboLabel.\n\t\tconst defaultName: string = this.defaultFont.name;\n\t\tconst label: string = `<span class=\"notectl-font-select__label\" data-font-label>${defaultName}</span>`;\n\t\tconst arrow = '<span class=\"notectl-font-select__arrow\">\\u25BE</span>';\n\t\tconst icon = `${label}${arrow}`;\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'font',\n\t\t\tgroup: 'format',\n\t\t\ticon,\n\t\t\tlabel: 'Font',\n\t\t\ttooltip: 'Font Family',\n\t\t\tcommand: 'removeFont',\n\t\t\tpriority: 5,\n\t\t\tpopupType: 'custom',\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\trenderPopup: (container, ctx) => {\n\t\t\t\tthis.renderFontPopup(container, ctx);\n\t\t\t},\n\t\t\tisActive: (state) => this.isFontActive(state),\n\t\t});\n\t}\n\n\tprivate updateComboLabel(state: EditorState): void {\n\t\t// Lazily find the label element in the DOM\n\t\tif (!this.comboLabel) {\n\t\t\tconst container: HTMLElement | undefined = this.context?.getPluginContainer('top');\n\t\t\tif (!container) return;\n\t\t\tthis.comboLabel = container.querySelector<HTMLSpanElement>('[data-font-label]') ?? null;\n\t\t\tif (!this.comboLabel) return;\n\t\t}\n\n\t\tconst activeFamily: string | null = this.getActiveFont(state);\n\t\tconst displayName: string = this.resolveFontName(activeFamily);\n\t\tthis.comboLabel.textContent = displayName;\n\t}\n\n\tprivate resolveFontName(family: string | null): string {\n\t\tif (!family) return this.defaultFont.name;\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 this.getActiveFont(state) !== null;\n\t}\n\n\tgetActiveFont(state: EditorState): string | null {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) return null;\n\n\t\tif (isCollapsed(sel)) {\n\t\t\tif (state.storedMarks) {\n\t\t\t\tconst mark = state.storedMarks.find((m) => m.type === 'font');\n\t\t\t\treturn mark && isMarkOfType(mark, 'font') ? (mark.attrs.family ?? null) : null;\n\t\t\t}\n\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\tif (!block) return null;\n\t\t\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\t\t\tconst mark = marks.find((m) => m.type === 'font');\n\t\t\treturn mark && isMarkOfType(mark, 'font') ? (mark.attrs.family ?? null) : null;\n\t\t}\n\n\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\tif (!block) return null;\n\t\tconst marks = getBlockMarksAtOffset(block, sel.anchor.offset);\n\t\tconst mark = marks.find((m) => m.type === 'font');\n\t\treturn mark && isMarkOfType(mark, 'font') ? (mark.attrs.family ?? null) : null;\n\t}\n\n\t// --- Font Application ---\n\n\tapplyFont(context: PluginContext, state: EditorState, family: string): boolean {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) return false;\n\n\t\tif (isCollapsed(sel)) {\n\t\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\t\tif (!anchorBlock) return false;\n\t\t\tconst currentMarks =\n\t\t\t\tstate.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\t\tconst withoutFont = currentMarks.filter((m) => m.type !== 'font');\n\t\t\tconst newMarks = [...withoutFont, { type: markType('font'), attrs: { family } }];\n\n\t\t\tconst tr = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t\t.setSelection(sel)\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst range = selectionRange(sel, state.getBlockOrder());\n\t\tconst builder = state.transaction('command');\n\t\tconst mark = { type: markType('font'), attrs: { family } };\n\n\t\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\t\tconst block = state.getBlock(blockId);\n\t\t\tif (block) {\n\t\t\t\tconst existing: Mark | undefined = this.findFontMarkInRange(block, from, to);\n\t\t\t\tif (existing) {\n\t\t\t\t\tbuilder.removeMark(blockId, from, to, existing);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbuilder.addMark(blockId, from, to, mark);\n\t\t});\n\n\t\tbuilder.setSelection(sel);\n\t\tcontext.dispatch(builder.build());\n\t\treturn true;\n\t}\n\n\tprivate removeFont(context: PluginContext, state: EditorState): boolean {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) return false;\n\n\t\tif (isCollapsed(sel)) {\n\t\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\t\tif (!anchorBlock) return false;\n\t\t\tconst currentMarks =\n\t\t\t\tstate.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\t\tif (!hasMark(currentMarks, markType('font'))) return false;\n\n\t\t\tconst newMarks = currentMarks.filter((m) => m.type !== 'font');\n\t\t\tconst tr = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t\t.setSelection(sel)\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst range = selectionRange(sel, state.getBlockOrder());\n\t\tconst builder = state.transaction('command');\n\n\t\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\t\tconst block = state.getBlock(blockId);\n\t\t\tif (block) {\n\t\t\t\tconst existing: Mark | undefined = this.findFontMarkInRange(block, from, to);\n\t\t\t\tif (existing) {\n\t\t\t\t\tbuilder.removeMark(blockId, from, to, existing);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tbuilder.setSelection(sel);\n\t\tcontext.dispatch(builder.build());\n\t\treturn true;\n\t}\n\n\t/** Finds the first font mark in a block's text range (for proper step inversion). */\n\tprivate findFontMarkInRange(block: BlockNode, from: number, to: number): Mark | undefined {\n\t\tconst textChildren = getTextChildren(block);\n\t\tlet pos = 0;\n\t\tfor (const node of textChildren) {\n\t\t\tconst nodeEnd: number = pos + node.text.length;\n\t\t\tif (nodeEnd > from && pos < to) {\n\t\t\t\tconst fontMark: Mark | undefined = node.marks.find((m) => m.type === 'font');\n\t\t\t\tif (fontMark) return fontMark;\n\t\t\t}\n\t\t\tpos = nodeEnd;\n\t\t}\n\t\treturn undefined;\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\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 dismissPopup(): void {\n\t\tconst toolbar = this.context?.getService(ToolbarServiceKey);\n\t\ttoolbar?.closePopup();\n\t}\n\n\tprivate renderFontPopup(container: HTMLElement, context: PluginContext): 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 = this.defaultFont.family;\n\n\t\tconst list: HTMLDivElement = document.createElement('div');\n\t\tlist.className = 'notectl-font-picker__list';\n\n\t\tfor (const font of this.config.fonts) {\n\t\t\tconst isDefault: boolean = 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\tthis.dismissPopup();\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\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\tlabel.style.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","/** Font picker toolbar combobox + popup styles. */\nexport const FONT_SELECT_CSS = `\n/* Font Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--font {\n\twidth: auto;\n\tmin-width: 100px;\n\tmax-width: 160px;\n\tpadding: 0 8px;\n\tgap: 4px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-bg);\n}\n\n.notectl-toolbar-btn--font:hover {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--font.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-bg);\n\tborder-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--font .notectl-toolbar-btn__icon {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 4px;\n\twidth: 100%;\n\toverflow: hidden;\n}\n\n.notectl-toolbar-btn--font .notectl-toolbar-btn__icon svg {\n\tdisplay: none;\n}\n\n.notectl-font-select__label {\n\tflex: 1;\n\tfont-size: 13px;\n\tfont-weight: 500;\n\tcolor: var(--notectl-fg);\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\ttext-align: left;\n\tline-height: 30px;\n}\n\n.notectl-font-select__arrow {\n\tflex-shrink: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tline-height: 30px;\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: left;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n.notectl-font-picker__item:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-font-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-font-picker__item--active:hover {\n\tbackground: var(--notectl-active-bg);\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"],"names":["FontPlugin","id","name","priority","config","injectedStyleElement","context","comboLabel","this","registerStyleSheet","registerMarkSpec","registerCommands","registerToolbarItem","injectFontFaces","destroy","remove","_oldState","newState","_tr","updateComboLabel","type","rank","attrs","family","default","mark","span","document","createElement","style","fontFamily","toHTMLString","content","String","parseHTML","tag","getAttrs","el","sanitize","tags","registerCommand","state","getState","removeFont","defaultFont","found","fonts","find","f","first","Error","icon","group","label","tooltip","command","popupType","separatorAfter","renderPopup","container","ctx","renderFontPopup","isActive","isFontActive","getPluginContainer","querySelector","activeFamily","getActiveFont","displayName","resolveFontName","textContent","match","split","trim","replace","sel","selection","isNodeSelection","isCollapsed","storedMarks","m","isMarkOfType","block","getBlock","anchor","blockId","getBlockMarksAtOffset","offset","anchorBlock","newMarks","filter","markType","tr","transaction","setStoredMarks","setSelection","build","dispatch","range","selectionRange","getBlockOrder","builder","forEachBlockInRange","from","to","existing","findFontMarkInRange","removeMark","addMark","currentMarks","hasMark","textChildren","getTextChildren","pos","node","nodeEnd","text","length","fontMark","marks","rules","font","fontFaces","face","declarations","src","weight","push","display","join","setAttribute","head","appendChild","dismissPopup","toolbar","getService","ToolbarServiceKey","closePopup","classList","add","activeFont","defaultFamily","list","className","isDefault","item","createFontItem","e","preventDefault","stopPropagation","executeCommand","applyFont","category","handler","check","addEventListener"],"mappings":";;;;;;AAgFO,MAAMA,EAAAA;AAAAA,EACHC,KAAK;AAAA,EACLC,OAAO;A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,SAASC,cAAc,QAAA;AACvDqH,IAAAA,GAAK7H,OAAO,UACZ6H,GAAKF,YAAY,6BAEbjF,MACHmF,GAAKP,UAAUC,IAAI,mCAAA;AAIpB,UAAMe,KAAyB/H,SAASC,cAAc,MAAA;AACtD8H,IAAAA,GAAMX,YAAY,8BAClBW,GAAMpF,cAAcR,KAAW,MAAW,IAC1CmF,GAAKb,YAAYsB,EAAAA;AAGjB,UAAMrG,KAAyB1B,SAASC,cAAc,MAAA;AAStD,WARAyB,GAAM0F,YAAY,8BAClB1F,GAAMiB,cAAcpE,IAChBqB,OACH8B,GAAMxB,MAAMC,aAAaP,KAE1B0H,GAAKb,YAAY/E,EAAAA,GAEjB4F,GAAKU,iBAAiB,aAAaF,EAAAA,GAC5BR;AAAAA,EACR;AAAA;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Plugin, PluginContext } from '../Plugin.js';
|
|
2
|
+
declare module '../../model/AttrRegistry.js' {
|
|
3
|
+
interface InlineNodeAttrRegistry {
|
|
4
|
+
hard_break: Record<string, never>;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare class HardBreakPlugin implements Plugin {
|
|
8
|
+
readonly id = "hard-break";
|
|
9
|
+
readonly name = "Hard Break";
|
|
10
|
+
readonly priority = 10;
|
|
11
|
+
init(context: PluginContext): void;
|
|
12
|
+
private registerInlineNodeSpec;
|
|
13
|
+
private registerCommands;
|
|
14
|
+
private registerKeymap;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=HardBreakPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HardBreakPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/hard-break/HardBreakPlugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI1D,OAAO,QAAQ,6BAA6B,CAAC;IAC5C,UAAU,sBAAsB;QAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;KAClC;CACD;AAID,qBAAa,eAAgB,YAAW,MAAM;IAC7C,QAAQ,CAAC,EAAE,gBAAgB;IAC3B,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,QAAQ,MAAM;IAEvB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAMlC,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,cAAc;CAWtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/hard-break/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { l as e } from "../chunks/Commands-DLP85Mp5.mjs";
|
|
2
|
+
class r {
|
|
3
|
+
id = "hard-break";
|
|
4
|
+
name = "Hard Break";
|
|
5
|
+
priority = 10;
|
|
6
|
+
init(e2) {
|
|
7
|
+
this.registerInlineNodeSpec(e2), this.registerCommands(e2), this.registerKeymap(e2);
|
|
8
|
+
}
|
|
9
|
+
registerInlineNodeSpec(e2) {
|
|
10
|
+
e2.registerInlineNodeSpec({ type: "hard_break", toDOM: () => document.createElement("br"), toHTMLString: () => "<br>", parseHTML: [{ tag: "br" }], sanitize: { tags: ["br"] } });
|
|
11
|
+
}
|
|
12
|
+
registerCommands(r2) {
|
|
13
|
+
r2.registerCommand("insertHardBreak", () => {
|
|
14
|
+
const t = r2.getState(), i = e(t);
|
|
15
|
+
return !!i && (r2.dispatch(i), true);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
registerKeymap(r2) {
|
|
19
|
+
r2.registerKeymap({ "Shift-Enter": () => {
|
|
20
|
+
const t = r2.getState(), i = e(t);
|
|
21
|
+
return !!i && (r2.dispatch(i), true);
|
|
22
|
+
} });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
r as HardBreakPlugin
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=hard-break.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hard-break.mjs","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"],"names":["HardBreakPlugin","id","name","priority","context","this","registerInlineNodeSpec","registerCommands","registerKeymap","type","toDOM","document","createElement","toHTMLString","parseHTML","tag","sanitize","tags","registerCommand","state","getState","tr","insertHardBreakCommand","dispatch"],"mappings":";AAkBO,MAAMA,EAAAA;AAAAA,EACHC,KAAK;AAAA,EACLC,OAAO;AAAA,EACPC,WAAW;AAAA,EAEpB,KAAKC,IAAAA;AACJC,SAAKC,uBAAuBF,EAAAA,GAC5BC,KAAKE,iBAAiBH,EAAAA,GACtBC,KAAKG,eAAeJ,EAAAA;AAAAA,EACrB;AAAA,EAEQ,uBAAuBA;AAC9BA,IAAAA,GAAQE,uBAAuB,EAC9BG,MAAM,cACNC,OAAA,MACQC,SAASC,cAAc,IAAA,GAE/BC,cAAA,MACQ,QAERC,WAAW,CAAC,EAAEC,KAAK,SACnBC,UAAU,EAAEC,MAAM,CAAC,IAAA,EAAA,EAAA,CAAA;AAAA,EAErB;AAAA,EAEQ,iBAAiBb;AACxBA,IAAAA,GAAQc,gBAAgB,mBAAmB,MAAA;AAC1C,YAAMC,IAAQf,GAAQgB,SAAAA,GAChBC,IAAKC,EAAuBH,CAAAA;AAClC,eAAKE,MACLjB,GAAQmB,SAASF,CAAAA,GAAAA;AAAAA,IACV,CAAA;AAAA,EAET;AAAA,EAEQ,eAAejB;AACtBA,IAAAA,GAAQI,eAAe,EACtB,eAAe,MAAA;AACd,YAAMW,IAAQf,GAAQgB,YAChBC,IAAKC,EAAuBH;AAClC,aAAA,CAAA,CAAKE,MACLjB,GAAQmB,SAASF,CAAAA,GAAAA;AAAAA;EAIpB;AAAA;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EditorState } from '../../state/EditorState.js';
|
|
2
|
+
export interface PickerEntryStyle {
|
|
3
|
+
readonly fontSize: string;
|
|
4
|
+
readonly fontWeight: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BlockTypePickerEntry {
|
|
7
|
+
/** Unique identifier, e.g. 'heading-1', 'footer'. */
|
|
8
|
+
readonly id: string;
|
|
9
|
+
/** Display label shown in the picker, e.g. 'Heading 1'. */
|
|
10
|
+
readonly label: string;
|
|
11
|
+
/** Command to execute when the entry is selected. */
|
|
12
|
+
readonly command: string;
|
|
13
|
+
/** Sort order — lower values appear first. */
|
|
14
|
+
readonly priority: number;
|
|
15
|
+
/** Optional styling for the label in the picker dropdown. */
|
|
16
|
+
readonly style?: PickerEntryStyle;
|
|
17
|
+
/** Returns true when this entry matches the current block type. */
|
|
18
|
+
isActive(state: EditorState): boolean;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=BlockTypePickerEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockTypePickerEntry.d.ts","sourceRoot":"","sources":["../../../src/plugins/heading/BlockTypePickerEntry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACpC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAClC,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC;CACtC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { EditorState } from '../../state/EditorState.js';
|
|
2
|
+
import { Transaction } from '../../state/Transaction.js';
|
|
3
|
+
import { Plugin, PluginContext } from '../Plugin.js';
|
|
4
|
+
import { BlockAlignment } from '../alignment/AlignmentPlugin.js';
|
|
5
|
+
declare module '../../model/AttrRegistry.js' {
|
|
6
|
+
interface NodeAttrRegistry {
|
|
7
|
+
heading: {
|
|
8
|
+
level: HeadingLevel;
|
|
9
|
+
align?: BlockAlignment;
|
|
10
|
+
};
|
|
11
|
+
title: {
|
|
12
|
+
align?: BlockAlignment;
|
|
13
|
+
};
|
|
14
|
+
subtitle: {
|
|
15
|
+
align?: BlockAlignment;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
20
|
+
export interface HeadingConfig {
|
|
21
|
+
/** Which heading levels to enable. Defaults to [1, 2, 3, 4, 5, 6]. */
|
|
22
|
+
readonly levels: readonly HeadingLevel[];
|
|
23
|
+
/** When true, a separator is rendered after the heading toolbar item. */
|
|
24
|
+
readonly separatorAfter?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare class HeadingPlugin implements Plugin {
|
|
27
|
+
readonly id = "heading";
|
|
28
|
+
readonly name = "Heading";
|
|
29
|
+
readonly priority = 30;
|
|
30
|
+
private readonly config;
|
|
31
|
+
private context;
|
|
32
|
+
private comboLabel;
|
|
33
|
+
constructor(config?: Partial<HeadingConfig>);
|
|
34
|
+
init(context: PluginContext): void;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
onStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void;
|
|
37
|
+
private registerNodeSpecs;
|
|
38
|
+
private registerCommands;
|
|
39
|
+
private registerKeymaps;
|
|
40
|
+
private registerInputRules;
|
|
41
|
+
private registerPickerEntries;
|
|
42
|
+
private registerToolbarItem;
|
|
43
|
+
private updateComboLabel;
|
|
44
|
+
private getActiveLabel;
|
|
45
|
+
private dismissPopup;
|
|
46
|
+
private renderHeadingPopup;
|
|
47
|
+
private createPickerItem;
|
|
48
|
+
private static readonly HEADING_TYPES;
|
|
49
|
+
/**
|
|
50
|
+
* Handles Enter inside a heading block.
|
|
51
|
+
* Empty heading → convert to paragraph.
|
|
52
|
+
* Cursor at end → split and convert new block to paragraph.
|
|
53
|
+
* Cursor in middle → normal split (both stay heading).
|
|
54
|
+
*/
|
|
55
|
+
private handleEnter;
|
|
56
|
+
/**
|
|
57
|
+
* Toggles between a special block type (title/subtitle) and paragraph.
|
|
58
|
+
* If the block is already that type, resets to paragraph.
|
|
59
|
+
*/
|
|
60
|
+
private toggleSpecialBlock;
|
|
61
|
+
/**
|
|
62
|
+
* Toggles between heading (at given level) and paragraph.
|
|
63
|
+
* If the block is already a heading at the same level, resets to paragraph.
|
|
64
|
+
*/
|
|
65
|
+
private toggleHeading;
|
|
66
|
+
private setBlockType;
|
|
67
|
+
/**
|
|
68
|
+
* Adds removeMark steps for each excluded mark type found
|
|
69
|
+
* on the block's inline text content.
|
|
70
|
+
*/
|
|
71
|
+
private stripExcludedMarks;
|
|
72
|
+
/**
|
|
73
|
+
* Clears excluded mark types from stored marks so that
|
|
74
|
+
* subsequent typing does not reintroduce them.
|
|
75
|
+
*/
|
|
76
|
+
private clearExcludedStoredMarks;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=HeadingPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeadingPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/heading/HeadingPlugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,4BAA4B,CAAC;AAClF,OAAO,KAAK,EAAE,MAAM,EAAE,a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OAAO,CAAC,qBAAqB;IAuD7B,OAAO,CAAC,mBAAmB;IAyB3B,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,kBAAkB;IAgC1B,OAAO,CAAC,gBAAgB;IAoCxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAIlC;IAEH;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAyCnB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;;OAGG;IACH,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,YAAY;IA0BpB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IA4B1B;;;OAGG;IACH,OAAO,CAAC,wBAAwB;CAgBhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/heading/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,YAAY,GACjB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACX,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { p as t, g as e, b as n, j as o, k as r } from "../chunks/Document-CI3iCwEP.mjs";
|
|
2
|
+
import { c as i } from "../chunks/NodeSpec-NZVvcCuH.mjs";
|
|
3
|
+
import { i as l, a, c as s } from "../chunks/Selection-D5ZjXoB7.mjs";
|
|
4
|
+
import { n as c } from "../chunks/TypeBrands-C09nE2qO.mjs";
|
|
5
|
+
import { a as g } from "../chunks/ToolbarPlugin-sJTiZr-S.mjs";
|
|
6
|
+
const d = { levels: [1, 2, 3, 4, 5, 6] }, p = { 1: "h1", 2: "h2", 3: "h3", 4: "h4", 5: "h5", 6: "h6" }, h = { 1: "Heading 1", 2: "Heading 2", 3: "Heading 3", 4: "Heading 4", 5: "Heading 5", 6: "Heading 6" }, u = "Paragraph";
|
|
7
|
+
class b {
|
|
8
|
+
id = "heading";
|
|
9
|
+
name = "Heading";
|
|
10
|
+
priority = 30;
|
|
11
|
+
config;
|
|
12
|
+
context = null;
|
|
13
|
+
comboLabel = null;
|
|
14
|
+
constructor(t2) {
|
|
15
|
+
this.config = { ...d, ...t2 };
|
|
16
|
+
}
|
|
17
|
+
init(t2) {
|
|
18
|
+
t2.registerStyleSheet("\n/* Heading Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--heading {\n width: auto;\n min-width: 100px;\n max-width: 160px;\n padding: 0 8px;\n gap: 4px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n background: var(--notectl-bg);\n}\n\n.notectl-toolbar-btn--heading:hover {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--heading.notectl-toolbar-btn--active {\n background: var(--notectl-bg);\n border-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--heading .notectl-toolbar-btn__icon {\n display: flex;\n align-items: center;\n gap: 4px;\n width: 100%;\n overflow: hidden;\n}\n\n.notectl-toolbar-btn--heading .notectl-toolbar-btn__icon svg {\n display: none;\n}\n\n.notectl-heading-select__label {\n flex: 1;\n font-size: 13px;\n font-weight: 500;\n color: var(--notectl-fg);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-align: left;\n line-height: 30px;\n}\n\n.notectl-heading-select__arrow {\n flex-shrink: 0;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n line-height: 30px;\n}\n\n/* Heading Picker Popup */\n.notectl-heading-picker {\n min-width: 200px;\n max-height: 320px;\n overflow-y: auto;\n}\n\n.notectl-heading-picker__list {\n padding: 4px 0;\n}\n\n.notectl-heading-picker__item {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 7px 12px;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n text-align: left;\n white-space: nowrap;\n font-family: inherit;\n transition: background 0.1s;\n}\n\n.notectl-heading-picker__item:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-heading-picker__item--active {\n background: var(--notectl-active-bg);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__item--active:hover {\n background: var(--notectl-active-bg);\n}\n\n.notectl-heading-picker__check {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n flex-shrink: 0;\n font-size: 13px;\n font-weight: 600;\n color: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__label {\n flex: 1;\n}\n"), this.context = t2, this.registerNodeSpecs(t2), this.registerCommands(t2), this.registerKeymaps(t2), this.registerInputRules(t2), this.registerPickerEntries(t2), this.registerToolbarItem(t2);
|
|
19
|
+
}
|
|
20
|
+
destroy() {
|
|
21
|
+
this.context = null, this.comboLabel = null;
|
|
22
|
+
}
|
|
23
|
+
onStateChange(t2, e2, n2) {
|
|
24
|
+
this.updateComboLabel(e2);
|
|
25
|
+
}
|
|
26
|
+
registerNodeSpecs(t2) {
|
|
27
|
+
t2.registerNodeSpec({ type: "title", group: "block", content: { allow: ["text"] }, excludeMarks: ["fontSize"], toDOM(t3) {
|
|
28
|
+
const e2 = i("h1", t3.id);
|
|
29
|
+
return e2.classList.add("notectl-title"), e2;
|
|
30
|
+
}, toHTML: (t3, e2) => `<h1>${e2 || "<br>"}</h1>`, sanitize: { tags: ["h1"] } }), t2.registerNodeSpec({ type: "subtitle", group: "block", content: { allow: ["text"] }, excludeMarks: ["fontSize"], toDOM(t3) {
|
|
31
|
+
const e2 = i("h2", t3.id);
|
|
32
|
+
return e2.classList.add("notectl-subtitle"), e2;
|
|
33
|
+
}, toHTML: (t3, e2) => `<h2>${e2 || "<br>"}</h2>`, sanitize: { tags: ["h2"] } }), t2.registerNodeSpec({ type: "heading", group: "block", content: { allow: ["text"] }, excludeMarks: ["fontSize"], attrs: { level: { default: 1 } }, toDOM(t3) {
|
|
34
|
+
const e2 = t3.attrs?.level ?? 1;
|
|
35
|
+
return i(p[e2] ?? "h1", t3.id);
|
|
36
|
+
}, toHTML(t3, e2) {
|
|
37
|
+
const n2 = t3.attrs?.level ?? 1, o2 = p[n2] ?? "h1";
|
|
38
|
+
return `<${o2}>${e2 || "<br>"}</${o2}>`;
|
|
39
|
+
}, 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"] } });
|
|
40
|
+
}
|
|
41
|
+
registerCommands(t2) {
|
|
42
|
+
t2.registerCommand("setTitle", () => this.toggleSpecialBlock(t2, "title")), t2.registerCommand("setSubtitle", () => this.toggleSpecialBlock(t2, "subtitle"));
|
|
43
|
+
for (const e2 of this.config.levels) t2.registerCommand(`setHeading${e2}`, () => this.toggleHeading(t2, e2));
|
|
44
|
+
t2.registerCommand("toggleHeading", () => this.toggleHeading(t2, 1)), t2.registerCommand("setParagraph", () => this.setBlockType(t2, c("paragraph")));
|
|
45
|
+
}
|
|
46
|
+
registerKeymaps(t2) {
|
|
47
|
+
const e2 = { Enter: () => this.handleEnter(t2) };
|
|
48
|
+
for (const n2 of this.config.levels) n2 <= 6 && (e2[`Mod-Shift-${n2}`] = () => t2.executeCommand(`setHeading${n2}`));
|
|
49
|
+
t2.registerKeymap(e2);
|
|
50
|
+
}
|
|
51
|
+
registerInputRules(t2) {
|
|
52
|
+
for (const e2 of this.config.levels) {
|
|
53
|
+
const n2 = "#".repeat(e2), o2 = new RegExp(`^${n2} $`);
|
|
54
|
+
t2.registerInputRule({ pattern: o2, handler(t3, n3, o3, r2) {
|
|
55
|
+
const i2 = t3.selection;
|
|
56
|
+
if (l(i2)) return null;
|
|
57
|
+
if (!a(i2)) return null;
|
|
58
|
+
const g2 = t3.getBlock(i2.anchor.blockId);
|
|
59
|
+
return g2 && "paragraph" === g2.type ? t3.transaction("input").deleteTextAt(i2.anchor.blockId, o3, o3 + e2 + 1).setBlockType(i2.anchor.blockId, c("heading"), { level: e2 }).setSelection(s(i2.anchor.blockId, 0)).build() : null;
|
|
60
|
+
} });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
registerPickerEntries(t2) {
|
|
64
|
+
t2.registerBlockTypePickerEntry({ id: "paragraph", label: u, command: "setParagraph", priority: 10, isActive: (t3) => {
|
|
65
|
+
if (l(t3.selection)) return false;
|
|
66
|
+
const e2 = t3.getBlock(t3.selection.anchor.blockId);
|
|
67
|
+
return "paragraph" === e2?.type;
|
|
68
|
+
} }), t2.registerBlockTypePickerEntry({ id: "title", label: "Title", command: "setTitle", priority: 20, style: { fontSize: "1.6em", fontWeight: "700" }, isActive: (t3) => {
|
|
69
|
+
if (l(t3.selection)) return false;
|
|
70
|
+
const e2 = t3.getBlock(t3.selection.anchor.blockId);
|
|
71
|
+
return "title" === e2?.type;
|
|
72
|
+
} }), t2.registerBlockTypePickerEntry({ id: "subtitle", label: "Subtitle", command: "setSubtitle", priority: 30, style: { fontSize: "1.3em", fontWeight: "500" }, isActive: (t3) => {
|
|
73
|
+
if (l(t3.selection)) return false;
|
|
74
|
+
const e2 = t3.getBlock(t3.selection.anchor.blockId);
|
|
75
|
+
return "subtitle" === e2?.type;
|
|
76
|
+
} });
|
|
77
|
+
for (const e2 of this.config.levels) t2.registerBlockTypePickerEntry({ id: `heading-${e2}`, label: h[e2], command: `setHeading${e2}`, priority: 100 + e2, style: { fontSize: 1.4 - 0.1 * e2 + "em", fontWeight: "600" }, isActive: (t3) => {
|
|
78
|
+
if (l(t3.selection)) return false;
|
|
79
|
+
const n2 = t3.getBlock(t3.selection.anchor.blockId);
|
|
80
|
+
return "heading" === n2?.type && n2.attrs?.level === e2;
|
|
81
|
+
} });
|
|
82
|
+
}
|
|
83
|
+
registerToolbarItem(t2) {
|
|
84
|
+
const e2 = `<span class="notectl-heading-select__label" data-heading-label>${u}</span><span class="notectl-heading-select__arrow">▾</span>`;
|
|
85
|
+
t2.registerToolbarItem({ id: "heading", group: "block", icon: e2, label: "Block Type", tooltip: "Block Type", command: "setParagraph", priority: 50, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (t3, e3) => {
|
|
86
|
+
this.renderHeadingPopup(t3, e3);
|
|
87
|
+
}, isActive: (e3) => t2.getSchemaRegistry().getBlockTypePickerEntries().some((t3) => "paragraph" !== t3.id && t3.isActive(e3)) });
|
|
88
|
+
}
|
|
89
|
+
updateComboLabel(t2) {
|
|
90
|
+
if (!this.comboLabel) {
|
|
91
|
+
const t3 = this.context?.getPluginContainer("top");
|
|
92
|
+
if (!t3) return;
|
|
93
|
+
if (this.comboLabel = t3.querySelector("[data-heading-label]") ?? null, !this.comboLabel) return;
|
|
94
|
+
}
|
|
95
|
+
this.comboLabel.textContent = this.getActiveLabel(t2);
|
|
96
|
+
}
|
|
97
|
+
getActiveLabel(t2) {
|
|
98
|
+
if (l(t2.selection)) return u;
|
|
99
|
+
const e2 = this.context?.getSchemaRegistry().getBlockTypePickerEntries() ?? [];
|
|
100
|
+
for (const n2 of e2) if (n2.isActive(t2)) return n2.label;
|
|
101
|
+
return u;
|
|
102
|
+
}
|
|
103
|
+
dismissPopup() {
|
|
104
|
+
const t2 = this.context?.getService(g);
|
|
105
|
+
t2?.closePopup();
|
|
106
|
+
}
|
|
107
|
+
renderHeadingPopup(t2, e2) {
|
|
108
|
+
t2.classList.add("notectl-heading-picker");
|
|
109
|
+
const n2 = e2.getState();
|
|
110
|
+
if (l(n2.selection)) return;
|
|
111
|
+
const o2 = document.createElement("div");
|
|
112
|
+
o2.className = "notectl-heading-picker__list", o2.setAttribute("role", "listbox"), o2.setAttribute("aria-label", "Block types");
|
|
113
|
+
const r2 = e2.getSchemaRegistry().getBlockTypePickerEntries();
|
|
114
|
+
for (const t3 of r2) {
|
|
115
|
+
const r3 = t3.isActive(n2);
|
|
116
|
+
o2.appendChild(this.createPickerItem(t3.label, r3, (n3) => {
|
|
117
|
+
n3.preventDefault(), n3.stopPropagation(), e2.executeCommand(t3.command), this.dismissPopup();
|
|
118
|
+
}, t3.style));
|
|
119
|
+
}
|
|
120
|
+
t2.appendChild(o2);
|
|
121
|
+
}
|
|
122
|
+
createPickerItem(t2, e2, n2, o2) {
|
|
123
|
+
const r2 = document.createElement("button");
|
|
124
|
+
r2.type = "button", r2.className = "notectl-heading-picker__item", r2.setAttribute("role", "option"), r2.setAttribute("aria-selected", String(e2)), e2 && r2.classList.add("notectl-heading-picker__item--active");
|
|
125
|
+
const i2 = document.createElement("span");
|
|
126
|
+
i2.className = "notectl-heading-picker__check", i2.textContent = e2 ? "✓" : "", r2.appendChild(i2);
|
|
127
|
+
const l2 = document.createElement("span");
|
|
128
|
+
return l2.className = "notectl-heading-picker__label", l2.textContent = t2, o2 && (l2.style.fontSize = o2.fontSize, l2.style.fontWeight = o2.fontWeight), r2.appendChild(l2), r2.addEventListener("mousedown", n2), r2;
|
|
129
|
+
}
|
|
130
|
+
static HEADING_TYPES = /* @__PURE__ */ new Set(["heading", "title", "subtitle"]);
|
|
131
|
+
handleEnter(o2) {
|
|
132
|
+
const r2 = o2.getState(), i2 = r2.selection;
|
|
133
|
+
if (l(i2)) return false;
|
|
134
|
+
if (!a(i2)) return false;
|
|
135
|
+
const g2 = r2.getBlock(i2.anchor.blockId);
|
|
136
|
+
if (!g2 || !b.HEADING_TYPES.has(g2.type)) return false;
|
|
137
|
+
if ("" === t(g2)) {
|
|
138
|
+
const t2 = r2.transaction("input").setBlockType(i2.anchor.blockId, c("paragraph")).setSelection(i2).build();
|
|
139
|
+
return o2.dispatch(t2), true;
|
|
140
|
+
}
|
|
141
|
+
const d2 = e(g2);
|
|
142
|
+
if (i2.anchor.offset >= d2) {
|
|
143
|
+
const t2 = n(), e2 = r2.transaction("input").splitBlock(i2.anchor.blockId, i2.anchor.offset, t2).setBlockType(t2, c("paragraph")).setSelection(s(t2, 0)).build();
|
|
144
|
+
return o2.dispatch(e2), true;
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
toggleSpecialBlock(t2, e2) {
|
|
149
|
+
const n2 = t2.getState();
|
|
150
|
+
if (l(n2.selection)) return false;
|
|
151
|
+
const o2 = n2.getBlock(n2.selection.anchor.blockId);
|
|
152
|
+
return !!o2 && (o2.type === e2 ? this.setBlockType(t2, c("paragraph")) : this.setBlockType(t2, c(e2)));
|
|
153
|
+
}
|
|
154
|
+
toggleHeading(t2, e2) {
|
|
155
|
+
const n2 = t2.getState(), o2 = n2.selection;
|
|
156
|
+
if (l(o2)) return false;
|
|
157
|
+
const r2 = n2.getBlock(o2.anchor.blockId);
|
|
158
|
+
return !!r2 && ("heading" === r2.type && r2.attrs?.level === e2 ? this.setBlockType(t2, c("paragraph")) : this.setBlockType(t2, c("heading"), { level: e2 }));
|
|
159
|
+
}
|
|
160
|
+
setBlockType(t2, e2, n2) {
|
|
161
|
+
const o2 = t2.getState(), r2 = o2.selection;
|
|
162
|
+
if (l(r2)) return false;
|
|
163
|
+
const i2 = o2.getBlock(r2.anchor.blockId);
|
|
164
|
+
if (!i2) return false;
|
|
165
|
+
const a2 = o2.transaction("command"), s2 = t2.getSchemaRegistry().getNodeSpec(e2);
|
|
166
|
+
s2?.excludeMarks && s2.excludeMarks.length > 0 && (this.stripExcludedMarks(a2, i2, s2.excludeMarks), this.clearExcludedStoredMarks(a2, o2, s2.excludeMarks));
|
|
167
|
+
const c2 = a2.setBlockType(r2.anchor.blockId, e2, n2).setSelection(r2).build();
|
|
168
|
+
return t2.dispatch(c2), true;
|
|
169
|
+
}
|
|
170
|
+
stripExcludedMarks(t2, n2, i2) {
|
|
171
|
+
if (0 === e(n2)) return;
|
|
172
|
+
const l2 = new Set(i2), a2 = o(n2);
|
|
173
|
+
let s2 = 0;
|
|
174
|
+
for (const e2 of a2) if (r(e2)) {
|
|
175
|
+
if (e2.text.length > 0) for (const o2 of e2.marks) l2.has(o2.type) && t2.removeMark(n2.id, s2, s2 + e2.text.length, o2);
|
|
176
|
+
s2 += e2.text.length;
|
|
177
|
+
} else s2 += 1;
|
|
178
|
+
}
|
|
179
|
+
clearExcludedStoredMarks(t2, e2, n2) {
|
|
180
|
+
if (!e2.storedMarks) return;
|
|
181
|
+
const o2 = new Set(n2), r2 = e2.storedMarks.filter((t3) => !o2.has(t3.type));
|
|
182
|
+
r2.length !== e2.storedMarks.length && t2.setStoredMarks(r2.length > 0 ? r2 : null, e2.storedMarks);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
b as HeadingPlugin
|
|
187
|
+
};
|
|
188
|
+
//# sourceMappingURL=heading.mjs.map
|