@editora/plugins 1.0.19 → 1.0.20
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/{CodePlugin.native-Bwf25lLX.js → CodePlugin.native-CKJo7IFG.js} +8 -8
- package/dist/{CodePlugin.native-Cpp4u3Jl.mjs → CodePlugin.native-D8gGxB8i.mjs} +59 -60
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-yjRBab4v.mjs → documentManager-BL98a7YZ.mjs} +402 -404
- package/dist/{documentManager-BDz6tovy.js → documentManager-r8t7yZEd.js} +9 -9
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +1 -1
- package/dist/{index-Bm1eqYHh.mjs → index-B-VitI3v.mjs} +23 -22
- package/dist/{index-CoflqYuK.js → index-D5xugkYA.js} +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +47 -50
- package/dist/purify.es-B6PsRpEV.js +3 -0
- package/dist/purify.es-DmCsrgBd.mjs +1480 -0
- package/dist/sanitizeHtml-CDoBlNTk.js +1 -0
- package/dist/sanitizeHtml-CtLy8um-.mjs +16 -0
- package/dist/table.cjs.js +14 -14
- package/dist/table.esm.js +158 -150
- package/dist/template.cjs.js +20 -21
- package/dist/template.esm.js +175 -723
- package/package.json +4 -3
package/dist/table.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { f as
|
|
2
|
-
let
|
|
1
|
+
import { f as Z, g as $ } from "./editorContainerHelpers-C7kdWnS0.mjs";
|
|
2
|
+
let u = null, h = null, A = null, V = null, B = null, N = null, D = null;
|
|
3
3
|
const H = '[data-theme="dark"], .dark, .editora-theme-dark';
|
|
4
|
-
let
|
|
5
|
-
const
|
|
4
|
+
let k = !1, y = null, q = 0, O = 0, z = !1, P = 0, W = 0, _ = 0, X = 0;
|
|
5
|
+
const ee = /* @__PURE__ */ new Set([
|
|
6
6
|
"DIV",
|
|
7
7
|
"P",
|
|
8
8
|
"BLOCKQUOTE",
|
|
@@ -17,24 +17,24 @@ const Z = /* @__PURE__ */ new Set([
|
|
|
17
17
|
"TD",
|
|
18
18
|
"TH"
|
|
19
19
|
]);
|
|
20
|
-
function
|
|
20
|
+
function K(e, t) {
|
|
21
21
|
let n = e;
|
|
22
22
|
for (; n && n !== t; ) {
|
|
23
|
-
if (n.nodeType === Node.ELEMENT_NODE &&
|
|
23
|
+
if (n.nodeType === Node.ELEMENT_NODE && ee.has(n.tagName))
|
|
24
24
|
return n;
|
|
25
25
|
n = n.parentNode;
|
|
26
26
|
}
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function U(e) {
|
|
30
30
|
const t = e.parentElement;
|
|
31
31
|
if (t && t.classList.contains("rte-table-wrapper"))
|
|
32
32
|
return t;
|
|
33
33
|
const n = document.createElement("div");
|
|
34
34
|
return n.className = "rte-table-wrapper", t?.insertBefore(n, e), n.appendChild(e), n;
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
const e =
|
|
36
|
+
const te = () => {
|
|
37
|
+
const e = Z(), t = $(e);
|
|
38
38
|
if (!t)
|
|
39
39
|
return alert("Please place your cursor in the editor before inserting a table"), !1;
|
|
40
40
|
const n = window.getSelection();
|
|
@@ -51,35 +51,35 @@ const $ = () => {
|
|
|
51
51
|
for (let m = 0; m < 2; m++) {
|
|
52
52
|
const g = document.createElement("tr");
|
|
53
53
|
for (let w = 0; w < 3; w++) {
|
|
54
|
-
const x = document.createElement("td"),
|
|
55
|
-
|
|
54
|
+
const x = document.createElement("td"), S = document.createElement("p");
|
|
55
|
+
S.appendChild(document.createElement("br")), x.appendChild(S), g.appendChild(x);
|
|
56
56
|
}
|
|
57
57
|
i.appendChild(g);
|
|
58
58
|
}
|
|
59
59
|
l.appendChild(r), l.appendChild(i);
|
|
60
|
-
const
|
|
60
|
+
const b = U(l), d = (m, g, w) => {
|
|
61
61
|
if (m !== t) return m;
|
|
62
62
|
const x = w ? g - 1 : g;
|
|
63
63
|
return t.childNodes[Math.min(Math.max(x, 0), t.childNodes.length - 1)] || null;
|
|
64
|
-
}, s = d(o.endContainer, o.endOffset, !0),
|
|
65
|
-
C && C.parentNode ? C.parentNode.insertBefore(
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
64
|
+
}, s = d(o.endContainer, o.endOffset, !0), c = d(o.startContainer, o.startOffset, !1), C = s && K(s, t) || c && K(c, t);
|
|
65
|
+
C && C.parentNode ? C.parentNode.insertBefore(b, C.nextSibling) : (o.collapse(!1), o.insertNode(b));
|
|
66
|
+
const L = l.querySelector("th p");
|
|
67
|
+
if (L) {
|
|
68
68
|
const m = document.createRange();
|
|
69
|
-
m.setStart(
|
|
69
|
+
m.setStart(L, 0), m.collapse(!0), n.removeAllRanges(), n.addRange(m);
|
|
70
70
|
}
|
|
71
71
|
t.focus();
|
|
72
|
-
},
|
|
72
|
+
}, ne = () => {
|
|
73
73
|
const e = f();
|
|
74
74
|
if (!e) return;
|
|
75
75
|
const { table: t, rowIndex: n } = e, o = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
|
|
76
76
|
for (let a = 0; a < l; a++) {
|
|
77
|
-
const i = document.createElement("td"),
|
|
78
|
-
|
|
77
|
+
const i = document.createElement("td"), b = document.createElement("p");
|
|
78
|
+
b.innerHTML = "<br>", i.appendChild(b), o.appendChild(i);
|
|
79
79
|
}
|
|
80
80
|
const r = t.rows[n];
|
|
81
81
|
r && r.parentElement ? r.parentElement.insertBefore(o, r) : t.appendChild(o), p();
|
|
82
|
-
},
|
|
82
|
+
}, oe = () => {
|
|
83
83
|
const e = f();
|
|
84
84
|
if (!e) return;
|
|
85
85
|
const { table: t, rowIndex: n } = e, o = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
|
|
@@ -95,7 +95,7 @@ const $ = () => {
|
|
|
95
95
|
r.parentElement?.insertBefore(o, r);
|
|
96
96
|
}
|
|
97
97
|
p();
|
|
98
|
-
},
|
|
98
|
+
}, re = () => {
|
|
99
99
|
const e = f();
|
|
100
100
|
if (!e) return;
|
|
101
101
|
const { table: t, colIndex: n } = e;
|
|
@@ -104,7 +104,7 @@ const $ = () => {
|
|
|
104
104
|
a.innerHTML = "<br>", r.appendChild(a), n === 0 ? l.insertBefore(r, l.cells[0]) : l.insertBefore(r, l.cells[n]);
|
|
105
105
|
}
|
|
106
106
|
p();
|
|
107
|
-
},
|
|
107
|
+
}, le = () => {
|
|
108
108
|
const e = f();
|
|
109
109
|
if (!e) return;
|
|
110
110
|
const { table: t, colIndex: n } = e;
|
|
@@ -113,12 +113,12 @@ const $ = () => {
|
|
|
113
113
|
a.innerHTML = "<br>", r.appendChild(a), n >= l.cells.length - 1 ? l.appendChild(r) : l.insertBefore(r, l.cells[n + 1]);
|
|
114
114
|
}
|
|
115
115
|
p();
|
|
116
|
-
},
|
|
116
|
+
}, ae = () => {
|
|
117
117
|
const e = f();
|
|
118
118
|
if (!e || e.rowCount <= 1) return;
|
|
119
119
|
const { table: t, rowIndex: n, colIndex: o } = e;
|
|
120
|
-
t.deleteRow(n),
|
|
121
|
-
},
|
|
120
|
+
t.deleteRow(n), G(t, n, o), p();
|
|
121
|
+
}, ie = () => {
|
|
122
122
|
const e = f();
|
|
123
123
|
if (!e || e.cellCount <= 1) return;
|
|
124
124
|
const { table: t, rowIndex: n, colIndex: o } = e;
|
|
@@ -126,8 +126,8 @@ const $ = () => {
|
|
|
126
126
|
const r = t.rows[l];
|
|
127
127
|
r.cells[o] && r.deleteCell(o);
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
},
|
|
129
|
+
G(t, n, o), p();
|
|
130
|
+
}, de = () => {
|
|
131
131
|
const e = f();
|
|
132
132
|
if (!e) return;
|
|
133
133
|
const { table: t, rowIndex: n } = e, o = t.rows[n];
|
|
@@ -139,15 +139,15 @@ const $ = () => {
|
|
|
139
139
|
const i = t.querySelector("tbody") || t.appendChild(document.createElement("tbody"));
|
|
140
140
|
i.insertBefore(o, i.firstChild), a.rows.length === 0 && a.remove();
|
|
141
141
|
} else
|
|
142
|
-
|
|
142
|
+
F(o, "td");
|
|
143
143
|
} else if (!r || o === t.tBodies[0]?.rows[0]) {
|
|
144
144
|
let a = r;
|
|
145
145
|
a || (a = document.createElement("thead"), t.insertBefore(a, t.firstChild)), a.appendChild(o);
|
|
146
146
|
} else
|
|
147
|
-
|
|
147
|
+
F(o, "th");
|
|
148
148
|
p();
|
|
149
149
|
};
|
|
150
|
-
function
|
|
150
|
+
function F(e, t) {
|
|
151
151
|
Array.from(e.cells).forEach((n) => {
|
|
152
152
|
if (n.tagName.toLowerCase() === t) return;
|
|
153
153
|
const o = document.createElement(t);
|
|
@@ -159,7 +159,7 @@ function K(e, t) {
|
|
|
159
159
|
n.parentNode?.replaceChild(o, n);
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
const
|
|
162
|
+
const se = () => {
|
|
163
163
|
const e = f();
|
|
164
164
|
if (!e) return;
|
|
165
165
|
const { table: t, colIndex: n } = e;
|
|
@@ -169,14 +169,14 @@ const ie = () => {
|
|
|
169
169
|
const r = l.tagName.toLowerCase() === "th" ? "td" : "th", a = document.createElement(r);
|
|
170
170
|
a.innerHTML = l.innerHTML;
|
|
171
171
|
for (let i = 0; i < l.attributes.length; i++) {
|
|
172
|
-
const
|
|
173
|
-
a.setAttribute(
|
|
172
|
+
const b = l.attributes[i];
|
|
173
|
+
a.setAttribute(b.name, b.value);
|
|
174
174
|
}
|
|
175
175
|
l.parentNode?.replaceChild(a, l);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
p();
|
|
179
|
-
},
|
|
179
|
+
}, ce = () => {
|
|
180
180
|
const e = f();
|
|
181
181
|
if (!e) return;
|
|
182
182
|
const t = e.table, n = t.parentElement;
|
|
@@ -187,16 +187,16 @@ function v(e, t) {
|
|
|
187
187
|
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
188
188
|
return n ? n.closest(t) : null;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function Y(e) {
|
|
191
191
|
if (!e) return !1;
|
|
192
192
|
const t = e.closest("[contenteditable]");
|
|
193
193
|
return !t || t.getAttribute("contenteditable") === "false" ? !1 : !t.closest('[data-readonly="true"]');
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function ue() {
|
|
196
196
|
const e = window.getSelection(), t = e && e.rangeCount > 0 ? e.getRangeAt(0).startContainer : null;
|
|
197
|
-
return v(t, ".rte-content") || (
|
|
197
|
+
return v(t, ".rte-content") || (h ? h.closest(".rte-content") : null);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function he(e, t, n) {
|
|
200
200
|
const o = window.execEditorCommand || window.executeEditorCommand;
|
|
201
201
|
if (typeof o == "function")
|
|
202
202
|
try {
|
|
@@ -204,15 +204,15 @@ function ce(e, t, n) {
|
|
|
204
204
|
} catch {
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
function
|
|
208
|
-
const t =
|
|
209
|
-
if (t && !
|
|
207
|
+
function j(e) {
|
|
208
|
+
const t = ue();
|
|
209
|
+
if (t && !Y(t)) return;
|
|
210
210
|
const n = t ? t.innerHTML : "";
|
|
211
211
|
if (e(), !t) return;
|
|
212
212
|
const o = t.innerHTML;
|
|
213
|
-
o !== n && (
|
|
213
|
+
o !== n && (he(t, n, o), t.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function G(e, t, n) {
|
|
216
216
|
if (!e.isConnected || e.rows.length === 0) return;
|
|
217
217
|
const o = e.rows[Math.min(t, e.rows.length - 1)], l = o.cells[Math.min(n, o.cells.length - 1)];
|
|
218
218
|
if (!l) return;
|
|
@@ -221,7 +221,7 @@ function j(e, t, n) {
|
|
|
221
221
|
const i = window.getSelection();
|
|
222
222
|
i?.removeAllRanges(), i?.addRange(r);
|
|
223
223
|
}
|
|
224
|
-
const
|
|
224
|
+
const be = () => {
|
|
225
225
|
const e = window.getSelection();
|
|
226
226
|
if (!e || e.rangeCount === 0) return;
|
|
227
227
|
const n = e.getRangeAt(0).startContainer;
|
|
@@ -240,8 +240,8 @@ const ue = () => {
|
|
|
240
240
|
const a = l.cells[r + 1];
|
|
241
241
|
if (!a) return;
|
|
242
242
|
const i = (d, s) => {
|
|
243
|
-
const
|
|
244
|
-
return Number.isFinite(
|
|
243
|
+
const c = parseInt(d.getAttribute(s) || "1", 10);
|
|
244
|
+
return Number.isFinite(c) && c > 0 ? c : 1;
|
|
245
245
|
};
|
|
246
246
|
if (i(o, "rowspan") !== i(a, "rowspan")) return;
|
|
247
247
|
o.setAttribute("colspan", String(i(o, "colspan") + i(a, "colspan"))), Array.from(a.childNodes).forEach((d) => {
|
|
@@ -259,10 +259,10 @@ function f() {
|
|
|
259
259
|
const i = a.parentElement;
|
|
260
260
|
for (; i && i !== o.rows[l] && (l++, !(l >= o.rows.length)); )
|
|
261
261
|
;
|
|
262
|
-
const
|
|
263
|
-
if (
|
|
264
|
-
for (let d = 0; d <
|
|
265
|
-
if (
|
|
262
|
+
const b = i;
|
|
263
|
+
if (b) {
|
|
264
|
+
for (let d = 0; d < b.cells.length; d++)
|
|
265
|
+
if (b.cells[d] === a) {
|
|
266
266
|
r = d;
|
|
267
267
|
break;
|
|
268
268
|
}
|
|
@@ -277,61 +277,67 @@ function f() {
|
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
279
|
function p() {
|
|
280
|
-
if (!
|
|
280
|
+
if (!u || !h) return;
|
|
281
281
|
const e = f();
|
|
282
282
|
if (!e) return;
|
|
283
283
|
const t = e.rowCount > 1, n = e.cellCount > 1;
|
|
284
|
-
|
|
284
|
+
J(t, n);
|
|
285
285
|
}
|
|
286
|
-
function
|
|
287
|
-
|
|
286
|
+
function me() {
|
|
287
|
+
A = () => {
|
|
288
288
|
const e = f();
|
|
289
|
-
e &&
|
|
289
|
+
e && Y(e.table) ? fe(e.table) : R();
|
|
290
290
|
}, V = (e) => {
|
|
291
291
|
const t = v(e.target, "table"), n = v(e.target, ".table-toolbar");
|
|
292
292
|
!t && !n && R();
|
|
293
|
-
}, A = () => {
|
|
294
|
-
R();
|
|
295
293
|
}, B = () => {
|
|
296
|
-
|
|
294
|
+
R();
|
|
297
295
|
}, N = () => {
|
|
298
|
-
|
|
299
|
-
},
|
|
296
|
+
h && u && u.style.display !== "none" && M(h);
|
|
297
|
+
}, D = () => {
|
|
298
|
+
h && u && u.style.display !== "none" && M(h);
|
|
299
|
+
}, document.addEventListener("selectionchange", A), document.addEventListener("mousedown", V), document.addEventListener("tableDeleted", B), window.addEventListener("scroll", N, !0), window.addEventListener("resize", D);
|
|
300
300
|
}
|
|
301
301
|
function M(e) {
|
|
302
|
-
if (!
|
|
303
|
-
const t = e.getBoundingClientRect(), n =
|
|
302
|
+
if (!u) return;
|
|
303
|
+
const t = e.getBoundingClientRect(), n = u.getBoundingClientRect(), o = n.height || 40, l = n.width || 280, r = 10;
|
|
304
304
|
let a = t.top - o - r, i = t.left + t.width / 2 - l / 2;
|
|
305
305
|
a < r && (a = t.bottom + r), i < r && (i = r);
|
|
306
|
-
const
|
|
307
|
-
i + l >
|
|
306
|
+
const b = window.innerWidth;
|
|
307
|
+
i + l > b - r && (i = b - l - r);
|
|
308
308
|
const d = window.innerHeight;
|
|
309
|
-
a + o > d - r && (a = d - o - r),
|
|
309
|
+
a + o > d - r && (a = d - o - r), u.style.top = a + "px", u.style.left = i + "px";
|
|
310
310
|
}
|
|
311
|
-
function
|
|
312
|
-
|
|
311
|
+
function fe(e) {
|
|
312
|
+
h = e, u || (u = ge(), document.body.appendChild(u));
|
|
313
313
|
const t = !!e.closest(H) || document.body.matches(H) || document.documentElement.matches(H);
|
|
314
|
-
|
|
315
|
-
M(e),
|
|
314
|
+
u.classList.toggle("rte-theme-dark", t), u.style.display = "flex", u.style.visibility = "hidden", requestAnimationFrame(() => {
|
|
315
|
+
M(e), u && (u.style.visibility = "visible");
|
|
316
316
|
});
|
|
317
317
|
const n = f();
|
|
318
|
-
n &&
|
|
318
|
+
n && J(n.rowCount > 1, n.cellCount > 1), we(e);
|
|
319
|
+
}
|
|
320
|
+
const I = /* @__PURE__ */ new Set();
|
|
321
|
+
function Q() {
|
|
322
|
+
I.forEach((e) => {
|
|
323
|
+
e.style.position === "relative" && (e.style.removeProperty("position"), e.getAttribute("style")?.trim() || e.removeAttribute("style"));
|
|
324
|
+
}), I.clear();
|
|
319
325
|
}
|
|
320
326
|
function R() {
|
|
321
|
-
if (
|
|
322
|
-
|
|
323
|
-
const t =
|
|
327
|
+
if (u && (u.style.display = "none"), h) {
|
|
328
|
+
h.querySelectorAll(".resize-handle").forEach((o) => o.remove());
|
|
329
|
+
const t = h.parentElement, n = t?.classList.contains("rte-table-wrapper") ? t.querySelector(".table-resize-handle") : h.querySelector(".table-resize-handle");
|
|
324
330
|
n && n.remove();
|
|
325
331
|
}
|
|
326
|
-
|
|
332
|
+
Q(), h = null;
|
|
327
333
|
}
|
|
328
|
-
function
|
|
329
|
-
if (!
|
|
330
|
-
const n =
|
|
334
|
+
function J(e, t) {
|
|
335
|
+
if (!u) return;
|
|
336
|
+
const n = u.querySelector('[data-action="deleteRow"]'), o = u.querySelector('[data-action="deleteColumn"]');
|
|
331
337
|
n && (n.disabled = !e), o && (o.disabled = !t);
|
|
332
338
|
}
|
|
333
339
|
let T = !1;
|
|
334
|
-
function
|
|
340
|
+
function pe() {
|
|
335
341
|
if (T || typeof document > "u") return;
|
|
336
342
|
if (document.getElementById("rte-table-toolbar-styles")) {
|
|
337
343
|
T = !0;
|
|
@@ -494,8 +500,8 @@ function me() {
|
|
|
494
500
|
}
|
|
495
501
|
`, document.head.appendChild(e);
|
|
496
502
|
}
|
|
497
|
-
function
|
|
498
|
-
|
|
503
|
+
function ge() {
|
|
504
|
+
pe();
|
|
499
505
|
const e = document.createElement("div");
|
|
500
506
|
e.className = "table-toolbar", e.style.cssText = `
|
|
501
507
|
position: fixed;
|
|
@@ -503,125 +509,125 @@ function fe() {
|
|
|
503
509
|
display: none;
|
|
504
510
|
`, e.setAttribute("role", "toolbar"), e.setAttribute("aria-label", "Table editing toolbar");
|
|
505
511
|
const t = (s) => {
|
|
506
|
-
const
|
|
507
|
-
return
|
|
512
|
+
const c = document.createElement("button");
|
|
513
|
+
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 = () => E(s.action), c;
|
|
508
514
|
}, n = () => {
|
|
509
515
|
const s = document.createElement("div");
|
|
510
516
|
return s.className = "toolbar-divider", s;
|
|
511
517
|
}, o = (...s) => {
|
|
512
|
-
const
|
|
513
|
-
return
|
|
518
|
+
const c = document.createElement("div");
|
|
519
|
+
return c.className = "toolbar-section", s.forEach((C) => c.appendChild(C)), c;
|
|
514
520
|
}, l = o(
|
|
515
521
|
t({
|
|
516
|
-
icon:
|
|
522
|
+
icon: ye(),
|
|
517
523
|
title: "Add row above (Ctrl+Shift+R)",
|
|
518
524
|
action: "addRowAbove"
|
|
519
525
|
}),
|
|
520
526
|
t({
|
|
521
|
-
icon:
|
|
527
|
+
icon: ke(),
|
|
522
528
|
title: "Add row below",
|
|
523
529
|
action: "addRowBelow"
|
|
524
530
|
}),
|
|
525
531
|
t({
|
|
526
|
-
icon:
|
|
532
|
+
icon: Ee(),
|
|
527
533
|
title: "Delete row",
|
|
528
534
|
action: "deleteRow",
|
|
529
535
|
danger: !0
|
|
530
536
|
})
|
|
531
537
|
), r = o(
|
|
532
538
|
t({
|
|
533
|
-
icon:
|
|
539
|
+
icon: xe(),
|
|
534
540
|
title: "Add column left",
|
|
535
541
|
action: "addColumnLeft"
|
|
536
542
|
}),
|
|
537
543
|
t({
|
|
538
|
-
icon:
|
|
544
|
+
icon: He(),
|
|
539
545
|
title: "Add column right (Ctrl+Shift+C)",
|
|
540
546
|
action: "addColumnRight"
|
|
541
547
|
}),
|
|
542
548
|
t({
|
|
543
|
-
icon:
|
|
549
|
+
icon: ze(),
|
|
544
550
|
title: "Delete column",
|
|
545
551
|
action: "deleteColumn",
|
|
546
552
|
danger: !0
|
|
547
553
|
})
|
|
548
554
|
), a = o(
|
|
549
555
|
t({
|
|
550
|
-
icon:
|
|
556
|
+
icon: Re(),
|
|
551
557
|
title: "Toggle header row",
|
|
552
558
|
action: "toggleHeaderRow"
|
|
553
559
|
}),
|
|
554
560
|
t({
|
|
555
|
-
icon:
|
|
561
|
+
icon: Te(),
|
|
556
562
|
title: "Toggle header column",
|
|
557
563
|
action: "toggleHeaderColumn"
|
|
558
564
|
})
|
|
559
565
|
), i = o(
|
|
560
566
|
t({
|
|
561
|
-
icon:
|
|
567
|
+
icon: Ie(),
|
|
562
568
|
title: "Merge cells (horizontally)",
|
|
563
569
|
action: "mergeCells"
|
|
564
570
|
})
|
|
565
|
-
),
|
|
571
|
+
), b = o(
|
|
566
572
|
t({
|
|
567
|
-
icon:
|
|
573
|
+
icon: Me(),
|
|
568
574
|
title: "Delete table",
|
|
569
575
|
action: "deleteTable",
|
|
570
576
|
delete: !0
|
|
571
577
|
})
|
|
572
578
|
);
|
|
573
|
-
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(
|
|
579
|
+
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(b);
|
|
574
580
|
const d = (s) => {
|
|
575
|
-
!
|
|
581
|
+
!u || u.style.display === "none" || (s.ctrlKey || s.metaKey) && s.shiftKey && (s.key === "r" || s.key === "R" ? (s.preventDefault(), E("addRowBelow")) : (s.key === "c" || s.key === "C") && (s.preventDefault(), E("addColumnRight")));
|
|
576
582
|
};
|
|
577
583
|
return window.addEventListener("keydown", d), e;
|
|
578
584
|
}
|
|
579
585
|
function E(e) {
|
|
580
|
-
|
|
586
|
+
j(() => {
|
|
581
587
|
switch (e) {
|
|
582
588
|
case "addRowAbove":
|
|
583
|
-
|
|
589
|
+
ne();
|
|
584
590
|
break;
|
|
585
591
|
case "addRowBelow":
|
|
586
|
-
|
|
592
|
+
oe();
|
|
587
593
|
break;
|
|
588
594
|
case "addColumnLeft":
|
|
589
|
-
|
|
595
|
+
re();
|
|
590
596
|
break;
|
|
591
597
|
case "addColumnRight":
|
|
592
|
-
|
|
598
|
+
le();
|
|
593
599
|
break;
|
|
594
600
|
case "deleteRow":
|
|
595
|
-
|
|
601
|
+
ae();
|
|
596
602
|
break;
|
|
597
603
|
case "deleteColumn":
|
|
598
|
-
|
|
604
|
+
ie();
|
|
599
605
|
break;
|
|
600
606
|
case "toggleHeaderRow":
|
|
601
|
-
|
|
607
|
+
de();
|
|
602
608
|
break;
|
|
603
609
|
case "toggleHeaderColumn":
|
|
604
|
-
|
|
610
|
+
se();
|
|
605
611
|
break;
|
|
606
612
|
case "deleteTable":
|
|
607
|
-
|
|
613
|
+
ce();
|
|
608
614
|
break;
|
|
609
615
|
case "mergeCells":
|
|
610
|
-
|
|
616
|
+
be();
|
|
611
617
|
break;
|
|
612
618
|
}
|
|
613
619
|
});
|
|
614
620
|
}
|
|
615
|
-
function
|
|
616
|
-
const t =
|
|
621
|
+
function we(e) {
|
|
622
|
+
const t = U(e);
|
|
617
623
|
e.querySelectorAll(".resize-handle").forEach((i) => i.remove());
|
|
618
624
|
const o = t.querySelector(".table-resize-handle");
|
|
619
|
-
o && o.remove();
|
|
625
|
+
o && o.remove(), Q();
|
|
620
626
|
const l = e.querySelector("thead tr, tbody tr:first-child");
|
|
621
627
|
if (!l) return;
|
|
622
628
|
const r = l.querySelectorAll("td, th");
|
|
623
|
-
r.forEach((i,
|
|
624
|
-
if (
|
|
629
|
+
r.forEach((i, b) => {
|
|
630
|
+
if (b === r.length - 1) return;
|
|
625
631
|
const d = document.createElement("div");
|
|
626
632
|
d.className = "resize-handle", d.style.cssText = `
|
|
627
633
|
position: absolute;
|
|
@@ -634,91 +640,93 @@ function pe(e) {
|
|
|
634
640
|
z-index: 10;
|
|
635
641
|
transition: background 0.15s ease;
|
|
636
642
|
`, d.addEventListener("mouseenter", () => {
|
|
637
|
-
|
|
643
|
+
k || (d.style.background = "rgba(0, 102, 204, 0.3)");
|
|
638
644
|
}), d.addEventListener("mouseleave", () => {
|
|
639
|
-
|
|
640
|
-
}), d.addEventListener("mousedown", (
|
|
641
|
-
|
|
642
|
-
})
|
|
645
|
+
k || (d.style.background = "transparent");
|
|
646
|
+
}), d.addEventListener("mousedown", (c) => {
|
|
647
|
+
c.preventDefault(), c.stopPropagation(), ve(c, b);
|
|
648
|
+
});
|
|
649
|
+
const s = i;
|
|
650
|
+
s.style.position || (s.style.position = "relative", I.add(s)), i.appendChild(d);
|
|
643
651
|
});
|
|
644
652
|
const a = document.createElement("div");
|
|
645
653
|
a.className = "table-resize-handle", a.addEventListener("mousedown", (i) => {
|
|
646
|
-
i.preventDefault(), i.stopPropagation(),
|
|
654
|
+
i.preventDefault(), i.stopPropagation(), Ce(i);
|
|
647
655
|
}), t.appendChild(a);
|
|
648
656
|
}
|
|
649
|
-
function
|
|
650
|
-
if (
|
|
651
|
-
const n =
|
|
652
|
-
n && n.cells[t] && (
|
|
657
|
+
function ve(e, t) {
|
|
658
|
+
if (k = !0, y = t, q = e.clientX, !h) return;
|
|
659
|
+
const n = h.querySelector("thead tr, tbody tr:first-child");
|
|
660
|
+
n && n.cells[t] && (O = n.cells[t].offsetWidth), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
653
661
|
const o = (r) => {
|
|
654
|
-
if (!
|
|
655
|
-
const a = r.clientX -
|
|
656
|
-
|
|
657
|
-
d.cells[
|
|
662
|
+
if (!k || y === null || !h) return;
|
|
663
|
+
const a = r.clientX - q, i = Math.max(50, O + a);
|
|
664
|
+
h.querySelectorAll("tr").forEach((d) => {
|
|
665
|
+
d.cells[y] && (d.cells[y].style.width = i + "px");
|
|
658
666
|
});
|
|
659
667
|
}, l = () => {
|
|
660
|
-
|
|
668
|
+
k = !1, y = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", l);
|
|
661
669
|
};
|
|
662
670
|
document.addEventListener("mousemove", o), document.addEventListener("mouseup", l);
|
|
663
671
|
}
|
|
664
|
-
function
|
|
665
|
-
if (!
|
|
666
|
-
z = !0,
|
|
672
|
+
function Ce(e) {
|
|
673
|
+
if (!h) return;
|
|
674
|
+
z = !0, P = e.clientX, W = e.clientY, _ = h.offsetWidth, X = h.offsetHeight, document.body.style.cursor = "nwse-resize", document.body.style.userSelect = "none";
|
|
667
675
|
const t = (o) => {
|
|
668
|
-
if (!z || !
|
|
669
|
-
const l = o.clientX -
|
|
670
|
-
|
|
676
|
+
if (!z || !h) return;
|
|
677
|
+
const l = o.clientX - P, r = o.clientY - W, a = Math.max(200, _ + l), i = Math.max(100, X + r);
|
|
678
|
+
h.style.width = a + "px", h.style.height = i + "px";
|
|
671
679
|
}, n = () => {
|
|
672
680
|
z = !1, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", n);
|
|
673
681
|
};
|
|
674
682
|
document.addEventListener("mousemove", t), document.addEventListener("mouseup", n);
|
|
675
683
|
}
|
|
676
|
-
function
|
|
684
|
+
function ye() {
|
|
677
685
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
678
686
|
<path d="M2 7h12V5H2v2zm0 4h12V9H2v2zM8 1v3H5v2h3v3h2V6h3V4h-3V1H8z"/>
|
|
679
687
|
</svg>`;
|
|
680
688
|
}
|
|
681
|
-
function
|
|
689
|
+
function ke() {
|
|
682
690
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
683
691
|
<path d="M2 3h12V1H2v2zm0 4h12V5H2v2zm6 4v3h3v-2h2v-2h-2v-3h-2v3H5v2h3z"/>
|
|
684
692
|
</svg>`;
|
|
685
693
|
}
|
|
686
|
-
function
|
|
694
|
+
function Ee() {
|
|
687
695
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
688
696
|
<path d="M2 5h12v2H2V5zm0 4h12v2H2V9zm4-6v2H4v2h2v2h2V7h2V5H8V3H6z"/>
|
|
689
697
|
</svg>`;
|
|
690
698
|
}
|
|
691
|
-
function
|
|
699
|
+
function xe() {
|
|
692
700
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
693
701
|
<path d="M7 2v12h2V2H7zm4 0v12h2V2h-2zM1 8h3v-3H1v3zm3 2H1v3h3v-3z"/>
|
|
694
702
|
</svg>`;
|
|
695
703
|
}
|
|
696
|
-
function
|
|
704
|
+
function He() {
|
|
697
705
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
698
706
|
<path d="M2 2v12h2V2H2zm4 0v12h2V2H6zM12 8h3v-3h-3v3zm0 2h3v3h-3v-3z"/>
|
|
699
707
|
</svg>`;
|
|
700
708
|
}
|
|
701
|
-
function
|
|
709
|
+
function ze() {
|
|
702
710
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
703
711
|
<path d="M5 2v12h2V2H5zm4 0v12h2V2H9zm3 2h3V1h-3v3zm3 2h-3v3h3V6zm0 4h-3v3h3v-3z"/>
|
|
704
712
|
</svg>`;
|
|
705
713
|
}
|
|
706
|
-
function
|
|
714
|
+
function Re() {
|
|
707
715
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
708
716
|
<path d="M2 2h12v3H2V2zm0 5h12v8H2V7zm2 2v4h2V9H4zm4 0v4h2V9H8zm4 0v4h2V9h-2z"/>
|
|
709
717
|
</svg>`;
|
|
710
718
|
}
|
|
711
|
-
function
|
|
719
|
+
function Te() {
|
|
712
720
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
713
721
|
<path d="M2 2v12h3V2H2zm5 0v12h8V2H7zm2 2h4v2H9V4zm0 4h4v2H9V8zm0 4h4v2H9v-2z"/>
|
|
714
722
|
</svg>`;
|
|
715
723
|
}
|
|
716
|
-
function
|
|
724
|
+
function Me() {
|
|
717
725
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
718
726
|
<path d="M3 1h10v1H3V1zm1 2v11h8V3H4zM6 5h1v6H6V5zm3 0h1v6H9V5z"/>
|
|
719
727
|
</svg>`;
|
|
720
728
|
}
|
|
721
|
-
function
|
|
729
|
+
function Ie() {
|
|
722
730
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
723
731
|
<path d="M2 2h4v3H2V2zm5 0h4v3H7V2zm5 0h2v3h-2V2zm-10 4h4v3H2V6zm5 0h4v3H7V6zm5 0h2v3h-2V6zm-10 4h4v3H2v-3zm5 0h4v3H7v-3zm5 0h2v3h-2v-3z"/>
|
|
724
732
|
</svg>`;
|
|
@@ -726,11 +734,11 @@ function Te() {
|
|
|
726
734
|
if (typeof window < "u" && !window.__tablePluginInitialized) {
|
|
727
735
|
window.__tablePluginInitialized = !0;
|
|
728
736
|
const e = () => {
|
|
729
|
-
|
|
737
|
+
me();
|
|
730
738
|
};
|
|
731
739
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : setTimeout(e, 100);
|
|
732
740
|
}
|
|
733
|
-
const
|
|
741
|
+
const Se = () => ({
|
|
734
742
|
name: "table",
|
|
735
743
|
toolbar: [
|
|
736
744
|
{
|
|
@@ -740,8 +748,8 @@ const Ie = () => ({
|
|
|
740
748
|
}
|
|
741
749
|
],
|
|
742
750
|
commands: {
|
|
743
|
-
insertTable: () => (
|
|
744
|
-
|
|
751
|
+
insertTable: () => (j(() => {
|
|
752
|
+
te();
|
|
745
753
|
}), !0)
|
|
746
754
|
},
|
|
747
755
|
keymap: {
|
|
@@ -750,5 +758,5 @@ const Ie = () => ({
|
|
|
750
758
|
}
|
|
751
759
|
});
|
|
752
760
|
export {
|
|
753
|
-
|
|
761
|
+
Se as TablePlugin
|
|
754
762
|
};
|