@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/comments.cjs.js +813 -340
- package/dist/comments.esm.js +1910 -654
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +48 -43
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +56 -51
- package/dist/plugins.css +1 -1
- package/dist/table.cjs.js +3 -3
- package/dist/table.esm.js +154 -154
- package/index.d.ts +63 -1
- package/package.json +1 -1
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,
|
|
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
|
|
23
|
-
for (;
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
26
|
-
|
|
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
|
|
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
|
|
42
|
-
if (!
|
|
43
|
-
const
|
|
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
|
|
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(
|
|
66
|
-
C && C.parentNode ? C.parentNode.insertBefore(
|
|
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),
|
|
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:
|
|
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"),
|
|
79
|
-
|
|
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[
|
|
82
|
-
r && r.parentElement ? r.parentElement.insertBefore(
|
|
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:
|
|
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),
|
|
89
|
+
i.innerHTML = "<br>", a.appendChild(i), n.appendChild(a);
|
|
90
90
|
}
|
|
91
|
-
if (
|
|
91
|
+
if (o >= t.rows.length - 1) {
|
|
92
92
|
const r = t.rows[t.rows.length - 1];
|
|
93
|
-
r && r.parentElement ? r.parentElement.appendChild(
|
|
93
|
+
r && r.parentElement ? r.parentElement.appendChild(n) : t.appendChild(n);
|
|
94
94
|
} else {
|
|
95
|
-
const r = t.rows[
|
|
96
|
-
r.parentElement?.insertBefore(
|
|
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:
|
|
103
|
-
for (let
|
|
104
|
-
const l = t.rows[
|
|
105
|
-
a.innerHTML = "<br>", r.appendChild(a),
|
|
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:
|
|
112
|
-
for (let
|
|
113
|
-
const l = t.rows[
|
|
114
|
-
a.innerHTML = "<br>", r.appendChild(a),
|
|
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:
|
|
121
|
-
t.deleteRow(
|
|
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:
|
|
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[
|
|
128
|
+
r.cells[n] && r.deleteCell(n);
|
|
129
129
|
}
|
|
130
|
-
G(t,
|
|
130
|
+
G(t, o, n), p();
|
|
131
131
|
}, se = () => {
|
|
132
132
|
const e = f();
|
|
133
133
|
if (!e) return;
|
|
134
|
-
const { table: t, rowIndex:
|
|
135
|
-
if (!
|
|
136
|
-
const l =
|
|
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 =
|
|
139
|
-
if (
|
|
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(
|
|
141
|
+
i.insertBefore(n, i.firstChild), a.rows.length === 0 && a.remove();
|
|
142
142
|
} else
|
|
143
|
-
U(
|
|
144
|
-
} else if (!r ||
|
|
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(
|
|
146
|
+
a || (a = document.createElement("thead"), t.insertBefore(a, t.firstChild)), a.appendChild(n);
|
|
147
147
|
} else
|
|
148
|
-
U(
|
|
148
|
+
U(n, "th");
|
|
149
149
|
p();
|
|
150
150
|
};
|
|
151
151
|
function U(e, t) {
|
|
152
|
-
Array.from(e.cells).forEach((
|
|
153
|
-
if (
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
for (let l = 0; l <
|
|
157
|
-
const r =
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
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:
|
|
167
|
-
for (let
|
|
168
|
-
const l = t.rows[
|
|
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
|
|
174
|
-
a.setAttribute(
|
|
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,
|
|
184
|
-
|
|
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
|
|
189
|
-
return
|
|
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,
|
|
201
|
-
const
|
|
202
|
-
if (typeof
|
|
200
|
+
function be(e, t, o) {
|
|
201
|
+
const n = window.execEditorCommand || window.executeEditorCommand;
|
|
202
|
+
if (typeof n == "function")
|
|
203
203
|
try {
|
|
204
|
-
|
|
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
|
|
211
|
+
const o = t ? t.innerHTML : "";
|
|
212
212
|
if (e(), !t) return;
|
|
213
|
-
const
|
|
214
|
-
|
|
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,
|
|
216
|
+
function G(e, t, o) {
|
|
217
217
|
if (!e.isConnected || e.rows.length === 0) return;
|
|
218
|
-
const
|
|
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
|
|
229
|
-
if (!w(
|
|
230
|
-
const
|
|
231
|
-
if (!
|
|
232
|
-
const l =
|
|
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] ===
|
|
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
|
|
245
|
-
return Number.isFinite(
|
|
244
|
+
const u = parseInt(d.getAttribute(s) || "1", 10);
|
|
245
|
+
return Number.isFinite(u) && u > 0 ? u : 1;
|
|
246
246
|
};
|
|
247
|
-
if (i(
|
|
248
|
-
|
|
249
|
-
|
|
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
|
|
256
|
-
if (!
|
|
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(
|
|
258
|
+
const a = w(o, "td, th");
|
|
259
259
|
if (a) {
|
|
260
260
|
const i = a.parentElement;
|
|
261
|
-
for (; i && i !==
|
|
261
|
+
for (; i && i !== n.rows[l] && (l++, !(l >= n.rows.length)); )
|
|
262
262
|
;
|
|
263
|
-
const
|
|
264
|
-
if (
|
|
265
|
-
for (let d = 0; d <
|
|
266
|
-
if (
|
|
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:
|
|
273
|
+
table: n,
|
|
274
274
|
rowIndex: l,
|
|
275
275
|
colIndex: r,
|
|
276
|
-
rowCount:
|
|
277
|
-
cellCount:
|
|
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,
|
|
285
|
-
J(t,
|
|
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
|
|
291
|
-
(e.textContent ?? "").trim() === "" ? (
|
|
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
|
|
298
|
-
if (!
|
|
299
|
-
const l =
|
|
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(
|
|
302
|
-
(
|
|
303
|
-
), a = r.indexOf(
|
|
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 =
|
|
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
|
-
|
|
308
|
+
B = () => {
|
|
309
309
|
const e = f();
|
|
310
310
|
e && M(e.table) ? we(e.table) : T();
|
|
311
|
-
},
|
|
312
|
-
const t = w(e.target, "table"),
|
|
313
|
-
!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",
|
|
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(),
|
|
325
|
-
let a = t.top -
|
|
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
|
|
328
|
-
i + l >
|
|
327
|
+
const c = window.innerWidth;
|
|
328
|
+
i + l > c - r && (i = c - l - r);
|
|
329
329
|
const d = window.innerHeight;
|
|
330
|
-
a +
|
|
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
|
|
339
|
-
|
|
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((
|
|
350
|
-
const t = b.parentElement,
|
|
351
|
-
|
|
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
|
|
358
|
-
|
|
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
|
|
534
|
-
return
|
|
535
|
-
},
|
|
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
|
-
},
|
|
539
|
-
const
|
|
540
|
-
return
|
|
541
|
-
}, l =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
586
|
+
), i = n(
|
|
587
587
|
t({
|
|
588
588
|
icon: Ae(),
|
|
589
589
|
title: "Merge cells (horizontally)",
|
|
590
590
|
action: "mergeCells"
|
|
591
591
|
})
|
|
592
|
-
),
|
|
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(
|
|
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
|
|
646
|
-
|
|
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,
|
|
651
|
-
if (
|
|
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", (
|
|
668
|
-
|
|
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
|
|
681
|
-
|
|
682
|
-
const
|
|
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",
|
|
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",
|
|
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 = (
|
|
696
|
+
const t = (n) => {
|
|
697
697
|
if (!R || !b) return;
|
|
698
|
-
const l =
|
|
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
|
-
},
|
|
701
|
-
R = !1, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", t), document.removeEventListener("mouseup",
|
|
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",
|
|
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">
|