@notectl/core 1.6.1 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/README.md +2 -2
  2. package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs → AttrRegistry-Ci0qAvtS.mjs} +2 -2
  3. package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs.map → AttrRegistry-Ci0qAvtS.mjs.map} +1 -1
  4. package/dist/chunks/AttributedMarkCommands-BETuHXj8.mjs +58 -0
  5. package/dist/chunks/AttributedMarkCommands-BETuHXj8.mjs.map +1 -0
  6. package/dist/chunks/{CaretNavigation-CAJXoaae.mjs → CaretNavigation-qLfeL0So.mjs} +56 -56
  7. package/dist/chunks/{CaretNavigation-CAJXoaae.mjs.map → CaretNavigation-qLfeL0So.mjs.map} +1 -1
  8. package/dist/chunks/ColorGrid-BBkN0AOb.mjs +80 -0
  9. package/dist/chunks/ColorGrid-BBkN0AOb.mjs.map +1 -0
  10. package/dist/chunks/ColorPickerPopup-D3ysvOH-.mjs +37 -0
  11. package/dist/chunks/ColorPickerPopup-D3ysvOH-.mjs.map +1 -0
  12. package/dist/chunks/ColorValidation-CV4f1wu6.mjs +39 -0
  13. package/dist/chunks/ColorValidation-CV4f1wu6.mjs.map +1 -0
  14. package/dist/chunks/{Document-CuwE73FF.mjs → Document-DfZ1NOjs.mjs} +15 -15
  15. package/dist/chunks/{Document-CuwE73FF.mjs.map → Document-DfZ1NOjs.mjs.map} +1 -1
  16. package/dist/chunks/MarkCommands-uybmkw9l.mjs +94 -0
  17. package/dist/chunks/MarkCommands-uybmkw9l.mjs.map +1 -0
  18. package/dist/chunks/{NavigationUtils-CyW0Vo8A.mjs → NavigationUtils-Cspt2ZrK.mjs} +3 -3
  19. package/dist/chunks/{NavigationUtils-CyW0Vo8A.mjs.map → NavigationUtils-Cspt2ZrK.mjs.map} +1 -1
  20. package/dist/chunks/{NodeResolver-B-wzthAQ.mjs → NodeResolver-CzLmmrph.mjs} +2 -2
  21. package/dist/chunks/{NodeResolver-B-wzthAQ.mjs.map → NodeResolver-CzLmmrph.mjs.map} +1 -1
  22. package/dist/chunks/PopupPositioning-Cn6L_mO2.mjs +30 -0
  23. package/dist/chunks/PopupPositioning-Cn6L_mO2.mjs.map +1 -0
  24. package/dist/chunks/RangeIterator-Bye0UtbY.mjs +16 -0
  25. package/dist/chunks/RangeIterator-Bye0UtbY.mjs.map +1 -0
  26. package/dist/chunks/{Selection-DmFDwiPJ.mjs → Selection-BRTab5hO.mjs} +7 -7
  27. package/dist/chunks/{Selection-DmFDwiPJ.mjs.map → Selection-BRTab5hO.mjs.map} +1 -1
  28. package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -1
  29. package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs → ToolbarKeyboardNav-DhpL8zNV.mjs} +3 -3
  30. package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs.map → ToolbarKeyboardNav-DhpL8zNV.mjs.map} +1 -1
  31. package/dist/chunks/{ToolbarPlugin-B6JETWaw.mjs → ToolbarPlugin-B7oJRzpl.mjs} +339 -127
  32. package/dist/chunks/ToolbarPlugin-B7oJRzpl.mjs.map +1 -0
  33. package/dist/chunks/{index-CPyHuEzh.mjs → index-Bt_d4IqB.mjs} +12 -12
  34. package/dist/chunks/{index-CPyHuEzh.mjs.map → index-Bt_d4IqB.mjs.map} +1 -1
  35. package/dist/chunks/{index-BigJ0z6n.mjs → index-CFJFD4lF.mjs} +8 -8
  36. package/dist/chunks/{index-BigJ0z6n.mjs.map → index-CFJFD4lF.mjs.map} +1 -1
  37. package/dist/chunks/{index-D67mP19g.mjs → index-CFPP456m.mjs} +13 -13
  38. package/dist/chunks/{index-D67mP19g.mjs.map → index-CFPP456m.mjs.map} +1 -1
  39. package/dist/chunks/{index-DQryjfJs.mjs → index-CH1r7DL-.mjs} +259 -300
  40. package/dist/chunks/index-CH1r7DL-.mjs.map +1 -0
  41. package/dist/chunks/{index-tBDVaSjG.mjs → index-CfyS_pgH.mjs} +28 -21
  42. package/dist/chunks/index-CfyS_pgH.mjs.map +1 -0
  43. package/dist/chunks/{index-DIAXWwgJ.mjs → index-Ckzqtn5D.mjs} +17 -14
  44. package/dist/chunks/{index-DIAXWwgJ.mjs.map → index-Ckzqtn5D.mjs.map} +1 -1
  45. package/dist/chunks/{index-BDMP86F4.mjs → index-CrKz_IEn.mjs} +35 -35
  46. package/dist/chunks/{index-BDMP86F4.mjs.map → index-CrKz_IEn.mjs.map} +1 -1
  47. package/dist/chunks/{index-B0UFAfyb.mjs → index-DGKQhSAl.mjs} +5 -5
  48. package/dist/chunks/{index-B0UFAfyb.mjs.map → index-DGKQhSAl.mjs.map} +1 -1
  49. package/dist/chunks/{index-83QoUENW.mjs → index-DIvHQtE2.mjs} +12 -9
  50. package/dist/chunks/{index-83QoUENW.mjs.map → index-DIvHQtE2.mjs.map} +1 -1
  51. package/dist/chunks/index-DayTn6Re.mjs +166 -0
  52. package/dist/chunks/index-DayTn6Re.mjs.map +1 -0
  53. package/dist/chunks/index-Deag_lVi.mjs +121 -0
  54. package/dist/chunks/index-Deag_lVi.mjs.map +1 -0
  55. package/dist/chunks/{index--z_Txzej.mjs → index-DmuuFS5D.mjs} +6 -6
  56. package/dist/chunks/{index--z_Txzej.mjs.map → index-DmuuFS5D.mjs.map} +1 -1
  57. package/dist/chunks/{index-DRZwd-1W.mjs → index-DoCvDkfj.mjs} +79 -96
  58. package/dist/chunks/index-DoCvDkfj.mjs.map +1 -0
  59. package/dist/chunks/index-DuRNETFv.mjs +296 -0
  60. package/dist/chunks/index-DuRNETFv.mjs.map +1 -0
  61. package/dist/chunks/{index-CPjf45-o.mjs → index-Dum8yE_t.mjs} +14 -14
  62. package/dist/chunks/{index-CPjf45-o.mjs.map → index-Dum8yE_t.mjs.map} +1 -1
  63. package/dist/chunks/{index-BWXkaC2Z.mjs → index-Dy6SllXW.mjs} +53 -65
  64. package/dist/chunks/index-Dy6SllXW.mjs.map +1 -0
  65. package/dist/chunks/{index-D8tbbW97.mjs → index-E7OgN7hM.mjs} +2 -2
  66. package/dist/chunks/{index-D8tbbW97.mjs.map → index-E7OgN7hM.mjs.map} +1 -1
  67. package/dist/chunks/{index-D4GKlc-A.mjs → index-yhz2qeeh.mjs} +224 -222
  68. package/dist/chunks/index-yhz2qeeh.mjs.map +1 -0
  69. package/dist/commands/AttributedMarkCommands.d.ts +46 -0
  70. package/dist/commands/AttributedMarkCommands.d.ts.map +1 -0
  71. package/dist/commands/CommandHelpers.d.ts +21 -0
  72. package/dist/commands/CommandHelpers.d.ts.map +1 -0
  73. package/dist/commands/Commands.d.ts +2 -8
  74. package/dist/commands/Commands.d.ts.map +1 -1
  75. package/dist/commands/DeleteCommands.d.ts.map +1 -1
  76. package/dist/commands/GapCursorCommands.d.ts.map +1 -1
  77. package/dist/commands/NodeSelectionCommands.d.ts.map +1 -1
  78. package/dist/commands/PasteCommand.d.ts.map +1 -1
  79. package/dist/commands/RangeIterator.d.ts +10 -0
  80. package/dist/commands/RangeIterator.d.ts.map +1 -0
  81. package/dist/editor/DocumentParser.d.ts.map +1 -1
  82. package/dist/editor/DocumentSerializer.d.ts +2 -0
  83. package/dist/editor/DocumentSerializer.d.ts.map +1 -1
  84. package/dist/editor/MarkSerializer.d.ts +11 -0
  85. package/dist/editor/MarkSerializer.d.ts.map +1 -0
  86. package/dist/editor/NotectlEditor.d.ts +6 -3
  87. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  88. package/dist/editor/PaperLayoutController.d.ts +2 -0
  89. package/dist/editor/PaperLayoutController.d.ts.map +1 -1
  90. package/dist/editor/styles/font-select.d.ts +1 -1
  91. package/dist/editor/styles/font-select.d.ts.map +1 -1
  92. package/dist/editor/styles/font-size-select.d.ts +1 -1
  93. package/dist/editor/styles/font-size-select.d.ts.map +1 -1
  94. package/dist/editor/styles/heading-select.d.ts +1 -1
  95. package/dist/editor/styles/heading-select.d.ts.map +1 -1
  96. package/dist/editor/styles/toolbar.d.ts +1 -1
  97. package/dist/editor/styles/toolbar.d.ts.map +1 -1
  98. package/dist/index.d.ts +11 -2
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/input/ClipboardHandler.d.ts +0 -2
  101. package/dist/input/ClipboardHandler.d.ts.map +1 -1
  102. package/dist/model/MarkSpec.d.ts +6 -0
  103. package/dist/model/MarkSpec.d.ts.map +1 -1
  104. package/dist/notectl-core.mjs +2245 -2085
  105. package/dist/notectl-core.mjs.map +1 -1
  106. package/dist/notectl-core.umd.js +5568 -5345
  107. package/dist/notectl-core.umd.js.map +1 -1
  108. package/dist/plugins/PluginManager.d.ts +2 -0
  109. package/dist/plugins/PluginManager.d.ts.map +1 -1
  110. package/dist/plugins/alignment.mjs +3 -3
  111. package/dist/plugins/blockquote.mjs +2 -2
  112. package/dist/plugins/caret-navigation.mjs +1 -1
  113. package/dist/plugins/code-block.mjs +3 -3
  114. package/dist/plugins/font/FontPlugin.d.ts +0 -6
  115. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  116. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
  117. package/dist/plugins/font-size/FontSizePlugin.d.ts +0 -5
  118. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
  119. package/dist/plugins/font-size.mjs +2 -2
  120. package/dist/plugins/font.mjs +2 -2
  121. package/dist/plugins/gap-cursor.mjs +7 -7
  122. package/dist/plugins/hard-break.mjs +2 -25
  123. package/dist/plugins/hard-break.mjs.map +1 -1
  124. package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +1 -7
  125. package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -1
  126. package/dist/plugins/heading/HeadingPlugin.d.ts +0 -6
  127. package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
  128. package/dist/plugins/heading.mjs +2 -2
  129. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  130. package/dist/plugins/highlight.mjs +2 -2
  131. package/dist/plugins/horizontal-rule.mjs +2 -2
  132. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
  133. package/dist/plugins/image.mjs +3 -3
  134. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  135. package/dist/plugins/link.mjs +2 -2
  136. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  137. package/dist/plugins/list.mjs +2 -2
  138. package/dist/plugins/shared/ColorGrid.d.ts +25 -0
  139. package/dist/plugins/shared/ColorGrid.d.ts.map +1 -0
  140. package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
  141. package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
  142. package/dist/plugins/shared/ColorValidation.d.ts +13 -2
  143. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
  144. package/dist/plugins/shared/PopupKeyboardPatterns.d.ts +43 -0
  145. package/dist/plugins/shared/PopupKeyboardPatterns.d.ts.map +1 -0
  146. package/dist/plugins/shared/PopupManager.d.ts +45 -0
  147. package/dist/plugins/shared/PopupManager.d.ts.map +1 -0
  148. package/dist/plugins/shared/PopupPositioning.d.ts +21 -0
  149. package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -0
  150. package/dist/plugins/strikethrough.mjs +2 -2
  151. package/dist/plugins/super-sub.mjs +2 -2
  152. package/dist/plugins/table/TableBorderColor.d.ts.map +1 -1
  153. package/dist/plugins/table/TableContextMenu.d.ts +2 -1
  154. package/dist/plugins/table/TableContextMenu.d.ts.map +1 -1
  155. package/dist/plugins/table.mjs +10 -10
  156. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  157. package/dist/plugins/text-color.mjs +2 -2
  158. package/dist/plugins/text-formatting.mjs +1 -1
  159. package/dist/plugins/toolbar/ToolbarItem.d.ts +11 -2
  160. package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
  161. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +5 -1
  162. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
  163. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
  164. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  165. package/dist/plugins/toolbar/ToolbarPopupController.d.ts +9 -1
  166. package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
  167. package/dist/plugins/toolbar/index.d.ts +1 -1
  168. package/dist/plugins/toolbar/index.d.ts.map +1 -1
  169. package/dist/plugins/toolbar.mjs +1 -1
  170. package/dist/presets/FullPreset.d.ts +16 -0
  171. package/dist/presets/FullPreset.d.ts.map +1 -0
  172. package/dist/presets/MinimalPreset.d.ts +7 -0
  173. package/dist/presets/MinimalPreset.d.ts.map +1 -0
  174. package/dist/presets/PresetTypes.d.ts +50 -0
  175. package/dist/presets/PresetTypes.d.ts.map +1 -0
  176. package/dist/state/BlockTreeOps.d.ts +21 -0
  177. package/dist/state/BlockTreeOps.d.ts.map +1 -0
  178. package/dist/state/InlineContentOps.d.ts +37 -0
  179. package/dist/state/InlineContentOps.d.ts.map +1 -0
  180. package/dist/state/StepApplication.d.ts.map +1 -1
  181. package/dist/test/PluginTestUtils.d.ts +4 -0
  182. package/dist/test/PluginTestUtils.d.ts.map +1 -1
  183. package/package.json +2 -2
  184. package/dist/chunks/ColorNames-BdsHwA2f.mjs +0 -59
  185. package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +0 -1
  186. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +0 -125
  187. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +0 -1
  188. package/dist/chunks/Commands-CicwYoTQ.mjs +0 -286
  189. package/dist/chunks/Commands-CicwYoTQ.mjs.map +0 -1
  190. package/dist/chunks/MarkCommands-CC37WA7Z.mjs +0 -94
  191. package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +0 -1
  192. package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs.map +0 -1
  193. package/dist/chunks/index-BWXkaC2Z.mjs.map +0 -1
  194. package/dist/chunks/index-D4GKlc-A.mjs.map +0 -1
  195. package/dist/chunks/index-DQryjfJs.mjs.map +0 -1
  196. package/dist/chunks/index-DRZwd-1W.mjs.map +0 -1
  197. package/dist/chunks/index-DUC1X43Z.mjs +0 -209
  198. package/dist/chunks/index-DUC1X43Z.mjs.map +0 -1
  199. package/dist/chunks/index-DipAT_Q9.mjs +0 -191
  200. package/dist/chunks/index-DipAT_Q9.mjs.map +0 -1
  201. package/dist/chunks/index-tBDVaSjG.mjs.map +0 -1
@@ -1,21 +1,92 @@
1
1
  import { S as t, r as e } from "./resolvePluginLocale-B4w1OkPy.mjs";
2
- import { f as o, n, a as r, b as i, c as s, d as l } from "./ToolbarKeyboardNav-B32OMv8r.mjs";
3
- const a = { formattingOptionsAria: "Formatting options", moreToolsAria: "More tools" }, c = { en: a, de: { formattingOptionsAria: "Formatierungsoptionen", moreToolsAria: "Weitere Werkzeuge" }, es: { formattingOptionsAria: "Opciones de formato", moreToolsAria: "Más herramientas" }, fr: { formattingOptionsAria: "Options de mise en forme", moreToolsAria: "Plus d'outils" }, zh: { formattingOptionsAria: "格式选项", moreToolsAria: "更多工具" }, ru: { formattingOptionsAria: "Параметры форматирования", moreToolsAria: "Другие инструменты" }, ar: { formattingOptionsAria: "خيارات التنسيق", moreToolsAria: "أدوات إضافية" }, hi: { formattingOptionsAria: "फ़ॉर्मेटिंग विकल्प", moreToolsAria: "और उपकरण" } }, d = { BurgerMenu: "burger-menu", Flow: "flow", None: "none" }, p = "notectl-toolbar-btn--overflow-hidden", h = "notectl-toolbar-separator--overflow-hidden";
4
- class u {
2
+ import { a as o, p as n } from "./PopupPositioning-Cn6L_mO2.mjs";
3
+ import { f as r, n as i, b as s, a as l, c as a, d as c } from "./ToolbarKeyboardNav-DhpL8zNV.mjs";
4
+ const d = new t("popup");
5
+ class p {
6
+ stack = [];
7
+ referenceNode;
8
+ constructor(t2) {
9
+ this.referenceNode = t2;
10
+ }
11
+ open(t2) {
12
+ const e2 = document.createElement("div");
13
+ e2.className = t2.className ? `notectl-popup ${t2.className}` : "notectl-popup", t2.ariaRole && e2.setAttribute("role", t2.ariaRole), t2.ariaLabel && e2.setAttribute("aria-label", t2.ariaLabel);
14
+ const r2 = { close: () => this.closeEntry(c2), getElement: () => e2 };
15
+ t2.content(e2, () => this.closeEntry(c2));
16
+ const i2 = t2.referenceNode ?? this.referenceNode;
17
+ o(e2, i2);
18
+ const s2 = t2.anchor instanceof HTMLElement ? t2.anchor.getBoundingClientRect() : t2.anchor;
19
+ n(e2, s2, { position: t2.position ?? "below-start" });
20
+ const l2 = t2.parent ? this.findEntryByHandle(t2.parent) : null, a2 = (o2) => {
21
+ const n2 = o2.composedPath();
22
+ if (!n2.includes(e2)) {
23
+ for (const t3 of this.stack) if (n2.includes(t3.element)) return;
24
+ t2.anchor instanceof HTMLElement && n2.includes(t2.anchor) || this.closeEntry(c2);
25
+ }
26
+ }, c2 = { element: e2, config: t2, clickOutsideHandler: a2, parent: l2 };
27
+ return this.stack.push(c2), setTimeout(() => {
28
+ document.addEventListener("mousedown", a2);
29
+ }, 0), this.focusFirstItem(e2), r2;
30
+ }
31
+ close() {
32
+ const t2 = this.stack[this.stack.length - 1];
33
+ t2 && this.closeEntry(t2);
34
+ }
35
+ closeAll() {
36
+ for (; this.stack.length > 0; ) {
37
+ const t2 = this.stack[this.stack.length - 1];
38
+ t2 && this.closeEntry(t2);
39
+ }
40
+ }
41
+ isOpen() {
42
+ return this.stack.length > 0;
43
+ }
44
+ destroy() {
45
+ this.closeAll();
46
+ }
47
+ closeEntry(t2) {
48
+ const e2 = this.stack.indexOf(t2);
49
+ if (-1 !== e2) {
50
+ for (; this.stack.length > e2 + 1; ) {
51
+ const t3 = this.stack[this.stack.length - 1];
52
+ t3 && this.removeEntry(t3);
53
+ }
54
+ this.removeEntry(t2), t2.config.restoreFocusTo && t2.config.restoreFocusTo.focus(), t2.config.onClose?.();
55
+ }
56
+ }
57
+ removeEntry(t2) {
58
+ const e2 = this.stack.indexOf(t2);
59
+ -1 !== e2 && (this.stack.splice(e2, 1), t2.element.remove(), document.removeEventListener("mousedown", t2.clickOutsideHandler));
60
+ }
61
+ findEntryByHandle(t2) {
62
+ const e2 = t2.getElement();
63
+ return this.stack.find((t3) => t3.element === e2) ?? null;
64
+ }
65
+ focusFirstItem(t2) {
66
+ requestAnimationFrame(() => {
67
+ const e2 = t2.querySelector('[role="menuitem"]') ?? t2.querySelector('[role="option"]') ?? t2.querySelector('[role="gridcell"]') ?? t2.querySelector("input") ?? t2.querySelector("button");
68
+ e2?.focus();
69
+ });
70
+ }
71
+ }
72
+ const u = { formattingOptionsAria: "Formatting options", moreToolsAria: "More tools" }, h = { en: u, de: { formattingOptionsAria: "Formatierungsoptionen", moreToolsAria: "Weitere Werkzeuge" }, es: { formattingOptionsAria: "Opciones de formato", moreToolsAria: "Más herramientas" }, fr: { formattingOptionsAria: "Options de mise en forme", moreToolsAria: "Plus d'outils" }, zh: { formattingOptionsAria: "格式选项", moreToolsAria: "更多工具" }, ru: { formattingOptionsAria: "Параметры форматирования", moreToolsAria: "Другие инструменты" }, ar: { formattingOptionsAria: "خيارات التنسيق", moreToolsAria: "أدوات إضافية" }, hi: { formattingOptionsAria: "फ़ॉर्मेटिंग विकल्प", moreToolsAria: "और उपकरण" } }, m = { BurgerMenu: "burger-menu", Flow: "flow", None: "none" }, b = "notectl-toolbar-btn--overflow-hidden", f = "notectl-toolbar-separator--overflow-hidden";
73
+ class v {
5
74
  toolbar;
6
75
  context;
7
76
  onOverflowChange;
8
77
  onItemActivated;
9
78
  getActiveElement;
10
79
  ariaLabel;
80
+ popupManager;
11
81
  entries = [];
12
82
  overflowButton = null;
13
83
  overflowDropdown = null;
84
+ overflowHandle = null;
14
85
  overflowEntries = [];
15
86
  resizeObserver = null;
16
87
  closeHandler = null;
17
88
  constructor(t2) {
18
- this.toolbar = t2.toolbar, this.ariaLabel = t2.ariaLabel, this.context = t2.context, this.onOverflowChange = t2.onOverflowChange, this.onItemActivated = t2.onItemActivated, this.getActiveElement = t2.getActiveElement, this.resizeObserver = new ResizeObserver(() => this.recalculate()), this.resizeObserver.observe(this.toolbar);
89
+ this.toolbar = t2.toolbar, this.ariaLabel = t2.ariaLabel, this.context = t2.context, this.onOverflowChange = t2.onOverflowChange, this.onItemActivated = t2.onItemActivated, this.getActiveElement = t2.getActiveElement, this.popupManager = t2.popupManager ?? null, this.resizeObserver = new ResizeObserver(() => this.recalculate()), this.resizeObserver.observe(this.toolbar);
19
90
  }
20
91
  update(t2) {
21
92
  this.entries = t2.map((t3) => ({ element: t3.element, item: t3.item })), this.recalculate();
@@ -23,30 +94,30 @@ class u {
23
94
  recalculate() {
24
95
  if (0 === this.entries.length) return;
25
96
  this.closeDropdown(), this.resetVisibility(), this.ensureOverflowButton(), this.setOverflowButtonVisible(false);
26
- const t2 = this.measureAvailableWidth() - 34 - 2;
27
- let e2 = 0, o2 = false;
28
- const n2 = [], r2 = Array.from(this.toolbar.children);
29
- for (const i2 of r2) {
30
- if (i2 === this.overflowButton) continue;
31
- if (i2.classList.contains("notectl-toolbar-separator")) {
32
- if (o2) {
33
- i2.classList.add(h);
97
+ const t2 = this.measureAvailableWidth(), e2 = Array.from(this.toolbar.children), o2 = this.measureChildWidths(e2), n2 = t2 - 34 - 2;
98
+ let r2 = 0, i2 = false;
99
+ const s2 = [];
100
+ for (const t3 of e2) {
101
+ if (t3 === this.overflowButton) continue;
102
+ if (t3.classList.contains("notectl-toolbar-separator")) {
103
+ if (i2) {
104
+ t3.classList.add(f);
34
105
  continue;
35
106
  }
36
- const n3 = i2.offsetWidth + 2;
37
- e2 + n3 > t2 ? (o2 = true, i2.classList.add(h)) : e2 += n3;
107
+ const e4 = (o2.get(t3) ?? 0) + 2;
108
+ r2 + e4 > n2 ? (i2 = true, t3.classList.add(f)) : r2 += e4;
38
109
  continue;
39
110
  }
40
- const r3 = this.entries.find((t3) => t3.element === i2);
41
- if (!r3) continue;
42
- if (o2) {
43
- r3.element.classList.add(p), n2.push(r3);
111
+ const e3 = this.entries.find((e4) => e4.element === t3);
112
+ if (!e3) continue;
113
+ if (i2) {
114
+ e3.element.classList.add(b), s2.push(e3);
44
115
  continue;
45
116
  }
46
- const s2 = r3.element.offsetWidth + 2;
47
- e2 + s2 > t2 ? (o2 = true, r3.element.classList.add(p), n2.push(r3)) : e2 += s2;
117
+ const l2 = (o2.get(t3) ?? 0) + 2;
118
+ r2 + l2 > n2 ? (i2 = true, e3.element.classList.add(b), s2.push(e3)) : r2 += l2;
48
119
  }
49
- this.overflowEntries = n2, this.hideTrailingSeparators(), this.setOverflowButtonVisible(n2.length > 0), this.notifyChange();
120
+ this.overflowEntries = s2, this.hideTrailingSeparators(), this.setOverflowButtonVisible(s2.length > 0), this.notifyChange();
50
121
  }
51
122
  updateItemStates(t2) {
52
123
  if (!this.overflowDropdown) return;
@@ -55,20 +126,28 @@ class u {
55
126
  const e3 = o2.getAttribute("data-toolbar-item"), n2 = this.overflowEntries.find((t3) => t3.item.id === e3);
56
127
  if (!n2) continue;
57
128
  const r2 = n2.item.isActive?.(t2) ?? false, i2 = n2.item.isEnabled?.(t2) ?? true;
58
- o2.classList.toggle("notectl-dropdown__item--active", r2), o2.disabled = !i2;
129
+ if (o2.classList.toggle("notectl-dropdown__item--active", r2), o2.disabled = !i2, "combobox" === n2.item.popupType) {
130
+ const e4 = o2.querySelector(".notectl-dropdown__item-label");
131
+ e4 && (e4.textContent = n2.item.getLabel(t2));
132
+ }
59
133
  }
60
134
  }
61
135
  destroy() {
62
136
  this.resizeObserver?.disconnect(), this.resizeObserver = null, this.closeDropdown(), this.overflowButton?.remove(), this.overflowButton = null, this.entries = [], this.overflowEntries = [];
63
137
  }
138
+ measureChildWidths(t2) {
139
+ const e2 = /* @__PURE__ */ new Map();
140
+ for (const o2 of t2) o2 !== this.overflowButton && e2.set(o2, o2.offsetWidth);
141
+ return e2;
142
+ }
64
143
  measureAvailableWidth() {
65
144
  const t2 = getComputedStyle(this.toolbar), e2 = Number.parseFloat(t2.paddingLeft) || 0, o2 = Number.parseFloat(t2.paddingRight) || 0;
66
145
  return this.toolbar.clientWidth - e2 - o2;
67
146
  }
68
147
  resetVisibility() {
69
- for (const t3 of this.entries) t3.element.classList.remove(p);
148
+ for (const t3 of this.entries) t3.element.classList.remove(b);
70
149
  const t2 = Array.from(this.toolbar.querySelectorAll(".notectl-toolbar-separator"));
71
- for (const e2 of t2) e2.classList.remove(h);
150
+ for (const e2 of t2) e2.classList.remove(f);
72
151
  }
73
152
  setOverflowButtonVisible(t2) {
74
153
  this.overflowButton && (this.overflowButton.classList.toggle("notectl-toolbar-overflow-btn--hidden", !t2), t2 || this.overflowButton.removeAttribute("tabindex"));
@@ -86,27 +165,31 @@ class u {
86
165
  openDropdown() {
87
166
  if (!this.overflowButton || 0 === this.overflowEntries.length) return;
88
167
  const t2 = document.createElement("div");
89
- t2.className = "notectl-toolbar-popup notectl-dropdown", t2.setAttribute("role", "menu"), this.renderDropdownItems(t2), this.positionDropdown(t2), this.appendToRoot(t2), this.overflowDropdown = t2, this.overflowButton.setAttribute("aria-expanded", "true"), requestAnimationFrame(() => {
168
+ t2.className = "notectl-toolbar-popup notectl-dropdown", t2.setAttribute("role", "menu"), this.renderDropdownItems(t2, this.context.getState()), this.popupManager ? (this.overflowHandle = this.popupManager.open({ anchor: this.overflowButton, className: "notectl-toolbar-popup notectl-dropdown", ariaRole: "menu", position: "below-end", referenceNode: this.overflowButton, restoreFocusTo: this.overflowButton, onClose: () => {
169
+ this.overflowHandle = null, this.overflowDropdown = null, this.overflowButton && this.overflowButton.setAttribute("aria-expanded", "false");
170
+ }, content: (t3) => {
171
+ this.renderDropdownItems(t3, this.context.getState()), this.overflowDropdown = t3, t3.addEventListener("keydown", (t4) => this.handleDropdownKeydown(t4));
172
+ } }), this.overflowButton.setAttribute("aria-expanded", "true")) : (this.positionDropdown(t2), o(t2, this.overflowButton), this.overflowDropdown = t2, this.overflowButton.setAttribute("aria-expanded", "true"), requestAnimationFrame(() => {
90
173
  const e2 = t2.querySelector('[role="menuitem"]');
91
174
  e2?.focus();
92
- }), t2.addEventListener("keydown", (t3) => this.handleDropdownKeydown(t3)), this.registerCloseHandler();
175
+ }), t2.addEventListener("keydown", (t3) => this.handleDropdownKeydown(t3)), this.registerCloseHandler());
93
176
  }
94
- renderDropdownItems(t2) {
95
- let e2 = null;
96
- for (const o2 of this.overflowEntries) {
97
- if (null !== e2 && o2.item.group !== e2) {
177
+ renderDropdownItems(t2, e2) {
178
+ let o2 = null;
179
+ for (const n2 of this.overflowEntries) {
180
+ if (null !== o2 && n2.item.group !== o2) {
98
181
  const e3 = document.createElement("div");
99
182
  e3.className = "notectl-dropdown__separator", e3.setAttribute("role", "separator"), t2.appendChild(e3);
100
183
  }
101
- e2 = o2.item.group;
102
- const n2 = document.createElement("button");
103
- n2.type = "button", n2.className = "notectl-dropdown__item", n2.setAttribute("role", "menuitem"), n2.setAttribute("tabindex", "-1"), n2.setAttribute("data-toolbar-item", o2.item.id);
104
- const r2 = document.createElement("span");
105
- r2.className = "notectl-dropdown__item-icon", r2.innerHTML = o2.item.icon, n2.appendChild(r2);
184
+ o2 = n2.item.group;
185
+ const r2 = document.createElement("button");
186
+ r2.type = "button", r2.className = "notectl-dropdown__item", r2.setAttribute("role", "menuitem"), r2.setAttribute("tabindex", "-1"), r2.setAttribute("data-toolbar-item", n2.item.id);
106
187
  const i2 = document.createElement("span");
107
- i2.className = "notectl-dropdown__item-label", i2.textContent = o2.item.tooltip ?? o2.item.label, n2.appendChild(i2), n2.addEventListener("mousedown", (t3) => {
108
- t3.preventDefault(), t3.stopPropagation(), this.activateOverflowItem(o2);
109
- }), t2.appendChild(n2);
188
+ i2.className = "notectl-dropdown__item-icon", "combobox" !== n2.item.popupType && (i2.innerHTML = n2.item.icon), r2.appendChild(i2);
189
+ const s2 = document.createElement("span");
190
+ s2.className = "notectl-dropdown__item-label", s2.textContent = "combobox" === n2.item.popupType ? n2.item.getLabel(e2) : n2.item.tooltip ?? n2.item.label, r2.appendChild(s2), r2.addEventListener("mousedown", (t3) => {
191
+ t3.preventDefault(), t3.stopPropagation(), this.activateOverflowItem(n2);
192
+ }), t2.appendChild(r2);
110
193
  }
111
194
  }
112
195
  positionDropdown(t2) {
@@ -114,11 +197,6 @@ class u {
114
197
  const e2 = this.overflowButton.getBoundingClientRect(), o2 = window.innerWidth - e2.right;
115
198
  t2.style.position = "fixed", t2.style.top = `${e2.bottom + 2}px`, t2.style.right = `${o2}px`, t2.style.left = "auto", t2.style.zIndex = "10000";
116
199
  }
117
- appendToRoot(t2) {
118
- if (!this.overflowButton) return;
119
- const e2 = this.overflowButton.getRootNode();
120
- e2 instanceof ShadowRoot ? e2.appendChild(t2) : document.body.appendChild(t2);
121
- }
122
200
  registerCloseHandler() {
123
201
  this.closeHandler = (t2) => {
124
202
  const e2 = t2.composedPath();
@@ -128,6 +206,10 @@ class u {
128
206
  }, 0);
129
207
  }
130
208
  closeDropdown() {
209
+ if (this.overflowHandle) {
210
+ const t2 = this.overflowHandle;
211
+ return this.overflowHandle = null, this.overflowDropdown = null, t2.close(), void (this.overflowButton && this.overflowButton.setAttribute("aria-expanded", "false"));
212
+ }
131
213
  this.overflowDropdown && (this.overflowDropdown.remove(), this.overflowDropdown = null), this.overflowButton && this.overflowButton.setAttribute("aria-expanded", "false"), this.closeHandler && (document.removeEventListener("mousedown", this.closeHandler), this.closeHandler = null);
132
214
  }
133
215
  activateOverflowItem(t2) {
@@ -136,26 +218,26 @@ class u {
136
218
  handleDropdownKeydown(t2) {
137
219
  if (!this.overflowDropdown) return;
138
220
  if ("Escape" === t2.key || "Tab" === t2.key) return t2.preventDefault(), t2.stopPropagation(), this.closeDropdown(), void this.overflowButton?.focus();
139
- const e2 = Array.from(this.overflowDropdown.querySelectorAll('[role="menuitem"]')), n2 = e2.indexOf(this.getActiveElement());
221
+ const e2 = Array.from(this.overflowDropdown.querySelectorAll('[role="menuitem"]')), o2 = e2.indexOf(this.getActiveElement());
140
222
  switch (t2.key) {
141
223
  case "ArrowDown": {
142
224
  t2.preventDefault();
143
- const r2 = o(e2, n2, 1);
144
- e2[r2]?.focus();
225
+ const n2 = r(e2, o2, 1);
226
+ e2[n2]?.focus();
145
227
  break;
146
228
  }
147
229
  case "ArrowUp": {
148
230
  t2.preventDefault();
149
- const r2 = o(e2, n2, -1);
150
- e2[r2]?.focus();
231
+ const n2 = r(e2, o2, -1);
232
+ e2[n2]?.focus();
151
233
  break;
152
234
  }
153
235
  case "Enter":
154
236
  case " ": {
155
237
  t2.preventDefault();
156
- const o2 = e2[n2];
157
- if (!o2) break;
158
- const r2 = o2.getAttribute("data-toolbar-item"), i2 = this.overflowEntries.find((t3) => t3.item.id === r2);
238
+ const n2 = e2[o2];
239
+ if (!n2) break;
240
+ const r2 = n2.getAttribute("data-toolbar-item"), i2 = this.overflowEntries.find((t3) => t3.item.id === r2);
159
241
  i2 && this.activateOverflowItem(i2);
160
242
  break;
161
243
  }
@@ -166,42 +248,83 @@ class u {
166
248
  for (let e2 = t2.length - 1; e2 >= 0; e2--) {
167
249
  const o2 = t2[e2];
168
250
  if (o2 && o2 !== this.overflowButton) {
169
- if (o2.classList.contains("notectl-toolbar-separator")) o2.classList.contains(h) || o2.classList.add(h);
170
- else if (!o2.classList.contains(p)) break;
251
+ if (o2.classList.contains("notectl-toolbar-separator")) o2.classList.contains(f) || o2.classList.add(f);
252
+ else if (!o2.classList.contains(b)) break;
171
253
  }
172
254
  }
173
255
  }
174
256
  notifyChange() {
175
- const t2 = this.entries.filter((t3) => !t3.element.classList.contains(p)).map((t3) => t3.element);
257
+ const t2 = this.entries.filter((t3) => !t3.element.classList.contains(b)).map((t3) => t3.element);
176
258
  this.onOverflowChange(t2, this.overflowEntries.length > 0 ? this.overflowButton : null);
177
259
  }
178
260
  }
179
- function m(t2, e2, o2) {
261
+ function g(t2, e2, o2) {
180
262
  const n2 = t2.querySelectorAll(".notectl-grid-picker__cell");
181
263
  for (const t3 of n2) {
182
264
  const n3 = Number(t3.getAttribute("data-row")), r2 = Number(t3.getAttribute("data-col"));
183
265
  t3.classList.toggle("notectl-grid-picker__cell--highlighted", n3 <= e2 && r2 <= o2);
184
266
  }
185
267
  }
186
- function b() {
268
+ function w() {
187
269
  const t2 = document.createElement("span");
188
270
  return t2.className = "notectl-toolbar-separator", t2.setAttribute("role", "separator"), t2;
189
271
  }
190
- class f {
272
+ class x {
191
273
  activePopup = null;
192
274
  activePopupButton = null;
193
- closePopupHandler = null;
275
+ activeHandle = null;
194
276
  getActiveElement;
277
+ popupManager = null;
195
278
  constructor(t2) {
196
279
  this.getActiveElement = t2;
197
280
  }
281
+ setPopupManager(t2) {
282
+ this.popupManager = t2;
283
+ }
198
284
  isOpen() {
199
285
  return null !== this.activePopup;
200
286
  }
201
287
  toggle(t2, e2, o2) {
202
- if (this.activePopup) return void this.close();
288
+ this.activePopup ? this.close() : this.popupManager ? this.openViaManager(t2, e2, o2) : this.openLegacy(t2, e2, o2);
289
+ }
290
+ close() {
291
+ if (this.activeHandle) {
292
+ const t2 = this.activeHandle;
293
+ return this.activeHandle = null, this.clearButtonState(), void t2.close();
294
+ }
295
+ this.clearButtonState(), this.activePopup && (this.activePopup.remove(), this.activePopup = null);
296
+ }
297
+ closeAndRestoreFocus() {
298
+ const t2 = this.activePopupButton;
299
+ this.close(), t2?.focus();
300
+ }
301
+ destroy() {
302
+ this.close();
303
+ }
304
+ openViaManager(t2, e2, o2) {
305
+ this.popupManager && (this.activePopupButton = t2, t2.classList.add("notectl-toolbar-btn--popup-open"), t2.setAttribute("aria-expanded", "true"), this.activeHandle = this.popupManager.open({ anchor: t2, className: "notectl-toolbar-popup", referenceNode: t2, restoreFocusTo: t2, position: "below-start", onClose: () => {
306
+ this.activeHandle = null, this.clearButtonState(), this.activePopup = null;
307
+ }, content: (t3, n2) => {
308
+ this.activePopup = t3, this.renderPopupContent(t3, e2, o2, n2), t3.addEventListener("keydown", (t4) => this.handlePopupKeydown(t4));
309
+ } }));
310
+ }
311
+ openLegacy(t2, e2, o2) {
203
312
  const n2 = document.createElement("div");
204
- switch (n2.className = "notectl-toolbar-popup", e2.popupType) {
313
+ n2.className = "notectl-toolbar-popup", this.renderPopupContent(n2, e2, o2, () => this.close()), this.positionAndAppend(n2, t2), this.activePopup = n2, this.activePopupButton = t2, t2.classList.add("notectl-toolbar-btn--popup-open"), t2.setAttribute("aria-expanded", "true"), this.focusFirstItem(n2), n2.addEventListener("keydown", (t3) => this.handlePopupKeydown(t3));
314
+ const r2 = (e3) => {
315
+ const o3 = e3.composedPath();
316
+ o3.includes(n2) || o3.includes(t2) || this.close();
317
+ };
318
+ setTimeout(() => {
319
+ document.addEventListener("mousedown", r2);
320
+ }, 0), n2.dataset.legacyClose = "true";
321
+ const i2 = this.close.bind(this);
322
+ this.close = () => {
323
+ document.removeEventListener("mousedown", r2), this.close = i2, i2();
324
+ };
325
+ }
326
+ renderPopupContent(t2, e2, o2, n2) {
327
+ switch (e2.popupType) {
205
328
  case "gridPicker":
206
329
  !(function(t3, e3, o3) {
207
330
  t3.className += " notectl-grid-picker";
@@ -212,7 +335,7 @@ class f {
212
335
  for (let t4 = 1; t4 <= e3.maxRows; t4++) for (let i2 = 1; i2 <= e3.maxCols; i2++) {
213
336
  const s2 = document.createElement("div");
214
337
  s2.className = "notectl-grid-picker__cell", s2.setAttribute("role", "gridcell"), s2.setAttribute("tabindex", "-1"), s2.setAttribute("aria-label", `${t4} x ${i2}`), s2.style.width = "20px", s2.style.height = "20px", s2.style.border = "1px solid #ccc", s2.style.cursor = "pointer", s2.setAttribute("data-row", String(t4)), s2.setAttribute("data-col", String(i2)), s2.addEventListener("mouseenter", () => {
215
- m(n3, t4, i2), r2.textContent = `${t4} x ${i2}`;
338
+ g(n3, t4, i2), r2.textContent = `${t4} x ${i2}`;
216
339
  }), s2.addEventListener("mousedown", (n4) => {
217
340
  n4.preventDefault(), n4.stopPropagation(), e3.onSelect(t4, i2), o3();
218
341
  }), s2.addEventListener("click", () => {
@@ -220,7 +343,7 @@ class f {
220
343
  }), n3.appendChild(s2);
221
344
  }
222
345
  t3.appendChild(n3), t3.appendChild(r2);
223
- })(n2, e2.popupConfig, () => this.close());
346
+ })(t2, e2.popupConfig, n2);
224
347
  break;
225
348
  case "dropdown":
226
349
  !(function(t3, e3, o3, n3) {
@@ -238,27 +361,15 @@ class f {
238
361
  o3(r2.command), n3();
239
362
  }), t3.appendChild(e4);
240
363
  }
241
- })(n2, e2.popupConfig, (t3) => o2.executeCommand(t3), () => this.close());
364
+ })(t2, e2.popupConfig, (t3) => o2.executeCommand(t3), n2);
242
365
  break;
243
366
  case "custom":
244
- e2.renderPopup(n2, o2, () => this.close());
367
+ case "combobox":
368
+ e2.renderPopup(t2, o2, n2);
245
369
  }
246
- this.positionAndAppend(n2, t2), this.activePopup = n2, this.activePopupButton = t2, t2.classList.add("notectl-toolbar-btn--popup-open"), t2.setAttribute("aria-expanded", "true"), this.focusFirstItem(n2), n2.addEventListener("keydown", (t3) => this.handlePopupKeydown(t3)), this.closePopupHandler = (e3) => {
247
- const o3 = e3.composedPath();
248
- o3.includes(n2) || o3.includes(t2) || this.close();
249
- }, setTimeout(() => {
250
- this.closePopupHandler && document.addEventListener("mousedown", this.closePopupHandler);
251
- }, 0);
252
- }
253
- close() {
254
- this.activePopupButton && (this.activePopupButton.classList.remove("notectl-toolbar-btn--popup-open"), this.activePopupButton.setAttribute("aria-expanded", "false"), this.activePopupButton = null), this.activePopup && (this.activePopup.remove(), this.activePopup = null), this.closePopupHandler && (document.removeEventListener("mousedown", this.closePopupHandler), this.closePopupHandler = null);
255
370
  }
256
- closeAndRestoreFocus() {
257
- const t2 = this.activePopupButton;
258
- this.close(), t2?.focus();
259
- }
260
- destroy() {
261
- this.close();
371
+ clearButtonState() {
372
+ this.activePopupButton && (this.activePopupButton.classList.remove("notectl-toolbar-btn--popup-open"), this.activePopupButton.setAttribute("aria-expanded", "false"), this.activePopupButton = null);
262
373
  }
263
374
  positionAndAppend(t2, e2) {
264
375
  const o2 = e2.getBoundingClientRect();
@@ -280,37 +391,37 @@ class f {
280
391
  e2.length > 0 ? this.handleDropdownKeydown(t2, e2) : null !== this.activePopup.querySelector(".notectl-grid-picker__cell") ? this.handleGridKeydown(t2) : this.handleCustomPopupKeydown(t2);
281
392
  }
282
393
  handleDropdownKeydown(t2, e2) {
283
- const n2 = Array.from(e2), r2 = n2.indexOf(this.getActiveElement());
394
+ const o2 = Array.from(e2), n2 = o2.indexOf(this.getActiveElement());
284
395
  switch (t2.key) {
285
396
  case "ArrowDown": {
286
397
  t2.preventDefault();
287
- const e3 = o(n2, r2, 1);
288
- n2[e3]?.focus();
398
+ const e3 = r(o2, n2, 1);
399
+ o2[e3]?.focus();
289
400
  break;
290
401
  }
291
402
  case "ArrowUp": {
292
403
  t2.preventDefault();
293
- const e3 = o(n2, r2, -1);
294
- n2[e3]?.focus();
404
+ const e3 = r(o2, n2, -1);
405
+ o2[e3]?.focus();
295
406
  break;
296
407
  }
297
408
  case "Enter":
298
409
  case " ": {
299
410
  t2.preventDefault();
300
- const e3 = n2[r2];
411
+ const e3 = o2[n2];
301
412
  e3 && e3.click();
302
413
  break;
303
414
  }
304
415
  }
305
416
  }
306
417
  handleGridKeydown(t2) {
307
- const e2 = this.getActiveElement(), o2 = Number(e2?.getAttribute("data-row") ?? 1), r2 = Number(e2?.getAttribute("data-col") ?? 1), i2 = this.activePopup?.querySelector(".notectl-grid-picker__grid") ?? null;
308
- if (!i2) return;
309
- const s2 = i2.querySelector(".notectl-grid-picker__cell:last-child"), l2 = Number(s2?.getAttribute("data-col") ?? 1), a2 = Number(s2?.getAttribute("data-row") ?? 1);
418
+ const e2 = this.getActiveElement(), o2 = Number(e2?.getAttribute("data-row") ?? 1), n2 = Number(e2?.getAttribute("data-col") ?? 1), r2 = this.activePopup?.querySelector(".notectl-grid-picker__grid") ?? null;
419
+ if (!r2) return;
420
+ const s2 = r2.querySelector(".notectl-grid-picker__cell:last-child"), l2 = Number(s2?.getAttribute("data-col") ?? 1), a2 = Number(s2?.getAttribute("data-row") ?? 1);
310
421
  if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t2.key)) {
311
422
  t2.preventDefault();
312
- const [e3, s3] = n(o2, r2, a2, l2, t2.key), c2 = i2.querySelector(`.notectl-grid-picker__cell[data-row="${e3}"][data-col="${s3}"]`);
313
- c2?.focus(), m(i2, e3, s3);
423
+ const [e3, s3] = i(o2, n2, a2, l2, t2.key), c2 = r2.querySelector(`.notectl-grid-picker__cell[data-row="${e3}"][data-col="${s3}"]`);
424
+ c2?.focus(), g(r2, e3, s3);
314
425
  const d2 = this.activePopup?.querySelector(".notectl-grid-picker__label") ?? null;
315
426
  d2 && (d2.textContent = `${e3} x ${s3}`);
316
427
  }
@@ -320,34 +431,34 @@ class f {
320
431
  if (!this.activePopup) return;
321
432
  const e2 = Array.from(this.activePopup.querySelectorAll("button"));
322
433
  if (0 === e2.length) return;
323
- const n2 = this.getActiveElement(), r2 = e2.indexOf(n2);
434
+ const o2 = this.getActiveElement(), n2 = e2.indexOf(o2);
324
435
  switch (t2.key) {
325
436
  case "ArrowDown": {
326
437
  t2.preventDefault();
327
- const n3 = o(e2, r2, 1);
328
- e2[n3]?.focus();
438
+ const o3 = r(e2, n2, 1);
439
+ e2[o3]?.focus();
329
440
  break;
330
441
  }
331
442
  case "ArrowUp": {
332
443
  t2.preventDefault();
333
- const n3 = o(e2, r2, -1);
334
- e2[n3]?.focus();
444
+ const o3 = r(e2, n2, -1);
445
+ e2[o3]?.focus();
335
446
  break;
336
447
  }
337
448
  case "Enter":
338
449
  case " ":
339
- t2.preventDefault(), n2 && n2.dispatchEvent(new MouseEvent("mousedown", { bubbles: true, cancelable: true }));
450
+ t2.preventDefault(), o2 && o2.dispatchEvent(new MouseEvent("mousedown", { bubbles: true, cancelable: true }));
340
451
  }
341
452
  }
342
453
  }
343
- class v {
454
+ class y {
344
455
  element;
345
456
  timer = null;
346
457
  target = null;
347
458
  isPopupActive;
348
459
  static TOOLTIP_ID = "notectl-toolbar-tooltip";
349
460
  constructor(t2) {
350
- this.isPopupActive = t2, this.element = document.createElement("div"), this.element.className = "notectl-toolbar-tooltip", this.element.id = v.TOOLTIP_ID, this.element.setAttribute("role", "tooltip"), this.element.style.display = "none";
461
+ this.isPopupActive = t2, this.element = document.createElement("div"), this.element.className = "notectl-toolbar-tooltip", this.element.id = y.TOOLTIP_ID, this.element.setAttribute("role", "tooltip"), this.element.style.display = "none";
351
462
  }
352
463
  show(t2) {
353
464
  if (this.hide(), this.isPopupActive() || t2.disabled) return;
@@ -356,7 +467,7 @@ class v {
356
467
  if (this.isPopupActive()) return;
357
468
  this.element.textContent = e2, this.element.style.display = "";
358
469
  const o2 = t2.getRootNode();
359
- o2 instanceof ShadowRoot && !this.element.parentNode ? o2.appendChild(this.element) : o2 instanceof ShadowRoot || this.element.parentNode || document.body.appendChild(this.element), t2.setAttribute("aria-describedby", v.TOOLTIP_ID);
470
+ o2 instanceof ShadowRoot && !this.element.parentNode ? o2.appendChild(this.element) : o2 instanceof ShadowRoot || this.element.parentNode || document.body.appendChild(this.element), t2.setAttribute("aria-describedby", y.TOOLTIP_ID);
360
471
  const n2 = t2.getBoundingClientRect();
361
472
  this.element.style.position = "fixed", this.element.style.top = `${n2.bottom + 6}px`, this.element.style.left = `${n2.left + n2.width / 2}px`, this.element.style.transform = "translateX(-50%)";
362
473
  }, 500));
@@ -368,8 +479,8 @@ class v {
368
479
  this.hide(), this.element.remove();
369
480
  }
370
481
  }
371
- const w = new t("toolbar");
372
- class g {
482
+ const A = new t("toolbar");
483
+ class E {
373
484
  id = "toolbar";
374
485
  name = "Toolbar";
375
486
  priority = 10;
@@ -382,14 +493,15 @@ class g {
382
493
  focusedIndex = 0;
383
494
  tooltip = null;
384
495
  popupController = null;
496
+ popupManager = null;
385
497
  overflowController = null;
386
498
  visibleElements = [];
387
499
  locale;
388
500
  constructor(t2) {
389
- this.layoutConfig = t2 ?? null, this.overflowBehavior = t2?.overflow ?? d.BurgerMenu;
501
+ this.layoutConfig = t2 ?? null, this.overflowBehavior = t2?.overflow ?? m.BurgerMenu;
390
502
  }
391
503
  init(t2) {
392
- this.locale = e(c, t2), t2.registerStyleSheet(`
504
+ this.locale = e(h, t2), t2.registerStyleSheet(`
393
505
  /* Toolbar */
394
506
  .notectl-plugin-container--top {
395
507
  display: flex;
@@ -642,7 +754,92 @@ class g {
642
754
  background: var(--notectl-border);
643
755
  margin: 4px 0;
644
756
  }
645
- `), this.context = t2, this.popupController = new f(() => this.getActiveElement()), this.tooltip = new v(() => this.popupController?.isOpen() ?? false), t2.registerService(w, { refresh: () => this.updateButtonStates(t2.getState()), closePopup: () => this.popupController?.close() }), this.createToolbarElement();
757
+
758
+ /* Combobox-style toolbar buttons (shared base for font, fontSize, heading, etc.) */
759
+ .notectl-toolbar-btn[role="combobox"] {
760
+ width: auto;
761
+ padding: 0 8px;
762
+ gap: 4px;
763
+ border: 1px solid var(--notectl-border);
764
+ border-radius: 4px;
765
+ background: var(--notectl-bg);
766
+ }
767
+
768
+ .notectl-toolbar-btn[role="combobox"]:hover {
769
+ background: var(--notectl-hover-bg);
770
+ border-color: var(--notectl-fg-muted);
771
+ }
772
+
773
+ .notectl-toolbar-btn[role="combobox"].notectl-toolbar-btn--active {
774
+ background: var(--notectl-bg);
775
+ border-color: var(--notectl-primary-muted);
776
+ }
777
+
778
+ .notectl-toolbar-combobox__label {
779
+ flex: 1;
780
+ font-size: 13px;
781
+ font-weight: 500;
782
+ color: var(--notectl-fg);
783
+ white-space: nowrap;
784
+ overflow: hidden;
785
+ text-overflow: ellipsis;
786
+ text-align: left;
787
+ line-height: 30px;
788
+ }
789
+
790
+ .notectl-toolbar-combobox__arrow {
791
+ flex-shrink: 0;
792
+ font-size: 11px;
793
+ color: var(--notectl-fg-muted);
794
+ line-height: 30px;
795
+ }
796
+
797
+ /* Link Popup */
798
+ .notectl-link-popup {
799
+ padding: 8px;
800
+ min-width: 200px;
801
+ }
802
+
803
+ .notectl-link-popup__input {
804
+ width: 100%;
805
+ padding: 4px;
806
+ box-sizing: border-box;
807
+ border: 1px solid var(--notectl-border);
808
+ border-radius: 4px;
809
+ font-size: 13px;
810
+ color: var(--notectl-fg);
811
+ background: var(--notectl-bg);
812
+ }
813
+
814
+ .notectl-link-popup__input:focus-visible {
815
+ outline: 2px solid var(--notectl-focus-ring);
816
+ outline-offset: -1px;
817
+ }
818
+
819
+ .notectl-link-popup__button {
820
+ width: 100%;
821
+ padding: 6px 12px;
822
+ cursor: pointer;
823
+ border: 1px solid var(--notectl-border);
824
+ border-radius: 4px;
825
+ background: var(--notectl-bg);
826
+ color: var(--notectl-fg);
827
+ font-size: 13px;
828
+ }
829
+
830
+ .notectl-link-popup__button--apply {
831
+ margin-top: 4px;
832
+ }
833
+
834
+ .notectl-link-popup__button:hover {
835
+ background: var(--notectl-hover-bg);
836
+ }
837
+
838
+ .notectl-link-popup__button:focus-visible {
839
+ outline: 2px solid var(--notectl-focus-ring);
840
+ outline-offset: -1px;
841
+ }
842
+ `), this.context = t2, this.popupManager = new p(t2.getContainer()), t2.registerService(d, this.popupManager), this.popupController = new x(() => this.getActiveElement()), this.popupController.setPopupManager(this.popupManager), this.tooltip = new y(() => this.popupController?.isOpen() ?? false), t2.registerService(A, { refresh: () => this.updateButtonStates(t2.getState()), closePopup: () => this.popupController?.close() }), this.createToolbarElement();
646
843
  }
647
844
  getOverflowBehavior() {
648
845
  return this.overflowBehavior;
@@ -654,7 +851,7 @@ class g {
654
851
  this.renderItems();
655
852
  }
656
853
  destroy() {
657
- this.overflowController?.destroy(), this.overflowController = null, this.popupController?.destroy(), this.popupController = null, this.tooltip?.destroy(), this.tooltip = null, this.toolbarElement && (this.toolbarElement.remove(), this.toolbarElement = null), this.buttons = [], this.visibleElements = [], this.context = null;
854
+ this.overflowController?.destroy(), this.overflowController = null, this.popupController?.destroy(), this.popupController = null, this.popupManager?.destroy(), this.popupManager = null, this.tooltip?.destroy(), this.tooltip = null, this.toolbarElement && (this.toolbarElement.remove(), this.toolbarElement = null), this.buttons = [], this.visibleElements = [], this.context = null;
658
855
  }
659
856
  onStateChange(t2, e2, o2) {
660
857
  this.updateButtonStates(e2);
@@ -673,7 +870,7 @@ class g {
673
870
  this.toolbarElement = document.createElement("div"), this.toolbarElement.setAttribute("role", "toolbar"), this.toolbarElement.setAttribute("aria-label", this.locale.formattingOptionsAria), this.toolbarElement.setAttribute("data-notectl-no-print", ""), this.toolbarElement.className = "notectl-toolbar", this.toolbarElement.addEventListener("keydown", (t3) => this.handleToolbarKeydown(t3)), this.applyOverflowBehavior(), t2.appendChild(this.toolbarElement);
674
871
  }
675
872
  applyOverflowBehavior() {
676
- this.toolbarElement && this.context && (this.overflowController?.destroy(), this.overflowController = null, this.toolbarElement.setAttribute("data-overflow", this.overflowBehavior), this.overflowBehavior === d.BurgerMenu ? this.overflowController = new u({ toolbar: this.toolbarElement, ariaLabel: this.locale.moreToolsAria, context: this.context, onOverflowChange: (t2, e2) => {
873
+ this.toolbarElement && this.context && (this.overflowController?.destroy(), this.overflowController = null, this.toolbarElement.setAttribute("data-overflow", this.overflowBehavior), this.overflowBehavior === m.BurgerMenu ? this.overflowController = new v({ toolbar: this.toolbarElement, ariaLabel: this.locale.moreToolsAria, context: this.context, popupManager: this.popupManager ?? void 0, onOverflowChange: (t2, e2) => {
677
874
  this.visibleElements = e2 ? [...t2, e2] : [...t2], this.initRovingTabindex();
678
875
  }, onItemActivated: (t2, e2) => {
679
876
  this.activateButton(t2, e2);
@@ -691,12 +888,12 @@ class g {
691
888
  return this.visibleElements.length > 0 ? this.visibleElements : this.buttons.map((t2) => t2.element);
692
889
  }
693
890
  initRovingTabindex() {
694
- const t2 = this.getTabElements(), e2 = r(t2);
695
- this.focusedIndex = e2 >= 0 ? e2 : 0, i(t2, this.focusedIndex);
891
+ const t2 = this.getTabElements(), e2 = s(t2);
892
+ this.focusedIndex = e2 >= 0 ? e2 : 0, l(t2, this.focusedIndex);
696
893
  }
697
894
  setRovingFocus(t2) {
698
895
  const e2 = this.getTabElements();
699
- t2 < 0 || t2 >= e2.length || (this.focusedIndex = t2, i(e2, t2), e2[t2]?.focus());
896
+ t2 < 0 || t2 >= e2.length || (this.focusedIndex = t2, l(e2, t2), e2[t2]?.focus());
700
897
  }
701
898
  getActiveElement() {
702
899
  const t2 = this.toolbarElement?.getRootNode();
@@ -711,25 +908,25 @@ class g {
711
908
  if (0 !== e2.length) switch (this.syncFocusedIndex(), t2.key) {
712
909
  case "ArrowRight": {
713
910
  t2.preventDefault();
714
- const o2 = l(e2, this.focusedIndex, 1);
911
+ const o2 = c(e2, this.focusedIndex, 1);
715
912
  this.setRovingFocus(o2);
716
913
  break;
717
914
  }
718
915
  case "ArrowLeft": {
719
916
  t2.preventDefault();
720
- const o2 = l(e2, this.focusedIndex, -1);
917
+ const o2 = c(e2, this.focusedIndex, -1);
721
918
  this.setRovingFocus(o2);
722
919
  break;
723
920
  }
724
921
  case "Home": {
725
922
  t2.preventDefault();
726
- const o2 = r(e2);
923
+ const o2 = s(e2);
727
924
  o2 >= 0 && this.setRovingFocus(o2);
728
925
  break;
729
926
  }
730
927
  case "End": {
731
928
  t2.preventDefault();
732
- const o2 = s(e2);
929
+ const o2 = a(e2);
733
930
  o2 >= 0 && this.setRovingFocus(o2);
734
931
  break;
735
932
  }
@@ -756,7 +953,7 @@ class g {
756
953
  o3.sort((t3, e4) => (t3.priority ?? 100) - (e4.priority ?? 100)), n2.push(...o3);
757
954
  }
758
955
  if (0 !== n2.length) {
759
- e2 || this.toolbarElement.appendChild(b()), e2 = false;
956
+ e2 || this.toolbarElement.appendChild(w()), e2 = false;
760
957
  for (const t3 of n2) {
761
958
  const e3 = this.createButton(t3);
762
959
  this.toolbarElement.appendChild(e3.element), this.buttons.push(e3);
@@ -774,7 +971,7 @@ class g {
774
971
  const o2 = e2[t3];
775
972
  if (!o2) continue;
776
973
  const n2 = this.createButton(o2);
777
- this.toolbarElement.appendChild(n2.element), this.buttons.push(n2), o2.separatorAfter && t3 < e2.length - 1 && this.toolbarElement.appendChild(b());
974
+ this.toolbarElement.appendChild(n2.element), this.buttons.push(n2), o2.separatorAfter && t3 < e2.length - 1 && this.toolbarElement.appendChild(w());
778
975
  }
779
976
  else {
780
977
  const t3 = /* @__PURE__ */ new Map();
@@ -784,7 +981,7 @@ class g {
784
981
  }
785
982
  let o2 = true;
786
983
  for (const [, e3] of t3) {
787
- o2 || this.toolbarElement.appendChild(b()), o2 = false;
984
+ o2 || this.toolbarElement.appendChild(w()), o2 = false;
788
985
  for (const t4 of e3) {
789
986
  const e4 = this.createButton(t4);
790
987
  this.toolbarElement.appendChild(e4.element), this.buttons.push(e4);
@@ -794,25 +991,40 @@ class g {
794
991
  }
795
992
  createButton(t2) {
796
993
  const e2 = document.createElement("button");
797
- e2.type = "button", e2.className = `notectl-toolbar-btn notectl-toolbar-btn--${t2.id}`, e2.setAttribute("aria-pressed", "false"), e2.setAttribute("aria-label", t2.label), e2.setAttribute("data-toolbar-item", t2.id), e2.setAttribute("data-tooltip", t2.tooltip ?? t2.label), t2.popupType && (e2.setAttribute("aria-haspopup", "true"), e2.setAttribute("aria-expanded", "false"));
798
- const o2 = document.createElement("span");
799
- return o2.className = "notectl-toolbar-btn__icon", o2.innerHTML = t2.icon, e2.appendChild(o2), e2.addEventListener("mousedown", (o3) => {
994
+ e2.type = "button", e2.className = `notectl-toolbar-btn notectl-toolbar-btn--${t2.id}`, e2.setAttribute("aria-pressed", "false"), e2.setAttribute("aria-label", t2.label), e2.setAttribute("data-toolbar-item", t2.id), e2.setAttribute("data-tooltip", t2.tooltip ?? t2.label);
995
+ let o2 = null;
996
+ if ("combobox" === t2.popupType) {
997
+ e2.setAttribute("role", "combobox"), e2.setAttribute("aria-haspopup", "listbox"), e2.setAttribute("aria-expanded", "false");
998
+ const n2 = document.createElement("span");
999
+ n2.className = "notectl-toolbar-combobox__label";
1000
+ const r2 = this.context?.getState();
1001
+ r2 && (n2.textContent = t2.getLabel(r2)), e2.appendChild(n2), o2 = n2;
1002
+ const i2 = document.createElement("span");
1003
+ i2.className = "notectl-toolbar-combobox__arrow", i2.setAttribute("aria-hidden", "true"), i2.textContent = "▾", e2.appendChild(i2);
1004
+ } else {
1005
+ t2.popupType && (e2.setAttribute("aria-haspopup", "true"), e2.setAttribute("aria-expanded", "false"));
1006
+ const o3 = document.createElement("span");
1007
+ o3.className = "notectl-toolbar-btn__icon", o3.innerHTML = t2.icon, e2.appendChild(o3);
1008
+ }
1009
+ return e2.addEventListener("mousedown", (o3) => {
800
1010
  o3.preventDefault(), this.activateButton(e2, t2);
801
- }), e2.addEventListener("mouseenter", () => this.tooltip?.show(e2)), e2.addEventListener("mouseleave", () => this.tooltip?.hide()), e2.addEventListener("focus", () => this.tooltip?.show(e2)), e2.addEventListener("blur", () => this.tooltip?.hide()), { element: e2, item: t2 };
1011
+ }), e2.addEventListener("mouseenter", () => this.tooltip?.show(e2)), e2.addEventListener("mouseleave", () => this.tooltip?.hide()), e2.addEventListener("focus", () => this.tooltip?.show(e2)), e2.addEventListener("blur", () => this.tooltip?.hide()), { element: e2, item: t2, comboLabelEl: o2 };
802
1012
  }
803
1013
  updateButtonStates(t2) {
804
1014
  for (const e2 of this.buttons) {
805
1015
  const o2 = e2.item.isActive?.(t2) ?? false, n2 = e2.item.isEnabled?.(t2) ?? true;
806
- e2.element.setAttribute("aria-pressed", String(o2)), e2.element.classList.toggle("notectl-toolbar-btn--active", o2), e2.element.disabled = !n2, n2 ? e2.element.removeAttribute("aria-disabled") : e2.element.setAttribute("aria-disabled", "true");
1016
+ e2.element.setAttribute("aria-pressed", String(o2)), e2.element.classList.toggle("notectl-toolbar-btn--active", o2), e2.element.disabled = !n2, n2 ? e2.element.removeAttribute("aria-disabled") : e2.element.setAttribute("aria-disabled", "true"), e2.comboLabelEl && "combobox" === e2.item.popupType && (e2.comboLabelEl.textContent = e2.item.getLabel(t2));
807
1017
  }
808
1018
  this.overflowController?.updateItemStates(t2);
809
1019
  }
810
1020
  }
811
1021
  export {
812
- g as T,
813
- w as a,
814
- c as b,
815
- a as c,
816
- d
1022
+ p as P,
1023
+ E as T,
1024
+ A as a,
1025
+ d as b,
1026
+ h as c,
1027
+ u as d,
1028
+ m as e
817
1029
  };
818
- //# sourceMappingURL=ToolbarPlugin-B6JETWaw.mjs.map
1030
+ //# sourceMappingURL=ToolbarPlugin-B7oJRzpl.mjs.map