@notectl/core 1.6.1 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs → AttrRegistry-Ci0qAvtS.mjs} +2 -2
- package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs.map → AttrRegistry-Ci0qAvtS.mjs.map} +1 -1
- package/dist/chunks/AttributedMarkCommands-BETuHXj8.mjs +58 -0
- package/dist/chunks/AttributedMarkCommands-BETuHXj8.mjs.map +1 -0
- package/dist/chunks/{CaretNavigation-CAJXoaae.mjs → CaretNavigation-qLfeL0So.mjs} +56 -56
- package/dist/chunks/{CaretNavigation-CAJXoaae.mjs.map → CaretNavigation-qLfeL0So.mjs.map} +1 -1
- package/dist/chunks/ColorGrid-BBkN0AOb.mjs +80 -0
- package/dist/chunks/ColorGrid-BBkN0AOb.mjs.map +1 -0
- package/dist/chunks/ColorPickerPopup-D3ysvOH-.mjs +37 -0
- package/dist/chunks/ColorPickerPopup-D3ysvOH-.mjs.map +1 -0
- package/dist/chunks/ColorValidation-CV4f1wu6.mjs +39 -0
- package/dist/chunks/ColorValidation-CV4f1wu6.mjs.map +1 -0
- package/dist/chunks/{Document-CuwE73FF.mjs → Document-DfZ1NOjs.mjs} +15 -15
- package/dist/chunks/{Document-CuwE73FF.mjs.map → Document-DfZ1NOjs.mjs.map} +1 -1
- package/dist/chunks/MarkCommands-uybmkw9l.mjs +94 -0
- package/dist/chunks/MarkCommands-uybmkw9l.mjs.map +1 -0
- package/dist/chunks/{NavigationUtils-CyW0Vo8A.mjs → NavigationUtils-Cspt2ZrK.mjs} +3 -3
- package/dist/chunks/{NavigationUtils-CyW0Vo8A.mjs.map → NavigationUtils-Cspt2ZrK.mjs.map} +1 -1
- package/dist/chunks/{NodeResolver-B-wzthAQ.mjs → NodeResolver-CzLmmrph.mjs} +2 -2
- package/dist/chunks/{NodeResolver-B-wzthAQ.mjs.map → NodeResolver-CzLmmrph.mjs.map} +1 -1
- package/dist/chunks/PopupPositioning-Cn6L_mO2.mjs +30 -0
- package/dist/chunks/PopupPositioning-Cn6L_mO2.mjs.map +1 -0
- package/dist/chunks/RangeIterator-Bye0UtbY.mjs +16 -0
- package/dist/chunks/RangeIterator-Bye0UtbY.mjs.map +1 -0
- package/dist/chunks/{Selection-DmFDwiPJ.mjs → Selection-BRTab5hO.mjs} +7 -7
- package/dist/chunks/{Selection-DmFDwiPJ.mjs.map → Selection-BRTab5hO.mjs.map} +1 -1
- package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -1
- package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs → ToolbarKeyboardNav-DhpL8zNV.mjs} +3 -3
- package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs.map → ToolbarKeyboardNav-DhpL8zNV.mjs.map} +1 -1
- package/dist/chunks/{ToolbarPlugin-B6JETWaw.mjs → ToolbarPlugin-B7oJRzpl.mjs} +339 -127
- package/dist/chunks/ToolbarPlugin-B7oJRzpl.mjs.map +1 -0
- package/dist/chunks/{index-CPyHuEzh.mjs → index-Bt_d4IqB.mjs} +12 -12
- package/dist/chunks/{index-CPyHuEzh.mjs.map → index-Bt_d4IqB.mjs.map} +1 -1
- package/dist/chunks/{index-BigJ0z6n.mjs → index-CFJFD4lF.mjs} +8 -8
- package/dist/chunks/{index-BigJ0z6n.mjs.map → index-CFJFD4lF.mjs.map} +1 -1
- package/dist/chunks/{index-D67mP19g.mjs → index-CFPP456m.mjs} +13 -13
- package/dist/chunks/{index-D67mP19g.mjs.map → index-CFPP456m.mjs.map} +1 -1
- package/dist/chunks/{index-DQryjfJs.mjs → index-CH1r7DL-.mjs} +259 -300
- package/dist/chunks/index-CH1r7DL-.mjs.map +1 -0
- package/dist/chunks/{index-tBDVaSjG.mjs → index-CfyS_pgH.mjs} +28 -21
- package/dist/chunks/index-CfyS_pgH.mjs.map +1 -0
- package/dist/chunks/{index-DIAXWwgJ.mjs → index-Ckzqtn5D.mjs} +17 -14
- package/dist/chunks/{index-DIAXWwgJ.mjs.map → index-Ckzqtn5D.mjs.map} +1 -1
- package/dist/chunks/{index-BDMP86F4.mjs → index-CrKz_IEn.mjs} +35 -35
- package/dist/chunks/{index-BDMP86F4.mjs.map → index-CrKz_IEn.mjs.map} +1 -1
- package/dist/chunks/{index-B0UFAfyb.mjs → index-DGKQhSAl.mjs} +5 -5
- package/dist/chunks/{index-B0UFAfyb.mjs.map → index-DGKQhSAl.mjs.map} +1 -1
- package/dist/chunks/{index-83QoUENW.mjs → index-DIvHQtE2.mjs} +12 -9
- package/dist/chunks/{index-83QoUENW.mjs.map → index-DIvHQtE2.mjs.map} +1 -1
- package/dist/chunks/index-DayTn6Re.mjs +166 -0
- package/dist/chunks/index-DayTn6Re.mjs.map +1 -0
- package/dist/chunks/index-Deag_lVi.mjs +121 -0
- package/dist/chunks/index-Deag_lVi.mjs.map +1 -0
- package/dist/chunks/{index--z_Txzej.mjs → index-DmuuFS5D.mjs} +6 -6
- package/dist/chunks/{index--z_Txzej.mjs.map → index-DmuuFS5D.mjs.map} +1 -1
- package/dist/chunks/{index-DRZwd-1W.mjs → index-DoCvDkfj.mjs} +79 -96
- package/dist/chunks/index-DoCvDkfj.mjs.map +1 -0
- package/dist/chunks/index-DuRNETFv.mjs +296 -0
- package/dist/chunks/index-DuRNETFv.mjs.map +1 -0
- package/dist/chunks/{index-CPjf45-o.mjs → index-Dum8yE_t.mjs} +14 -14
- package/dist/chunks/{index-CPjf45-o.mjs.map → index-Dum8yE_t.mjs.map} +1 -1
- package/dist/chunks/{index-BWXkaC2Z.mjs → index-Dy6SllXW.mjs} +53 -65
- package/dist/chunks/index-Dy6SllXW.mjs.map +1 -0
- package/dist/chunks/{index-D8tbbW97.mjs → index-E7OgN7hM.mjs} +2 -2
- package/dist/chunks/{index-D8tbbW97.mjs.map → index-E7OgN7hM.mjs.map} +1 -1
- package/dist/chunks/{index-D4GKlc-A.mjs → index-yhz2qeeh.mjs} +224 -222
- package/dist/chunks/index-yhz2qeeh.mjs.map +1 -0
- package/dist/commands/AttributedMarkCommands.d.ts +46 -0
- package/dist/commands/AttributedMarkCommands.d.ts.map +1 -0
- package/dist/commands/CommandHelpers.d.ts +21 -0
- package/dist/commands/CommandHelpers.d.ts.map +1 -0
- package/dist/commands/Commands.d.ts +2 -8
- package/dist/commands/Commands.d.ts.map +1 -1
- package/dist/commands/DeleteCommands.d.ts.map +1 -1
- package/dist/commands/GapCursorCommands.d.ts.map +1 -1
- package/dist/commands/NodeSelectionCommands.d.ts.map +1 -1
- package/dist/commands/PasteCommand.d.ts.map +1 -1
- package/dist/commands/RangeIterator.d.ts +10 -0
- package/dist/commands/RangeIterator.d.ts.map +1 -0
- package/dist/editor/DocumentParser.d.ts.map +1 -1
- package/dist/editor/DocumentSerializer.d.ts +2 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -1
- package/dist/editor/MarkSerializer.d.ts +11 -0
- package/dist/editor/MarkSerializer.d.ts.map +1 -0
- package/dist/editor/NotectlEditor.d.ts +6 -3
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/PaperLayoutController.d.ts +2 -0
- package/dist/editor/PaperLayoutController.d.ts.map +1 -1
- package/dist/editor/styles/font-select.d.ts +1 -1
- package/dist/editor/styles/font-select.d.ts.map +1 -1
- package/dist/editor/styles/font-size-select.d.ts +1 -1
- package/dist/editor/styles/font-size-select.d.ts.map +1 -1
- package/dist/editor/styles/heading-select.d.ts +1 -1
- package/dist/editor/styles/heading-select.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/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts +0 -2
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/model/MarkSpec.d.ts +6 -0
- package/dist/model/MarkSpec.d.ts.map +1 -1
- package/dist/notectl-core.mjs +2245 -2085
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +5568 -5345
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/PluginManager.d.ts +2 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +3 -3
- package/dist/plugins/blockquote.mjs +2 -2
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block.mjs +3 -3
- package/dist/plugins/font/FontPlugin.d.ts +0 -6
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePlugin.d.ts +0 -5
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +2 -2
- package/dist/plugins/font.mjs +2 -2
- package/dist/plugins/gap-cursor.mjs +7 -7
- package/dist/plugins/hard-break.mjs +2 -25
- package/dist/plugins/hard-break.mjs.map +1 -1
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +1 -7
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -1
- package/dist/plugins/heading/HeadingPlugin.d.ts +0 -6
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +2 -2
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +2 -2
- package/dist/plugins/horizontal-rule.mjs +2 -2
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image.mjs +3 -3
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +2 -2
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +2 -2
- package/dist/plugins/shared/ColorGrid.d.ts +25 -0
- package/dist/plugins/shared/ColorGrid.d.ts.map +1 -0
- package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
- package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
- package/dist/plugins/shared/ColorValidation.d.ts +13 -2
- package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
- package/dist/plugins/shared/PopupKeyboardPatterns.d.ts +43 -0
- package/dist/plugins/shared/PopupKeyboardPatterns.d.ts.map +1 -0
- package/dist/plugins/shared/PopupManager.d.ts +45 -0
- package/dist/plugins/shared/PopupManager.d.ts.map +1 -0
- package/dist/plugins/shared/PopupPositioning.d.ts +21 -0
- package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -0
- package/dist/plugins/strikethrough.mjs +2 -2
- package/dist/plugins/super-sub.mjs +2 -2
- package/dist/plugins/table/TableBorderColor.d.ts.map +1 -1
- package/dist/plugins/table/TableContextMenu.d.ts +2 -1
- package/dist/plugins/table/TableContextMenu.d.ts.map +1 -1
- package/dist/plugins/table.mjs +10 -10
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +2 -2
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarItem.d.ts +11 -2
- package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +5 -1
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts +9 -1
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
- package/dist/plugins/toolbar/index.d.ts +1 -1
- package/dist/plugins/toolbar/index.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/presets/FullPreset.d.ts +16 -0
- package/dist/presets/FullPreset.d.ts.map +1 -0
- package/dist/presets/MinimalPreset.d.ts +7 -0
- package/dist/presets/MinimalPreset.d.ts.map +1 -0
- package/dist/presets/PresetTypes.d.ts +50 -0
- package/dist/presets/PresetTypes.d.ts.map +1 -0
- package/dist/state/BlockTreeOps.d.ts +21 -0
- package/dist/state/BlockTreeOps.d.ts.map +1 -0
- package/dist/state/InlineContentOps.d.ts +37 -0
- package/dist/state/InlineContentOps.d.ts.map +1 -0
- package/dist/state/StepApplication.d.ts.map +1 -1
- package/dist/test/PluginTestUtils.d.ts +4 -0
- package/dist/test/PluginTestUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/ColorNames-BdsHwA2f.mjs +0 -59
- package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +0 -1
- package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +0 -125
- package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +0 -1
- package/dist/chunks/Commands-CicwYoTQ.mjs +0 -286
- package/dist/chunks/Commands-CicwYoTQ.mjs.map +0 -1
- package/dist/chunks/MarkCommands-CC37WA7Z.mjs +0 -94
- package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs.map +0 -1
- package/dist/chunks/index-BWXkaC2Z.mjs.map +0 -1
- package/dist/chunks/index-D4GKlc-A.mjs.map +0 -1
- package/dist/chunks/index-DQryjfJs.mjs.map +0 -1
- package/dist/chunks/index-DRZwd-1W.mjs.map +0 -1
- package/dist/chunks/index-DUC1X43Z.mjs +0 -209
- package/dist/chunks/index-DUC1X43Z.mjs.map +0 -1
- package/dist/chunks/index-DipAT_Q9.mjs +0 -191
- package/dist/chunks/index-DipAT_Q9.mjs.map +0 -1
- package/dist/chunks/index-tBDVaSjG.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-DRZwd-1W.mjs","sources":["../../src/plugins/heading/HeadingBlockTypePicker.ts","../../src/plugins/heading/HeadingCommands.ts","../../src/plugins/heading/HeadingKeyboardHandlers.ts","../../src/plugins/heading/HeadingLocale.ts","../../src/plugins/heading/HeadingPlugin.ts","../../src/editor/styles/heading-select.ts","../../src/plugins/heading/HeadingInputRules.ts"],"sourcesContent":["/**\n * Block type picker entries and toolbar dropdown for heading block types.\n * Registers picker entries for paragraph, title, subtitle, and all heading levels,\n * plus a combobox-style toolbar item with a custom popup.\n */\n\nimport { isGapCursor, isNodeSelection } from '../../model/Selection.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { ToolbarServiceKey } from '../toolbar/ToolbarPlugin.js';\nimport type { PickerEntryStyle } from './BlockTypePickerEntry.js';\nimport type { HeadingLocale } from './HeadingLocale.js';\nimport type { HeadingConfig, HeadingLevel } from './HeadingPlugin.js';\n\n// --- Picker Entry Registration ---\n\n/** Registers block type picker entries for paragraph, title, subtitle, and heading levels. */\nexport function registerHeadingPickerEntries(\n\tcontext: PluginContext,\n\tconfig: HeadingConfig,\n\tlocale: HeadingLocale,\n): void {\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'paragraph',\n\t\tlabel: locale.paragraph,\n\t\tcommand: 'setParagraph',\n\t\tpriority: 10,\n\t\tisActive: (state) => {\n\t\t\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'paragraph';\n\t\t},\n\t});\n\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'title',\n\t\tlabel: locale.title,\n\t\tcommand: 'setTitle',\n\t\tpriority: 20,\n\t\tstyle: { fontSize: '1.6em', fontWeight: '700' },\n\t\tisActive: (state) => {\n\t\t\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'title';\n\t\t},\n\t});\n\n\tcontext.registerBlockTypePickerEntry({\n\t\tid: 'subtitle',\n\t\tlabel: locale.subtitle,\n\t\tcommand: 'setSubtitle',\n\t\tpriority: 30,\n\t\tstyle: { fontSize: '1.3em', fontWeight: '500' },\n\t\tisActive: (state) => {\n\t\t\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\treturn block?.type === 'subtitle';\n\t\t},\n\t});\n\n\tfor (const level of config.levels) {\n\t\tcontext.registerBlockTypePickerEntry({\n\t\t\tid: `heading-${level}`,\n\t\t\tlabel: getHeadingLabel(locale, level),\n\t\t\tcommand: `setHeading${level}`,\n\t\t\tpriority: 100 + level,\n\t\t\tstyle: { fontSize: `${1.4 - level * 0.1}em`, fontWeight: '600' },\n\t\t\tisActive: (state) => {\n\t\t\t\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\t\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\t\treturn block?.type === 'heading' && block.attrs?.level === level;\n\t\t\t},\n\t\t});\n\t}\n}\n\n// --- Toolbar Item ---\n\n/** Registers the heading toolbar dropdown with a custom picker popup. */\nexport function registerHeadingToolbarItem(\n\tcontext: PluginContext,\n\tconfig: HeadingConfig,\n\tlocale: HeadingLocale,\n): void {\n\tconst icon: string = `<span class=\"notectl-heading-select__label\" data-heading-label>${locale.paragraph}</span><span class=\"notectl-heading-select__arrow\">\\u25BE</span>`;\n\n\tcontext.registerToolbarItem({\n\t\tid: 'heading',\n\t\tgroup: 'block',\n\t\ticon,\n\t\tlabel: locale.blockTypeLabel,\n\t\ttooltip: locale.blockTypeLabel,\n\t\tcommand: 'setParagraph',\n\t\tpriority: 50,\n\t\tpopupType: 'custom',\n\t\tseparatorAfter: config.separatorAfter,\n\t\trenderPopup: (container, ctx) => {\n\t\t\trenderHeadingPopup(container, ctx, locale);\n\t\t},\n\t\tisActive: (state) => {\n\t\t\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\t\t\treturn entries.some((entry) => entry.id !== 'paragraph' && entry.isActive(state));\n\t\t},\n\t});\n}\n\n// --- Combo Label Update ---\n\n/**\n * Updates the combobox label in the toolbar to reflect the current block type.\n * Returns the resolved HTMLSpanElement (cached across calls) for reuse.\n */\nexport function updateComboLabel(\n\tstate: EditorState,\n\tcontext: PluginContext,\n\tlocale: HeadingLocale,\n\tcachedLabel: HTMLSpanElement | null,\n): HTMLSpanElement | null {\n\tlet label: HTMLSpanElement | null = cachedLabel;\n\n\tif (!label) {\n\t\tconst container: HTMLElement | undefined = context.getPluginContainer('top');\n\t\tif (!container) return null;\n\t\tlabel = container.querySelector<HTMLSpanElement>('[data-heading-label]') ?? null;\n\t\tif (!label) return null;\n\t}\n\n\tlabel.textContent = getActiveLabel(state, context, locale);\n\treturn label;\n}\n\n// --- Popup Rendering ---\n\nfunction renderHeadingPopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tlocale: HeadingLocale,\n): void {\n\tcontainer.classList.add('notectl-heading-picker');\n\n\tconst state: EditorState = context.getState();\n\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return;\n\n\tconst list: HTMLDivElement = document.createElement('div');\n\tlist.className = 'notectl-heading-picker__list';\n\tlist.setAttribute('role', 'listbox');\n\tlist.setAttribute('aria-label', locale.blockTypesAria);\n\n\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\tfor (const entry of entries) {\n\t\tconst active: boolean = entry.isActive(state);\n\t\tlist.appendChild(\n\t\t\tcreatePickerItem(\n\t\t\t\tentry.label,\n\t\t\t\tactive,\n\t\t\t\t(e: MouseEvent) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\tcontext.executeCommand(entry.command);\n\t\t\t\t\tconst toolbar = context.getService(ToolbarServiceKey);\n\t\t\t\t\ttoolbar?.closePopup();\n\t\t\t\t},\n\t\t\t\tentry.style,\n\t\t\t),\n\t\t);\n\t}\n\n\tcontainer.appendChild(list);\n}\n\nfunction createPickerItem(\n\tlabel: string,\n\tisActive: boolean,\n\thandler: (e: MouseEvent) => void,\n\tstyle?: PickerEntryStyle,\n): HTMLButtonElement {\n\tconst item: HTMLButtonElement = document.createElement('button');\n\titem.type = 'button';\n\titem.className = 'notectl-heading-picker__item';\n\titem.setAttribute('role', 'option');\n\titem.setAttribute('aria-selected', String(isActive));\n\n\tif (isActive) {\n\t\titem.classList.add('notectl-heading-picker__item--active');\n\t}\n\n\tconst check: HTMLSpanElement = document.createElement('span');\n\tcheck.className = 'notectl-heading-picker__check';\n\tcheck.textContent = isActive ? '\\u2713' : '';\n\titem.appendChild(check);\n\n\tconst labelSpan: HTMLSpanElement = document.createElement('span');\n\tlabelSpan.className = 'notectl-heading-picker__label';\n\tlabelSpan.textContent = label;\n\tif (style) {\n\t\tlabelSpan.style.fontSize = style.fontSize;\n\t\tlabelSpan.style.fontWeight = style.fontWeight;\n\t}\n\titem.appendChild(labelSpan);\n\n\titem.addEventListener('mousedown', handler);\n\treturn item;\n}\n\n// --- Helpers ---\n\nfunction getHeadingLabel(locale: HeadingLocale, level: HeadingLevel): string {\n\tconst key = `heading${level}` as keyof HeadingLocale;\n\treturn locale[key] as string;\n}\n\nfunction getActiveLabel(state: EditorState, context: PluginContext, locale: HeadingLocale): string {\n\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return locale.paragraph;\n\tconst entries = context.getBlockTypePickerRegistry().getBlockTypePickerEntries();\n\tfor (const entry of entries) {\n\t\tif (entry.isActive(state)) return entry.label;\n\t}\n\treturn locale.paragraph;\n}\n","/**\n * Command registration and implementations for heading block types.\n * Handles toggle between heading/title/subtitle and paragraph,\n * plus excluded-mark stripping when switching block types.\n */\n\nimport type { BlockNode, Mark } from '../../model/Document.js';\nimport { getBlockLength, getInlineChildren, isTextNode } from '../../model/Document.js';\nimport { isGapCursor, isNodeSelection } from '../../model/Selection.js';\nimport { type NodeTypeName, nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { TransactionBuilder } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig, HeadingLevel } from './HeadingPlugin.js';\n\n/** Registers all heading commands (setTitle, setSubtitle, setHeadingN, toggleHeading, setParagraph). */\nexport function registerHeadingCommands(context: PluginContext, config: HeadingConfig): void {\n\tcontext.registerCommand('setTitle', () => toggleSpecialBlock(context, 'title'));\n\n\tcontext.registerCommand('setSubtitle', () => toggleSpecialBlock(context, 'subtitle'));\n\n\tfor (const level of config.levels) {\n\t\tcontext.registerCommand(`setHeading${level}`, () => toggleHeading(context, level));\n\t}\n\n\tcontext.registerCommand('toggleHeading', () => toggleHeading(context, 1));\n\n\tcontext.registerCommand('setParagraph', () => setBlockType(context, nodeType('paragraph')));\n}\n\n// --- Command Implementations ---\n\n/**\n * Toggles between a special block type (title/subtitle) and paragraph.\n * If the block is already that type, resets to paragraph.\n */\nfunction toggleSpecialBlock(context: PluginContext, type: string): boolean {\n\tconst state: EditorState = context.getState();\n\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(state.selection.anchor.blockId);\n\tif (!block) return false;\n\n\tif (block.type === type) {\n\t\treturn setBlockType(context, nodeType('paragraph'));\n\t}\n\n\treturn setBlockType(context, nodeType(type) as NodeTypeName);\n}\n\n/**\n * Toggles between heading (at given level) and paragraph.\n * If the block is already a heading at the same level, resets to paragraph.\n */\nfunction toggleHeading(context: PluginContext, level: HeadingLevel): boolean {\n\tconst state: EditorState = context.getState();\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block) return false;\n\n\tif (block.type === 'heading' && block.attrs?.level === level) {\n\t\treturn setBlockType(context, nodeType('paragraph'));\n\t}\n\n\treturn setBlockType(context, nodeType('heading'), { level });\n}\n\nfunction setBlockType(\n\tcontext: PluginContext,\n\ttype: NodeTypeName,\n\tattrs?: Record<string, string | number | boolean>,\n): boolean {\n\tconst state: EditorState = context.getState();\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block) return false;\n\n\tconst builder: TransactionBuilder = state.transaction('command');\n\n\tconst spec = context.getSchemaRegistry().getNodeSpec(type);\n\tif (spec?.excludeMarks && spec.excludeMarks.length > 0) {\n\t\tstripExcludedMarks(builder, block, spec.excludeMarks);\n\t\tclearExcludedStoredMarks(builder, state, spec.excludeMarks);\n\t}\n\n\tconst tr = builder.setBlockType(sel.anchor.blockId, type, attrs).setSelection(sel).build();\n\tcontext.dispatch(tr);\n\treturn true;\n}\n\n// --- Mark Stripping Helpers ---\n\n/**\n * Adds removeMark steps for each excluded mark type found\n * on the block's inline text content.\n */\nfunction stripExcludedMarks(\n\tbuilder: TransactionBuilder,\n\tblock: BlockNode,\n\texcludeMarks: readonly string[],\n): void {\n\tconst blockLength: number = getBlockLength(block);\n\tif (blockLength === 0) return;\n\n\tconst excludeSet: Set<string> = new Set(excludeMarks);\n\tconst inlineChildren = getInlineChildren(block);\n\tlet offset = 0;\n\n\tfor (const child of inlineChildren) {\n\t\tif (isTextNode(child)) {\n\t\t\tif (child.text.length > 0) {\n\t\t\t\tfor (const mark of child.marks) {\n\t\t\t\t\tif (excludeSet.has(mark.type)) {\n\t\t\t\t\t\tbuilder.removeMark(block.id, offset, offset + child.text.length, mark);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += child.text.length;\n\t\t} else {\n\t\t\toffset += 1;\n\t\t}\n\t}\n}\n\n/**\n * Clears excluded mark types from stored marks so that\n * subsequent typing does not reintroduce them.\n */\nfunction clearExcludedStoredMarks(\n\tbuilder: TransactionBuilder,\n\tstate: EditorState,\n\texcludeMarks: readonly string[],\n): void {\n\tif (!state.storedMarks) return;\n\n\tconst excludeSet: Set<string> = new Set(excludeMarks);\n\tconst filtered: readonly Mark[] = state.storedMarks.filter((m: Mark) => !excludeSet.has(m.type));\n\n\tif (filtered.length !== state.storedMarks.length) {\n\t\tbuilder.setStoredMarks(filtered.length > 0 ? filtered : null, state.storedMarks);\n\t}\n}\n","/**\n * Keyboard handlers for heading block types.\n * Handles Enter key behavior: empty heading → paragraph, cursor at end → split + paragraph.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockLength, getBlockText } from '../../model/Document.js';\nimport {\n\tcreateCollapsedSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig } from './HeadingPlugin.js';\n\n// --- Context Guard ---\n\nconst HEADING_TYPES: ReadonlySet<string> = new Set(['heading', 'title', 'subtitle']);\n\ninterface HeadingContext {\n\treadonly state: EditorState;\n\treadonly block: BlockNode;\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Guards against NodeSelection, non-collapsed selections, and non-heading blocks.\n * Returns false (not handled) if the cursor is not inside a heading-type block.\n */\nfunction withHeadingContext(\n\tcontext: PluginContext,\n\thandler: (ctx: HeadingContext) => boolean,\n): boolean {\n\tconst state: EditorState = context.getState();\n\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\n\tconst sel = state.selection;\n\tif (!isCollapsed(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block || !HEADING_TYPES.has(block.type)) return false;\n\n\treturn handler({\n\t\tstate,\n\t\tblock,\n\t\tblockId: sel.anchor.blockId,\n\t\toffset: sel.anchor.offset,\n\t});\n}\n\n/** Registers all heading keyboard handlers (Enter, Mod-Shift-N shortcuts). */\nexport function registerHeadingKeymaps(context: PluginContext, config: HeadingConfig): void {\n\tconst keymap: Record<string, () => boolean> = {\n\t\tEnter: () => handleEnter(context),\n\t};\n\n\tfor (const level of config.levels) {\n\t\tif (level <= 6) {\n\t\t\tkeymap[`Mod-Shift-${level}`] = () => context.executeCommand(`setHeading${level}`);\n\t\t}\n\t}\n\n\tcontext.registerKeymap(keymap);\n}\n\n// --- Enter Handler ---\n\n/**\n * Handles Enter inside a heading block.\n * Empty heading → convert to paragraph.\n * Cursor at end → split and convert new block to paragraph.\n * Cursor in middle → normal split (both stay heading).\n */\nfunction handleEnter(context: PluginContext): boolean {\n\treturn withHeadingContext(context, (ctx) => {\n\t\tconst text: string = getBlockText(ctx.block);\n\n\t\tif (text === '') {\n\t\t\tconst tr = ctx.state\n\t\t\t\t.transaction('input')\n\t\t\t\t.setBlockType(ctx.blockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(ctx.state.selection)\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst blockLength: number = getBlockLength(ctx.block);\n\n\t\tif (ctx.offset >= blockLength) {\n\t\t\tconst newBlockId = generateBlockId();\n\t\t\tconst tr = ctx.state\n\t\t\t\t.transaction('input')\n\t\t\t\t.splitBlock(ctx.blockId, ctx.offset, newBlockId)\n\t\t\t\t.setBlockType(newBlockId, nodeType('paragraph'))\n\t\t\t\t.setSelection(createCollapsedSelection(newBlockId, 0))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n","/**\n * Locale interface and default English locale for the HeadingPlugin.\n */\n\n// --- Locale Interface ---\n\nexport interface HeadingLocale {\n\treadonly paragraph: string;\n\treadonly title: string;\n\treadonly subtitle: string;\n\treadonly heading1: string;\n\treadonly heading2: string;\n\treadonly heading3: string;\n\treadonly heading4: string;\n\treadonly heading5: string;\n\treadonly heading6: string;\n\treadonly blockTypeLabel: string;\n\treadonly blockTypesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const HEADING_LOCALE_EN: HeadingLocale = {\n\tparagraph: 'Paragraph',\n\ttitle: 'Title',\n\tsubtitle: 'Subtitle',\n\theading1: 'Heading 1',\n\theading2: 'Heading 2',\n\theading3: 'Heading 3',\n\theading4: 'Heading 4',\n\theading5: 'Heading 5',\n\theading6: 'Heading 6',\n\tblockTypeLabel: 'Block Type',\n\tblockTypesAria: 'Block types',\n};\n\n// --- German Locale ---\n\nexport const HEADING_LOCALE_DE: HeadingLocale = {\n\tparagraph: 'Absatz',\n\ttitle: 'Titel',\n\tsubtitle: 'Untertitel',\n\theading1: 'Überschrift 1',\n\theading2: 'Überschrift 2',\n\theading3: 'Überschrift 3',\n\theading4: 'Überschrift 4',\n\theading5: 'Überschrift 5',\n\theading6: 'Überschrift 6',\n\tblockTypeLabel: 'Blocktyp',\n\tblockTypesAria: 'Blocktypen',\n};\n\n// --- Spanish Locale ---\n\nexport const HEADING_LOCALE_ES: HeadingLocale = {\n\tparagraph: 'Párrafo',\n\ttitle: 'Título',\n\tsubtitle: 'Subtítulo',\n\theading1: 'Encabezado 1',\n\theading2: 'Encabezado 2',\n\theading3: 'Encabezado 3',\n\theading4: 'Encabezado 4',\n\theading5: 'Encabezado 5',\n\theading6: 'Encabezado 6',\n\tblockTypeLabel: 'Tipo de bloque',\n\tblockTypesAria: 'Tipos de bloque',\n};\n\n// --- French Locale ---\n\nexport const HEADING_LOCALE_FR: HeadingLocale = {\n\tparagraph: 'Paragraphe',\n\ttitle: 'Titre',\n\tsubtitle: 'Sous-titre',\n\theading1: 'Titre 1',\n\theading2: 'Titre 2',\n\theading3: 'Titre 3',\n\theading4: 'Titre 4',\n\theading5: 'Titre 5',\n\theading6: 'Titre 6',\n\tblockTypeLabel: 'Type de bloc',\n\tblockTypesAria: 'Types de bloc',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const HEADING_LOCALE_ZH: HeadingLocale = {\n\tparagraph: '正文',\n\ttitle: '标题',\n\tsubtitle: '副标题',\n\theading1: '一级标题',\n\theading2: '二级标题',\n\theading3: '三级标题',\n\theading4: '四级标题',\n\theading5: '五级标题',\n\theading6: '六级标题',\n\tblockTypeLabel: '块类型',\n\tblockTypesAria: '块类型列表',\n};\n\n// --- Russian Locale ---\n\nexport const HEADING_LOCALE_RU: HeadingLocale = {\n\tparagraph: 'Абзац',\n\ttitle: 'Заголовок',\n\tsubtitle: 'Подзаголовок',\n\theading1: 'Заголовок 1',\n\theading2: 'Заголовок 2',\n\theading3: 'Заголовок 3',\n\theading4: 'Заголовок 4',\n\theading5: 'Заголовок 5',\n\theading6: 'Заголовок 6',\n\tblockTypeLabel: 'Тип блока',\n\tblockTypesAria: 'Типы блоков',\n};\n\n// --- Arabic Locale ---\n\nexport const HEADING_LOCALE_AR: HeadingLocale = {\n\tparagraph: 'فقرة',\n\ttitle: 'عنوان',\n\tsubtitle: 'عنوان فرعي',\n\theading1: 'عنوان 1',\n\theading2: 'عنوان 2',\n\theading3: 'عنوان 3',\n\theading4: 'عنوان 4',\n\theading5: 'عنوان 5',\n\theading6: 'عنوان 6',\n\tblockTypeLabel: 'نوع الكتلة',\n\tblockTypesAria: 'أنواع الكتل',\n};\n\n// --- Hindi Locale ---\n\nexport const HEADING_LOCALE_HI: HeadingLocale = {\n\tparagraph: 'अनुच्छेद',\n\ttitle: 'शीर्षक',\n\tsubtitle: 'उपशीर्षक',\n\theading1: 'शीर्षक 1',\n\theading2: 'शीर्षक 2',\n\theading3: 'शीर्षक 3',\n\theading4: 'शीर्षक 4',\n\theading5: 'शीर्षक 5',\n\theading6: 'शीर्षक 6',\n\tblockTypeLabel: 'ब्लॉक प्रकार',\n\tblockTypesAria: 'ब्लॉक प्रकार सूची',\n};\n\n// --- Locale Map ---\n\nexport const HEADING_LOCALES: Record<string, HeadingLocale> = {\n\ten: HEADING_LOCALE_EN,\n\tde: HEADING_LOCALE_DE,\n\tes: HEADING_LOCALE_ES,\n\tfr: HEADING_LOCALE_FR,\n\tzh: HEADING_LOCALE_ZH,\n\tru: HEADING_LOCALE_RU,\n\tar: HEADING_LOCALE_AR,\n\thi: HEADING_LOCALE_HI,\n};\n","/**\n * HeadingPlugin: registers Title, Subtitle, and H1–H6 heading block types\n * with NodeSpec, toggle commands, keyboard shortcuts, input rules, and a\n * combobox-style toolbar dropdown that reflects the current block type.\n *\n * This file is a thin orchestrator — command logic, input rules, keyboard\n * handlers, and picker/toolbar rendering are delegated to dedicated modules.\n */\n\nimport { HEADING_SELECT_CSS } from '../../editor/styles/heading-select.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport { createBlockElement } from '../../model/NodeSpec.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport type { BlockAlignment } from '../alignment/AlignmentPlugin.js';\nimport {\n\tregisterHeadingPickerEntries,\n\tregisterHeadingToolbarItem,\n\tupdateComboLabel,\n} from './HeadingBlockTypePicker.js';\nimport { registerHeadingCommands } from './HeadingCommands.js';\nimport { registerHeadingInputRules } from './HeadingInputRules.js';\nimport { registerHeadingKeymaps } from './HeadingKeyboardHandlers.js';\nimport { HEADING_LOCALES, type HeadingLocale } from './HeadingLocale.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\theading: { level: HeadingLevel; align?: BlockAlignment };\n\t\ttitle: { align?: BlockAlignment };\n\t\tsubtitle: { align?: BlockAlignment };\n\t}\n}\n\n// --- Configuration ---\n\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport interface HeadingConfig {\n\t/** Which heading levels to enable. Defaults to [1, 2, 3, 4, 5, 6]. */\n\treadonly levels: readonly HeadingLevel[];\n\t/** When true, a separator is rendered after the heading toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: HeadingLocale;\n}\n\nconst DEFAULT_CONFIG: HeadingConfig = {\n\tlevels: [1, 2, 3, 4, 5, 6],\n};\n\n// --- Heading Tag Mapping ---\n\nconst HEADING_TAGS: Record<HeadingLevel, string> = {\n\t1: 'h1',\n\t2: 'h2',\n\t3: 'h3',\n\t4: 'h4',\n\t5: 'h5',\n\t6: 'h6',\n};\n\n// --- Plugin ---\n\nexport class HeadingPlugin implements Plugin {\n\treadonly id = 'heading';\n\treadonly name = 'Heading';\n\treadonly priority = 30;\n\n\tprivate readonly config: HeadingConfig;\n\tprivate locale!: HeadingLocale;\n\tprivate context: PluginContext | null = null;\n\tprivate comboLabel: HTMLSpanElement | null = null;\n\n\tconstructor(config?: Partial<HeadingConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(HEADING_LOCALES, context, this.config.locale);\n\t\tcontext.registerStyleSheet(HEADING_SELECT_CSS);\n\t\tthis.context = context;\n\n\t\tthis.registerNodeSpecs(context);\n\t\tregisterHeadingCommands(context, this.config);\n\t\tregisterHeadingKeymaps(context, this.config);\n\t\tregisterHeadingInputRules(context, this.config);\n\t\tregisterHeadingPickerEntries(context, this.config, this.locale);\n\t\tregisterHeadingToolbarItem(context, this.config, this.locale);\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\tif (!this.context) return;\n\t\tthis.comboLabel = updateComboLabel(_newState, this.context, this.locale, this.comboLabel);\n\t}\n\n\tprivate registerNodeSpecs(context: PluginContext): void {\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'title',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\ttoDOM(node) {\n\t\t\t\tconst el = createBlockElement('h1', node.id);\n\t\t\t\tel.classList.add('notectl-title');\n\t\t\t\treturn el;\n\t\t\t},\n\t\t\ttoHTML(_node, content) {\n\t\t\t\treturn `<h1>${content || '<br>'}</h1>`;\n\t\t\t},\n\t\t\tsanitize: { tags: ['h1'] },\n\t\t});\n\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'subtitle',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\ttoDOM(node) {\n\t\t\t\tconst el = createBlockElement('h2', node.id);\n\t\t\t\tel.classList.add('notectl-subtitle');\n\t\t\t\treturn el;\n\t\t\t},\n\t\t\ttoHTML(_node, content) {\n\t\t\t\treturn `<h2>${content || '<br>'}</h2>`;\n\t\t\t},\n\t\t\tsanitize: { tags: ['h2'] },\n\t\t});\n\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'heading',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\texcludeMarks: ['fontSize'],\n\t\t\tattrs: {\n\t\t\t\tlevel: { default: 1 },\n\t\t\t},\n\t\t\ttoDOM(node) {\n\t\t\t\tconst level = node.attrs?.level ?? 1;\n\t\t\t\tconst tag = HEADING_TAGS[level] ?? 'h1';\n\t\t\t\treturn createBlockElement(tag, node.id);\n\t\t\t},\n\t\t\ttoHTML(node, content) {\n\t\t\t\tconst level = (node.attrs?.level ?? 1) as HeadingLevel;\n\t\t\t\tconst tag: string = HEADING_TAGS[level] ?? 'h1';\n\t\t\t\treturn `<${tag}>${content || '<br>'}</${tag}>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{ tag: 'h1', getAttrs: () => ({ level: 1 }) },\n\t\t\t\t{ tag: 'h2', getAttrs: () => ({ level: 2 }) },\n\t\t\t\t{ tag: 'h3', getAttrs: () => ({ level: 3 }) },\n\t\t\t\t{ tag: 'h4', getAttrs: () => ({ level: 4 }) },\n\t\t\t\t{ tag: 'h5', getAttrs: () => ({ level: 5 }) },\n\t\t\t\t{ tag: 'h6', getAttrs: () => ({ level: 6 }) },\n\t\t\t],\n\t\t\tsanitize: { tags: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] },\n\t\t});\n\t}\n}\n","/** Heading picker toolbar combobox + popup styles. */\nexport const HEADING_SELECT_CSS = `\n/* Heading Select — Combobox-style toolbar button */\n.notectl-toolbar-btn--heading {\n\twidth: auto;\n\tmin-width: 100px;\n\tmax-width: 160px;\n\tpadding: 0 8px;\n\tgap: 4px;\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 4px;\n\tbackground: var(--notectl-bg);\n}\n\n.notectl-toolbar-btn--heading:hover {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-fg-muted);\n}\n\n.notectl-toolbar-btn--heading.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-bg);\n\tborder-color: var(--notectl-primary-muted);\n}\n\n.notectl-toolbar-btn--heading .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--heading .notectl-toolbar-btn__icon svg {\n\tdisplay: none;\n}\n\n.notectl-heading-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-heading-select__arrow {\n\tflex-shrink: 0;\n\tfont-size: 11px;\n\tcolor: var(--notectl-fg-muted);\n\tline-height: 30px;\n}\n\n/* Heading Picker Popup */\n.notectl-heading-picker {\n\tmin-width: 200px;\n\tmax-height: 320px;\n\toverflow-y: auto;\n}\n\n.notectl-heading-picker__list {\n\tpadding: 4px 0;\n}\n\n.notectl-heading-picker__item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\twidth: 100%;\n\tpadding: 7px 12px;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\ttext-align: left;\n\twhite-space: nowrap;\n\tfont-family: inherit;\n\ttransition: background 0.1s;\n}\n\n.notectl-heading-picker__item:hover {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-heading-picker__item--active {\n\tbackground: var(--notectl-active-bg);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__item--active:hover {\n\tbackground: var(--notectl-active-bg);\n}\n\n.notectl-heading-picker__check {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 16px;\n\tflex-shrink: 0;\n\tfont-size: 13px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-heading-picker__label {\n\tflex: 1;\n}\n`;\n","/**\n * Input rule registration for heading block types.\n * Converts `# `, `## `, etc. at the start of a paragraph into headings.\n */\n\nimport {\n\tcreateCollapsedSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { HeadingConfig } from './HeadingPlugin.js';\n\n/** Registers markdown-style input rules (e.g. `# ` → H1) for configured heading levels. */\nexport function registerHeadingInputRules(context: PluginContext, config: HeadingConfig): void {\n\tfor (const level of config.levels) {\n\t\tconst hashes: string = '#'.repeat(level);\n\t\tconst pattern: RegExp = new RegExp(`^${hashes} $`);\n\n\t\tcontext.registerInputRule({\n\t\t\tpattern,\n\t\t\thandler(state, _match, start, _end) {\n\t\t\t\tconst sel = state.selection;\n\t\t\t\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, start, start + level + 1)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('heading'), { level })\n\t\t\t\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0))\n\t\t\t\t\t.build();\n\t\t\t},\n\t\t});\n\t}\n}\n"],"names":["createPickerItem","label","isActive","handler","style","item","document","createElement","type","className","setAttribute","String","classList","add","check","textContent","appendChild","labelSpan","fontSize","fontWeight","addEventListener","getHeadingLabel","locale","level","toggleSpecialBlock","context","state","getState","isNodeSelection","selection","isGapCursor","block","getBlock","anchor","blockId","setBlockType","nodeType","toggleHeading","sel","attrs","builder","transaction","spec","getSchemaRegistry","getNodeSpec","excludeMarks","length","getBlockLength","excludeSet","Set","inlineChildren","getInlineChildren","offset","child","isTextNode","text","mark","marks","has","removeMark","id","storedMarks","filtered","filter","m","setStoredMarks","tr","setSelection","build","dispatch","HEADING_TYPES","HEADING_LOCALE_EN","paragraph","title","subtitle","heading1","heading2","heading3","heading4","heading5","heading6","blockTypeLabel","blockTypesAria","HEADING_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_CONFIG","levels","HEADING_TAGS","HeadingPlugin","name","priority","config","comboLabel","this","resolvePluginLocale","registerStyleSheet","registerNodeSpecs","registerCommand","keymap","Enter","isCollapsed","ctx","getBlockText","blockLength","newBlockId","generateBlockId","splitBlock","createCollapsedSelection","executeCommand","registerKeymap","hashes","repeat","pattern","RegExp","registerInputRule","_match","start","_end","deleteTextAt","registerBlockTypePickerEntry","command","icon","registerToolbarItem","group","tooltip","popupType","separatorAfter","renderPopup","container","list","entries","getBlockTypePickerRegistry","getBlockTypePickerEntries","entry","active","e","preventDefault","stopPropagation","toolbar","getService","ToolbarServiceKey","closePopup","some","destroy","_oldState","_newState","_tr","cachedLabel","getPluginContainer","querySelector","registerNodeSpec","content","allow","node","el","createBlockElement","toHTML","_node","sanitize","tags","default","tag","parseHTML","getAttrs"],"mappings":";;;;;;AA0KA,SAASA,EACRC,IACAC,IACAC,IACAC,IAAAA;AAEA,QAAMC,KAA0BC,SAASC,cAAc;AACvDF,EAAAA,GAAKG,OAAO,UACZH,GAAKI,YAAY,gCACjBJ,GAAKK,aAAa,QAAQ,QAAA,GAC1BL,GAAKK,aAAa,iBAAiBC,OAAOT,EAAAA,CAAAA,G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AAO,QACvC,EAAEiJ,KAAK,MAAME,UAAU,OAAA,EAASnJ,OAAO,EAAA,GAAA,GACvC,EAAEiJ,KAAK,MAAME,UAAU,OAAA,EAASnJ,OAAO,EAAA,GAAA,GACvC,EAAEiJ,KAAK,MAAME,UAAU,OAAA,EAASnJ,OAAO,EAAA,GAAA,GACvC,EAAEiJ,KAAK,MAAME,UAAU,OAAA,EAASnJ,OAAO,EAAA,GAAA,CAAA,GAExC8I,UAAU,EAAEC,MAAM,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,IAAA,EAAA,EAAA,CAAA;AAAA,EAEnD;AAAA;"}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { r as t } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
2
|
-
import { a as e } from "./ToolbarPlugin-B6JETWaw.mjs";
|
|
3
|
-
import { f as n } from "./Commands-CicwYoTQ.mjs";
|
|
4
|
-
import { i as o } from "./AttrRegistry-I-VdmRnN.mjs";
|
|
5
|
-
import { g as i, h as r } from "./Document-CuwE73FF.mjs";
|
|
6
|
-
import { i as s, a, b as l, s as c } from "./Selection-DmFDwiPJ.mjs";
|
|
7
|
-
import { m as p } from "./TypeBrands-C09nE2qO.mjs";
|
|
8
|
-
const f = { label: "Font Size", tooltip: "Font Size", customFontSizeAria: "Custom font size", fontSizesAria: "Font sizes" }, u = { en: f, de: { label: "Schriftgröße", tooltip: "Schriftgröße", customFontSizeAria: "Benutzerdefinierte Schriftgröße", fontSizesAria: "Schriftgrößen" }, es: { label: "Tamaño de fuente", tooltip: "Tamaño de fuente", customFontSizeAria: "Tamaño de fuente personalizado", fontSizesAria: "Tamaños de fuente" }, fr: { label: "Taille de police", tooltip: "Taille de police", customFontSizeAria: "Taille de police personnalisée", fontSizesAria: "Tailles de police" }, zh: { label: "字号", tooltip: "字号", customFontSizeAria: "自定义字号", fontSizesAria: "字号列表" }, ru: { label: "Размер шрифта", tooltip: "Размер шрифта", customFontSizeAria: "Произвольный размер шрифта", fontSizesAria: "Размеры шрифта" }, ar: { label: "حجم الخط", tooltip: "حجم الخط", customFontSizeAria: "حجم خط مخصص", fontSizesAria: "أحجام الخط" }, hi: { label: "फ़ॉन्ट आकार", tooltip: "फ़ॉन्ट आकार", customFontSizeAria: "कस्टम फ़ॉन्ट आकार", fontSizesAria: "फ़ॉन्ट आकार सूची" } };
|
|
9
|
-
function d(t2) {
|
|
10
|
-
const e2 = t2.selection;
|
|
11
|
-
if (s(e2) || a(e2)) return null;
|
|
12
|
-
if (l(e2) && t2.storedMarks) return S(t2.storedMarks);
|
|
13
|
-
const n2 = t2.getBlock(e2.anchor.blockId);
|
|
14
|
-
return n2 ? S(i(n2, e2.anchor.offset)) : null;
|
|
15
|
-
}
|
|
16
|
-
function m(t2, e2) {
|
|
17
|
-
const n2 = d(t2);
|
|
18
|
-
if (!n2) return e2;
|
|
19
|
-
const o2 = Number.parseInt(n2, 10);
|
|
20
|
-
return Number.isNaN(o2) ? e2 : o2;
|
|
21
|
-
}
|
|
22
|
-
function z(t2, e2, o2) {
|
|
23
|
-
const r2 = e2.selection;
|
|
24
|
-
if (s(r2) || a(r2)) return false;
|
|
25
|
-
if (l(r2)) {
|
|
26
|
-
const n2 = e2.getBlock(r2.anchor.blockId);
|
|
27
|
-
if (!n2) return false;
|
|
28
|
-
const s2 = [...(e2.storedMarks ?? i(n2, r2.anchor.offset)).filter((t3) => "fontSize" !== t3.type), { type: p("fontSize"), attrs: { size: o2 } }], a2 = e2.transaction("command").setStoredMarks(s2, e2.storedMarks).setSelection(r2).build();
|
|
29
|
-
return t2.dispatch(a2), true;
|
|
30
|
-
}
|
|
31
|
-
const f2 = c(r2, e2.getBlockOrder()), u2 = e2.transaction("command"), d2 = { type: p("fontSize"), attrs: { size: o2 } };
|
|
32
|
-
return n(e2, f2, (t3, e3, n2) => {
|
|
33
|
-
u2.removeMark(t3, e3, n2, { type: p("fontSize") }), u2.addMark(t3, e3, n2, d2);
|
|
34
|
-
}), u2.setSelection(r2), t2.dispatch(u2.build()), true;
|
|
35
|
-
}
|
|
36
|
-
function b(t2, e2) {
|
|
37
|
-
const o2 = e2.selection;
|
|
38
|
-
if (s(o2) || a(o2)) return false;
|
|
39
|
-
if (l(o2)) {
|
|
40
|
-
const n2 = e2.getBlock(o2.anchor.blockId);
|
|
41
|
-
if (!n2) return false;
|
|
42
|
-
const s2 = e2.storedMarks ?? i(n2, o2.anchor.offset);
|
|
43
|
-
if (!r(s2, p("fontSize"))) return false;
|
|
44
|
-
const a2 = s2.filter((t3) => "fontSize" !== t3.type), l2 = e2.transaction("command").setStoredMarks(a2, e2.storedMarks).setSelection(o2).build();
|
|
45
|
-
return t2.dispatch(l2), true;
|
|
46
|
-
}
|
|
47
|
-
const f2 = c(o2, e2.getBlockOrder()), u2 = e2.transaction("command");
|
|
48
|
-
return n(e2, f2, (t3, e3, n2) => {
|
|
49
|
-
u2.removeMark(t3, e3, n2, { type: p("fontSize") });
|
|
50
|
-
}), u2.setSelection(o2), t2.dispatch(u2.build()), true;
|
|
51
|
-
}
|
|
52
|
-
function g(t2, e2, n2, o2, i2) {
|
|
53
|
-
const r2 = (function(t3, e3, n3) {
|
|
54
|
-
if ("up" === e3) {
|
|
55
|
-
for (const e4 of n3) if (e4 > t3) return e4;
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
for (let e4 = n3.length - 1; e4 >= 0; e4--) {
|
|
59
|
-
const o3 = n3[e4];
|
|
60
|
-
if (void 0 !== o3 && o3 < t3) return o3;
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
63
|
-
})(m(e2, i2), n2, o2);
|
|
64
|
-
return null !== r2 && (r2 === i2 ? b(t2, e2) : z(t2, e2, `${r2}px`));
|
|
65
|
-
}
|
|
66
|
-
function h(t2, e2, n2) {
|
|
67
|
-
e2 === n2 ? t2.executeCommand("removeFontSize") : z(t2, t2.getState(), `${e2}px`);
|
|
68
|
-
}
|
|
69
|
-
function S(t2) {
|
|
70
|
-
const e2 = t2.find((t3) => "fontSize" === t3.type);
|
|
71
|
-
return e2 && o(e2, "fontSize") ? e2.attrs.size ?? null : null;
|
|
72
|
-
}
|
|
73
|
-
function k(t2, e2) {
|
|
74
|
-
const n2 = document.createElement("button");
|
|
75
|
-
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");
|
|
76
|
-
const o2 = document.createElement("span");
|
|
77
|
-
o2.className = "notectl-font-size-picker__check", o2.textContent = e2 ? "✓" : "", n2.appendChild(o2);
|
|
78
|
-
const i2 = document.createElement("span");
|
|
79
|
-
return i2.className = "notectl-font-size-picker__label", i2.textContent = String(t2), n2.appendChild(i2), n2;
|
|
80
|
-
}
|
|
81
|
-
const v = [8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96];
|
|
82
|
-
class x {
|
|
83
|
-
id = "fontSize";
|
|
84
|
-
name = "Font Size";
|
|
85
|
-
priority = 21;
|
|
86
|
-
config;
|
|
87
|
-
sizes;
|
|
88
|
-
defaultSize;
|
|
89
|
-
locale;
|
|
90
|
-
context = null;
|
|
91
|
-
comboLabel = null;
|
|
92
|
-
constructor(t2) {
|
|
93
|
-
var e2;
|
|
94
|
-
this.config = { ...t2 }, this.sizes = (function(t3) {
|
|
95
|
-
if (!t3 || 0 === t3.length) return v;
|
|
96
|
-
const e3 = [...new Set(t3)].filter((t4) => Number.isInteger(t4) && t4 > 0);
|
|
97
|
-
return e3.sort((t4, e4) => t4 - e4), e3.length > 0 ? e3 : v;
|
|
98
|
-
})(t2?.sizes), this.defaultSize = (e2 = t2?.defaultSize, void 0 === e2 ? 16 : Number.isInteger(e2) && e2 > 0 ? e2 : 16);
|
|
99
|
-
}
|
|
100
|
-
init(e2) {
|
|
101
|
-
this.locale = t(u, e2, this.config.locale), e2.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 = e2, this.registerMarkSpec(e2), this.registerCommands(e2), this.registerKeymaps(e2), this.registerToolbarItem(e2), this.applyDefaultSizeToContainer(e2);
|
|
102
|
-
}
|
|
103
|
-
destroy() {
|
|
104
|
-
this.context = null, this.comboLabel = null;
|
|
105
|
-
}
|
|
106
|
-
onStateChange(t2, e2, n2) {
|
|
107
|
-
this.updateComboLabel(e2);
|
|
108
|
-
}
|
|
109
|
-
registerMarkSpec(t2) {
|
|
110
|
-
t2.registerMarkSpec({ type: "fontSize", rank: 4, attrs: { size: { default: "" } }, toDOM(t3) {
|
|
111
|
-
const e2 = document.createElement("span"), n2 = t3.attrs?.size ?? "";
|
|
112
|
-
return n2 && (e2.style.fontSize = n2), e2;
|
|
113
|
-
}, toHTMLString: (t3, e2) => {
|
|
114
|
-
const n2 = String(t3.attrs?.size ?? "");
|
|
115
|
-
return n2 ? `<span style="font-size: ${n2}">${e2}</span>` : e2;
|
|
116
|
-
}, parseHTML: [{ tag: "span", getAttrs: (t3) => {
|
|
117
|
-
const e2 = t3.style.fontSize;
|
|
118
|
-
return !!e2 && { size: e2 };
|
|
119
|
-
} }], sanitize: { tags: ["span"] } });
|
|
120
|
-
}
|
|
121
|
-
registerCommands(t2) {
|
|
122
|
-
t2.registerCommand("removeFontSize", () => b(t2, t2.getState())), t2.registerCommand("setFontSize", () => false), t2.registerCommand("increaseFontSize", () => g(t2, t2.getState(), "up", this.sizes, this.defaultSize)), t2.registerCommand("decreaseFontSize", () => g(t2, t2.getState(), "down", this.sizes, this.defaultSize));
|
|
123
|
-
}
|
|
124
|
-
registerKeymaps(t2) {
|
|
125
|
-
t2.registerKeymap({ "Mod-Shift-+": () => g(t2, t2.getState(), "up", this.sizes, this.defaultSize), "Mod-Shift-_": () => g(t2, t2.getState(), "down", this.sizes, this.defaultSize) });
|
|
126
|
-
}
|
|
127
|
-
registerToolbarItem(t2) {
|
|
128
|
-
const e2 = `<span class="notectl-font-size-select__label" data-font-size-label>${this.defaultSize}</span><span class="notectl-font-size-select__arrow">▾</span>`;
|
|
129
|
-
t2.registerToolbarItem({ id: "fontSize", group: "format", icon: e2, label: this.locale.label, tooltip: this.locale.tooltip, command: "removeFontSize", priority: 6, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (t3, e3) => {
|
|
130
|
-
!(function(t4, e4, n2) {
|
|
131
|
-
t4.classList.add("notectl-font-size-picker");
|
|
132
|
-
const o2 = m(e4.getState(), n2.defaultSize), i2 = (function(t5, e5) {
|
|
133
|
-
const n3 = document.createElement("input");
|
|
134
|
-
return n3.type = "number", n3.className = "notectl-font-size-picker__input", n3.min = String(1), n3.max = String(400), n3.value = String(t5), n3.setAttribute("aria-label", e5.locale?.customFontSizeAria ?? "Custom font size"), n3;
|
|
135
|
-
})(o2, n2);
|
|
136
|
-
!(function(t5, e5) {
|
|
137
|
-
const n3 = document.createElement("div");
|
|
138
|
-
n3.className = "notectl-font-size-picker__input-wrapper", n3.appendChild(e5), t5.appendChild(n3);
|
|
139
|
-
})(t4, i2);
|
|
140
|
-
const { list: r2, items: s2 } = (function(t5, e5, n3, o3) {
|
|
141
|
-
const i3 = document.createElement("div");
|
|
142
|
-
i3.className = "notectl-font-size-picker__list", i3.setAttribute("role", "listbox"), i3.setAttribute("aria-label", o3.locale?.fontSizesAria ?? "Font sizes");
|
|
143
|
-
const r3 = [];
|
|
144
|
-
for (const s3 of t5) {
|
|
145
|
-
const t6 = k(s3, s3 === e5);
|
|
146
|
-
t6.addEventListener("mousedown", (t7) => {
|
|
147
|
-
t7.preventDefault(), t7.stopPropagation(), h(n3, s3, o3.defaultSize), o3.dismissPopup();
|
|
148
|
-
}), r3.push(t6), i3.appendChild(t6);
|
|
149
|
-
}
|
|
150
|
-
return { list: i3, items: r3 };
|
|
151
|
-
})(n2.sizes, o2, e4, n2);
|
|
152
|
-
t4.appendChild(r2), (function(t5, e5, n3, o3) {
|
|
153
|
-
const i3 = e5.indexOf(n3);
|
|
154
|
-
if (i3 < 0) return;
|
|
155
|
-
const r3 = t5[i3];
|
|
156
|
-
r3 && (requestAnimationFrame(() => {
|
|
157
|
-
r3.scrollIntoView({ block: "nearest" });
|
|
158
|
-
}), o3.setAttribute("aria-activedescendant", r3.id));
|
|
159
|
-
})(s2, n2.sizes, o2, r2), (function(t5, e5, n3, o3, i3) {
|
|
160
|
-
let r3 = -1;
|
|
161
|
-
const s3 = (t6) => {
|
|
162
|
-
r3 >= 0 && r3 < n3.length && n3[r3]?.classList.remove("notectl-font-size-picker__item--focused"), r3 = t6;
|
|
163
|
-
const o4 = n3[r3];
|
|
164
|
-
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));
|
|
165
|
-
};
|
|
166
|
-
t5.addEventListener("keydown", (e6) => {
|
|
167
|
-
if ("Enter" === e6.key) {
|
|
168
|
-
e6.preventDefault();
|
|
169
|
-
const n4 = Number.parseInt(t5.value, 10);
|
|
170
|
-
!Number.isNaN(n4) && n4 >= 1 && n4 <= 400 && (h(o3, n4, i3.defaultSize), i3.dismissPopup());
|
|
171
|
-
} else "ArrowDown" === e6.key ? (e6.preventDefault(), s3(0), n3[0]?.focus()) : "Escape" === e6.key && (e6.preventDefault(), i3.dismissPopup());
|
|
172
|
-
}), e5.addEventListener("keydown", (e6) => {
|
|
173
|
-
if ("ArrowDown" === e6.key) e6.preventDefault(), r3 < n3.length - 1 && (s3(r3 + 1), n3[r3]?.focus());
|
|
174
|
-
else if ("ArrowUp" === e6.key) e6.preventDefault(), r3 > 0 ? (s3(r3 - 1), n3[r3]?.focus()) : (s3(-1), t5.focus());
|
|
175
|
-
else if ("Enter" === e6.key) {
|
|
176
|
-
e6.preventDefault();
|
|
177
|
-
const t6 = i3.sizes[r3];
|
|
178
|
-
r3 >= 0 && r3 < i3.sizes.length && void 0 !== t6 && (h(o3, t6, i3.defaultSize), i3.dismissPopup());
|
|
179
|
-
} else "Escape" === e6.key && (e6.preventDefault(), i3.dismissPopup());
|
|
180
|
-
});
|
|
181
|
-
})(i2, r2, s2, e4, n2);
|
|
182
|
-
})(t3, e3, { sizes: this.sizes, defaultSize: this.defaultSize, dismissPopup: () => this.dismissPopup(), locale: this.locale });
|
|
183
|
-
}, isActive: (t3) => (function(t4) {
|
|
184
|
-
return null !== d(t4);
|
|
185
|
-
})(t3) });
|
|
186
|
-
}
|
|
187
|
-
applyDefaultSizeToContainer(t2) {
|
|
188
|
-
t2.getContainer().style.fontSize = `${this.defaultSize}px`;
|
|
189
|
-
}
|
|
190
|
-
dismissPopup() {
|
|
191
|
-
const t2 = this.context?.getService(e);
|
|
192
|
-
t2?.closePopup();
|
|
193
|
-
}
|
|
194
|
-
updateComboLabel(t2) {
|
|
195
|
-
if (!this.comboLabel) {
|
|
196
|
-
const t3 = this.context?.getPluginContainer("top");
|
|
197
|
-
if (!t3) return;
|
|
198
|
-
if (this.comboLabel = t3.querySelector("[data-font-size-label]") ?? null, !this.comboLabel) return;
|
|
199
|
-
}
|
|
200
|
-
const e2 = m(t2, this.defaultSize);
|
|
201
|
-
this.comboLabel.textContent = String(e2);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
export {
|
|
205
|
-
u as F,
|
|
206
|
-
f as a,
|
|
207
|
-
x as b
|
|
208
|
-
};
|
|
209
|
-
//# sourceMappingURL=index-DUC1X43Z.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-DUC1X43Z.mjs","sources":["../../src/editor/styles/font-size-select.ts","../../src/plugins/font-size/FontSizeLocale.ts","../../src/plugins/font-size/FontSizeOperations.ts","../../src/plugins/font-size/FontSizePopup.ts","../../src/plugins/font-size/FontSizePlugin.ts"],"sourcesContent":["/** Font size picker toolbar combobox + popup styles. */\nexport const FONT_SIZE_SELECT_CSS = `\n/* Font Size Select — 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","/** Locale interface and default English locale for the FontSizePlugin. */\n\n// --- Locale Interface ---\n\nexport interface FontSizeLocale {\n\treadonly label: string;\n\treadonly tooltip: string;\n\treadonly customFontSizeAria: string;\n\treadonly fontSizesAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const FONT_SIZE_LOCALE_EN: FontSizeLocale = {\n\tlabel: 'Font Size',\n\ttooltip: 'Font Size',\n\tcustomFontSizeAria: 'Custom font size',\n\tfontSizesAria: 'Font sizes',\n};\n\n// --- German Locale ---\n\nexport const FONT_SIZE_LOCALE_DE: FontSizeLocale = {\n\tlabel: 'Schriftgröße',\n\ttooltip: 'Schriftgröße',\n\tcustomFontSizeAria: 'Benutzerdefinierte Schriftgröße',\n\tfontSizesAria: 'Schriftgrößen',\n};\n\n// --- Spanish Locale ---\n\nexport const FONT_SIZE_LOCALE_ES: FontSizeLocale = {\n\tlabel: 'Tamaño de fuente',\n\ttooltip: 'Tamaño de fuente',\n\tcustomFontSizeAria: 'Tamaño de fuente personalizado',\n\tfontSizesAria: 'Tamaños de fuente',\n};\n\n// --- French Locale ---\n\nexport const FONT_SIZE_LOCALE_FR: FontSizeLocale = {\n\tlabel: 'Taille de police',\n\ttooltip: 'Taille de police',\n\tcustomFontSizeAria: 'Taille de police personnalisée',\n\tfontSizesAria: 'Tailles de police',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const FONT_SIZE_LOCALE_ZH: FontSizeLocale = {\n\tlabel: '字号',\n\ttooltip: '字号',\n\tcustomFontSizeAria: '自定义字号',\n\tfontSizesAria: '字号列表',\n};\n\n// --- Russian Locale ---\n\nexport const FONT_SIZE_LOCALE_RU: FontSizeLocale = {\n\tlabel: 'Размер шрифта',\n\ttooltip: 'Размер шрифта',\n\tcustomFontSizeAria: 'Произвольный размер шрифта',\n\tfontSizesAria: 'Размеры шрифта',\n};\n\n// --- Arabic Locale ---\n\nexport const FONT_SIZE_LOCALE_AR: FontSizeLocale = {\n\tlabel: 'حجم الخط',\n\ttooltip: 'حجم الخط',\n\tcustomFontSizeAria: 'حجم خط مخصص',\n\tfontSizesAria: 'أحجام الخط',\n};\n\n// --- Hindi Locale ---\n\nexport const FONT_SIZE_LOCALE_HI: FontSizeLocale = {\n\tlabel: 'फ़ॉन्ट आकार',\n\ttooltip: 'फ़ॉन्ट आकार',\n\tcustomFontSizeAria: 'कस्टम फ़ॉन्ट आकार',\n\tfontSizesAria: 'फ़ॉन्ट आकार सूची',\n};\n\n// --- Locale Map ---\n\nexport const FONT_SIZE_LOCALES: Record<string, FontSizeLocale> = {\n\ten: FONT_SIZE_LOCALE_EN,\n\tde: FONT_SIZE_LOCALE_DE,\n\tes: FONT_SIZE_LOCALE_ES,\n\tfr: FONT_SIZE_LOCALE_FR,\n\tzh: FONT_SIZE_LOCALE_ZH,\n\tru: FONT_SIZE_LOCALE_RU,\n\tar: FONT_SIZE_LOCALE_AR,\n\thi: FONT_SIZE_LOCALE_HI,\n};\n","/**\n * Pure business logic for font-size state queries and transaction builders.\n * All functions are DOM-free and operate on EditorState / PluginContext.\n */\n\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 {\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n\tselectionRange,\n} 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) || isGapCursor(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) || isGapCursor(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) || isGapCursor(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 type { FontSizeLocale } from './FontSizeLocale.js';\nimport { getActiveSizeNumeric, selectSize } from './FontSizeOperations.js';\n\n// --- Constants ---\n\nconst MIN_CUSTOM_SIZE = 1;\nconst MAX_CUSTOM_SIZE = 400;\n\n// --- Config ---\n\nexport interface FontSizePopupConfig {\n\treadonly sizes: readonly number[];\n\treadonly defaultSize: number;\n\treadonly dismissPopup: () => void;\n\treadonly locale?: FontSizeLocale;\n}\n\n// --- Public Entry Point ---\n\n/** Builds the font-size picker DOM inside the given container. */\nexport function renderFontSizePopup(\n\tcontainer: HTMLElement,\n\tcontext: PluginContext,\n\tconfig: FontSizePopupConfig,\n): void {\n\tcontainer.classList.add('notectl-font-size-picker');\n\n\tconst currentSize: number = getActiveSizeNumeric(context.getState(), config.defaultSize);\n\n\tconst input: HTMLInputElement = buildCustomInput(currentSize, config);\n\tappendInputWrapper(container, input);\n\n\tconst { list, items } = buildSizeList(config.sizes, currentSize, context, config);\n\tcontainer.appendChild(list);\n\n\tscrollActiveIntoView(items, config.sizes, currentSize, list);\n\tattachKeyboardNavigation(input, list, items, context, config);\n}\n\n// --- Custom Input ---\n\nfunction buildCustomInput(currentSize: number, config: FontSizePopupConfig): HTMLInputElement {\n\tconst input: HTMLInputElement = document.createElement('input');\n\tinput.type = 'number';\n\tinput.className = 'notectl-font-size-picker__input';\n\tinput.min = String(MIN_CUSTOM_SIZE);\n\tinput.max = String(MAX_CUSTOM_SIZE);\n\tinput.value = String(currentSize);\n\tinput.setAttribute('aria-label', config.locale?.customFontSizeAria ?? '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', config.locale?.fontSizesAria ?? '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 { resolvePluginLocale } from '../../i18n/resolvePluginLocale.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 { FONT_SIZE_LOCALES, type FontSizeLocale } from './FontSizeLocale.js';\nimport {\n\tgetActiveSizeNumeric,\n\tisFontSizeActive,\n\tremoveFontSize,\n\tstepFontSize,\n} from './FontSizeOperations.js';\nimport { renderFontSizePopup } from './FontSizePopup.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface MarkAttrRegistry {\n\t\tfontSize: { size: string };\n\t}\n}\n\n// --- Constants ---\n\n/** Default preset sizes shown in the font size dropdown. */\nexport const DEFAULT_FONT_SIZES: readonly number[] = [\n\t8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96,\n];\n\nconst DEFAULT_FONT_SIZE = 16;\n\n// --- Configuration ---\n\nexport interface FontSizeConfig {\n\t/**\n\t * Preset sizes shown in the font size dropdown.\n\t * Must contain positive integers. Values are sorted and deduplicated automatically.\n\t * Defaults to {@link DEFAULT_FONT_SIZES} when omitted or empty.\n\t */\n\treadonly sizes?: readonly number[];\n\t/**\n\t * The base font size that text has when no fontSize mark is applied.\n\t * Shown as the initial value in the toolbar combo and used as the\n\t * \"neutral\" size — selecting it removes the mark instead of applying one.\n\t * Defaults to 16.\n\t */\n\treadonly defaultSize?: number;\n\t/** When true, a separator is rendered after the fontSize toolbar item. */\n\treadonly separatorAfter?: boolean;\n\treadonly locale?: FontSizeLocale;\n}\n\n// --- Plugin ---\n\nexport class FontSizePlugin implements Plugin {\n\treadonly id = 'fontSize';\n\treadonly name = 'Font Size';\n\treadonly priority = 21;\n\n\tprivate readonly config: FontSizeConfig;\n\tprivate readonly sizes: readonly number[];\n\tprivate readonly defaultSize: number;\n\tprivate locale!: FontSizeLocale;\n\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\tthis.locale = resolvePluginLocale(FONT_SIZE_LOCALES, context, this.config.locale);\n\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: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip,\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\tlocale: this.locale,\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (state) => isFontSizeActive(state),\n\t\t});\n\t}\n\n\t/**\n\t * Sets the configured default font size on the editor content container\n\t * so that unformatted text renders at the correct size instead of the\n\t * browser default (16px).\n\t */\n\tprivate applyDefaultSizeToContainer(context: PluginContext): void {\n\t\tconst container: HTMLElement = context.getContainer();\n\t\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"],"names":["FONT_SIZE_LOCALE_EN","label","tooltip","customFontSizeAria","fontSizesAria","FONT_SIZE_LOCALES","en","de","es","fr","zh","ru","ar","hi","getActiveSize","state","sel","selection","isNodeSelection","isGapCursor","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","DEFAULT_FONT_SIZES","FontSizePlugin","name","priority","config","locale","comboLabel","this","unique","Set","n","isInteger","sort","a","b","resolvePluginLocale","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","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","getService","ToolbarServiceKey","closePopup","getPluginContainer","querySelector","activeSize"],"mappings":";;;;;;;AACO,MCYMA,IAAsC,EAClDC,OAAO,aACPC,SAAS,aACTC,oBAAoB,oBACpBC,eAAe,gBAoEHC,IAAoD,EAChEC,IAAIN,GACJO,IAjEkD,EAClDN,OAAO,gBACPC,SAAS,gBACTC,oBAAoB,mCACpBC,eAAe,gBAAA,GA8DfI,IAzDkD,EAClDP,OAAO,oBACPC,SAAS,oBACTC,oBAAoB,kCACpBC,eAAe,oBAAA,GAsDfK,IAjDkD,EAClDR,OAAO,oBACPC,SAAS,oBACTC,oBAAoB,kCACpBC,eAAe,oBAAA,GA8CfM,IAzCkD,EAClDT,OAAO,MAC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cC;IACtB,GEkJyCA,EAAAA,EAAAA,CAAAA;AAAAA,EAExC;AAAA,EAOQ,4BAA4BsB,IAAAA;AACJA,IAAAA,GAAQoI,aAAAA,EAC7B/C,MAAMC,WAAW,GAAGxB,KAAKrE,WAAAA;AAAAA,EACpC;AAAA,EAEQ,eAAA4H;AACP,UAAMgB,KAAUvE,KAAK9D,SAASsI,WAAWC,CAAAA;AACzCF,IAAAA,IAASG,WAAAA;AAAAA,EACV;AAAA,EAEQ,iBAAiB9J,IAAAA;AACxB,SAAKoF,KAAKD,YAAY;AACrB,YAAM0C,KAAqCzC,KAAK9D,SAASyI,mBAAmB,KAAA;AAC5E,UAAA,CAAKlC,GAAW;AAEhB,UADAzC,KAAKD,aAAa0C,GAAUmC,cAA+B,wBAAA,KAA6B,OACnF5E,KAAKD,WAAY;AAAA,IACvB;AAEA,UAAM8E,KAAqBnJ,EAAqBd,IAAOoF,KAAKrE,WAAAA;AAC5DqE,SAAKD,WAAWR,cAAcJ,OAAO0F,EAAAA;AAAAA,EACtC;AAAA;"}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { f as t } from "./Commands-CicwYoTQ.mjs";
|
|
2
|
-
import { r as n } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
3
|
-
import { i as e } from "./AttrRegistry-I-VdmRnN.mjs";
|
|
4
|
-
import { g as o, h as r, w as i } from "./Document-CuwE73FF.mjs";
|
|
5
|
-
import { i as l, a, b as s, s as c } from "./Selection-DmFDwiPJ.mjs";
|
|
6
|
-
import { m as f } from "./TypeBrands-C09nE2qO.mjs";
|
|
7
|
-
import { a as p } from "./ToolbarPlugin-B6JETWaw.mjs";
|
|
8
|
-
const m = { label: "Font", tooltip: "Font Family" }, d = { en: m, de: { label: "Schriftart", tooltip: "Schriftfamilie" }, es: { label: "Fuente", tooltip: "Familia de fuente" }, fr: { label: "Police", tooltip: "Famille de police" }, zh: { label: "字体", tooltip: "字体系列" }, ru: { label: "Шрифт", tooltip: "Семейство шрифтов" }, ar: { label: "الخط", tooltip: "عائلة الخط" }, hi: { label: "फ़ॉन्ट", tooltip: "फ़ॉन्ट परिवार" } };
|
|
9
|
-
class h {
|
|
10
|
-
id = "font";
|
|
11
|
-
name = "Font";
|
|
12
|
-
priority = 22;
|
|
13
|
-
config;
|
|
14
|
-
locale;
|
|
15
|
-
injectedStyleElement = null;
|
|
16
|
-
context = null;
|
|
17
|
-
comboLabel = null;
|
|
18
|
-
constructor(t2) {
|
|
19
|
-
this.config = t2;
|
|
20
|
-
}
|
|
21
|
-
init(t2) {
|
|
22
|
-
this.locale = n(d, t2, this.config.locale), 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();
|
|
23
|
-
}
|
|
24
|
-
destroy() {
|
|
25
|
-
this.injectedStyleElement?.remove(), this.injectedStyleElement = null, this.context = null, this.comboLabel = null;
|
|
26
|
-
}
|
|
27
|
-
onStateChange(t2, n2, e2) {
|
|
28
|
-
this.updateComboLabel(n2);
|
|
29
|
-
}
|
|
30
|
-
registerMarkSpec(t2) {
|
|
31
|
-
t2.registerMarkSpec({ type: "font", rank: 6, attrs: { family: { default: "" } }, toDOM(t3) {
|
|
32
|
-
const n2 = document.createElement("span"), e2 = t3.attrs?.family ?? "";
|
|
33
|
-
return e2 && (n2.style.fontFamily = e2), n2;
|
|
34
|
-
}, toHTMLString: (t3, n2) => {
|
|
35
|
-
const e2 = String(t3.attrs?.family ?? "");
|
|
36
|
-
return e2 ? `<span style="font-family: ${e2}">${n2}</span>` : n2;
|
|
37
|
-
}, parseHTML: [{ tag: "span", getAttrs: (t3) => {
|
|
38
|
-
const n2 = t3.style.fontFamily;
|
|
39
|
-
return !!n2 && { family: n2 };
|
|
40
|
-
} }], sanitize: { tags: ["span"] } });
|
|
41
|
-
}
|
|
42
|
-
registerCommands(t2) {
|
|
43
|
-
t2.registerCommand("removeFont", () => {
|
|
44
|
-
const n2 = t2.getState();
|
|
45
|
-
return this.removeFont(t2, n2);
|
|
46
|
-
}), t2.registerCommand("setFont", () => false);
|
|
47
|
-
}
|
|
48
|
-
get defaultFont() {
|
|
49
|
-
if (this.config.defaultFont) {
|
|
50
|
-
const t3 = this.config.fonts.find((t4) => t4.name === this.config.defaultFont);
|
|
51
|
-
if (t3) return t3;
|
|
52
|
-
}
|
|
53
|
-
const t2 = this.config.fonts[0];
|
|
54
|
-
if (!t2) throw new Error("FontPlugin: fonts list is empty");
|
|
55
|
-
return t2;
|
|
56
|
-
}
|
|
57
|
-
registerToolbarItem(t2) {
|
|
58
|
-
const n2 = `<span class="notectl-font-select__label" data-font-label>${this.defaultFont.name}</span><span class="notectl-font-select__arrow">▾</span>`;
|
|
59
|
-
t2.registerToolbarItem({ id: "font", group: "format", icon: n2, label: this.locale.label, tooltip: this.locale.tooltip, command: "removeFont", priority: 5, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (t3, n3) => {
|
|
60
|
-
this.renderFontPopup(t3, n3);
|
|
61
|
-
}, isActive: (t3) => this.isFontActive(t3) });
|
|
62
|
-
}
|
|
63
|
-
updateComboLabel(t2) {
|
|
64
|
-
if (!this.comboLabel) {
|
|
65
|
-
const t3 = this.context?.getPluginContainer("top");
|
|
66
|
-
if (!t3) return;
|
|
67
|
-
if (this.comboLabel = t3.querySelector("[data-font-label]") ?? null, !this.comboLabel) return;
|
|
68
|
-
}
|
|
69
|
-
const n2 = this.getActiveFont(t2), e2 = this.resolveFontName(n2);
|
|
70
|
-
this.comboLabel.textContent = e2;
|
|
71
|
-
}
|
|
72
|
-
resolveFontName(t2) {
|
|
73
|
-
if (!t2) return this.defaultFont.name;
|
|
74
|
-
const n2 = this.config.fonts.find((n3) => n3.family === t2);
|
|
75
|
-
return n2?.name ?? (t2.split(",")[0] ?? "").trim().replace(/'/g, "");
|
|
76
|
-
}
|
|
77
|
-
isFontActive(t2) {
|
|
78
|
-
return null !== this.getActiveFont(t2);
|
|
79
|
-
}
|
|
80
|
-
getActiveFont(t2) {
|
|
81
|
-
const n2 = t2.selection;
|
|
82
|
-
if (l(n2) || a(n2)) return null;
|
|
83
|
-
if (s(n2)) {
|
|
84
|
-
if (t2.storedMarks) {
|
|
85
|
-
const n3 = t2.storedMarks.find((t3) => "font" === t3.type);
|
|
86
|
-
return n3 && e(n3, "font") ? n3.attrs.family ?? null : null;
|
|
87
|
-
}
|
|
88
|
-
const r3 = t2.getBlock(n2.anchor.blockId);
|
|
89
|
-
if (!r3) return null;
|
|
90
|
-
const i3 = o(r3, n2.anchor.offset).find((t3) => "font" === t3.type);
|
|
91
|
-
return i3 && e(i3, "font") ? i3.attrs.family ?? null : null;
|
|
92
|
-
}
|
|
93
|
-
const r2 = t2.getBlock(n2.anchor.blockId);
|
|
94
|
-
if (!r2) return null;
|
|
95
|
-
const i2 = o(r2, n2.anchor.offset).find((t3) => "font" === t3.type);
|
|
96
|
-
return i2 && e(i2, "font") ? i2.attrs.family ?? null : null;
|
|
97
|
-
}
|
|
98
|
-
applyFont(n2, e2, r2) {
|
|
99
|
-
const i2 = e2.selection;
|
|
100
|
-
if (l(i2) || a(i2)) return false;
|
|
101
|
-
if (s(i2)) {
|
|
102
|
-
const t2 = e2.getBlock(i2.anchor.blockId);
|
|
103
|
-
if (!t2) return false;
|
|
104
|
-
const l2 = [...(e2.storedMarks ?? o(t2, i2.anchor.offset)).filter((t3) => "font" !== t3.type), { type: f("font"), attrs: { family: r2 } }], a2 = e2.transaction("command").setStoredMarks(l2, e2.storedMarks).setSelection(i2).build();
|
|
105
|
-
return n2.dispatch(a2), true;
|
|
106
|
-
}
|
|
107
|
-
const p2 = c(i2, e2.getBlockOrder()), m2 = e2.transaction("command"), d2 = { type: f("font"), attrs: { family: r2 } };
|
|
108
|
-
return t(e2, p2, (t2, n3, o2) => {
|
|
109
|
-
const r3 = e2.getBlock(t2);
|
|
110
|
-
if (r3) {
|
|
111
|
-
const e3 = this.findFontMarkInRange(r3, n3, o2);
|
|
112
|
-
e3 && m2.removeMark(t2, n3, o2, e3);
|
|
113
|
-
}
|
|
114
|
-
m2.addMark(t2, n3, o2, d2);
|
|
115
|
-
}), m2.setSelection(i2), n2.dispatch(m2.build()), true;
|
|
116
|
-
}
|
|
117
|
-
removeFont(n2, e2) {
|
|
118
|
-
const i2 = e2.selection;
|
|
119
|
-
if (l(i2) || a(i2)) return false;
|
|
120
|
-
if (s(i2)) {
|
|
121
|
-
const t2 = e2.getBlock(i2.anchor.blockId);
|
|
122
|
-
if (!t2) return false;
|
|
123
|
-
const l2 = e2.storedMarks ?? o(t2, i2.anchor.offset);
|
|
124
|
-
if (!r(l2, f("font"))) return false;
|
|
125
|
-
const a2 = l2.filter((t3) => "font" !== t3.type), s2 = e2.transaction("command").setStoredMarks(a2, e2.storedMarks).setSelection(i2).build();
|
|
126
|
-
return n2.dispatch(s2), true;
|
|
127
|
-
}
|
|
128
|
-
const p2 = c(i2, e2.getBlockOrder()), m2 = e2.transaction("command");
|
|
129
|
-
return t(e2, p2, (t2, n3, o2) => {
|
|
130
|
-
const r2 = e2.getBlock(t2);
|
|
131
|
-
if (r2) {
|
|
132
|
-
const e3 = this.findFontMarkInRange(r2, n3, o2);
|
|
133
|
-
e3 && m2.removeMark(t2, n3, o2, e3);
|
|
134
|
-
}
|
|
135
|
-
}), m2.setSelection(i2), n2.dispatch(m2.build()), true;
|
|
136
|
-
}
|
|
137
|
-
findFontMarkInRange(t2, n2, e2) {
|
|
138
|
-
const o2 = i(t2);
|
|
139
|
-
let r2 = 0;
|
|
140
|
-
for (const t3 of o2) {
|
|
141
|
-
const o3 = r2 + t3.text.length;
|
|
142
|
-
if (o3 > n2 && r2 < e2) {
|
|
143
|
-
const n3 = t3.marks.find((t4) => "font" === t4.type);
|
|
144
|
-
if (n3) return n3;
|
|
145
|
-
}
|
|
146
|
-
r2 = o3;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
injectFontFaces() {
|
|
150
|
-
const t2 = [];
|
|
151
|
-
for (const n3 of this.config.fonts) if (n3.fontFaces?.length) for (const e2 of n3.fontFaces) {
|
|
152
|
-
const o2 = [`font-family: '${(n3.family.split(",")[0] ?? "").trim().replace(/'/g, "")}'`, `src: ${e2.src}`];
|
|
153
|
-
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 {
|
|
154
|
-
${o2.join(";\n ")};
|
|
155
|
-
}`);
|
|
156
|
-
}
|
|
157
|
-
if (0 === t2.length) return;
|
|
158
|
-
const n2 = document.createElement("style");
|
|
159
|
-
n2.setAttribute("data-notectl-fonts", ""), n2.textContent = t2.join("\n\n"), document.head.appendChild(n2), this.injectedStyleElement = n2;
|
|
160
|
-
}
|
|
161
|
-
dismissPopup() {
|
|
162
|
-
const t2 = this.context?.getService(p);
|
|
163
|
-
t2?.closePopup();
|
|
164
|
-
}
|
|
165
|
-
renderFontPopup(t2, n2) {
|
|
166
|
-
t2.classList.add("notectl-font-picker");
|
|
167
|
-
const e2 = n2.getState(), o2 = this.getActiveFont(e2), r2 = this.defaultFont.family, i2 = document.createElement("div");
|
|
168
|
-
i2.className = "notectl-font-picker__list";
|
|
169
|
-
for (const t3 of this.config.fonts) {
|
|
170
|
-
const e3 = t3.family === r2, l2 = e3 && !o2 || o2 === t3.family, a2 = this.createFontItem(t3.name, t3.family, l2, (o3) => {
|
|
171
|
-
o3.preventDefault(), o3.stopPropagation(), e3 ? n2.executeCommand("removeFont") : this.applyFont(n2, n2.getState(), t3.family), this.dismissPopup();
|
|
172
|
-
});
|
|
173
|
-
t3.category && a2.setAttribute("data-category", t3.category), i2.appendChild(a2);
|
|
174
|
-
}
|
|
175
|
-
t2.appendChild(i2);
|
|
176
|
-
}
|
|
177
|
-
createFontItem(t2, n2, e2, o2) {
|
|
178
|
-
const r2 = document.createElement("button");
|
|
179
|
-
r2.type = "button", r2.className = "notectl-font-picker__item", e2 && r2.classList.add("notectl-font-picker__item--active");
|
|
180
|
-
const i2 = document.createElement("span");
|
|
181
|
-
i2.className = "notectl-font-picker__check", i2.textContent = e2 ? "✓" : "", r2.appendChild(i2);
|
|
182
|
-
const l2 = document.createElement("span");
|
|
183
|
-
return l2.className = "notectl-font-picker__label", l2.textContent = t2, n2 && (l2.style.fontFamily = n2), r2.appendChild(l2), r2.addEventListener("mousedown", o2), r2;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
export {
|
|
187
|
-
d as F,
|
|
188
|
-
m as a,
|
|
189
|
-
h as b
|
|
190
|
-
};
|
|
191
|
-
//# sourceMappingURL=index-DipAT_Q9.mjs.map
|