@notectl/core 1.0.3 → 1.0.5
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 +51 -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-D5VqeBPT.mjs +398 -0
- package/dist/chunks/ToolbarPlugin-D5VqeBPT.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-CPPb-Jah.mjs +569 -0
- package/dist/chunks/index-CPPb-Jah.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 +131 -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 +81 -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 +2576 -11104
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +6810 -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 +66 -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/CodeBlockNodeView.d.ts +5 -0
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +135 -0
- package/dist/plugins/code-block/CodeBlockPlugin.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/FontSizePlugin.d.ts +65 -0
- package/dist/plugins/font-size/FontSizePlugin.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 +220 -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/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,135 @@
|
|
|
1
|
+
import { DecorationSet } from '../../decorations/Decoration.js';
|
|
2
|
+
import { BlockId } from '../../model/TypeBrands.js';
|
|
3
|
+
import { EditorState } from '../../state/EditorState.js';
|
|
4
|
+
import { Transaction } from '../../state/Transaction.js';
|
|
5
|
+
import { Plugin, PluginContext, ServiceKey } from '../Plugin.js';
|
|
6
|
+
declare module '../../model/AttrRegistry.js' {
|
|
7
|
+
interface NodeAttrRegistry {
|
|
8
|
+
code_block: {
|
|
9
|
+
language: string;
|
|
10
|
+
backgroundColor: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export interface SyntaxToken {
|
|
15
|
+
readonly from: number;
|
|
16
|
+
readonly to: number;
|
|
17
|
+
readonly type: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SyntaxHighlighter {
|
|
20
|
+
tokenize(code: string, language: string): readonly SyntaxToken[];
|
|
21
|
+
getSupportedLanguages(): readonly string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Configurable keyboard bindings for CodeBlockPlugin actions.
|
|
25
|
+
* Omit a slot to use the default; set to `null` to disable the binding.
|
|
26
|
+
*
|
|
27
|
+
* Key descriptor format: `'Mod-Enter'`, `'Mod-Shift-M'`, etc.
|
|
28
|
+
* `Mod` resolves to Cmd on macOS, Ctrl on Windows/Linux.
|
|
29
|
+
*/
|
|
30
|
+
export interface CodeBlockKeymap {
|
|
31
|
+
/**
|
|
32
|
+
* Insert a new paragraph below the code block and move the cursor there.
|
|
33
|
+
* @default 'Mod-Enter'
|
|
34
|
+
*/
|
|
35
|
+
readonly insertAfter?: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Toggle the current block between code block and paragraph.
|
|
38
|
+
* @default 'Mod-Shift-M'
|
|
39
|
+
*/
|
|
40
|
+
readonly toggle?: string | null;
|
|
41
|
+
}
|
|
42
|
+
export interface CodeBlockConfig {
|
|
43
|
+
readonly highlighter?: SyntaxHighlighter;
|
|
44
|
+
readonly defaultLanguage?: string;
|
|
45
|
+
readonly useSpaces?: boolean;
|
|
46
|
+
readonly spaceCount?: number;
|
|
47
|
+
readonly showCopyButton?: boolean;
|
|
48
|
+
readonly separatorAfter?: boolean;
|
|
49
|
+
/** Default body background color (overrides --notectl-code-block-bg). */
|
|
50
|
+
readonly background?: string;
|
|
51
|
+
/** Default header background color (overrides --notectl-code-block-header-bg). */
|
|
52
|
+
readonly headerBackground?: string;
|
|
53
|
+
/** Default text color (overrides --notectl-code-block-color). */
|
|
54
|
+
readonly textColor?: string;
|
|
55
|
+
/** Default header/label text color (overrides --notectl-code-block-header-color). */
|
|
56
|
+
readonly headerColor?: string;
|
|
57
|
+
/** Customize keyboard bindings for code block actions. */
|
|
58
|
+
readonly keymap?: CodeBlockKeymap;
|
|
59
|
+
}
|
|
60
|
+
export interface CodeBlockService {
|
|
61
|
+
setLanguage(blockId: BlockId, language: string): void;
|
|
62
|
+
getLanguage(blockId: BlockId): string;
|
|
63
|
+
setBackground(blockId: BlockId, color: string): void;
|
|
64
|
+
getBackground(blockId: BlockId): string;
|
|
65
|
+
isCodeBlock(blockId: BlockId): boolean;
|
|
66
|
+
getSupportedLanguages(): readonly string[];
|
|
67
|
+
}
|
|
68
|
+
export declare const CODE_BLOCK_SERVICE_KEY: ServiceKey<CodeBlockService>;
|
|
69
|
+
export declare class CodeBlockPlugin implements Plugin {
|
|
70
|
+
readonly id = "code-block";
|
|
71
|
+
readonly name = "Code Block";
|
|
72
|
+
readonly priority = 36;
|
|
73
|
+
private readonly config;
|
|
74
|
+
private readonly resolvedKeymap;
|
|
75
|
+
private context;
|
|
76
|
+
constructor(config?: Partial<CodeBlockConfig>);
|
|
77
|
+
init(context: PluginContext): void;
|
|
78
|
+
destroy(): void;
|
|
79
|
+
onStateChange(oldState: EditorState, newState: EditorState, _tr: Transaction): void;
|
|
80
|
+
decorations(state: EditorState): DecorationSet;
|
|
81
|
+
private registerNodeSpec;
|
|
82
|
+
private registerNodeView;
|
|
83
|
+
private registerCommands;
|
|
84
|
+
private registerKeymaps;
|
|
85
|
+
private registerInputRule;
|
|
86
|
+
private registerToolbarItem;
|
|
87
|
+
private registerMiddleware;
|
|
88
|
+
private registerService;
|
|
89
|
+
private patchTableCellContent;
|
|
90
|
+
/**
|
|
91
|
+
* Handles Backspace at the start of a code block.
|
|
92
|
+
* Converts the code block back to a paragraph, preserving text.
|
|
93
|
+
*/
|
|
94
|
+
private handleBackspace;
|
|
95
|
+
private handleEnter;
|
|
96
|
+
private handleTab;
|
|
97
|
+
private handleShiftTab;
|
|
98
|
+
private handleEscape;
|
|
99
|
+
/**
|
|
100
|
+
* Handles ArrowDown at the last line of a code block.
|
|
101
|
+
* Exits to the next block or creates a paragraph below.
|
|
102
|
+
*/
|
|
103
|
+
private handleArrowDown;
|
|
104
|
+
/**
|
|
105
|
+
* Handles ArrowUp at the first line of a code block.
|
|
106
|
+
* Exits to the previous block.
|
|
107
|
+
*/
|
|
108
|
+
private handleArrowUp;
|
|
109
|
+
/**
|
|
110
|
+
* Handles ArrowRight at the end of a code block.
|
|
111
|
+
* Exits to the next block or creates a paragraph below.
|
|
112
|
+
*/
|
|
113
|
+
private handleArrowRight;
|
|
114
|
+
/**
|
|
115
|
+
* Handles ArrowLeft at the start of a code block.
|
|
116
|
+
* Exits to the previous block at end.
|
|
117
|
+
*/
|
|
118
|
+
private handleArrowLeft;
|
|
119
|
+
/**
|
|
120
|
+
* Handles Mod+Enter: always creates a paragraph below and moves cursor there.
|
|
121
|
+
*/
|
|
122
|
+
private handleModEnter;
|
|
123
|
+
private setBlockFocused;
|
|
124
|
+
private toggleCodeBlock;
|
|
125
|
+
private insertCodeBlock;
|
|
126
|
+
private exitOnDoubleEnter;
|
|
127
|
+
private insertParagraphAfter;
|
|
128
|
+
private setAttr;
|
|
129
|
+
/**
|
|
130
|
+
* Strips all marks from a block's inline content.
|
|
131
|
+
* Used when converting to code_block so no formatting carries over.
|
|
132
|
+
*/
|
|
133
|
+
private stripAllMarks;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=CodeBlockPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeBlockPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/code-block/CodeBlockPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAgBrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,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AW,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa;IA+B9C,OAAO,CAAC,gBAAgB;IA6CxB,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,gBAAgB;IAwBxB,OAAO,CAAC,eAAe;IA2BvB,OAAO,CAAC,iBAAiB;IA6BzB,OAAO,CAAC,mBAAmB;IAsB3B,OAAO,CAAC,kBAAkB;IAyB1B,OAAO,CAAC,eAAe;IAyCvB,OAAO,CAAC,qBAAqB;IAoB7B;;;OAGG;IACH,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,WAAW;IA4BnB,OAAO,CAAC,SAAS;IAqBjB,OAAO,CAAC,cAAc;IAyCtB,OAAO,CAAC,YAAY;IA2BpB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAiCvB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAkCrB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IA6BxB;;;OAGG;IACH,OAAO,CAAC,eAAe;IA6BvB;;OAEG;IACH,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,OAAO;IAiBf;;;OAGG;IACH,OAAO,CAAC,aAAa;CAoBrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/code-block/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,eAAe,EACf,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,WAAW,GAChB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { EditorState } from '../../state/EditorState.js';
|
|
2
|
+
import { Transaction } from '../../state/Transaction.js';
|
|
3
|
+
import { Plugin, PluginContext } from '../Plugin.js';
|
|
4
|
+
declare module '../../model/AttrRegistry.js' {
|
|
5
|
+
interface MarkAttrRegistry {
|
|
6
|
+
font: {
|
|
7
|
+
family: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** Describes a single @font-face source. */
|
|
12
|
+
export interface FontFaceDescriptor {
|
|
13
|
+
/** CSS `src` value, e.g. `"url('/fonts/My.woff2') format('woff2')"`. */
|
|
14
|
+
readonly src: string;
|
|
15
|
+
/** Font weight, e.g. `'400'` or `'300 700'` for variable fonts. */
|
|
16
|
+
readonly weight?: string;
|
|
17
|
+
/** Font style, e.g. `'normal'` or `'italic'`. */
|
|
18
|
+
readonly style?: string;
|
|
19
|
+
/** Font display strategy. Defaults to `'swap'`. */
|
|
20
|
+
readonly display?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Defines a font available in the editor. */
|
|
23
|
+
export interface FontDefinition {
|
|
24
|
+
/** Display name shown in the toolbar dropdown. */
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/** CSS `font-family` value, e.g. `"'Fira Code', monospace"`. */
|
|
27
|
+
readonly family: string;
|
|
28
|
+
/** Font category for grouping in the UI. */
|
|
29
|
+
readonly category?: 'serif' | 'sans-serif' | 'monospace' | 'display' | 'handwriting';
|
|
30
|
+
/**
|
|
31
|
+
* Optional `@font-face` descriptors. When provided, the plugin
|
|
32
|
+
* auto-injects the corresponding CSS rules into the document.
|
|
33
|
+
*/
|
|
34
|
+
readonly fontFaces?: readonly FontFaceDescriptor[];
|
|
35
|
+
}
|
|
36
|
+
export interface FontConfig {
|
|
37
|
+
/**
|
|
38
|
+
* Fonts available in the editor. System fonts require no `fontFaces`.
|
|
39
|
+
* Custom fonts with `fontFaces` get their `@font-face` rules auto-injected.
|
|
40
|
+
*
|
|
41
|
+
* Use `STARTER_FONTS` for a pre-configured set of fonts:
|
|
42
|
+
* ```ts
|
|
43
|
+
* new FontPlugin({ fonts: [...STARTER_FONTS] })
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
readonly fonts: readonly FontDefinition[];
|
|
47
|
+
/**
|
|
48
|
+
* Name of the font that acts as the editor's default.
|
|
49
|
+
* Selecting this font removes the mark (since the editor already uses it).
|
|
50
|
+
* Defaults to the first font in the list.
|
|
51
|
+
*/
|
|
52
|
+
readonly defaultFont?: string;
|
|
53
|
+
/** When true, a separator is rendered after the font toolbar item. */
|
|
54
|
+
readonly separatorAfter?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare class FontPlugin implements Plugin {
|
|
57
|
+
readonly id = "font";
|
|
58
|
+
readonly name = "Font";
|
|
59
|
+
readonly priority = 22;
|
|
60
|
+
private readonly config;
|
|
61
|
+
private injectedStyleElement;
|
|
62
|
+
private context;
|
|
63
|
+
private comboLabel;
|
|
64
|
+
constructor(config: FontConfig);
|
|
65
|
+
init(context: PluginContext): void;
|
|
66
|
+
destroy(): void;
|
|
67
|
+
onStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void;
|
|
68
|
+
private registerMarkSpec;
|
|
69
|
+
private registerCommands;
|
|
70
|
+
private get defaultFont();
|
|
71
|
+
private registerToolbarItem;
|
|
72
|
+
private updateComboLabel;
|
|
73
|
+
private resolveFontName;
|
|
74
|
+
private isFontActive;
|
|
75
|
+
getActiveFont(state: EditorState): string | null;
|
|
76
|
+
applyFont(context: PluginContext, state: EditorState, family: string): boolean;
|
|
77
|
+
private removeFont;
|
|
78
|
+
/** Finds the first font mark in a block's text range (for proper step inversion). */
|
|
79
|
+
private findFontMarkInRange;
|
|
80
|
+
private injectFontFaces;
|
|
81
|
+
private dismissPopup;
|
|
82
|
+
private renderFontPopup;
|
|
83
|
+
private createFontItem;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=FontPlugin.d.ts.map
|
|
@@ -0,0 +1 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|
4
|
+
/** Fira Code — a monospace font with programming ligatures. */
|
|
5
|
+
export declare const FIRA_CODE: FontDefinition;
|
|
6
|
+
/** Fira Sans — a humanist sans-serif typeface. */
|
|
7
|
+
export declare const FIRA_SANS: FontDefinition;
|
|
8
|
+
/** All starter fonts bundled with notectl. */
|
|
9
|
+
export declare const STARTER_FONTS: readonly FontDefinition[];
|
|
10
|
+
//# sourceMappingURL=StarterFonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StarterFonts.d.ts","sourceRoot":"","sources":["../../../src/plugins/font/StarterFonts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,eAAO,MAAM,oBAAoB,EAAE,MAC+6sI,CAAC;AAEn9sI,eAAO,MAAM,oBAAoB,EAAE,MACuogL,CAAC;AAE3qgL,+DAA+D;AAC/D,eAAO,MAAM,SAAS,EAAE,cAWvB,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,SAAS,EAAE,cAWvB,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,aAAa,EAAE,SAAS,cAAc,EAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/font/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACvB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { EditorState } from '../../state/EditorState.js';
|
|
2
|
+
import { Transaction } from '../../state/Transaction.js';
|
|
3
|
+
import { Plugin, PluginContext } from '../Plugin.js';
|
|
4
|
+
declare module '../../model/AttrRegistry.js' {
|
|
5
|
+
interface MarkAttrRegistry {
|
|
6
|
+
fontSize: {
|
|
7
|
+
size: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** Default preset sizes shown in the font size dropdown. */
|
|
12
|
+
export declare const DEFAULT_FONT_SIZES: readonly number[];
|
|
13
|
+
export interface FontSizeConfig {
|
|
14
|
+
/**
|
|
15
|
+
* Preset sizes shown in the font size dropdown.
|
|
16
|
+
* Must contain positive integers. Values are sorted and deduplicated automatically.
|
|
17
|
+
* Defaults to {@link DEFAULT_FONT_SIZES} when omitted or empty.
|
|
18
|
+
*/
|
|
19
|
+
readonly sizes?: readonly number[];
|
|
20
|
+
/**
|
|
21
|
+
* The base font size that text has when no fontSize mark is applied.
|
|
22
|
+
* Shown as the initial value in the toolbar combo and used as the
|
|
23
|
+
* "neutral" size — selecting it removes the mark instead of applying one.
|
|
24
|
+
* Defaults to 16.
|
|
25
|
+
*/
|
|
26
|
+
readonly defaultSize?: number;
|
|
27
|
+
/** When true, a separator is rendered after the fontSize toolbar item. */
|
|
28
|
+
readonly separatorAfter?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare class FontSizePlugin implements Plugin {
|
|
31
|
+
readonly id = "fontSize";
|
|
32
|
+
readonly name = "Font Size";
|
|
33
|
+
readonly priority = 21;
|
|
34
|
+
private readonly config;
|
|
35
|
+
private readonly sizes;
|
|
36
|
+
private readonly defaultSize;
|
|
37
|
+
private context;
|
|
38
|
+
private comboLabel;
|
|
39
|
+
constructor(config?: Partial<FontSizeConfig>);
|
|
40
|
+
init(context: PluginContext): void;
|
|
41
|
+
destroy(): void;
|
|
42
|
+
onStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void;
|
|
43
|
+
private registerMarkSpec;
|
|
44
|
+
private registerCommands;
|
|
45
|
+
private registerKeymaps;
|
|
46
|
+
private registerToolbarItem;
|
|
47
|
+
/**
|
|
48
|
+
* Sets the configured default font size on the editor content container
|
|
49
|
+
* so that unformatted text renders at the correct size instead of the
|
|
50
|
+
* browser default (16px).
|
|
51
|
+
*/
|
|
52
|
+
private applyDefaultSizeToContainer;
|
|
53
|
+
private updateComboLabel;
|
|
54
|
+
private isFontSizeActive;
|
|
55
|
+
private getActiveSize;
|
|
56
|
+
private getActiveSizeNumeric;
|
|
57
|
+
private applyFontSize;
|
|
58
|
+
private removeFontSize;
|
|
59
|
+
private stepFontSize;
|
|
60
|
+
private getNextPresetSize;
|
|
61
|
+
private dismissPopup;
|
|
62
|
+
private renderFontSizePopup;
|
|
63
|
+
private selectSize;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=FontSizePlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontSizePlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/font-size/FontSizePlugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK1D,OAAO,QAAQ,6BAA6B,CAAC;IAC5C,UAAU,gBAAgB;QACzB,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;KAC3B;CACD;AAID,4DAA4D;AAC5D,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAE/C,CAAC;AAQF,MAAM,WAAW,cAAc;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CAClC;AAMD,qBAAa,cAAe,YAAW,MAAM;IAC5C,QAAQ,CAAC,EAAE,cAAc;IACzB,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,QAAQ,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,UAAU,CAAgC;gBAEtC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAM5C,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAUlC,OAAO,IAAI,IAAI;IAKf,aAAa,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI;IAMpF,OAAO,CAAC,gBAAgB;IAoCxB,OAAO,CAAC,gBAAgB;IAuBxB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,mBAAmB;IAoB3B;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAKnC,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,aAAa;IAmCrB,OAAO,CAAC,cAAc;IAmCtB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,mBAAmB;IAkJ3B,OAAO,CAAC,UAAU;CAOlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/font-size/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { t } from "../chunks/Commands-DLP85Mp5.mjs";
|
|
2
|
+
import { b as e } from "../chunks/AttrRegistry-DTsHyDVA.mjs";
|
|
3
|
+
import { e as n, h as o } from "../chunks/Document-CI3iCwEP.mjs";
|
|
4
|
+
import { i, a as s, s as r } from "../chunks/Selection-D5ZjXoB7.mjs";
|
|
5
|
+
import { m as c } from "../chunks/TypeBrands-C09nE2qO.mjs";
|
|
6
|
+
import { a } from "../chunks/ToolbarPlugin-D5VqeBPT.mjs";
|
|
7
|
+
const l = [8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96], p = {};
|
|
8
|
+
class u {
|
|
9
|
+
id = "fontSize";
|
|
10
|
+
name = "Font Size";
|
|
11
|
+
priority = 21;
|
|
12
|
+
config;
|
|
13
|
+
sizes;
|
|
14
|
+
defaultSize;
|
|
15
|
+
context = null;
|
|
16
|
+
comboLabel = null;
|
|
17
|
+
constructor(t2) {
|
|
18
|
+
var e2;
|
|
19
|
+
this.config = { ...p, ...t2 }, this.sizes = (function(t3) {
|
|
20
|
+
if (!t3 || 0 === t3.length) return l;
|
|
21
|
+
const e3 = [...new Set(t3)].filter((t4) => Number.isInteger(t4) && t4 > 0);
|
|
22
|
+
return e3.sort((t4, e4) => t4 - e4), e3.length > 0 ? e3 : l;
|
|
23
|
+
})(t2?.sizes), this.defaultSize = (e2 = t2?.defaultSize, void 0 === e2 ? 16 : Number.isInteger(e2) && e2 > 0 ? e2 : 16);
|
|
24
|
+
}
|
|
25
|
+
init(t2) {
|
|
26
|
+
t2.registerStyleSheet("\n/* Font Size Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--fontSize {\n width: auto;\n min-width: 60px;\n max-width: 80px;\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--fontSize:hover {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--fontSize.notectl-toolbar-btn--active {\n background: var(--notectl-bg);\n border-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--fontSize .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--fontSize .notectl-toolbar-btn__icon svg {\n display: none;\n}\n\n.notectl-font-size-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-size-select__arrow {\n flex-shrink: 0;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n line-height: 30px;\n}\n\n/* Font Size Picker Popup */\n.notectl-font-size-picker {\n min-width: 140px;\n display: flex;\n flex-direction: column;\n}\n\n.notectl-font-size-picker__input-wrapper {\n padding: 8px 8px 4px;\n}\n\n.notectl-font-size-picker__input {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n font-size: 13px;\n font-family: inherit;\n color: var(--notectl-fg);\n background: var(--notectl-bg);\n outline: none;\n box-sizing: border-box;\n -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 -webkit-appearance: none;\n margin: 0;\n}\n\n.notectl-font-size-picker__input:focus {\n border-color: var(--notectl-border-focus);\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-font-size-picker__list {\n max-height: 280px;\n overflow-y: auto;\n padding: 4px 0;\n}\n\n.notectl-font-size-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 outline: none;\n}\n\n.notectl-font-size-picker__item:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-font-size-picker__item--active {\n background: var(--notectl-active-bg);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-font-size-picker__item--active:hover {\n background: var(--notectl-active-bg);\n}\n\n.notectl-font-size-picker__item--focused {\n outline: 2px solid var(--notectl-primary);\n outline-offset: -2px;\n}\n\n.notectl-font-size-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-size-picker__label {\n flex: 1;\n}\n"), this.context = t2, this.registerMarkSpec(t2), this.registerCommands(t2), this.registerKeymaps(t2), this.registerToolbarItem(t2), this.applyDefaultSizeToContainer(t2);
|
|
27
|
+
}
|
|
28
|
+
destroy() {
|
|
29
|
+
this.context = null, this.comboLabel = null;
|
|
30
|
+
}
|
|
31
|
+
onStateChange(t2, e2, n2) {
|
|
32
|
+
this.updateComboLabel(e2);
|
|
33
|
+
}
|
|
34
|
+
registerMarkSpec(t2) {
|
|
35
|
+
t2.registerMarkSpec({ type: "fontSize", rank: 4, attrs: { size: { default: "" } }, toDOM(t3) {
|
|
36
|
+
const e2 = document.createElement("span"), n2 = t3.attrs?.size ?? "";
|
|
37
|
+
return n2 && (e2.style.fontSize = n2), e2;
|
|
38
|
+
}, toHTMLString: (t3, e2) => {
|
|
39
|
+
const n2 = String(t3.attrs?.size ?? "");
|
|
40
|
+
return n2 ? `<span style="font-size: ${n2}">${e2}</span>` : e2;
|
|
41
|
+
}, parseHTML: [{ tag: "span", getAttrs: (t3) => {
|
|
42
|
+
const e2 = t3.style.fontSize;
|
|
43
|
+
return !!e2 && { size: e2 };
|
|
44
|
+
} }], sanitize: { tags: ["span"] } });
|
|
45
|
+
}
|
|
46
|
+
registerCommands(t2) {
|
|
47
|
+
t2.registerCommand("removeFontSize", () => {
|
|
48
|
+
const e2 = t2.getState();
|
|
49
|
+
return this.removeFontSize(t2, e2);
|
|
50
|
+
}), t2.registerCommand("setFontSize", () => false), t2.registerCommand("increaseFontSize", () => {
|
|
51
|
+
const e2 = t2.getState();
|
|
52
|
+
return this.stepFontSize(t2, e2, "up");
|
|
53
|
+
}), t2.registerCommand("decreaseFontSize", () => {
|
|
54
|
+
const e2 = t2.getState();
|
|
55
|
+
return this.stepFontSize(t2, e2, "down");
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
registerKeymaps(t2) {
|
|
59
|
+
t2.registerKeymap({ "Mod-Shift-+": () => {
|
|
60
|
+
const e2 = t2.getState();
|
|
61
|
+
return this.stepFontSize(t2, e2, "up");
|
|
62
|
+
}, "Mod-Shift-_": () => {
|
|
63
|
+
const e2 = t2.getState();
|
|
64
|
+
return this.stepFontSize(t2, e2, "down");
|
|
65
|
+
} });
|
|
66
|
+
}
|
|
67
|
+
registerToolbarItem(t2) {
|
|
68
|
+
const e2 = `<span class="notectl-font-size-select__label" data-font-size-label>${this.defaultSize}</span><span class="notectl-font-size-select__arrow">▾</span>`;
|
|
69
|
+
t2.registerToolbarItem({ id: "fontSize", group: "format", icon: e2, label: "Font Size", tooltip: "Font Size", command: "removeFontSize", priority: 6, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (t3, e3) => {
|
|
70
|
+
this.renderFontSizePopup(t3, e3);
|
|
71
|
+
}, isActive: (t3) => this.isFontSizeActive(t3) });
|
|
72
|
+
}
|
|
73
|
+
applyDefaultSizeToContainer(t2) {
|
|
74
|
+
t2.getContainer().style.fontSize = `${this.defaultSize}px`;
|
|
75
|
+
}
|
|
76
|
+
updateComboLabel(t2) {
|
|
77
|
+
if (!this.comboLabel) {
|
|
78
|
+
const t3 = this.context?.getPluginContainer("top");
|
|
79
|
+
if (!t3) return;
|
|
80
|
+
if (this.comboLabel = t3.querySelector("[data-font-size-label]") ?? null, !this.comboLabel) return;
|
|
81
|
+
}
|
|
82
|
+
const e2 = this.getActiveSizeNumeric(t2);
|
|
83
|
+
this.comboLabel.textContent = String(e2);
|
|
84
|
+
}
|
|
85
|
+
isFontSizeActive(t2) {
|
|
86
|
+
return null !== this.getActiveSize(t2);
|
|
87
|
+
}
|
|
88
|
+
getActiveSize(t2) {
|
|
89
|
+
const o2 = t2.selection;
|
|
90
|
+
if (i(o2)) return null;
|
|
91
|
+
if (s(o2)) {
|
|
92
|
+
if (t2.storedMarks) {
|
|
93
|
+
const n2 = t2.storedMarks.find((t3) => "fontSize" === t3.type);
|
|
94
|
+
return n2 && e(n2, "fontSize") ? n2.attrs.size ?? null : null;
|
|
95
|
+
}
|
|
96
|
+
const i2 = t2.getBlock(o2.anchor.blockId);
|
|
97
|
+
if (!i2) return null;
|
|
98
|
+
const s2 = n(i2, o2.anchor.offset).find((t3) => "fontSize" === t3.type);
|
|
99
|
+
return s2 && e(s2, "fontSize") ? s2.attrs.size ?? null : null;
|
|
100
|
+
}
|
|
101
|
+
const r2 = t2.getBlock(o2.anchor.blockId);
|
|
102
|
+
if (!r2) return null;
|
|
103
|
+
const c2 = n(r2, o2.anchor.offset).find((t3) => "fontSize" === t3.type);
|
|
104
|
+
return c2 && e(c2, "fontSize") ? c2.attrs.size ?? null : null;
|
|
105
|
+
}
|
|
106
|
+
getActiveSizeNumeric(t2) {
|
|
107
|
+
const e2 = this.getActiveSize(t2);
|
|
108
|
+
if (!e2) return this.defaultSize;
|
|
109
|
+
const n2 = Number.parseInt(e2, 10);
|
|
110
|
+
return Number.isNaN(n2) ? this.defaultSize : n2;
|
|
111
|
+
}
|
|
112
|
+
applyFontSize(e2, o2, a2) {
|
|
113
|
+
const l2 = o2.selection;
|
|
114
|
+
if (i(l2)) return false;
|
|
115
|
+
if (s(l2)) {
|
|
116
|
+
const t2 = o2.getBlock(l2.anchor.blockId);
|
|
117
|
+
if (!t2) return false;
|
|
118
|
+
const i2 = [...(o2.storedMarks ?? n(t2, l2.anchor.offset)).filter((t3) => "fontSize" !== t3.type), { type: c("fontSize"), attrs: { size: a2 } }], s2 = o2.transaction("command").setStoredMarks(i2, o2.storedMarks).setSelection(l2).build();
|
|
119
|
+
return e2.dispatch(s2), true;
|
|
120
|
+
}
|
|
121
|
+
const p2 = r(l2, o2.getBlockOrder()), u2 = o2.transaction("command"), f = { type: c("fontSize"), attrs: { size: a2 } };
|
|
122
|
+
return t(o2, p2, (t2, e3, n2) => {
|
|
123
|
+
u2.removeMark(t2, e3, n2, { type: c("fontSize") }), u2.addMark(t2, e3, n2, f);
|
|
124
|
+
}), u2.setSelection(l2), e2.dispatch(u2.build()), true;
|
|
125
|
+
}
|
|
126
|
+
removeFontSize(e2, a2) {
|
|
127
|
+
const l2 = a2.selection;
|
|
128
|
+
if (i(l2)) return false;
|
|
129
|
+
if (s(l2)) {
|
|
130
|
+
const t2 = a2.getBlock(l2.anchor.blockId);
|
|
131
|
+
if (!t2) return false;
|
|
132
|
+
const i2 = a2.storedMarks ?? n(t2, l2.anchor.offset);
|
|
133
|
+
if (!o(i2, c("fontSize"))) return false;
|
|
134
|
+
const s2 = i2.filter((t3) => "fontSize" !== t3.type), r2 = a2.transaction("command").setStoredMarks(s2, a2.storedMarks).setSelection(l2).build();
|
|
135
|
+
return e2.dispatch(r2), true;
|
|
136
|
+
}
|
|
137
|
+
const p2 = r(l2, a2.getBlockOrder()), u2 = a2.transaction("command");
|
|
138
|
+
return t(a2, p2, (t2, e3, n2) => {
|
|
139
|
+
u2.removeMark(t2, e3, n2, { type: c("fontSize") });
|
|
140
|
+
}), u2.setSelection(l2), e2.dispatch(u2.build()), true;
|
|
141
|
+
}
|
|
142
|
+
stepFontSize(t2, e2, n2) {
|
|
143
|
+
const o2 = this.getActiveSizeNumeric(e2), i2 = this.getNextPresetSize(o2, n2);
|
|
144
|
+
return null !== i2 && (i2 === this.defaultSize ? this.removeFontSize(t2, e2) : this.applyFontSize(t2, e2, `${i2}px`));
|
|
145
|
+
}
|
|
146
|
+
getNextPresetSize(t2, e2) {
|
|
147
|
+
if ("up" === e2) {
|
|
148
|
+
for (const e3 of this.sizes) if (e3 > t2) return e3;
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
for (let e3 = this.sizes.length - 1; e3 >= 0; e3--) {
|
|
152
|
+
const n2 = this.sizes[e3];
|
|
153
|
+
if (void 0 !== n2 && n2 < t2) return n2;
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
dismissPopup() {
|
|
158
|
+
const t2 = this.context?.getService(a);
|
|
159
|
+
t2?.closePopup();
|
|
160
|
+
}
|
|
161
|
+
renderFontSizePopup(t2, e2) {
|
|
162
|
+
t2.classList.add("notectl-font-size-picker");
|
|
163
|
+
const n2 = e2.getState(), o2 = this.getActiveSizeNumeric(n2);
|
|
164
|
+
let i2 = -1;
|
|
165
|
+
const s2 = document.createElement("div");
|
|
166
|
+
s2.className = "notectl-font-size-picker__input-wrapper";
|
|
167
|
+
const r2 = document.createElement("input");
|
|
168
|
+
r2.type = "number", r2.className = "notectl-font-size-picker__input", r2.min = String(1), r2.max = String(400), r2.value = String(o2), r2.setAttribute("aria-label", "Custom font size"), s2.appendChild(r2), t2.appendChild(s2);
|
|
169
|
+
const c2 = document.createElement("div");
|
|
170
|
+
c2.className = "notectl-font-size-picker__list", c2.setAttribute("role", "listbox"), c2.setAttribute("aria-label", "Font sizes");
|
|
171
|
+
const a2 = [];
|
|
172
|
+
for (let t3 = 0; t3 < this.sizes.length; t3++) {
|
|
173
|
+
const n3 = this.sizes[t3];
|
|
174
|
+
if (void 0 === n3) continue;
|
|
175
|
+
const i3 = n3 === o2, s3 = `notectl-font-size-option-${n3}`, r3 = document.createElement("button");
|
|
176
|
+
r3.type = "button", r3.id = s3, r3.className = "notectl-font-size-picker__item", r3.setAttribute("role", "option"), r3.setAttribute("aria-selected", String(i3)), i3 && r3.classList.add("notectl-font-size-picker__item--active");
|
|
177
|
+
const l3 = document.createElement("span");
|
|
178
|
+
l3.className = "notectl-font-size-picker__check", l3.textContent = i3 ? "✓" : "", r3.appendChild(l3);
|
|
179
|
+
const p3 = document.createElement("span");
|
|
180
|
+
p3.className = "notectl-font-size-picker__label", p3.textContent = String(n3), r3.appendChild(p3), r3.addEventListener("mousedown", (t4) => {
|
|
181
|
+
t4.preventDefault(), t4.stopPropagation(), this.selectSize(e2, n3), this.dismissPopup();
|
|
182
|
+
}), a2.push(r3), c2.appendChild(r3);
|
|
183
|
+
}
|
|
184
|
+
t2.appendChild(c2);
|
|
185
|
+
const l2 = this.sizes.indexOf(o2);
|
|
186
|
+
if (l2 >= 0) {
|
|
187
|
+
const t3 = a2[l2];
|
|
188
|
+
t3 && (requestAnimationFrame(() => {
|
|
189
|
+
t3.scrollIntoView({ block: "nearest" });
|
|
190
|
+
}), c2.setAttribute("aria-activedescendant", t3.id));
|
|
191
|
+
}
|
|
192
|
+
const p2 = (t3) => {
|
|
193
|
+
i2 >= 0 && i2 < a2.length && a2[i2]?.classList.remove("notectl-font-size-picker__item--focused"), i2 = t3;
|
|
194
|
+
const e3 = a2[i2];
|
|
195
|
+
i2 >= 0 && i2 < a2.length && e3 && (e3.classList.add("notectl-font-size-picker__item--focused"), e3.scrollIntoView({ block: "nearest" }), c2.setAttribute("aria-activedescendant", e3.id));
|
|
196
|
+
};
|
|
197
|
+
r2.addEventListener("keydown", (t3) => {
|
|
198
|
+
if ("Enter" === t3.key) {
|
|
199
|
+
t3.preventDefault();
|
|
200
|
+
const n3 = Number.parseInt(r2.value, 10);
|
|
201
|
+
!Number.isNaN(n3) && n3 >= 1 && n3 <= 400 && (this.selectSize(e2, n3), this.dismissPopup());
|
|
202
|
+
} else "ArrowDown" === t3.key ? (t3.preventDefault(), p2(0), a2[0]?.focus()) : "Escape" === t3.key && (t3.preventDefault(), this.dismissPopup());
|
|
203
|
+
}), c2.addEventListener("keydown", (t3) => {
|
|
204
|
+
if ("ArrowDown" === t3.key) t3.preventDefault(), i2 < a2.length - 1 && (p2(i2 + 1), a2[i2]?.focus());
|
|
205
|
+
else if ("ArrowUp" === t3.key) t3.preventDefault(), i2 > 0 ? (p2(i2 - 1), a2[i2]?.focus()) : (p2(-1), r2.focus());
|
|
206
|
+
else if ("Enter" === t3.key) {
|
|
207
|
+
t3.preventDefault();
|
|
208
|
+
const n3 = this.sizes[i2];
|
|
209
|
+
i2 >= 0 && i2 < this.sizes.length && void 0 !== n3 && (this.selectSize(e2, n3), this.dismissPopup());
|
|
210
|
+
} else "Escape" === t3.key && (t3.preventDefault(), this.dismissPopup());
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
selectSize(t2, e2) {
|
|
214
|
+
e2 === this.defaultSize ? t2.executeCommand("removeFontSize") : this.applyFontSize(t2, t2.getState(), `${e2}px`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
export {
|
|
218
|
+
u as FontSizePlugin
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=font-size.mjs.map
|