@editora/plugins 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/table.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as Z } from "./notify-zOp-mUOJ.mjs";
2
2
  import { f as $, g as ee } from "./editorContainerHelpers-C7kdWnS0.mjs";
3
- let h = null, b = null, V = null, B = null, N = null, D = null, q = null;
3
+ let h = null, b = null, B = null, V = null, N = null, D = null, q = null;
4
4
  const H = '[data-theme="dark"], .dark, .editora-theme-dark';
5
5
  let E = !1, k = null, O = 0, P = 0, R = !1, K = 0, W = 0, _ = 0, X = 0;
6
6
  const te = /* @__PURE__ */ new Set([
@@ -19,11 +19,11 @@ const te = /* @__PURE__ */ new Set([
19
19
  "TH"
20
20
  ]);
21
21
  function F(e, t) {
22
- let n = e;
23
- for (; n && n !== t; ) {
24
- if (n.nodeType === Node.ELEMENT_NODE && te.has(n.tagName))
25
- return n;
26
- n = n.parentNode;
22
+ let o = e;
23
+ for (; o && o !== t; ) {
24
+ if (o.nodeType === Node.ELEMENT_NODE && te.has(o.tagName))
25
+ return o;
26
+ o = o.parentNode;
27
27
  }
28
28
  return null;
29
29
  }
@@ -31,16 +31,16 @@ function Y(e) {
31
31
  const t = e.parentElement;
32
32
  if (t && t.classList.contains("rte-table-wrapper"))
33
33
  return t;
34
- const n = document.createElement("div");
35
- return n.className = "rte-table-wrapper", t?.insertBefore(n, e), n.appendChild(e), n;
34
+ const o = window.getSelection(), { anchorNode: n, anchorOffset: l, focusNode: r, focusOffset: a } = o ?? {}, i = !!o && !!n && !!r && (e.contains(n) || e.contains(r)), c = document.createElement("div");
35
+ return c.className = "rte-table-wrapper", t?.insertBefore(c, e), c.appendChild(e), i && o && n && r && n.isConnected && r.isConnected && o.setBaseAndExtent(n, l ?? 0, r, a ?? 0), c;
36
36
  }
37
37
  const ne = () => {
38
38
  const e = $(), t = ee(e);
39
39
  if (!t)
40
40
  return Z("Please place your cursor in the editor before inserting a table"), !1;
41
- const n = window.getSelection();
42
- if (!n || n.rangeCount === 0) return;
43
- const o = n.getRangeAt(0), l = document.createElement("table");
41
+ const o = window.getSelection();
42
+ if (!o || o.rangeCount === 0) return;
43
+ const n = o.getRangeAt(0), l = document.createElement("table");
44
44
  l.className = "rte-table";
45
45
  const r = document.createElement("thead"), a = document.createElement("tr");
46
46
  for (let m = 0; m < 3; m++) {
@@ -58,120 +58,120 @@ const ne = () => {
58
58
  i.appendChild(g);
59
59
  }
60
60
  l.appendChild(r), l.appendChild(i);
61
- const u = Y(l), d = (m, g, v) => {
61
+ const c = Y(l), d = (m, g, v) => {
62
62
  if (m !== t) return m;
63
63
  const x = v ? g - 1 : g;
64
64
  return t.childNodes[Math.min(Math.max(x, 0), t.childNodes.length - 1)] || null;
65
- }, s = d(o.endContainer, o.endOffset, !0), c = d(o.startContainer, o.startOffset, !1), C = s && F(s, t) || c && F(c, t);
66
- C && C.parentNode ? C.parentNode.insertBefore(u, C.nextSibling) : (o.collapse(!1), o.insertNode(u));
65
+ }, s = d(n.endContainer, n.endOffset, !0), u = d(n.startContainer, n.startOffset, !1), C = s && F(s, t) || u && F(u, t);
66
+ C && C.parentNode ? C.parentNode.insertBefore(c, C.nextSibling) : (n.collapse(!1), n.insertNode(c));
67
67
  const L = l.querySelector("th p");
68
68
  if (L) {
69
69
  const m = document.createRange();
70
- m.setStart(L, 0), m.collapse(!0), n.removeAllRanges(), n.addRange(m);
70
+ m.setStart(L, 0), m.collapse(!0), o.removeAllRanges(), o.addRange(m);
71
71
  }
72
72
  t.focus();
73
73
  }, oe = () => {
74
74
  const e = f();
75
75
  if (!e) return;
76
- const { table: t, rowIndex: n } = e, o = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
76
+ const { table: t, rowIndex: o } = e, n = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
77
77
  for (let a = 0; a < l; a++) {
78
- const i = document.createElement("td"), u = document.createElement("p");
79
- u.innerHTML = "<br>", i.appendChild(u), o.appendChild(i);
78
+ const i = document.createElement("td"), c = document.createElement("p");
79
+ c.innerHTML = "<br>", i.appendChild(c), n.appendChild(i);
80
80
  }
81
- const r = t.rows[n];
82
- r && r.parentElement ? r.parentElement.insertBefore(o, r) : t.appendChild(o), p();
81
+ const r = t.rows[o];
82
+ r && r.parentElement ? r.parentElement.insertBefore(n, r) : t.appendChild(n), p();
83
83
  }, re = () => {
84
84
  const e = f();
85
85
  if (!e) return;
86
- const { table: t, rowIndex: n } = e, o = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
86
+ const { table: t, rowIndex: o } = e, n = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
87
87
  for (let r = 0; r < l; r++) {
88
88
  const a = document.createElement("td"), i = document.createElement("p");
89
- i.innerHTML = "<br>", a.appendChild(i), o.appendChild(a);
89
+ i.innerHTML = "<br>", a.appendChild(i), n.appendChild(a);
90
90
  }
91
- if (n >= t.rows.length - 1) {
91
+ if (o >= t.rows.length - 1) {
92
92
  const r = t.rows[t.rows.length - 1];
93
- r && r.parentElement ? r.parentElement.appendChild(o) : t.appendChild(o);
93
+ r && r.parentElement ? r.parentElement.appendChild(n) : t.appendChild(n);
94
94
  } else {
95
- const r = t.rows[n + 1];
96
- r.parentElement?.insertBefore(o, r);
95
+ const r = t.rows[o + 1];
96
+ r.parentElement?.insertBefore(n, r);
97
97
  }
98
98
  p();
99
99
  }, le = () => {
100
100
  const e = f();
101
101
  if (!e) return;
102
- const { table: t, colIndex: n } = e;
103
- for (let o = 0; o < t.rows.length; o++) {
104
- const l = t.rows[o], r = document.createElement("td"), a = document.createElement("p");
105
- a.innerHTML = "<br>", r.appendChild(a), n === 0 ? l.insertBefore(r, l.cells[0]) : l.insertBefore(r, l.cells[n]);
102
+ const { table: t, colIndex: o } = e;
103
+ for (let n = 0; n < t.rows.length; n++) {
104
+ const l = t.rows[n], r = document.createElement("td"), a = document.createElement("p");
105
+ a.innerHTML = "<br>", r.appendChild(a), o === 0 ? l.insertBefore(r, l.cells[0]) : l.insertBefore(r, l.cells[o]);
106
106
  }
107
107
  p();
108
108
  }, ae = () => {
109
109
  const e = f();
110
110
  if (!e) return;
111
- const { table: t, colIndex: n } = e;
112
- for (let o = 0; o < t.rows.length; o++) {
113
- const l = t.rows[o], r = document.createElement("td"), a = document.createElement("p");
114
- a.innerHTML = "<br>", r.appendChild(a), n >= l.cells.length - 1 ? l.appendChild(r) : l.insertBefore(r, l.cells[n + 1]);
111
+ const { table: t, colIndex: o } = e;
112
+ for (let n = 0; n < t.rows.length; n++) {
113
+ const l = t.rows[n], r = document.createElement("td"), a = document.createElement("p");
114
+ a.innerHTML = "<br>", r.appendChild(a), o >= l.cells.length - 1 ? l.appendChild(r) : l.insertBefore(r, l.cells[o + 1]);
115
115
  }
116
116
  p();
117
117
  }, ie = () => {
118
118
  const e = f();
119
119
  if (!e || e.rowCount <= 1) return;
120
- const { table: t, rowIndex: n, colIndex: o } = e;
121
- t.deleteRow(n), G(t, n, o), p();
120
+ const { table: t, rowIndex: o, colIndex: n } = e;
121
+ t.deleteRow(o), G(t, o, n), p();
122
122
  }, de = () => {
123
123
  const e = f();
124
124
  if (!e || e.cellCount <= 1) return;
125
- const { table: t, rowIndex: n, colIndex: o } = e;
125
+ const { table: t, rowIndex: o, colIndex: n } = e;
126
126
  for (let l = 0; l < t.rows.length; l++) {
127
127
  const r = t.rows[l];
128
- r.cells[o] && r.deleteCell(o);
128
+ r.cells[n] && r.deleteCell(n);
129
129
  }
130
- G(t, n, o), p();
130
+ G(t, o, n), p();
131
131
  }, se = () => {
132
132
  const e = f();
133
133
  if (!e) return;
134
- const { table: t, rowIndex: n } = e, o = t.rows[n];
135
- if (!o) return;
136
- const l = o.parentElement?.tagName.toLowerCase() === "thead", r = t.querySelector("thead");
134
+ const { table: t, rowIndex: o } = e, n = t.rows[o];
135
+ if (!n) return;
136
+ const l = n.parentElement?.tagName.toLowerCase() === "thead", r = t.querySelector("thead");
137
137
  if (l) {
138
- const a = o.parentElement;
139
- if (o === a.rows[a.rows.length - 1]) {
138
+ const a = n.parentElement;
139
+ if (n === a.rows[a.rows.length - 1]) {
140
140
  const i = t.querySelector("tbody") || t.appendChild(document.createElement("tbody"));
141
- i.insertBefore(o, i.firstChild), a.rows.length === 0 && a.remove();
141
+ i.insertBefore(n, i.firstChild), a.rows.length === 0 && a.remove();
142
142
  } else
143
- U(o, "td");
144
- } else if (!r || o === t.tBodies[0]?.rows[0]) {
143
+ U(n, "td");
144
+ } else if (!r || n === t.tBodies[0]?.rows[0]) {
145
145
  let a = r;
146
- a || (a = document.createElement("thead"), t.insertBefore(a, t.firstChild)), a.appendChild(o);
146
+ a || (a = document.createElement("thead"), t.insertBefore(a, t.firstChild)), a.appendChild(n);
147
147
  } else
148
- U(o, "th");
148
+ U(n, "th");
149
149
  p();
150
150
  };
151
151
  function U(e, t) {
152
- Array.from(e.cells).forEach((n) => {
153
- if (n.tagName.toLowerCase() === t) return;
154
- const o = document.createElement(t);
155
- o.innerHTML = n.innerHTML;
156
- for (let l = 0; l < n.attributes.length; l++) {
157
- const r = n.attributes[l];
158
- o.setAttribute(r.name, r.value);
159
- }
160
- n.parentNode?.replaceChild(o, n);
152
+ Array.from(e.cells).forEach((o) => {
153
+ if (o.tagName.toLowerCase() === t) return;
154
+ const n = document.createElement(t);
155
+ n.innerHTML = o.innerHTML;
156
+ for (let l = 0; l < o.attributes.length; l++) {
157
+ const r = o.attributes[l];
158
+ n.setAttribute(r.name, r.value);
159
+ }
160
+ o.parentNode?.replaceChild(n, o);
161
161
  });
162
162
  }
163
163
  const ce = () => {
164
164
  const e = f();
165
165
  if (!e) return;
166
- const { table: t, colIndex: n } = e;
167
- for (let o = 0; o < t.rows.length; o++) {
168
- const l = t.rows[o].cells[n];
166
+ const { table: t, colIndex: o } = e;
167
+ for (let n = 0; n < t.rows.length; n++) {
168
+ const l = t.rows[n].cells[o];
169
169
  if (l) {
170
170
  const r = l.tagName.toLowerCase() === "th" ? "td" : "th", a = document.createElement(r);
171
171
  a.innerHTML = l.innerHTML;
172
172
  for (let i = 0; i < l.attributes.length; i++) {
173
- const u = l.attributes[i];
174
- a.setAttribute(u.name, u.value);
173
+ const c = l.attributes[i];
174
+ a.setAttribute(c.name, c.value);
175
175
  }
176
176
  l.parentNode?.replaceChild(a, l);
177
177
  }
@@ -180,13 +180,13 @@ const ce = () => {
180
180
  }, ue = () => {
181
181
  const e = f();
182
182
  if (!e) return;
183
- const t = e.table, n = t.parentElement;
184
- n && n.classList.contains("rte-table-wrapper") ? n.remove() : t.remove(), document.dispatchEvent(new CustomEvent("tableDeleted"));
183
+ const t = e.table, o = t.parentElement;
184
+ o && o.classList.contains("rte-table-wrapper") ? o.remove() : t.remove(), document.dispatchEvent(new CustomEvent("tableDeleted"));
185
185
  };
186
186
  function w(e, t) {
187
187
  if (!e || !(e instanceof Node)) return null;
188
- const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
189
- return n ? n.closest(t) : null;
188
+ const o = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
189
+ return o ? o.closest(t) : null;
190
190
  }
191
191
  function M(e) {
192
192
  if (!e) return !1;
@@ -197,25 +197,25 @@ function he() {
197
197
  const e = window.getSelection(), t = e && e.rangeCount > 0 ? e.getRangeAt(0).startContainer : null;
198
198
  return w(t, ".rte-content") || (b ? b.closest(".rte-content") : null);
199
199
  }
200
- function be(e, t, n) {
201
- const o = window.execEditorCommand || window.executeEditorCommand;
202
- if (typeof o == "function")
200
+ function be(e, t, o) {
201
+ const n = window.execEditorCommand || window.executeEditorCommand;
202
+ if (typeof n == "function")
203
203
  try {
204
- o("recordDomTransaction", e, t, n);
204
+ n("recordDomTransaction", e, t, o);
205
205
  } catch {
206
206
  }
207
207
  }
208
208
  function j(e) {
209
209
  const t = he();
210
210
  if (t && !M(t)) return;
211
- const n = t ? t.innerHTML : "";
211
+ const o = t ? t.innerHTML : "";
212
212
  if (e(), !t) return;
213
- const o = t.innerHTML;
214
- o !== n && (be(t, n, o), t.dispatchEvent(new Event("input", { bubbles: !0 })));
213
+ const n = t.innerHTML;
214
+ n !== o && (be(t, o, n), t.dispatchEvent(new Event("input", { bubbles: !0 })));
215
215
  }
216
- function G(e, t, n) {
216
+ function G(e, t, o) {
217
217
  if (!e.isConnected || e.rows.length === 0) return;
218
- const o = e.rows[Math.min(t, e.rows.length - 1)], l = o.cells[Math.min(n, o.cells.length - 1)];
218
+ const n = e.rows[Math.min(t, e.rows.length - 1)], l = n.cells[Math.min(o, n.cells.length - 1)];
219
219
  if (!l) return;
220
220
  const r = document.createRange(), a = l.querySelector("p, div, li") || l;
221
221
  r.selectNodeContents(a), r.collapse(!0);
@@ -225,15 +225,15 @@ function G(e, t, n) {
225
225
  const me = () => {
226
226
  const e = window.getSelection();
227
227
  if (!e || e.rangeCount === 0) return;
228
- const n = e.getRangeAt(0).startContainer;
229
- if (!w(n, "table")) return;
230
- const o = w(n, "td, th");
231
- if (!o) return;
232
- const l = o.parentElement;
228
+ const o = e.getRangeAt(0).startContainer;
229
+ if (!w(o, "table")) return;
230
+ const n = w(o, "td, th");
231
+ if (!n) return;
232
+ const l = n.parentElement;
233
233
  if (!l) return;
234
234
  let r = -1;
235
235
  for (let d = 0; d < l.cells.length; d++)
236
- if (l.cells[d] === o) {
236
+ if (l.cells[d] === n) {
237
237
  r = d;
238
238
  break;
239
239
  }
@@ -241,93 +241,93 @@ const me = () => {
241
241
  const a = l.cells[r + 1];
242
242
  if (!a) return;
243
243
  const i = (d, s) => {
244
- const c = parseInt(d.getAttribute(s) || "1", 10);
245
- return Number.isFinite(c) && c > 0 ? c : 1;
244
+ const u = parseInt(d.getAttribute(s) || "1", 10);
245
+ return Number.isFinite(u) && u > 0 ? u : 1;
246
246
  };
247
- if (i(o, "rowspan") !== i(a, "rowspan")) return;
248
- o.setAttribute("colspan", String(i(o, "colspan") + i(a, "colspan"))), Array.from(a.childNodes).forEach((d) => {
249
- o.appendChild(d);
247
+ if (i(n, "rowspan") !== i(a, "rowspan")) return;
248
+ n.setAttribute("colspan", String(i(n, "colspan") + i(a, "colspan"))), Array.from(a.childNodes).forEach((d) => {
249
+ n.appendChild(d);
250
250
  }), a.remove(), p();
251
251
  };
252
252
  function f() {
253
253
  const e = window.getSelection();
254
254
  if (!e || e.rangeCount === 0) return null;
255
- const n = e.getRangeAt(0).startContainer, o = w(n, "table");
256
- if (!o) return null;
255
+ const o = e.getRangeAt(0).startContainer, n = w(o, "table");
256
+ if (!n) return null;
257
257
  let l = 0, r = 0;
258
- const a = w(n, "td, th");
258
+ const a = w(o, "td, th");
259
259
  if (a) {
260
260
  const i = a.parentElement;
261
- for (; i && i !== o.rows[l] && (l++, !(l >= o.rows.length)); )
261
+ for (; i && i !== n.rows[l] && (l++, !(l >= n.rows.length)); )
262
262
  ;
263
- const u = i;
264
- if (u) {
265
- for (let d = 0; d < u.cells.length; d++)
266
- if (u.cells[d] === a) {
263
+ const c = i;
264
+ if (c) {
265
+ for (let d = 0; d < c.cells.length; d++)
266
+ if (c.cells[d] === a) {
267
267
  r = d;
268
268
  break;
269
269
  }
270
270
  }
271
271
  }
272
272
  return {
273
- table: o,
273
+ table: n,
274
274
  rowIndex: l,
275
275
  colIndex: r,
276
- rowCount: o.rows.length,
277
- cellCount: o.rows[0]?.cells.length || 0
276
+ rowCount: n.rows.length,
277
+ cellCount: n.rows[0]?.cells.length || 0
278
278
  };
279
279
  }
280
280
  function p() {
281
281
  if (!h || !b) return;
282
282
  const e = f();
283
283
  if (!e) return;
284
- const t = e.rowCount > 1, n = e.cellCount > 1;
285
- J(t, n);
284
+ const t = e.rowCount > 1, o = e.cellCount > 1;
285
+ J(t, o);
286
286
  }
287
287
  function fe(e) {
288
288
  const t = window.getSelection();
289
289
  if (!t) return;
290
- const n = document.createRange();
291
- (e.textContent ?? "").trim() === "" ? (n.selectNodeContents(e.querySelector("p, div") || e), n.collapse(!0)) : n.selectNodeContents(e), t.removeAllRanges(), t.addRange(n);
290
+ const o = document.createRange();
291
+ (e.textContent ?? "").trim() === "" ? (o.selectNodeContents(e.querySelector("p, div") || e), o.collapse(!0)) : o.selectNodeContents(e), t.removeAllRanges(), t.addRange(o);
292
292
  }
293
293
  function pe(e) {
294
294
  if (e.key !== "Tab" || e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey) return;
295
295
  const t = window.getSelection();
296
296
  if (!t || t.rangeCount === 0) return;
297
- const n = w(t.getRangeAt(0).startContainer, "td, th"), o = n?.closest("table");
298
- if (!n || !o || !M(o)) return;
299
- const l = o.closest("[contenteditable]");
297
+ const o = w(t.getRangeAt(0).startContainer, "td, th"), n = o?.closest("table");
298
+ if (!o || !n || !M(n)) return;
299
+ const l = n.closest("[contenteditable]");
300
300
  if (!l || !(e.target instanceof Node) || !l.contains(e.target)) return;
301
- const r = Array.from(o.querySelectorAll("th, td")).filter(
302
- (u) => u.closest("table") === o
303
- ), a = r.indexOf(n);
301
+ const r = Array.from(n.querySelectorAll("th, td")).filter(
302
+ (c) => c.closest("table") === n
303
+ ), a = r.indexOf(o);
304
304
  let i;
305
- e.shiftKey ? i = r[a - 1] : a < r.length - 1 ? i = r[a + 1] : (y("addRowBelow"), i = n.parentElement?.nextElementSibling?.querySelector("th, td")), i && (e.preventDefault(), fe(i));
305
+ e.shiftKey ? i = r[a - 1] : a < r.length - 1 ? i = r[a + 1] : (y("addRowBelow"), i = o.parentElement?.nextElementSibling?.querySelector("th, td")), i && (e.preventDefault(), fe(i));
306
306
  }
307
307
  function ge() {
308
- V = () => {
308
+ B = () => {
309
309
  const e = f();
310
310
  e && M(e.table) ? we(e.table) : T();
311
- }, B = (e) => {
312
- const t = w(e.target, "table"), n = w(e.target, ".table-toolbar");
313
- !t && !n && T();
311
+ }, V = (e) => {
312
+ const t = w(e.target, "table"), o = w(e.target, ".table-toolbar");
313
+ !t && !o && T();
314
314
  }, N = () => {
315
315
  T();
316
316
  }, D = () => {
317
317
  b && h && h.style.display !== "none" && S(b);
318
318
  }, q = () => {
319
319
  b && h && h.style.display !== "none" && S(b);
320
- }, document.addEventListener("selectionchange", V), document.addEventListener("keydown", pe), document.addEventListener("mousedown", B), document.addEventListener("tableDeleted", N), window.addEventListener("scroll", D, !0), window.addEventListener("resize", q);
320
+ }, document.addEventListener("selectionchange", B), document.addEventListener("keydown", pe), document.addEventListener("mousedown", V), document.addEventListener("tableDeleted", N), window.addEventListener("scroll", D, !0), window.addEventListener("resize", q);
321
321
  }
322
322
  function S(e) {
323
323
  if (!h) return;
324
- const t = e.getBoundingClientRect(), n = h.getBoundingClientRect(), o = n.height || 40, l = n.width || 280, r = 10;
325
- let a = t.top - o - r, i = t.left + t.width / 2 - l / 2;
324
+ const t = e.getBoundingClientRect(), o = h.getBoundingClientRect(), n = o.height || 40, l = o.width || 280, r = 10;
325
+ let a = t.top - n - r, i = t.left + t.width / 2 - l / 2;
326
326
  a < r && (a = t.bottom + r), i < r && (i = r);
327
- const u = window.innerWidth;
328
- i + l > u - r && (i = u - l - r);
327
+ const c = window.innerWidth;
328
+ i + l > c - r && (i = c - l - r);
329
329
  const d = window.innerHeight;
330
- a + o > d - r && (a = d - o - r), h.style.top = a + "px", h.style.left = i + "px";
330
+ a + n > d - r && (a = d - n - r), h.style.top = a + "px", h.style.left = i + "px";
331
331
  }
332
332
  function we(e) {
333
333
  b = e, h || (h = Ce(), document.body.appendChild(h));
@@ -335,8 +335,8 @@ function we(e) {
335
335
  h.classList.toggle("rte-theme-dark", t), h.style.display = "flex", h.style.visibility = "hidden", requestAnimationFrame(() => {
336
336
  S(e), h && (h.style.visibility = "visible");
337
337
  });
338
- const n = f();
339
- n && J(n.rowCount > 1, n.cellCount > 1), ye(e);
338
+ const o = f();
339
+ o && J(o.rowCount > 1, o.cellCount > 1), ye(e);
340
340
  }
341
341
  const I = /* @__PURE__ */ new Set();
342
342
  function Q() {
@@ -346,16 +346,16 @@ function Q() {
346
346
  }
347
347
  function T() {
348
348
  if (h && (h.style.display = "none"), b) {
349
- b.querySelectorAll(".resize-handle").forEach((o) => o.remove());
350
- const t = b.parentElement, n = t?.classList.contains("rte-table-wrapper") ? t.querySelector(".table-resize-handle") : b.querySelector(".table-resize-handle");
351
- n && n.remove();
349
+ b.querySelectorAll(".resize-handle").forEach((n) => n.remove());
350
+ const t = b.parentElement, o = t?.classList.contains("rte-table-wrapper") ? t.querySelector(".table-resize-handle") : b.querySelector(".table-resize-handle");
351
+ o && o.remove();
352
352
  }
353
353
  Q(), b = null;
354
354
  }
355
355
  function J(e, t) {
356
356
  if (!h) return;
357
- const n = h.querySelector('[data-action="deleteRow"]'), o = h.querySelector('[data-action="deleteColumn"]');
358
- n && (n.disabled = !e), o && (o.disabled = !t);
357
+ const o = h.querySelector('[data-action="deleteRow"]'), n = h.querySelector('[data-action="deleteColumn"]');
358
+ o && (o.disabled = !e), n && (n.disabled = !t);
359
359
  }
360
360
  let z = !1;
361
361
  function ve() {
@@ -530,15 +530,15 @@ function Ce() {
530
530
  display: none;
531
531
  `, e.setAttribute("role", "toolbar"), e.setAttribute("aria-label", "Table editing toolbar");
532
532
  const t = (s) => {
533
- const c = document.createElement("button");
534
- return c.className = "toolbar-icon-btn", s.danger && c.classList.add("toolbar-icon-btn-danger"), s.delete && c.classList.add("toolbar-icon-btn-delete"), c.innerHTML = s.icon, c.title = s.title, c.setAttribute("aria-label", s.title), c.setAttribute("type", "button"), c.setAttribute("data-action", s.action), c.onclick = () => y(s.action), c;
535
- }, n = () => {
533
+ const u = document.createElement("button");
534
+ return u.className = "toolbar-icon-btn", s.danger && u.classList.add("toolbar-icon-btn-danger"), s.delete && u.classList.add("toolbar-icon-btn-delete"), u.innerHTML = s.icon, u.title = s.title, u.setAttribute("aria-label", s.title), u.setAttribute("type", "button"), u.setAttribute("data-action", s.action), u.onclick = () => y(s.action), u;
535
+ }, o = () => {
536
536
  const s = document.createElement("div");
537
537
  return s.className = "toolbar-divider", s;
538
- }, o = (...s) => {
539
- const c = document.createElement("div");
540
- return c.className = "toolbar-section", s.forEach((C) => c.appendChild(C)), c;
541
- }, l = o(
538
+ }, n = (...s) => {
539
+ const u = document.createElement("div");
540
+ return u.className = "toolbar-section", s.forEach((C) => u.appendChild(C)), u;
541
+ }, l = n(
542
542
  t({
543
543
  icon: xe(),
544
544
  title: "Add row above (Ctrl+Shift+R)",
@@ -555,7 +555,7 @@ function Ce() {
555
555
  action: "deleteRow",
556
556
  danger: !0
557
557
  })
558
- ), r = o(
558
+ ), r = n(
559
559
  t({
560
560
  icon: Te(),
561
561
  title: "Add column left",
@@ -572,7 +572,7 @@ function Ce() {
572
572
  action: "deleteColumn",
573
573
  danger: !0
574
574
  })
575
- ), a = o(
575
+ ), a = n(
576
576
  t({
577
577
  icon: Ie(),
578
578
  title: "Toggle header row",
@@ -583,13 +583,13 @@ function Ce() {
583
583
  title: "Toggle header column",
584
584
  action: "toggleHeaderColumn"
585
585
  })
586
- ), i = o(
586
+ ), i = n(
587
587
  t({
588
588
  icon: Ae(),
589
589
  title: "Merge cells (horizontally)",
590
590
  action: "mergeCells"
591
591
  })
592
- ), u = o(
592
+ ), c = n(
593
593
  t({
594
594
  icon: Le(),
595
595
  title: "Delete table",
@@ -597,7 +597,7 @@ function Ce() {
597
597
  delete: !0
598
598
  })
599
599
  );
600
- e.appendChild(l), e.appendChild(n()), e.appendChild(r), e.appendChild(n()), e.appendChild(a), e.appendChild(n()), e.appendChild(i), e.appendChild(n()), e.appendChild(u);
600
+ e.appendChild(l), e.appendChild(o()), e.appendChild(r), e.appendChild(o()), e.appendChild(a), e.appendChild(o()), e.appendChild(i), e.appendChild(o()), e.appendChild(c);
601
601
  const d = (s) => {
602
602
  !h || h.style.display === "none" || (s.ctrlKey || s.metaKey) && s.shiftKey && (s.key === "r" || s.key === "R" ? (s.preventDefault(), y("addRowBelow")) : (s.key === "c" || s.key === "C") && (s.preventDefault(), y("addColumnRight")));
603
603
  };
@@ -642,13 +642,13 @@ function y(e) {
642
642
  function ye(e) {
643
643
  const t = Y(e);
644
644
  e.querySelectorAll(".resize-handle").forEach((i) => i.remove());
645
- const o = t.querySelector(".table-resize-handle");
646
- o && o.remove(), Q();
645
+ const n = t.querySelector(".table-resize-handle");
646
+ n && n.remove(), Q();
647
647
  const l = e.querySelector("thead tr, tbody tr:first-child");
648
648
  if (!l) return;
649
649
  const r = l.querySelectorAll("td, th");
650
- r.forEach((i, u) => {
651
- if (u === r.length - 1) return;
650
+ r.forEach((i, c) => {
651
+ if (c === r.length - 1) return;
652
652
  const d = document.createElement("div");
653
653
  d.className = "resize-handle", d.style.cssText = `
654
654
  position: absolute;
@@ -664,8 +664,8 @@ function ye(e) {
664
664
  E || (d.style.background = "rgba(0, 102, 204, 0.3)");
665
665
  }), d.addEventListener("mouseleave", () => {
666
666
  E || (d.style.background = "transparent");
667
- }), d.addEventListener("mousedown", (c) => {
668
- c.preventDefault(), c.stopPropagation(), ke(c, u);
667
+ }), d.addEventListener("mousedown", (u) => {
668
+ u.preventDefault(), u.stopPropagation(), ke(u, c);
669
669
  });
670
670
  const s = i;
671
671
  s.style.position || (s.style.position = "relative", I.add(s)), i.appendChild(d);
@@ -677,30 +677,30 @@ function ye(e) {
677
677
  }
678
678
  function ke(e, t) {
679
679
  if (E = !0, k = t, O = e.clientX, !b) return;
680
- const n = b.querySelector("thead tr, tbody tr:first-child");
681
- n && n.cells[t] && (P = n.cells[t].offsetWidth), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
682
- const o = (r) => {
680
+ const o = b.querySelector("thead tr, tbody tr:first-child");
681
+ o && o.cells[t] && (P = o.cells[t].offsetWidth), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
682
+ const n = (r) => {
683
683
  if (!E || k === null || !b) return;
684
684
  const a = r.clientX - O, i = Math.max(50, P + a);
685
685
  b.querySelectorAll("tr").forEach((d) => {
686
686
  d.cells[k] && (d.cells[k].style.width = i + "px");
687
687
  });
688
688
  }, l = () => {
689
- E = !1, k = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", l);
689
+ E = !1, k = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", l);
690
690
  };
691
- document.addEventListener("mousemove", o), document.addEventListener("mouseup", l);
691
+ document.addEventListener("mousemove", n), document.addEventListener("mouseup", l);
692
692
  }
693
693
  function Ee(e) {
694
694
  if (!b) return;
695
695
  R = !0, K = e.clientX, W = e.clientY, _ = b.offsetWidth, X = b.offsetHeight, document.body.style.cursor = "nwse-resize", document.body.style.userSelect = "none";
696
- const t = (o) => {
696
+ const t = (n) => {
697
697
  if (!R || !b) return;
698
- const l = o.clientX - K, r = o.clientY - W, a = Math.max(200, _ + l), i = Math.max(100, X + r);
698
+ const l = n.clientX - K, r = n.clientY - W, a = Math.max(200, _ + l), i = Math.max(100, X + r);
699
699
  b.style.width = a + "px", b.style.height = i + "px";
700
- }, n = () => {
701
- R = !1, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", n);
700
+ }, o = () => {
701
+ R = !1, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", o);
702
702
  };
703
- document.addEventListener("mousemove", t), document.addEventListener("mouseup", n);
703
+ document.addEventListener("mousemove", t), document.addEventListener("mouseup", o);
704
704
  }
705
705
  function xe() {
706
706
  return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">