@notectl/core 1.0.6 → 1.0.8

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 (233) hide show
  1. package/README.md +78 -56
  2. package/custom-elements.json +344 -0
  3. package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs → AttrRegistry-D-przlzb.mjs} +4 -4
  4. package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs.map → AttrRegistry-D-przlzb.mjs.map} +1 -1
  5. package/dist/chunks/ColorNames-iaWsSZx1.mjs +35 -0
  6. package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +1 -0
  7. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +140 -0
  8. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +1 -0
  9. package/dist/chunks/{Commands-DLP85Mp5.mjs → Commands-CSpSwGXv.mjs} +13 -13
  10. package/dist/chunks/{Commands-DLP85Mp5.mjs.map → Commands-CSpSwGXv.mjs.map} +1 -1
  11. package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs +46 -0
  12. package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs.map +1 -0
  13. package/dist/chunks/{ToolbarPlugin-sJTiZr-S.mjs → ToolbarPlugin-DY2xaJiu.mjs} +63 -93
  14. package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +1 -0
  15. package/dist/chunks/index-BAk1EG1x.mjs +541 -0
  16. package/dist/chunks/index-BAk1EG1x.mjs.map +1 -0
  17. package/dist/chunks/index-BRYzYOYC.mjs +63 -0
  18. package/dist/chunks/index-BRYzYOYC.mjs.map +1 -0
  19. package/dist/chunks/index-BSFLNveF.mjs +953 -0
  20. package/dist/chunks/index-BSFLNveF.mjs.map +1 -0
  21. package/dist/chunks/index-BYgspns5.mjs +209 -0
  22. package/dist/chunks/index-BYgspns5.mjs.map +1 -0
  23. package/dist/chunks/index-B_3qDrUN.mjs +64 -0
  24. package/dist/chunks/index-B_3qDrUN.mjs.map +1 -0
  25. package/dist/chunks/index-Bsp4LC5t.mjs +130 -0
  26. package/dist/chunks/index-Bsp4LC5t.mjs.map +1 -0
  27. package/dist/chunks/index-C-YWHOcC.mjs +100 -0
  28. package/dist/chunks/index-C-YWHOcC.mjs.map +1 -0
  29. package/dist/chunks/index-C2GQoHot.mjs +92 -0
  30. package/dist/chunks/index-C2GQoHot.mjs.map +1 -0
  31. package/dist/chunks/index-CT3HGdQt.mjs +39 -0
  32. package/dist/chunks/index-CT3HGdQt.mjs.map +1 -0
  33. package/dist/chunks/index-Ct0ivLhO.mjs +407 -0
  34. package/dist/chunks/index-Ct0ivLhO.mjs.map +1 -0
  35. package/dist/chunks/index-CxiWyUho.mjs +191 -0
  36. package/dist/chunks/index-CxiWyUho.mjs.map +1 -0
  37. package/dist/chunks/index-D3CQWJiw.mjs +200 -0
  38. package/dist/chunks/index-D3CQWJiw.mjs.map +1 -0
  39. package/dist/chunks/index-DC1EK22F.mjs +41 -0
  40. package/dist/chunks/index-DC1EK22F.mjs.map +1 -0
  41. package/dist/chunks/index-Dh76rR13.mjs +196 -0
  42. package/dist/chunks/index-Dh76rR13.mjs.map +1 -0
  43. package/dist/chunks/index-o6hDR07y.mjs +41 -0
  44. package/dist/chunks/index-o6hDR07y.mjs.map +1 -0
  45. package/dist/chunks/index-uTnc9y7M.mjs +62 -0
  46. package/dist/chunks/index-uTnc9y7M.mjs.map +1 -0
  47. package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs +34 -0
  48. package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -0
  49. package/dist/editor/NotectlEditor.d.ts +10 -0
  50. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  51. package/dist/editor/PaperLayoutController.d.ts +27 -0
  52. package/dist/editor/PaperLayoutController.d.ts.map +1 -0
  53. package/dist/editor/PaperSize.d.ts +35 -0
  54. package/dist/editor/PaperSize.d.ts.map +1 -0
  55. package/dist/editor/styles/color-picker.d.ts +1 -1
  56. package/dist/editor/styles/color-picker.d.ts.map +1 -1
  57. package/dist/editor/styles/paper.d.ts +3 -0
  58. package/dist/editor/styles/paper.d.ts.map +1 -0
  59. package/dist/editor/styles/table.d.ts +1 -1
  60. package/dist/editor/styles/table.d.ts.map +1 -1
  61. package/dist/editor/styles/toolbar.d.ts +1 -1
  62. package/dist/editor/styles/toolbar.d.ts.map +1 -1
  63. package/dist/editor/styles.d.ts.map +1 -1
  64. package/dist/i18n/Locale.d.ts +17 -0
  65. package/dist/i18n/Locale.d.ts.map +1 -0
  66. package/dist/i18n/LocaleService.d.ts +8 -0
  67. package/dist/i18n/LocaleService.d.ts.map +1 -0
  68. package/dist/i18n/index.d.ts +4 -0
  69. package/dist/i18n/index.d.ts.map +1 -0
  70. package/dist/i18n/resolvePluginLocale.d.ts +3 -0
  71. package/dist/i18n/resolvePluginLocale.d.ts.map +1 -0
  72. package/dist/index.d.ts +42 -0
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/input/ClipboardHandler.d.ts.map +1 -1
  75. package/dist/input/InputHandler.d.ts.map +1 -1
  76. package/dist/input/KeyboardHandler.d.ts.map +1 -1
  77. package/dist/input/PasteHandler.d.ts.map +1 -1
  78. package/dist/notectl-core.mjs +2126 -1952
  79. package/dist/notectl-core.mjs.map +1 -1
  80. package/dist/notectl-core.umd.js +2002 -1544
  81. package/dist/notectl-core.umd.js.map +1 -1
  82. package/dist/plugins/PluginManager.d.ts +5 -0
  83. package/dist/plugins/PluginManager.d.ts.map +1 -1
  84. package/dist/plugins/alignment/AlignmentLocale.d.ts +19 -0
  85. package/dist/plugins/alignment/AlignmentLocale.d.ts.map +1 -0
  86. package/dist/plugins/alignment/AlignmentPlugin.d.ts +4 -0
  87. package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
  88. package/dist/plugins/alignment.mjs +3 -89
  89. package/dist/plugins/alignment.mjs.map +1 -1
  90. package/dist/plugins/blockquote/BlockquoteLocale.d.ts +17 -0
  91. package/dist/plugins/blockquote/BlockquoteLocale.d.ts.map +1 -0
  92. package/dist/plugins/blockquote/BlockquotePlugin.d.ts +3 -0
  93. package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -1
  94. package/dist/plugins/blockquote.mjs +2 -55
  95. package/dist/plugins/blockquote.mjs.map +1 -1
  96. package/dist/plugins/code-block/CodeBlockLocale.d.ts +17 -0
  97. package/dist/plugins/code-block/CodeBlockLocale.d.ts.map +1 -0
  98. package/dist/plugins/code-block/CodeBlockPlugin.d.ts +1 -0
  99. package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
  100. package/dist/plugins/code-block/CodeBlockTypes.d.ts +2 -0
  101. package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -1
  102. package/dist/plugins/code-block.mjs +3 -3
  103. package/dist/plugins/font/FontLocale.d.ts +15 -0
  104. package/dist/plugins/font/FontLocale.d.ts.map +1 -0
  105. package/dist/plugins/font/FontPlugin.d.ts +3 -0
  106. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  107. package/dist/plugins/font-size/FontSizeLocale.d.ts +17 -0
  108. package/dist/plugins/font-size/FontSizeLocale.d.ts.map +1 -0
  109. package/dist/plugins/font-size/FontSizePlugin.d.ts +3 -0
  110. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
  111. package/dist/plugins/font-size/FontSizePopup.d.ts +2 -0
  112. package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -1
  113. package/dist/plugins/font-size.mjs +2 -201
  114. package/dist/plugins/font-size.mjs.map +1 -1
  115. package/dist/plugins/font.mjs +2 -183
  116. package/dist/plugins/font.mjs.map +1 -1
  117. package/dist/plugins/hard-break.mjs +1 -1
  118. package/dist/plugins/heading/HeadingLocale.d.ts +26 -0
  119. package/dist/plugins/heading/HeadingLocale.d.ts.map +1 -0
  120. package/dist/plugins/heading/HeadingPlugin.d.ts +4 -0
  121. package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
  122. package/dist/plugins/heading.mjs +1 -184
  123. package/dist/plugins/heading.mjs.map +1 -1
  124. package/dist/plugins/highlight/HighlightLocale.d.ts +17 -0
  125. package/dist/plugins/highlight/HighlightLocale.d.ts.map +1 -0
  126. package/dist/plugins/highlight/HighlightPlugin.d.ts +3 -5
  127. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  128. package/dist/plugins/highlight.mjs +2 -123
  129. package/dist/plugins/highlight.mjs.map +1 -1
  130. package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts +15 -0
  131. package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts.map +1 -0
  132. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +4 -0
  133. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
  134. package/dist/plugins/horizontal-rule.mjs +2 -56
  135. package/dist/plugins/horizontal-rule.mjs.map +1 -1
  136. package/dist/plugins/image/ImageLocale.d.ts +25 -0
  137. package/dist/plugins/image/ImageLocale.d.ts.map +1 -0
  138. package/dist/plugins/image/ImagePlugin.d.ts +1 -0
  139. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
  140. package/dist/plugins/image/ImageUpload.d.ts +3 -0
  141. package/dist/plugins/image/ImageUpload.d.ts.map +1 -1
  142. package/dist/plugins/image.mjs +4 -378
  143. package/dist/plugins/image.mjs.map +1 -1
  144. package/dist/plugins/link/LinkLocale.d.ts +23 -0
  145. package/dist/plugins/link/LinkLocale.d.ts.map +1 -0
  146. package/dist/plugins/link/LinkPlugin.d.ts +3 -0
  147. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  148. package/dist/plugins/link.mjs +2 -124
  149. package/dist/plugins/link.mjs.map +1 -1
  150. package/dist/plugins/list/ListLocale.d.ts +18 -0
  151. package/dist/plugins/list/ListLocale.d.ts.map +1 -0
  152. package/dist/plugins/list/ListPlugin.d.ts +4 -0
  153. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  154. package/dist/plugins/list.mjs +2 -190
  155. package/dist/plugins/list.mjs.map +1 -1
  156. package/dist/plugins/print/PrintLocale.d.ts +16 -0
  157. package/dist/plugins/print/PrintLocale.d.ts.map +1 -0
  158. package/dist/plugins/print/PrintPlugin.d.ts +1 -0
  159. package/dist/plugins/print/PrintPlugin.d.ts.map +1 -1
  160. package/dist/plugins/print/PrintStyleCollector.d.ts +7 -0
  161. package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
  162. package/dist/plugins/print/PrintTypes.d.ts +5 -0
  163. package/dist/plugins/print/PrintTypes.d.ts.map +1 -1
  164. package/dist/plugins/shared/ColorMarkOperations.d.ts +28 -0
  165. package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -0
  166. package/dist/plugins/shared/ColorNames.d.ts +22 -0
  167. package/dist/plugins/shared/ColorNames.d.ts.map +1 -0
  168. package/dist/plugins/shared/ColorPickerPopup.d.ts +31 -0
  169. package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -0
  170. package/dist/plugins/shared/ColorValidation.d.ts +14 -0
  171. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -0
  172. package/dist/plugins/strikethrough/StrikethroughLocale.d.ts +17 -0
  173. package/dist/plugins/strikethrough/StrikethroughLocale.d.ts.map +1 -0
  174. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +3 -0
  175. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
  176. package/dist/plugins/strikethrough.mjs +2 -32
  177. package/dist/plugins/strikethrough.mjs.map +1 -1
  178. package/dist/plugins/super-sub/SuperSubLocale.d.ts +19 -0
  179. package/dist/plugins/super-sub/SuperSubLocale.d.ts.map +1 -0
  180. package/dist/plugins/super-sub/SuperSubPlugin.d.ts +3 -0
  181. package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
  182. package/dist/plugins/super-sub.mjs +2 -78
  183. package/dist/plugins/super-sub.mjs.map +1 -1
  184. package/dist/plugins/table/TableBorderColor.d.ts +24 -0
  185. package/dist/plugins/table/TableBorderColor.d.ts.map +1 -0
  186. package/dist/plugins/table/TableCommands.d.ts +9 -8
  187. package/dist/plugins/table/TableCommands.d.ts.map +1 -1
  188. package/dist/plugins/table/TableContextMenu.d.ts +14 -0
  189. package/dist/plugins/table/TableContextMenu.d.ts.map +1 -0
  190. package/dist/plugins/table/TableControls.d.ts +3 -1
  191. package/dist/plugins/table/TableControls.d.ts.map +1 -1
  192. package/dist/plugins/table/TableControlsDOM.d.ts +13 -1
  193. package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
  194. package/dist/plugins/table/TableLocale.d.ts +48 -0
  195. package/dist/plugins/table/TableLocale.d.ts.map +1 -0
  196. package/dist/plugins/table/TableNavigation.d.ts +2 -1
  197. package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
  198. package/dist/plugins/table/TableNodeViews.d.ts +3 -1
  199. package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
  200. package/dist/plugins/table/TablePlugin.d.ts +7 -1
  201. package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
  202. package/dist/plugins/table/index.d.ts +3 -0
  203. package/dist/plugins/table/index.d.ts.map +1 -1
  204. package/dist/plugins/table.mjs +18 -660
  205. package/dist/plugins/table.mjs.map +1 -1
  206. package/dist/plugins/text-color/TextColorLocale.d.ts +17 -0
  207. package/dist/plugins/text-color/TextColorLocale.d.ts.map +1 -0
  208. package/dist/plugins/text-color/TextColorPlugin.d.ts +3 -5
  209. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  210. package/dist/plugins/text-color.mjs +2 -123
  211. package/dist/plugins/text-color.mjs.map +1 -1
  212. package/dist/plugins/text-formatting/TextFormattingLocale.d.ts +18 -0
  213. package/dist/plugins/text-formatting/TextFormattingLocale.d.ts.map +1 -0
  214. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +4 -0
  215. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
  216. package/dist/plugins/text-formatting.mjs +2 -49
  217. package/dist/plugins/text-formatting.mjs.map +1 -1
  218. package/dist/plugins/toolbar/ToolbarLocale.d.ts +14 -0
  219. package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -0
  220. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
  221. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  222. package/dist/plugins/toolbar.mjs +1 -1
  223. package/dist/state/EditorState.d.ts +4 -1
  224. package/dist/state/EditorState.d.ts.map +1 -1
  225. package/dist/view/EditorView.d.ts.map +1 -1
  226. package/package.json +3 -2
  227. package/dist/chunks/Plugin-B9OZ6Y4c.mjs +0 -15
  228. package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +0 -1
  229. package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs.map +0 -1
  230. package/dist/chunks/color-picker-Csf0wx5a.mjs +0 -5
  231. package/dist/chunks/color-picker-Csf0wx5a.mjs.map +0 -1
  232. package/dist/chunks/index-QvKiO9_4.mjs +0 -538
  233. package/dist/chunks/index-QvKiO9_4.mjs.map +0 -1
@@ -0,0 +1,953 @@
1
+ import { S as t, r as e } from "./resolvePluginLocale-B4w1OkPy.mjs";
2
+ import { i as n, c as o, b as r, a as l } from "./Selection-D5ZjXoB7.mjs";
3
+ import { g as i, i as a } from "./ColorNames-iaWsSZx1.mjs";
4
+ import { n as s } from "./ToolbarKeyboardNav-B32OMv8r.mjs";
5
+ import { u as c, b as d, c as u, d as b, g as h } from "./Document-CI3iCwEP.mjs";
6
+ import { n as p } from "./TypeBrands-C09nE2qO.mjs";
7
+ function f() {
8
+ const t2 = u(p("paragraph"), [b("")], d());
9
+ return u(p("table_cell"), [t2], d());
10
+ }
11
+ function m(t2, e2) {
12
+ const n2 = t2.getNodePath(e2);
13
+ if (!n2) return null;
14
+ let o2 = null, r2 = null, l2 = null, i2 = null;
15
+ for (const e3 of n2) {
16
+ const n3 = t2.getBlock(e3);
17
+ n3 && ("table" === n3.type ? (o2 = e3, r2 = n3) : "table_row" === n3.type ? l2 = e3 : "table_cell" === n3.type && (i2 = e3));
18
+ }
19
+ const a2 = t2.getBlock(e2);
20
+ if ("table_cell" === a2?.type && (i2 = e2), !(o2 && r2 && i2 && l2)) return null;
21
+ const s2 = t2.doc.children.findIndex((t3) => t3.id === o2), d2 = c(r2), u2 = d2.findIndex((t3) => t3.id === l2);
22
+ if (-1 === u2) return null;
23
+ const b2 = d2[u2];
24
+ if (!b2) return null;
25
+ const h2 = c(b2), p2 = h2.findIndex((t3) => t3.id === i2);
26
+ if (-1 === p2) return null;
27
+ const f2 = h2.length, m2 = d2.length;
28
+ return { tableId: o2, tableIndex: s2, rowId: l2, rowIndex: u2, cellId: i2, colIndex: p2, totalRows: m2, totalCols: f2 };
29
+ }
30
+ function g(t2, e2, n2, o2) {
31
+ const r2 = t2.getBlock(e2);
32
+ if (!r2) return null;
33
+ const l2 = c(r2)[n2];
34
+ if (!l2) return null;
35
+ const i2 = c(l2)[o2];
36
+ return i2?.id ?? null;
37
+ }
38
+ function w(t2, e2) {
39
+ const n2 = t2.getBlock(e2);
40
+ if (!n2) return e2;
41
+ const o2 = c(n2)[0];
42
+ if (!o2) return e2;
43
+ let r2 = o2;
44
+ for (; ; ) {
45
+ const t3 = c(r2)[0];
46
+ if (!t3) return r2.id;
47
+ r2 = t3;
48
+ }
49
+ }
50
+ function v(t2, e2) {
51
+ const n2 = t2.getBlock(e2);
52
+ if (!n2) return e2;
53
+ const o2 = c(n2), r2 = o2[o2.length - 1];
54
+ if (!r2) return e2;
55
+ let l2 = r2;
56
+ for (; ; ) {
57
+ const t3 = c(l2), e3 = t3[t3.length - 1];
58
+ if (!e3) return l2.id;
59
+ l2 = e3;
60
+ }
61
+ }
62
+ function x(t2, e2) {
63
+ const n2 = t2.getNodePath(e2);
64
+ if (!n2) return false;
65
+ for (const e3 of n2) {
66
+ const n3 = t2.getBlock(e3);
67
+ if ("table" === n3?.type) return true;
68
+ }
69
+ return false;
70
+ }
71
+ const C = { insertRowAbove: "Insert Row Above", insertRowBelow: "Insert Row Below", insertColumnLeft: "Insert Column Left", insertColumnRight: "Insert Column Right", deleteRow: "Delete Row", deleteColumn: "Delete Column", borderColorLabel: "Border Color...", deleteTable: "Delete Table", tableActions: "Table actions", menuKeyboardHint: "↑↓ Navigate · Enter Select · Esc Close", insertRow: "Insert row", insertColumn: "Insert column", addRow: "Add row", addColumn: "Add column", tableActionsHint: "Table actions (Right-click or Shift+F10)", contextMenuHint: "Right-click or Shift+F10 for table actions", borderColor: "Border color", defaultColor: "Default", noBorders: "No borders", borderColorPicker: "Border color picker", announceBorderColorSet: (t2) => `Table border color set to ${t2}`, announceBorderReset: "Table borders reset to default", borderSwatchLabel: (t2) => `Border ${t2}`, announceRowInsertedAbove: "Row inserted above", announceRowInsertedBelow: "Row inserted below", announceColumnInserted: (t2) => `Column inserted ${t2}`, announceRowDeleted: "Row deleted", announceColumnDeleted: "Column deleted", announceTableDeleted: "Table deleted", insertTable: "Insert Table", tableAriaLabel: (t2, e2) => `Table with ${t2} rows and ${e2} columns`, tableAriaDescription: "Right-click or press Shift+F10 for table actions" }, I = { insertRowAbove: "Zeile oberhalb einfügen", insertRowBelow: "Zeile unterhalb einfügen", insertColumnLeft: "Spalte links einfügen", insertColumnRight: "Spalte rechts einfügen", deleteRow: "Zeile löschen", deleteColumn: "Spalte löschen", borderColorLabel: "Rahmenfarbe…", deleteTable: "Tabelle löschen", tableActions: "Tabellenaktionen", menuKeyboardHint: "↑↓ Navigieren · Eingabe Auswählen · Esc Schließen", insertRow: "Zeile einfügen", insertColumn: "Spalte einfügen", addRow: "Zeile hinzufügen", addColumn: "Spalte hinzufügen", tableActionsHint: "Tabellenaktionen (Rechtsklick oder Umschalt+F10)", contextMenuHint: "Rechtsklick oder Umschalt+F10 für Tabellenaktionen", borderColor: "Rahmenfarbe", defaultColor: "Standard", noBorders: "Keine Rahmen", borderColorPicker: "Rahmenfarbe auswählen", announceBorderColorSet: (t2) => `Tabellenrahmenfarbe auf ${t2} gesetzt`, announceBorderReset: "Tabellenrahmen auf Standard zurückgesetzt", borderSwatchLabel: (t2) => `Rahmen ${t2}`, announceRowInsertedAbove: "Zeile oberhalb eingefügt", announceRowInsertedBelow: "Zeile unterhalb eingefügt", announceColumnInserted: (t2) => `Spalte ${t2} eingefügt`, announceRowDeleted: "Zeile gelöscht", announceColumnDeleted: "Spalte gelöscht", announceTableDeleted: "Tabelle gelöscht", insertTable: "Tabelle einfügen", tableAriaLabel: (t2, e2) => `Tabelle mit ${t2} Zeilen und ${e2} Spalten`, tableAriaDescription: "Rechtsklick oder Umschalt+F10 für Tabellenaktionen" }, y = { insertRowAbove: "Insertar fila arriba", insertRowBelow: "Insertar fila abajo", insertColumnLeft: "Insertar columna a la izquierda", insertColumnRight: "Insertar columna a la derecha", deleteRow: "Eliminar fila", deleteColumn: "Eliminar columna", borderColorLabel: "Color del borde…", deleteTable: "Eliminar tabla", tableActions: "Acciones de tabla", menuKeyboardHint: "↑↓ Navegar · Enter Seleccionar · Esc Cerrar", insertRow: "Insertar fila", insertColumn: "Insertar columna", addRow: "Añadir fila", addColumn: "Añadir columna", tableActionsHint: "Acciones de tabla (clic derecho o Mayús+F10)", contextMenuHint: "Clic derecho o Mayús+F10 para acciones de tabla", borderColor: "Color del borde", defaultColor: "Predeterminado", noBorders: "Sin bordes", borderColorPicker: "Selector de color de borde", announceBorderColorSet: (t2) => `Color del borde de tabla establecido en ${t2}`, announceBorderReset: "Bordes de tabla restablecidos a predeterminado", borderSwatchLabel: (t2) => `Borde ${t2}`, announceRowInsertedAbove: "Fila insertada arriba", announceRowInsertedBelow: "Fila insertada abajo", announceColumnInserted: (t2) => `Columna insertada ${t2}`, announceRowDeleted: "Fila eliminada", announceColumnDeleted: "Columna eliminada", announceTableDeleted: "Tabla eliminada", insertTable: "Insertar tabla", tableAriaLabel: (t2, e2) => `Tabla con ${t2} filas y ${e2} columnas`, tableAriaDescription: "Clic derecho o Mayús+F10 para acciones de tabla" }, R = { insertRowAbove: "Insérer une ligne au-dessus", insertRowBelow: "Insérer une ligne en dessous", insertColumnLeft: "Insérer une colonne à gauche", insertColumnRight: "Insérer une colonne à droite", deleteRow: "Supprimer la ligne", deleteColumn: "Supprimer la colonne", borderColorLabel: "Couleur de bordure…", deleteTable: "Supprimer le tableau", tableActions: "Actions du tableau", menuKeyboardHint: "↑↓ Naviguer · Entrée Sélectionner · Échap Fermer", insertRow: "Insérer une ligne", insertColumn: "Insérer une colonne", addRow: "Ajouter une ligne", addColumn: "Ajouter une colonne", tableActionsHint: "Actions du tableau (clic droit ou Maj+F10)", contextMenuHint: "Clic droit ou Maj+F10 pour les actions du tableau", borderColor: "Couleur de bordure", defaultColor: "Par défaut", noBorders: "Sans bordure", borderColorPicker: "Sélecteur de couleur de bordure", announceBorderColorSet: (t2) => `Couleur de bordure du tableau définie sur ${t2}`, announceBorderReset: "Bordures du tableau réinitialisées par défaut", borderSwatchLabel: (t2) => `Bordure ${t2}`, announceRowInsertedAbove: "Ligne insérée au-dessus", announceRowInsertedBelow: "Ligne insérée en dessous", announceColumnInserted: (t2) => `Colonne insérée à ${t2}`, announceRowDeleted: "Ligne supprimée", announceColumnDeleted: "Colonne supprimée", announceTableDeleted: "Tableau supprimé", insertTable: "Insérer un tableau", tableAriaLabel: (t2, e2) => `Tableau avec ${t2} lignes et ${e2} colonnes`, tableAriaDescription: "Clic droit ou Maj+F10 pour les actions du tableau" }, k = { insertRowAbove: "在上方插入行", insertRowBelow: "在下方插入行", insertColumnLeft: "在左侧插入列", insertColumnRight: "在右侧插入列", deleteRow: "删除行", deleteColumn: "删除列", borderColorLabel: "边框颜色…", deleteTable: "删除表格", tableActions: "表格操作", menuKeyboardHint: "↑↓ 导航 · Enter 选择 · Esc 关闭", insertRow: "插入行", insertColumn: "插入列", addRow: "添加行", addColumn: "添加列", tableActionsHint: "表格操作(右键或 Shift+F10)", contextMenuHint: "右键或 Shift+F10 打开表格操作", borderColor: "边框颜色", defaultColor: "默认", noBorders: "无边框", borderColorPicker: "边框颜色选择器", announceBorderColorSet: (t2) => `表格边框颜色已设置为${t2}`, announceBorderReset: "表格边框已重置为默认", borderSwatchLabel: (t2) => `边框 ${t2}`, announceRowInsertedAbove: "已在上方插入行", announceRowInsertedBelow: "已在下方插入行", announceColumnInserted: (t2) => `已插入列到${t2}`, announceRowDeleted: "行已删除", announceColumnDeleted: "列已删除", announceTableDeleted: "表格已删除", insertTable: "插入表格", tableAriaLabel: (t2, e2) => `表格,${t2} 行 ${e2} 列`, tableAriaDescription: "右键或 Shift+F10 打开表格操作" }, A = { insertRowAbove: "Вставить строку сверху", insertRowBelow: "Вставить строку снизу", insertColumnLeft: "Вставить столбец слева", insertColumnRight: "Вставить столбец справа", deleteRow: "Удалить строку", deleteColumn: "Удалить столбец", borderColorLabel: "Цвет границы…", deleteTable: "Удалить таблицу", tableActions: "Действия с таблицей", menuKeyboardHint: "↑↓ Навигация · Enter Выбрать · Esc Закрыть", insertRow: "Вставить строку", insertColumn: "Вставить столбец", addRow: "Добавить строку", addColumn: "Добавить столбец", tableActionsHint: "Действия с таблицей (ПКМ или Shift+F10)", contextMenuHint: "ПКМ или Shift+F10 для действий с таблицей", borderColor: "Цвет границы", defaultColor: "По умолчанию", noBorders: "Без границ", borderColorPicker: "Выбор цвета границы", announceBorderColorSet: (t2) => `Цвет границы таблицы установлен на ${t2}`, announceBorderReset: "Границы таблицы сброшены по умолчанию", borderSwatchLabel: (t2) => `Граница ${t2}`, announceRowInsertedAbove: "Строка вставлена сверху", announceRowInsertedBelow: "Строка вставлена снизу", announceColumnInserted: (t2) => `Столбец вставлен ${t2}`, announceRowDeleted: "Строка удалена", announceColumnDeleted: "Столбец удален", announceTableDeleted: "Таблица удалена", insertTable: "Вставить таблицу", tableAriaLabel: (t2, e2) => `Таблица: ${t2} строк, ${e2} столбцов`, tableAriaDescription: "ПКМ или Shift+F10 для действий с таблицей" }, S = { insertRowAbove: "إدراج صف أعلى", insertRowBelow: "إدراج صف أسفل", insertColumnLeft: "إدراج عمود على اليسار", insertColumnRight: "إدراج عمود على اليمين", deleteRow: "حذف الصف", deleteColumn: "حذف العمود", borderColorLabel: "لون الحدود…", deleteTable: "حذف الجدول", tableActions: "إجراءات الجدول", menuKeyboardHint: "↑↓ تنقل · Enter تحديد · Esc إغلاق", insertRow: "إدراج صف", insertColumn: "إدراج عمود", addRow: "إضافة صف", addColumn: "إضافة عمود", tableActionsHint: "إجراءات الجدول (انقر بزر الماوس الأيمن أو Shift+F10)", contextMenuHint: "انقر بزر الماوس الأيمن أو Shift+F10 لإجراءات الجدول", borderColor: "لون الحدود", defaultColor: "افتراضي", noBorders: "بدون حدود", borderColorPicker: "منتقي لون الحدود", announceBorderColorSet: (t2) => `تم تعيين لون حدود الجدول إلى ${t2}`, announceBorderReset: "تم إعادة تعيين حدود الجدول إلى الافتراضي", borderSwatchLabel: (t2) => `حدود ${t2}`, announceRowInsertedAbove: "تم إدراج صف أعلى", announceRowInsertedBelow: "تم إدراج صف أسفل", announceColumnInserted: (t2) => `تم إدراج عمود ${t2}`, announceRowDeleted: "تم حذف الصف", announceColumnDeleted: "تم حذف العمود", announceTableDeleted: "تم حذف الجدول", insertTable: "إدراج جدول", tableAriaLabel: (t2, e2) => `جدول من ${t2} صفوف و ${e2} أعمدة`, tableAriaDescription: "انقر بزر الماوس الأيمن أو Shift+F10 لإجراءات الجدول" }, L = { insertRowAbove: "ऊपर पंक्ति डालें", insertRowBelow: "नीचे पंक्ति डालें", insertColumnLeft: "बाएं स्तंभ डालें", insertColumnRight: "दाएं स्तंभ डालें", deleteRow: "पंक्ति हटाएं", deleteColumn: "स्तंभ हटाएं", borderColorLabel: "बॉर्डर रंग…", deleteTable: "तालिका हटाएं", tableActions: "तालिका क्रियाएं", menuKeyboardHint: "↑↓ नेविगेशन · Enter चुनें · Esc बंद करें", insertRow: "पंक्ति डालें", insertColumn: "स्तंभ डालें", addRow: "पंक्ति जोड़ें", addColumn: "स्तंभ जोड़ें", tableActionsHint: "तालिका क्रियाएं (राइट-क्लिक या Shift+F10)", contextMenuHint: "तालिका क्रियाओं के लिए राइट-क्लिक या Shift+F10", borderColor: "बॉर्डर रंग", defaultColor: "डिफ़ॉल्ट", noBorders: "कोई बॉर्डर नहीं", borderColorPicker: "बॉर्डर रंग चुनें", announceBorderColorSet: (t2) => `तालिका बॉर्डर रंग ${t2} पर सेट किया गया`, announceBorderReset: "तालिका बॉर्डर डिफ़ॉल्ट पर रीसेट किया गया", borderSwatchLabel: (t2) => `बॉर्डर ${t2}`, announceRowInsertedAbove: "ऊपर पंक्ति डाली गई", announceRowInsertedBelow: "नीचे पंक्ति डाली गई", announceColumnInserted: (t2) => `स्तंभ ${t2} डाला गया`, announceRowDeleted: "पंक्ति हटाई गई", announceColumnDeleted: "स्तंभ हटाया गया", announceTableDeleted: "तालिका हटाई गई", insertTable: "तालिका डालें", tableAriaLabel: (t2, e2) => `तालिका: ${t2} पंक्तियां और ${e2} स्तंभ`, tableAriaDescription: "तालिका क्रियाओं के लिए राइट-क्लिक या Shift+F10" }, B = { en: C, de: I, es: y, fr: R, zh: k, ru: A, ar: S, hi: L }, E = ["#000000", "#434343", "#666666", "#999999", "#b7b7b7", "#cccccc", "#d9d9d9", "#efefef", "#980000", "#cc0000", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3c78d8", "#3d85c6", "#674ea7", "#a64d79", "#0b5394", "#38761d"], T = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
72
+ function D(t2, e2, n2) {
73
+ const o2 = t2.getBlock(e2);
74
+ if (!o2 || "table" !== o2.type) return null;
75
+ const r2 = t2.getNodePath(e2);
76
+ if (!r2) return null;
77
+ if (void 0 === n2) {
78
+ const { borderColor: e3, ...n3 } = o2.attrs ?? {}, l3 = n3;
79
+ return t2.transaction("command").setNodeAttr(r2, l3).setSelection(t2.selection).build();
80
+ }
81
+ const l2 = { ...o2.attrs, borderColor: n2 };
82
+ return t2.transaction("command").setNodeAttr(r2, l2).setSelection(t2.selection).build();
83
+ }
84
+ function M(t2, e2, o2 = C) {
85
+ const r2 = t2.getState();
86
+ if (n(r2.selection)) return false;
87
+ const l2 = m(r2, r2.selection.anchor.blockId);
88
+ if (!l2) return false;
89
+ const a2 = D(r2, l2.tableId, e2);
90
+ if (!a2) return false;
91
+ t2.dispatch(a2);
92
+ const s2 = "none" === e2 ? "none" : i(e2);
93
+ return t2.announce(o2.announceBorderColorSet(s2)), true;
94
+ }
95
+ function H(t2, e2 = C) {
96
+ const o2 = t2.getState();
97
+ if (n(o2.selection)) return false;
98
+ const r2 = m(o2, o2.selection.anchor.blockId);
99
+ if (!r2) return false;
100
+ const l2 = D(o2, r2.tableId, void 0);
101
+ return !!l2 && (t2.dispatch(l2), t2.announce(e2.announceBorderReset), true);
102
+ }
103
+ function $(t2, e2) {
104
+ const n2 = t2.getBlock(e2);
105
+ if (n2) return n2.attrs?.borderColor;
106
+ }
107
+ function N(t2, e2, n2, o2, r2 = C) {
108
+ t2.classList.add("notectl-color-picker");
109
+ const l2 = $(e2.getState(), n2), c2 = E.length, d2 = Math.ceil(c2 / 5), u2 = document.createElement("button");
110
+ u2.type = "button", u2.className = "notectl-color-picker__default", u2.textContent = r2.defaultColor, u2.addEventListener("mousedown", (t3) => {
111
+ t3.preventDefault(), t3.stopPropagation(), H(e2, r2), o2();
112
+ }), u2.addEventListener("keydown", (t3) => {
113
+ "Escape" === t3.key && (t3.preventDefault(), o2());
114
+ }), t2.appendChild(u2);
115
+ const b2 = document.createElement("button");
116
+ b2.type = "button", b2.className = "notectl-color-picker__default", b2.textContent = r2.noBorders, b2.addEventListener("mousedown", (t3) => {
117
+ t3.preventDefault(), t3.stopPropagation(), M(e2, "none", r2), o2();
118
+ }), b2.addEventListener("keydown", (t3) => {
119
+ "Escape" === t3.key && (t3.preventDefault(), o2());
120
+ }), t2.appendChild(b2);
121
+ const h2 = document.createElement("div");
122
+ h2.className = "notectl-color-picker__grid", h2.setAttribute("role", "grid"), h2.setAttribute("aria-label", r2.borderColorPicker);
123
+ const p2 = [];
124
+ let f2 = 0;
125
+ for (let t3 = 0; t3 < d2; t3++) {
126
+ const n3 = document.createElement("div");
127
+ n3.setAttribute("role", "row");
128
+ for (let s2 = 0; s2 < 5; s2++) {
129
+ const d3 = 5 * t3 + s2;
130
+ if (d3 >= c2) break;
131
+ const u3 = E[d3], b3 = i(u3), h3 = !!l2 && l2.toLowerCase() === u3.toLowerCase(), m2 = document.createElement("button");
132
+ m2.type = "button", m2.className = "notectl-color-picker__swatch", m2.setAttribute("role", "gridcell"), m2.setAttribute("aria-label", r2.borderSwatchLabel(b3)), m2.setAttribute("aria-selected", String(h3)), m2.dataset.index = String(d3), m2.style.backgroundColor = u3, m2.title = b3, a(u3) && (m2.style.border = "1px solid #d0d0d0"), h3 && (m2.classList.add("notectl-color-picker__swatch--active"), f2 = d3), m2.addEventListener("mousedown", (t4) => {
133
+ t4.preventDefault(), t4.stopPropagation(), M(e2, u3, r2), o2();
134
+ }), p2.push(m2), n3.appendChild(m2);
135
+ }
136
+ h2.appendChild(n3);
137
+ }
138
+ P(p2, f2), h2.addEventListener("keydown", (t3) => {
139
+ if ("Escape" === t3.key) return t3.preventDefault(), void o2();
140
+ if ("Enter" === t3.key || " " === t3.key) {
141
+ t3.preventDefault();
142
+ const n3 = t3.target.dataset.index;
143
+ if (void 0 !== n3) {
144
+ const t4 = E[Number(n3)];
145
+ t4 && (M(e2, t4, r2), o2());
146
+ }
147
+ return;
148
+ }
149
+ if (T.has(t3.key)) {
150
+ t3.preventDefault();
151
+ const e3 = Math.floor(f2 / 5) + 1, n3 = f2 % 5 + 1, [o3, r3] = s(e3, n3, d2, 5, t3.key);
152
+ let l3 = 5 * (o3 - 1) + (r3 - 1);
153
+ return l3 >= c2 && (l3 = c2 - 1), f2 = l3, P(p2, f2), void p2[f2]?.focus();
154
+ }
155
+ if ("Home" === t3.key || "End" === t3.key) {
156
+ t3.preventDefault();
157
+ const e3 = 5 * Math.floor(f2 / 5), n3 = Math.min(e3 + 5 - 1, c2 - 1);
158
+ f2 = "Home" === t3.key ? e3 : n3, P(p2, f2), p2[f2]?.focus();
159
+ }
160
+ }), t2.appendChild(h2);
161
+ }
162
+ function P(t2, e2) {
163
+ for (let n2 = 0; n2 < t2.length; n2++) {
164
+ const o2 = t2[n2];
165
+ o2 && o2.setAttribute("tabindex", n2 === e2 ? "0" : "-1");
166
+ }
167
+ }
168
+ function z(t2, e2, n2) {
169
+ const r2 = t2.getBlock(e2);
170
+ if (!r2) return null;
171
+ const l2 = c(r2), i2 = l2[0] ? c(l2[0]).length : 0;
172
+ if (0 === i2) return null;
173
+ const a2 = (function(t3) {
174
+ const e3 = [];
175
+ for (let n3 = 0; n3 < t3; n3++) e3.push(f());
176
+ return u(p("table_row"), e3, d());
177
+ })(i2), s2 = t2.transaction("command").insertNode([e2], n2, a2), b2 = c(a2)[0], h2 = b2 ? c(b2)[0] : void 0;
178
+ return h2 ? s2.setSelection(o(h2.id, 0)) : b2 && s2.setSelection(o(b2.id, 0)), s2.build();
179
+ }
180
+ function F(t2, e2, n2) {
181
+ const o2 = t2.getBlock(e2);
182
+ if (!o2) return null;
183
+ const r2 = c(o2), l2 = t2.transaction("command");
184
+ for (const t3 of r2) {
185
+ const o3 = f();
186
+ l2.insertNode([e2, t3.id], n2, o3);
187
+ }
188
+ return l2.setSelection(t2.selection), l2.build();
189
+ }
190
+ function _(t2, e2, n2, r2 = 0) {
191
+ const l2 = t2.getBlock(e2);
192
+ if (!l2) return null;
193
+ if (c(l2).length <= 1) return j(t2, e2);
194
+ const i2 = t2.transaction("command").removeNode([e2], n2), a2 = g(t2, e2, n2 > 0 ? n2 - 1 : 1, r2);
195
+ if (a2) {
196
+ const e3 = w(t2, a2);
197
+ i2.setSelection(o(e3, 0));
198
+ }
199
+ return i2.build();
200
+ }
201
+ function V(t2, e2, n2, r2 = 0) {
202
+ const l2 = t2.getBlock(e2);
203
+ if (!l2) return null;
204
+ const i2 = c(l2);
205
+ if ((i2[0] ? c(i2[0]).length : 0) <= 1) return j(t2, e2);
206
+ const a2 = t2.transaction("command");
207
+ for (let t3 = i2.length - 1; t3 >= 0; t3--) {
208
+ const o2 = i2[t3];
209
+ o2 && a2.removeNode([e2, o2.id], n2);
210
+ }
211
+ const s2 = g(t2, e2, r2, n2 > 0 ? n2 - 1 : 1);
212
+ if (s2) {
213
+ const e3 = w(t2, s2);
214
+ a2.setSelection(o(e3, 0));
215
+ }
216
+ return a2.build();
217
+ }
218
+ function j(t2, e2) {
219
+ const n2 = t2.doc.children.findIndex((t3) => t3.id === e2);
220
+ if (-1 === n2) return null;
221
+ const r2 = t2.transaction("command").removeNode([], n2), l2 = t2.doc.children[n2 + 1];
222
+ if (l2) return r2.setSelection(o(l2.id, 0)), r2.build();
223
+ const i2 = t2.doc.children[n2 - 1];
224
+ return i2 && r2.setSelection(o(i2.id, 0)), r2.build();
225
+ }
226
+ function Z(t2, e2, r2) {
227
+ const l2 = t2.getState(), i2 = l2.selection;
228
+ if (n(i2)) return false;
229
+ const a2 = i2.anchor.blockId;
230
+ let s2 = -1;
231
+ for (let t3 = 0; t3 < l2.doc.children.length; t3++) {
232
+ const e3 = l2.doc.children[t3];
233
+ if (!e3) continue;
234
+ if (e3.id === a2) {
235
+ s2 = t3;
236
+ break;
237
+ }
238
+ const n2 = l2.getNodePath(a2);
239
+ if (n2 && n2[0] === e3.id) {
240
+ s2 = t3;
241
+ break;
242
+ }
243
+ }
244
+ -1 === s2 && (s2 = l2.doc.children.length - 1);
245
+ const b2 = (function(t3, e3) {
246
+ const n2 = d(), o2 = [];
247
+ for (let n3 = 0; n3 < t3; n3++) {
248
+ const t4 = [];
249
+ for (let n4 = 0; n4 < e3; n4++) t4.push(f());
250
+ o2.push(u(p("table_row"), t4, d()));
251
+ }
252
+ return u(p("table"), o2, n2);
253
+ })(e2, r2), h2 = u(p("paragraph")), m2 = s2 + 1, g2 = l2.transaction("command").insertNode([], m2, b2).insertNode([], m2 + 1, h2), w2 = c(b2)[0], v2 = w2 ? c(w2)[0] : void 0, x2 = v2 ? c(v2)[0] : void 0;
254
+ return x2 ? g2.setSelection(o(x2.id, 0)) : v2 && g2.setSelection(o(v2.id, 0)), t2.dispatch(g2.build()), true;
255
+ }
256
+ function q(t2, e2) {
257
+ const o2 = t2.getState();
258
+ if (n(o2.selection)) return false;
259
+ const r2 = m(o2, o2.selection.anchor.blockId);
260
+ if (!r2) return false;
261
+ const l2 = z(o2, r2.tableId, r2.rowIndex + 1);
262
+ return !!l2 && (t2.dispatch(l2), t2.announce(e2?.announceRowInsertedBelow ?? "Row inserted below"), true);
263
+ }
264
+ function O(t2, e2, o2) {
265
+ const r2 = t2.getState();
266
+ if (n(r2.selection)) return false;
267
+ const l2 = m(r2, r2.selection.anchor.blockId);
268
+ if (!l2) return false;
269
+ const i2 = "left" === e2 ? l2.colIndex : l2.colIndex + 1, a2 = F(r2, l2.tableId, i2);
270
+ return !!a2 && (t2.dispatch(a2), t2.announce(o2?.announceColumnInserted(e2) ?? `Column inserted ${e2}`), true);
271
+ }
272
+ function K(t2, e2) {
273
+ t2.registerCommand("insertTable", () => Z(t2, 3, 3)), t2.registerCommand("addRowAbove", () => (function(t3, e3) {
274
+ const o2 = t3.getState();
275
+ if (n(o2.selection)) return false;
276
+ const r2 = m(o2, o2.selection.anchor.blockId);
277
+ if (!r2) return false;
278
+ const l2 = z(o2, r2.tableId, r2.rowIndex);
279
+ return !!l2 && (t3.dispatch(l2), t3.announce(e3?.announceRowInsertedAbove ?? "Row inserted above"), true);
280
+ })(t2, e2)), t2.registerCommand("addRowBelow", () => q(t2, e2)), t2.registerCommand("addColumnLeft", () => (function(t3, e3) {
281
+ return O(t3, "left", e3);
282
+ })(t2, e2)), t2.registerCommand("addColumnRight", () => (function(t3, e3) {
283
+ return O(t3, "right", e3);
284
+ })(t2, e2)), t2.registerCommand("deleteRow", () => (function(t3, e3) {
285
+ const o2 = t3.getState();
286
+ if (n(o2.selection)) return false;
287
+ const r2 = m(o2, o2.selection.anchor.blockId);
288
+ if (!r2) return false;
289
+ const l2 = _(o2, r2.tableId, r2.rowIndex, r2.colIndex);
290
+ return !!l2 && (t3.dispatch(l2), t3.announce(e3?.announceRowDeleted ?? "Row deleted"), true);
291
+ })(t2, e2)), t2.registerCommand("deleteColumn", () => (function(t3, e3) {
292
+ const o2 = t3.getState();
293
+ if (n(o2.selection)) return false;
294
+ const r2 = m(o2, o2.selection.anchor.blockId);
295
+ if (!r2) return false;
296
+ const l2 = V(o2, r2.tableId, r2.colIndex, r2.rowIndex);
297
+ return !!l2 && (t3.dispatch(l2), t3.announce(e3?.announceColumnDeleted ?? "Column deleted"), true);
298
+ })(t2, e2)), t2.registerCommand("selectTable", () => (function(t3) {
299
+ const e3 = t3.getState(), o2 = e3.selection;
300
+ if (n(o2)) {
301
+ const t4 = e3.getBlock(o2.nodeId);
302
+ return "table" === t4?.type;
303
+ }
304
+ const l2 = m(e3, o2.anchor.blockId);
305
+ if (!l2) return false;
306
+ const i2 = e3.getNodePath(l2.tableId);
307
+ if (!i2) return false;
308
+ const a2 = e3.transaction("command").setSelection(r(l2.tableId, i2)).build();
309
+ return t3.dispatch(a2), true;
310
+ })(t2)), t2.registerCommand("deleteTable", () => (function(t3, e3) {
311
+ const o2 = t3.getState(), r2 = (function(t4) {
312
+ if (n(t4.selection)) {
313
+ const e5 = t4.getBlock(t4.selection.nodeId);
314
+ return "table" !== e5?.type ? null : { tableId: e5.id };
315
+ }
316
+ const e4 = m(t4, t4.selection.anchor.blockId);
317
+ return e4 ? { tableId: e4.tableId } : null;
318
+ })(o2);
319
+ if (!r2) return false;
320
+ const l2 = j(o2, r2.tableId);
321
+ return !!l2 && (t3.dispatch(l2), t3.announce(e3?.announceTableDeleted ?? "Table deleted"), true);
322
+ })(t2, e2));
323
+ }
324
+ function Y(t2, e2, n2, o2, r2, l2 = C) {
325
+ let i2 = true, a2 = null;
326
+ const s2 = document.createElement("div");
327
+ s2.className = "notectl-table-context-menu", s2.setAttribute("role", "menu"), s2.setAttribute("aria-label", l2.tableActions), s2.setAttribute("contenteditable", "false");
328
+ const c2 = [];
329
+ let d2 = 0;
330
+ const u2 = (function(t3) {
331
+ return [{ type: "item", label: t3.insertRowAbove, command: "addRowAbove" }, { type: "item", label: t3.insertRowBelow, command: "addRowBelow" }, { type: "separator" }, { type: "item", label: t3.insertColumnLeft, command: "addColumnLeft" }, { type: "item", label: t3.insertColumnRight, command: "addColumnRight" }, { type: "separator" }, { type: "item", label: t3.deleteRow, command: "deleteRow" }, { type: "item", label: t3.deleteColumn, command: "deleteColumn" }, { type: "separator" }, { type: "submenu", label: t3.borderColorLabel, id: "borderColor" }, { type: "separator" }, { type: "item", label: t3.deleteTable, command: "deleteTable" }];
332
+ })(l2);
333
+ for (const t3 of u2) {
334
+ if ("separator" === t3.type) {
335
+ const t4 = document.createElement("div");
336
+ t4.setAttribute("role", "separator"), s2.appendChild(t4);
337
+ continue;
338
+ }
339
+ const n3 = document.createElement("button");
340
+ n3.type = "button", n3.setAttribute("role", "menuitem"), n3.textContent = t3.label, "submenu" === t3.type && (n3.dataset.submenu = t3.id, n3.setAttribute("aria-haspopup", "true"), n3.setAttribute("aria-expanded", "false")), "item" === t3.type && (n3.dataset.command = t3.command), n3.addEventListener("mousedown", (t4) => {
341
+ t4.preventDefault(), t4.stopPropagation();
342
+ }), n3.addEventListener("click", (o3) => {
343
+ o3.stopPropagation(), "item" === t3.type ? (e2.executeCommand(t3.command), m2()) : "submenu" === t3.type && h2(n3);
344
+ }), c2.push(n3), s2.appendChild(n3);
345
+ }
346
+ const b2 = document.createElement("div");
347
+ function h2(o3) {
348
+ p2(), o3.setAttribute("aria-expanded", "true"), a2 = document.createElement("div"), a2.className = "notectl-table-context-menu", a2.style.position = "fixed", a2.setAttribute("contenteditable", "false"), a2.addEventListener("keydown", (t3) => {
349
+ t3.stopPropagation(), "ArrowLeft" === t3.key && (t3.preventDefault(), p2(), o3.focus());
350
+ }), N(a2, e2, n2, () => {
351
+ m2();
352
+ }, l2), t2.appendChild(a2);
353
+ const r3 = o3.getBoundingClientRect(), i3 = s2.getBoundingClientRect();
354
+ let c3 = i3.right + 2, d3 = r3.top;
355
+ const u3 = window.innerWidth, b3 = window.innerHeight;
356
+ c3 + 200 > u3 && (c3 = i3.left - 200 - 2), d3 + 200 > b3 && (d3 = b3 - 200), a2.style.left = `${c3}px`, a2.style.top = `${d3}px`, requestAnimationFrame(() => {
357
+ const t3 = a2?.querySelector("button");
358
+ t3?.focus();
359
+ });
360
+ }
361
+ function p2() {
362
+ a2 && (a2.remove(), a2 = null);
363
+ for (const t3 of c2) t3.dataset.submenu && t3.setAttribute("aria-expanded", "false");
364
+ }
365
+ b2.className = "notectl-table-context-menu__hint", b2.setAttribute("aria-hidden", "true"), b2.textContent = l2.menuKeyboardHint, s2.appendChild(b2), U(c2, d2), s2.addEventListener("keydown", (t3) => {
366
+ switch (t3.stopPropagation(), t3.key) {
367
+ case "Escape":
368
+ return t3.preventDefault(), void m2();
369
+ case "ArrowDown":
370
+ return t3.preventDefault(), d2 = (d2 + 1) % c2.length, U(c2, d2), void c2[d2]?.focus();
371
+ case "ArrowUp":
372
+ return t3.preventDefault(), d2 = (d2 - 1 + c2.length) % c2.length, U(c2, d2), void c2[d2]?.focus();
373
+ case "ArrowRight": {
374
+ t3.preventDefault();
375
+ const e3 = c2[d2];
376
+ return void (e3?.dataset.submenu && h2(e3));
377
+ }
378
+ case "ArrowLeft":
379
+ return t3.preventDefault(), p2(), void c2[d2]?.focus();
380
+ case "Enter":
381
+ case " ": {
382
+ t3.preventDefault();
383
+ const n3 = c2[d2];
384
+ if (!n3) return;
385
+ return void (n3.dataset.submenu ? h2(n3) : n3.dataset.command && (e2.executeCommand(n3.dataset.command), m2()));
386
+ }
387
+ case "Home":
388
+ return t3.preventDefault(), d2 = 0, U(c2, d2), void c2[d2]?.focus();
389
+ case "End":
390
+ return t3.preventDefault(), d2 = c2.length - 1, U(c2, d2), void c2[d2]?.focus();
391
+ }
392
+ }), (function(t3, e3) {
393
+ const n3 = window.innerWidth, o3 = window.innerHeight;
394
+ let r3 = e3.left, l3 = e3.top;
395
+ r3 + 200 > n3 && (r3 = n3 - 200), l3 + 340 > o3 && (l3 = o3 - 340), r3 < 0 && (r3 = 0), l3 < 0 && (l3 = 0), t3.style.left = `${r3}px`, t3.style.top = `${l3}px`;
396
+ })(s2, o2), t2.appendChild(s2), c2[0]?.focus(), requestAnimationFrame(() => {
397
+ i2 && c2[0] && c2[0].focus();
398
+ });
399
+ const f2 = (t3) => {
400
+ const e3 = t3.composedPath();
401
+ e3.includes(s2) || a2 && e3.includes(a2) || m2();
402
+ };
403
+ function m2() {
404
+ i2 && (i2 = false, p2(), s2.remove(), document.removeEventListener("mousedown", f2, true), r2?.());
405
+ }
406
+ return setTimeout(() => {
407
+ document.addEventListener("mousedown", f2, true);
408
+ }, 0), { isOpen: () => i2, close: m2, destroy: m2 };
409
+ }
410
+ function U(t2, e2) {
411
+ for (let n2 = 0; n2 < t2.length; n2++) {
412
+ const o2 = t2[n2];
413
+ o2 && o2.setAttribute("tabindex", n2 === e2 ? "0" : "-1");
414
+ }
415
+ }
416
+ function W(t2, e2) {
417
+ const o2 = t2.getState();
418
+ if (n(o2.selection)) return false;
419
+ const r2 = o2.selection, l2 = m(o2, r2.anchor.blockId);
420
+ return !!l2 && e2(o2, r2, l2);
421
+ }
422
+ function X(t2) {
423
+ return W(t2, (e2, n2, r2) => {
424
+ const l2 = r2.tableIndex + 1;
425
+ if (l2 >= e2.doc.children.length) return false;
426
+ const i2 = e2.doc.children[l2];
427
+ if (!i2) return false;
428
+ const a2 = e2.transaction("command").setSelection(o(i2.id, 0)).build();
429
+ return t2.dispatch(a2), true;
430
+ });
431
+ }
432
+ let G = null;
433
+ function J(t2, e2, n2, r2) {
434
+ const l2 = t2.getState(), i2 = g(l2, e2, n2, r2);
435
+ if (!i2) return false;
436
+ const a2 = w(l2, i2), s2 = l2.transaction("command").setSelection(o(a2, 0)).build();
437
+ return t2.dispatch(s2), true;
438
+ }
439
+ function Q(t2, e2, n2, r2) {
440
+ const l2 = t2.getState(), i2 = g(l2, e2, n2, r2);
441
+ if (!i2) return false;
442
+ const a2 = v(l2, i2), s2 = l2.getBlock(a2);
443
+ if (!s2) return false;
444
+ const c2 = h(s2), d2 = l2.transaction("command").setSelection(o(a2, c2)).build();
445
+ return t2.dispatch(d2), true;
446
+ }
447
+ function tt(t2, e2) {
448
+ const n2 = t2.getState(), o2 = n2.getNodePath(e2);
449
+ if (!o2) return false;
450
+ const l2 = n2.transaction("input").setSelection(r(e2, o2)).build();
451
+ return t2.dispatch(l2), true;
452
+ }
453
+ const et = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M6 1v10M1 6h10" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>';
454
+ function nt(t2, e2, n2) {
455
+ const o2 = document.createElement("button");
456
+ return o2.className = t2, o2.innerHTML = e2, o2.title = n2, o2.type = "button", o2.setAttribute("aria-label", n2), o2.setAttribute("contenteditable", "false"), o2.addEventListener("mousedown", (t3) => {
457
+ t3.preventDefault(), t3.stopPropagation();
458
+ }), o2;
459
+ }
460
+ function ot(t2, e2) {
461
+ const n2 = document.createElement("div");
462
+ n2.className = `ntbl-insert-line ntbl-insert-line--${t2}`, n2.setAttribute("contenteditable", "false"), n2.setAttribute("data-notectl-no-print", "");
463
+ const o2 = nt("ntbl-insert-btn", et, e2 ?? ("horizontal" === t2 ? "Insert row" : "Insert column"));
464
+ return n2.appendChild(o2), n2;
465
+ }
466
+ function rt(t2, e2) {
467
+ const n2 = document.createElement("button");
468
+ n2.className = `ntbl-add-zone ${t2}`, n2.type = "button", n2.setAttribute("contenteditable", "false"), n2.setAttribute("aria-label", e2), n2.setAttribute("data-notectl-no-print", ""), n2.title = e2;
469
+ const o2 = document.createElement("span");
470
+ return o2.className = "ntbl-add-icon", o2.innerHTML = et, n2.appendChild(o2), n2.addEventListener("mousedown", (t3) => {
471
+ t3.preventDefault(), t3.stopPropagation();
472
+ }), n2;
473
+ }
474
+ function lt(t2) {
475
+ const e2 = document.createElement("div");
476
+ return e2.className = t2, e2.setAttribute("contenteditable", "false"), e2.setAttribute("data-notectl-no-print", ""), e2;
477
+ }
478
+ function it(t2, e2) {
479
+ "none" === e2 ? (t2.style.backgroundColor = "transparent", t2.style.border = "1px dashed rgba(128,128,128,0.4)") : e2 ? (t2.style.backgroundColor = e2, t2.style.border = "1px solid rgba(0,0,0,0.15)") : (t2.style.backgroundColor = "var(--notectl-border)", t2.style.border = "1px solid rgba(0,0,0,0.15)");
480
+ }
481
+ function at(t2, e2, n2, o2) {
482
+ const r2 = document.createElement("div");
483
+ r2.className = `ntbl-handle ${t2}`, r2.dataset.index = String(e2);
484
+ const l2 = nt("ntbl-handle-delete", '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 2l6 6M8 2l-6 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>', n2);
485
+ return l2.addEventListener("click", (t3) => {
486
+ t3.preventDefault(), t3.stopPropagation(), o2(e2);
487
+ }), r2.appendChild(l2), r2;
488
+ }
489
+ function st(t2, e2) {
490
+ let n2 = 0, o2 = 0, r2 = t2;
491
+ for (; r2 && r2 !== e2; ) n2 += r2.offsetTop, o2 += r2.offsetLeft, r2 = r2.offsetParent;
492
+ return { top: n2, left: o2 };
493
+ }
494
+ class ct {
495
+ tableId;
496
+ numRows;
497
+ numCols;
498
+ activeRowIndex = -1;
499
+ activeColIndex = -1;
500
+ colBar;
501
+ rowBar;
502
+ insertLineH;
503
+ insertLineV;
504
+ addRowZone;
505
+ addColZone;
506
+ deleteTableBtn;
507
+ borderColorBtn;
508
+ actionsBtn;
509
+ contextHint;
510
+ observer;
511
+ borderColorPopup = null;
512
+ activeContextMenu = null;
513
+ container;
514
+ tableEl;
515
+ getState;
516
+ dispatchFn;
517
+ pluginContext;
518
+ locale;
519
+ onMouseMove = (t2) => {
520
+ const e2 = this.tableEl.getBoundingClientRect(), n2 = t2.clientX - e2.left, o2 = t2.clientY - e2.top;
521
+ if (!(n2 >= -10 && n2 <= e2.width + 10 && o2 >= -10 && o2 <= e2.height + 10)) return void this.hideInsertLines();
522
+ const r2 = (function(t3, e3, n3, o3) {
523
+ let r3 = Number.POSITIVE_INFINITY, l2 = null;
524
+ for (const t4 of n3) {
525
+ const n4 = Math.abs(e3 - t4.position);
526
+ n4 < r3 && n4 < 10 && (r3 = n4, l2 = t4);
527
+ }
528
+ let i2 = Number.POSITIVE_INFINITY, a2 = null;
529
+ for (const e4 of o3) {
530
+ const n4 = Math.abs(t3 - e4.position);
531
+ n4 < i2 && n4 < 10 && (i2 = n4, a2 = e4);
532
+ }
533
+ return l2 && (!a2 || r3 <= i2) ? { type: "row", border: l2 } : a2 ? { type: "col", border: a2 } : { type: "none", border: null };
534
+ })(n2, o2, (function(t3) {
535
+ const e3 = t3.querySelectorAll(":scope > tbody > tr"), n3 = t3.offsetTop, o3 = [];
536
+ for (let t4 = 1; t4 < e3.length; t4++) {
537
+ const r3 = e3[t4];
538
+ r3 && o3.push({ position: r3.offsetTop - n3, index: t4 });
539
+ }
540
+ return o3;
541
+ })(this.tableEl), (function(t3, e3) {
542
+ if (e3 <= 1) return [];
543
+ const n3 = t3 / e3, o3 = [];
544
+ for (let t4 = 1; t4 < e3; t4++) o3.push({ position: Math.round(n3 * t4), index: t4 });
545
+ return o3;
546
+ })(this.tableEl.offsetWidth, this.numCols));
547
+ "row" === r2.type && r2.border ? (this.showHorizontalLine(r2.border), this.hideVerticalLine()) : "col" === r2.type && r2.border ? (this.showVerticalLine(r2.border), this.hideHorizontalLine()) : this.hideInsertLines();
548
+ };
549
+ onMouseLeave = () => {
550
+ this.hideInsertLines();
551
+ };
552
+ constructor(t2, e2, n2, o2, r2, l2, i2 = C) {
553
+ if (this.container = t2, this.tableEl = e2, this.getState = o2, this.dispatchFn = r2, this.pluginContext = l2 ?? null, this.locale = i2, this.tableId = n2.id, this.numRows = c(n2).length, this.numCols = this.countCols(n2), this.colBar = lt("ntbl-col-bar"), this.rowBar = lt("ntbl-row-bar"), this.insertLineH = ot("horizontal", i2.insertRow), this.insertLineV = ot("vertical", i2.insertColumn), this.addRowZone = rt("ntbl-add-row", i2.addRow), this.addColZone = rt("ntbl-add-col", i2.addColumn), this.deleteTableBtn = nt("ntbl-delete-table-btn", '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M9 3h6m-9 4h12M10 11v6m4-6v6m-9 3h14l-1-13H6L5 20z" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>', i2.deleteTable), this.deleteTableBtn.setAttribute("data-notectl-no-print", ""), l2) {
554
+ const t3 = $(o2(), this.tableId);
555
+ this.borderColorBtn = (function(t4) {
556
+ const e3 = nt("ntbl-border-color-btn", '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M3 3h18v18H3V3zm0 6h18M3 15h18M9 3v18M15 3v18" stroke="currentColor" stroke-width="1.5"/></svg>', "Border color");
557
+ e3.setAttribute("data-notectl-no-print", "");
558
+ const n3 = document.createElement("span");
559
+ return n3.className = "ntbl-border-color-swatch", it(n3, t4), e3.appendChild(n3), e3;
560
+ })(t3), this.actionsBtn = (function(t4) {
561
+ const e3 = nt("ntbl-actions-btn", '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/></svg>', t4 ?? "Table actions (Right-click or Shift+F10)");
562
+ return e3.setAttribute("data-notectl-no-print", ""), e3;
563
+ })(i2.tableActionsHint);
564
+ } else this.borderColorBtn = null, this.actionsBtn = null;
565
+ t2.append(this.colBar, this.rowBar, this.insertLineH, this.insertLineV, this.addRowZone, this.addColZone, this.deleteTableBtn), this.borderColorBtn && t2.appendChild(this.borderColorBtn), this.actionsBtn && t2.appendChild(this.actionsBtn), this.contextHint = (function(t3) {
566
+ const e3 = document.createElement("div");
567
+ return e3.className = "ntbl-context-hint", e3.setAttribute("aria-hidden", "true"), e3.setAttribute("contenteditable", "false"), e3.setAttribute("data-notectl-no-print", ""), e3.textContent = t3 ?? "Right-click or Shift+F10 for table actions", e3;
568
+ })(i2.contextMenuHint), t2.appendChild(this.contextHint), this.rebuildColHandles(), this.rebuildRowHandles(), this.bindEventListeners(), this.observer = new ResizeObserver(() => {
569
+ this.positionControls();
570
+ }), this.observer.observe(e2), requestAnimationFrame(() => this.positionControls());
571
+ }
572
+ update(t2) {
573
+ this.tableId = t2.id;
574
+ const e2 = c(t2).length, n2 = this.countCols(t2);
575
+ if (e2 === this.numRows && n2 === this.numCols || (this.numRows = e2, this.numCols = n2, this.rebuildColHandles(), this.rebuildRowHandles()), this.borderColorBtn) {
576
+ const e3 = this.borderColorBtn.querySelector(".ntbl-border-color-swatch");
577
+ if (e3) {
578
+ const n3 = t2.attrs?.borderColor;
579
+ it(e3, n3);
580
+ }
581
+ }
582
+ requestAnimationFrame(() => this.positionControls());
583
+ }
584
+ destroy() {
585
+ this.activeContextMenu?.destroy(), this.closeBorderColorPopup(), this.observer.disconnect(), this.container.removeEventListener("mousemove", this.onMouseMove), this.container.removeEventListener("mouseleave", this.onMouseLeave), this.colBar.remove(), this.rowBar.remove(), this.insertLineH.remove(), this.insertLineV.remove(), this.addRowZone.remove(), this.addColZone.remove(), this.deleteTableBtn.remove(), this.borderColorBtn?.remove(), this.actionsBtn?.remove(), this.contextHint.remove();
586
+ }
587
+ bindEventListeners() {
588
+ const t2 = this.insertLineH.querySelector(".ntbl-insert-btn"), e2 = this.insertLineV.querySelector(".ntbl-insert-btn");
589
+ if (t2.addEventListener("click", () => {
590
+ this.activeRowIndex >= 0 && this.dispatchTransaction(z(this.getState(), this.tableId, this.activeRowIndex));
591
+ }), e2.addEventListener("click", () => {
592
+ this.activeColIndex >= 0 && this.dispatchTransaction(F(this.getState(), this.tableId, this.activeColIndex));
593
+ }), this.addRowZone.addEventListener("click", () => {
594
+ this.dispatchTransaction(z(this.getState(), this.tableId, this.numRows));
595
+ }), this.addColZone.addEventListener("click", () => {
596
+ this.dispatchTransaction(F(this.getState(), this.tableId, this.numCols));
597
+ }), this.deleteTableBtn.addEventListener("click", () => {
598
+ this.dispatchTransaction(j(this.getState(), this.tableId));
599
+ }), this.borderColorBtn && this.pluginContext) {
600
+ const t3 = this.pluginContext;
601
+ this.borderColorBtn.addEventListener("click", () => {
602
+ this.toggleBorderColorPopup(t3);
603
+ });
604
+ }
605
+ if (this.actionsBtn && this.pluginContext) {
606
+ const t3 = this.pluginContext;
607
+ this.actionsBtn.addEventListener("click", () => {
608
+ this.openActionsMenu(t3);
609
+ });
610
+ }
611
+ this.container.addEventListener("mousemove", this.onMouseMove), this.container.addEventListener("mouseleave", this.onMouseLeave);
612
+ }
613
+ openActionsMenu(t2) {
614
+ if (this.activeContextMenu?.isOpen()) return this.activeContextMenu.close(), void (this.activeContextMenu = null);
615
+ if (!this.actionsBtn) return;
616
+ const e2 = this.actionsBtn.getBoundingClientRect(), n2 = new DOMRect(e2.left, e2.bottom + 4, 0, 0);
617
+ this.activeContextMenu = Y(this.container, t2, this.tableId, n2, () => {
618
+ this.activeContextMenu = null;
619
+ }, this.locale);
620
+ }
621
+ toggleBorderColorPopup(t2) {
622
+ this.borderColorPopup ? this.closeBorderColorPopup() : (this.borderColorPopup = document.createElement("div"), this.borderColorPopup.className = "notectl-table-context-menu", this.borderColorPopup.style.position = "absolute", this.borderColorPopup.style.top = "24px", this.borderColorPopup.style.left = "24px", this.borderColorPopup.style.zIndex = "10000", this.borderColorPopup.setAttribute("contenteditable", "false"), N(this.borderColorPopup, t2, this.tableId, () => {
623
+ this.closeBorderColorPopup();
624
+ }, this.locale), this.container.appendChild(this.borderColorPopup));
625
+ }
626
+ closeBorderColorPopup() {
627
+ this.borderColorPopup && (this.borderColorPopup.remove(), this.borderColorPopup = null);
628
+ }
629
+ dispatchTransaction(t2) {
630
+ t2 && this.dispatchFn(t2);
631
+ }
632
+ countCols(t2) {
633
+ const e2 = c(t2);
634
+ return e2[0] ? c(e2[0]).length : 0;
635
+ }
636
+ positionControls() {
637
+ !(function(t2, e2, n2) {
638
+ const o2 = t2.children;
639
+ if (0 === o2.length) return;
640
+ const r2 = e2 / n2;
641
+ for (let t3 = 0; t3 < o2.length; t3++) {
642
+ const e3 = o2[t3];
643
+ e3.style.left = `${Math.round(r2 * t3)}px`, e3.style.width = `${Math.round(r2)}px`;
644
+ }
645
+ t2.style.width = `${e2}px`;
646
+ })(this.colBar, this.tableEl.offsetWidth, this.numCols), (function(t2, e2) {
647
+ const n2 = t2.children;
648
+ if (0 === n2.length) return;
649
+ const o2 = e2.querySelectorAll(":scope > tbody > tr"), r2 = e2.offsetTop;
650
+ let l2 = 0;
651
+ for (let t3 = 0; t3 < n2.length; t3++) {
652
+ const e3 = n2[t3], i2 = o2[t3];
653
+ if (i2) {
654
+ const t4 = i2.offsetTop - r2, n3 = i2.offsetHeight;
655
+ e3.style.top = `${t4}px`, e3.style.height = `${n3}px`, l2 = t4 + n3;
656
+ }
657
+ }
658
+ t2.style.height = `${l2}px`;
659
+ })(this.rowBar, this.tableEl), (function(t2, e2, n2, o2) {
660
+ const r2 = st(n2, o2), l2 = n2.offsetHeight, i2 = n2.offsetWidth;
661
+ t2.style.width = `${i2}px`, t2.style.left = `${r2.left}px`, e2.style.height = `${l2}px`, e2.style.top = `${r2.top}px`;
662
+ })(this.addRowZone, this.addColZone, this.tableEl, this.container);
663
+ }
664
+ showHorizontalLine(t2) {
665
+ this.activeRowIndex = t2.index;
666
+ const e2 = st(this.tableEl, this.container);
667
+ this.insertLineH.style.top = e2.top + t2.position - 1 + "px", this.insertLineH.style.left = `${e2.left}px`, this.insertLineH.style.width = `${this.tableEl.offsetWidth}px`, this.insertLineH.classList.add("ntbl-insert-line--visible");
668
+ }
669
+ showVerticalLine(t2) {
670
+ this.activeColIndex = t2.index;
671
+ const e2 = st(this.tableEl, this.container);
672
+ this.insertLineV.style.left = e2.left + t2.position - 1 + "px", this.insertLineV.style.top = `${e2.top}px`, this.insertLineV.style.height = `${this.tableEl.offsetHeight}px`, this.insertLineV.classList.add("ntbl-insert-line--visible");
673
+ }
674
+ hideInsertLines() {
675
+ this.hideHorizontalLine(), this.hideVerticalLine();
676
+ }
677
+ hideHorizontalLine() {
678
+ this.insertLineH.classList.remove("ntbl-insert-line--visible"), this.activeRowIndex = -1;
679
+ }
680
+ hideVerticalLine() {
681
+ this.insertLineV.classList.remove("ntbl-insert-line--visible"), this.activeColIndex = -1;
682
+ }
683
+ rebuildColHandles() {
684
+ this.colBar.innerHTML = "";
685
+ for (let t2 = 0; t2 < this.numCols; t2++) {
686
+ const e2 = at("ntbl-col-handle", t2, "Delete column", (t3) => {
687
+ this.dispatchTransaction(V(this.getState(), this.tableId, t3));
688
+ });
689
+ this.colBar.appendChild(e2);
690
+ }
691
+ }
692
+ rebuildRowHandles() {
693
+ this.rowBar.innerHTML = "";
694
+ for (let t2 = 0; t2 < this.numRows; t2++) {
695
+ const e2 = at("ntbl-row-handle", t2, "Delete row", (t3) => {
696
+ this.dispatchTransaction(_(this.getState(), this.tableId, t3));
697
+ });
698
+ this.rowBar.appendChild(e2);
699
+ }
700
+ }
701
+ }
702
+ function dt(t2, e2) {
703
+ "none" === e2 ? (t2.style.setProperty("--ntbl-border-color", "transparent"), t2.classList.add("notectl-table--borderless")) : e2 ? (t2.style.setProperty("--ntbl-border-color", e2), t2.classList.remove("notectl-table--borderless")) : (t2.style.removeProperty("--ntbl-border-color"), t2.classList.remove("notectl-table--borderless"));
704
+ }
705
+ const ut = new t("tableSelection");
706
+ const bt = { maxPickerRows: 8, maxPickerCols: 8 };
707
+ class ht {
708
+ id = "table";
709
+ name = "Table";
710
+ priority = 40;
711
+ config;
712
+ locale;
713
+ selectionService = null;
714
+ cleanupMouseSelection = null;
715
+ context = null;
716
+ constructor(t2) {
717
+ this.config = { ...bt, ...t2 };
718
+ }
719
+ init(t2) {
720
+ this.locale = e(B, t2, this.config.locale), t2.registerStyleSheet('\n/* Table */\n.notectl-table-wrapper {\n margin: 8px 0;\n overflow-x: auto;\n position: relative;\n}\n\n.notectl-table {\n width: 100%;\n border-collapse: collapse;\n table-layout: fixed;\n}\n\n.notectl-table td {\n border: 1px solid var(--ntbl-border-color, var(--notectl-border));\n padding: 8px 12px;\n min-width: 60px;\n vertical-align: top;\n min-height: 1.6em;\n}\n\n.notectl-table--borderless td {\n border: 1px dashed rgba(128, 128, 128, 0.15);\n}\n\n@media print {\n .notectl-table--borderless td {\n border: none;\n }\n}\n\n.notectl-table td:focus-within {\n outline: 2px solid var(--notectl-primary);\n outline-offset: -2px;\n}\n\n.notectl-table-cell--selected {\n background: var(--notectl-primary-muted);\n}\n\n/* Table Context Menu */\n.notectl-table-context-menu {\n position: fixed;\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px var(--notectl-shadow);\n padding: 4px 0;\n min-width: 180px;\n z-index: 10000;\n}\n\n.notectl-table-context-menu button {\n display: block;\n width: 100%;\n padding: 8px 12px;\n text-align: left;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n font-family: inherit;\n}\n\n.notectl-table-context-menu button:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-table-context-menu hr {\n border: none;\n border-top: 1px solid var(--notectl-border);\n margin: 4px 0;\n}\n\n/* === Table Controls === */\n\n/* Outer container for table + controls */\n.ntbl-container {\n position: relative;\n margin: 8px 0;\n padding: 24px 0 0 24px;\n}\n\n.ntbl-container .notectl-table-wrapper {\n margin: 0;\n}\n\n.ntbl-container.notectl-table--selected .notectl-table-wrapper {\n outline: 2px solid var(--notectl-primary-fg);\n outline-offset: 2px;\n border-radius: 6px;\n}\n\n/* --- Column Handle Bar --- */\n.ntbl-col-bar {\n position: absolute;\n top: 0;\n left: 24px;\n height: 20px;\n display: flex;\n opacity: 0;\n transition: opacity 0.2s ease;\n z-index: 3;\n pointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-col-bar,\n.ntbl-container:focus-within .ntbl-col-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-col-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* --- Row Handle Bar --- */\n.ntbl-row-bar {\n position: absolute;\n top: 24px;\n left: 0;\n width: 20px;\n display: flex;\n flex-direction: column;\n opacity: 0;\n transition: opacity 0.2s ease;\n z-index: 3;\n pointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-row-bar,\n.ntbl-container:focus-within .ntbl-row-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-row-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* --- Handle (shared base) --- */\n.ntbl-handle {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: background 0.15s ease;\n border-radius: 3px;\n}\n\n.ntbl-col-handle {\n height: 100%;\n background: var(--notectl-hover-bg);\n border-radius: 4px 4px 0 0;\n}\n\n.ntbl-col-handle:hover {\n background: var(--notectl-border);\n}\n\n.ntbl-row-handle {\n width: 100%;\n background: var(--notectl-hover-bg);\n border-radius: 4px 0 0 4px;\n}\n\n.ntbl-row-handle:hover {\n background: var(--notectl-border);\n}\n\n/* --- Handle Delete Button --- */\n.ntbl-handle-delete {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n border: none;\n background: transparent;\n color: var(--notectl-fg-muted);\n cursor: pointer;\n border-radius: 3px;\n padding: 0;\n opacity: 0;\n transform: scale(0.7);\n transition: opacity 0.15s, transform 0.15s,\n background 0.15s, color 0.15s;\n}\n\n.ntbl-handle:hover .ntbl-handle-delete,\n.ntbl-handle:focus-within .ntbl-handle-delete {\n opacity: 1;\n transform: scale(1);\n}\n\n.ntbl-handle-delete:hover,\n.ntbl-handle-delete:focus-visible {\n background: var(--notectl-danger-muted);\n color: var(--notectl-danger);\n}\n\n.ntbl-handle-delete:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Insert Lines --- */\n.ntbl-insert-line {\n position: absolute;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.15s ease;\n z-index: 6;\n}\n\n.ntbl-insert-line--visible {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-insert-line--horizontal {\n height: 2px;\n background: linear-gradient(\n 90deg,\n transparent,\n var(--notectl-primary) 8%,\n var(--notectl-primary) 92%,\n transparent\n );\n box-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--vertical {\n width: 2px;\n background: linear-gradient(\n 180deg,\n transparent,\n var(--notectl-primary) 8%,\n var(--notectl-primary) 92%,\n transparent\n );\n box-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n/* --- Insert Button on Line --- */\n.ntbl-insert-btn {\n position: absolute;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n background: var(--notectl-bg);\n border: 2px solid var(--notectl-primary);\n color: var(--notectl-primary);\n cursor: pointer;\n pointer-events: all;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n box-shadow: 0 2px 8px var(--notectl-focus-ring);\n transition: background 0.15s, color 0.15s,\n transform 0.15s, box-shadow 0.15s;\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn {\n left: 50%;\n top: -9px;\n transform: translateX(-50%);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn {\n top: 50%;\n left: -9px;\n transform: translateY(-50%);\n}\n\n.ntbl-insert-btn:hover,\n.ntbl-insert-btn:focus-visible {\n background: var(--notectl-primary);\n color: var(--notectl-bg);\n box-shadow: 0 2px 12px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn:hover {\n transform: translateX(-50%) scale(1.2);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn:hover {\n transform: translateY(-50%) scale(1.2);\n}\n\n/* --- Add Row / Add Column Zones --- */\n.ntbl-add-zone {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n user-select: none;\n opacity: 0;\n transition: opacity 0.2s ease, background 0.2s ease,\n border-color 0.2s ease;\n}\n\n.ntbl-container:hover .ntbl-add-zone,\n.ntbl-container:focus-within .ntbl-add-zone {\n opacity: 1;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-add-zone {\n opacity: 1;\n}\n\n.ntbl-delete-table-btn {\n position: absolute;\n top: 0;\n left: 0;\n width: 20px;\n height: 20px;\n border: 1px solid var(--notectl-danger);\n border-radius: 4px;\n background: var(--notectl-bg);\n color: var(--notectl-danger);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n transition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n z-index: 7;\n}\n\n.ntbl-container:hover .ntbl-delete-table-btn,\n.ntbl-container:focus-within .ntbl-delete-table-btn,\n.ntbl-container.notectl-table--selected .ntbl-delete-table-btn {\n opacity: 1;\n}\n\n.ntbl-delete-table-btn:hover,\n.ntbl-delete-table-btn:focus-visible {\n background: var(--notectl-danger-muted);\n border-color: var(--notectl-danger);\n}\n\n.ntbl-delete-table-btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Context Menu Discovery Hint --- */\n.ntbl-context-hint {\n position: absolute;\n top: 4px;\n right: 0;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n padding: 2px 8px;\n border-radius: 4px;\n opacity: 0;\n transition: opacity 0.2s ease;\n pointer-events: none;\n white-space: nowrap;\n z-index: 5;\n}\n\n.ntbl-container:hover .ntbl-context-hint,\n.ntbl-container:focus-within .ntbl-context-hint,\n.ntbl-container.notectl-table--selected .ntbl-context-hint {\n opacity: 1;\n}\n\n/* --- Table Actions Button --- */\n.ntbl-actions-btn {\n position: absolute;\n top: 0;\n left: 48px;\n width: 20px;\n height: 20px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n background: var(--notectl-bg);\n color: var(--notectl-fg-muted);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n transition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n z-index: 7;\n cursor: pointer;\n padding: 0;\n}\n\n.ntbl-container:hover .ntbl-actions-btn,\n.ntbl-container:focus-within .ntbl-actions-btn,\n.ntbl-container.notectl-table--selected .ntbl-actions-btn {\n opacity: 1;\n}\n\n.ntbl-actions-btn:hover,\n.ntbl-actions-btn:focus-visible {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-primary);\n}\n\n.ntbl-actions-btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Border Color Button --- */\n.ntbl-border-color-btn {\n position: absolute;\n top: 0;\n left: 24px;\n width: 20px;\n height: 20px;\n border: 1px solid var(--notectl-border);\n border-radius: 4px;\n background: var(--notectl-bg);\n color: var(--notectl-fg-muted);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n transition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n z-index: 7;\n cursor: pointer;\n padding: 0;\n}\n\n.ntbl-container:hover .ntbl-border-color-btn,\n.ntbl-container:focus-within .ntbl-border-color-btn,\n.ntbl-container.notectl-table--selected .ntbl-border-color-btn {\n opacity: 1;\n}\n\n.ntbl-border-color-btn:hover,\n.ntbl-border-color-btn:focus-visible {\n background: var(--notectl-hover-bg);\n border-color: var(--notectl-primary);\n}\n\n.ntbl-border-color-btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-border-color-swatch {\n width: 10px;\n height: 10px;\n border-radius: 2px;\n border: 1px solid rgba(0, 0, 0, 0.15);\n}\n\n/* --- Context Menu Keyboard Hint --- */\n.notectl-table-context-menu__hint {\n padding: 4px 12px 6px;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n border-top: 1px solid var(--notectl-border);\n margin-top: 4px;\n text-align: center;\n user-select: none;\n}\n\n/* --- Context Menu Focus --- */\n.notectl-table-context-menu button:focus-visible {\n outline: none;\n background: var(--notectl-primary-muted);\n box-shadow: inset 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.notectl-table-context-menu [role="separator"] {\n border: none;\n border-top: 1px solid var(--notectl-border);\n margin: 4px 0;\n height: 0;\n}\n\n.ntbl-add-row {\n bottom: 0;\n height: 24px;\n border: 1px dashed var(--notectl-border);\n border-radius: 0 0 6px 6px;\n border-top: none;\n color: var(--notectl-fg-muted);\n transform: translateY(100%);\n}\n\n.ntbl-add-row:hover,\n.ntbl-add-row:focus-visible {\n background: var(--notectl-primary-muted);\n border-color: var(--notectl-primary);\n color: var(--notectl-primary);\n}\n\n.ntbl-add-row:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-col {\n right: 0;\n top: 24px;\n width: 24px;\n border: 1px dashed var(--notectl-border);\n border-radius: 0 6px 6px 0;\n border-left: none;\n color: var(--notectl-fg-muted);\n transform: translateX(100%);\n}\n\n.ntbl-add-col:hover,\n.ntbl-add-col:focus-visible {\n background: var(--notectl-primary-muted);\n border-color: var(--notectl-primary);\n color: var(--notectl-primary);\n}\n\n.ntbl-add-col:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n transition: transform 0.2s ease;\n}\n\n.ntbl-add-zone:hover .ntbl-add-icon {\n transform: scale(1.15);\n}\n'), this.context = t2, this.registerNodeSpecs(t2), this.registerNodeViews(t2), K(t2, this.locale), t2.registerCommand("resetTableBorderColor", () => H(t2, this.locale)), (function(t3, e2) {
721
+ const o2 = { Tab: () => (function(t4, e3) {
722
+ return W(t4, (n2, o3, r2) => r2.colIndex < r2.totalCols - 1 ? J(t4, r2.tableId, r2.rowIndex, r2.colIndex + 1) : r2.rowIndex < r2.totalRows - 1 ? J(t4, r2.tableId, r2.rowIndex + 1, 0) : (q(t4, e3), true));
723
+ })(t3, e2), "Shift-Tab": () => (function(t4) {
724
+ return W(t4, (e3, n2, o3) => o3.colIndex > 0 ? J(t4, o3.tableId, o3.rowIndex, o3.colIndex - 1) : !(o3.rowIndex > 0) || J(t4, o3.tableId, o3.rowIndex - 1, o3.totalCols - 1));
725
+ })(t3), Enter: () => (function(t4) {
726
+ const e3 = t4.getState();
727
+ if (n(e3.selection)) return false;
728
+ const o3 = e3.getBlock(e3.selection.anchor.blockId);
729
+ if (o3 && "paragraph" !== o3.type) return false;
730
+ const r2 = m(e3, e3.selection.anchor.blockId);
731
+ return !!r2 && (!(r2.rowIndex < r2.totalRows - 1) || J(t4, r2.tableId, r2.rowIndex + 1, r2.colIndex));
732
+ })(t3), Backspace: () => (function(t4) {
733
+ return W(t4, (e3, n2, o3) => {
734
+ if (!l(n2)) return false;
735
+ if (0 !== n2.anchor.offset) return false;
736
+ if (0 !== o3.rowIndex || 0 !== o3.colIndex) return false;
737
+ const r2 = w(e3, o3.cellId);
738
+ return n2.anchor.blockId === r2 && tt(t4, o3.tableId);
739
+ });
740
+ })(t3), Delete: () => (function(t4) {
741
+ return W(t4, (e3, n2, o3) => {
742
+ if (!l(n2)) return false;
743
+ const r2 = e3.getBlock(n2.anchor.blockId);
744
+ if (!r2) return false;
745
+ const i2 = h(r2);
746
+ if (n2.anchor.offset !== i2) return false;
747
+ if (o3.rowIndex !== o3.totalRows - 1 || o3.colIndex !== o3.totalCols - 1) return false;
748
+ const a2 = v(e3, o3.cellId);
749
+ return n2.anchor.blockId === a2 && tt(t4, o3.tableId);
750
+ });
751
+ })(t3), ArrowDown: () => (function(t4) {
752
+ return W(t4, (e3, n2, o3) => {
753
+ const r2 = v(e3, o3.cellId);
754
+ return n2.anchor.blockId === r2 && (o3.rowIndex >= o3.totalRows - 1 ? X(t4) : J(t4, o3.tableId, o3.rowIndex + 1, o3.colIndex));
755
+ });
756
+ })(t3), ArrowUp: () => (function(t4) {
757
+ return W(t4, (e3, n2, o3) => {
758
+ const r2 = w(e3, o3.cellId);
759
+ return n2.anchor.blockId === r2 && !(o3.rowIndex <= 0) && J(t4, o3.tableId, o3.rowIndex - 1, o3.colIndex);
760
+ });
761
+ })(t3), ArrowRight: () => (function(t4) {
762
+ return W(t4, (e3, n2, o3) => {
763
+ if (!l(n2)) return false;
764
+ const r2 = e3.getBlock(n2.anchor.blockId);
765
+ if (!r2) return false;
766
+ const i2 = h(r2);
767
+ if (n2.anchor.offset !== i2) return false;
768
+ const a2 = v(e3, o3.cellId);
769
+ return n2.anchor.blockId === a2 && (o3.colIndex < o3.totalCols - 1 ? J(t4, o3.tableId, o3.rowIndex, o3.colIndex + 1) : !(o3.rowIndex < o3.totalRows - 1) || J(t4, o3.tableId, o3.rowIndex + 1, 0));
770
+ });
771
+ })(t3), ArrowLeft: () => (function(t4) {
772
+ return W(t4, (e3, n2, o3) => {
773
+ if (!l(n2)) return false;
774
+ if (0 !== n2.anchor.offset) return false;
775
+ const r2 = w(e3, o3.cellId);
776
+ return n2.anchor.blockId === r2 && (o3.colIndex > 0 ? Q(t4, o3.tableId, o3.rowIndex, o3.colIndex - 1) : !(o3.rowIndex > 0) || Q(t4, o3.tableId, o3.rowIndex - 1, o3.totalCols - 1));
777
+ });
778
+ })(t3), Escape: () => X(t3), "Shift-F10": () => (function(t4) {
779
+ return W(t4, (e3, n2, o3) => {
780
+ const r2 = t4.getContainer(), l2 = r2.querySelector(`[data-block-id="${o3.cellId}"]`);
781
+ if (!l2) return false;
782
+ const i2 = l2.getBoundingClientRect(), a2 = new DOMRect(i2.left + i2.width / 2, i2.bottom, 0, 0), s2 = r2.querySelector(`[data-block-id="${o3.tableId}"].ntbl-container`) ?? r2;
783
+ return G?.close(), G = Y(s2, t4, o3.tableId, a2, () => {
784
+ G = null;
785
+ }), true;
786
+ });
787
+ })(t3) };
788
+ t3.registerKeymap(o2);
789
+ })(t2, this.locale), this.registerToolbarItem(t2), this.selectionService = (function(t3) {
790
+ let e2 = null, n2 = [], o2 = /* @__PURE__ */ new Set();
791
+ const r2 = { getSelectedRange: () => e2, setSelectedRange(r3) {
792
+ e2 = r3, (function() {
793
+ if (!e2) return n2 = [], void (o2 = /* @__PURE__ */ new Set());
794
+ const r4 = t3.getState(), l2 = [], i2 = Math.min(e2.fromRow, e2.toRow), a2 = Math.max(e2.fromRow, e2.toRow), s2 = Math.min(e2.fromCol, e2.toCol), c2 = Math.max(e2.fromCol, e2.toCol);
795
+ for (let t4 = i2; t4 <= a2; t4++) for (let n3 = s2; n3 <= c2; n3++) {
796
+ const o3 = g(r4, e2.tableId, t4, n3);
797
+ o3 && l2.push(o3);
798
+ }
799
+ n2 = l2, o2 = new Set(l2);
800
+ })(), (function(t4, e3) {
801
+ const n3 = t4.getContainer().querySelectorAll("td[data-block-id]");
802
+ for (const t5 of n3) {
803
+ const n4 = t5.getAttribute("data-block-id");
804
+ e3.has(n4) ? t5.classList.add("notectl-table-cell--selected") : t5.classList.remove("notectl-table-cell--selected");
805
+ }
806
+ })(t3, o2);
807
+ }, getSelectedCellIds: () => n2, isSelected: (t4) => o2.has(t4) };
808
+ return t3.registerService(ut, r2), r2;
809
+ })(t2);
810
+ }
811
+ onReady() {
812
+ this.context && this.selectionService && (this.cleanupMouseSelection = (function(t2, e2) {
813
+ const n2 = t2.getContainer();
814
+ let o2 = null, r2 = false;
815
+ function l2(n3) {
816
+ const l3 = n3.target.closest("td[data-block-id]");
817
+ if (l3) if (n3.shiftKey) {
818
+ if (o2) {
819
+ const r3 = m(t2.getState(), l3.getAttribute("data-block-id"));
820
+ if (!r3 || r3.tableId !== o2.tableId) return;
821
+ n3.preventDefault(), e2.setSelectedRange({ tableId: o2.tableId, fromRow: o2.row, fromCol: o2.col, toRow: r3.rowIndex, toCol: r3.colIndex });
822
+ }
823
+ } else {
824
+ e2.setSelectedRange(null);
825
+ const n4 = m(t2.getState(), l3.getAttribute("data-block-id"));
826
+ if (!n4) return;
827
+ o2 = { tableId: n4.tableId, row: n4.rowIndex, col: n4.colIndex }, r2 = true;
828
+ }
829
+ else e2.setSelectedRange(null);
830
+ }
831
+ function i2(n3) {
832
+ if (!r2 || !o2) return;
833
+ const l3 = n3.target.closest("td[data-block-id]");
834
+ if (!l3) return;
835
+ const i3 = m(t2.getState(), l3.getAttribute("data-block-id"));
836
+ i3 && i3.tableId === o2.tableId && (i3.rowIndex === o2.row && i3.colIndex === o2.col || (n3.preventDefault(), e2.setSelectedRange({ tableId: o2.tableId, fromRow: o2.row, fromCol: o2.col, toRow: i3.rowIndex, toCol: i3.colIndex })));
837
+ }
838
+ function a2() {
839
+ r2 = false;
840
+ }
841
+ return n2.addEventListener("mousedown", l2), n2.addEventListener("mousemove", i2), document.addEventListener("mouseup", a2), () => {
842
+ n2.removeEventListener("mousedown", l2), n2.removeEventListener("mousemove", i2), document.removeEventListener("mouseup", a2);
843
+ };
844
+ })(this.context, this.selectionService));
845
+ }
846
+ destroy() {
847
+ this.cleanupMouseSelection?.(), this.cleanupMouseSelection = null, this.selectionService = null, this.context = null;
848
+ }
849
+ onStateChange(t2, e2, o2) {
850
+ if (this.selectionService?.getSelectedRange()) {
851
+ const t3 = e2.selection;
852
+ !n(t3) && x(e2, t3.anchor.blockId) || this.selectionService.setSelectedRange(null);
853
+ }
854
+ }
855
+ registerNodeSpecs(t2) {
856
+ t2.registerNodeSpec({ type: "table", group: "block", content: { allow: ["table_row"], min: 1 }, isolating: true, selectable: true, toDOM(t3) {
857
+ const e2 = document.createElement("div");
858
+ return e2.className = "notectl-table-wrapper", e2.setAttribute("data-block-id", t3.id), e2;
859
+ } }), t2.registerNodeSpec({ type: "table_row", group: "table_content", content: { allow: ["table_cell"], min: 1 }, toDOM(t3) {
860
+ const e2 = document.createElement("tr");
861
+ return e2.setAttribute("data-block-id", t3.id), e2.setAttribute("role", "row"), e2;
862
+ } }), t2.registerNodeSpec({ type: "table_cell", group: "table_content", content: { allow: ["paragraph", "list_item", "heading", "blockquote", "image", "horizontal_rule"] }, isolating: true, toDOM(t3) {
863
+ const e2 = document.createElement("td");
864
+ return e2.setAttribute("data-block-id", t3.id), e2.setAttribute("role", "cell"), e2;
865
+ } });
866
+ }
867
+ registerNodeViews(t2) {
868
+ t2.getSchemaRegistry(), t2.registerNodeView("table", /* @__PURE__ */ (function(t3, e2, n2 = C) {
869
+ return (t4, o2, r2) => {
870
+ const l2 = document.createElement("div");
871
+ l2.className = "ntbl-container", l2.setAttribute("data-block-id", t4.id), l2.setAttribute("data-selectable", "true");
872
+ const i2 = document.createElement("div");
873
+ i2.className = "notectl-table-wrapper";
874
+ const a2 = document.createElement("table");
875
+ a2.className = "notectl-table", a2.setAttribute("role", "table");
876
+ const s2 = c(t4), d2 = s2.length, u2 = s2[0] ? c(s2[0]).length : 0;
877
+ a2.setAttribute("aria-label", n2.tableAriaLabel(d2, u2)), a2.setAttribute("aria-description", n2.tableAriaDescription);
878
+ const b2 = document.createElement("tbody");
879
+ a2.appendChild(b2), i2.appendChild(a2), l2.appendChild(i2), dt(a2, t4.attrs?.borderColor);
880
+ const h2 = document.createElement("div");
881
+ h2.className = "notectl-sr-only", h2.setAttribute("aria-live", "polite"), h2.setAttribute("aria-atomic", "true"), l2.appendChild(h2);
882
+ const p2 = (function(t5, e3, n3, o3, r3, l3, i3) {
883
+ return new ct(t5, e3, n3, o3, r3, l3, i3);
884
+ })(l2, a2, t4, o2, r2, e2, n2);
885
+ let f2 = null, m2 = t4.id;
886
+ const g2 = (t5) => {
887
+ if (!e2) return;
888
+ t5.preventDefault(), t5.stopPropagation(), f2?.close();
889
+ const o3 = new DOMRect(t5.clientX, t5.clientY, 0, 0);
890
+ f2 = Y(l2, e2, m2, o3, () => {
891
+ f2 = null;
892
+ }, n2);
893
+ };
894
+ return a2.addEventListener("contextmenu", g2), { dom: l2, contentDOM: b2, update(t5) {
895
+ if ("table" !== t5.type) return false;
896
+ m2 = t5.id, l2.setAttribute("data-block-id", t5.id), l2.setAttribute("data-selectable", "true");
897
+ const e3 = c(t5), o3 = e3.length, r3 = e3[0] ? c(e3[0]).length : 0;
898
+ return a2.setAttribute("aria-label", n2.tableAriaLabel(o3, r3)), dt(a2, t5.attrs?.borderColor), p2.update(t5), false;
899
+ }, destroy() {
900
+ f2?.destroy(), a2.removeEventListener("contextmenu", g2), p2.destroy();
901
+ }, selectNode() {
902
+ l2.classList.add("notectl-table--selected");
903
+ }, deselectNode() {
904
+ l2.classList.remove("notectl-table--selected");
905
+ } };
906
+ };
907
+ })(0, t2, this.locale)), t2.registerNodeView("table_row", (t3, e2, n2) => {
908
+ const o2 = document.createElement("tr");
909
+ return o2.setAttribute("data-block-id", t3.id), o2.setAttribute("role", "row"), { dom: o2, contentDOM: o2, update: (t4) => ("table_row" !== t4.type || o2.setAttribute("data-block-id", t4.id), false), destroy() {
910
+ } };
911
+ }), t2.registerNodeView("table_cell", (t3, e2, n2) => {
912
+ const o2 = document.createElement("td");
913
+ o2.setAttribute("data-block-id", t3.id), o2.setAttribute("role", "cell");
914
+ const r2 = t3.attrs?.colspan ?? 1, l2 = t3.attrs?.rowspan ?? 1;
915
+ r2 > 1 && (o2.colSpan = r2), l2 > 1 && (o2.rowSpan = l2);
916
+ const i2 = t3.attrs?.align;
917
+ return i2 && "left" !== i2 && (o2.style.textAlign = i2), { dom: o2, contentDOM: o2, update(t4) {
918
+ if ("table_cell" !== t4.type) return false;
919
+ o2.setAttribute("data-block-id", t4.id);
920
+ const e3 = t4.attrs?.colspan ?? 1, n3 = t4.attrs?.rowspan ?? 1;
921
+ return e3 > 1 ? o2.colSpan = e3 : o2.removeAttribute("colspan"), n3 > 1 ? o2.rowSpan = n3 : o2.removeAttribute("rowspan"), false;
922
+ }, destroy() {
923
+ } };
924
+ });
925
+ }
926
+ registerToolbarItem(t2) {
927
+ const e2 = this.config.maxPickerRows ?? 8, o2 = this.config.maxPickerCols ?? 8;
928
+ t2.registerToolbarItem({ id: "table", group: "insert", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 3h18v18H3V3zm2 2v4h6V5H5zm8 0v4h6V5h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6z"/></svg>', label: this.locale.insertTable, tooltip: this.locale.insertTable, command: "insertTable", priority: 80, separatorAfter: this.config.separatorAfter, popupType: "gridPicker", popupConfig: { maxRows: e2, maxCols: o2, onSelect: (e3, n2) => {
929
+ Z(t2, e3, n2);
930
+ } }, isActive: (t3) => !n(t3.selection) && x(t3, t3.selection.anchor.blockId) });
931
+ }
932
+ }
933
+ export {
934
+ E as B,
935
+ B as T,
936
+ S as a,
937
+ I as b,
938
+ C as c,
939
+ y as d,
940
+ R as e,
941
+ L as f,
942
+ A as g,
943
+ k as h,
944
+ ht as i,
945
+ ut as j,
946
+ m as k,
947
+ x as l,
948
+ Y as m,
949
+ $ as n,
950
+ H as r,
951
+ M as s
952
+ };
953
+ //# sourceMappingURL=index-BSFLNveF.mjs.map