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