@notectl/core 1.7.0 → 1.7.2

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 (218) hide show
  1. package/README.md +2 -2
  2. package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs → AttrRegistry-D9Jx_RVb.mjs} +2 -2
  3. package/dist/chunks/{AttrRegistry-I-VdmRnN.mjs.map → AttrRegistry-D9Jx_RVb.mjs.map} +1 -1
  4. package/dist/chunks/AttributedMarkCommands-BtLea72z.mjs +80 -0
  5. package/dist/chunks/AttributedMarkCommands-BtLea72z.mjs.map +1 -0
  6. package/dist/chunks/{CaretNavigation-CAJXoaae.mjs → CaretNavigation-7JYpIKbs.mjs} +56 -56
  7. package/dist/chunks/{CaretNavigation-CAJXoaae.mjs.map → CaretNavigation-7JYpIKbs.mjs.map} +1 -1
  8. package/dist/chunks/ColorGrid-Dneqb8if.mjs +81 -0
  9. package/dist/chunks/ColorGrid-Dneqb8if.mjs.map +1 -0
  10. package/dist/chunks/ColorPickerPopup-CiCLBbe9.mjs +37 -0
  11. package/dist/chunks/ColorPickerPopup-CiCLBbe9.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-Brtw2jL1.mjs} +18 -18
  15. package/dist/chunks/{Document-CuwE73FF.mjs.map → Document-Brtw2jL1.mjs.map} +1 -1
  16. package/dist/chunks/MarkCommands-6RUJ4L3r.mjs +94 -0
  17. package/dist/chunks/MarkCommands-6RUJ4L3r.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-C2XYkeOi.mjs} +2 -2
  21. package/dist/chunks/{NodeResolver-B-wzthAQ.mjs.map → NodeResolver-C2XYkeOi.mjs.map} +1 -1
  22. package/dist/chunks/PopupPositioning-BTT-_pQ3.mjs +32 -0
  23. package/dist/chunks/PopupPositioning-BTT-_pQ3.mjs.map +1 -0
  24. package/dist/chunks/RangeIterator-Bh4Vl_6D.mjs +16 -0
  25. package/dist/chunks/RangeIterator-Bh4Vl_6D.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/StyleRuntime-ChRjVQwL.mjs +239 -0
  29. package/dist/chunks/StyleRuntime-ChRjVQwL.mjs.map +1 -0
  30. package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -1
  31. package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs → ToolbarKeyboardNav-DhpL8zNV.mjs} +3 -3
  32. package/dist/chunks/{ToolbarKeyboardNav-B32OMv8r.mjs.map → ToolbarKeyboardNav-DhpL8zNV.mjs.map} +1 -1
  33. package/dist/chunks/{ToolbarPlugin-B6JETWaw.mjs → ToolbarPlugin-DpLVJ71w.mjs} +348 -135
  34. package/dist/chunks/ToolbarPlugin-DpLVJ71w.mjs.map +1 -0
  35. package/dist/chunks/index--n1RGpq-.mjs +171 -0
  36. package/dist/chunks/index--n1RGpq-.mjs.map +1 -0
  37. package/dist/chunks/index-4or5UzNO.mjs +168 -0
  38. package/dist/chunks/index-4or5UzNO.mjs.map +1 -0
  39. package/dist/chunks/{index-pxbbDHVH.mjs → index-ABlTDvEX.mjs} +20 -19
  40. package/dist/chunks/index-ABlTDvEX.mjs.map +1 -0
  41. package/dist/chunks/{index--z_Txzej.mjs → index-BAke7kNL.mjs} +45 -45
  42. package/dist/chunks/{index--z_Txzej.mjs.map → index-BAke7kNL.mjs.map} +1 -1
  43. package/dist/chunks/{index-DMt3ojrY.mjs → index-BXtw5PNN.mjs} +2 -2
  44. package/dist/chunks/{index-DMt3ojrY.mjs.map → index-BXtw5PNN.mjs.map} +1 -1
  45. package/dist/chunks/{index-FlTg80Pk.mjs → index-BhDXjueu.mjs} +285 -325
  46. package/dist/chunks/index-BhDXjueu.mjs.map +1 -0
  47. package/dist/chunks/{index-D0s0Q8Wc.mjs → index-BqNUfq-y.mjs} +43 -35
  48. package/dist/chunks/index-BqNUfq-y.mjs.map +1 -0
  49. package/dist/chunks/{index-CflvcXSd.mjs → index-BvqkuEY1.mjs} +21 -17
  50. package/dist/chunks/index-BvqkuEY1.mjs.map +1 -0
  51. package/dist/chunks/{index-C9gc3Bws.mjs → index-C1opJocO.mjs} +32 -32
  52. package/dist/chunks/{index-C9gc3Bws.mjs.map → index-C1opJocO.mjs.map} +1 -1
  53. package/dist/chunks/index-CWltg1wK.mjs +124 -0
  54. package/dist/chunks/index-CWltg1wK.mjs.map +1 -0
  55. package/dist/chunks/{index-D8tbbW97.mjs → index-Cd3uJLP3.mjs} +2 -2
  56. package/dist/chunks/{index-D8tbbW97.mjs.map → index-Cd3uJLP3.mjs.map} +1 -1
  57. package/dist/chunks/{index-C0cEs7Jc.mjs → index-CluzpB2b.mjs} +10 -10
  58. package/dist/chunks/{index-C0cEs7Jc.mjs.map → index-CluzpB2b.mjs.map} +1 -1
  59. package/dist/chunks/{index-CoeD4T9-.mjs → index-D3NlpmT1.mjs} +15 -11
  60. package/dist/chunks/index-D3NlpmT1.mjs.map +1 -0
  61. package/dist/chunks/{index-CAV2N-fF.mjs → index-D515iymW.mjs} +75 -74
  62. package/dist/chunks/{index-CAV2N-fF.mjs.map → index-D515iymW.mjs.map} +1 -1
  63. package/dist/chunks/{index-B-NSeaM4.mjs → index-Dk49P9N4.mjs} +2 -2
  64. package/dist/chunks/{index-B-NSeaM4.mjs.map → index-Dk49P9N4.mjs.map} +1 -1
  65. package/dist/chunks/index-DyzigvbZ.mjs +410 -0
  66. package/dist/chunks/index-DyzigvbZ.mjs.map +1 -0
  67. package/dist/chunks/index-ErZ5_a1o.mjs +296 -0
  68. package/dist/chunks/index-ErZ5_a1o.mjs.map +1 -0
  69. package/dist/chunks/{index-CNs4QQ8l.mjs → index-fsVJLutn.mjs} +52 -64
  70. package/dist/chunks/index-fsVJLutn.mjs.map +1 -0
  71. package/dist/commands/AttributedMarkCommands.d.ts +46 -0
  72. package/dist/commands/AttributedMarkCommands.d.ts.map +1 -0
  73. package/dist/commands/CommandHelpers.d.ts +21 -0
  74. package/dist/commands/CommandHelpers.d.ts.map +1 -0
  75. package/dist/commands/Commands.d.ts +2 -8
  76. package/dist/commands/Commands.d.ts.map +1 -1
  77. package/dist/commands/DeleteCommands.d.ts.map +1 -1
  78. package/dist/commands/GapCursorCommands.d.ts.map +1 -1
  79. package/dist/commands/NodeSelectionCommands.d.ts.map +1 -1
  80. package/dist/commands/PasteCommand.d.ts.map +1 -1
  81. package/dist/commands/RangeIterator.d.ts +10 -0
  82. package/dist/commands/RangeIterator.d.ts.map +1 -0
  83. package/dist/editor/DocumentParser.d.ts.map +1 -1
  84. package/dist/editor/DocumentSerializer.d.ts +2 -0
  85. package/dist/editor/DocumentSerializer.d.ts.map +1 -1
  86. package/dist/editor/EditorThemeController.d.ts +3 -0
  87. package/dist/editor/EditorThemeController.d.ts.map +1 -1
  88. package/dist/editor/MarkSerializer.d.ts +11 -0
  89. package/dist/editor/MarkSerializer.d.ts.map +1 -0
  90. package/dist/editor/NotectlEditor.d.ts +19 -3
  91. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  92. package/dist/editor/PaperLayoutController.d.ts +2 -0
  93. package/dist/editor/PaperLayoutController.d.ts.map +1 -1
  94. package/dist/editor/styles/font-select.d.ts +1 -1
  95. package/dist/editor/styles/font-select.d.ts.map +1 -1
  96. package/dist/editor/styles/font-size-select.d.ts +1 -1
  97. package/dist/editor/styles/font-size-select.d.ts.map +1 -1
  98. package/dist/editor/styles/heading-select.d.ts +1 -1
  99. package/dist/editor/styles/heading-select.d.ts.map +1 -1
  100. package/dist/editor/styles/toolbar.d.ts +1 -1
  101. package/dist/editor/styles/toolbar.d.ts.map +1 -1
  102. package/dist/index.d.ts +9 -2
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/input/ClipboardHandler.d.ts +0 -2
  105. package/dist/input/ClipboardHandler.d.ts.map +1 -1
  106. package/dist/input/LegacyHTMLNormalizer.d.ts.map +1 -1
  107. package/dist/model/MarkSpec.d.ts +6 -0
  108. package/dist/model/MarkSpec.d.ts.map +1 -1
  109. package/dist/notectl-core.mjs +2244 -2095
  110. package/dist/notectl-core.mjs.map +1 -1
  111. package/dist/notectl-core.umd.js +2862 -2415
  112. package/dist/notectl-core.umd.js.map +1 -1
  113. package/dist/plugins/PluginManager.d.ts +2 -0
  114. package/dist/plugins/PluginManager.d.ts.map +1 -1
  115. package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
  116. package/dist/plugins/alignment.mjs +1 -1
  117. package/dist/plugins/blockquote.mjs +1 -1
  118. package/dist/plugins/caret-navigation.mjs +1 -1
  119. package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
  120. package/dist/plugins/code-block.mjs +1 -1
  121. package/dist/plugins/font/FontPlugin.d.ts +0 -6
  122. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  123. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -1
  124. package/dist/plugins/font-size/FontSizePlugin.d.ts +0 -5
  125. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
  126. package/dist/plugins/font-size.mjs +1 -1
  127. package/dist/plugins/font.mjs +1 -1
  128. package/dist/plugins/gap-cursor.mjs +2 -2
  129. package/dist/plugins/hard-break.mjs +2 -25
  130. package/dist/plugins/hard-break.mjs.map +1 -1
  131. package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +1 -7
  132. package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -1
  133. package/dist/plugins/heading/HeadingPlugin.d.ts +0 -6
  134. package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
  135. package/dist/plugins/heading.mjs +1 -1
  136. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  137. package/dist/plugins/highlight.mjs +1 -1
  138. package/dist/plugins/horizontal-rule.mjs +1 -1
  139. package/dist/plugins/image/ImageNodeView.d.ts.map +1 -1
  140. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
  141. package/dist/plugins/image.mjs +1 -1
  142. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  143. package/dist/plugins/link.mjs +1 -1
  144. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  145. package/dist/plugins/list.mjs +1 -1
  146. package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -1
  147. package/dist/plugins/shared/ColorGrid.d.ts +25 -0
  148. package/dist/plugins/shared/ColorGrid.d.ts.map +1 -0
  149. package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -1
  150. package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
  151. package/dist/plugins/shared/ColorValidation.d.ts +13 -2
  152. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -1
  153. package/dist/plugins/shared/PopupKeyboardPatterns.d.ts +43 -0
  154. package/dist/plugins/shared/PopupKeyboardPatterns.d.ts.map +1 -0
  155. package/dist/plugins/shared/PopupManager.d.ts +45 -0
  156. package/dist/plugins/shared/PopupManager.d.ts.map +1 -0
  157. package/dist/plugins/shared/PopupPositioning.d.ts +21 -0
  158. package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -0
  159. package/dist/plugins/strikethrough.mjs +1 -1
  160. package/dist/plugins/super-sub.mjs +1 -1
  161. package/dist/plugins/table/TableBorderColor.d.ts.map +1 -1
  162. package/dist/plugins/table/TableContextMenu.d.ts +2 -1
  163. package/dist/plugins/table/TableContextMenu.d.ts.map +1 -1
  164. package/dist/plugins/table/TableControls.d.ts.map +1 -1
  165. package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
  166. package/dist/plugins/table/TableControlsLayout.d.ts.map +1 -1
  167. package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
  168. package/dist/plugins/table.mjs +1 -1
  169. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  170. package/dist/plugins/text-color.mjs +1 -1
  171. package/dist/plugins/text-formatting.mjs +1 -1
  172. package/dist/plugins/toolbar/ToolbarItem.d.ts +11 -2
  173. package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
  174. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +5 -1
  175. package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
  176. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
  177. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  178. package/dist/plugins/toolbar/ToolbarPopupController.d.ts +9 -1
  179. package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
  180. package/dist/plugins/toolbar/ToolbarRenderers.d.ts.map +1 -1
  181. package/dist/plugins/toolbar/ToolbarTooltip.d.ts.map +1 -1
  182. package/dist/plugins/toolbar/index.d.ts +1 -1
  183. package/dist/plugins/toolbar/index.d.ts.map +1 -1
  184. package/dist/plugins/toolbar.mjs +1 -1
  185. package/dist/state/BlockTreeOps.d.ts +21 -0
  186. package/dist/state/BlockTreeOps.d.ts.map +1 -0
  187. package/dist/state/InlineContentOps.d.ts +37 -0
  188. package/dist/state/InlineContentOps.d.ts.map +1 -0
  189. package/dist/state/StepApplication.d.ts.map +1 -1
  190. package/dist/style/StyleRuntime.d.ts +38 -0
  191. package/dist/style/StyleRuntime.d.ts.map +1 -0
  192. package/dist/test/PluginTestUtils.d.ts +4 -0
  193. package/dist/test/PluginTestUtils.d.ts.map +1 -1
  194. package/dist/view/Reconciler.d.ts.map +1 -1
  195. package/package.json +2 -2
  196. package/dist/chunks/ColorNames-BdsHwA2f.mjs +0 -59
  197. package/dist/chunks/ColorNames-BdsHwA2f.mjs.map +0 -1
  198. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs +0 -125
  199. package/dist/chunks/ColorPickerPopup-xL8ZUfpB.mjs.map +0 -1
  200. package/dist/chunks/Commands-CicwYoTQ.mjs +0 -286
  201. package/dist/chunks/Commands-CicwYoTQ.mjs.map +0 -1
  202. package/dist/chunks/MarkCommands-CC37WA7Z.mjs +0 -94
  203. package/dist/chunks/MarkCommands-CC37WA7Z.mjs.map +0 -1
  204. package/dist/chunks/ToolbarPlugin-B6JETWaw.mjs.map +0 -1
  205. package/dist/chunks/index-B9GkDVsx.mjs +0 -187
  206. package/dist/chunks/index-B9GkDVsx.mjs.map +0 -1
  207. package/dist/chunks/index-CKPrAOr6.mjs +0 -209
  208. package/dist/chunks/index-CKPrAOr6.mjs.map +0 -1
  209. package/dist/chunks/index-CNs4QQ8l.mjs.map +0 -1
  210. package/dist/chunks/index-CflvcXSd.mjs.map +0 -1
  211. package/dist/chunks/index-CoeD4T9-.mjs.map +0 -1
  212. package/dist/chunks/index-D0s0Q8Wc.mjs.map +0 -1
  213. package/dist/chunks/index-DfzCof6H.mjs +0 -191
  214. package/dist/chunks/index-DfzCof6H.mjs.map +0 -1
  215. package/dist/chunks/index-DyIwN_67.mjs +0 -404
  216. package/dist/chunks/index-DyIwN_67.mjs.map +0 -1
  217. package/dist/chunks/index-FlTg80Pk.mjs.map +0 -1
  218. package/dist/chunks/index-pxbbDHVH.mjs.map +0 -1
@@ -1,21 +1,93 @@
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-BTT-_pQ3.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
+ import { s as d, a as p } from "./StyleRuntime-ChRjVQwL.mjs";
5
+ const u = new t("popup");
6
+ class h {
7
+ stack = [];
8
+ referenceNode;
9
+ constructor(t2) {
10
+ this.referenceNode = t2;
11
+ }
12
+ open(t2) {
13
+ const e2 = document.createElement("div");
14
+ 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);
15
+ const r2 = { close: () => this.closeEntry(c2), getElement: () => e2 };
16
+ t2.content(e2, () => this.closeEntry(c2));
17
+ const i2 = t2.referenceNode ?? this.referenceNode;
18
+ o(e2, i2);
19
+ const s2 = t2.anchor instanceof HTMLElement ? t2.anchor.getBoundingClientRect() : t2.anchor;
20
+ n(e2, s2, { position: t2.position ?? "below-start" });
21
+ const l2 = t2.parent ? this.findEntryByHandle(t2.parent) : null, a2 = (o2) => {
22
+ const n2 = o2.composedPath();
23
+ if (!n2.includes(e2)) {
24
+ for (const t3 of this.stack) if (n2.includes(t3.element)) return;
25
+ t2.anchor instanceof HTMLElement && n2.includes(t2.anchor) || this.closeEntry(c2);
26
+ }
27
+ }, c2 = { element: e2, config: t2, clickOutsideHandler: a2, parent: l2 };
28
+ return this.stack.push(c2), setTimeout(() => {
29
+ document.addEventListener("mousedown", a2);
30
+ }, 0), this.focusFirstItem(e2), r2;
31
+ }
32
+ close() {
33
+ const t2 = this.stack[this.stack.length - 1];
34
+ t2 && this.closeEntry(t2);
35
+ }
36
+ closeAll() {
37
+ for (; this.stack.length > 0; ) {
38
+ const t2 = this.stack[this.stack.length - 1];
39
+ t2 && this.closeEntry(t2);
40
+ }
41
+ }
42
+ isOpen() {
43
+ return this.stack.length > 0;
44
+ }
45
+ destroy() {
46
+ this.closeAll();
47
+ }
48
+ closeEntry(t2) {
49
+ const e2 = this.stack.indexOf(t2);
50
+ if (-1 !== e2) {
51
+ for (; this.stack.length > e2 + 1; ) {
52
+ const t3 = this.stack[this.stack.length - 1];
53
+ t3 && this.removeEntry(t3);
54
+ }
55
+ this.removeEntry(t2), t2.config.restoreFocusTo && t2.config.restoreFocusTo.focus(), t2.config.onClose?.();
56
+ }
57
+ }
58
+ removeEntry(t2) {
59
+ const e2 = this.stack.indexOf(t2);
60
+ -1 !== e2 && (this.stack.splice(e2, 1), t2.element.remove(), document.removeEventListener("mousedown", t2.clickOutsideHandler));
61
+ }
62
+ findEntryByHandle(t2) {
63
+ const e2 = t2.getElement();
64
+ return this.stack.find((t3) => t3.element === e2) ?? null;
65
+ }
66
+ focusFirstItem(t2) {
67
+ requestAnimationFrame(() => {
68
+ const e2 = t2.querySelector('[role="menuitem"]') ?? t2.querySelector('[role="option"]') ?? t2.querySelector('[role="gridcell"]') ?? t2.querySelector("input") ?? t2.querySelector("button");
69
+ e2?.focus();
70
+ });
71
+ }
72
+ }
73
+ const m = { formattingOptionsAria: "Formatting options", moreToolsAria: "More tools" }, b = { en: m, 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: "और उपकरण" } }, f = { BurgerMenu: "burger-menu", Flow: "flow", None: "none" }, v = "notectl-toolbar-btn--overflow-hidden", g = "notectl-toolbar-separator--overflow-hidden";
74
+ class w {
5
75
  toolbar;
6
76
  context;
7
77
  onOverflowChange;
8
78
  onItemActivated;
9
79
  getActiveElement;
10
80
  ariaLabel;
81
+ popupManager;
11
82
  entries = [];
12
83
  overflowButton = null;
13
84
  overflowDropdown = null;
85
+ overflowHandle = null;
14
86
  overflowEntries = [];
15
87
  resizeObserver = null;
16
88
  closeHandler = null;
17
89
  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);
90
+ 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
91
  }
20
92
  update(t2) {
21
93
  this.entries = t2.map((t3) => ({ element: t3.element, item: t3.item })), this.recalculate();
@@ -23,30 +95,30 @@ class u {
23
95
  recalculate() {
24
96
  if (0 === this.entries.length) return;
25
97
  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);
98
+ const t2 = this.measureAvailableWidth(), e2 = Array.from(this.toolbar.children), o2 = this.measureChildWidths(e2), n2 = t2 - 34 - 2;
99
+ let r2 = 0, i2 = false;
100
+ const s2 = [];
101
+ for (const t3 of e2) {
102
+ if (t3 === this.overflowButton) continue;
103
+ if (t3.classList.contains("notectl-toolbar-separator")) {
104
+ if (i2) {
105
+ t3.classList.add(g);
34
106
  continue;
35
107
  }
36
- const n3 = i2.offsetWidth + 2;
37
- e2 + n3 > t2 ? (o2 = true, i2.classList.add(h)) : e2 += n3;
108
+ const e4 = (o2.get(t3) ?? 0) + 2;
109
+ r2 + e4 > n2 ? (i2 = true, t3.classList.add(g)) : r2 += e4;
38
110
  continue;
39
111
  }
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);
112
+ const e3 = this.entries.find((e4) => e4.element === t3);
113
+ if (!e3) continue;
114
+ if (i2) {
115
+ e3.element.classList.add(v), s2.push(e3);
44
116
  continue;
45
117
  }
46
- const s2 = r3.element.offsetWidth + 2;
47
- e2 + s2 > t2 ? (o2 = true, r3.element.classList.add(p), n2.push(r3)) : e2 += s2;
118
+ const l2 = (o2.get(t3) ?? 0) + 2;
119
+ r2 + l2 > n2 ? (i2 = true, e3.element.classList.add(v), s2.push(e3)) : r2 += l2;
48
120
  }
49
- this.overflowEntries = n2, this.hideTrailingSeparators(), this.setOverflowButtonVisible(n2.length > 0), this.notifyChange();
121
+ this.overflowEntries = s2, this.hideTrailingSeparators(), this.setOverflowButtonVisible(s2.length > 0), this.notifyChange();
50
122
  }
51
123
  updateItemStates(t2) {
52
124
  if (!this.overflowDropdown) return;
@@ -55,20 +127,28 @@ class u {
55
127
  const e3 = o2.getAttribute("data-toolbar-item"), n2 = this.overflowEntries.find((t3) => t3.item.id === e3);
56
128
  if (!n2) continue;
57
129
  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;
130
+ if (o2.classList.toggle("notectl-dropdown__item--active", r2), o2.disabled = !i2, "combobox" === n2.item.popupType) {
131
+ const e4 = o2.querySelector(".notectl-dropdown__item-label");
132
+ e4 && (e4.textContent = n2.item.getLabel(t2));
133
+ }
59
134
  }
60
135
  }
61
136
  destroy() {
62
137
  this.resizeObserver?.disconnect(), this.resizeObserver = null, this.closeDropdown(), this.overflowButton?.remove(), this.overflowButton = null, this.entries = [], this.overflowEntries = [];
63
138
  }
139
+ measureChildWidths(t2) {
140
+ const e2 = /* @__PURE__ */ new Map();
141
+ for (const o2 of t2) o2 !== this.overflowButton && e2.set(o2, o2.offsetWidth);
142
+ return e2;
143
+ }
64
144
  measureAvailableWidth() {
65
145
  const t2 = getComputedStyle(this.toolbar), e2 = Number.parseFloat(t2.paddingLeft) || 0, o2 = Number.parseFloat(t2.paddingRight) || 0;
66
146
  return this.toolbar.clientWidth - e2 - o2;
67
147
  }
68
148
  resetVisibility() {
69
- for (const t3 of this.entries) t3.element.classList.remove(p);
149
+ for (const t3 of this.entries) t3.element.classList.remove(v);
70
150
  const t2 = Array.from(this.toolbar.querySelectorAll(".notectl-toolbar-separator"));
71
- for (const e2 of t2) e2.classList.remove(h);
151
+ for (const e2 of t2) e2.classList.remove(g);
72
152
  }
73
153
  setOverflowButtonVisible(t2) {
74
154
  this.overflowButton && (this.overflowButton.classList.toggle("notectl-toolbar-overflow-btn--hidden", !t2), t2 || this.overflowButton.removeAttribute("tabindex"));
@@ -86,38 +166,37 @@ class u {
86
166
  openDropdown() {
87
167
  if (!this.overflowButton || 0 === this.overflowEntries.length) return;
88
168
  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(() => {
169
+ 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: () => {
170
+ this.overflowHandle = null, this.overflowDropdown = null, this.overflowButton && this.overflowButton.setAttribute("aria-expanded", "false");
171
+ }, content: (t3) => {
172
+ this.renderDropdownItems(t3, this.context.getState()), this.overflowDropdown = t3, t3.addEventListener("keydown", (t4) => this.handleDropdownKeydown(t4));
173
+ } }), this.overflowButton.setAttribute("aria-expanded", "true")) : (this.positionDropdown(t2), o(t2, this.overflowButton), this.overflowDropdown = t2, this.overflowButton.setAttribute("aria-expanded", "true"), requestAnimationFrame(() => {
90
174
  const e2 = t2.querySelector('[role="menuitem"]');
91
175
  e2?.focus();
92
- }), t2.addEventListener("keydown", (t3) => this.handleDropdownKeydown(t3)), this.registerCloseHandler();
176
+ }), t2.addEventListener("keydown", (t3) => this.handleDropdownKeydown(t3)), this.registerCloseHandler());
93
177
  }
94
- renderDropdownItems(t2) {
95
- let e2 = null;
96
- for (const o2 of this.overflowEntries) {
97
- if (null !== e2 && o2.item.group !== e2) {
178
+ renderDropdownItems(t2, e2) {
179
+ let o2 = null;
180
+ for (const n2 of this.overflowEntries) {
181
+ if (null !== o2 && n2.item.group !== o2) {
98
182
  const e3 = document.createElement("div");
99
183
  e3.className = "notectl-dropdown__separator", e3.setAttribute("role", "separator"), t2.appendChild(e3);
100
184
  }
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);
185
+ o2 = n2.item.group;
186
+ const r2 = document.createElement("button");
187
+ 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
188
  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);
189
+ i2.className = "notectl-dropdown__item-icon", "combobox" !== n2.item.popupType && (i2.innerHTML = n2.item.icon), r2.appendChild(i2);
190
+ const s2 = document.createElement("span");
191
+ 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) => {
192
+ t3.preventDefault(), t3.stopPropagation(), this.activateOverflowItem(n2);
193
+ }), t2.appendChild(r2);
110
194
  }
111
195
  }
112
196
  positionDropdown(t2) {
113
197
  if (!this.overflowButton) return;
114
198
  const e2 = this.overflowButton.getBoundingClientRect(), o2 = window.innerWidth - e2.right;
115
- 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
- }
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);
199
+ d(t2, { position: "fixed", top: `${e2.bottom + 2}px`, right: `${o2}px`, left: "auto", zIndex: "10000" });
121
200
  }
122
201
  registerCloseHandler() {
123
202
  this.closeHandler = (t2) => {
@@ -128,6 +207,10 @@ class u {
128
207
  }, 0);
129
208
  }
130
209
  closeDropdown() {
210
+ if (this.overflowHandle) {
211
+ const t2 = this.overflowHandle;
212
+ return this.overflowHandle = null, this.overflowDropdown = null, t2.close(), void (this.overflowButton && this.overflowButton.setAttribute("aria-expanded", "false"));
213
+ }
131
214
  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
215
  }
133
216
  activateOverflowItem(t2) {
@@ -136,26 +219,26 @@ class u {
136
219
  handleDropdownKeydown(t2) {
137
220
  if (!this.overflowDropdown) return;
138
221
  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());
222
+ const e2 = Array.from(this.overflowDropdown.querySelectorAll('[role="menuitem"]')), o2 = e2.indexOf(this.getActiveElement());
140
223
  switch (t2.key) {
141
224
  case "ArrowDown": {
142
225
  t2.preventDefault();
143
- const r2 = o(e2, n2, 1);
144
- e2[r2]?.focus();
226
+ const n2 = r(e2, o2, 1);
227
+ e2[n2]?.focus();
145
228
  break;
146
229
  }
147
230
  case "ArrowUp": {
148
231
  t2.preventDefault();
149
- const r2 = o(e2, n2, -1);
150
- e2[r2]?.focus();
232
+ const n2 = r(e2, o2, -1);
233
+ e2[n2]?.focus();
151
234
  break;
152
235
  }
153
236
  case "Enter":
154
237
  case " ": {
155
238
  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);
239
+ const n2 = e2[o2];
240
+ if (!n2) break;
241
+ const r2 = n2.getAttribute("data-toolbar-item"), i2 = this.overflowEntries.find((t3) => t3.item.id === r2);
159
242
  i2 && this.activateOverflowItem(i2);
160
243
  break;
161
244
  }
@@ -166,53 +249,94 @@ class u {
166
249
  for (let e2 = t2.length - 1; e2 >= 0; e2--) {
167
250
  const o2 = t2[e2];
168
251
  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;
252
+ if (o2.classList.contains("notectl-toolbar-separator")) o2.classList.contains(g) || o2.classList.add(g);
253
+ else if (!o2.classList.contains(v)) break;
171
254
  }
172
255
  }
173
256
  }
174
257
  notifyChange() {
175
- const t2 = this.entries.filter((t3) => !t3.element.classList.contains(p)).map((t3) => t3.element);
258
+ const t2 = this.entries.filter((t3) => !t3.element.classList.contains(v)).map((t3) => t3.element);
176
259
  this.onOverflowChange(t2, this.overflowEntries.length > 0 ? this.overflowButton : null);
177
260
  }
178
261
  }
179
- function m(t2, e2, o2) {
262
+ function x(t2, e2, o2) {
180
263
  const n2 = t2.querySelectorAll(".notectl-grid-picker__cell");
181
264
  for (const t3 of n2) {
182
265
  const n3 = Number(t3.getAttribute("data-row")), r2 = Number(t3.getAttribute("data-col"));
183
266
  t3.classList.toggle("notectl-grid-picker__cell--highlighted", n3 <= e2 && r2 <= o2);
184
267
  }
185
268
  }
186
- function b() {
269
+ function y() {
187
270
  const t2 = document.createElement("span");
188
271
  return t2.className = "notectl-toolbar-separator", t2.setAttribute("role", "separator"), t2;
189
272
  }
190
- class f {
273
+ class A {
191
274
  activePopup = null;
192
275
  activePopupButton = null;
193
- closePopupHandler = null;
276
+ activeHandle = null;
194
277
  getActiveElement;
278
+ popupManager = null;
195
279
  constructor(t2) {
196
280
  this.getActiveElement = t2;
197
281
  }
282
+ setPopupManager(t2) {
283
+ this.popupManager = t2;
284
+ }
198
285
  isOpen() {
199
286
  return null !== this.activePopup;
200
287
  }
201
288
  toggle(t2, e2, o2) {
202
- if (this.activePopup) return void this.close();
289
+ this.activePopup ? this.close() : this.popupManager ? this.openViaManager(t2, e2, o2) : this.openLegacy(t2, e2, o2);
290
+ }
291
+ close() {
292
+ if (this.activeHandle) {
293
+ const t2 = this.activeHandle;
294
+ return this.activeHandle = null, this.clearButtonState(), void t2.close();
295
+ }
296
+ this.clearButtonState(), this.activePopup && (this.activePopup.remove(), this.activePopup = null);
297
+ }
298
+ closeAndRestoreFocus() {
299
+ const t2 = this.activePopupButton;
300
+ this.close(), t2?.focus();
301
+ }
302
+ destroy() {
303
+ this.close();
304
+ }
305
+ openViaManager(t2, e2, o2) {
306
+ 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: () => {
307
+ this.activeHandle = null, this.clearButtonState(), this.activePopup = null;
308
+ }, content: (t3, n2) => {
309
+ this.activePopup = t3, this.renderPopupContent(t3, e2, o2, n2), t3.addEventListener("keydown", (t4) => this.handlePopupKeydown(t4));
310
+ } }));
311
+ }
312
+ openLegacy(t2, e2, o2) {
203
313
  const n2 = document.createElement("div");
204
- switch (n2.className = "notectl-toolbar-popup", e2.popupType) {
314
+ 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));
315
+ const r2 = (e3) => {
316
+ const o3 = e3.composedPath();
317
+ o3.includes(n2) || o3.includes(t2) || this.close();
318
+ };
319
+ setTimeout(() => {
320
+ document.addEventListener("mousedown", r2);
321
+ }, 0), n2.dataset.legacyClose = "true";
322
+ const i2 = this.close.bind(this);
323
+ this.close = () => {
324
+ document.removeEventListener("mousedown", r2), this.close = i2, i2();
325
+ };
326
+ }
327
+ renderPopupContent(t2, e2, o2, n2) {
328
+ switch (e2.popupType) {
205
329
  case "gridPicker":
206
330
  !(function(t3, e3, o3) {
207
331
  t3.className += " notectl-grid-picker";
208
332
  const n3 = document.createElement("div");
209
- n3.className = "notectl-grid-picker__grid", n3.setAttribute("role", "grid"), n3.style.display = "grid", n3.style.gridTemplateColumns = `repeat(${e3.maxCols}, 1fr)`, n3.style.gap = "2px", n3.style.padding = "8px";
333
+ n3.className = "notectl-grid-picker__grid", n3.setAttribute("role", "grid"), d(n3, { display: "grid", gridTemplateColumns: `repeat(${e3.maxCols}, 1fr)`, gap: "2px", padding: "8px" });
210
334
  const r2 = document.createElement("div");
211
- r2.className = "notectl-grid-picker__label", r2.textContent = "1 x 1", r2.style.textAlign = "center", r2.style.padding = "4px", r2.style.fontSize = "12px", r2.setAttribute("aria-live", "polite");
335
+ r2.className = "notectl-grid-picker__label", r2.textContent = "1 x 1", d(r2, { textAlign: "center", padding: "4px", fontSize: "12px" }), r2.setAttribute("aria-live", "polite");
212
336
  for (let t4 = 1; t4 <= e3.maxRows; t4++) for (let i2 = 1; i2 <= e3.maxCols; i2++) {
213
337
  const s2 = document.createElement("div");
214
- 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
+ s2.className = "notectl-grid-picker__cell", s2.setAttribute("role", "gridcell"), s2.setAttribute("tabindex", "-1"), s2.setAttribute("aria-label", `${t4} x ${i2}`), d(s2, { width: "20px", height: "20px", border: "1px solid #ccc", cursor: "pointer" }), s2.setAttribute("data-row", String(t4)), s2.setAttribute("data-col", String(i2)), s2.addEventListener("mouseenter", () => {
339
+ x(n3, t4, i2), r2.textContent = `${t4} x ${i2}`;
216
340
  }), s2.addEventListener("mousedown", (n4) => {
217
341
  n4.preventDefault(), n4.stopPropagation(), e3.onSelect(t4, i2), o3();
218
342
  }), s2.addEventListener("click", () => {
@@ -220,7 +344,7 @@ class f {
220
344
  }), n3.appendChild(s2);
221
345
  }
222
346
  t3.appendChild(n3), t3.appendChild(r2);
223
- })(n2, e2.popupConfig, () => this.close());
347
+ })(t2, e2.popupConfig, n2);
224
348
  break;
225
349
  case "dropdown":
226
350
  !(function(t3, e3, o3, n3) {
@@ -238,31 +362,19 @@ class f {
238
362
  o3(r2.command), n3();
239
363
  }), t3.appendChild(e4);
240
364
  }
241
- })(n2, e2.popupConfig, (t3) => o2.executeCommand(t3), () => this.close());
365
+ })(t2, e2.popupConfig, (t3) => o2.executeCommand(t3), n2);
242
366
  break;
243
367
  case "custom":
244
- e2.renderPopup(n2, o2, () => this.close());
368
+ case "combobox":
369
+ e2.renderPopup(t2, o2, n2);
245
370
  }
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
371
  }
256
- closeAndRestoreFocus() {
257
- const t2 = this.activePopupButton;
258
- this.close(), t2?.focus();
259
- }
260
- destroy() {
261
- this.close();
372
+ clearButtonState() {
373
+ this.activePopupButton && (this.activePopupButton.classList.remove("notectl-toolbar-btn--popup-open"), this.activePopupButton.setAttribute("aria-expanded", "false"), this.activePopupButton = null);
262
374
  }
263
375
  positionAndAppend(t2, e2) {
264
376
  const o2 = e2.getBoundingClientRect();
265
- t2.style.position = "fixed", t2.style.top = `${o2.bottom + 2}px`, t2.style.left = `${o2.left}px`, t2.style.zIndex = "10000";
377
+ d(t2, { position: "fixed", top: `${o2.bottom + 2}px`, left: `${o2.left}px`, zIndex: "10000" });
266
378
  const n2 = e2.getRootNode();
267
379
  n2 instanceof ShadowRoot ? n2.appendChild(t2) : document.body.appendChild(t2);
268
380
  }
@@ -280,37 +392,37 @@ class f {
280
392
  e2.length > 0 ? this.handleDropdownKeydown(t2, e2) : null !== this.activePopup.querySelector(".notectl-grid-picker__cell") ? this.handleGridKeydown(t2) : this.handleCustomPopupKeydown(t2);
281
393
  }
282
394
  handleDropdownKeydown(t2, e2) {
283
- const n2 = Array.from(e2), r2 = n2.indexOf(this.getActiveElement());
395
+ const o2 = Array.from(e2), n2 = o2.indexOf(this.getActiveElement());
284
396
  switch (t2.key) {
285
397
  case "ArrowDown": {
286
398
  t2.preventDefault();
287
- const e3 = o(n2, r2, 1);
288
- n2[e3]?.focus();
399
+ const e3 = r(o2, n2, 1);
400
+ o2[e3]?.focus();
289
401
  break;
290
402
  }
291
403
  case "ArrowUp": {
292
404
  t2.preventDefault();
293
- const e3 = o(n2, r2, -1);
294
- n2[e3]?.focus();
405
+ const e3 = r(o2, n2, -1);
406
+ o2[e3]?.focus();
295
407
  break;
296
408
  }
297
409
  case "Enter":
298
410
  case " ": {
299
411
  t2.preventDefault();
300
- const e3 = n2[r2];
412
+ const e3 = o2[n2];
301
413
  e3 && e3.click();
302
414
  break;
303
415
  }
304
416
  }
305
417
  }
306
418
  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);
419
+ 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;
420
+ if (!r2) return;
421
+ 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
422
  if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t2.key)) {
311
423
  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);
424
+ const [e3, s3] = i(o2, n2, a2, l2, t2.key), c2 = r2.querySelector(`.notectl-grid-picker__cell[data-row="${e3}"][data-col="${s3}"]`);
425
+ c2?.focus(), x(r2, e3, s3);
314
426
  const d2 = this.activePopup?.querySelector(".notectl-grid-picker__label") ?? null;
315
427
  d2 && (d2.textContent = `${e3} x ${s3}`);
316
428
  }
@@ -320,56 +432,56 @@ class f {
320
432
  if (!this.activePopup) return;
321
433
  const e2 = Array.from(this.activePopup.querySelectorAll("button"));
322
434
  if (0 === e2.length) return;
323
- const n2 = this.getActiveElement(), r2 = e2.indexOf(n2);
435
+ const o2 = this.getActiveElement(), n2 = e2.indexOf(o2);
324
436
  switch (t2.key) {
325
437
  case "ArrowDown": {
326
438
  t2.preventDefault();
327
- const n3 = o(e2, r2, 1);
328
- e2[n3]?.focus();
439
+ const o3 = r(e2, n2, 1);
440
+ e2[o3]?.focus();
329
441
  break;
330
442
  }
331
443
  case "ArrowUp": {
332
444
  t2.preventDefault();
333
- const n3 = o(e2, r2, -1);
334
- e2[n3]?.focus();
445
+ const o3 = r(e2, n2, -1);
446
+ e2[o3]?.focus();
335
447
  break;
336
448
  }
337
449
  case "Enter":
338
450
  case " ":
339
- t2.preventDefault(), n2 && n2.dispatchEvent(new MouseEvent("mousedown", { bubbles: true, cancelable: true }));
451
+ t2.preventDefault(), o2 && o2.dispatchEvent(new MouseEvent("mousedown", { bubbles: true, cancelable: true }));
340
452
  }
341
453
  }
342
454
  }
343
- class v {
455
+ class E {
344
456
  element;
345
457
  timer = null;
346
458
  target = null;
347
459
  isPopupActive;
348
460
  static TOOLTIP_ID = "notectl-toolbar-tooltip";
349
461
  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";
462
+ this.isPopupActive = t2, this.element = document.createElement("div"), this.element.className = "notectl-toolbar-tooltip", this.element.id = E.TOOLTIP_ID, this.element.setAttribute("role", "tooltip"), p(this.element, "display", "none");
351
463
  }
352
464
  show(t2) {
353
465
  if (this.hide(), this.isPopupActive() || t2.disabled) return;
354
466
  const e2 = t2.getAttribute("data-tooltip");
355
467
  e2 && (this.target = t2, this.timer = setTimeout(() => {
356
468
  if (this.isPopupActive()) return;
357
- this.element.textContent = e2, this.element.style.display = "";
469
+ this.element.textContent = e2, p(this.element, "display", "");
358
470
  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);
471
+ 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", E.TOOLTIP_ID);
360
472
  const n2 = t2.getBoundingClientRect();
361
- 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%)";
473
+ d(this.element, { position: "fixed", top: `${n2.bottom + 6}px`, left: `${n2.left + n2.width / 2}px`, transform: "translateX(-50%)" });
362
474
  }, 500));
363
475
  }
364
476
  hide() {
365
- this.timer && (clearTimeout(this.timer), this.timer = null), this.target && (this.target.removeAttribute("aria-describedby"), this.target = null), this.element.style.display = "none";
477
+ this.timer && (clearTimeout(this.timer), this.timer = null), this.target && (this.target.removeAttribute("aria-describedby"), this.target = null), p(this.element, "display", "none");
366
478
  }
367
479
  destroy() {
368
480
  this.hide(), this.element.remove();
369
481
  }
370
482
  }
371
- const w = new t("toolbar");
372
- class g {
483
+ const k = new t("toolbar");
484
+ class C {
373
485
  id = "toolbar";
374
486
  name = "Toolbar";
375
487
  priority = 10;
@@ -382,14 +494,15 @@ class g {
382
494
  focusedIndex = 0;
383
495
  tooltip = null;
384
496
  popupController = null;
497
+ popupManager = null;
385
498
  overflowController = null;
386
499
  visibleElements = [];
387
500
  locale;
388
501
  constructor(t2) {
389
- this.layoutConfig = t2 ?? null, this.overflowBehavior = t2?.overflow ?? d.BurgerMenu;
502
+ this.layoutConfig = t2 ?? null, this.overflowBehavior = t2?.overflow ?? f.BurgerMenu;
390
503
  }
391
504
  init(t2) {
392
- this.locale = e(c, t2), t2.registerStyleSheet(`
505
+ this.locale = e(b, t2), t2.registerStyleSheet(`
393
506
  /* Toolbar */
394
507
  .notectl-plugin-container--top {
395
508
  display: flex;
@@ -642,7 +755,92 @@ class g {
642
755
  background: var(--notectl-border);
643
756
  margin: 4px 0;
644
757
  }
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();
758
+
759
+ /* Combobox-style toolbar buttons (shared base for font, fontSize, heading, etc.) */
760
+ .notectl-toolbar-btn[role="combobox"] {
761
+ width: auto;
762
+ padding: 0 8px;
763
+ gap: 4px;
764
+ border: 1px solid var(--notectl-border);
765
+ border-radius: 4px;
766
+ background: var(--notectl-bg);
767
+ }
768
+
769
+ .notectl-toolbar-btn[role="combobox"]:hover {
770
+ background: var(--notectl-hover-bg);
771
+ border-color: var(--notectl-fg-muted);
772
+ }
773
+
774
+ .notectl-toolbar-btn[role="combobox"].notectl-toolbar-btn--active {
775
+ background: var(--notectl-bg);
776
+ border-color: var(--notectl-primary-muted);
777
+ }
778
+
779
+ .notectl-toolbar-combobox__label {
780
+ flex: 1;
781
+ font-size: 13px;
782
+ font-weight: 500;
783
+ color: var(--notectl-fg);
784
+ white-space: nowrap;
785
+ overflow: hidden;
786
+ text-overflow: ellipsis;
787
+ text-align: left;
788
+ line-height: 30px;
789
+ }
790
+
791
+ .notectl-toolbar-combobox__arrow {
792
+ flex-shrink: 0;
793
+ font-size: 11px;
794
+ color: var(--notectl-fg-muted);
795
+ line-height: 30px;
796
+ }
797
+
798
+ /* Link Popup */
799
+ .notectl-link-popup {
800
+ padding: 8px;
801
+ min-width: 200px;
802
+ }
803
+
804
+ .notectl-link-popup__input {
805
+ width: 100%;
806
+ padding: 4px;
807
+ box-sizing: border-box;
808
+ border: 1px solid var(--notectl-border);
809
+ border-radius: 4px;
810
+ font-size: 13px;
811
+ color: var(--notectl-fg);
812
+ background: var(--notectl-bg);
813
+ }
814
+
815
+ .notectl-link-popup__input:focus-visible {
816
+ outline: 2px solid var(--notectl-focus-ring);
817
+ outline-offset: -1px;
818
+ }
819
+
820
+ .notectl-link-popup__button {
821
+ width: 100%;
822
+ padding: 6px 12px;
823
+ cursor: pointer;
824
+ border: 1px solid var(--notectl-border);
825
+ border-radius: 4px;
826
+ background: var(--notectl-bg);
827
+ color: var(--notectl-fg);
828
+ font-size: 13px;
829
+ }
830
+
831
+ .notectl-link-popup__button--apply {
832
+ margin-top: 4px;
833
+ }
834
+
835
+ .notectl-link-popup__button:hover {
836
+ background: var(--notectl-hover-bg);
837
+ }
838
+
839
+ .notectl-link-popup__button:focus-visible {
840
+ outline: 2px solid var(--notectl-focus-ring);
841
+ outline-offset: -1px;
842
+ }
843
+ `), this.context = t2, this.popupManager = new h(t2.getContainer()), t2.registerService(u, this.popupManager), this.popupController = new A(() => this.getActiveElement()), this.popupController.setPopupManager(this.popupManager), this.tooltip = new E(() => this.popupController?.isOpen() ?? false), t2.registerService(k, { refresh: () => this.updateButtonStates(t2.getState()), closePopup: () => this.popupController?.close() }), this.createToolbarElement();
646
844
  }
647
845
  getOverflowBehavior() {
648
846
  return this.overflowBehavior;
@@ -654,7 +852,7 @@ class g {
654
852
  this.renderItems();
655
853
  }
656
854
  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;
855
+ 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
856
  }
659
857
  onStateChange(t2, e2, o2) {
660
858
  this.updateButtonStates(e2);
@@ -673,7 +871,7 @@ class g {
673
871
  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
872
  }
675
873
  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) => {
874
+ this.toolbarElement && this.context && (this.overflowController?.destroy(), this.overflowController = null, this.toolbarElement.setAttribute("data-overflow", this.overflowBehavior), this.overflowBehavior === f.BurgerMenu ? this.overflowController = new w({ toolbar: this.toolbarElement, ariaLabel: this.locale.moreToolsAria, context: this.context, popupManager: this.popupManager ?? void 0, onOverflowChange: (t2, e2) => {
677
875
  this.visibleElements = e2 ? [...t2, e2] : [...t2], this.initRovingTabindex();
678
876
  }, onItemActivated: (t2, e2) => {
679
877
  this.activateButton(t2, e2);
@@ -691,12 +889,12 @@ class g {
691
889
  return this.visibleElements.length > 0 ? this.visibleElements : this.buttons.map((t2) => t2.element);
692
890
  }
693
891
  initRovingTabindex() {
694
- const t2 = this.getTabElements(), e2 = r(t2);
695
- this.focusedIndex = e2 >= 0 ? e2 : 0, i(t2, this.focusedIndex);
892
+ const t2 = this.getTabElements(), e2 = s(t2);
893
+ this.focusedIndex = e2 >= 0 ? e2 : 0, l(t2, this.focusedIndex);
696
894
  }
697
895
  setRovingFocus(t2) {
698
896
  const e2 = this.getTabElements();
699
- t2 < 0 || t2 >= e2.length || (this.focusedIndex = t2, i(e2, t2), e2[t2]?.focus());
897
+ t2 < 0 || t2 >= e2.length || (this.focusedIndex = t2, l(e2, t2), e2[t2]?.focus());
700
898
  }
701
899
  getActiveElement() {
702
900
  const t2 = this.toolbarElement?.getRootNode();
@@ -711,25 +909,25 @@ class g {
711
909
  if (0 !== e2.length) switch (this.syncFocusedIndex(), t2.key) {
712
910
  case "ArrowRight": {
713
911
  t2.preventDefault();
714
- const o2 = l(e2, this.focusedIndex, 1);
912
+ const o2 = c(e2, this.focusedIndex, 1);
715
913
  this.setRovingFocus(o2);
716
914
  break;
717
915
  }
718
916
  case "ArrowLeft": {
719
917
  t2.preventDefault();
720
- const o2 = l(e2, this.focusedIndex, -1);
918
+ const o2 = c(e2, this.focusedIndex, -1);
721
919
  this.setRovingFocus(o2);
722
920
  break;
723
921
  }
724
922
  case "Home": {
725
923
  t2.preventDefault();
726
- const o2 = r(e2);
924
+ const o2 = s(e2);
727
925
  o2 >= 0 && this.setRovingFocus(o2);
728
926
  break;
729
927
  }
730
928
  case "End": {
731
929
  t2.preventDefault();
732
- const o2 = s(e2);
930
+ const o2 = a(e2);
733
931
  o2 >= 0 && this.setRovingFocus(o2);
734
932
  break;
735
933
  }
@@ -756,7 +954,7 @@ class g {
756
954
  o3.sort((t3, e4) => (t3.priority ?? 100) - (e4.priority ?? 100)), n2.push(...o3);
757
955
  }
758
956
  if (0 !== n2.length) {
759
- e2 || this.toolbarElement.appendChild(b()), e2 = false;
957
+ e2 || this.toolbarElement.appendChild(y()), e2 = false;
760
958
  for (const t3 of n2) {
761
959
  const e3 = this.createButton(t3);
762
960
  this.toolbarElement.appendChild(e3.element), this.buttons.push(e3);
@@ -774,7 +972,7 @@ class g {
774
972
  const o2 = e2[t3];
775
973
  if (!o2) continue;
776
974
  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());
975
+ this.toolbarElement.appendChild(n2.element), this.buttons.push(n2), o2.separatorAfter && t3 < e2.length - 1 && this.toolbarElement.appendChild(y());
778
976
  }
779
977
  else {
780
978
  const t3 = /* @__PURE__ */ new Map();
@@ -784,7 +982,7 @@ class g {
784
982
  }
785
983
  let o2 = true;
786
984
  for (const [, e3] of t3) {
787
- o2 || this.toolbarElement.appendChild(b()), o2 = false;
985
+ o2 || this.toolbarElement.appendChild(y()), o2 = false;
788
986
  for (const t4 of e3) {
789
987
  const e4 = this.createButton(t4);
790
988
  this.toolbarElement.appendChild(e4.element), this.buttons.push(e4);
@@ -794,25 +992,40 @@ class g {
794
992
  }
795
993
  createButton(t2) {
796
994
  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) => {
995
+ 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);
996
+ let o2 = null;
997
+ if ("combobox" === t2.popupType) {
998
+ e2.setAttribute("role", "combobox"), e2.setAttribute("aria-haspopup", "listbox"), e2.setAttribute("aria-expanded", "false");
999
+ const n2 = document.createElement("span");
1000
+ n2.className = "notectl-toolbar-combobox__label";
1001
+ const r2 = this.context?.getState();
1002
+ r2 && (n2.textContent = t2.getLabel(r2)), e2.appendChild(n2), o2 = n2;
1003
+ const i2 = document.createElement("span");
1004
+ i2.className = "notectl-toolbar-combobox__arrow", i2.setAttribute("aria-hidden", "true"), i2.textContent = "▾", e2.appendChild(i2);
1005
+ } else {
1006
+ t2.popupType && (e2.setAttribute("aria-haspopup", "true"), e2.setAttribute("aria-expanded", "false"));
1007
+ const o3 = document.createElement("span");
1008
+ o3.className = "notectl-toolbar-btn__icon", o3.innerHTML = t2.icon, e2.appendChild(o3);
1009
+ }
1010
+ return e2.addEventListener("mousedown", (o3) => {
800
1011
  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 };
1012
+ }), 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
1013
  }
803
1014
  updateButtonStates(t2) {
804
1015
  for (const e2 of this.buttons) {
805
1016
  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");
1017
+ 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
1018
  }
808
1019
  this.overflowController?.updateItemStates(t2);
809
1020
  }
810
1021
  }
811
1022
  export {
812
- g as T,
813
- w as a,
814
- c as b,
815
- a as c,
816
- d
1023
+ h as P,
1024
+ C as T,
1025
+ k as a,
1026
+ u as b,
1027
+ b as c,
1028
+ m as d,
1029
+ f as e
817
1030
  };
818
- //# sourceMappingURL=ToolbarPlugin-B6JETWaw.mjs.map
1031
+ //# sourceMappingURL=ToolbarPlugin-DpLVJ71w.mjs.map