@notectl/core 1.0.6 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -56
- package/custom-elements.json +344 -0
- package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs → AttrRegistry-D-przlzb.mjs} +4 -4
- package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs.map → AttrRegistry-D-przlzb.mjs.map} +1 -1
- package/dist/chunks/ColorNames-iaWsSZx1.mjs +35 -0
- package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +1 -0
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +140 -0
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +1 -0
- package/dist/chunks/{Commands-DLP85Mp5.mjs → Commands-CSpSwGXv.mjs} +13 -13
- package/dist/chunks/{Commands-DLP85Mp5.mjs.map → Commands-CSpSwGXv.mjs.map} +1 -1
- package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs +46 -0
- package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs.map +1 -0
- package/dist/chunks/ToolbarPlugin-DFkl1uYO.mjs +818 -0
- package/dist/chunks/ToolbarPlugin-DFkl1uYO.mjs.map +1 -0
- package/dist/chunks/index-BCvuDpVr.mjs +191 -0
- package/dist/chunks/index-BCvuDpVr.mjs.map +1 -0
- package/dist/chunks/index-BFsYGsBR.mjs +92 -0
- package/dist/chunks/index-BFsYGsBR.mjs.map +1 -0
- package/dist/chunks/index-BIL37LSL.mjs +73 -0
- package/dist/chunks/index-BIL37LSL.mjs.map +1 -0
- package/dist/chunks/index-BL56fbXt.mjs +402 -0
- package/dist/chunks/index-BL56fbXt.mjs.map +1 -0
- package/dist/chunks/index-BQ8iIYLn.mjs +209 -0
- package/dist/chunks/index-BQ8iIYLn.mjs.map +1 -0
- package/dist/chunks/index-BRYzYOYC.mjs +63 -0
- package/dist/chunks/index-BRYzYOYC.mjs.map +1 -0
- package/dist/chunks/index-BSFLNveF.mjs +953 -0
- package/dist/chunks/index-BSFLNveF.mjs.map +1 -0
- package/dist/chunks/index-BTJfyJlJ.mjs +187 -0
- package/dist/chunks/index-BTJfyJlJ.mjs.map +1 -0
- package/dist/chunks/index-Bsp4LC5t.mjs +130 -0
- package/dist/chunks/index-Bsp4LC5t.mjs.map +1 -0
- package/dist/chunks/index-DA8TG2S8.mjs +220 -0
- package/dist/chunks/index-DA8TG2S8.mjs.map +1 -0
- package/dist/chunks/index-DAFCISBN.mjs +100 -0
- package/dist/chunks/index-DAFCISBN.mjs.map +1 -0
- package/dist/chunks/index-DC1EK22F.mjs +41 -0
- package/dist/chunks/index-DC1EK22F.mjs.map +1 -0
- package/dist/chunks/index-DGrRWMlW.mjs +541 -0
- package/dist/chunks/index-DGrRWMlW.mjs.map +1 -0
- package/dist/chunks/index-DfO_fKw6.mjs +39 -0
- package/dist/chunks/index-DfO_fKw6.mjs.map +1 -0
- package/dist/chunks/index-o6hDR07y.mjs +41 -0
- package/dist/chunks/index-o6hDR07y.mjs.map +1 -0
- package/dist/chunks/index-uTnc9y7M.mjs +62 -0
- package/dist/chunks/index-uTnc9y7M.mjs.map +1 -0
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs +34 -0
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +37 -5
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/PaperLayoutController.d.ts +27 -0
- package/dist/editor/PaperLayoutController.d.ts.map +1 -0
- package/dist/editor/PaperSize.d.ts +35 -0
- package/dist/editor/PaperSize.d.ts.map +1 -0
- package/dist/editor/styles/color-picker.d.ts +1 -1
- package/dist/editor/styles/color-picker.d.ts.map +1 -1
- package/dist/editor/styles/list.d.ts +2 -0
- package/dist/editor/styles/list.d.ts.map +1 -1
- package/dist/editor/styles/paper.d.ts +3 -0
- package/dist/editor/styles/paper.d.ts.map +1 -0
- package/dist/editor/styles/table.d.ts +1 -1
- package/dist/editor/styles/table.d.ts.map +1 -1
- package/dist/editor/styles/toolbar.d.ts +1 -1
- package/dist/editor/styles/toolbar.d.ts.map +1 -1
- package/dist/editor/styles.d.ts.map +1 -1
- package/dist/i18n/Locale.d.ts +17 -0
- package/dist/i18n/Locale.d.ts.map +1 -0
- package/dist/i18n/LocaleService.d.ts +8 -0
- package/dist/i18n/LocaleService.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/resolvePluginLocale.d.ts +3 -0
- package/dist/i18n/resolvePluginLocale.d.ts.map +1 -0
- package/dist/index.d.ts +48 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts +2 -0
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/InputHandler.d.ts +2 -0
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/KeyboardHandler.d.ts +2 -0
- package/dist/input/KeyboardHandler.d.ts.map +1 -1
- package/dist/input/LegacyHTMLNormalizer.d.ts +18 -0
- package/dist/input/LegacyHTMLNormalizer.d.ts.map +1 -0
- package/dist/input/PasteHandler.d.ts +4 -0
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/model/HTMLParser.d.ts +13 -0
- package/dist/model/HTMLParser.d.ts.map +1 -1
- package/dist/model/SchemaRegistry.d.ts +2 -2
- package/dist/model/SchemaRegistry.d.ts.map +1 -1
- package/dist/notectl-core.mjs +2297 -1971
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +2894 -1825
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/Plugin.d.ts +17 -2
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/PluginManager.d.ts +22 -1
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentLocale.d.ts +19 -0
- package/dist/plugins/alignment/AlignmentLocale.d.ts.map +1 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts +4 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +3 -89
- package/dist/plugins/alignment.mjs.map +1 -1
- package/dist/plugins/blockquote/BlockquoteLocale.d.ts +17 -0
- package/dist/plugins/blockquote/BlockquoteLocale.d.ts.map +1 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts +3 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -1
- package/dist/plugins/blockquote.mjs +2 -55
- package/dist/plugins/blockquote.mjs.map +1 -1
- package/dist/plugins/code-block/CodeBlockLocale.d.ts +17 -0
- package/dist/plugins/code-block/CodeBlockLocale.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +2 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +3 -3
- package/dist/plugins/font/FontLocale.d.ts +15 -0
- package/dist/plugins/font/FontLocale.d.ts.map +1 -0
- package/dist/plugins/font/FontPlugin.d.ts +3 -0
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeLocale.d.ts +17 -0
- package/dist/plugins/font-size/FontSizeLocale.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts +3 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePopup.d.ts +2 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +2 -201
- package/dist/plugins/font-size.mjs.map +1 -1
- package/dist/plugins/font.mjs +2 -183
- package/dist/plugins/font.mjs.map +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +14 -0
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingCommands.d.ts +5 -0
- package/dist/plugins/heading/HeadingCommands.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts +5 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts +5 -0
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingLocale.d.ts +26 -0
- package/dist/plugins/heading/HeadingLocale.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +4 -40
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -184
- package/dist/plugins/heading.mjs.map +1 -1
- package/dist/plugins/highlight/HighlightLocale.d.ts +17 -0
- package/dist/plugins/highlight/HighlightLocale.d.ts.map +1 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts +3 -5
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +2 -123
- package/dist/plugins/highlight.mjs.map +1 -1
- package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts +15 -0
- package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +4 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
- package/dist/plugins/horizontal-rule.mjs +2 -56
- package/dist/plugins/horizontal-rule.mjs.map +1 -1
- package/dist/plugins/image/ImageLocale.d.ts +25 -0
- package/dist/plugins/image/ImageLocale.d.ts.map +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image/ImageUpload.d.ts +3 -0
- package/dist/plugins/image/ImageUpload.d.ts.map +1 -1
- package/dist/plugins/image.mjs +4 -378
- package/dist/plugins/image.mjs.map +1 -1
- package/dist/plugins/link/LinkLocale.d.ts +23 -0
- package/dist/plugins/link/LinkLocale.d.ts.map +1 -0
- package/dist/plugins/link/LinkPlugin.d.ts +3 -0
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +2 -124
- package/dist/plugins/link.mjs.map +1 -1
- package/dist/plugins/list/ListLocale.d.ts +18 -0
- package/dist/plugins/list/ListLocale.d.ts.map +1 -0
- package/dist/plugins/list/ListPlugin.d.ts +13 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +2 -190
- package/dist/plugins/list.mjs.map +1 -1
- package/dist/plugins/print/PrintLocale.d.ts +16 -0
- package/dist/plugins/print/PrintLocale.d.ts.map +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -1
- package/dist/plugins/print/PrintStyleCollector.d.ts +7 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
- package/dist/plugins/print/PrintTypes.d.ts +5 -0
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -1
- package/dist/plugins/shared/ColorMarkOperations.d.ts +28 -0
- package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -0
- package/dist/plugins/shared/ColorNames.d.ts +22 -0
- package/dist/plugins/shared/ColorNames.d.ts.map +1 -0
- package/dist/plugins/shared/ColorPickerPopup.d.ts +31 -0
- package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -0
- package/dist/plugins/shared/ColorValidation.d.ts +14 -0
- package/dist/plugins/shared/ColorValidation.d.ts.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughLocale.d.ts +17 -0
- package/dist/plugins/strikethrough/StrikethroughLocale.d.ts.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +3 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +2 -32
- package/dist/plugins/strikethrough.mjs.map +1 -1
- package/dist/plugins/super-sub/SuperSubLocale.d.ts +19 -0
- package/dist/plugins/super-sub/SuperSubLocale.d.ts.map +1 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts +3 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
- package/dist/plugins/super-sub.mjs +2 -78
- package/dist/plugins/super-sub.mjs.map +1 -1
- package/dist/plugins/table/TableBorderColor.d.ts +24 -0
- package/dist/plugins/table/TableBorderColor.d.ts.map +1 -0
- package/dist/plugins/table/TableCommands.d.ts +9 -8
- package/dist/plugins/table/TableCommands.d.ts.map +1 -1
- package/dist/plugins/table/TableContextMenu.d.ts +14 -0
- package/dist/plugins/table/TableContextMenu.d.ts.map +1 -0
- package/dist/plugins/table/TableControls.d.ts +3 -1
- package/dist/plugins/table/TableControls.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsDOM.d.ts +13 -1
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
- package/dist/plugins/table/TableLocale.d.ts +48 -0
- package/dist/plugins/table/TableLocale.d.ts.map +1 -0
- package/dist/plugins/table/TableNavigation.d.ts +2 -1
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
- package/dist/plugins/table/TableNodeViews.d.ts +3 -1
- package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
- package/dist/plugins/table/TablePlugin.d.ts +7 -1
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
- package/dist/plugins/table/index.d.ts +3 -0
- package/dist/plugins/table/index.d.ts.map +1 -1
- package/dist/plugins/table.mjs +18 -660
- package/dist/plugins/table.mjs.map +1 -1
- package/dist/plugins/text-color/TextColorLocale.d.ts +17 -0
- package/dist/plugins/text-color/TextColorLocale.d.ts.map +1 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts +3 -5
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +2 -123
- package/dist/plugins/text-color.mjs.map +1 -1
- package/dist/plugins/text-formatting/TextFormattingLocale.d.ts +18 -0
- package/dist/plugins/text-formatting/TextFormattingLocale.d.ts.map +1 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +4 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +2 -49
- package/dist/plugins/text-formatting.mjs.map +1 -1
- package/dist/plugins/toolbar/ToolbarLocale.d.ts +15 -0
- package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts +23 -0
- package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +56 -0
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +18 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/state/EditorState.d.ts +4 -1
- package/dist/state/EditorState.d.ts.map +1 -1
- package/dist/state/ReadonlyGuard.d.ts +6 -0
- package/dist/state/ReadonlyGuard.d.ts.map +1 -0
- package/dist/state/Transaction.d.ts +4 -0
- package/dist/state/Transaction.d.ts.map +1 -1
- package/dist/view/EditorView.d.ts +2 -0
- package/dist/view/EditorView.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs +0 -15
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs +0 -398
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs.map +0 -1
- package/dist/chunks/color-picker-Csf0wx5a.mjs +0 -5
- package/dist/chunks/color-picker-Csf0wx5a.mjs.map +0 -1
- package/dist/chunks/index-QvKiO9_4.mjs +0 -538
- package/dist/chunks/index-QvKiO9_4.mjs.map +0 -1
- package/dist/input/SourceNormalizer.d.ts +0 -7
- package/dist/input/SourceNormalizer.d.ts.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Locale interface and default English locale for the FontSizePlugin. */
|
|
2
|
+
export interface FontSizeLocale {
|
|
3
|
+
readonly label: string;
|
|
4
|
+
readonly tooltip: string;
|
|
5
|
+
readonly customFontSizeAria: string;
|
|
6
|
+
readonly fontSizesAria: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const FONT_SIZE_LOCALE_EN: FontSizeLocale;
|
|
9
|
+
export declare const FONT_SIZE_LOCALE_DE: FontSizeLocale;
|
|
10
|
+
export declare const FONT_SIZE_LOCALE_ES: FontSizeLocale;
|
|
11
|
+
export declare const FONT_SIZE_LOCALE_FR: FontSizeLocale;
|
|
12
|
+
export declare const FONT_SIZE_LOCALE_ZH: FontSizeLocale;
|
|
13
|
+
export declare const FONT_SIZE_LOCALE_RU: FontSizeLocale;
|
|
14
|
+
export declare const FONT_SIZE_LOCALE_AR: FontSizeLocale;
|
|
15
|
+
export declare const FONT_SIZE_LOCALE_HI: FontSizeLocale;
|
|
16
|
+
export declare const FONT_SIZE_LOCALES: Record<string, FontSizeLocale>;
|
|
17
|
+
//# sourceMappingURL=FontSizeLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontSizeLocale.d.ts","sourceRoot":"","sources":["../../../src/plugins/font-size/FontSizeLocale.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAI1E,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAC/B;AAID,eAAO,MAAM,mBAAmB,EAAE,cAKjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,cAKjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,cAKjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,cAKjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,cAKjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,cAKjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,cAKjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,cAKjC,CAAC;AAIF,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAS5D,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EditorState } from '../../state/EditorState.js';
|
|
2
2
|
import { Transaction } from '../../state/Transaction.js';
|
|
3
3
|
import { Plugin, PluginContext } from '../Plugin.js';
|
|
4
|
+
import { FontSizeLocale } from './FontSizeLocale.js';
|
|
4
5
|
declare module '../../model/AttrRegistry.js' {
|
|
5
6
|
interface MarkAttrRegistry {
|
|
6
7
|
fontSize: {
|
|
@@ -26,6 +27,7 @@ export interface FontSizeConfig {
|
|
|
26
27
|
readonly defaultSize?: number;
|
|
27
28
|
/** When true, a separator is rendered after the fontSize toolbar item. */
|
|
28
29
|
readonly separatorAfter?: boolean;
|
|
30
|
+
readonly locale?: FontSizeLocale;
|
|
29
31
|
}
|
|
30
32
|
export declare class FontSizePlugin implements Plugin {
|
|
31
33
|
readonly id = "fontSize";
|
|
@@ -34,6 +36,7 @@ export declare class FontSizePlugin implements Plugin {
|
|
|
34
36
|
private readonly config;
|
|
35
37
|
private readonly sizes;
|
|
36
38
|
private readonly defaultSize;
|
|
39
|
+
private locale;
|
|
37
40
|
private context;
|
|
38
41
|
private comboLabel;
|
|
39
42
|
constructor(config?: Partial<FontSizeConfig>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FontSizePlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/font-size/FontSizePlugin.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CAAgC;gBAEtC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAM5C,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAYlC,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;IAoBxB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,mBAAmB;IAyB3B;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAKnC,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,gBAAgB;CAWxB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { PluginContext } from '../Plugin.js';
|
|
2
|
+
import { FontSizeLocale } from './FontSizeLocale.js';
|
|
2
3
|
export interface FontSizePopupConfig {
|
|
3
4
|
readonly sizes: readonly number[];
|
|
4
5
|
readonly defaultSize: number;
|
|
5
6
|
readonly dismissPopup: () => void;
|
|
7
|
+
readonly locale?: FontSizeLocale;
|
|
6
8
|
}
|
|
7
9
|
/** Builds the font-size picker DOM inside the given container. */
|
|
8
10
|
export declare function renderFontSizePopup(container: HTMLElement, context: PluginContext, config: FontSizePopupConfig): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FontSizePopup.d.ts","sourceRoot":"","sources":["../../../src/plugins/font-size/FontSizePopup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"FontSizePopup.d.ts","sourceRoot":"","sources":["../../../src/plugins/font-size/FontSizePopup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAU1D,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;CACjC;AAID,kEAAkE;AAClE,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,mBAAmB,GACzB,IAAI,CAaN"}
|
|
@@ -1,204 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as e } from "../chunks/Commands-DLP85Mp5.mjs";
|
|
3
|
-
import { b as n } from "../chunks/AttrRegistry-DTsHyDVA.mjs";
|
|
4
|
-
import { e as o, h as i } from "../chunks/Document-CI3iCwEP.mjs";
|
|
5
|
-
import { i as r, a as s, s as a } from "../chunks/Selection-D5ZjXoB7.mjs";
|
|
6
|
-
import { m as c } from "../chunks/TypeBrands-C09nE2qO.mjs";
|
|
7
|
-
function l(t2) {
|
|
8
|
-
const e2 = t2.selection;
|
|
9
|
-
if (r(e2)) return null;
|
|
10
|
-
if (s(e2) && t2.storedMarks) return b(t2.storedMarks);
|
|
11
|
-
const n2 = t2.getBlock(e2.anchor.blockId);
|
|
12
|
-
return n2 ? b(o(n2, e2.anchor.offset)) : null;
|
|
13
|
-
}
|
|
14
|
-
function p(t2, e2) {
|
|
15
|
-
const n2 = l(t2);
|
|
16
|
-
if (!n2) return e2;
|
|
17
|
-
const o2 = Number.parseInt(n2, 10);
|
|
18
|
-
return Number.isNaN(o2) ? e2 : o2;
|
|
19
|
-
}
|
|
20
|
-
function u(t2, n2, i2) {
|
|
21
|
-
const l2 = n2.selection;
|
|
22
|
-
if (r(l2)) return false;
|
|
23
|
-
if (s(l2)) {
|
|
24
|
-
const e2 = n2.getBlock(l2.anchor.blockId);
|
|
25
|
-
if (!e2) return false;
|
|
26
|
-
const r2 = [...(n2.storedMarks ?? o(e2, l2.anchor.offset)).filter((t3) => "fontSize" !== t3.type), { type: c("fontSize"), attrs: { size: i2 } }], s2 = n2.transaction("command").setStoredMarks(r2, n2.storedMarks).setSelection(l2).build();
|
|
27
|
-
return t2.dispatch(s2), true;
|
|
28
|
-
}
|
|
29
|
-
const p2 = a(l2, n2.getBlockOrder()), u2 = n2.transaction("command"), f2 = { type: c("fontSize"), attrs: { size: i2 } };
|
|
30
|
-
return e(n2, p2, (t3, e2, n3) => {
|
|
31
|
-
u2.removeMark(t3, e2, n3, { type: c("fontSize") }), u2.addMark(t3, e2, n3, f2);
|
|
32
|
-
}), u2.setSelection(l2), t2.dispatch(u2.build()), true;
|
|
33
|
-
}
|
|
34
|
-
function f(t2, n2) {
|
|
35
|
-
const l2 = n2.selection;
|
|
36
|
-
if (r(l2)) return false;
|
|
37
|
-
if (s(l2)) {
|
|
38
|
-
const e2 = n2.getBlock(l2.anchor.blockId);
|
|
39
|
-
if (!e2) return false;
|
|
40
|
-
const r2 = n2.storedMarks ?? o(e2, l2.anchor.offset);
|
|
41
|
-
if (!i(r2, c("fontSize"))) return false;
|
|
42
|
-
const s2 = r2.filter((t3) => "fontSize" !== t3.type), a2 = n2.transaction("command").setStoredMarks(s2, n2.storedMarks).setSelection(l2).build();
|
|
43
|
-
return t2.dispatch(a2), true;
|
|
44
|
-
}
|
|
45
|
-
const p2 = a(l2, n2.getBlockOrder()), u2 = n2.transaction("command");
|
|
46
|
-
return e(n2, p2, (t3, e2, n3) => {
|
|
47
|
-
u2.removeMark(t3, e2, n3, { type: c("fontSize") });
|
|
48
|
-
}), u2.setSelection(l2), t2.dispatch(u2.build()), true;
|
|
49
|
-
}
|
|
50
|
-
function d(t2, e2, n2, o2, i2) {
|
|
51
|
-
const r2 = (function(t3, e3, n3) {
|
|
52
|
-
if ("up" === e3) {
|
|
53
|
-
for (const e4 of n3) if (e4 > t3) return e4;
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
for (let e4 = n3.length - 1; e4 >= 0; e4--) {
|
|
57
|
-
const o3 = n3[e4];
|
|
58
|
-
if (void 0 !== o3 && o3 < t3) return o3;
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
})(p(e2, i2), n2, o2);
|
|
62
|
-
return null !== r2 && (r2 === i2 ? f(t2, e2) : u(t2, e2, `${r2}px`));
|
|
63
|
-
}
|
|
64
|
-
function m(t2, e2, n2) {
|
|
65
|
-
e2 === n2 ? t2.executeCommand("removeFontSize") : u(t2, t2.getState(), `${e2}px`);
|
|
66
|
-
}
|
|
67
|
-
function b(t2) {
|
|
68
|
-
const e2 = t2.find((t3) => "fontSize" === t3.type);
|
|
69
|
-
return e2 && n(e2, "fontSize") ? e2.attrs.size ?? null : null;
|
|
70
|
-
}
|
|
71
|
-
function z(t2, e2) {
|
|
72
|
-
const n2 = document.createElement("button");
|
|
73
|
-
n2.type = "button", n2.id = `notectl-font-size-option-${t2}`, n2.className = "notectl-font-size-picker__item", n2.setAttribute("role", "option"), n2.setAttribute("aria-selected", String(e2)), e2 && n2.classList.add("notectl-font-size-picker__item--active");
|
|
74
|
-
const o2 = document.createElement("span");
|
|
75
|
-
o2.className = "notectl-font-size-picker__check", o2.textContent = e2 ? "✓" : "", n2.appendChild(o2);
|
|
76
|
-
const i2 = document.createElement("span");
|
|
77
|
-
return i2.className = "notectl-font-size-picker__label", i2.textContent = String(t2), n2.appendChild(i2), n2;
|
|
78
|
-
}
|
|
79
|
-
const g = [8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96];
|
|
80
|
-
class h {
|
|
81
|
-
id = "fontSize";
|
|
82
|
-
name = "Font Size";
|
|
83
|
-
priority = 21;
|
|
84
|
-
config;
|
|
85
|
-
sizes;
|
|
86
|
-
defaultSize;
|
|
87
|
-
context = null;
|
|
88
|
-
comboLabel = null;
|
|
89
|
-
constructor(t2) {
|
|
90
|
-
var e2;
|
|
91
|
-
this.config = { ...t2 }, this.sizes = (function(t3) {
|
|
92
|
-
if (!t3 || 0 === t3.length) return g;
|
|
93
|
-
const e3 = [...new Set(t3)].filter((t4) => Number.isInteger(t4) && t4 > 0);
|
|
94
|
-
return e3.sort((t4, e4) => t4 - e4), e3.length > 0 ? e3 : g;
|
|
95
|
-
})(t2?.sizes), this.defaultSize = (e2 = t2?.defaultSize, void 0 === e2 ? 16 : Number.isInteger(e2) && e2 > 0 ? e2 : 16);
|
|
96
|
-
}
|
|
97
|
-
init(t2) {
|
|
98
|
-
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);
|
|
99
|
-
}
|
|
100
|
-
destroy() {
|
|
101
|
-
this.context = null, this.comboLabel = null;
|
|
102
|
-
}
|
|
103
|
-
onStateChange(t2, e2, n2) {
|
|
104
|
-
this.updateComboLabel(e2);
|
|
105
|
-
}
|
|
106
|
-
registerMarkSpec(t2) {
|
|
107
|
-
t2.registerMarkSpec({ type: "fontSize", rank: 4, attrs: { size: { default: "" } }, toDOM(t3) {
|
|
108
|
-
const e2 = document.createElement("span"), n2 = t3.attrs?.size ?? "";
|
|
109
|
-
return n2 && (e2.style.fontSize = n2), e2;
|
|
110
|
-
}, toHTMLString: (t3, e2) => {
|
|
111
|
-
const n2 = String(t3.attrs?.size ?? "");
|
|
112
|
-
return n2 ? `<span style="font-size: ${n2}">${e2}</span>` : e2;
|
|
113
|
-
}, parseHTML: [{ tag: "span", getAttrs: (t3) => {
|
|
114
|
-
const e2 = t3.style.fontSize;
|
|
115
|
-
return !!e2 && { size: e2 };
|
|
116
|
-
} }], sanitize: { tags: ["span"] } });
|
|
117
|
-
}
|
|
118
|
-
registerCommands(t2) {
|
|
119
|
-
t2.registerCommand("removeFontSize", () => f(t2, t2.getState())), t2.registerCommand("setFontSize", () => false), t2.registerCommand("increaseFontSize", () => d(t2, t2.getState(), "up", this.sizes, this.defaultSize)), t2.registerCommand("decreaseFontSize", () => d(t2, t2.getState(), "down", this.sizes, this.defaultSize));
|
|
120
|
-
}
|
|
121
|
-
registerKeymaps(t2) {
|
|
122
|
-
t2.registerKeymap({ "Mod-Shift-+": () => d(t2, t2.getState(), "up", this.sizes, this.defaultSize), "Mod-Shift-_": () => d(t2, t2.getState(), "down", this.sizes, this.defaultSize) });
|
|
123
|
-
}
|
|
124
|
-
registerToolbarItem(t2) {
|
|
125
|
-
const e2 = `<span class="notectl-font-size-select__label" data-font-size-label>${this.defaultSize}</span><span class="notectl-font-size-select__arrow">▾</span>`;
|
|
126
|
-
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) => {
|
|
127
|
-
!(function(t4, e4, n2) {
|
|
128
|
-
t4.classList.add("notectl-font-size-picker");
|
|
129
|
-
const o2 = p(e4.getState(), n2.defaultSize), i2 = (function(t5) {
|
|
130
|
-
const e5 = document.createElement("input");
|
|
131
|
-
return e5.type = "number", e5.className = "notectl-font-size-picker__input", e5.min = String(1), e5.max = String(400), e5.value = String(t5), e5.setAttribute("aria-label", "Custom font size"), e5;
|
|
132
|
-
})(o2);
|
|
133
|
-
!(function(t5, e5) {
|
|
134
|
-
const n3 = document.createElement("div");
|
|
135
|
-
n3.className = "notectl-font-size-picker__input-wrapper", n3.appendChild(e5), t5.appendChild(n3);
|
|
136
|
-
})(t4, i2);
|
|
137
|
-
const { list: r2, items: s2 } = (function(t5, e5, n3, o3) {
|
|
138
|
-
const i3 = document.createElement("div");
|
|
139
|
-
i3.className = "notectl-font-size-picker__list", i3.setAttribute("role", "listbox"), i3.setAttribute("aria-label", "Font sizes");
|
|
140
|
-
const r3 = [];
|
|
141
|
-
for (const s3 of t5) {
|
|
142
|
-
const t6 = z(s3, s3 === e5);
|
|
143
|
-
t6.addEventListener("mousedown", (t7) => {
|
|
144
|
-
t7.preventDefault(), t7.stopPropagation(), m(n3, s3, o3.defaultSize), o3.dismissPopup();
|
|
145
|
-
}), r3.push(t6), i3.appendChild(t6);
|
|
146
|
-
}
|
|
147
|
-
return { list: i3, items: r3 };
|
|
148
|
-
})(n2.sizes, o2, e4, n2);
|
|
149
|
-
t4.appendChild(r2), (function(t5, e5, n3, o3) {
|
|
150
|
-
const i3 = e5.indexOf(n3);
|
|
151
|
-
if (i3 < 0) return;
|
|
152
|
-
const r3 = t5[i3];
|
|
153
|
-
r3 && (requestAnimationFrame(() => {
|
|
154
|
-
r3.scrollIntoView({ block: "nearest" });
|
|
155
|
-
}), o3.setAttribute("aria-activedescendant", r3.id));
|
|
156
|
-
})(s2, n2.sizes, o2, r2), (function(t5, e5, n3, o3, i3) {
|
|
157
|
-
let r3 = -1;
|
|
158
|
-
const s3 = (t6) => {
|
|
159
|
-
r3 >= 0 && r3 < n3.length && n3[r3]?.classList.remove("notectl-font-size-picker__item--focused"), r3 = t6;
|
|
160
|
-
const o4 = n3[r3];
|
|
161
|
-
r3 >= 0 && r3 < n3.length && o4 && (o4.classList.add("notectl-font-size-picker__item--focused"), o4.scrollIntoView({ block: "nearest" }), e5.setAttribute("aria-activedescendant", o4.id));
|
|
162
|
-
};
|
|
163
|
-
t5.addEventListener("keydown", (e6) => {
|
|
164
|
-
if ("Enter" === e6.key) {
|
|
165
|
-
e6.preventDefault();
|
|
166
|
-
const n4 = Number.parseInt(t5.value, 10);
|
|
167
|
-
!Number.isNaN(n4) && n4 >= 1 && n4 <= 400 && (m(o3, n4, i3.defaultSize), i3.dismissPopup());
|
|
168
|
-
} else "ArrowDown" === e6.key ? (e6.preventDefault(), s3(0), n3[0]?.focus()) : "Escape" === e6.key && (e6.preventDefault(), i3.dismissPopup());
|
|
169
|
-
}), e5.addEventListener("keydown", (e6) => {
|
|
170
|
-
if ("ArrowDown" === e6.key) e6.preventDefault(), r3 < n3.length - 1 && (s3(r3 + 1), n3[r3]?.focus());
|
|
171
|
-
else if ("ArrowUp" === e6.key) e6.preventDefault(), r3 > 0 ? (s3(r3 - 1), n3[r3]?.focus()) : (s3(-1), t5.focus());
|
|
172
|
-
else if ("Enter" === e6.key) {
|
|
173
|
-
e6.preventDefault();
|
|
174
|
-
const t6 = i3.sizes[r3];
|
|
175
|
-
r3 >= 0 && r3 < i3.sizes.length && void 0 !== t6 && (m(o3, t6, i3.defaultSize), i3.dismissPopup());
|
|
176
|
-
} else "Escape" === e6.key && (e6.preventDefault(), i3.dismissPopup());
|
|
177
|
-
});
|
|
178
|
-
})(i2, r2, s2, e4, n2);
|
|
179
|
-
})(t3, e3, { sizes: this.sizes, defaultSize: this.defaultSize, dismissPopup: () => this.dismissPopup() });
|
|
180
|
-
}, isActive: (t3) => (function(t4) {
|
|
181
|
-
return null !== l(t4);
|
|
182
|
-
})(t3) });
|
|
183
|
-
}
|
|
184
|
-
applyDefaultSizeToContainer(t2) {
|
|
185
|
-
t2.getContainer().style.fontSize = `${this.defaultSize}px`;
|
|
186
|
-
}
|
|
187
|
-
dismissPopup() {
|
|
188
|
-
const e2 = this.context?.getService(t);
|
|
189
|
-
e2?.closePopup();
|
|
190
|
-
}
|
|
191
|
-
updateComboLabel(t2) {
|
|
192
|
-
if (!this.comboLabel) {
|
|
193
|
-
const t3 = this.context?.getPluginContainer("top");
|
|
194
|
-
if (!t3) return;
|
|
195
|
-
if (this.comboLabel = t3.querySelector("[data-font-size-label]") ?? null, !this.comboLabel) return;
|
|
196
|
-
}
|
|
197
|
-
const e2 = p(t2, this.defaultSize);
|
|
198
|
-
this.comboLabel.textContent = String(e2);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
1
|
+
import { b } from "../chunks/index-BQ8iIYLn.mjs";
|
|
201
2
|
export {
|
|
202
|
-
|
|
3
|
+
b as FontSizePlugin
|
|
203
4
|
};
|
|
204
5
|
//# sourceMappingURL=font-size.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-size.mjs","sources":["../../src/plugins/font-size/FontSizeOperations.ts","../../src/plugins/font-size/FontSizePopup.ts","../../src/plugins/font-size/FontSizePlugin.ts","../../src/editor/styles/font-size-select.ts"],"sourcesContent":["/**\n * Pure business logic for font-size state queries and transaction builders.\n * All functions are DOM-free and operate on EditorState / PluginContext.\n */\n\nimport { forEachBlockInRange } from '../../commands/Commands.js';\nimport { isMarkOfType } from '../../model/AttrRegistry.js';\nimport type { Mark } from '../../model/Document.js';\nimport { getBlockMarksAtOffset, hasMark } 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 { PluginContext } from '../Plugin.js';\n\n// --- State Queries ---\n\n/** Returns the raw fontSize CSS value at the current selection, or null. */\nexport function getActiveSize(state: EditorState): string | null {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return null;\n\n\tif (isCollapsed(sel) && state.storedMarks) {\n\t\treturn extractFontSize(state.storedMarks);\n\t}\n\n\tconst block = state.getBlock(sel.anchor.blockId);\n\tif (!block) return null;\n\treturn extractFontSize(getBlockMarksAtOffset(block, sel.anchor.offset));\n}\n\n/** Returns the active font size as a number, falling back to defaultSize. */\nexport function getActiveSizeNumeric(state: EditorState, defaultSize: number): number {\n\tconst raw: string | null = getActiveSize(state);\n\tif (!raw) return defaultSize;\n\tconst parsed: number = Number.parseInt(raw, 10);\n\treturn Number.isNaN(parsed) ? defaultSize : parsed;\n}\n\n/** Returns true when the selection carries a fontSize mark. */\nexport function isFontSizeActive(state: EditorState): boolean {\n\treturn getActiveSize(state) !== null;\n}\n\n// --- Commands ---\n\n/** Applies a fontSize mark with the given CSS size string to the selection. */\nexport function applyFontSize(context: PluginContext, state: EditorState, size: string): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\n\tif (isCollapsed(sel)) {\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return false;\n\t\tconst currentMarks = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tconst withoutSize = currentMarks.filter((m) => m.type !== 'fontSize');\n\t\tconst newMarks = [...withoutSize, { type: markType('fontSize'), attrs: { size } }];\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\tconst mark = { type: markType('fontSize'), attrs: { size } };\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tbuilder.removeMark(blockId, from, to, { type: markType('fontSize') });\n\t\tbuilder.addMark(blockId, from, to, mark);\n\t});\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** Removes the fontSize mark from the current selection. */\nexport function removeFontSize(context: PluginContext, state: EditorState): boolean {\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel)) return false;\n\n\tif (isCollapsed(sel)) {\n\t\tconst anchorBlock = state.getBlock(sel.anchor.blockId);\n\t\tif (!anchorBlock) return false;\n\t\tconst currentMarks = state.storedMarks ?? getBlockMarksAtOffset(anchorBlock, sel.anchor.offset);\n\t\tif (!hasMark(currentMarks, markType('fontSize'))) return false;\n\n\t\tconst newMarks = currentMarks.filter((m) => m.type !== 'fontSize');\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setStoredMarks(newMarks, state.storedMarks)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tconst range = selectionRange(sel, state.getBlockOrder());\n\tconst builder = state.transaction('command');\n\n\tforEachBlockInRange(state, range, (blockId, from, to) => {\n\t\tbuilder.removeMark(blockId, from, to, { type: markType('fontSize') });\n\t});\n\n\tbuilder.setSelection(sel);\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/** Steps the font size up or down through the preset list. */\nexport function stepFontSize(\n\tcontext: PluginContext,\n\tstate: EditorState,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n\tdefaultSize: number,\n): boolean {\n\tconst current: number = getActiveSizeNumeric(state, defaultSize);\n\tconst next: number | null = getNextPresetSize(current, direction, sizes);\n\tif (next === null) return false;\n\n\tif (next === defaultSize) {\n\t\treturn removeFontSize(context, state);\n\t}\n\treturn applyFontSize(context, state, `${next}px`);\n}\n\n/**\n * Selects a specific font size: removes the mark when size equals the\n * default, otherwise applies the new size.\n */\nexport function selectSize(context: PluginContext, size: number, defaultSize: number): void {\n\tif (size === defaultSize) {\n\t\tcontext.executeCommand('removeFontSize');\n\t} else {\n\t\tapplyFontSize(context, context.getState(), `${size}px`);\n\t}\n}\n\n// --- Helpers ---\n\n/** Finds the next preset size in the given direction, or null at boundaries. */\nexport function getNextPresetSize(\n\tcurrent: number,\n\tdirection: 'up' | 'down',\n\tsizes: readonly number[],\n): number | null {\n\tif (direction === 'up') {\n\t\tfor (const size of sizes) {\n\t\t\tif (size > current) return size;\n\t\t}\n\t\treturn null;\n\t}\n\tfor (let i: number = sizes.length - 1; i >= 0; i--) {\n\t\tconst size: number | undefined = sizes[i];\n\t\tif (size !== undefined && size < current) return size;\n\t}\n\treturn null;\n}\n\nfunction extractFontSize(marks: readonly Mark[]): string | null {\n\tconst mark = marks.find((m) => m.type === 'fontSize');\n\treturn mark && isMarkOfType(mark, 'fontSize') ? (mark.attrs.size ?? null) : null;\n}\n","/**\n * Renders the font-size picker popup with a custom numeric input\n * and an accessible preset list with keyboard navigation.\n */\n\nimport type { PluginContext } from '../Plugin.js';\nimport { getActiveSizeNumeric, selectSize } from './FontSizeOperations.js';\n\n// --- Constants ---\n\nconst MIN_CUSTOM_SIZE = 1;\nconst MAX_CUSTOM_SIZE = 400;\n\n// --- Config ---\n\nexport interface FontSizePopupConfig {\n\treadonly sizes: readonly number[];\n\treadonly defaultSize: number;\n\treadonly dismissPopup: () => void;\n}\n\n// --- Public Entry Point ---\n\n/** Builds the font-size picker DOM inside the given container. */\nexport function renderFontSizePopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tcontainer.classList.add('notectl-font-size-picker');\n\n\tconst currentSize: number = getActiveSizeNumeric(context.getState(), config.defaultSize);\n\n\tconst input: HTMLInputElement = buildCustomInput(currentSize);\n\tappendInputWrapper(container, input);\n\n\tconst { list, items } = buildSizeList(config.sizes, currentSize, context, config);\n\tcontainer.appendChild(list);\n\n\tscrollActiveIntoView(items, config.sizes, currentSize, list);\n\tattachKeyboardNavigation(input, list, items, context, config);\n}\n\n// --- Custom Input ---\n\nfunction buildCustomInput(currentSize: number): HTMLInputElement {\n\tconst input: HTMLInputElement = document.createElement('input');\n\tinput.type = 'number';\n\tinput.className = 'notectl-font-size-picker__input';\n\tinput.min = String(MIN_CUSTOM_SIZE);\n\tinput.max = String(MAX_CUSTOM_SIZE);\n\tinput.value = String(currentSize);\n\tinput.setAttribute('aria-label', 'Custom font size');\n\treturn input;\n}\n\nfunction appendInputWrapper(container: HTMLElement, input: HTMLInputElement): void {\n\tconst wrapper: HTMLDivElement = document.createElement('div');\n\twrapper.className = 'notectl-font-size-picker__input-wrapper';\n\twrapper.appendChild(input);\n\tcontainer.appendChild(wrapper);\n}\n\n// --- Size List ---\n\ninterface SizeListResult {\n\treadonly list: HTMLDivElement;\n\treadonly items: HTMLButtonElement[];\n}\n\nfunction buildSizeList(\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): SizeListResult {\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-font-size-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', 'Font sizes');\n\n\tconst items: HTMLButtonElement[] = [];\n\n\tfor (const size of sizes) {\n\t\tconst isActive: boolean = size === currentSize;\n\t\tconst item: HTMLButtonElement = buildSizeItem(size, isActive);\n\n\t\titem.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tselectSize(context, size, config.defaultSize);\n\t\t\tconfig.dismissPopup();\n\t\t});\n\n\t\titems.push(item);\n\t\tlist.appendChild(item);\n\t}\n\n\treturn { list, items };\n}\n\nfunction buildSizeItem(size: number, isActive: boolean): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.id = `notectl-font-size-option-${size}`;\n\titem.className = 'notectl-font-size-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-font-size-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-font-size-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst label: HTMLSpanElement = document.createElement('span');\n\tlabel.className = 'notectl-font-size-picker__label';\n\tlabel.textContent = String(size);\n\titem.appendChild(label);\n\n\treturn item;\n}\n\n// --- Scroll ---\n\nfunction scrollActiveIntoView(\n\titems: HTMLButtonElement[],\n\tsizes: readonly number[],\n\tcurrentSize: number,\n\tlist: HTMLDivElement,\n): void {\n\tconst activeIdx: number = sizes.indexOf(currentSize);\n\tif (activeIdx < 0) return;\n\n\tconst activeItem: HTMLButtonElement | undefined = items[activeIdx];\n\tif (!activeItem) return;\n\n\trequestAnimationFrame(() => {\n\t\tactiveItem.scrollIntoView({ block: 'nearest' });\n\t});\n\tlist.setAttribute('aria-activedescendant', activeItem.id);\n}\n\n// --- Keyboard Navigation ---\n\nfunction attachKeyboardNavigation(\n\tinput: HTMLInputElement,\n\tlist: HTMLDivElement,\n\titems: HTMLButtonElement[],\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tlet focusedIndex = -1;\n\n\tconst setFocused = (idx: number): void => {\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length) {\n\t\t\titems[focusedIndex]?.classList.remove('notectl-font-size-picker__item--focused');\n\t\t}\n\t\tfocusedIndex = idx;\n\t\tconst el: HTMLButtonElement | undefined = items[focusedIndex];\n\t\tif (focusedIndex >= 0 && focusedIndex < items.length && el) {\n\t\t\tel.classList.add('notectl-font-size-picker__item--focused');\n\t\t\tel.scrollIntoView({ block: 'nearest' });\n\t\t\tlist.setAttribute('aria-activedescendant', el.id);\n\t\t}\n\t};\n\n\tinput.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\t\t\tconst val: number = Number.parseInt(input.value, 10);\n\t\t\tif (!Number.isNaN(val) && val >= MIN_CUSTOM_SIZE && val <= MAX_CUSTOM_SIZE) {\n\t\t\t\tselectSize(context, val, config.defaultSize);\n\t\t\t\tconfig.dismissPopup();\n\t\t\t}\n\t\t} else if (e.key === 'ArrowDown') {\n\t\t\te.preventDefault();\n\t\t\tsetFocused(0);\n\t\t\titems[0]?.focus();\n\t\t} else if (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tconfig.dismissPopup();\n\t\t}\n\t});\n\n\tlist.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\tif (e.key === 'ArrowDown') {\n\t\t\te.preventDefault();\n\t\t\tif (focusedIndex < items.length - 1) {\n\t\t\t\tsetFocused(focusedIndex + 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t}\n\t\t} else if (e.key === 'ArrowUp') {\n\t\t\te.preventDefault();\n\t\t\tif (focusedIndex > 0) {\n\t\t\t\tsetFocused(focusedIndex - 1);\n\t\t\t\titems[focusedIndex]?.focus();\n\t\t\t} else {\n\t\t\t\tsetFocused(-1);\n\t\t\t\tinput.focus();\n\t\t\t}\n\t\t} else if (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\t\t\tconst selectedSize: number | undefined = config.sizes[focusedIndex];\n\t\t\tif (focusedIndex >= 0 && focusedIndex < config.sizes.length && selectedSize !== undefined) {\n\t\t\t\tselectSize(context, selectedSize, config.defaultSize);\n\t\t\t\tconfig.dismissPopup();\n\t\t\t}\n\t\t} else if (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tconfig.dismissPopup();\n\t\t}\n\t});\n}\n","/**\n * FontSizePlugin: registers a fontSize mark with attrs, a combobox-style\n * toolbar selector with WCAG-accessible popup, and commands for\n * increasing / decreasing font size.\n */\n\nimport { FONT_SIZE_SELECT_CSS } from '../../editor/styles/font-size-select.js';\nimport 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';\nimport {\n\tgetActiveSizeNumeric,\n\tisFontSizeActive,\n\tremoveFontSize,\n\tstepFontSize,\n} from './FontSizeOperations.js';\nimport { renderFontSizePopup } from './FontSizePopup.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfontSize: { size: string };\n\t}\n}\n\n// --- Constants ---\n\n/** Default preset sizes shown in the font size dropdown. */\nexport const DEFAULT_FONT_SIZES: readonly number[] = [\n\t8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96,\n];\n\nconst DEFAULT_FONT_SIZE = 16;\n\n// --- Configuration ---\n\nexport interface FontSizeConfig {\n\t/**\n\t * Preset sizes shown in the font size dropdown.\n\t * Must contain positive integers. Values are sorted and deduplicated automatically.\n\t * Defaults to {@link DEFAULT_FONT_SIZES} when omitted or empty.\n\t */\n\treadonly sizes?: readonly number[];\n\t/**\n\t * The base font size that text has when no fontSize mark is applied.\n\t * Shown as the initial value in the toolbar combo and used as the\n\t * \"neutral\" size — selecting it removes the mark instead of applying one.\n\t * Defaults to 16.\n\t */\n\treadonly defaultSize?: number;\n\t/** When true, a separator is rendered after the fontSize toolbar item. */\n\treadonly separatorAfter?: boolean;\n}\n\n// --- Plugin ---\n\nexport class FontSizePlugin implements Plugin {\n\treadonly id = 'fontSize';\n\treadonly name = 'Font Size';\n\treadonly priority = 21;\n\n\tprivate readonly config: FontSizeConfig;\n\tprivate readonly sizes: readonly number[];\n\tprivate readonly defaultSize: number;\n\tprivate context: PluginContext | null = null;\n\tprivate comboLabel: HTMLSpanElement | null = null;\n\n\tconstructor(config?: Partial<FontSizeConfig>) {\n\t\tthis.config = { ...config };\n\t\tthis.sizes = resolveSizes(config?.sizes);\n\t\tthis.defaultSize = resolveDefaultSize(config?.defaultSize);\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tcontext.registerStyleSheet(FONT_SIZE_SELECT_CSS);\n\t\tthis.context = context;\n\t\tthis.registerMarkSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.applyDefaultSizeToContainer(context);\n\t}\n\n\tdestroy(): void {\n\t\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: 'fontSize',\n\t\t\trank: 4,\n\t\t\tattrs: {\n\t\t\t\tsize: { default: '' },\n\t\t\t},\n\t\t\ttoDOM(mark) {\n\t\t\t\tconst span: HTMLElement = document.createElement('span');\n\t\t\t\tconst size: string = mark.attrs?.size ?? '';\n\t\t\t\tif (size) {\n\t\t\t\t\tspan.style.fontSize = size;\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 size: string = String(mark.attrs?.size ?? '');\n\t\t\t\tif (!size) return content;\n\t\t\t\treturn `<span style=\"font-size: ${size}\">${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 size: string = el.style.fontSize;\n\t\t\t\t\t\tif (!size) return false;\n\t\t\t\t\t\treturn { size };\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: { tags: ['span'] },\n\t\t});\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('removeFontSize', () => {\n\t\t\treturn removeFontSize(context, context.getState());\n\t\t});\n\n\t\tcontext.registerCommand('setFontSize', () => {\n\t\t\treturn false;\n\t\t});\n\n\t\tcontext.registerCommand('increaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t});\n\n\t\tcontext.registerCommand('decreaseFontSize', () => {\n\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t});\n\t}\n\n\t// --- Keymaps ---\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift-+': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'up', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t\t'Mod-Shift-_': () => {\n\t\t\t\treturn stepFontSize(context, context.getState(), 'down', this.sizes, this.defaultSize);\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst icon: string = `<span class=\"notectl-font-size-select__label\" data-font-size-label>${this.defaultSize}</span><span class=\"notectl-font-size-select__arrow\">\\u25BE</span>`;\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'fontSize',\n\t\t\tgroup: 'format',\n\t\t\ticon,\n\t\t\tlabel: 'Font Size',\n\t\t\ttooltip: 'Font Size',\n\t\t\tcommand: 'removeFontSize',\n\t\t\tpriority: 6,\n\t\t\tpopupType: 'custom',\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\trenderPopup: (container, ctx) => {\n\t\t\t\trenderFontSizePopup(container, ctx, {\n\t\t\t\t\tsizes: this.sizes,\n\t\t\t\t\tdefaultSize: this.defaultSize,\n\t\t\t\t\tdismissPopup: () => this.dismissPopup(),\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state) => isFontSizeActive(state),\n\t\t});\n\t}\n\n\t/**\n\t * Sets the configured default font size on the editor content container\n\t * so that unformatted text renders at the correct size instead of the\n\t * browser default (16px).\n\t */\n\tprivate applyDefaultSizeToContainer(context: PluginContext): void {\n\t\tconst container: HTMLElement = context.getContainer();\n\t\tcontainer.style.fontSize = `${this.defaultSize}px`;\n\t}\n\n\tprivate dismissPopup(): void {\n\t\tconst toolbar = this.context?.getService(ToolbarServiceKey);\n\t\ttoolbar?.closePopup();\n\t}\n\n\tprivate updateComboLabel(state: EditorState): void {\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-size-label]') ?? null;\n\t\t\tif (!this.comboLabel) return;\n\t\t}\n\n\t\tconst activeSize: number = getActiveSizeNumeric(state, this.defaultSize);\n\t\tthis.comboLabel.textContent = String(activeSize);\n\t}\n}\n\n// --- Helpers ---\n\nfunction resolveSizes(sizes: readonly number[] | undefined): readonly number[] {\n\tif (!sizes || sizes.length === 0) return DEFAULT_FONT_SIZES;\n\tconst unique: number[] = [...new Set(sizes)].filter((n) => Number.isInteger(n) && n > 0);\n\tunique.sort((a, b) => a - b);\n\treturn unique.length > 0 ? unique : DEFAULT_FONT_SIZES;\n}\n\nfunction resolveDefaultSize(size: number | undefined): number {\n\tif (size === undefined) return DEFAULT_FONT_SIZE;\n\treturn Number.isInteger(size) && size > 0 ? size : DEFAULT_FONT_SIZE;\n}\n","/** Font size picker toolbar combobox + popup styles. */\nexport const FONT_SIZE_SELECT_CSS = `\n/* Font Size Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--fontSize {\n\twidth: auto;\n\tmin-width: 60px;\n\tmax-width: 80px;\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--fontSize:hover {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--fontSize.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-bg);\n\tborder-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--fontSize .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--fontSize .notectl-toolbar-btn__icon svg {\n\tdisplay: none;\n}\n\n.notectl-font-size-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-size-select__arrow {\n\tflex-shrink: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tline-height: 30px;\n}\n\n/* Font Size Picker Popup */\n.notectl-font-size-picker {\n\tmin-width: 140px;\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.notectl-font-size-picker__input-wrapper {\n\tpadding: 8px 8px 4px;\n}\n\n.notectl-font-size-picker__input {\n\twidth: 100%;\n\tpadding: 6px 8px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tfont-size: 13px;\n\tfont-family: inherit;\n\tcolor: var(--notectl-fg);\n\tbackground: var(--notectl-bg);\n\toutline: none;\n\tbox-sizing: border-box;\n\t-moz-appearance: textfield;\n}\n\n.notectl-font-size-picker__input::-webkit-inner-spin-button,\n.notectl-font-size-picker__input::-webkit-outer-spin-button {\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.notectl-font-size-picker__input:focus {\n\tborder-color: var(--notectl-border-focus);\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-font-size-picker__list {\n\tmax-height: 280px;\n\toverflow-y: auto;\n\tpadding: 4px 0;\n}\n\n.notectl-font-size-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\ttext-align: left;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n\toutline: none;\n}\n\n.notectl-font-size-picker__item:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-font-size-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-font-size-picker__item--active:hover {\n\tbackground: var(--notectl-active-bg);\n}\n\n.notectl-font-size-picker__item--focused {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: -2px;\n}\n\n.notectl-font-size-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-font-size-picker__label {\n\tflex: 1;\n}\n`;\n"],"names":["getActiveSize","state","sel","selection","isNodeSelection","isCollapsed","storedMarks","extractFontSize","block","getBlock","anchor","blockId","getBlockMarksAtOffset","offset","getActiveSizeNumeric","defaultSize","raw","parsed","Number","parseInt","isNaN","applyFontSize","context","size","anchorBlock","newMarks","filter","m","type","markType","attrs","tr","transaction","setStoredMarks","setSelection","build","dispatch","range","selectionRange","getBlockOrder","builder","mark","forEachBlockInRange","from","to","removeMark","addMark","removeFontSize","currentMarks","hasMark","stepFontSize","direction","sizes","next","current","i","length","selectSize","executeCommand","getState","marks","find","isMarkOfType","buildSizeItem","isActive","item","document","createElement","id","className","setAttribute","String","classList","add","check","textContent","appendChild","label","DEFAULT_FONT_SIZES","FontSizePlugin","name","priority","config","comboLabel","this","unique","Set","n","isInteger","sort","a","b","registerStyleSheet","registerMarkSpec","registerCommands","registerKeymaps","registerToolbarItem","applyDefaultSizeToContainer","destroy","_oldState","newState","_tr","updateComboLabel","rank","default","span","style","fontSize","toHTMLString","content","parseHTML","tag","getAttrs","el","sanitize","tags","registerCommand","registerKeymap","icon","group","tooltip","command","popupType","separatorAfter","renderPopup","container","ctx","currentSize","input","min","max","value","wrapper","list","items","addEventListener","e","preventDefault","stopPropagation","dismissPopup","push","activeIdx","indexOf","activeItem","requestAnimationFrame","scrollIntoView","focusedIndex","setFocused","idx","remove","key","val","focus","selectedSize","getContainer","toolbar","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AAKlC,GAAW;AAEhB,UADAzC,KAAKD,aAAa0C,GAAUmC,cAA+B,wBAAA,KAA6B,OACnF5E,KAAKD,WAAY;AAAA,IACvB;AAEA,UAAM8E,KAAqBnJ,EAAqBb,IAAOmF,KAAKrE;AAC5DqE,SAAKD,WAAWR,cAAcJ,OAAO0F;EACtC;AAAA;"}
|
|
1
|
+
{"version":3,"file":"font-size.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/plugins/font.mjs
CHANGED
|
@@ -1,186 +1,5 @@
|
|
|
1
|
-
import {
|
|
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
|
-
}
|
|
1
|
+
import { b } from "../chunks/index-BCvuDpVr.mjs";
|
|
183
2
|
export {
|
|
184
|
-
|
|
3
|
+
b as FontPlugin
|
|
185
4
|
};
|
|
186
5
|
//# sourceMappingURL=font.mjs.map
|