@notectl/core 1.0.9 → 1.6.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/dist/chunks/{AttrRegistry-D-przlzb.mjs → AttrRegistry-I-VdmRnN.mjs} +2 -2
- package/dist/chunks/{AttrRegistry-D-przlzb.mjs.map → AttrRegistry-I-VdmRnN.mjs.map} +1 -1
- package/dist/chunks/CaretNavigation-CAJXoaae.mjs +311 -0
- package/dist/chunks/CaretNavigation-CAJXoaae.mjs.map +1 -0
- package/dist/chunks/ColorNames-BdsHwA2f.mjs +59 -0
- package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +1 -0
- package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +125 -0
- package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +1 -0
- package/dist/chunks/Commands-CicwYoTQ.mjs +286 -0
- package/dist/chunks/Commands-CicwYoTQ.mjs.map +1 -0
- package/dist/chunks/{Document-CI3iCwEP.mjs → Document-CuwE73FF.mjs} +35 -22
- package/dist/chunks/{Document-CI3iCwEP.mjs.map → Document-CuwE73FF.mjs.map} +1 -1
- package/dist/chunks/HTMLUtils-DTqQzcKR.mjs +35 -0
- package/dist/chunks/HTMLUtils-DTqQzcKR.mjs.map +1 -0
- package/dist/chunks/MarkCommands-CC37WA7Z.mjs +94 -0
- package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +1 -0
- package/dist/chunks/NavigationUtils-CyW0Vo8A.mjs +47 -0
- package/dist/chunks/NavigationUtils-CyW0Vo8A.mjs.map +1 -0
- package/dist/chunks/{NodeResolver-D68ZLXti.mjs → NodeResolver-B-wzthAQ.mjs} +2 -2
- package/dist/chunks/{NodeResolver-D68ZLXti.mjs.map → NodeResolver-B-wzthAQ.mjs.map} +1 -1
- package/dist/chunks/Platform-S_xqIqcM.mjs +26 -0
- package/dist/chunks/Platform-S_xqIqcM.mjs.map +1 -0
- package/dist/chunks/Selection-DmFDwiPJ.mjs +52 -0
- package/dist/chunks/Selection-DmFDwiPJ.mjs.map +1 -0
- package/dist/chunks/ToolbarItem-BpZggUGo.mjs +8 -0
- package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -0
- package/dist/chunks/{ToolbarPlugin-DFkl1uYO.mjs → ToolbarPlugin-B6JETWaw.mjs} +3 -3
- package/dist/chunks/{ToolbarPlugin-DFkl1uYO.mjs.map → ToolbarPlugin-B6JETWaw.mjs.map} +1 -1
- package/dist/chunks/index--z_Txzej.mjs +467 -0
- package/dist/chunks/index--z_Txzej.mjs.map +1 -0
- package/dist/chunks/{index-o6hDR07y.mjs → index-83QoUENW.mjs} +25 -20
- package/dist/chunks/index-83QoUENW.mjs.map +1 -0
- package/dist/chunks/{index-DfO_fKw6.mjs → index-B0UFAfyb.mjs} +15 -15
- package/dist/chunks/{index-DfO_fKw6.mjs.map → index-B0UFAfyb.mjs.map} +1 -1
- package/dist/chunks/{index-BFsYGsBR.mjs → index-BDMP86F4.mjs} +39 -39
- package/dist/chunks/{index-BFsYGsBR.mjs.map → index-BDMP86F4.mjs.map} +1 -1
- package/dist/chunks/{index-Bsp4LC5t.mjs → index-BWXkaC2Z.mjs} +36 -36
- package/dist/chunks/index-BWXkaC2Z.mjs.map +1 -0
- package/dist/chunks/{index-DAFCISBN.mjs → index-BigJ0z6n.mjs} +3 -3
- package/dist/chunks/{index-DAFCISBN.mjs.map → index-BigJ0z6n.mjs.map} +1 -1
- package/dist/chunks/{index-uTnc9y7M.mjs → index-CPjf45-o.mjs} +28 -28
- package/dist/chunks/index-CPjf45-o.mjs.map +1 -0
- package/dist/chunks/{index-DGrRWMlW.mjs → index-CPyHuEzh.mjs} +105 -105
- package/dist/chunks/index-CPyHuEzh.mjs.map +1 -0
- package/dist/chunks/{index-BL56fbXt.mjs → index-D4GKlc-A.mjs} +89 -87
- package/dist/chunks/index-D4GKlc-A.mjs.map +1 -0
- package/dist/chunks/{index-BRYzYOYC.mjs → index-D67mP19g.mjs} +29 -29
- package/dist/chunks/index-D67mP19g.mjs.map +1 -0
- package/dist/chunks/{index-BIL37LSL.mjs → index-D8tbbW97.mjs} +18 -18
- package/dist/chunks/{index-BIL37LSL.mjs.map → index-D8tbbW97.mjs.map} +1 -1
- package/dist/chunks/{index-DC1EK22F.mjs → index-DIAXWwgJ.mjs} +24 -19
- package/dist/chunks/index-DIAXWwgJ.mjs.map +1 -0
- package/dist/chunks/{index-BSFLNveF.mjs → index-DQryjfJs.mjs} +352 -341
- package/dist/chunks/index-DQryjfJs.mjs.map +1 -0
- package/dist/chunks/{index-BTJfyJlJ.mjs → index-DRZwd-1W.mjs} +104 -104
- package/dist/chunks/index-DRZwd-1W.mjs.map +1 -0
- package/dist/chunks/{index-BQ8iIYLn.mjs → index-DUC1X43Z.mjs} +54 -54
- package/dist/chunks/index-DUC1X43Z.mjs.map +1 -0
- package/dist/chunks/{index-BCvuDpVr.mjs → index-DipAT_Q9.mjs} +31 -31
- package/dist/chunks/index-DipAT_Q9.mjs.map +1 -0
- package/dist/chunks/{index-DA8TG2S8.mjs → index-tBDVaSjG.mjs} +56 -56
- package/dist/chunks/index-tBDVaSjG.mjs.map +1 -0
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -1
- package/dist/commands/Commands.d.ts +13 -45
- package/dist/commands/Commands.d.ts.map +1 -1
- package/dist/commands/DeleteCommands.d.ts +15 -0
- package/dist/commands/DeleteCommands.d.ts.map +1 -0
- package/dist/commands/GapCursorCommands.d.ts +24 -0
- package/dist/commands/GapCursorCommands.d.ts.map +1 -0
- package/dist/commands/MarkCommands.d.ts +19 -0
- package/dist/commands/MarkCommands.d.ts.map +1 -0
- package/dist/commands/MovementCommands.d.ts +27 -0
- package/dist/commands/MovementCommands.d.ts.map +1 -0
- package/dist/commands/NodeSelectionCommands.d.ts +24 -0
- package/dist/commands/NodeSelectionCommands.d.ts.map +1 -0
- package/dist/commands/PasteCommand.d.ts.map +1 -1
- package/dist/commands/WordBoundary.d.ts +12 -0
- package/dist/commands/WordBoundary.d.ts.map +1 -0
- package/dist/editor/DocumentSerializer.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +7 -1
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/index.d.ts +25 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/CompositionTracker.d.ts +14 -0
- package/dist/input/CompositionTracker.d.ts.map +1 -0
- package/dist/input/FileHandlerRegistry.d.ts +16 -0
- package/dist/input/FileHandlerRegistry.d.ts.map +1 -0
- package/dist/input/InputHandler.d.ts +6 -4
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/InputRuleRegistry.d.ts +9 -0
- package/dist/input/InputRuleRegistry.d.ts.map +1 -0
- package/dist/input/KeyboardHandler.d.ts +20 -5
- package/dist/input/KeyboardHandler.d.ts.map +1 -1
- package/dist/input/Keymap.d.ts +11 -0
- package/dist/input/Keymap.d.ts.map +1 -1
- package/dist/input/KeymapRegistry.d.ts +19 -0
- package/dist/input/KeymapRegistry.d.ts.map +1 -0
- package/dist/input/PasteHandler.d.ts +3 -0
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/model/Document.d.ts +8 -0
- package/dist/model/Document.d.ts.map +1 -1
- package/dist/model/GraphemeUtils.d.ts +20 -0
- package/dist/model/GraphemeUtils.d.ts.map +1 -0
- package/dist/model/HTMLUtils.d.ts +6 -1
- package/dist/model/HTMLUtils.d.ts.map +1 -1
- package/dist/model/NavigationUtils.d.ts +16 -0
- package/dist/model/NavigationUtils.d.ts.map +1 -0
- package/dist/model/SchemaRegistry.d.ts +0 -39
- package/dist/model/SchemaRegistry.d.ts.map +1 -1
- package/dist/model/Selection.d.ts +14 -3
- package/dist/model/Selection.d.ts.map +1 -1
- package/dist/notectl-core.mjs +2755 -2496
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +2672 -1680
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/Plugin.d.ts +17 -3
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/PluginManager.d.ts +14 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts +35 -0
- package/dist/plugins/caret-navigation/CaretNavigationPlugin.d.ts.map +1 -0
- package/dist/plugins/caret-navigation/index.d.ts +2 -0
- package/dist/plugins/caret-navigation/index.d.ts.map +1 -0
- package/dist/plugins/caret-navigation.mjs +5 -0
- package/dist/plugins/caret-navigation.mjs.map +1 -0
- package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- 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.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts +15 -0
- package/dist/plugins/gap-cursor/GapCursorPlugin.d.ts.map +1 -0
- package/dist/plugins/gap-cursor/index.d.ts +2 -0
- package/dist/plugins/gap-cursor/index.d.ts.map +1 -0
- package/dist/plugins/gap-cursor.mjs +65 -0
- package/dist/plugins/gap-cursor.mjs.map +1 -0
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/BlockTypePickerRegistry.d.ts +9 -0
- package/dist/plugins/heading/BlockTypePickerRegistry.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts.map +1 -1
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/ImageCommands.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
- package/dist/plugins/print/PrintTypes.d.ts +5 -1
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -1
- package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
- package/dist/plugins/shared/ColorValidation.d.ts +7 -0
- package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/table/TableCommands.d.ts.map +1 -1
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarRegistry.d.ts +12 -0
- package/dist/plugins/toolbar/ToolbarRegistry.d.ts.map +1 -0
- package/dist/plugins/toolbar.mjs +2 -2
- package/dist/state/EditorState.d.ts.map +1 -1
- package/dist/state/History.d.ts.map +1 -1
- package/dist/state/SelectionTransactions.d.ts +10 -0
- package/dist/state/SelectionTransactions.d.ts.map +1 -0
- package/dist/test/TestUtils.d.ts +23 -0
- package/dist/test/TestUtils.d.ts.map +1 -1
- package/dist/view/CaretNavigation.d.ts +48 -0
- package/dist/view/CaretNavigation.d.ts.map +1 -0
- package/dist/view/CursorWrapper.d.ts +19 -0
- package/dist/view/CursorWrapper.d.ts.map +1 -0
- package/dist/view/DomPointUtils.d.ts +20 -0
- package/dist/view/DomPointUtils.d.ts.map +1 -0
- package/dist/view/EditorView.d.ts +43 -0
- package/dist/view/EditorView.d.ts.map +1 -1
- package/dist/view/MarkRendering.d.ts +7 -0
- package/dist/view/MarkRendering.d.ts.map +1 -0
- package/dist/view/NodeViewRegistry.d.ts +9 -0
- package/dist/view/NodeViewRegistry.d.ts.map +1 -0
- package/dist/view/Platform.d.ts +29 -0
- package/dist/view/Platform.d.ts.map +1 -0
- package/dist/view/Reconciler.d.ts +4 -0
- package/dist/view/Reconciler.d.ts.map +1 -1
- package/dist/view/SelectionSync.d.ts +2 -0
- package/dist/view/SelectionSync.d.ts.map +1 -1
- package/dist/view/ViewMovementCommands.d.ts +40 -0
- package/dist/view/ViewMovementCommands.d.ts.map +1 -0
- package/package.json +10 -2
- package/dist/chunks/ColorNames-iaWsSZx1.mjs +0 -35
- package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +0 -1
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +0 -140
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +0 -1
- package/dist/chunks/Commands-CSpSwGXv.mjs +0 -461
- package/dist/chunks/Commands-CSpSwGXv.mjs.map +0 -1
- package/dist/chunks/HTMLUtils-0wvCRvJc.mjs +0 -7
- package/dist/chunks/HTMLUtils-0wvCRvJc.mjs.map +0 -1
- package/dist/chunks/Selection-D5ZjXoB7.mjs +0 -44
- package/dist/chunks/Selection-D5ZjXoB7.mjs.map +0 -1
- package/dist/chunks/ToolbarItem-ugDymuXi.mjs +0 -7
- package/dist/chunks/ToolbarItem-ugDymuXi.mjs.map +0 -1
- package/dist/chunks/index-BCvuDpVr.mjs.map +0 -1
- package/dist/chunks/index-BL56fbXt.mjs.map +0 -1
- package/dist/chunks/index-BQ8iIYLn.mjs.map +0 -1
- package/dist/chunks/index-BRYzYOYC.mjs.map +0 -1
- package/dist/chunks/index-BSFLNveF.mjs.map +0 -1
- package/dist/chunks/index-BTJfyJlJ.mjs.map +0 -1
- package/dist/chunks/index-Bsp4LC5t.mjs.map +0 -1
- package/dist/chunks/index-DA8TG2S8.mjs.map +0 -1
- package/dist/chunks/index-DC1EK22F.mjs.map +0 -1
- package/dist/chunks/index-DGrRWMlW.mjs.map +0 -1
- package/dist/chunks/index-o6hDR07y.mjs.map +0 -1
- package/dist/chunks/index-uTnc9y7M.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarItem-BpZggUGo.mjs","sources":["../../src/plugins/toolbar/ToolbarItem.ts"],"sourcesContent":["/**\n * ToolbarItem: describes a toolbar button registered by a plugin.\n */\n\nimport type { EditorState } from '../../state/EditorState.js';\nimport { isMac } from '../../view/Platform.js';\nimport type { PluginContext } from '../Plugin.js';\n\nexport interface GridPickerConfig {\n\treadonly maxRows: number;\n\treadonly maxCols: number;\n\tonSelect(rows: number, cols: number): void;\n}\n\nexport interface DropdownConfig {\n\treadonly items: readonly { label: string; command: string; icon?: string }[];\n}\n\nexport type ToolbarGroup = 'format' | 'block' | 'insert' | (string & {});\nexport type PopupType = 'gridPicker' | 'dropdown' | 'custom';\n\ninterface ToolbarItemBase {\n\treadonly id: string;\n\t/** Grouping key: 'format' | 'insert' | 'block' or custom. */\n\treadonly group: ToolbarGroup;\n\t/** Icon content: inline SVG markup or plain text. Rendered via innerHTML. */\n\treadonly icon: string;\n\treadonly label: string;\n\t/** Tooltip shown on hover, e.g. \"Bold (Ctrl+B)\". Falls back to label. */\n\treadonly tooltip?: string;\n\t/** Command name to execute on click. */\n\treadonly command: string;\n\t/**\n\t * Lower priority renders further left.\n\t * @deprecated Use the declarative `toolbar` config on `createEditor()` instead.\n\t */\n\treadonly priority?: number;\n\t/**\n\t * When true, a visual separator is rendered after this item.\n\t * @deprecated Use the declarative `toolbar` config on `createEditor()` instead.\n\t */\n\treadonly separatorAfter?: boolean;\n\tisActive?(state: EditorState): boolean;\n\tisEnabled?(state: EditorState): boolean;\n}\n\ninterface ToolbarItemNoPopup extends ToolbarItemBase {\n\treadonly popupType?: undefined;\n}\n\ninterface ToolbarItemGridPicker extends ToolbarItemBase {\n\treadonly popupType: 'gridPicker';\n\treadonly popupConfig: GridPickerConfig;\n}\n\ninterface ToolbarItemDropdown extends ToolbarItemBase {\n\treadonly popupType: 'dropdown';\n\treadonly popupConfig: DropdownConfig;\n}\n\ninterface ToolbarItemCustomPopup extends ToolbarItemBase {\n\treadonly popupType: 'custom';\n\trenderPopup(container: HTMLElement, context: PluginContext, onClose: () => void): void;\n}\n\nexport type ToolbarItem =\n\t| ToolbarItemNoPopup\n\t| ToolbarItemGridPicker\n\t| ToolbarItemDropdown\n\t| ToolbarItemCustomPopup;\n\n/**\n * Formats a keymap binding string into a human-readable shortcut,\n * using platform-appropriate modifier symbols (⌘ on Mac, Ctrl on others).\n *\n * @example formatShortcut('Mod-B') → \"Ctrl+B\" or \"⌘B\"\n * @example formatShortcut('Mod-Shift-X') → \"Ctrl+Shift+X\" or \"⌘⇧X\"\n */\nexport function formatShortcut(binding: string): string {\n\tif (isMac()) {\n\t\treturn binding\n\t\t\t.replace(/Mod/g, '⌘')\n\t\t\t.replace(/Shift/g, '⇧')\n\t\t\t.replace(/Alt/g, '⌥')\n\t\t\t.replace(/-/g, '');\n\t}\n\treturn binding.replace(/Mod/g, 'Ctrl').replace(/-/g, '+');\n}\n"],"names":["formatShortcut","binding","isMac","replace"],"mappings":";AA8EO,SAASA,EAAeC,IAAAA;AAC9B,SAAIC,EAAAA,IACID,GACLE,QAAQ,QAAQ,GAAA,EAChBA,QAAQ,UAAU,GAAA,EAClBA,QAAQ,QAAQ,GAAA,EAChBA,QAAQ,MAAM,EAAA,IAEVF,GAAQE,QAAQ,QAAQ,MAAA,EAAQA,QAAQ,MAAM,GAAA;AACtD;"}
|
|
@@ -747,7 +747,7 @@ class g {
|
|
|
747
747
|
}
|
|
748
748
|
renderItemsByLayout() {
|
|
749
749
|
if (!this.context || !this.toolbarElement || !this.layoutConfig) return;
|
|
750
|
-
const t2 = this.context.
|
|
750
|
+
const t2 = this.context.getToolbarRegistry();
|
|
751
751
|
let e2 = true;
|
|
752
752
|
for (const o2 of this.layoutConfig.groups) {
|
|
753
753
|
const n2 = [];
|
|
@@ -767,7 +767,7 @@ class g {
|
|
|
767
767
|
}
|
|
768
768
|
renderItemsByPriority() {
|
|
769
769
|
if (!this.context || !this.toolbarElement) return;
|
|
770
|
-
const t2 = this.context.
|
|
770
|
+
const t2 = this.context.getToolbarRegistry().getToolbarItems().filter((t3) => !this.hiddenItems.has(t3.id));
|
|
771
771
|
if (0 === t2.length) return void this.toolbarElement.remove();
|
|
772
772
|
const e2 = [...t2].sort((t3, e3) => (t3.priority ?? 100) - (e3.priority ?? 100));
|
|
773
773
|
if (e2.some((t3) => t3.separatorAfter)) for (let t3 = 0; t3 < e2.length; t3++) {
|
|
@@ -815,4 +815,4 @@ export {
|
|
|
815
815
|
a as c,
|
|
816
816
|
d
|
|
817
817
|
};
|
|
818
|
-
//# sourceMappingURL=ToolbarPlugin-
|
|
818
|
+
//# sourceMappingURL=ToolbarPlugin-B6JETWaw.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarPlugin-DFkl1uYO.mjs","sources":["../../src/editor/styles/toolbar.ts","../../src/plugins/toolbar/ToolbarLocale.ts","../../src/plugins/toolbar/ToolbarOverflowBehavior.ts","../../src/plugins/toolbar/ToolbarOverflowController.ts","../../src/plugins/toolbar/ToolbarRenderers.ts","../../src/plugins/toolbar/ToolbarPopupController.ts","../../src/plugins/toolbar/ToolbarTooltip.ts","../../src/plugins/toolbar/ToolbarPlugin.ts"],"sourcesContent":["/** Toolbar styles — buttons, separators, tooltips, popups, dropdowns. */\nexport const TOOLBAR_CSS = `\n/* Toolbar */\n.notectl-plugin-container--top {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\tborder-bottom: 1px solid var(--notectl-border);\n\tbackground: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n\tmin-height: 40px;\n}\n\n.notectl-toolbar {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n\tflex: 1;\n\tmin-width: 0;\n\tgap: 2px;\n\tpadding: 4px 8px;\n}\n\n.notectl-toolbar[hidden] {\n\tdisplay: none;\n}\n\n.notectl-toolbar-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n\tfont-size: 14px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n.notectl-toolbar-btn:hover {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-border);\n}\n\n.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-active-bg);\n\tborder-color: var(--notectl-primary-muted);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-toolbar-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n.notectl-toolbar-btn:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n.notectl-toolbar-btn:disabled:hover {\n\tbackground: transparent;\n\tborder-color: transparent;\n}\n\n.notectl-toolbar-btn__icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpointer-events: none;\n}\n\n.notectl-toolbar-btn__icon svg {\n\tdisplay: block;\n\twidth: 18px;\n\theight: 18px;\n\tfill: currentColor;\n}\n\n/* Tooltip (rendered as fixed-position element in shadow root) */\n.notectl-toolbar-tooltip {\n\tposition: fixed;\n\tpadding: 4px 8px;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-tooltip-bg);\n\tcolor: var(--notectl-tooltip-fg);\n\tfont-size: 11px;\n\tfont-weight: 500;\n\twhite-space: nowrap;\n\tpointer-events: none;\n\tz-index: 10001;\n\tline-height: 1.4;\n\tletter-spacing: 0.01em;\n\tfont-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.notectl-toolbar-separator {\n\tdisplay: inline-block;\n\twidth: 1px;\n\theight: 20px;\n\tbackground: var(--notectl-border);\n\tmargin: 0 4px;\n\tvertical-align: middle;\n}\n\n/* Toolbar Popups */\n.notectl-toolbar-popup {\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px var(--notectl-shadow);\n\toverflow: hidden;\n}\n\n/* Grid Picker */\n.notectl-grid-picker__cell:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n\n.notectl-grid-picker__cell--highlighted {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n}\n\n/* Dropdown */\n.notectl-dropdown {\n\tmin-width: 160px;\n\tpadding: 4px 0;\n}\n\n.notectl-dropdown__item {\n\tdisplay: flex;\n\talign-items: center;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\ttext-align: left;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\tfont-family: inherit;\n\twhite-space: nowrap;\n}\n\n.notectl-dropdown__item:hover,\n.notectl-dropdown__item:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-dropdown__item:focus-visible {\n\toutline: none;\n}\n\n.notectl-dropdown__item-icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 28px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-fg-muted);\n\tflex-shrink: 0;\n}\n\n.notectl-dropdown__item-label {\n\tflex: 1;\n}\n\n/* Overflow behavior: flow mode — toolbar wraps to additional rows */\n.notectl-toolbar[data-overflow=\"flow\"] {\n\tflex-wrap: wrap;\n\toverflow: visible;\n}\n\n/* Overflow behavior: none — toolbar clips without any responsive behavior */\n.notectl-toolbar[data-overflow=\"none\"] {\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n}\n\n/* Overflow: hidden items (burger-menu mode) */\n.notectl-toolbar-btn--overflow-hidden,\n.notectl-toolbar-separator--overflow-hidden {\n\tdisplay: none;\n}\n\n/* Overflow \"more\" button */\n.notectl-toolbar-overflow-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n\tfont-size: 16px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\tmargin-left: auto;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n.notectl-toolbar-overflow-btn:hover {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-border);\n}\n\n.notectl-toolbar-overflow-btn--hidden {\n\tdisplay: none;\n}\n\n.notectl-toolbar-overflow-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n/* Dropdown item states shared by all dropdown menus (including overflow) */\n.notectl-dropdown__item:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n.notectl-dropdown__item:disabled:hover {\n\tbackground: none;\n}\n\n.notectl-dropdown__item--active {\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-dropdown__item-icon svg {\n\tdisplay: block;\n\twidth: 16px;\n\theight: 16px;\n\tfill: currentColor;\n}\n\n.notectl-dropdown__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 0;\n}\n`;\n","/** Locale interface and default English locale for the ToolbarPlugin. */\n\n// --- Locale Interface ---\n\nexport interface ToolbarLocale {\n\treadonly formattingOptionsAria: string;\n\treadonly moreToolsAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const TOOLBAR_LOCALE_EN: ToolbarLocale = {\n\tformattingOptionsAria: 'Formatting options',\n\tmoreToolsAria: 'More tools',\n};\n\n// --- German Locale ---\n\nexport const TOOLBAR_LOCALE_DE: ToolbarLocale = {\n\tformattingOptionsAria: 'Formatierungsoptionen',\n\tmoreToolsAria: 'Weitere Werkzeuge',\n};\n\n// --- Spanish Locale ---\n\nexport const TOOLBAR_LOCALE_ES: ToolbarLocale = {\n\tformattingOptionsAria: 'Opciones de formato',\n\tmoreToolsAria: 'Más herramientas',\n};\n\n// --- French Locale ---\n\nexport const TOOLBAR_LOCALE_FR: ToolbarLocale = {\n\tformattingOptionsAria: 'Options de mise en forme',\n\tmoreToolsAria: \"Plus d'outils\",\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const TOOLBAR_LOCALE_ZH: ToolbarLocale = {\n\tformattingOptionsAria: '格式选项',\n\tmoreToolsAria: '更多工具',\n};\n\n// --- Russian Locale ---\n\nexport const TOOLBAR_LOCALE_RU: ToolbarLocale = {\n\tformattingOptionsAria: 'Параметры форматирования',\n\tmoreToolsAria: 'Другие инструменты',\n};\n\n// --- Arabic Locale ---\n\nexport const TOOLBAR_LOCALE_AR: ToolbarLocale = {\n\tformattingOptionsAria: 'خيارات التنسيق',\n\tmoreToolsAria: 'أدوات إضافية',\n};\n\n// --- Hindi Locale ---\n\nexport const TOOLBAR_LOCALE_HI: ToolbarLocale = {\n\tformattingOptionsAria: 'फ़ॉर्मेटिंग विकल्प',\n\tmoreToolsAria: 'और उपकरण',\n};\n\n// --- Locale Map ---\n\nexport const TOOLBAR_LOCALES: Record<string, ToolbarLocale> = {\n\ten: TOOLBAR_LOCALE_EN,\n\tde: TOOLBAR_LOCALE_DE,\n\tes: TOOLBAR_LOCALE_ES,\n\tfr: TOOLBAR_LOCALE_FR,\n\tzh: TOOLBAR_LOCALE_ZH,\n\tru: TOOLBAR_LOCALE_RU,\n\tar: TOOLBAR_LOCALE_AR,\n\thi: TOOLBAR_LOCALE_HI,\n};\n","/**\n * Controls how the toolbar responds when items exceed the available width.\n *\n * @example\n * ```typescript\n * const editor = await createEditor({\n * toolbar: {\n * groups: [[BoldPlugin, ItalicPlugin], [HeadingPlugin]],\n * overflow: ToolbarOverflowBehavior.Flow,\n * },\n * });\n * ```\n */\nexport const ToolbarOverflowBehavior = {\n\t/** Items that don't fit are hidden behind a \"...\" dropdown button. Default. */\n\tBurgerMenu: 'burger-menu',\n\t/** Toolbar wraps to additional rows when items overflow. Pure CSS, no JS measurement. */\n\tFlow: 'flow',\n\t/** No responsive behavior; the toolbar clips at the container boundary. */\n\tNone: 'none',\n} as const;\n\nexport type ToolbarOverflowBehavior =\n\t(typeof ToolbarOverflowBehavior)[keyof typeof ToolbarOverflowBehavior];\n","/**\n * ToolbarOverflowController: manages responsive toolbar overflow.\n * Uses ResizeObserver to detect when items exceed available width,\n * hides overflow items, and shows a \"more\" dropdown button.\n */\n\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { ToolbarItem } from './ToolbarItem.js';\nimport { findNextDropdownItem } from './ToolbarKeyboardNav.js';\n\n// --- Types ---\n\ninterface OverflowEntry {\n\treadonly element: HTMLButtonElement;\n\treadonly item: ToolbarItem;\n}\n\ntype OnOverflowChange = (\n\tvisibleButtons: readonly HTMLButtonElement[],\n\toverflowButton: HTMLButtonElement | null,\n) => void;\n\ntype OnItemActivated = (overflowButton: HTMLButtonElement, item: ToolbarItem) => void;\n\nexport interface OverflowControllerConfig {\n\treadonly toolbar: HTMLElement;\n\treadonly ariaLabel: string;\n\treadonly context: PluginContext;\n\treadonly onOverflowChange: OnOverflowChange;\n\treadonly onItemActivated: OnItemActivated;\n\treadonly getActiveElement: () => Element | null;\n}\n\n// --- Constants ---\n\nconst OVERFLOW_BTN_WIDTH = 34;\nconst GAP = 2;\nconst HIDDEN_BTN_CLASS = 'notectl-toolbar-btn--overflow-hidden';\nconst HIDDEN_SEP_CLASS = 'notectl-toolbar-separator--overflow-hidden';\nconst HIDDEN_OVERFLOW_CLASS = 'notectl-toolbar-overflow-btn--hidden';\nconst ELLIPSIS_SVG =\n\t'<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\"><circle cx=\"3\" cy=\"8\" r=\"1.5\" fill=\"currentColor\"/><circle cx=\"8\" cy=\"8\" r=\"1.5\" fill=\"currentColor\"/><circle cx=\"13\" cy=\"8\" r=\"1.5\" fill=\"currentColor\"/></svg>';\n\n// --- Controller ---\n\nexport class ToolbarOverflowController {\n\tprivate readonly toolbar: HTMLElement;\n\tprivate readonly context: PluginContext;\n\tprivate readonly onOverflowChange: OnOverflowChange;\n\tprivate readonly onItemActivated: OnItemActivated;\n\tprivate readonly getActiveElement: () => Element | null;\n\tprivate readonly ariaLabel: string;\n\n\tprivate entries: OverflowEntry[] = [];\n\tprivate overflowButton: HTMLButtonElement | null = null;\n\tprivate overflowDropdown: HTMLElement | null = null;\n\tprivate overflowEntries: OverflowEntry[] = [];\n\tprivate resizeObserver: ResizeObserver | null = null;\n\tprivate closeHandler: ((e: MouseEvent) => void) | null = null;\n\n\tconstructor(config: OverflowControllerConfig) {\n\t\tthis.toolbar = config.toolbar;\n\t\tthis.ariaLabel = config.ariaLabel;\n\t\tthis.context = config.context;\n\t\tthis.onOverflowChange = config.onOverflowChange;\n\t\tthis.onItemActivated = config.onItemActivated;\n\t\tthis.getActiveElement = config.getActiveElement;\n\n\t\tthis.resizeObserver = new ResizeObserver(() => this.recalculate());\n\t\tthis.resizeObserver.observe(this.toolbar);\n\t}\n\n\t/** Called after renderItems() — stores button references and recalculates. */\n\tupdate(buttons: readonly { element: HTMLButtonElement; item: ToolbarItem }[]): void {\n\t\tthis.entries = buttons.map((b) => ({ element: b.element, item: b.item }));\n\t\tthis.recalculate();\n\t}\n\n\t/** Measures toolbar and redistributes items between visible and overflow. */\n\trecalculate(): void {\n\t\tif (this.entries.length === 0) return;\n\n\t\tthis.closeDropdown();\n\t\tthis.resetVisibility();\n\t\tthis.ensureOverflowButton();\n\t\tthis.setOverflowButtonVisible(false);\n\n\t\tconst availableWidth: number = this.measureAvailableWidth();\n\t\tconst maxWidth: number = availableWidth - OVERFLOW_BTN_WIDTH - GAP;\n\t\tlet usedWidth = 0;\n\t\tlet overflowing = false;\n\t\tconst overflowList: OverflowEntry[] = [];\n\n\t\tconst children: HTMLElement[] = Array.from(this.toolbar.children) as HTMLElement[];\n\t\tfor (const child of children) {\n\t\t\tif (child === this.overflowButton) continue;\n\n\t\t\tif (child.classList.contains('notectl-toolbar-separator')) {\n\t\t\t\tif (overflowing) {\n\t\t\t\t\tchild.classList.add(HIDDEN_SEP_CLASS);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst sepWidth: number = child.offsetWidth + GAP;\n\t\t\t\tif (usedWidth + sepWidth > maxWidth) {\n\t\t\t\t\toverflowing = true;\n\t\t\t\t\tchild.classList.add(HIDDEN_SEP_CLASS);\n\t\t\t\t} else {\n\t\t\t\t\tusedWidth += sepWidth;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst entry: OverflowEntry | undefined = this.entries.find((oe) => oe.element === child);\n\t\t\tif (!entry) continue;\n\n\t\t\tif (overflowing) {\n\t\t\t\tentry.element.classList.add(HIDDEN_BTN_CLASS);\n\t\t\t\toverflowList.push(entry);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst btnWidth: number = entry.element.offsetWidth + GAP;\n\t\t\tif (usedWidth + btnWidth > maxWidth) {\n\t\t\t\toverflowing = true;\n\t\t\t\tentry.element.classList.add(HIDDEN_BTN_CLASS);\n\t\t\t\toverflowList.push(entry);\n\t\t\t} else {\n\t\t\t\tusedWidth += btnWidth;\n\t\t\t}\n\t\t}\n\n\t\tthis.overflowEntries = overflowList;\n\t\tthis.hideTrailingSeparators();\n\t\tthis.setOverflowButtonVisible(overflowList.length > 0);\n\t\tthis.notifyChange();\n\t}\n\n\t/** Updates active/disabled states for items in the open overflow dropdown. */\n\tupdateItemStates(state: EditorState): void {\n\t\tif (!this.overflowDropdown) return;\n\n\t\tconst menuItems: HTMLButtonElement[] = Array.from(\n\t\t\tthis.overflowDropdown.querySelectorAll('.notectl-dropdown__item'),\n\t\t) as HTMLButtonElement[];\n\n\t\tfor (const menuItem of menuItems) {\n\t\t\tconst itemId: string | null = menuItem.getAttribute('data-toolbar-item');\n\t\t\tconst entry: OverflowEntry | undefined = this.overflowEntries.find(\n\t\t\t\t(oe) => oe.item.id === itemId,\n\t\t\t);\n\t\t\tif (!entry) continue;\n\n\t\t\tconst active: boolean = entry.item.isActive?.(state) ?? false;\n\t\t\tconst enabled: boolean = entry.item.isEnabled?.(state) ?? true;\n\t\t\tmenuItem.classList.toggle('notectl-dropdown__item--active', active);\n\t\t\tmenuItem.disabled = !enabled;\n\t\t}\n\t}\n\n\t/** Cleans up ResizeObserver, DOM elements, and event listeners. */\n\tdestroy(): void {\n\t\tthis.resizeObserver?.disconnect();\n\t\tthis.resizeObserver = null;\n\t\tthis.closeDropdown();\n\t\tthis.overflowButton?.remove();\n\t\tthis.overflowButton = null;\n\t\tthis.entries = [];\n\t\tthis.overflowEntries = [];\n\t}\n\n\t// --- Measurement ---\n\n\tprivate measureAvailableWidth(): number {\n\t\tconst toolbarStyle: CSSStyleDeclaration = getComputedStyle(this.toolbar);\n\t\tconst paddingLeft: number = Number.parseFloat(toolbarStyle.paddingLeft) || 0;\n\t\tconst paddingRight: number = Number.parseFloat(toolbarStyle.paddingRight) || 0;\n\t\treturn this.toolbar.clientWidth - paddingLeft - paddingRight;\n\t}\n\n\tprivate resetVisibility(): void {\n\t\tfor (const entry of this.entries) {\n\t\t\tentry.element.classList.remove(HIDDEN_BTN_CLASS);\n\t\t}\n\t\tconst separators: HTMLElement[] = Array.from(\n\t\t\tthis.toolbar.querySelectorAll('.notectl-toolbar-separator'),\n\t\t) as HTMLElement[];\n\t\tfor (const sep of separators) {\n\t\t\tsep.classList.remove(HIDDEN_SEP_CLASS);\n\t\t}\n\t}\n\n\t// --- Overflow Button ---\n\n\tprivate setOverflowButtonVisible(visible: boolean): void {\n\t\tif (!this.overflowButton) return;\n\t\tthis.overflowButton.classList.toggle(HIDDEN_OVERFLOW_CLASS, !visible);\n\t\tif (!visible) {\n\t\t\tthis.overflowButton.removeAttribute('tabindex');\n\t\t}\n\t}\n\n\tprivate ensureOverflowButton(): void {\n\t\tif (this.overflowButton) return;\n\n\t\tconst btn: HTMLButtonElement = document.createElement('button');\n\t\tbtn.type = 'button';\n\t\tbtn.className = 'notectl-toolbar-overflow-btn';\n\t\tbtn.setAttribute('aria-label', this.ariaLabel);\n\t\tbtn.setAttribute('aria-haspopup', 'true');\n\t\tbtn.setAttribute('aria-expanded', 'false');\n\t\tbtn.innerHTML = ELLIPSIS_SVG;\n\n\t\tbtn.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\tthis.toggleDropdown();\n\t\t});\n\n\t\tthis.toolbar.appendChild(btn);\n\t\tthis.overflowButton = btn;\n\t}\n\n\t// --- Dropdown ---\n\n\tprivate toggleDropdown(): void {\n\t\tif (this.overflowDropdown) {\n\t\t\tthis.closeDropdown();\n\t\t} else {\n\t\t\tthis.openDropdown();\n\t\t}\n\t}\n\n\tprivate openDropdown(): void {\n\t\tif (!this.overflowButton || this.overflowEntries.length === 0) return;\n\n\t\tconst dropdown: HTMLDivElement = document.createElement('div');\n\t\tdropdown.className = 'notectl-toolbar-popup notectl-dropdown';\n\t\tdropdown.setAttribute('role', 'menu');\n\n\t\tthis.renderDropdownItems(dropdown);\n\t\tthis.positionDropdown(dropdown);\n\t\tthis.appendToRoot(dropdown);\n\n\t\tthis.overflowDropdown = dropdown;\n\t\tthis.overflowButton.setAttribute('aria-expanded', 'true');\n\n\t\trequestAnimationFrame(() => {\n\t\t\tconst first: HTMLElement | null = dropdown.querySelector('[role=\"menuitem\"]');\n\t\t\tfirst?.focus();\n\t\t});\n\n\t\tdropdown.addEventListener('keydown', (e: KeyboardEvent) => this.handleDropdownKeydown(e));\n\t\tthis.registerCloseHandler();\n\t}\n\n\tprivate renderDropdownItems(dropdown: HTMLElement): void {\n\t\tlet lastGroup: string | null = null;\n\n\t\tfor (const entry of this.overflowEntries) {\n\t\t\tif (lastGroup !== null && entry.item.group !== lastGroup) {\n\t\t\t\tconst sep: HTMLDivElement = document.createElement('div');\n\t\t\t\tsep.className = 'notectl-dropdown__separator';\n\t\t\t\tsep.setAttribute('role', 'separator');\n\t\t\t\tdropdown.appendChild(sep);\n\t\t\t}\n\t\t\tlastGroup = entry.item.group;\n\n\t\t\tconst menuBtn: HTMLButtonElement = document.createElement('button');\n\t\t\tmenuBtn.type = 'button';\n\t\t\tmenuBtn.className = 'notectl-dropdown__item';\n\t\t\tmenuBtn.setAttribute('role', 'menuitem');\n\t\t\tmenuBtn.setAttribute('tabindex', '-1');\n\t\t\tmenuBtn.setAttribute('data-toolbar-item', entry.item.id);\n\n\t\t\tconst iconSpan: HTMLSpanElement = document.createElement('span');\n\t\t\ticonSpan.className = 'notectl-dropdown__item-icon';\n\t\t\ticonSpan.innerHTML = entry.item.icon;\n\t\t\tmenuBtn.appendChild(iconSpan);\n\n\t\t\tconst labelSpan: HTMLSpanElement = document.createElement('span');\n\t\t\tlabelSpan.className = 'notectl-dropdown__item-label';\n\t\t\tlabelSpan.textContent = entry.item.tooltip ?? entry.item.label;\n\t\t\tmenuBtn.appendChild(labelSpan);\n\n\t\t\tmenuBtn.addEventListener('mousedown', (ev: MouseEvent) => {\n\t\t\t\tev.preventDefault();\n\t\t\t\tev.stopPropagation();\n\t\t\t\tthis.activateOverflowItem(entry);\n\t\t\t});\n\n\t\t\tdropdown.appendChild(menuBtn);\n\t\t}\n\t}\n\n\tprivate positionDropdown(dropdown: HTMLElement): void {\n\t\tif (!this.overflowButton) return;\n\n\t\tconst rect: DOMRect = this.overflowButton.getBoundingClientRect();\n\t\tconst rightEdge: number = window.innerWidth - rect.right;\n\n\t\tdropdown.style.position = 'fixed';\n\t\tdropdown.style.top = `${rect.bottom + 2}px`;\n\t\tdropdown.style.right = `${rightEdge}px`;\n\t\tdropdown.style.left = 'auto';\n\t\tdropdown.style.zIndex = '10000';\n\t}\n\n\tprivate appendToRoot(element: HTMLElement): void {\n\t\tif (!this.overflowButton) return;\n\n\t\tconst root: Node = this.overflowButton.getRootNode();\n\t\tif (root instanceof ShadowRoot) {\n\t\t\troot.appendChild(element);\n\t\t} else {\n\t\t\tdocument.body.appendChild(element);\n\t\t}\n\t}\n\n\tprivate registerCloseHandler(): void {\n\t\tthis.closeHandler = (ev: MouseEvent) => {\n\t\t\tconst path: EventTarget[] = ev.composedPath();\n\t\t\tif (\n\t\t\t\tthis.overflowDropdown &&\n\t\t\t\t!path.includes(this.overflowDropdown) &&\n\t\t\t\tthis.overflowButton &&\n\t\t\t\t!path.includes(this.overflowButton)\n\t\t\t) {\n\t\t\t\tthis.closeDropdown();\n\t\t\t}\n\t\t};\n\t\tsetTimeout(() => {\n\t\t\tif (this.closeHandler) {\n\t\t\t\tdocument.addEventListener('mousedown', this.closeHandler);\n\t\t\t}\n\t\t}, 0);\n\t}\n\n\tprivate closeDropdown(): void {\n\t\tif (this.overflowDropdown) {\n\t\t\tthis.overflowDropdown.remove();\n\t\t\tthis.overflowDropdown = null;\n\t\t}\n\t\tif (this.overflowButton) {\n\t\t\tthis.overflowButton.setAttribute('aria-expanded', 'false');\n\t\t}\n\t\tif (this.closeHandler) {\n\t\t\tdocument.removeEventListener('mousedown', this.closeHandler);\n\t\t\tthis.closeHandler = null;\n\t\t}\n\t}\n\n\tprivate activateOverflowItem(entry: OverflowEntry): void {\n\t\tthis.closeDropdown();\n\t\tif (entry.item.popupType && this.overflowButton) {\n\t\t\tthis.onItemActivated(this.overflowButton, entry.item);\n\t\t} else {\n\t\t\tthis.context.executeCommand(entry.item.command);\n\t\t}\n\t}\n\n\t// --- Keyboard Navigation ---\n\n\tprivate handleDropdownKeydown(e: KeyboardEvent): void {\n\t\tif (!this.overflowDropdown) return;\n\n\t\tif (e.key === 'Escape' || e.key === 'Tab') {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tthis.closeDropdown();\n\t\t\tthis.overflowButton?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\tconst items: HTMLElement[] = Array.from(\n\t\t\tthis.overflowDropdown.querySelectorAll('[role=\"menuitem\"]'),\n\t\t) as HTMLElement[];\n\t\tconst current: number = items.indexOf(this.getActiveElement() as HTMLElement);\n\n\t\tswitch (e.key) {\n\t\t\tcase 'ArrowDown': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst next: number = findNextDropdownItem(items, current, 1);\n\t\t\t\titems[next]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowUp': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst prev: number = findNextDropdownItem(items, current, -1);\n\t\t\t\titems[prev]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'Enter':\n\t\t\tcase ' ': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst focusedItem: HTMLElement | undefined = items[current];\n\t\t\t\tif (!focusedItem) break;\n\t\t\t\tconst itemId: string | null = focusedItem.getAttribute('data-toolbar-item');\n\t\t\t\tconst entry: OverflowEntry | undefined = this.overflowEntries.find(\n\t\t\t\t\t(oe) => oe.item.id === itemId,\n\t\t\t\t);\n\t\t\t\tif (entry) this.activateOverflowItem(entry);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Helpers ---\n\n\tprivate hideTrailingSeparators(): void {\n\t\tconst children: HTMLElement[] = Array.from(this.toolbar.children) as HTMLElement[];\n\t\tfor (let i = children.length - 1; i >= 0; i--) {\n\t\t\tconst child: HTMLElement | undefined = children[i];\n\t\t\tif (!child || child === this.overflowButton) continue;\n\t\t\tif (child.classList.contains('notectl-toolbar-separator')) {\n\t\t\t\tif (!child.classList.contains(HIDDEN_SEP_CLASS)) {\n\t\t\t\t\tchild.classList.add(HIDDEN_SEP_CLASS);\n\t\t\t\t}\n\t\t\t} else if (!child.classList.contains(HIDDEN_BTN_CLASS)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate notifyChange(): void {\n\t\tconst visible: HTMLButtonElement[] = this.entries\n\t\t\t.filter((oe) => !oe.element.classList.contains(HIDDEN_BTN_CLASS))\n\t\t\t.map((oe) => oe.element);\n\t\tthis.onOverflowChange(visible, this.overflowEntries.length > 0 ? this.overflowButton : null);\n\t}\n}\n","/**\n * ToolbarRenderers: pure rendering functions for toolbar popup content.\n * Grid pickers, dropdown menus, and separator elements.\n */\n\nimport type { DropdownConfig, GridPickerConfig } from './ToolbarItem.js';\n\nconst HIGHLIGHTED_CLASS = 'notectl-grid-picker__cell--highlighted';\n\n/**\n * Renders a grid picker into the given container.\n * Calls `onClose` after a cell is selected so the popup can be dismissed.\n */\nexport function renderGridPicker(\n\tcontainer: HTMLElement,\n\tconfig: GridPickerConfig,\n\tonClose: () => void,\n): void {\n\tcontainer.className += ' notectl-grid-picker';\n\n\tconst grid: HTMLDivElement = document.createElement('div');\n\tgrid.className = 'notectl-grid-picker__grid';\n\tgrid.setAttribute('role', 'grid');\n\tgrid.style.display = 'grid';\n\tgrid.style.gridTemplateColumns = `repeat(${config.maxCols}, 1fr)`;\n\tgrid.style.gap = '2px';\n\tgrid.style.padding = '8px';\n\n\tconst label: HTMLDivElement = document.createElement('div');\n\tlabel.className = 'notectl-grid-picker__label';\n\tlabel.textContent = '1 x 1';\n\tlabel.style.textAlign = 'center';\n\tlabel.style.padding = '4px';\n\tlabel.style.fontSize = '12px';\n\tlabel.setAttribute('aria-live', 'polite');\n\n\tfor (let r = 1; r <= config.maxRows; r++) {\n\t\tfor (let c = 1; c <= config.maxCols; c++) {\n\t\t\tconst cell: HTMLDivElement = document.createElement('div');\n\t\t\tcell.className = 'notectl-grid-picker__cell';\n\t\t\tcell.setAttribute('role', 'gridcell');\n\t\t\tcell.setAttribute('tabindex', '-1');\n\t\t\tcell.setAttribute('aria-label', `${r} x ${c}`);\n\t\t\tcell.style.width = '20px';\n\t\t\tcell.style.height = '20px';\n\t\t\tcell.style.border = '1px solid #ccc';\n\t\t\tcell.style.cursor = 'pointer';\n\t\t\tcell.setAttribute('data-row', String(r));\n\t\t\tcell.setAttribute('data-col', String(c));\n\n\t\t\tcell.addEventListener('mouseenter', () => {\n\t\t\t\thighlightCells(grid, r, c);\n\t\t\t\tlabel.textContent = `${r} x ${c}`;\n\t\t\t});\n\n\t\t\tcell.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\tconfig.onSelect(r, c);\n\t\t\t\tonClose();\n\t\t\t});\n\n\t\t\tcell.addEventListener('click', () => {\n\t\t\t\tconfig.onSelect(r, c);\n\t\t\t\tonClose();\n\t\t\t});\n\n\t\t\tgrid.appendChild(cell);\n\t\t}\n\t}\n\n\tcontainer.appendChild(grid);\n\tcontainer.appendChild(label);\n}\n\n/**\n * Highlights grid cells up to the given row/col and updates the label.\n * Used by both mouse hover and keyboard navigation.\n */\nexport function highlightCells(grid: HTMLElement, targetRow: number, targetCol: number): void {\n\tconst cells: NodeListOf<Element> = grid.querySelectorAll('.notectl-grid-picker__cell');\n\tfor (const cell of cells) {\n\t\tconst r: number = Number(cell.getAttribute('data-row'));\n\t\tconst c: number = Number(cell.getAttribute('data-col'));\n\t\tcell.classList.toggle(HIGHLIGHTED_CLASS, r <= targetRow && c <= targetCol);\n\t}\n}\n\n/**\n * Renders a dropdown menu into the given container.\n * Calls `onClose` after an item is activated so the popup can be dismissed.\n */\nexport function renderDropdown(\n\tcontainer: HTMLElement,\n\tconfig: DropdownConfig,\n\texecuteCommand: (command: string) => void,\n\tonClose: () => void,\n): void {\n\tcontainer.classList.add('notectl-dropdown');\n\tcontainer.setAttribute('role', 'menu');\n\n\tfor (const item of config.items) {\n\t\tconst btn: HTMLButtonElement = document.createElement('button');\n\t\tbtn.type = 'button';\n\t\tbtn.className = 'notectl-dropdown__item';\n\t\tbtn.setAttribute('role', 'menuitem');\n\t\tbtn.setAttribute('tabindex', '-1');\n\n\t\tif (item.icon) {\n\t\t\tconst iconSpan: HTMLSpanElement = document.createElement('span');\n\t\t\ticonSpan.className = 'notectl-dropdown__item-icon';\n\t\t\ticonSpan.innerHTML = item.icon;\n\t\t\tbtn.appendChild(iconSpan);\n\t\t}\n\n\t\tconst labelSpan: HTMLSpanElement = document.createElement('span');\n\t\tlabelSpan.className = 'notectl-dropdown__item-label';\n\t\tlabelSpan.textContent = item.label;\n\t\tbtn.appendChild(labelSpan);\n\n\t\tbtn.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\texecuteCommand(item.command);\n\t\t\tonClose();\n\t\t});\n\n\t\tbtn.addEventListener('click', () => {\n\t\t\texecuteCommand(item.command);\n\t\t\tonClose();\n\t\t});\n\n\t\tcontainer.appendChild(btn);\n\t}\n}\n\n/** Creates a toolbar group separator element. */\nexport function createSeparator(): HTMLSpanElement {\n\tconst sep: HTMLSpanElement = document.createElement('span');\n\tsep.className = 'notectl-toolbar-separator';\n\tsep.setAttribute('role', 'separator');\n\treturn sep;\n}\n","/**\n * ToolbarPopupController: manages popup lifecycle, positioning, keyboard\n * navigation, and auto-close for toolbar popups (grid pickers, dropdowns,\n * and custom popups).\n */\n\nimport type { PluginContext } from '../Plugin.js';\nimport type { ToolbarItem } from './ToolbarItem.js';\nimport { findNextDropdownItem, navigateGrid } from './ToolbarKeyboardNav.js';\nimport { highlightCells, renderDropdown, renderGridPicker } from './ToolbarRenderers.js';\n\nexport class ToolbarPopupController {\n\tprivate activePopup: HTMLElement | null = null;\n\tprivate activePopupButton: HTMLButtonElement | null = null;\n\tprivate closePopupHandler: ((e: MouseEvent) => void) | null = null;\n\tprivate readonly getActiveElement: () => Element | null;\n\n\tconstructor(getActiveElement: () => Element | null) {\n\t\tthis.getActiveElement = getActiveElement;\n\t}\n\n\t/** Whether a popup is currently open. */\n\tisOpen(): boolean {\n\t\treturn this.activePopup !== null;\n\t}\n\n\t/** Toggles a popup for the given toolbar button. */\n\ttoggle(button: HTMLButtonElement, item: ToolbarItem, context: PluginContext): void {\n\t\tif (this.activePopup) {\n\t\t\tthis.close();\n\t\t\treturn;\n\t\t}\n\n\t\tconst popup: HTMLDivElement = document.createElement('div');\n\t\tpopup.className = 'notectl-toolbar-popup';\n\n\t\tswitch (item.popupType) {\n\t\t\tcase 'gridPicker':\n\t\t\t\trenderGridPicker(popup, item.popupConfig, () => this.close());\n\t\t\t\tbreak;\n\t\t\tcase 'dropdown':\n\t\t\t\trenderDropdown(\n\t\t\t\t\tpopup,\n\t\t\t\t\titem.popupConfig,\n\t\t\t\t\t(cmd: string) => context.executeCommand(cmd),\n\t\t\t\t\t() => this.close(),\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase 'custom':\n\t\t\t\titem.renderPopup(popup, context, () => this.close());\n\t\t\t\tbreak;\n\t\t}\n\n\t\tthis.positionAndAppend(popup, button);\n\n\t\tthis.activePopup = popup;\n\t\tthis.activePopupButton = button;\n\t\tbutton.classList.add('notectl-toolbar-btn--popup-open');\n\t\tbutton.setAttribute('aria-expanded', 'true');\n\n\t\tthis.focusFirstItem(popup);\n\n\t\tpopup.addEventListener('keydown', (e: KeyboardEvent) => this.handlePopupKeydown(e));\n\n\t\tthis.closePopupHandler = (e: MouseEvent) => {\n\t\t\tconst path: EventTarget[] = e.composedPath();\n\t\t\tif (!path.includes(popup) && !path.includes(button)) {\n\t\t\t\tthis.close();\n\t\t\t}\n\t\t};\n\t\tsetTimeout(() => {\n\t\t\tif (this.closePopupHandler) {\n\t\t\t\tdocument.addEventListener('mousedown', this.closePopupHandler);\n\t\t\t}\n\t\t}, 0);\n\t}\n\n\t/** Closes the active popup and cleans up event listeners. */\n\tclose(): void {\n\t\tif (this.activePopupButton) {\n\t\t\tthis.activePopupButton.classList.remove('notectl-toolbar-btn--popup-open');\n\t\t\tthis.activePopupButton.setAttribute('aria-expanded', 'false');\n\t\t\tthis.activePopupButton = null;\n\t\t}\n\t\tif (this.activePopup) {\n\t\t\tthis.activePopup.remove();\n\t\t\tthis.activePopup = null;\n\t\t}\n\t\tif (this.closePopupHandler) {\n\t\t\tdocument.removeEventListener('mousedown', this.closePopupHandler);\n\t\t\tthis.closePopupHandler = null;\n\t\t}\n\t}\n\n\t/** Closes popup and restores focus to the trigger button. */\n\tcloseAndRestoreFocus(): void {\n\t\tconst triggerBtn: HTMLButtonElement | null = this.activePopupButton;\n\t\tthis.close();\n\t\ttriggerBtn?.focus();\n\t}\n\n\tdestroy(): void {\n\t\tthis.close();\n\t}\n\n\t// --- Positioning ---\n\n\tprivate positionAndAppend(popup: HTMLElement, button: HTMLButtonElement): void {\n\t\tconst rect: DOMRect = button.getBoundingClientRect();\n\t\tpopup.style.position = 'fixed';\n\t\tpopup.style.top = `${rect.bottom + 2}px`;\n\t\tpopup.style.left = `${rect.left}px`;\n\t\tpopup.style.zIndex = '10000';\n\n\t\tconst root: Node = button.getRootNode();\n\t\tif (root instanceof ShadowRoot) {\n\t\t\troot.appendChild(popup);\n\t\t} else {\n\t\t\tdocument.body.appendChild(popup);\n\t\t}\n\t}\n\n\t// --- Focus ---\n\n\tprivate focusFirstItem(popup: HTMLElement): void {\n\t\trequestAnimationFrame(() => {\n\t\t\tconst firstItem: HTMLElement | null =\n\t\t\t\tpopup.querySelector('[role=\"menuitem\"]') ??\n\t\t\t\tpopup.querySelector('.notectl-grid-picker__cell') ??\n\t\t\t\tpopup.querySelector('button');\n\t\t\tfirstItem?.focus();\n\t\t});\n\t}\n\n\t// --- Keyboard Navigation ---\n\n\tprivate handlePopupKeydown(e: KeyboardEvent): void {\n\t\tif (!this.activePopup) return;\n\n\t\tif (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tthis.closeAndRestoreFocus();\n\t\t\treturn;\n\t\t}\n\n\t\tif (e.key === 'Tab') {\n\t\t\te.preventDefault();\n\t\t\tthis.closeAndRestoreFocus();\n\t\t\treturn;\n\t\t}\n\n\t\tconst menuItems: NodeListOf<Element> = this.activePopup.querySelectorAll('[role=\"menuitem\"]');\n\t\tif (menuItems.length > 0) {\n\t\t\tthis.handleDropdownKeydown(e, menuItems);\n\t\t\treturn;\n\t\t}\n\n\t\tconst hasGrid: boolean = this.activePopup.querySelector('.notectl-grid-picker__cell') !== null;\n\t\tif (hasGrid) {\n\t\t\tthis.handleGridKeydown(e);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.handleCustomPopupKeydown(e);\n\t}\n\n\tprivate handleDropdownKeydown(e: KeyboardEvent, items: NodeListOf<Element>): void {\n\t\tconst itemArr: HTMLElement[] = Array.from(items) as HTMLElement[];\n\t\tconst current: number = itemArr.indexOf(this.getActiveElement() as HTMLElement);\n\n\t\tswitch (e.key) {\n\t\t\tcase 'ArrowDown': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst next: number = findNextDropdownItem(itemArr, current, 1);\n\t\t\t\titemArr[next]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowUp': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst prev: number = findNextDropdownItem(itemArr, current, -1);\n\t\t\t\titemArr[prev]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'Enter':\n\t\t\tcase ' ': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst focused: HTMLElement | undefined = itemArr[current];\n\t\t\t\tif (focused) focused.click();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleGridKeydown(e: KeyboardEvent): void {\n\t\tconst focused: HTMLElement = this.getActiveElement() as HTMLElement;\n\t\tconst row: number = Number(focused?.getAttribute('data-row') ?? 1);\n\t\tconst col: number = Number(focused?.getAttribute('data-col') ?? 1);\n\n\t\tconst grid: Element | null =\n\t\t\tthis.activePopup?.querySelector('.notectl-grid-picker__grid') ?? null;\n\t\tif (!grid) return;\n\n\t\tconst lastCell: Element | null = grid.querySelector('.notectl-grid-picker__cell:last-child');\n\t\tconst maxCols: number = Number(lastCell?.getAttribute('data-col') ?? 1);\n\t\tconst maxRows: number = Number(lastCell?.getAttribute('data-row') ?? 1);\n\n\t\tif (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {\n\t\t\te.preventDefault();\n\t\t\tconst [newRow, newCol]: [number, number] = navigateGrid(\n\t\t\t\trow,\n\t\t\t\tcol,\n\t\t\t\tmaxRows,\n\t\t\t\tmaxCols,\n\t\t\t\te.key as 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight',\n\t\t\t);\n\t\t\tconst target: HTMLElement | null = grid.querySelector(\n\t\t\t\t`.notectl-grid-picker__cell[data-row=\"${newRow}\"][data-col=\"${newCol}\"]`,\n\t\t\t);\n\t\t\ttarget?.focus();\n\n\t\t\thighlightCells(grid as HTMLElement, newRow, newCol);\n\t\t\tconst label: Element | null =\n\t\t\t\tthis.activePopup?.querySelector('.notectl-grid-picker__label') ?? null;\n\t\t\tif (label) label.textContent = `${newRow} x ${newCol}`;\n\t\t}\n\n\t\tif (e.key === 'Enter' || e.key === ' ') {\n\t\t\te.preventDefault();\n\t\t\tfocused?.click();\n\t\t}\n\t}\n\n\tprivate handleCustomPopupKeydown(e: KeyboardEvent): void {\n\t\tif (!this.activePopup) return;\n\t\tconst buttons: HTMLButtonElement[] = Array.from(this.activePopup.querySelectorAll('button'));\n\t\tif (buttons.length === 0) return;\n\t\tconst active: HTMLElement = this.getActiveElement() as HTMLElement;\n\t\tconst currentIdx: number = buttons.indexOf(active as HTMLButtonElement);\n\n\t\tswitch (e.key) {\n\t\t\tcase 'ArrowDown': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst next: number = findNextDropdownItem(buttons, currentIdx, 1);\n\t\t\t\tbuttons[next]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowUp': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst prev: number = findNextDropdownItem(buttons, currentIdx, -1);\n\t\t\t\tbuttons[prev]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'Enter':\n\t\t\tcase ' ': {\n\t\t\t\te.preventDefault();\n\t\t\t\tif (active) {\n\t\t\t\t\tactive.dispatchEvent(new MouseEvent('mousedown', { bubbles: true, cancelable: true }));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * ToolbarTooltip: manages the tooltip lifecycle for toolbar buttons.\n * Shows a tooltip after a short delay when hovering or focusing a button,\n * hides it when the cursor leaves or focus moves away.\n */\n\nconst TOOLTIP_DELAY_MS = 500;\n\nexport class ToolbarTooltip {\n\tprivate readonly element: HTMLElement;\n\tprivate timer: ReturnType<typeof setTimeout> | null = null;\n\tprivate target: HTMLButtonElement | null = null;\n\tprivate readonly isPopupActive: () => boolean;\n\n\tstatic readonly TOOLTIP_ID = 'notectl-toolbar-tooltip';\n\n\tconstructor(isPopupActive: () => boolean) {\n\t\tthis.isPopupActive = isPopupActive;\n\t\tthis.element = document.createElement('div');\n\t\tthis.element.className = 'notectl-toolbar-tooltip';\n\t\tthis.element.id = ToolbarTooltip.TOOLTIP_ID;\n\t\tthis.element.setAttribute('role', 'tooltip');\n\t\tthis.element.style.display = 'none';\n\t}\n\n\tshow(button: HTMLButtonElement): void {\n\t\tthis.hide();\n\n\t\tif (this.isPopupActive() || button.disabled) return;\n\n\t\tconst text: string | null = button.getAttribute('data-tooltip');\n\t\tif (!text) return;\n\n\t\tthis.target = button;\n\n\t\tthis.timer = setTimeout(() => {\n\t\t\tif (this.isPopupActive()) return;\n\n\t\t\tthis.element.textContent = text;\n\t\t\tthis.element.style.display = '';\n\n\t\t\tconst root: Node = button.getRootNode();\n\t\t\tif (root instanceof ShadowRoot && !this.element.parentNode) {\n\t\t\t\troot.appendChild(this.element);\n\t\t\t} else if (!(root instanceof ShadowRoot) && !this.element.parentNode) {\n\t\t\t\tdocument.body.appendChild(this.element);\n\t\t\t}\n\n\t\t\tbutton.setAttribute('aria-describedby', ToolbarTooltip.TOOLTIP_ID);\n\n\t\t\tconst rect: DOMRect = button.getBoundingClientRect();\n\t\t\tthis.element.style.position = 'fixed';\n\t\t\tthis.element.style.top = `${rect.bottom + 6}px`;\n\t\t\tthis.element.style.left = `${rect.left + rect.width / 2}px`;\n\t\t\tthis.element.style.transform = 'translateX(-50%)';\n\t\t}, TOOLTIP_DELAY_MS);\n\t}\n\n\thide(): void {\n\t\tif (this.timer) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = null;\n\t\t}\n\t\tif (this.target) {\n\t\t\tthis.target.removeAttribute('aria-describedby');\n\t\t\tthis.target = null;\n\t\t}\n\t\tthis.element.style.display = 'none';\n\t}\n\n\tdestroy(): void {\n\t\tthis.hide();\n\t\tthis.element.remove();\n\t}\n}\n","/**\n * Toolbar plugin: renders toolbar items registered by other plugins.\n * Acts as a pure rendering engine — has no knowledge of specific features.\n * Supports buttons, dropdowns, grid pickers, and custom popups.\n * Implements WAI-ARIA Toolbar pattern with roving tabindex.\n */\n\nimport { TOOLBAR_CSS } from '../../editor/styles/toolbar.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport { ServiceKey } from '../Plugin.js';\nimport type { Plugin, PluginConfig, PluginContext } from '../Plugin.js';\nimport type { ToolbarItem } from './ToolbarItem.js';\nimport {\n\tapplyRovingTabindex,\n\tfindFirstEnabled,\n\tfindLastEnabled,\n\tfindNextEnabled,\n} from './ToolbarKeyboardNav.js';\nimport { TOOLBAR_LOCALES, type ToolbarLocale } from './ToolbarLocale.js';\nimport {\n\tToolbarOverflowBehavior,\n\ttype ToolbarOverflowBehavior as ToolbarOverflowBehaviorType,\n} from './ToolbarOverflowBehavior.js';\nimport { ToolbarOverflowController } from './ToolbarOverflowController.js';\nimport { ToolbarPopupController } from './ToolbarPopupController.js';\nimport { createSeparator } from './ToolbarRenderers.js';\nimport { ToolbarTooltip } from './ToolbarTooltip.js';\n\n// --- Layout Config ---\n\nexport interface ToolbarLayoutConfig {\n\treadonly groups: ReadonlyArray<ReadonlyArray<string>>;\n\t/**\n\t * Controls responsive overflow behavior when toolbar items exceed available width.\n\t * Defaults to `ToolbarOverflowBehavior.BurgerMenu`.\n\t */\n\treadonly overflow?: ToolbarOverflowBehaviorType;\n}\n\n// --- Typed Service API ---\n\nexport interface ToolbarServiceAPI {\n\t/** Re-reads isActive/isEnabled from state and updates all buttons. */\n\trefresh(): void;\n\t/** Closes the currently open popup, if any. */\n\tclosePopup(): void;\n}\n\nexport const ToolbarServiceKey = new ServiceKey<ToolbarServiceAPI>('toolbar');\n\n// --- Plugin ---\n\ninterface ToolbarButton {\n\telement: HTMLButtonElement;\n\titem: ToolbarItem;\n}\n\nexport class ToolbarPlugin implements Plugin {\n\treadonly id = 'toolbar';\n\treadonly name = 'Toolbar';\n\treadonly priority = 10;\n\n\tprivate context: PluginContext | null = null;\n\tprivate toolbarElement: HTMLElement | null = null;\n\tprivate buttons: ToolbarButton[] = [];\n\tprivate readonly hiddenItems = new Set<string>();\n\tprivate readonly layoutConfig: ToolbarLayoutConfig | null;\n\tprivate overflowBehavior: ToolbarOverflowBehaviorType;\n\tprivate focusedIndex = 0;\n\tprivate tooltip: ToolbarTooltip | null = null;\n\tprivate popupController: ToolbarPopupController | null = null;\n\tprivate overflowController: ToolbarOverflowController | null = null;\n\tprivate visibleElements: HTMLButtonElement[] = [];\n\tprivate locale!: ToolbarLocale;\n\n\tconstructor(layoutConfig?: ToolbarLayoutConfig) {\n\t\tthis.layoutConfig = layoutConfig ?? null;\n\t\tthis.overflowBehavior = layoutConfig?.overflow ?? ToolbarOverflowBehavior.BurgerMenu;\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(TOOLBAR_LOCALES, context);\n\t\tcontext.registerStyleSheet(TOOLBAR_CSS);\n\t\tthis.context = context;\n\n\t\tthis.popupController = new ToolbarPopupController(() => this.getActiveElement());\n\t\tthis.tooltip = new ToolbarTooltip(() => this.popupController?.isOpen() ?? false);\n\n\t\tcontext.registerService(ToolbarServiceKey, {\n\t\t\trefresh: () => this.updateButtonStates(context.getState()),\n\t\t\tclosePopup: () => this.popupController?.close(),\n\t\t});\n\n\t\tthis.createToolbarElement();\n\t}\n\n\t/** Returns the current overflow behavior. */\n\tgetOverflowBehavior(): ToolbarOverflowBehaviorType {\n\t\treturn this.overflowBehavior;\n\t}\n\n\t/** Switches the overflow behavior at runtime. */\n\tsetOverflowBehavior(behavior: ToolbarOverflowBehaviorType): void {\n\t\tif (behavior === this.overflowBehavior) return;\n\n\t\tthis.overflowBehavior = behavior;\n\t\tthis.applyOverflowBehavior();\n\t\tthis.renderItems();\n\t}\n\n\tonReady(): void {\n\t\tthis.renderItems();\n\t}\n\n\tdestroy(): void {\n\t\tthis.overflowController?.destroy();\n\t\tthis.overflowController = null;\n\t\tthis.popupController?.destroy();\n\t\tthis.popupController = null;\n\t\tthis.tooltip?.destroy();\n\t\tthis.tooltip = null;\n\t\tif (this.toolbarElement) {\n\t\t\tthis.toolbarElement.remove();\n\t\t\tthis.toolbarElement = null;\n\t\t}\n\t\tthis.buttons = [];\n\t\tthis.visibleElements = [];\n\t\tthis.context = null;\n\t}\n\n\tonStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void {\n\t\tthis.updateButtonStates(newState);\n\t}\n\n\tonReadOnlyChange(readonly: boolean): void {\n\t\tif (this.toolbarElement) {\n\t\t\tthis.toolbarElement.hidden = readonly;\n\t\t}\n\t}\n\n\tonConfigure(config: PluginConfig): void {\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tif (value === false) {\n\t\t\t\tthis.hiddenItems.add(key);\n\t\t\t} else {\n\t\t\t\tthis.hiddenItems.delete(key);\n\t\t\t}\n\t\t}\n\t\tthis.renderItems();\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate createToolbarElement(): void {\n\t\tif (!this.context) return;\n\n\t\tif (this.toolbarElement) {\n\t\t\tthis.toolbarElement.remove();\n\t\t}\n\t\tthis.buttons = [];\n\n\t\tconst container: HTMLElement = this.context.getPluginContainer('top');\n\t\tthis.toolbarElement = document.createElement('div');\n\t\tthis.toolbarElement.setAttribute('role', 'toolbar');\n\t\tthis.toolbarElement.setAttribute('aria-label', this.locale.formattingOptionsAria);\n\t\tthis.toolbarElement.setAttribute('data-notectl-no-print', '');\n\t\tthis.toolbarElement.className = 'notectl-toolbar';\n\n\t\tthis.toolbarElement.addEventListener('keydown', (e) => this.handleToolbarKeydown(e));\n\n\t\tthis.applyOverflowBehavior();\n\t\tcontainer.appendChild(this.toolbarElement);\n\t}\n\n\t/** Applies the current overflow behavior: creates/destroys the overflow controller and sets the data attribute. */\n\tprivate applyOverflowBehavior(): void {\n\t\tif (!this.toolbarElement || !this.context) return;\n\n\t\t// Tear down existing overflow controller\n\t\tthis.overflowController?.destroy();\n\t\tthis.overflowController = null;\n\n\t\tthis.toolbarElement.setAttribute('data-overflow', this.overflowBehavior);\n\n\t\tif (this.overflowBehavior === ToolbarOverflowBehavior.BurgerMenu) {\n\t\t\tthis.overflowController = new ToolbarOverflowController({\n\t\t\t\ttoolbar: this.toolbarElement,\n\t\t\t\tariaLabel: this.locale.moreToolsAria,\n\t\t\t\tcontext: this.context,\n\t\t\t\tonOverflowChange: (visibleButtons, overflowBtn) => {\n\t\t\t\t\tthis.visibleElements = overflowBtn\n\t\t\t\t\t\t? [...visibleButtons, overflowBtn]\n\t\t\t\t\t\t: [...visibleButtons];\n\t\t\t\t\tthis.initRovingTabindex();\n\t\t\t\t},\n\t\t\t\tonItemActivated: (btn: HTMLButtonElement, item: ToolbarItem) => {\n\t\t\t\t\tthis.activateButton(btn, item);\n\t\t\t\t},\n\t\t\t\tgetActiveElement: () => this.getActiveElement(),\n\t\t\t});\n\t\t} else {\n\t\t\t// Flow and None modes: all buttons are visible for roving tabindex\n\t\t\tthis.visibleElements = [];\n\t\t}\n\t}\n\n\tprivate renderItems(): void {\n\t\tif (!this.context || !this.toolbarElement) return;\n\n\t\tfor (const btn of this.buttons) {\n\t\t\tbtn.element.remove();\n\t\t}\n\t\tthis.buttons = [];\n\n\t\tfor (const sep of this.toolbarElement.querySelectorAll('.notectl-toolbar-separator')) {\n\t\t\tsep.remove();\n\t\t}\n\n\t\tif (this.layoutConfig) {\n\t\t\tthis.renderItemsByLayout();\n\t\t} else {\n\t\t\tthis.renderItemsByPriority();\n\t\t}\n\n\t\tif (this.buttons.length > 0 && !this.toolbarElement.parentElement) {\n\t\t\tconst container: HTMLElement = this.context.getPluginContainer('top');\n\t\t\tcontainer.appendChild(this.toolbarElement);\n\t\t}\n\n\t\tthis.overflowController?.update(this.buttons);\n\t\tthis.initRovingTabindex();\n\t\tthis.updateButtonStates(this.context.getState());\n\t}\n\n\t// --- Roving Tabindex ---\n\n\tprivate getTabElements(): HTMLButtonElement[] {\n\t\treturn this.visibleElements.length > 0\n\t\t\t? this.visibleElements\n\t\t\t: this.buttons.map((b) => b.element);\n\t}\n\n\tprivate initRovingTabindex(): void {\n\t\tconst elements: HTMLButtonElement[] = this.getTabElements();\n\t\tconst first: number = findFirstEnabled(elements);\n\t\tthis.focusedIndex = first >= 0 ? first : 0;\n\t\tapplyRovingTabindex(elements, this.focusedIndex);\n\t}\n\n\tprivate setRovingFocus(index: number): void {\n\t\tconst elements: HTMLButtonElement[] = this.getTabElements();\n\t\tif (index < 0 || index >= elements.length) return;\n\t\tthis.focusedIndex = index;\n\t\tapplyRovingTabindex(elements, index);\n\t\telements[index]?.focus();\n\t}\n\n\t/** Returns the active element, respecting shadow DOM boundaries. */\n\tprivate getActiveElement(): Element | null {\n\t\tconst root: Node | undefined = this.toolbarElement?.getRootNode();\n\t\tif (root instanceof ShadowRoot) {\n\t\t\treturn root.activeElement;\n\t\t}\n\t\treturn document.activeElement;\n\t}\n\n\tprivate syncFocusedIndex(): void {\n\t\tconst active: Element | null = this.getActiveElement();\n\t\tconst elements: HTMLButtonElement[] = this.getTabElements();\n\t\tconst idx: number = elements.findIndex((el) => el === active);\n\t\tif (idx >= 0) {\n\t\t\tthis.focusedIndex = idx;\n\t\t}\n\t}\n\n\t// --- Toolbar Keyboard ---\n\n\tprivate handleToolbarKeydown(e: KeyboardEvent): void {\n\t\tconst elements: HTMLButtonElement[] = this.getTabElements();\n\t\tif (elements.length === 0) return;\n\n\t\tthis.syncFocusedIndex();\n\n\t\tswitch (e.key) {\n\t\t\tcase 'ArrowRight': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst next: number = findNextEnabled(elements, this.focusedIndex, 1);\n\t\t\t\tthis.setRovingFocus(next);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowLeft': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst prev: number = findNextEnabled(elements, this.focusedIndex, -1);\n\t\t\t\tthis.setRovingFocus(prev);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'Home': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst first: number = findFirstEnabled(elements);\n\t\t\t\tif (first >= 0) this.setRovingFocus(first);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'End': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst last: number = findLastEnabled(elements);\n\t\t\t\tif (last >= 0) this.setRovingFocus(last);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'Enter':\n\t\t\tcase ' ': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst focused: HTMLButtonElement | undefined = elements[this.focusedIndex];\n\t\t\t\tconst btn: ToolbarButton | undefined = this.buttons.find((b) => b.element === focused);\n\t\t\t\tif (btn) this.activateButton(btn.element, btn.item);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Activates a toolbar button (shared between mouse click and keyboard). */\n\tprivate activateButton(btn: HTMLButtonElement, item: ToolbarItem): void {\n\t\tthis.tooltip?.hide();\n\t\tif (item.popupType && this.context) {\n\t\t\tthis.popupController?.toggle(btn, item, this.context);\n\t\t} else {\n\t\t\tthis.context?.executeCommand(item.command);\n\t\t}\n\t}\n\n\t// --- Layout Rendering ---\n\n\tprivate renderItemsByLayout(): void {\n\t\tif (!this.context || !this.toolbarElement || !this.layoutConfig) return;\n\n\t\tconst registry = this.context.getSchemaRegistry();\n\t\tlet firstGroup = true;\n\n\t\tfor (const groupPluginIds of this.layoutConfig.groups) {\n\t\t\tconst groupItems: ToolbarItem[] = [];\n\t\t\tfor (const pId of groupPluginIds) {\n\t\t\t\tconst items: ToolbarItem[] = registry\n\t\t\t\t\t.getToolbarItemsByPlugin(pId)\n\t\t\t\t\t.filter((item) => !this.hiddenItems.has(item.id));\n\t\t\t\titems.sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));\n\t\t\t\tgroupItems.push(...items);\n\t\t\t}\n\n\t\t\tif (groupItems.length === 0) continue;\n\n\t\t\tif (!firstGroup) {\n\t\t\t\tthis.toolbarElement.appendChild(createSeparator());\n\t\t\t}\n\t\t\tfirstGroup = false;\n\n\t\t\tfor (const item of groupItems) {\n\t\t\t\tconst btn: ToolbarButton = this.createButton(item);\n\t\t\t\tthis.toolbarElement.appendChild(btn.element);\n\t\t\t\tthis.buttons.push(btn);\n\t\t\t}\n\t\t}\n\n\t\tif (this.buttons.length === 0) {\n\t\t\tthis.toolbarElement.remove();\n\t\t}\n\t}\n\n\tprivate renderItemsByPriority(): void {\n\t\tif (!this.context || !this.toolbarElement) return;\n\n\t\tconst registry = this.context.getSchemaRegistry();\n\t\tconst items: ToolbarItem[] = registry\n\t\t\t.getToolbarItems()\n\t\t\t.filter((item) => !this.hiddenItems.has(item.id));\n\t\tif (items.length === 0) {\n\t\t\tthis.toolbarElement.remove();\n\t\t\treturn;\n\t\t}\n\n\t\tconst sorted: ToolbarItem[] = [...items].sort(\n\t\t\t(a, b) => (a.priority ?? 100) - (b.priority ?? 100),\n\t\t);\n\n\t\tconst hasSeparatorAfter: boolean = sorted.some((item) => item.separatorAfter);\n\n\t\tif (hasSeparatorAfter) {\n\t\t\tfor (let i = 0; i < sorted.length; i++) {\n\t\t\t\tconst item: ToolbarItem | undefined = sorted[i];\n\t\t\t\tif (!item) continue;\n\t\t\t\tconst btn: ToolbarButton = this.createButton(item);\n\t\t\t\tthis.toolbarElement.appendChild(btn.element);\n\t\t\t\tthis.buttons.push(btn);\n\n\t\t\t\tif (item.separatorAfter && i < sorted.length - 1) {\n\t\t\t\t\tthis.toolbarElement.appendChild(createSeparator());\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst groups = new Map<string, ToolbarItem[]>();\n\t\t\tfor (const item of sorted) {\n\t\t\t\tconst list: ToolbarItem[] = groups.get(item.group) ?? [];\n\t\t\t\tlist.push(item);\n\t\t\t\tgroups.set(item.group, list);\n\t\t\t}\n\n\t\t\tlet firstGroup = true;\n\t\t\tfor (const [, groupItems] of groups) {\n\t\t\t\tif (!firstGroup) {\n\t\t\t\t\tthis.toolbarElement.appendChild(createSeparator());\n\t\t\t\t}\n\t\t\t\tfirstGroup = false;\n\n\t\t\t\tfor (const item of groupItems) {\n\t\t\t\t\tconst btn: ToolbarButton = this.createButton(item);\n\t\t\t\t\tthis.toolbarElement.appendChild(btn.element);\n\t\t\t\t\tthis.buttons.push(btn);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Button Creation ---\n\n\tprivate createButton(item: ToolbarItem): ToolbarButton {\n\t\tconst btn: HTMLButtonElement = document.createElement('button');\n\t\tbtn.type = 'button';\n\t\tbtn.className = `notectl-toolbar-btn notectl-toolbar-btn--${item.id}`;\n\t\tbtn.setAttribute('aria-pressed', 'false');\n\t\tbtn.setAttribute('aria-label', item.label);\n\t\tbtn.setAttribute('data-toolbar-item', item.id);\n\t\tbtn.setAttribute('data-tooltip', item.tooltip ?? item.label);\n\n\t\tif (item.popupType) {\n\t\t\tbtn.setAttribute('aria-haspopup', 'true');\n\t\t\tbtn.setAttribute('aria-expanded', 'false');\n\t\t}\n\n\t\tconst span: HTMLSpanElement = document.createElement('span');\n\t\tspan.className = 'notectl-toolbar-btn__icon';\n\t\tspan.innerHTML = item.icon;\n\t\tbtn.appendChild(span);\n\n\t\tbtn.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\tthis.activateButton(btn, item);\n\t\t});\n\n\t\tbtn.addEventListener('mouseenter', () => this.tooltip?.show(btn));\n\t\tbtn.addEventListener('mouseleave', () => this.tooltip?.hide());\n\t\tbtn.addEventListener('focus', () => this.tooltip?.show(btn));\n\t\tbtn.addEventListener('blur', () => this.tooltip?.hide());\n\n\t\treturn { element: btn, item };\n\t}\n\n\t// --- Button State Updates ---\n\n\tprivate updateButtonStates(state: EditorState): void {\n\t\tfor (const btn of this.buttons) {\n\t\t\tconst active: boolean = btn.item.isActive?.(state) ?? false;\n\t\t\tconst enabled: boolean = btn.item.isEnabled?.(state) ?? true;\n\t\t\tbtn.element.setAttribute('aria-pressed', String(active));\n\t\t\tbtn.element.classList.toggle('notectl-toolbar-btn--active', active);\n\t\t\tbtn.element.disabled = !enabled;\n\t\t\tif (!enabled) {\n\t\t\t\tbtn.element.setAttribute('aria-disabled', 'true');\n\t\t\t} else {\n\t\t\t\tbtn.element.removeAttribute('aria-disabled');\n\t\t\t}\n\t\t}\n\t\tthis.overflowController?.updateItemStates(state);\n\t}\n}\n"],"names":["TOOLBAR_LOCALE_EN","formattingOptionsAria","moreToolsAria","TOOLBAR_LOCALES","en","de","es","fr","zh","ru","ar","hi","ToolbarOverflowBehavior","BurgerMenu","Flow","None","HIDDEN_BTN_CLASS","HIDDEN_SEP_CLASS","ToolbarOverflowController","toolbar","context","onOverflowChange","onItemActivated","getActiveElement","ariaLabel","entries","overflowButton","overflowDropdown","overflowEntries","resizeObserver","closeHandler","config","this","ResizeObserver","recalculate","observe","buttons","map","b","element","item","length","closeDropdown","resetVisibility","ensureOverflowButton","setOverflowButtonVisible","maxWidth","measureAvailableWidth","usedWidth","overflowing","overflowList","children","Array","from","child","classList","contains","add","sepWidth","offsetWidth","entry","find","oe","push","btnWidth","hideTrailingSeparators","notifyChange","state","menuItems","querySelectorAll","menuItem","itemId","getAttribute","id","active","isActive","enabled","isEnabled","toggle","disabled","destroy","disconnect","remove","toolbarStyle","getComputedStyle","paddingLeft","Number","parseFloat","paddingRight","clientWidth","separators","sep","visible","removeAttribute","btn","document","createElement","type","className","setAttribute","innerHTML","addEventListener","e","preventDefault","toggleDropdown","appendChild","openDropdown","dropdown","renderDropdownItems","positionDropdown","appendToRoot","requestAnimationFrame","first","querySelector","focus","handleDropdownKeydown","registerCloseHandler","lastGroup","group","menuBtn","iconSpan","icon","labelSpan","textContent","tooltip","label","ev","stopPropagation","activateOverflowItem","rect","getBoundingClientRect","rightEdge","window","innerWidth","right","style","position","top","bottom","left","zIndex","root","getRootNode","ShadowRoot","body","path","composedPath","includes","setTimeout","removeEventListener","popupType","executeCommand","command","key","items","current","indexOf","next","findNextDropdownItem","prev","focusedItem","i","filter","highlightCells","grid","targetRow","targetCol","cells","cell","r","c","createSeparator","ToolbarPopupController","activePopup","activePopupButton","closePopupHandler","isOpen","button","close","popup","container","onClose","display","gridTemplateColumns","maxCols","gap","padding","textAlign","fontSize","maxRows","width","height","border","cursor","String","onSelect","popupConfig","cmd","renderPopup","positionAndAppend","focusFirstItem","handlePopupKeydown","closeAndRestoreFocus","triggerBtn","firstItem","handleGridKeydown","handleCustomPopupKeydown","itemArr","focused","click","row","col","lastCell","newRow","newCol","navigateGrid","target","currentIdx","dispatchEvent","MouseEvent","bubbles","cancelable","ToolbarTooltip","timer","isPopupActive","static","TOOLTIP_ID","hide","text","parentNode","transform","clearTimeout","ToolbarServiceKey","ServiceKey","ToolbarPlugin","name","priority","toolbarElement","hiddenItems","Set","layoutConfig","overflowBehavior","focusedIndex","popupController","overflowController","visibleElements","locale","overflow","resolvePluginLocale","registerStyleSheet","registerService","refresh","updateButtonStates","getState","closePopup","createToolbarElement","getOverflowBehavior","behavior","applyOverflowBehavior","renderItems","_oldState","newState","_tr","readonly","hidden","value","Object","delete","getPluginContainer","handleToolbarKeydown","visibleButtons","overflowBtn","initRovingTabindex","activateButton","renderItemsByLayout","renderItemsByPriority","parentElement","update","getTabElements","elements","findFirstEnabled","applyRovingTabindex","index","activeElement","syncFocusedIndex","idx","findIndex","el","findNextEnabled","setRovingFocus","last","findLastEnabled","registry","getSchemaRegistry","firstGroup","groupPluginIds","groups","groupItems","pId","getToolbarItemsByPlugin","has","sort","a","createButton","getToolbarItems","sorted","some","separatorAfter","Map","list","get","set","span","show","updateItemStates"],"mappings":";;AACO,MCUMA,IAAmC,EAC/CC,uBAAuB,sBACvBC,eAAe,aAAA,GAsDHC,IAAiD,EAC7DC,IAAIJ,GACJK,IAnD+C,EAC/CJ,uBAAuB,yBACvBC,eAAe,uBAkDfI,IA7C+C,EAC/CL,uBAAuB,uBACvBC,eAAe,sBA4CfK,IAvC+C,EAC/CN,uBAAuB,4BACvBC,eAAe,mBAsCfM,IAjC+C,EAC/CP,uBAAuB,QACvBC,eAAe,UAgCfO,IA3B+C,EAC/CR,uBAAuB,4BACvBC,eAAe,wBA0BfQ,IArB+C,EAC/CT,uBAAuB,kBACvBC,eAAe,kBAoBfS,IAf+C,EAC/CV,uBAAuB,sBACvBC,eAAe,gBCjDHU,IAA0B,EAEtCC,YAAY,eAEZC,MAAM,QAENC,MAAM,OAAA,GCmBDC,IAAmB,wCACnBC,IAAmB;AAOlB,MAAMC,EAAAA;AAAAA,EACKC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EAETC,UAA2B,CAAA;AAAA,EAC3BC,iBAA2C;AAAA,EAC3CC,mBAAuC;AAAA,EACvCC,kBAAmC,CAAA;AAAA,EACnCC,iBAAwC;AAAA,EACxCC,eAAiD;AAAA,EAEzD,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MAAMrE,KAAK4F,SAAS6L,KAAK3N,EAAAA,CAAAA,GAC5DA,GAAIO,iBAAiB,cAAc,MAAMrE,KAAK4F,SAASuG,SACvDrI,GAAIO,iBAAiB,SAAS,MAAMrE,KAAK4F,SAAS6L,KAAK3N,EAAAA,CAAAA,GACvDA,GAAIO,iBAAiB,QAAQ,MAAMrE,KAAK4F,SAASuG,SAE1C,EAAE5L,SAASuD,IAAKtD,MAAAA,GAAAA;AAAAA,EACxB;AAAA,EAIQ,mBAAmB2B,IAAAA;AAC1B,eAAW2B,MAAO9D,KAAKI,SAAS;AAC/B,YAAMsC,KAAkBoB,GAAItD,KAAKmC,WAAWR,EAAAA,KAAAA,OACtCS,KAAmBkB,GAAItD,KAAKqC,YAAYV,EAAAA,KAAAA;AAC9C2B,MAAAA,GAAIvD,QAAQ4D,aAAa,gBAAgB+F,OAAOxH,EAAAA,CAAAA,GAChDoB,GAAIvD,QAAQgB,UAAUuB,OAAO,+BAA+BJ,EAAAA,GAC5DoB,GAAIvD,QAAQwC,WAAAA,CAAYH,IACnBA,KAGJkB,GAAIvD,QAAQsD,gBAAgB,eAAA,IAF5BC,GAAIvD,QAAQ4D,aAAa,iBAAiB,MAAA;AAAA,IAI5C;AACAnE,SAAKoN,oBAAoBsE,iBAAiBvP;EAC3C;AAAA;"}
|
|
1
|
+
{"version":3,"file":"ToolbarPlugin-B6JETWaw.mjs","sources":["../../src/editor/styles/toolbar.ts","../../src/plugins/toolbar/ToolbarLocale.ts","../../src/plugins/toolbar/ToolbarOverflowBehavior.ts","../../src/plugins/toolbar/ToolbarOverflowController.ts","../../src/plugins/toolbar/ToolbarRenderers.ts","../../src/plugins/toolbar/ToolbarPopupController.ts","../../src/plugins/toolbar/ToolbarTooltip.ts","../../src/plugins/toolbar/ToolbarPlugin.ts"],"sourcesContent":["/** Toolbar styles — buttons, separators, tooltips, popups, dropdowns. */\nexport const TOOLBAR_CSS = `\n/* Toolbar */\n.notectl-plugin-container--top {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\tborder-bottom: 1px solid var(--notectl-border);\n\tbackground: var(--notectl-toolbar-bg, var(--notectl-surface-raised));\n\tmin-height: 40px;\n}\n\n.notectl-toolbar {\n\tdisplay: flex;\n\talign-items: center;\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n\tflex: 1;\n\tmin-width: 0;\n\tgap: 2px;\n\tpadding: 4px 8px;\n}\n\n.notectl-toolbar[hidden] {\n\tdisplay: none;\n}\n\n.notectl-toolbar-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n\tfont-size: 14px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n.notectl-toolbar-btn:hover {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-border);\n}\n\n.notectl-toolbar-btn--active {\n\tbackground: var(--notectl-active-bg);\n\tborder-color: var(--notectl-primary-muted);\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-toolbar-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n.notectl-toolbar-btn:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n.notectl-toolbar-btn:disabled:hover {\n\tbackground: transparent;\n\tborder-color: transparent;\n}\n\n.notectl-toolbar-btn__icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tpointer-events: none;\n}\n\n.notectl-toolbar-btn__icon svg {\n\tdisplay: block;\n\twidth: 18px;\n\theight: 18px;\n\tfill: currentColor;\n}\n\n/* Tooltip (rendered as fixed-position element in shadow root) */\n.notectl-toolbar-tooltip {\n\tposition: fixed;\n\tpadding: 4px 8px;\n\tborder-radius: 4px;\n\tbackground: var(--notectl-tooltip-bg);\n\tcolor: var(--notectl-tooltip-fg);\n\tfont-size: 11px;\n\tfont-weight: 500;\n\twhite-space: nowrap;\n\tpointer-events: none;\n\tz-index: 10001;\n\tline-height: 1.4;\n\tletter-spacing: 0.01em;\n\tfont-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.notectl-toolbar-separator {\n\tdisplay: inline-block;\n\twidth: 1px;\n\theight: 20px;\n\tbackground: var(--notectl-border);\n\tmargin: 0 4px;\n\tvertical-align: middle;\n}\n\n/* Toolbar Popups */\n.notectl-toolbar-popup {\n\tbackground: var(--notectl-surface-overlay);\n\tborder: 1px solid var(--notectl-border);\n\tborder-radius: 6px;\n\tbox-shadow: 0 4px 12px var(--notectl-shadow);\n\toverflow: hidden;\n}\n\n/* Grid Picker */\n.notectl-grid-picker__cell:focus-visible {\n\toutline: 2px solid var(--notectl-focus-ring);\n\toutline-offset: -1px;\n}\n\n.notectl-grid-picker__cell--highlighted {\n\tbackground: var(--notectl-primary-muted);\n\tborder-color: var(--notectl-primary);\n}\n\n/* Dropdown */\n.notectl-dropdown {\n\tmin-width: 160px;\n\tpadding: 4px 0;\n}\n\n.notectl-dropdown__item {\n\tdisplay: flex;\n\talign-items: center;\n\twidth: 100%;\n\tpadding: 8px 12px;\n\ttext-align: left;\n\tborder: none;\n\tbackground: none;\n\tcursor: pointer;\n\tfont-size: 14px;\n\tcolor: var(--notectl-fg);\n\tline-height: 1.4;\n\tfont-family: inherit;\n\twhite-space: nowrap;\n}\n\n.notectl-dropdown__item:hover,\n.notectl-dropdown__item:focus-visible {\n\tbackground: var(--notectl-hover-bg);\n}\n\n.notectl-dropdown__item:focus-visible {\n\toutline: none;\n}\n\n.notectl-dropdown__item-icon {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 28px;\n\tfont-weight: 600;\n\tcolor: var(--notectl-fg-muted);\n\tflex-shrink: 0;\n}\n\n.notectl-dropdown__item-label {\n\tflex: 1;\n}\n\n/* Overflow behavior: flow mode — toolbar wraps to additional rows */\n.notectl-toolbar[data-overflow=\"flow\"] {\n\tflex-wrap: wrap;\n\toverflow: visible;\n}\n\n/* Overflow behavior: none — toolbar clips without any responsive behavior */\n.notectl-toolbar[data-overflow=\"none\"] {\n\tflex-wrap: nowrap;\n\toverflow: hidden;\n}\n\n/* Overflow: hidden items (burger-menu mode) */\n.notectl-toolbar-btn--overflow-hidden,\n.notectl-toolbar-separator--overflow-hidden {\n\tdisplay: none;\n}\n\n/* Overflow \"more\" button */\n.notectl-toolbar-overflow-btn {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid transparent;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcursor: pointer;\n\tcolor: var(--notectl-fg);\n\tfont-size: 16px;\n\tline-height: 1;\n\tpadding: 0;\n\tflex-shrink: 0;\n\tmargin-left: auto;\n\ttransition: background 0.1s, border-color 0.1s;\n}\n\n.notectl-toolbar-overflow-btn:hover {\n\tbackground: var(--notectl-hover-bg);\n\tborder-color: var(--notectl-border);\n}\n\n.notectl-toolbar-overflow-btn--hidden {\n\tdisplay: none;\n}\n\n.notectl-toolbar-overflow-btn:focus-visible {\n\tbox-shadow: 0 0 0 2px var(--notectl-focus-ring);\n\toutline: none;\n}\n\n/* Dropdown item states shared by all dropdown menus (including overflow) */\n.notectl-dropdown__item:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n.notectl-dropdown__item:disabled:hover {\n\tbackground: none;\n}\n\n.notectl-dropdown__item--active {\n\tcolor: var(--notectl-primary-fg);\n}\n\n.notectl-dropdown__item-icon svg {\n\tdisplay: block;\n\twidth: 16px;\n\theight: 16px;\n\tfill: currentColor;\n}\n\n.notectl-dropdown__separator {\n\theight: 1px;\n\tbackground: var(--notectl-border);\n\tmargin: 4px 0;\n}\n`;\n","/** Locale interface and default English locale for the ToolbarPlugin. */\n\n// --- Locale Interface ---\n\nexport interface ToolbarLocale {\n\treadonly formattingOptionsAria: string;\n\treadonly moreToolsAria: string;\n}\n\n// --- Default English Locale ---\n\nexport const TOOLBAR_LOCALE_EN: ToolbarLocale = {\n\tformattingOptionsAria: 'Formatting options',\n\tmoreToolsAria: 'More tools',\n};\n\n// --- German Locale ---\n\nexport const TOOLBAR_LOCALE_DE: ToolbarLocale = {\n\tformattingOptionsAria: 'Formatierungsoptionen',\n\tmoreToolsAria: 'Weitere Werkzeuge',\n};\n\n// --- Spanish Locale ---\n\nexport const TOOLBAR_LOCALE_ES: ToolbarLocale = {\n\tformattingOptionsAria: 'Opciones de formato',\n\tmoreToolsAria: 'Más herramientas',\n};\n\n// --- French Locale ---\n\nexport const TOOLBAR_LOCALE_FR: ToolbarLocale = {\n\tformattingOptionsAria: 'Options de mise en forme',\n\tmoreToolsAria: \"Plus d'outils\",\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const TOOLBAR_LOCALE_ZH: ToolbarLocale = {\n\tformattingOptionsAria: '格式选项',\n\tmoreToolsAria: '更多工具',\n};\n\n// --- Russian Locale ---\n\nexport const TOOLBAR_LOCALE_RU: ToolbarLocale = {\n\tformattingOptionsAria: 'Параметры форматирования',\n\tmoreToolsAria: 'Другие инструменты',\n};\n\n// --- Arabic Locale ---\n\nexport const TOOLBAR_LOCALE_AR: ToolbarLocale = {\n\tformattingOptionsAria: 'خيارات التنسيق',\n\tmoreToolsAria: 'أدوات إضافية',\n};\n\n// --- Hindi Locale ---\n\nexport const TOOLBAR_LOCALE_HI: ToolbarLocale = {\n\tformattingOptionsAria: 'फ़ॉर्मेटिंग विकल्प',\n\tmoreToolsAria: 'और उपकरण',\n};\n\n// --- Locale Map ---\n\nexport const TOOLBAR_LOCALES: Record<string, ToolbarLocale> = {\n\ten: TOOLBAR_LOCALE_EN,\n\tde: TOOLBAR_LOCALE_DE,\n\tes: TOOLBAR_LOCALE_ES,\n\tfr: TOOLBAR_LOCALE_FR,\n\tzh: TOOLBAR_LOCALE_ZH,\n\tru: TOOLBAR_LOCALE_RU,\n\tar: TOOLBAR_LOCALE_AR,\n\thi: TOOLBAR_LOCALE_HI,\n};\n","/**\n * Controls how the toolbar responds when items exceed the available width.\n *\n * @example\n * ```typescript\n * const editor = await createEditor({\n * toolbar: {\n * groups: [[BoldPlugin, ItalicPlugin], [HeadingPlugin]],\n * overflow: ToolbarOverflowBehavior.Flow,\n * },\n * });\n * ```\n */\nexport const ToolbarOverflowBehavior = {\n\t/** Items that don't fit are hidden behind a \"...\" dropdown button. Default. */\n\tBurgerMenu: 'burger-menu',\n\t/** Toolbar wraps to additional rows when items overflow. Pure CSS, no JS measurement. */\n\tFlow: 'flow',\n\t/** No responsive behavior; the toolbar clips at the container boundary. */\n\tNone: 'none',\n} as const;\n\nexport type ToolbarOverflowBehavior =\n\t(typeof ToolbarOverflowBehavior)[keyof typeof ToolbarOverflowBehavior];\n","/**\n * ToolbarOverflowController: manages responsive toolbar overflow.\n * Uses ResizeObserver to detect when items exceed available width,\n * hides overflow items, and shows a \"more\" dropdown button.\n */\n\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { ToolbarItem } from './ToolbarItem.js';\nimport { findNextDropdownItem } from './ToolbarKeyboardNav.js';\n\n// --- Types ---\n\ninterface OverflowEntry {\n\treadonly element: HTMLButtonElement;\n\treadonly item: ToolbarItem;\n}\n\ntype OnOverflowChange = (\n\tvisibleButtons: readonly HTMLButtonElement[],\n\toverflowButton: HTMLButtonElement | null,\n) => void;\n\ntype OnItemActivated = (overflowButton: HTMLButtonElement, item: ToolbarItem) => void;\n\nexport interface OverflowControllerConfig {\n\treadonly toolbar: HTMLElement;\n\treadonly ariaLabel: string;\n\treadonly context: PluginContext;\n\treadonly onOverflowChange: OnOverflowChange;\n\treadonly onItemActivated: OnItemActivated;\n\treadonly getActiveElement: () => Element | null;\n}\n\n// --- Constants ---\n\nconst OVERFLOW_BTN_WIDTH = 34;\nconst GAP = 2;\nconst HIDDEN_BTN_CLASS = 'notectl-toolbar-btn--overflow-hidden';\nconst HIDDEN_SEP_CLASS = 'notectl-toolbar-separator--overflow-hidden';\nconst HIDDEN_OVERFLOW_CLASS = 'notectl-toolbar-overflow-btn--hidden';\nconst ELLIPSIS_SVG =\n\t'<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\"><circle cx=\"3\" cy=\"8\" r=\"1.5\" fill=\"currentColor\"/><circle cx=\"8\" cy=\"8\" r=\"1.5\" fill=\"currentColor\"/><circle cx=\"13\" cy=\"8\" r=\"1.5\" fill=\"currentColor\"/></svg>';\n\n// --- Controller ---\n\nexport class ToolbarOverflowController {\n\tprivate readonly toolbar: HTMLElement;\n\tprivate readonly context: PluginContext;\n\tprivate readonly onOverflowChange: OnOverflowChange;\n\tprivate readonly onItemActivated: OnItemActivated;\n\tprivate readonly getActiveElement: () => Element | null;\n\tprivate readonly ariaLabel: string;\n\n\tprivate entries: OverflowEntry[] = [];\n\tprivate overflowButton: HTMLButtonElement | null = null;\n\tprivate overflowDropdown: HTMLElement | null = null;\n\tprivate overflowEntries: OverflowEntry[] = [];\n\tprivate resizeObserver: ResizeObserver | null = null;\n\tprivate closeHandler: ((e: MouseEvent) => void) | null = null;\n\n\tconstructor(config: OverflowControllerConfig) {\n\t\tthis.toolbar = config.toolbar;\n\t\tthis.ariaLabel = config.ariaLabel;\n\t\tthis.context = config.context;\n\t\tthis.onOverflowChange = config.onOverflowChange;\n\t\tthis.onItemActivated = config.onItemActivated;\n\t\tthis.getActiveElement = config.getActiveElement;\n\n\t\tthis.resizeObserver = new ResizeObserver(() => this.recalculate());\n\t\tthis.resizeObserver.observe(this.toolbar);\n\t}\n\n\t/** Called after renderItems() — stores button references and recalculates. */\n\tupdate(buttons: readonly { element: HTMLButtonElement; item: ToolbarItem }[]): void {\n\t\tthis.entries = buttons.map((b) => ({ element: b.element, item: b.item }));\n\t\tthis.recalculate();\n\t}\n\n\t/** Measures toolbar and redistributes items between visible and overflow. */\n\trecalculate(): void {\n\t\tif (this.entries.length === 0) return;\n\n\t\tthis.closeDropdown();\n\t\tthis.resetVisibility();\n\t\tthis.ensureOverflowButton();\n\t\tthis.setOverflowButtonVisible(false);\n\n\t\tconst availableWidth: number = this.measureAvailableWidth();\n\t\tconst maxWidth: number = availableWidth - OVERFLOW_BTN_WIDTH - GAP;\n\t\tlet usedWidth = 0;\n\t\tlet overflowing = false;\n\t\tconst overflowList: OverflowEntry[] = [];\n\n\t\tconst children: HTMLElement[] = Array.from(this.toolbar.children) as HTMLElement[];\n\t\tfor (const child of children) {\n\t\t\tif (child === this.overflowButton) continue;\n\n\t\t\tif (child.classList.contains('notectl-toolbar-separator')) {\n\t\t\t\tif (overflowing) {\n\t\t\t\t\tchild.classList.add(HIDDEN_SEP_CLASS);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst sepWidth: number = child.offsetWidth + GAP;\n\t\t\t\tif (usedWidth + sepWidth > maxWidth) {\n\t\t\t\t\toverflowing = true;\n\t\t\t\t\tchild.classList.add(HIDDEN_SEP_CLASS);\n\t\t\t\t} else {\n\t\t\t\t\tusedWidth += sepWidth;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst entry: OverflowEntry | undefined = this.entries.find((oe) => oe.element === child);\n\t\t\tif (!entry) continue;\n\n\t\t\tif (overflowing) {\n\t\t\t\tentry.element.classList.add(HIDDEN_BTN_CLASS);\n\t\t\t\toverflowList.push(entry);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst btnWidth: number = entry.element.offsetWidth + GAP;\n\t\t\tif (usedWidth + btnWidth > maxWidth) {\n\t\t\t\toverflowing = true;\n\t\t\t\tentry.element.classList.add(HIDDEN_BTN_CLASS);\n\t\t\t\toverflowList.push(entry);\n\t\t\t} else {\n\t\t\t\tusedWidth += btnWidth;\n\t\t\t}\n\t\t}\n\n\t\tthis.overflowEntries = overflowList;\n\t\tthis.hideTrailingSeparators();\n\t\tthis.setOverflowButtonVisible(overflowList.length > 0);\n\t\tthis.notifyChange();\n\t}\n\n\t/** Updates active/disabled states for items in the open overflow dropdown. */\n\tupdateItemStates(state: EditorState): void {\n\t\tif (!this.overflowDropdown) return;\n\n\t\tconst menuItems: HTMLButtonElement[] = Array.from(\n\t\t\tthis.overflowDropdown.querySelectorAll('.notectl-dropdown__item'),\n\t\t) as HTMLButtonElement[];\n\n\t\tfor (const menuItem of menuItems) {\n\t\t\tconst itemId: string | null = menuItem.getAttribute('data-toolbar-item');\n\t\t\tconst entry: OverflowEntry | undefined = this.overflowEntries.find(\n\t\t\t\t(oe) => oe.item.id === itemId,\n\t\t\t);\n\t\t\tif (!entry) continue;\n\n\t\t\tconst active: boolean = entry.item.isActive?.(state) ?? false;\n\t\t\tconst enabled: boolean = entry.item.isEnabled?.(state) ?? true;\n\t\t\tmenuItem.classList.toggle('notectl-dropdown__item--active', active);\n\t\t\tmenuItem.disabled = !enabled;\n\t\t}\n\t}\n\n\t/** Cleans up ResizeObserver, DOM elements, and event listeners. */\n\tdestroy(): void {\n\t\tthis.resizeObserver?.disconnect();\n\t\tthis.resizeObserver = null;\n\t\tthis.closeDropdown();\n\t\tthis.overflowButton?.remove();\n\t\tthis.overflowButton = null;\n\t\tthis.entries = [];\n\t\tthis.overflowEntries = [];\n\t}\n\n\t// --- Measurement ---\n\n\tprivate measureAvailableWidth(): number {\n\t\tconst toolbarStyle: CSSStyleDeclaration = getComputedStyle(this.toolbar);\n\t\tconst paddingLeft: number = Number.parseFloat(toolbarStyle.paddingLeft) || 0;\n\t\tconst paddingRight: number = Number.parseFloat(toolbarStyle.paddingRight) || 0;\n\t\treturn this.toolbar.clientWidth - paddingLeft - paddingRight;\n\t}\n\n\tprivate resetVisibility(): void {\n\t\tfor (const entry of this.entries) {\n\t\t\tentry.element.classList.remove(HIDDEN_BTN_CLASS);\n\t\t}\n\t\tconst separators: HTMLElement[] = Array.from(\n\t\t\tthis.toolbar.querySelectorAll('.notectl-toolbar-separator'),\n\t\t) as HTMLElement[];\n\t\tfor (const sep of separators) {\n\t\t\tsep.classList.remove(HIDDEN_SEP_CLASS);\n\t\t}\n\t}\n\n\t// --- Overflow Button ---\n\n\tprivate setOverflowButtonVisible(visible: boolean): void {\n\t\tif (!this.overflowButton) return;\n\t\tthis.overflowButton.classList.toggle(HIDDEN_OVERFLOW_CLASS, !visible);\n\t\tif (!visible) {\n\t\t\tthis.overflowButton.removeAttribute('tabindex');\n\t\t}\n\t}\n\n\tprivate ensureOverflowButton(): void {\n\t\tif (this.overflowButton) return;\n\n\t\tconst btn: HTMLButtonElement = document.createElement('button');\n\t\tbtn.type = 'button';\n\t\tbtn.className = 'notectl-toolbar-overflow-btn';\n\t\tbtn.setAttribute('aria-label', this.ariaLabel);\n\t\tbtn.setAttribute('aria-haspopup', 'true');\n\t\tbtn.setAttribute('aria-expanded', 'false');\n\t\tbtn.innerHTML = ELLIPSIS_SVG;\n\n\t\tbtn.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\tthis.toggleDropdown();\n\t\t});\n\n\t\tthis.toolbar.appendChild(btn);\n\t\tthis.overflowButton = btn;\n\t}\n\n\t// --- Dropdown ---\n\n\tprivate toggleDropdown(): void {\n\t\tif (this.overflowDropdown) {\n\t\t\tthis.closeDropdown();\n\t\t} else {\n\t\t\tthis.openDropdown();\n\t\t}\n\t}\n\n\tprivate openDropdown(): void {\n\t\tif (!this.overflowButton || this.overflowEntries.length === 0) return;\n\n\t\tconst dropdown: HTMLDivElement = document.createElement('div');\n\t\tdropdown.className = 'notectl-toolbar-popup notectl-dropdown';\n\t\tdropdown.setAttribute('role', 'menu');\n\n\t\tthis.renderDropdownItems(dropdown);\n\t\tthis.positionDropdown(dropdown);\n\t\tthis.appendToRoot(dropdown);\n\n\t\tthis.overflowDropdown = dropdown;\n\t\tthis.overflowButton.setAttribute('aria-expanded', 'true');\n\n\t\trequestAnimationFrame(() => {\n\t\t\tconst first: HTMLElement | null = dropdown.querySelector('[role=\"menuitem\"]');\n\t\t\tfirst?.focus();\n\t\t});\n\n\t\tdropdown.addEventListener('keydown', (e: KeyboardEvent) => this.handleDropdownKeydown(e));\n\t\tthis.registerCloseHandler();\n\t}\n\n\tprivate renderDropdownItems(dropdown: HTMLElement): void {\n\t\tlet lastGroup: string | null = null;\n\n\t\tfor (const entry of this.overflowEntries) {\n\t\t\tif (lastGroup !== null && entry.item.group !== lastGroup) {\n\t\t\t\tconst sep: HTMLDivElement = document.createElement('div');\n\t\t\t\tsep.className = 'notectl-dropdown__separator';\n\t\t\t\tsep.setAttribute('role', 'separator');\n\t\t\t\tdropdown.appendChild(sep);\n\t\t\t}\n\t\t\tlastGroup = entry.item.group;\n\n\t\t\tconst menuBtn: HTMLButtonElement = document.createElement('button');\n\t\t\tmenuBtn.type = 'button';\n\t\t\tmenuBtn.className = 'notectl-dropdown__item';\n\t\t\tmenuBtn.setAttribute('role', 'menuitem');\n\t\t\tmenuBtn.setAttribute('tabindex', '-1');\n\t\t\tmenuBtn.setAttribute('data-toolbar-item', entry.item.id);\n\n\t\t\tconst iconSpan: HTMLSpanElement = document.createElement('span');\n\t\t\ticonSpan.className = 'notectl-dropdown__item-icon';\n\t\t\ticonSpan.innerHTML = entry.item.icon;\n\t\t\tmenuBtn.appendChild(iconSpan);\n\n\t\t\tconst labelSpan: HTMLSpanElement = document.createElement('span');\n\t\t\tlabelSpan.className = 'notectl-dropdown__item-label';\n\t\t\tlabelSpan.textContent = entry.item.tooltip ?? entry.item.label;\n\t\t\tmenuBtn.appendChild(labelSpan);\n\n\t\t\tmenuBtn.addEventListener('mousedown', (ev: MouseEvent) => {\n\t\t\t\tev.preventDefault();\n\t\t\t\tev.stopPropagation();\n\t\t\t\tthis.activateOverflowItem(entry);\n\t\t\t});\n\n\t\t\tdropdown.appendChild(menuBtn);\n\t\t}\n\t}\n\n\tprivate positionDropdown(dropdown: HTMLElement): void {\n\t\tif (!this.overflowButton) return;\n\n\t\tconst rect: DOMRect = this.overflowButton.getBoundingClientRect();\n\t\tconst rightEdge: number = window.innerWidth - rect.right;\n\n\t\tdropdown.style.position = 'fixed';\n\t\tdropdown.style.top = `${rect.bottom + 2}px`;\n\t\tdropdown.style.right = `${rightEdge}px`;\n\t\tdropdown.style.left = 'auto';\n\t\tdropdown.style.zIndex = '10000';\n\t}\n\n\tprivate appendToRoot(element: HTMLElement): void {\n\t\tif (!this.overflowButton) return;\n\n\t\tconst root: Node = this.overflowButton.getRootNode();\n\t\tif (root instanceof ShadowRoot) {\n\t\t\troot.appendChild(element);\n\t\t} else {\n\t\t\tdocument.body.appendChild(element);\n\t\t}\n\t}\n\n\tprivate registerCloseHandler(): void {\n\t\tthis.closeHandler = (ev: MouseEvent) => {\n\t\t\tconst path: EventTarget[] = ev.composedPath();\n\t\t\tif (\n\t\t\t\tthis.overflowDropdown &&\n\t\t\t\t!path.includes(this.overflowDropdown) &&\n\t\t\t\tthis.overflowButton &&\n\t\t\t\t!path.includes(this.overflowButton)\n\t\t\t) {\n\t\t\t\tthis.closeDropdown();\n\t\t\t}\n\t\t};\n\t\tsetTimeout(() => {\n\t\t\tif (this.closeHandler) {\n\t\t\t\tdocument.addEventListener('mousedown', this.closeHandler);\n\t\t\t}\n\t\t}, 0);\n\t}\n\n\tprivate closeDropdown(): void {\n\t\tif (this.overflowDropdown) {\n\t\t\tthis.overflowDropdown.remove();\n\t\t\tthis.overflowDropdown = null;\n\t\t}\n\t\tif (this.overflowButton) {\n\t\t\tthis.overflowButton.setAttribute('aria-expanded', 'false');\n\t\t}\n\t\tif (this.closeHandler) {\n\t\t\tdocument.removeEventListener('mousedown', this.closeHandler);\n\t\t\tthis.closeHandler = null;\n\t\t}\n\t}\n\n\tprivate activateOverflowItem(entry: OverflowEntry): void {\n\t\tthis.closeDropdown();\n\t\tif (entry.item.popupType && this.overflowButton) {\n\t\t\tthis.onItemActivated(this.overflowButton, entry.item);\n\t\t} else {\n\t\t\tthis.context.executeCommand(entry.item.command);\n\t\t}\n\t}\n\n\t// --- Keyboard Navigation ---\n\n\tprivate handleDropdownKeydown(e: KeyboardEvent): void {\n\t\tif (!this.overflowDropdown) return;\n\n\t\tif (e.key === 'Escape' || e.key === 'Tab') {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tthis.closeDropdown();\n\t\t\tthis.overflowButton?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\tconst items: HTMLElement[] = Array.from(\n\t\t\tthis.overflowDropdown.querySelectorAll('[role=\"menuitem\"]'),\n\t\t) as HTMLElement[];\n\t\tconst current: number = items.indexOf(this.getActiveElement() as HTMLElement);\n\n\t\tswitch (e.key) {\n\t\t\tcase 'ArrowDown': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst next: number = findNextDropdownItem(items, current, 1);\n\t\t\t\titems[next]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowUp': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst prev: number = findNextDropdownItem(items, current, -1);\n\t\t\t\titems[prev]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'Enter':\n\t\t\tcase ' ': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst focusedItem: HTMLElement | undefined = items[current];\n\t\t\t\tif (!focusedItem) break;\n\t\t\t\tconst itemId: string | null = focusedItem.getAttribute('data-toolbar-item');\n\t\t\t\tconst entry: OverflowEntry | undefined = this.overflowEntries.find(\n\t\t\t\t\t(oe) => oe.item.id === itemId,\n\t\t\t\t);\n\t\t\t\tif (entry) this.activateOverflowItem(entry);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Helpers ---\n\n\tprivate hideTrailingSeparators(): void {\n\t\tconst children: HTMLElement[] = Array.from(this.toolbar.children) as HTMLElement[];\n\t\tfor (let i = children.length - 1; i >= 0; i--) {\n\t\t\tconst child: HTMLElement | undefined = children[i];\n\t\t\tif (!child || child === this.overflowButton) continue;\n\t\t\tif (child.classList.contains('notectl-toolbar-separator')) {\n\t\t\t\tif (!child.classList.contains(HIDDEN_SEP_CLASS)) {\n\t\t\t\t\tchild.classList.add(HIDDEN_SEP_CLASS);\n\t\t\t\t}\n\t\t\t} else if (!child.classList.contains(HIDDEN_BTN_CLASS)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate notifyChange(): void {\n\t\tconst visible: HTMLButtonElement[] = this.entries\n\t\t\t.filter((oe) => !oe.element.classList.contains(HIDDEN_BTN_CLASS))\n\t\t\t.map((oe) => oe.element);\n\t\tthis.onOverflowChange(visible, this.overflowEntries.length > 0 ? this.overflowButton : null);\n\t}\n}\n","/**\n * ToolbarRenderers: pure rendering functions for toolbar popup content.\n * Grid pickers, dropdown menus, and separator elements.\n */\n\nimport type { DropdownConfig, GridPickerConfig } from './ToolbarItem.js';\n\nconst HIGHLIGHTED_CLASS = 'notectl-grid-picker__cell--highlighted';\n\n/**\n * Renders a grid picker into the given container.\n * Calls `onClose` after a cell is selected so the popup can be dismissed.\n */\nexport function renderGridPicker(\n\tcontainer: HTMLElement,\n\tconfig: GridPickerConfig,\n\tonClose: () => void,\n): void {\n\tcontainer.className += ' notectl-grid-picker';\n\n\tconst grid: HTMLDivElement = document.createElement('div');\n\tgrid.className = 'notectl-grid-picker__grid';\n\tgrid.setAttribute('role', 'grid');\n\tgrid.style.display = 'grid';\n\tgrid.style.gridTemplateColumns = `repeat(${config.maxCols}, 1fr)`;\n\tgrid.style.gap = '2px';\n\tgrid.style.padding = '8px';\n\n\tconst label: HTMLDivElement = document.createElement('div');\n\tlabel.className = 'notectl-grid-picker__label';\n\tlabel.textContent = '1 x 1';\n\tlabel.style.textAlign = 'center';\n\tlabel.style.padding = '4px';\n\tlabel.style.fontSize = '12px';\n\tlabel.setAttribute('aria-live', 'polite');\n\n\tfor (let r = 1; r <= config.maxRows; r++) {\n\t\tfor (let c = 1; c <= config.maxCols; c++) {\n\t\t\tconst cell: HTMLDivElement = document.createElement('div');\n\t\t\tcell.className = 'notectl-grid-picker__cell';\n\t\t\tcell.setAttribute('role', 'gridcell');\n\t\t\tcell.setAttribute('tabindex', '-1');\n\t\t\tcell.setAttribute('aria-label', `${r} x ${c}`);\n\t\t\tcell.style.width = '20px';\n\t\t\tcell.style.height = '20px';\n\t\t\tcell.style.border = '1px solid #ccc';\n\t\t\tcell.style.cursor = 'pointer';\n\t\t\tcell.setAttribute('data-row', String(r));\n\t\t\tcell.setAttribute('data-col', String(c));\n\n\t\t\tcell.addEventListener('mouseenter', () => {\n\t\t\t\thighlightCells(grid, r, c);\n\t\t\t\tlabel.textContent = `${r} x ${c}`;\n\t\t\t});\n\n\t\t\tcell.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\tconfig.onSelect(r, c);\n\t\t\t\tonClose();\n\t\t\t});\n\n\t\t\tcell.addEventListener('click', () => {\n\t\t\t\tconfig.onSelect(r, c);\n\t\t\t\tonClose();\n\t\t\t});\n\n\t\t\tgrid.appendChild(cell);\n\t\t}\n\t}\n\n\tcontainer.appendChild(grid);\n\tcontainer.appendChild(label);\n}\n\n/**\n * Highlights grid cells up to the given row/col and updates the label.\n * Used by both mouse hover and keyboard navigation.\n */\nexport function highlightCells(grid: HTMLElement, targetRow: number, targetCol: number): void {\n\tconst cells: NodeListOf<Element> = grid.querySelectorAll('.notectl-grid-picker__cell');\n\tfor (const cell of cells) {\n\t\tconst r: number = Number(cell.getAttribute('data-row'));\n\t\tconst c: number = Number(cell.getAttribute('data-col'));\n\t\tcell.classList.toggle(HIGHLIGHTED_CLASS, r <= targetRow && c <= targetCol);\n\t}\n}\n\n/**\n * Renders a dropdown menu into the given container.\n * Calls `onClose` after an item is activated so the popup can be dismissed.\n */\nexport function renderDropdown(\n\tcontainer: HTMLElement,\n\tconfig: DropdownConfig,\n\texecuteCommand: (command: string) => void,\n\tonClose: () => void,\n): void {\n\tcontainer.classList.add('notectl-dropdown');\n\tcontainer.setAttribute('role', 'menu');\n\n\tfor (const item of config.items) {\n\t\tconst btn: HTMLButtonElement = document.createElement('button');\n\t\tbtn.type = 'button';\n\t\tbtn.className = 'notectl-dropdown__item';\n\t\tbtn.setAttribute('role', 'menuitem');\n\t\tbtn.setAttribute('tabindex', '-1');\n\n\t\tif (item.icon) {\n\t\t\tconst iconSpan: HTMLSpanElement = document.createElement('span');\n\t\t\ticonSpan.className = 'notectl-dropdown__item-icon';\n\t\t\ticonSpan.innerHTML = item.icon;\n\t\t\tbtn.appendChild(iconSpan);\n\t\t}\n\n\t\tconst labelSpan: HTMLSpanElement = document.createElement('span');\n\t\tlabelSpan.className = 'notectl-dropdown__item-label';\n\t\tlabelSpan.textContent = item.label;\n\t\tbtn.appendChild(labelSpan);\n\n\t\tbtn.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\texecuteCommand(item.command);\n\t\t\tonClose();\n\t\t});\n\n\t\tbtn.addEventListener('click', () => {\n\t\t\texecuteCommand(item.command);\n\t\t\tonClose();\n\t\t});\n\n\t\tcontainer.appendChild(btn);\n\t}\n}\n\n/** Creates a toolbar group separator element. */\nexport function createSeparator(): HTMLSpanElement {\n\tconst sep: HTMLSpanElement = document.createElement('span');\n\tsep.className = 'notectl-toolbar-separator';\n\tsep.setAttribute('role', 'separator');\n\treturn sep;\n}\n","/**\n * ToolbarPopupController: manages popup lifecycle, positioning, keyboard\n * navigation, and auto-close for toolbar popups (grid pickers, dropdowns,\n * and custom popups).\n */\n\nimport type { PluginContext } from '../Plugin.js';\nimport type { ToolbarItem } from './ToolbarItem.js';\nimport { findNextDropdownItem, navigateGrid } from './ToolbarKeyboardNav.js';\nimport { highlightCells, renderDropdown, renderGridPicker } from './ToolbarRenderers.js';\n\nexport class ToolbarPopupController {\n\tprivate activePopup: HTMLElement | null = null;\n\tprivate activePopupButton: HTMLButtonElement | null = null;\n\tprivate closePopupHandler: ((e: MouseEvent) => void) | null = null;\n\tprivate readonly getActiveElement: () => Element | null;\n\n\tconstructor(getActiveElement: () => Element | null) {\n\t\tthis.getActiveElement = getActiveElement;\n\t}\n\n\t/** Whether a popup is currently open. */\n\tisOpen(): boolean {\n\t\treturn this.activePopup !== null;\n\t}\n\n\t/** Toggles a popup for the given toolbar button. */\n\ttoggle(button: HTMLButtonElement, item: ToolbarItem, context: PluginContext): void {\n\t\tif (this.activePopup) {\n\t\t\tthis.close();\n\t\t\treturn;\n\t\t}\n\n\t\tconst popup: HTMLDivElement = document.createElement('div');\n\t\tpopup.className = 'notectl-toolbar-popup';\n\n\t\tswitch (item.popupType) {\n\t\t\tcase 'gridPicker':\n\t\t\t\trenderGridPicker(popup, item.popupConfig, () => this.close());\n\t\t\t\tbreak;\n\t\t\tcase 'dropdown':\n\t\t\t\trenderDropdown(\n\t\t\t\t\tpopup,\n\t\t\t\t\titem.popupConfig,\n\t\t\t\t\t(cmd: string) => context.executeCommand(cmd),\n\t\t\t\t\t() => this.close(),\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase 'custom':\n\t\t\t\titem.renderPopup(popup, context, () => this.close());\n\t\t\t\tbreak;\n\t\t}\n\n\t\tthis.positionAndAppend(popup, button);\n\n\t\tthis.activePopup = popup;\n\t\tthis.activePopupButton = button;\n\t\tbutton.classList.add('notectl-toolbar-btn--popup-open');\n\t\tbutton.setAttribute('aria-expanded', 'true');\n\n\t\tthis.focusFirstItem(popup);\n\n\t\tpopup.addEventListener('keydown', (e: KeyboardEvent) => this.handlePopupKeydown(e));\n\n\t\tthis.closePopupHandler = (e: MouseEvent) => {\n\t\t\tconst path: EventTarget[] = e.composedPath();\n\t\t\tif (!path.includes(popup) && !path.includes(button)) {\n\t\t\t\tthis.close();\n\t\t\t}\n\t\t};\n\t\tsetTimeout(() => {\n\t\t\tif (this.closePopupHandler) {\n\t\t\t\tdocument.addEventListener('mousedown', this.closePopupHandler);\n\t\t\t}\n\t\t}, 0);\n\t}\n\n\t/** Closes the active popup and cleans up event listeners. */\n\tclose(): void {\n\t\tif (this.activePopupButton) {\n\t\t\tthis.activePopupButton.classList.remove('notectl-toolbar-btn--popup-open');\n\t\t\tthis.activePopupButton.setAttribute('aria-expanded', 'false');\n\t\t\tthis.activePopupButton = null;\n\t\t}\n\t\tif (this.activePopup) {\n\t\t\tthis.activePopup.remove();\n\t\t\tthis.activePopup = null;\n\t\t}\n\t\tif (this.closePopupHandler) {\n\t\t\tdocument.removeEventListener('mousedown', this.closePopupHandler);\n\t\t\tthis.closePopupHandler = null;\n\t\t}\n\t}\n\n\t/** Closes popup and restores focus to the trigger button. */\n\tcloseAndRestoreFocus(): void {\n\t\tconst triggerBtn: HTMLButtonElement | null = this.activePopupButton;\n\t\tthis.close();\n\t\ttriggerBtn?.focus();\n\t}\n\n\tdestroy(): void {\n\t\tthis.close();\n\t}\n\n\t// --- Positioning ---\n\n\tprivate positionAndAppend(popup: HTMLElement, button: HTMLButtonElement): void {\n\t\tconst rect: DOMRect = button.getBoundingClientRect();\n\t\tpopup.style.position = 'fixed';\n\t\tpopup.style.top = `${rect.bottom + 2}px`;\n\t\tpopup.style.left = `${rect.left}px`;\n\t\tpopup.style.zIndex = '10000';\n\n\t\tconst root: Node = button.getRootNode();\n\t\tif (root instanceof ShadowRoot) {\n\t\t\troot.appendChild(popup);\n\t\t} else {\n\t\t\tdocument.body.appendChild(popup);\n\t\t}\n\t}\n\n\t// --- Focus ---\n\n\tprivate focusFirstItem(popup: HTMLElement): void {\n\t\trequestAnimationFrame(() => {\n\t\t\tconst firstItem: HTMLElement | null =\n\t\t\t\tpopup.querySelector('[role=\"menuitem\"]') ??\n\t\t\t\tpopup.querySelector('.notectl-grid-picker__cell') ??\n\t\t\t\tpopup.querySelector('button');\n\t\t\tfirstItem?.focus();\n\t\t});\n\t}\n\n\t// --- Keyboard Navigation ---\n\n\tprivate handlePopupKeydown(e: KeyboardEvent): void {\n\t\tif (!this.activePopup) return;\n\n\t\tif (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\tthis.closeAndRestoreFocus();\n\t\t\treturn;\n\t\t}\n\n\t\tif (e.key === 'Tab') {\n\t\t\te.preventDefault();\n\t\t\tthis.closeAndRestoreFocus();\n\t\t\treturn;\n\t\t}\n\n\t\tconst menuItems: NodeListOf<Element> = this.activePopup.querySelectorAll('[role=\"menuitem\"]');\n\t\tif (menuItems.length > 0) {\n\t\t\tthis.handleDropdownKeydown(e, menuItems);\n\t\t\treturn;\n\t\t}\n\n\t\tconst hasGrid: boolean = this.activePopup.querySelector('.notectl-grid-picker__cell') !== null;\n\t\tif (hasGrid) {\n\t\t\tthis.handleGridKeydown(e);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.handleCustomPopupKeydown(e);\n\t}\n\n\tprivate handleDropdownKeydown(e: KeyboardEvent, items: NodeListOf<Element>): void {\n\t\tconst itemArr: HTMLElement[] = Array.from(items) as HTMLElement[];\n\t\tconst current: number = itemArr.indexOf(this.getActiveElement() as HTMLElement);\n\n\t\tswitch (e.key) {\n\t\t\tcase 'ArrowDown': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst next: number = findNextDropdownItem(itemArr, current, 1);\n\t\t\t\titemArr[next]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowUp': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst prev: number = findNextDropdownItem(itemArr, current, -1);\n\t\t\t\titemArr[prev]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'Enter':\n\t\t\tcase ' ': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst focused: HTMLElement | undefined = itemArr[current];\n\t\t\t\tif (focused) focused.click();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleGridKeydown(e: KeyboardEvent): void {\n\t\tconst focused: HTMLElement = this.getActiveElement() as HTMLElement;\n\t\tconst row: number = Number(focused?.getAttribute('data-row') ?? 1);\n\t\tconst col: number = Number(focused?.getAttribute('data-col') ?? 1);\n\n\t\tconst grid: Element | null =\n\t\t\tthis.activePopup?.querySelector('.notectl-grid-picker__grid') ?? null;\n\t\tif (!grid) return;\n\n\t\tconst lastCell: Element | null = grid.querySelector('.notectl-grid-picker__cell:last-child');\n\t\tconst maxCols: number = Number(lastCell?.getAttribute('data-col') ?? 1);\n\t\tconst maxRows: number = Number(lastCell?.getAttribute('data-row') ?? 1);\n\n\t\tif (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {\n\t\t\te.preventDefault();\n\t\t\tconst [newRow, newCol]: [number, number] = navigateGrid(\n\t\t\t\trow,\n\t\t\t\tcol,\n\t\t\t\tmaxRows,\n\t\t\t\tmaxCols,\n\t\t\t\te.key as 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight',\n\t\t\t);\n\t\t\tconst target: HTMLElement | null = grid.querySelector(\n\t\t\t\t`.notectl-grid-picker__cell[data-row=\"${newRow}\"][data-col=\"${newCol}\"]`,\n\t\t\t);\n\t\t\ttarget?.focus();\n\n\t\t\thighlightCells(grid as HTMLElement, newRow, newCol);\n\t\t\tconst label: Element | null =\n\t\t\t\tthis.activePopup?.querySelector('.notectl-grid-picker__label') ?? null;\n\t\t\tif (label) label.textContent = `${newRow} x ${newCol}`;\n\t\t}\n\n\t\tif (e.key === 'Enter' || e.key === ' ') {\n\t\t\te.preventDefault();\n\t\t\tfocused?.click();\n\t\t}\n\t}\n\n\tprivate handleCustomPopupKeydown(e: KeyboardEvent): void {\n\t\tif (!this.activePopup) return;\n\t\tconst buttons: HTMLButtonElement[] = Array.from(this.activePopup.querySelectorAll('button'));\n\t\tif (buttons.length === 0) return;\n\t\tconst active: HTMLElement = this.getActiveElement() as HTMLElement;\n\t\tconst currentIdx: number = buttons.indexOf(active as HTMLButtonElement);\n\n\t\tswitch (e.key) {\n\t\t\tcase 'ArrowDown': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst next: number = findNextDropdownItem(buttons, currentIdx, 1);\n\t\t\t\tbuttons[next]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowUp': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst prev: number = findNextDropdownItem(buttons, currentIdx, -1);\n\t\t\t\tbuttons[prev]?.focus();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'Enter':\n\t\t\tcase ' ': {\n\t\t\t\te.preventDefault();\n\t\t\t\tif (active) {\n\t\t\t\t\tactive.dispatchEvent(new MouseEvent('mousedown', { bubbles: true, cancelable: true }));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * ToolbarTooltip: manages the tooltip lifecycle for toolbar buttons.\n * Shows a tooltip after a short delay when hovering or focusing a button,\n * hides it when the cursor leaves or focus moves away.\n */\n\nconst TOOLTIP_DELAY_MS = 500;\n\nexport class ToolbarTooltip {\n\tprivate readonly element: HTMLElement;\n\tprivate timer: ReturnType<typeof setTimeout> | null = null;\n\tprivate target: HTMLButtonElement | null = null;\n\tprivate readonly isPopupActive: () => boolean;\n\n\tstatic readonly TOOLTIP_ID = 'notectl-toolbar-tooltip';\n\n\tconstructor(isPopupActive: () => boolean) {\n\t\tthis.isPopupActive = isPopupActive;\n\t\tthis.element = document.createElement('div');\n\t\tthis.element.className = 'notectl-toolbar-tooltip';\n\t\tthis.element.id = ToolbarTooltip.TOOLTIP_ID;\n\t\tthis.element.setAttribute('role', 'tooltip');\n\t\tthis.element.style.display = 'none';\n\t}\n\n\tshow(button: HTMLButtonElement): void {\n\t\tthis.hide();\n\n\t\tif (this.isPopupActive() || button.disabled) return;\n\n\t\tconst text: string | null = button.getAttribute('data-tooltip');\n\t\tif (!text) return;\n\n\t\tthis.target = button;\n\n\t\tthis.timer = setTimeout(() => {\n\t\t\tif (this.isPopupActive()) return;\n\n\t\t\tthis.element.textContent = text;\n\t\t\tthis.element.style.display = '';\n\n\t\t\tconst root: Node = button.getRootNode();\n\t\t\tif (root instanceof ShadowRoot && !this.element.parentNode) {\n\t\t\t\troot.appendChild(this.element);\n\t\t\t} else if (!(root instanceof ShadowRoot) && !this.element.parentNode) {\n\t\t\t\tdocument.body.appendChild(this.element);\n\t\t\t}\n\n\t\t\tbutton.setAttribute('aria-describedby', ToolbarTooltip.TOOLTIP_ID);\n\n\t\t\tconst rect: DOMRect = button.getBoundingClientRect();\n\t\t\tthis.element.style.position = 'fixed';\n\t\t\tthis.element.style.top = `${rect.bottom + 6}px`;\n\t\t\tthis.element.style.left = `${rect.left + rect.width / 2}px`;\n\t\t\tthis.element.style.transform = 'translateX(-50%)';\n\t\t}, TOOLTIP_DELAY_MS);\n\t}\n\n\thide(): void {\n\t\tif (this.timer) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = null;\n\t\t}\n\t\tif (this.target) {\n\t\t\tthis.target.removeAttribute('aria-describedby');\n\t\t\tthis.target = null;\n\t\t}\n\t\tthis.element.style.display = 'none';\n\t}\n\n\tdestroy(): void {\n\t\tthis.hide();\n\t\tthis.element.remove();\n\t}\n}\n","/**\n * Toolbar plugin: renders toolbar items registered by other plugins.\n * Acts as a pure rendering engine — has no knowledge of specific features.\n * Supports buttons, dropdowns, grid pickers, and custom popups.\n * Implements WAI-ARIA Toolbar pattern with roving tabindex.\n */\n\nimport { TOOLBAR_CSS } from '../../editor/styles/toolbar.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport { ServiceKey } from '../Plugin.js';\nimport type { Plugin, PluginConfig, PluginContext } from '../Plugin.js';\nimport type { ToolbarItem } from './ToolbarItem.js';\nimport {\n\tapplyRovingTabindex,\n\tfindFirstEnabled,\n\tfindLastEnabled,\n\tfindNextEnabled,\n} from './ToolbarKeyboardNav.js';\nimport { TOOLBAR_LOCALES, type ToolbarLocale } from './ToolbarLocale.js';\nimport {\n\tToolbarOverflowBehavior,\n\ttype ToolbarOverflowBehavior as ToolbarOverflowBehaviorType,\n} from './ToolbarOverflowBehavior.js';\nimport { ToolbarOverflowController } from './ToolbarOverflowController.js';\nimport { ToolbarPopupController } from './ToolbarPopupController.js';\nimport { createSeparator } from './ToolbarRenderers.js';\nimport { ToolbarTooltip } from './ToolbarTooltip.js';\n\n// --- Layout Config ---\n\nexport interface ToolbarLayoutConfig {\n\treadonly groups: ReadonlyArray<ReadonlyArray<string>>;\n\t/**\n\t * Controls responsive overflow behavior when toolbar items exceed available width.\n\t * Defaults to `ToolbarOverflowBehavior.BurgerMenu`.\n\t */\n\treadonly overflow?: ToolbarOverflowBehaviorType;\n}\n\n// --- Typed Service API ---\n\nexport interface ToolbarServiceAPI {\n\t/** Re-reads isActive/isEnabled from state and updates all buttons. */\n\trefresh(): void;\n\t/** Closes the currently open popup, if any. */\n\tclosePopup(): void;\n}\n\nexport const ToolbarServiceKey = new ServiceKey<ToolbarServiceAPI>('toolbar');\n\n// --- Plugin ---\n\ninterface ToolbarButton {\n\telement: HTMLButtonElement;\n\titem: ToolbarItem;\n}\n\nexport class ToolbarPlugin implements Plugin {\n\treadonly id = 'toolbar';\n\treadonly name = 'Toolbar';\n\treadonly priority = 10;\n\n\tprivate context: PluginContext | null = null;\n\tprivate toolbarElement: HTMLElement | null = null;\n\tprivate buttons: ToolbarButton[] = [];\n\tprivate readonly hiddenItems = new Set<string>();\n\tprivate readonly layoutConfig: ToolbarLayoutConfig | null;\n\tprivate overflowBehavior: ToolbarOverflowBehaviorType;\n\tprivate focusedIndex = 0;\n\tprivate tooltip: ToolbarTooltip | null = null;\n\tprivate popupController: ToolbarPopupController | null = null;\n\tprivate overflowController: ToolbarOverflowController | null = null;\n\tprivate visibleElements: HTMLButtonElement[] = [];\n\tprivate locale!: ToolbarLocale;\n\n\tconstructor(layoutConfig?: ToolbarLayoutConfig) {\n\t\tthis.layoutConfig = layoutConfig ?? null;\n\t\tthis.overflowBehavior = layoutConfig?.overflow ?? ToolbarOverflowBehavior.BurgerMenu;\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(TOOLBAR_LOCALES, context);\n\t\tcontext.registerStyleSheet(TOOLBAR_CSS);\n\t\tthis.context = context;\n\n\t\tthis.popupController = new ToolbarPopupController(() => this.getActiveElement());\n\t\tthis.tooltip = new ToolbarTooltip(() => this.popupController?.isOpen() ?? false);\n\n\t\tcontext.registerService(ToolbarServiceKey, {\n\t\t\trefresh: () => this.updateButtonStates(context.getState()),\n\t\t\tclosePopup: () => this.popupController?.close(),\n\t\t});\n\n\t\tthis.createToolbarElement();\n\t}\n\n\t/** Returns the current overflow behavior. */\n\tgetOverflowBehavior(): ToolbarOverflowBehaviorType {\n\t\treturn this.overflowBehavior;\n\t}\n\n\t/** Switches the overflow behavior at runtime. */\n\tsetOverflowBehavior(behavior: ToolbarOverflowBehaviorType): void {\n\t\tif (behavior === this.overflowBehavior) return;\n\n\t\tthis.overflowBehavior = behavior;\n\t\tthis.applyOverflowBehavior();\n\t\tthis.renderItems();\n\t}\n\n\tonReady(): void {\n\t\tthis.renderItems();\n\t}\n\n\tdestroy(): void {\n\t\tthis.overflowController?.destroy();\n\t\tthis.overflowController = null;\n\t\tthis.popupController?.destroy();\n\t\tthis.popupController = null;\n\t\tthis.tooltip?.destroy();\n\t\tthis.tooltip = null;\n\t\tif (this.toolbarElement) {\n\t\t\tthis.toolbarElement.remove();\n\t\t\tthis.toolbarElement = null;\n\t\t}\n\t\tthis.buttons = [];\n\t\tthis.visibleElements = [];\n\t\tthis.context = null;\n\t}\n\n\tonStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void {\n\t\tthis.updateButtonStates(newState);\n\t}\n\n\tonReadOnlyChange(readonly: boolean): void {\n\t\tif (this.toolbarElement) {\n\t\t\tthis.toolbarElement.hidden = readonly;\n\t\t}\n\t}\n\n\tonConfigure(config: PluginConfig): void {\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tif (value === false) {\n\t\t\t\tthis.hiddenItems.add(key);\n\t\t\t} else {\n\t\t\t\tthis.hiddenItems.delete(key);\n\t\t\t}\n\t\t}\n\t\tthis.renderItems();\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate createToolbarElement(): void {\n\t\tif (!this.context) return;\n\n\t\tif (this.toolbarElement) {\n\t\t\tthis.toolbarElement.remove();\n\t\t}\n\t\tthis.buttons = [];\n\n\t\tconst container: HTMLElement = this.context.getPluginContainer('top');\n\t\tthis.toolbarElement = document.createElement('div');\n\t\tthis.toolbarElement.setAttribute('role', 'toolbar');\n\t\tthis.toolbarElement.setAttribute('aria-label', this.locale.formattingOptionsAria);\n\t\tthis.toolbarElement.setAttribute('data-notectl-no-print', '');\n\t\tthis.toolbarElement.className = 'notectl-toolbar';\n\n\t\tthis.toolbarElement.addEventListener('keydown', (e) => this.handleToolbarKeydown(e));\n\n\t\tthis.applyOverflowBehavior();\n\t\tcontainer.appendChild(this.toolbarElement);\n\t}\n\n\t/** Applies the current overflow behavior: creates/destroys the overflow controller and sets the data attribute. */\n\tprivate applyOverflowBehavior(): void {\n\t\tif (!this.toolbarElement || !this.context) return;\n\n\t\t// Tear down existing overflow controller\n\t\tthis.overflowController?.destroy();\n\t\tthis.overflowController = null;\n\n\t\tthis.toolbarElement.setAttribute('data-overflow', this.overflowBehavior);\n\n\t\tif (this.overflowBehavior === ToolbarOverflowBehavior.BurgerMenu) {\n\t\t\tthis.overflowController = new ToolbarOverflowController({\n\t\t\t\ttoolbar: this.toolbarElement,\n\t\t\t\tariaLabel: this.locale.moreToolsAria,\n\t\t\t\tcontext: this.context,\n\t\t\t\tonOverflowChange: (visibleButtons, overflowBtn) => {\n\t\t\t\t\tthis.visibleElements = overflowBtn\n\t\t\t\t\t\t? [...visibleButtons, overflowBtn]\n\t\t\t\t\t\t: [...visibleButtons];\n\t\t\t\t\tthis.initRovingTabindex();\n\t\t\t\t},\n\t\t\t\tonItemActivated: (btn: HTMLButtonElement, item: ToolbarItem) => {\n\t\t\t\t\tthis.activateButton(btn, item);\n\t\t\t\t},\n\t\t\t\tgetActiveElement: () => this.getActiveElement(),\n\t\t\t});\n\t\t} else {\n\t\t\t// Flow and None modes: all buttons are visible for roving tabindex\n\t\t\tthis.visibleElements = [];\n\t\t}\n\t}\n\n\tprivate renderItems(): void {\n\t\tif (!this.context || !this.toolbarElement) return;\n\n\t\tfor (const btn of this.buttons) {\n\t\t\tbtn.element.remove();\n\t\t}\n\t\tthis.buttons = [];\n\n\t\tfor (const sep of this.toolbarElement.querySelectorAll('.notectl-toolbar-separator')) {\n\t\t\tsep.remove();\n\t\t}\n\n\t\tif (this.layoutConfig) {\n\t\t\tthis.renderItemsByLayout();\n\t\t} else {\n\t\t\tthis.renderItemsByPriority();\n\t\t}\n\n\t\tif (this.buttons.length > 0 && !this.toolbarElement.parentElement) {\n\t\t\tconst container: HTMLElement = this.context.getPluginContainer('top');\n\t\t\tcontainer.appendChild(this.toolbarElement);\n\t\t}\n\n\t\tthis.overflowController?.update(this.buttons);\n\t\tthis.initRovingTabindex();\n\t\tthis.updateButtonStates(this.context.getState());\n\t}\n\n\t// --- Roving Tabindex ---\n\n\tprivate getTabElements(): HTMLButtonElement[] {\n\t\treturn this.visibleElements.length > 0\n\t\t\t? this.visibleElements\n\t\t\t: this.buttons.map((b) => b.element);\n\t}\n\n\tprivate initRovingTabindex(): void {\n\t\tconst elements: HTMLButtonElement[] = this.getTabElements();\n\t\tconst first: number = findFirstEnabled(elements);\n\t\tthis.focusedIndex = first >= 0 ? first : 0;\n\t\tapplyRovingTabindex(elements, this.focusedIndex);\n\t}\n\n\tprivate setRovingFocus(index: number): void {\n\t\tconst elements: HTMLButtonElement[] = this.getTabElements();\n\t\tif (index < 0 || index >= elements.length) return;\n\t\tthis.focusedIndex = index;\n\t\tapplyRovingTabindex(elements, index);\n\t\telements[index]?.focus();\n\t}\n\n\t/** Returns the active element, respecting shadow DOM boundaries. */\n\tprivate getActiveElement(): Element | null {\n\t\tconst root: Node | undefined = this.toolbarElement?.getRootNode();\n\t\tif (root instanceof ShadowRoot) {\n\t\t\treturn root.activeElement;\n\t\t}\n\t\treturn document.activeElement;\n\t}\n\n\tprivate syncFocusedIndex(): void {\n\t\tconst active: Element | null = this.getActiveElement();\n\t\tconst elements: HTMLButtonElement[] = this.getTabElements();\n\t\tconst idx: number = elements.findIndex((el) => el === active);\n\t\tif (idx >= 0) {\n\t\t\tthis.focusedIndex = idx;\n\t\t}\n\t}\n\n\t// --- Toolbar Keyboard ---\n\n\tprivate handleToolbarKeydown(e: KeyboardEvent): void {\n\t\tconst elements: HTMLButtonElement[] = this.getTabElements();\n\t\tif (elements.length === 0) return;\n\n\t\tthis.syncFocusedIndex();\n\n\t\tswitch (e.key) {\n\t\t\tcase 'ArrowRight': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst next: number = findNextEnabled(elements, this.focusedIndex, 1);\n\t\t\t\tthis.setRovingFocus(next);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowLeft': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst prev: number = findNextEnabled(elements, this.focusedIndex, -1);\n\t\t\t\tthis.setRovingFocus(prev);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'Home': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst first: number = findFirstEnabled(elements);\n\t\t\t\tif (first >= 0) this.setRovingFocus(first);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'End': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst last: number = findLastEnabled(elements);\n\t\t\t\tif (last >= 0) this.setRovingFocus(last);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'Enter':\n\t\t\tcase ' ': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst focused: HTMLButtonElement | undefined = elements[this.focusedIndex];\n\t\t\t\tconst btn: ToolbarButton | undefined = this.buttons.find((b) => b.element === focused);\n\t\t\t\tif (btn) this.activateButton(btn.element, btn.item);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Activates a toolbar button (shared between mouse click and keyboard). */\n\tprivate activateButton(btn: HTMLButtonElement, item: ToolbarItem): void {\n\t\tthis.tooltip?.hide();\n\t\tif (item.popupType && this.context) {\n\t\t\tthis.popupController?.toggle(btn, item, this.context);\n\t\t} else {\n\t\t\tthis.context?.executeCommand(item.command);\n\t\t}\n\t}\n\n\t// --- Layout Rendering ---\n\n\tprivate renderItemsByLayout(): void {\n\t\tif (!this.context || !this.toolbarElement || !this.layoutConfig) return;\n\n\t\tconst toolbarReg = this.context.getToolbarRegistry();\n\t\tlet firstGroup = true;\n\n\t\tfor (const groupPluginIds of this.layoutConfig.groups) {\n\t\t\tconst groupItems: ToolbarItem[] = [];\n\t\t\tfor (const pId of groupPluginIds) {\n\t\t\t\tconst items: ToolbarItem[] = toolbarReg\n\t\t\t\t\t.getToolbarItemsByPlugin(pId)\n\t\t\t\t\t.filter((item) => !this.hiddenItems.has(item.id));\n\t\t\t\titems.sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));\n\t\t\t\tgroupItems.push(...items);\n\t\t\t}\n\n\t\t\tif (groupItems.length === 0) continue;\n\n\t\t\tif (!firstGroup) {\n\t\t\t\tthis.toolbarElement.appendChild(createSeparator());\n\t\t\t}\n\t\t\tfirstGroup = false;\n\n\t\t\tfor (const item of groupItems) {\n\t\t\t\tconst btn: ToolbarButton = this.createButton(item);\n\t\t\t\tthis.toolbarElement.appendChild(btn.element);\n\t\t\t\tthis.buttons.push(btn);\n\t\t\t}\n\t\t}\n\n\t\tif (this.buttons.length === 0) {\n\t\t\tthis.toolbarElement.remove();\n\t\t}\n\t}\n\n\tprivate renderItemsByPriority(): void {\n\t\tif (!this.context || !this.toolbarElement) return;\n\n\t\tconst toolbarRegistry = this.context.getToolbarRegistry();\n\t\tconst items: ToolbarItem[] = toolbarRegistry\n\t\t\t.getToolbarItems()\n\t\t\t.filter((item) => !this.hiddenItems.has(item.id));\n\t\tif (items.length === 0) {\n\t\t\tthis.toolbarElement.remove();\n\t\t\treturn;\n\t\t}\n\n\t\tconst sorted: ToolbarItem[] = [...items].sort(\n\t\t\t(a, b) => (a.priority ?? 100) - (b.priority ?? 100),\n\t\t);\n\n\t\tconst hasSeparatorAfter: boolean = sorted.some((item) => item.separatorAfter);\n\n\t\tif (hasSeparatorAfter) {\n\t\t\tfor (let i = 0; i < sorted.length; i++) {\n\t\t\t\tconst item: ToolbarItem | undefined = sorted[i];\n\t\t\t\tif (!item) continue;\n\t\t\t\tconst btn: ToolbarButton = this.createButton(item);\n\t\t\t\tthis.toolbarElement.appendChild(btn.element);\n\t\t\t\tthis.buttons.push(btn);\n\n\t\t\t\tif (item.separatorAfter && i < sorted.length - 1) {\n\t\t\t\t\tthis.toolbarElement.appendChild(createSeparator());\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst groups = new Map<string, ToolbarItem[]>();\n\t\t\tfor (const item of sorted) {\n\t\t\t\tconst list: ToolbarItem[] = groups.get(item.group) ?? [];\n\t\t\t\tlist.push(item);\n\t\t\t\tgroups.set(item.group, list);\n\t\t\t}\n\n\t\t\tlet firstGroup = true;\n\t\t\tfor (const [, groupItems] of groups) {\n\t\t\t\tif (!firstGroup) {\n\t\t\t\t\tthis.toolbarElement.appendChild(createSeparator());\n\t\t\t\t}\n\t\t\t\tfirstGroup = false;\n\n\t\t\t\tfor (const item of groupItems) {\n\t\t\t\t\tconst btn: ToolbarButton = this.createButton(item);\n\t\t\t\t\tthis.toolbarElement.appendChild(btn.element);\n\t\t\t\t\tthis.buttons.push(btn);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Button Creation ---\n\n\tprivate createButton(item: ToolbarItem): ToolbarButton {\n\t\tconst btn: HTMLButtonElement = document.createElement('button');\n\t\tbtn.type = 'button';\n\t\tbtn.className = `notectl-toolbar-btn notectl-toolbar-btn--${item.id}`;\n\t\tbtn.setAttribute('aria-pressed', 'false');\n\t\tbtn.setAttribute('aria-label', item.label);\n\t\tbtn.setAttribute('data-toolbar-item', item.id);\n\t\tbtn.setAttribute('data-tooltip', item.tooltip ?? item.label);\n\n\t\tif (item.popupType) {\n\t\t\tbtn.setAttribute('aria-haspopup', 'true');\n\t\t\tbtn.setAttribute('aria-expanded', 'false');\n\t\t}\n\n\t\tconst span: HTMLSpanElement = document.createElement('span');\n\t\tspan.className = 'notectl-toolbar-btn__icon';\n\t\tspan.innerHTML = item.icon;\n\t\tbtn.appendChild(span);\n\n\t\tbtn.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\te.preventDefault();\n\t\t\tthis.activateButton(btn, item);\n\t\t});\n\n\t\tbtn.addEventListener('mouseenter', () => this.tooltip?.show(btn));\n\t\tbtn.addEventListener('mouseleave', () => this.tooltip?.hide());\n\t\tbtn.addEventListener('focus', () => this.tooltip?.show(btn));\n\t\tbtn.addEventListener('blur', () => this.tooltip?.hide());\n\n\t\treturn { element: btn, item };\n\t}\n\n\t// --- Button State Updates ---\n\n\tprivate updateButtonStates(state: EditorState): void {\n\t\tfor (const btn of this.buttons) {\n\t\t\tconst active: boolean = btn.item.isActive?.(state) ?? false;\n\t\t\tconst enabled: boolean = btn.item.isEnabled?.(state) ?? true;\n\t\t\tbtn.element.setAttribute('aria-pressed', String(active));\n\t\t\tbtn.element.classList.toggle('notectl-toolbar-btn--active', active);\n\t\t\tbtn.element.disabled = !enabled;\n\t\t\tif (!enabled) {\n\t\t\t\tbtn.element.setAttribute('aria-disabled', 'true');\n\t\t\t} else {\n\t\t\t\tbtn.element.removeAttribute('aria-disabled');\n\t\t\t}\n\t\t}\n\t\tthis.overflowController?.updateItemStates(state);\n\t}\n}\n"],"names":["TOOLBAR_LOCALE_EN","formattingOptionsAria","moreToolsAria","TOOLBAR_LOCALES","en","de","es","fr","zh","ru","ar","hi","ToolbarOverflowBehavior","BurgerMenu","Flow","None","HIDDEN_BTN_CLASS","HIDDEN_SEP_CLASS","ToolbarOverflowController","toolbar","context","onOverflowChange","onItemActivated","getActiveElement","ariaLabel","entries","overflowButton","overflowDropdown","overflowEntries","resizeObserver","closeHandler","config","this","ResizeObserver","recalculate","observe","buttons","map","b","element","item","length","closeDropdown","resetVisibility","ensureOverflowButton","setOverflowButtonVisible","maxWidth","measureAvailableWidth","usedWidth","overflowing","overflowList","children","Array","from","child","classList","contains","add","sepWidth","offsetWidth","entry","find","oe","push","btnWidth","hideTrailingSeparators","notifyChange","state","menuItems","querySelectorAll","menuItem","itemId","getAttribute","id","active","isActive","enabled","isEnabled","toggle","disabled","destroy","disconnect","remove","toolbarStyle","getComputedStyle","paddingLeft","Number","parseFloat","paddingRight","clientWidth","separators","sep","visible","removeAttribute","btn","document","createElement","type","className","setAttribute","innerHTML","addEventListener","e","preventDefault","toggleDropdown","appendChild","openDropdown","dropdown","renderDropdownItems","positionDropdown","appendToRoot","requestAnimationFrame","first","querySelector","focus","handleDropdownKeydown","registerCloseHandler","lastGroup","group","menuBtn","iconSpan","icon","labelSpan","textContent","tooltip","label","ev","stopPropagation","activateOverflowItem","rect","getBoundingClientRect","rightEdge","window","innerWidth","right","style","position","top","bottom","left","zIndex","root","getRootNode","ShadowRoot","body","path","composedPath","includes","setTimeout","removeEventListener","popupType","executeCommand","command","key","items","current","indexOf","next","findNextDropdownItem","prev","focusedItem","i","filter","highlightCells","grid","targetRow","targetCol","cells","cell","r","c","createSeparator","ToolbarPopupController","activePopup","activePopupButton","closePopupHandler","isOpen","button","close","popup","container","onClose","display","gridTemplateColumns","maxCols","gap","padding","textAlign","fontSize","maxRows","width","height","border","cursor","String","onSelect","popupConfig","cmd","renderPopup","positionAndAppend","focusFirstItem","handlePopupKeydown","closeAndRestoreFocus","triggerBtn","firstItem","handleGridKeydown","handleCustomPopupKeydown","itemArr","focused","click","row","col","lastCell","newRow","newCol","navigateGrid","target","currentIdx","dispatchEvent","MouseEvent","bubbles","cancelable","ToolbarTooltip","timer","isPopupActive","static","TOOLTIP_ID","hide","text","parentNode","transform","clearTimeout","ToolbarServiceKey","ServiceKey","ToolbarPlugin","name","priority","toolbarElement","hiddenItems","Set","layoutConfig","overflowBehavior","focusedIndex","popupController","overflowController","visibleElements","locale","overflow","resolvePluginLocale","registerStyleSheet","registerService","refresh","updateButtonStates","getState","closePopup","createToolbarElement","getOverflowBehavior","behavior","applyOverflowBehavior","renderItems","_oldState","newState","_tr","readonly","hidden","value","Object","delete","getPluginContainer","handleToolbarKeydown","visibleButtons","overflowBtn","initRovingTabindex","activateButton","renderItemsByLayout","renderItemsByPriority","parentElement","update","getTabElements","elements","findFirstEnabled","applyRovingTabindex","index","activeElement","syncFocusedIndex","idx","findIndex","el","findNextEnabled","setRovingFocus","last","findLastEnabled","toolbarReg","getToolbarRegistry","firstGroup","groupPluginIds","groups","groupItems","pId","getToolbarItemsByPlugin","has","sort","a","createButton","getToolbarItems","sorted","some","separatorAfter","Map","list","get","set","span","show","updateItemStates"],"mappings":";;AACO,MCUMA,IAAmC,EAC/CC,uBAAuB,sBACvBC,eAAe,aAAA,GAsDHC,IAAiD,EAC7DC,IAAIJ,GACJK,IAnD+C,EAC/CJ,uBAAuB,yBACvBC,eAAe,uBAkDfI,IA7C+C,EAC/CL,uBAAuB,uBACvBC,eAAe,sBA4CfK,IAvC+C,EAC/CN,uBAAuB,4BACvBC,eAAe,mBAsCfM,IAjC+C,EAC/CP,uBAAuB,QACvBC,eAAe,UAgCfO,IA3B+C,EAC/CR,uBAAuB,4BACvBC,eAAe,wBA0BfQ,IArB+C,EAC/CT,uBAAuB,kBACvBC,eAAe,kBAoBfS,IAf+C,EAC/CV,uBAAuB,sBACvBC,eAAe,gBCjDHU,IAA0B,EAEtCC,YAAY,eAEZC,MAAM,QAENC,MAAM,OAAA,GCmBDC,IAAmB,wCACnBC,IAAmB;AAOlB,MAAMC,EAAAA;AAAAA,EACKC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EAETC,UAA2B,CAAA;AAAA,EAC3BC,iB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