@editora/plugins 1.2.1 → 1.2.3
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/collaboration.cjs.js +1 -1
- package/dist/collaboration.esm.js +97 -97
- package/dist/plugins.css +1 -1
- package/dist/table.cjs.js +13 -13
- package/dist/table.esm.js +181 -180
- package/package.json +3 -3
package/dist/table.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, N = null, B = null, V = null, D = null, q = null;
|
|
4
4
|
const H = '[data-theme="dark"], .dark, .editora-theme-dark';
|
|
5
|
-
let E = !1, k = null, O = 0, P = 0, R = !1, K = 0,
|
|
5
|
+
let E = !1, k = null, O = 0, P = 0, R = !1, K = 0, _ = 0, W = 0, X = 0;
|
|
6
6
|
const te = /* @__PURE__ */ new Set([
|
|
7
7
|
"DIV",
|
|
8
8
|
"P",
|
|
@@ -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 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;
|
|
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
|
|
35
|
-
return c.className = "rte-table-wrapper", t?.insertBefore(c, e), c.appendChild(e), i &&
|
|
34
|
+
const n = window.getSelection(), { anchorNode: o, anchorOffset: l, focusNode: r, focusOffset: a } = n ?? {}, i = !!n && !!o && !!r && (e.contains(o) || e.contains(r)), c = document.createElement("div");
|
|
35
|
+
return c.className = "rte-table-wrapper", t?.insertBefore(c, e), c.appendChild(e), i && n && o && r && o.isConnected && r.isConnected && n.setBaseAndExtent(o, 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 n = window.getSelection();
|
|
42
|
+
if (!n || n.rangeCount === 0) return;
|
|
43
|
+
const o = n.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++) {
|
|
@@ -62,110 +62,110 @@ const ne = () => {
|
|
|
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(c, C.nextSibling) : (
|
|
65
|
+
}, s = d(o.endContainer, o.endOffset, !0), u = d(o.startContainer, o.startOffset, !1), C = s && F(s, t) || u && F(u, t);
|
|
66
|
+
C && C.parentNode ? C.parentNode.insertBefore(c, C.nextSibling) : (o.collapse(!1), o.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), n.removeAllRanges(), n.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: n } = e, o = document.createElement("tr"), l = t.rows[0]?.cells.length || 0;
|
|
77
77
|
for (let a = 0; a < l; a++) {
|
|
78
78
|
const i = document.createElement("td"), c = document.createElement("p");
|
|
79
|
-
c.innerHTML = "<br>", i.appendChild(c),
|
|
79
|
+
c.innerHTML = "<br>", i.appendChild(c), o.appendChild(i);
|
|
80
80
|
}
|
|
81
|
-
const r = t.rows[
|
|
82
|
-
r && r.parentElement ? r.parentElement.insertBefore(
|
|
81
|
+
const r = t.rows[n];
|
|
82
|
+
r && r.parentElement ? r.parentElement.insertBefore(o, r) : t.appendChild(o), p();
|
|
83
83
|
}, re = () => {
|
|
84
84
|
const e = f();
|
|
85
85
|
if (!e) return;
|
|
86
|
-
const { table: t, rowIndex:
|
|
86
|
+
const { table: t, rowIndex: n } = e, o = 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), o.appendChild(a);
|
|
90
90
|
}
|
|
91
|
-
if (
|
|
91
|
+
if (n >= 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(o) : t.appendChild(o);
|
|
94
94
|
} else {
|
|
95
|
-
const r = t.rows[
|
|
96
|
-
r.parentElement?.insertBefore(
|
|
95
|
+
const r = t.rows[n + 1];
|
|
96
|
+
r.parentElement?.insertBefore(o, 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: 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]);
|
|
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: 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]);
|
|
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: n, colIndex: o } = e;
|
|
121
|
+
t.deleteRow(n), G(t, n, o), 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: n, colIndex: o } = 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[o] && r.deleteCell(o);
|
|
129
129
|
}
|
|
130
|
-
G(t,
|
|
130
|
+
G(t, n, o), 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: n } = e, o = t.rows[n];
|
|
135
|
+
if (!o) return;
|
|
136
|
+
const l = o.parentElement?.tagName.toLowerCase() === "thead", r = t.querySelector("thead");
|
|
137
137
|
if (l) {
|
|
138
|
-
const a =
|
|
139
|
-
if (
|
|
138
|
+
const a = o.parentElement;
|
|
139
|
+
if (o === a.rows[a.rows.length - 1]) {
|
|
140
140
|
const i = t.querySelector("tbody") || t.appendChild(document.createElement("tbody"));
|
|
141
|
-
i.insertBefore(
|
|
141
|
+
i.insertBefore(o, i.firstChild), a.rows.length === 0 && a.remove();
|
|
142
142
|
} else
|
|
143
|
-
U(
|
|
144
|
-
} else if (!r ||
|
|
143
|
+
U(o, "td");
|
|
144
|
+
} else if (!r || o === 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(o);
|
|
147
147
|
} else
|
|
148
|
-
U(
|
|
148
|
+
U(o, "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((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);
|
|
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: n } = e;
|
|
167
|
+
for (let o = 0; o < t.rows.length; o++) {
|
|
168
|
+
const l = t.rows[o].cells[n];
|
|
169
169
|
if (l) {
|
|
170
170
|
const r = l.tagName.toLowerCase() === "th" ? "td" : "th", a = document.createElement(r);
|
|
171
171
|
a.innerHTML = l.innerHTML;
|
|
@@ -180,60 +180,61 @@ 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, n = t.parentElement;
|
|
184
|
+
n && n.classList.contains("rte-table-wrapper") ? n.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 n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
189
|
+
return n ? n.closest(t) : null;
|
|
190
190
|
}
|
|
191
|
+
const he = ".rte-content, .editora-content";
|
|
191
192
|
function M(e) {
|
|
192
193
|
if (!e) return !1;
|
|
193
|
-
const t = e.closest("[contenteditable]");
|
|
194
|
-
return !t || t.getAttribute("contenteditable") === "false" ? !1 : !
|
|
194
|
+
const t = e.closest(he), n = e.closest("[contenteditable]");
|
|
195
|
+
return !t || !n || !t.contains(n) || n.getAttribute("contenteditable") === "false" ? !1 : !n.closest('[data-readonly="true"]');
|
|
195
196
|
}
|
|
196
|
-
function
|
|
197
|
+
function be() {
|
|
197
198
|
const e = window.getSelection(), t = e && e.rangeCount > 0 ? e.getRangeAt(0).startContainer : null;
|
|
198
199
|
return w(t, ".rte-content") || (b ? b.closest(".rte-content") : null);
|
|
199
200
|
}
|
|
200
|
-
function
|
|
201
|
-
const
|
|
202
|
-
if (typeof
|
|
201
|
+
function me(e, t, n) {
|
|
202
|
+
const o = window.execEditorCommand || window.executeEditorCommand;
|
|
203
|
+
if (typeof o == "function")
|
|
203
204
|
try {
|
|
204
|
-
|
|
205
|
+
o("recordDomTransaction", e, t, n);
|
|
205
206
|
} catch {
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
function j(e) {
|
|
209
|
-
const t =
|
|
210
|
+
const t = be();
|
|
210
211
|
if (t && !M(t)) return;
|
|
211
|
-
const
|
|
212
|
+
const n = t ? t.innerHTML : "";
|
|
212
213
|
if (e(), !t) return;
|
|
213
|
-
const
|
|
214
|
-
|
|
214
|
+
const o = t.innerHTML;
|
|
215
|
+
o !== n && (me(t, n, o), t.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
215
216
|
}
|
|
216
|
-
function G(e, t,
|
|
217
|
+
function G(e, t, n) {
|
|
217
218
|
if (!e.isConnected || e.rows.length === 0) return;
|
|
218
|
-
const
|
|
219
|
+
const o = e.rows[Math.min(t, e.rows.length - 1)], l = o.cells[Math.min(n, o.cells.length - 1)];
|
|
219
220
|
if (!l) return;
|
|
220
221
|
const r = document.createRange(), a = l.querySelector("p, div, li") || l;
|
|
221
222
|
r.selectNodeContents(a), r.collapse(!0);
|
|
222
223
|
const i = window.getSelection();
|
|
223
224
|
i?.removeAllRanges(), i?.addRange(r);
|
|
224
225
|
}
|
|
225
|
-
const
|
|
226
|
+
const fe = () => {
|
|
226
227
|
const e = window.getSelection();
|
|
227
228
|
if (!e || e.rangeCount === 0) return;
|
|
228
|
-
const
|
|
229
|
-
if (!w(
|
|
230
|
-
const
|
|
231
|
-
if (!
|
|
232
|
-
const l =
|
|
229
|
+
const n = e.getRangeAt(0).startContainer;
|
|
230
|
+
if (!w(n, "table")) return;
|
|
231
|
+
const o = w(n, "td, th");
|
|
232
|
+
if (!o) return;
|
|
233
|
+
const l = o.parentElement;
|
|
233
234
|
if (!l) return;
|
|
234
235
|
let r = -1;
|
|
235
236
|
for (let d = 0; d < l.cells.length; d++)
|
|
236
|
-
if (l.cells[d] ===
|
|
237
|
+
if (l.cells[d] === o) {
|
|
237
238
|
r = d;
|
|
238
239
|
break;
|
|
239
240
|
}
|
|
@@ -244,21 +245,21 @@ const me = () => {
|
|
|
244
245
|
const u = parseInt(d.getAttribute(s) || "1", 10);
|
|
245
246
|
return Number.isFinite(u) && u > 0 ? u : 1;
|
|
246
247
|
};
|
|
247
|
-
if (i(
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
if (i(o, "rowspan") !== i(a, "rowspan")) return;
|
|
249
|
+
o.setAttribute("colspan", String(i(o, "colspan") + i(a, "colspan"))), Array.from(a.childNodes).forEach((d) => {
|
|
250
|
+
o.appendChild(d);
|
|
250
251
|
}), a.remove(), p();
|
|
251
252
|
};
|
|
252
253
|
function f() {
|
|
253
254
|
const e = window.getSelection();
|
|
254
255
|
if (!e || e.rangeCount === 0) return null;
|
|
255
|
-
const
|
|
256
|
-
if (!
|
|
256
|
+
const n = e.getRangeAt(0).startContainer, o = w(n, "table");
|
|
257
|
+
if (!o) return null;
|
|
257
258
|
let l = 0, r = 0;
|
|
258
|
-
const a = w(
|
|
259
|
+
const a = w(n, "td, th");
|
|
259
260
|
if (a) {
|
|
260
261
|
const i = a.parentElement;
|
|
261
|
-
for (; i && i !==
|
|
262
|
+
for (; i && i !== o.rows[l] && (l++, !(l >= o.rows.length)); )
|
|
262
263
|
;
|
|
263
264
|
const c = i;
|
|
264
265
|
if (c) {
|
|
@@ -270,73 +271,73 @@ function f() {
|
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
273
|
return {
|
|
273
|
-
table:
|
|
274
|
+
table: o,
|
|
274
275
|
rowIndex: l,
|
|
275
276
|
colIndex: r,
|
|
276
|
-
rowCount:
|
|
277
|
-
cellCount:
|
|
277
|
+
rowCount: o.rows.length,
|
|
278
|
+
cellCount: o.rows[0]?.cells.length || 0
|
|
278
279
|
};
|
|
279
280
|
}
|
|
280
281
|
function p() {
|
|
281
282
|
if (!h || !b) return;
|
|
282
283
|
const e = f();
|
|
283
284
|
if (!e) return;
|
|
284
|
-
const t = e.rowCount > 1,
|
|
285
|
-
J(t,
|
|
285
|
+
const t = e.rowCount > 1, n = e.cellCount > 1;
|
|
286
|
+
J(t, n);
|
|
286
287
|
}
|
|
287
|
-
function
|
|
288
|
+
function pe(e) {
|
|
288
289
|
const t = window.getSelection();
|
|
289
290
|
if (!t) return;
|
|
290
|
-
const
|
|
291
|
-
(e.textContent ?? "").trim() === "" ? (
|
|
291
|
+
const n = document.createRange();
|
|
292
|
+
(e.textContent ?? "").trim() === "" ? (n.selectNodeContents(e.querySelector("p, div") || e), n.collapse(!0)) : n.selectNodeContents(e), t.removeAllRanges(), t.addRange(n);
|
|
292
293
|
}
|
|
293
|
-
function
|
|
294
|
+
function ge(e) {
|
|
294
295
|
if (e.key !== "Tab" || e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
295
296
|
const t = window.getSelection();
|
|
296
297
|
if (!t || t.rangeCount === 0) return;
|
|
297
|
-
const
|
|
298
|
-
if (!
|
|
299
|
-
const l =
|
|
298
|
+
const n = w(t.getRangeAt(0).startContainer, "td, th"), o = n?.closest("table");
|
|
299
|
+
if (!n || !o || !M(o)) return;
|
|
300
|
+
const l = o.closest("[contenteditable]");
|
|
300
301
|
if (!l || !(e.target instanceof Node) || !l.contains(e.target)) return;
|
|
301
|
-
const r = Array.from(
|
|
302
|
-
(c) => c.closest("table") ===
|
|
303
|
-
), a = r.indexOf(
|
|
302
|
+
const r = Array.from(o.querySelectorAll("th, td")).filter(
|
|
303
|
+
(c) => c.closest("table") === o
|
|
304
|
+
), a = r.indexOf(n);
|
|
304
305
|
let i;
|
|
305
|
-
e.shiftKey ? i = r[a - 1] : a < r.length - 1 ? i = r[a + 1] : (y("addRowBelow"), i =
|
|
306
|
+
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(), pe(i));
|
|
306
307
|
}
|
|
307
|
-
function
|
|
308
|
-
|
|
308
|
+
function we() {
|
|
309
|
+
N = () => {
|
|
309
310
|
const e = f();
|
|
310
|
-
e && M(e.table) ?
|
|
311
|
-
},
|
|
312
|
-
const t = w(e.target, "table"),
|
|
313
|
-
!t && !
|
|
314
|
-
},
|
|
311
|
+
e && M(e.table) ? ve(e.table) : T();
|
|
312
|
+
}, B = (e) => {
|
|
313
|
+
const t = w(e.target, "table"), n = w(e.target, ".table-toolbar");
|
|
314
|
+
!t && !n && T();
|
|
315
|
+
}, V = () => {
|
|
315
316
|
T();
|
|
316
317
|
}, D = () => {
|
|
317
318
|
b && h && h.style.display !== "none" && S(b);
|
|
318
319
|
}, q = () => {
|
|
319
320
|
b && h && h.style.display !== "none" && S(b);
|
|
320
|
-
}, document.addEventListener("selectionchange",
|
|
321
|
+
}, document.addEventListener("selectionchange", N), document.addEventListener("keydown", ge), document.addEventListener("mousedown", B), document.addEventListener("tableDeleted", V), window.addEventListener("scroll", D, !0), window.addEventListener("resize", q);
|
|
321
322
|
}
|
|
322
323
|
function S(e) {
|
|
323
324
|
if (!h) return;
|
|
324
|
-
const t = e.getBoundingClientRect(),
|
|
325
|
-
let a = t.top -
|
|
325
|
+
const t = e.getBoundingClientRect(), n = h.getBoundingClientRect(), o = n.height || 40, l = n.width || 280, r = 10;
|
|
326
|
+
let a = t.top - o - r, i = t.left + t.width / 2 - l / 2;
|
|
326
327
|
a < r && (a = t.bottom + r), i < r && (i = r);
|
|
327
328
|
const c = window.innerWidth;
|
|
328
329
|
i + l > c - r && (i = c - l - r);
|
|
329
330
|
const d = window.innerHeight;
|
|
330
|
-
a +
|
|
331
|
+
a + o > d - r && (a = d - o - r), h.style.top = a + "px", h.style.left = i + "px";
|
|
331
332
|
}
|
|
332
|
-
function
|
|
333
|
-
b = e, h || (h =
|
|
333
|
+
function ve(e) {
|
|
334
|
+
b = e, h || (h = ye(), document.body.appendChild(h));
|
|
334
335
|
const t = !!e.closest(H) || document.body.matches(H) || document.documentElement.matches(H);
|
|
335
336
|
h.classList.toggle("rte-theme-dark", t), h.style.display = "flex", h.style.visibility = "hidden", requestAnimationFrame(() => {
|
|
336
337
|
S(e), h && (h.style.visibility = "visible");
|
|
337
338
|
});
|
|
338
|
-
const
|
|
339
|
-
|
|
339
|
+
const n = f();
|
|
340
|
+
n && J(n.rowCount > 1, n.cellCount > 1), ke(e);
|
|
340
341
|
}
|
|
341
342
|
const I = /* @__PURE__ */ new Set();
|
|
342
343
|
function Q() {
|
|
@@ -346,19 +347,19 @@ function Q() {
|
|
|
346
347
|
}
|
|
347
348
|
function T() {
|
|
348
349
|
if (h && (h.style.display = "none"), b) {
|
|
349
|
-
b.querySelectorAll(".resize-handle").forEach((
|
|
350
|
-
const t = b.parentElement,
|
|
351
|
-
|
|
350
|
+
b.querySelectorAll(".resize-handle").forEach((o) => o.remove());
|
|
351
|
+
const t = b.parentElement, n = t?.classList.contains("rte-table-wrapper") ? t.querySelector(".table-resize-handle") : b.querySelector(".table-resize-handle");
|
|
352
|
+
n && n.remove();
|
|
352
353
|
}
|
|
353
354
|
Q(), b = null;
|
|
354
355
|
}
|
|
355
356
|
function J(e, t) {
|
|
356
357
|
if (!h) return;
|
|
357
|
-
const
|
|
358
|
-
|
|
358
|
+
const n = h.querySelector('[data-action="deleteRow"]'), o = h.querySelector('[data-action="deleteColumn"]');
|
|
359
|
+
n && (n.disabled = !e), o && (o.disabled = !t);
|
|
359
360
|
}
|
|
360
361
|
let z = !1;
|
|
361
|
-
function
|
|
362
|
+
function Ce() {
|
|
362
363
|
if (z || typeof document > "u") return;
|
|
363
364
|
if (document.getElementById("rte-table-toolbar-styles")) {
|
|
364
365
|
z = !0;
|
|
@@ -521,8 +522,8 @@ function ve() {
|
|
|
521
522
|
}
|
|
522
523
|
`, document.head.appendChild(e);
|
|
523
524
|
}
|
|
524
|
-
function
|
|
525
|
-
|
|
525
|
+
function ye() {
|
|
526
|
+
Ce();
|
|
526
527
|
const e = document.createElement("div");
|
|
527
528
|
e.className = "table-toolbar", e.style.cssText = `
|
|
528
529
|
position: fixed;
|
|
@@ -532,72 +533,72 @@ function Ce() {
|
|
|
532
533
|
const t = (s) => {
|
|
533
534
|
const u = document.createElement("button");
|
|
534
535
|
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
|
-
},
|
|
536
|
+
}, n = () => {
|
|
536
537
|
const s = document.createElement("div");
|
|
537
538
|
return s.className = "toolbar-divider", s;
|
|
538
|
-
},
|
|
539
|
+
}, o = (...s) => {
|
|
539
540
|
const u = document.createElement("div");
|
|
540
541
|
return u.className = "toolbar-section", s.forEach((C) => u.appendChild(C)), u;
|
|
541
|
-
}, l =
|
|
542
|
+
}, l = o(
|
|
542
543
|
t({
|
|
543
|
-
icon:
|
|
544
|
+
icon: He(),
|
|
544
545
|
title: "Add row above (Ctrl+Shift+R)",
|
|
545
546
|
action: "addRowAbove"
|
|
546
547
|
}),
|
|
547
548
|
t({
|
|
548
|
-
icon:
|
|
549
|
+
icon: Re(),
|
|
549
550
|
title: "Add row below",
|
|
550
551
|
action: "addRowBelow"
|
|
551
552
|
}),
|
|
552
553
|
t({
|
|
553
|
-
icon:
|
|
554
|
+
icon: Te(),
|
|
554
555
|
title: "Delete row",
|
|
555
556
|
action: "deleteRow",
|
|
556
557
|
danger: !0
|
|
557
558
|
})
|
|
558
|
-
), r =
|
|
559
|
+
), r = o(
|
|
559
560
|
t({
|
|
560
|
-
icon:
|
|
561
|
+
icon: ze(),
|
|
561
562
|
title: "Add column left",
|
|
562
563
|
action: "addColumnLeft"
|
|
563
564
|
}),
|
|
564
565
|
t({
|
|
565
|
-
icon:
|
|
566
|
+
icon: Se(),
|
|
566
567
|
title: "Add column right (Ctrl+Shift+C)",
|
|
567
568
|
action: "addColumnRight"
|
|
568
569
|
}),
|
|
569
570
|
t({
|
|
570
|
-
icon:
|
|
571
|
+
icon: Ie(),
|
|
571
572
|
title: "Delete column",
|
|
572
573
|
action: "deleteColumn",
|
|
573
574
|
danger: !0
|
|
574
575
|
})
|
|
575
|
-
), a =
|
|
576
|
+
), a = o(
|
|
576
577
|
t({
|
|
577
|
-
icon:
|
|
578
|
+
icon: Me(),
|
|
578
579
|
title: "Toggle header row",
|
|
579
580
|
action: "toggleHeaderRow"
|
|
580
581
|
}),
|
|
581
582
|
t({
|
|
582
|
-
icon:
|
|
583
|
+
icon: Le(),
|
|
583
584
|
title: "Toggle header column",
|
|
584
585
|
action: "toggleHeaderColumn"
|
|
585
586
|
})
|
|
586
|
-
), i =
|
|
587
|
+
), i = o(
|
|
587
588
|
t({
|
|
588
|
-
icon:
|
|
589
|
+
icon: Ne(),
|
|
589
590
|
title: "Merge cells (horizontally)",
|
|
590
591
|
action: "mergeCells"
|
|
591
592
|
})
|
|
592
|
-
), c =
|
|
593
|
+
), c = o(
|
|
593
594
|
t({
|
|
594
|
-
icon:
|
|
595
|
+
icon: Ae(),
|
|
595
596
|
title: "Delete table",
|
|
596
597
|
action: "deleteTable",
|
|
597
598
|
delete: !0
|
|
598
599
|
})
|
|
599
600
|
);
|
|
600
|
-
e.appendChild(l), e.appendChild(
|
|
601
|
+
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(c);
|
|
601
602
|
const d = (s) => {
|
|
602
603
|
!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
604
|
};
|
|
@@ -634,16 +635,16 @@ function y(e) {
|
|
|
634
635
|
ue();
|
|
635
636
|
break;
|
|
636
637
|
case "mergeCells":
|
|
637
|
-
|
|
638
|
+
fe();
|
|
638
639
|
break;
|
|
639
640
|
}
|
|
640
641
|
});
|
|
641
642
|
}
|
|
642
|
-
function
|
|
643
|
+
function ke(e) {
|
|
643
644
|
const t = Y(e);
|
|
644
645
|
e.querySelectorAll(".resize-handle").forEach((i) => i.remove());
|
|
645
|
-
const
|
|
646
|
-
|
|
646
|
+
const o = t.querySelector(".table-resize-handle");
|
|
647
|
+
o && o.remove(), Q();
|
|
647
648
|
const l = e.querySelector("thead tr, tbody tr:first-child");
|
|
648
649
|
if (!l) return;
|
|
649
650
|
const r = l.querySelectorAll("td, th");
|
|
@@ -665,89 +666,89 @@ function ye(e) {
|
|
|
665
666
|
}), d.addEventListener("mouseleave", () => {
|
|
666
667
|
E || (d.style.background = "transparent");
|
|
667
668
|
}), d.addEventListener("mousedown", (u) => {
|
|
668
|
-
u.preventDefault(), u.stopPropagation(),
|
|
669
|
+
u.preventDefault(), u.stopPropagation(), Ee(u, c);
|
|
669
670
|
});
|
|
670
671
|
const s = i;
|
|
671
672
|
s.style.position || (s.style.position = "relative", I.add(s)), i.appendChild(d);
|
|
672
673
|
});
|
|
673
674
|
const a = document.createElement("div");
|
|
674
675
|
a.className = "table-resize-handle", a.addEventListener("mousedown", (i) => {
|
|
675
|
-
i.preventDefault(), i.stopPropagation(),
|
|
676
|
+
i.preventDefault(), i.stopPropagation(), xe(i);
|
|
676
677
|
}), t.appendChild(a);
|
|
677
678
|
}
|
|
678
|
-
function
|
|
679
|
+
function Ee(e, t) {
|
|
679
680
|
if (E = !0, k = t, O = e.clientX, !b) return;
|
|
680
|
-
const
|
|
681
|
-
|
|
682
|
-
const
|
|
681
|
+
const n = b.querySelector("thead tr, tbody tr:first-child");
|
|
682
|
+
n && n.cells[t] && (P = n.cells[t].offsetWidth), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
683
|
+
const o = (r) => {
|
|
683
684
|
if (!E || k === null || !b) return;
|
|
684
685
|
const a = r.clientX - O, i = Math.max(50, P + a);
|
|
685
686
|
b.querySelectorAll("tr").forEach((d) => {
|
|
686
687
|
d.cells[k] && (d.cells[k].style.width = i + "px");
|
|
687
688
|
});
|
|
688
689
|
}, l = () => {
|
|
689
|
-
E = !1, k = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove",
|
|
690
|
+
E = !1, k = null, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", l);
|
|
690
691
|
};
|
|
691
|
-
document.addEventListener("mousemove",
|
|
692
|
+
document.addEventListener("mousemove", o), document.addEventListener("mouseup", l);
|
|
692
693
|
}
|
|
693
|
-
function
|
|
694
|
+
function xe(e) {
|
|
694
695
|
if (!b) return;
|
|
695
|
-
R = !0, K = e.clientX,
|
|
696
|
-
const t = (
|
|
696
|
+
R = !0, K = e.clientX, _ = e.clientY, W = b.offsetWidth, X = b.offsetHeight, document.body.style.cursor = "nwse-resize", document.body.style.userSelect = "none";
|
|
697
|
+
const t = (o) => {
|
|
697
698
|
if (!R || !b) return;
|
|
698
|
-
const l =
|
|
699
|
+
const l = o.clientX - K, r = o.clientY - _, a = Math.max(200, W + l), i = Math.max(100, X + r);
|
|
699
700
|
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",
|
|
701
|
+
}, n = () => {
|
|
702
|
+
R = !1, document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", n);
|
|
702
703
|
};
|
|
703
|
-
document.addEventListener("mousemove", t), document.addEventListener("mouseup",
|
|
704
|
+
document.addEventListener("mousemove", t), document.addEventListener("mouseup", n);
|
|
704
705
|
}
|
|
705
|
-
function
|
|
706
|
+
function He() {
|
|
706
707
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
707
708
|
<path d="M2 7h12V5H2v2zm0 4h12V9H2v2zM8 1v3H5v2h3v3h2V6h3V4h-3V1H8z"/>
|
|
708
709
|
</svg>`;
|
|
709
710
|
}
|
|
710
|
-
function
|
|
711
|
+
function Re() {
|
|
711
712
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
712
713
|
<path d="M2 3h12V1H2v2zm0 4h12V5H2v2zm6 4v3h3v-2h2v-2h-2v-3h-2v3H5v2h3z"/>
|
|
713
714
|
</svg>`;
|
|
714
715
|
}
|
|
715
|
-
function
|
|
716
|
+
function Te() {
|
|
716
717
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
717
718
|
<path d="M2 5h12v2H2V5zm0 4h12v2H2V9zm4-6v2H4v2h2v2h2V7h2V5H8V3H6z"/>
|
|
718
719
|
</svg>`;
|
|
719
720
|
}
|
|
720
|
-
function
|
|
721
|
+
function ze() {
|
|
721
722
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
722
723
|
<path d="M7 2v12h2V2H7zm4 0v12h2V2h-2zM1 8h3v-3H1v3zm3 2H1v3h3v-3z"/>
|
|
723
724
|
</svg>`;
|
|
724
725
|
}
|
|
725
|
-
function
|
|
726
|
+
function Se() {
|
|
726
727
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
727
728
|
<path d="M2 2v12h2V2H2zm4 0v12h2V2H6zM12 8h3v-3h-3v3zm0 2h3v3h-3v-3z"/>
|
|
728
729
|
</svg>`;
|
|
729
730
|
}
|
|
730
|
-
function
|
|
731
|
+
function Ie() {
|
|
731
732
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
732
733
|
<path d="M5 2v12h2V2H5zm4 0v12h2V2H9zm3 2h3V1h-3v3zm3 2h-3v3h3V6zm0 4h-3v3h3v-3z"/>
|
|
733
734
|
</svg>`;
|
|
734
735
|
}
|
|
735
|
-
function
|
|
736
|
+
function Me() {
|
|
736
737
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
737
738
|
<path d="M2 2h12v3H2V2zm0 5h12v8H2V7zm2 2v4h2V9H4zm4 0v4h2V9H8zm4 0v4h2V9h-2z"/>
|
|
738
739
|
</svg>`;
|
|
739
740
|
}
|
|
740
|
-
function
|
|
741
|
+
function Le() {
|
|
741
742
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
742
743
|
<path d="M2 2v12h3V2H2zm5 0v12h8V2H7zm2 2h4v2H9V4zm0 4h4v2H9V8zm0 4h4v2H9v-2z"/>
|
|
743
744
|
</svg>`;
|
|
744
745
|
}
|
|
745
|
-
function
|
|
746
|
+
function Ae() {
|
|
746
747
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
747
748
|
<path d="M3 1h10v1H3V1zm1 2v11h8V3H4zM6 5h1v6H6V5zm3 0h1v6H9V5z"/>
|
|
748
749
|
</svg>`;
|
|
749
750
|
}
|
|
750
|
-
function
|
|
751
|
+
function Ne() {
|
|
751
752
|
return `<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
752
753
|
<path d="M2 2h4v3H2V2zm5 0h4v3H7V2zm5 0h2v3h-2V2zm-10 4h4v3H2V6zm5 0h4v3H7V6zm5 0h2v3h-2V6zm-10 4h4v3H2v-3zm5 0h4v3H7v-3zm5 0h2v3h-2v-3z"/>
|
|
753
754
|
</svg>`;
|
|
@@ -755,11 +756,11 @@ function Ae() {
|
|
|
755
756
|
if (typeof window < "u" && !window.__tablePluginInitialized) {
|
|
756
757
|
window.__tablePluginInitialized = !0;
|
|
757
758
|
const e = () => {
|
|
758
|
-
|
|
759
|
+
we();
|
|
759
760
|
};
|
|
760
761
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : setTimeout(e, 100);
|
|
761
762
|
}
|
|
762
|
-
const
|
|
763
|
+
const De = () => ({
|
|
763
764
|
name: "table",
|
|
764
765
|
toolbar: [
|
|
765
766
|
{
|
|
@@ -779,5 +780,5 @@ const Ne = () => ({
|
|
|
779
780
|
}
|
|
780
781
|
});
|
|
781
782
|
export {
|
|
782
|
-
|
|
783
|
+
De as TablePlugin
|
|
783
784
|
};
|