@editora/core 1.0.7 → 1.0.8

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.
Files changed (34) hide show
  1. package/LICENSE +21 -0
  2. package/dist/ApprovalWorkflowPlugin.native-C3jtAYjG.mjs +1076 -0
  3. package/dist/BlocksLibraryPlugin.native-HMWKxWNs.mjs +1327 -0
  4. package/dist/CitationsPlugin.native-BnU0qCwR.mjs +1464 -0
  5. package/dist/ConditionalContentPlugin.native-CfhY46rU.mjs +1367 -0
  6. package/dist/ContentRulesPlugin.native-nBLQ8QFZ.mjs +1099 -0
  7. package/dist/DataBindingPlugin.native-jQ1JPRTp.mjs +917 -0
  8. package/dist/DocSchemaPlugin.native-CHOge18O.mjs +1325 -0
  9. package/dist/MentionPlugin.native-BMDlOqur.mjs +734 -0
  10. package/dist/PIIRedactionPlugin.native-DcsjmtV1.mjs +1396 -0
  11. package/dist/{PageBreakPlugin.native-CXdX5fAv.mjs → PageBreakPlugin.native-DijGuHJZ.mjs} +37 -37
  12. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-WuIwOAOR.mjs} +30 -30
  13. package/dist/SlashCommandsPlugin.native-CmxvMEaE.mjs +755 -0
  14. package/dist/SmartPastePlugin.native-BOKKtF07.mjs +1398 -0
  15. package/dist/TrackChangesPlugin.native-Bghu2q4a.mjs +761 -0
  16. package/dist/TranslationWorkflowPlugin.native-Bz6jDGvj.mjs +1728 -0
  17. package/dist/VersionDiffPlugin.native-Bvxgy--t.mjs +776 -0
  18. package/dist/editora.min.js +13 -13
  19. package/dist/editora.umd.js +13 -13
  20. package/dist/index-D1LOqg5C.js +10 -0
  21. package/dist/{index-yzU4NdPT.mjs → index-DqC57IEH.mjs} +424 -331
  22. package/dist/index.cjs.js +1 -1
  23. package/dist/index.esm.js +2 -2
  24. package/dist/plugin-loader.js +77 -40
  25. package/dist/webcomponent-core.js +479 -386
  26. package/dist/webcomponent-core.min.css +1 -1
  27. package/dist/webcomponent-core.min.js +39 -39
  28. package/dist/webcomponent.cjs.js +1 -1
  29. package/dist/webcomponent.esm.js +1 -1
  30. package/dist/webcomponent.js +417 -287
  31. package/dist/webcomponent.min.css +1 -1
  32. package/dist/webcomponent.min.js +5664 -394
  33. package/package.json +2 -2
  34. package/dist/index-BpE6GFbz.js +0 -10
@@ -0,0 +1,761 @@
1
+ const p = ".rte-content, .editora-content", g = '.rte-track-insert[data-track-change="insert"]', f = '.rte-track-delete[data-track-change="delete"]', w = `${g}, ${f}`, _ = "__editoraCommandEditorRoot", B = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new Set();
2
+ let q = !1, h = null, F = !1, T = {}, j = !1;
3
+ const J = typeof InputEvent != "undefined" && typeof InputEvent.prototype == "object" && "inputType" in InputEvent.prototype, Q = /* @__PURE__ */ new Set([
4
+ "IMG",
5
+ "TABLE",
6
+ "VIDEO",
7
+ "AUDIO",
8
+ "SVG",
9
+ "MATH",
10
+ "HR",
11
+ "IFRAME",
12
+ "INPUT",
13
+ "TEXTAREA",
14
+ "SELECT",
15
+ "BUTTON",
16
+ "CANVAS"
17
+ ]);
18
+ function ee(e) {
19
+ if (!e) return null;
20
+ const t = e.querySelector('[contenteditable="true"]');
21
+ return t instanceof HTMLElement ? t : null;
22
+ }
23
+ function te() {
24
+ if (typeof window == "undefined") return null;
25
+ const e = window[_];
26
+ if (!(e instanceof HTMLElement)) return null;
27
+ window[_] = null;
28
+ const t = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
29
+ if (t) {
30
+ const r = ee(t);
31
+ if (r) return r;
32
+ if (t.getAttribute("contenteditable") === "true") return t;
33
+ }
34
+ if (e.getAttribute("contenteditable") === "true")
35
+ return e;
36
+ const n = e.closest('[contenteditable="true"]');
37
+ return n instanceof HTMLElement ? n : null;
38
+ }
39
+ function ne(e) {
40
+ if ((e == null ? void 0 : e.contentElement) instanceof HTMLElement) return e.contentElement;
41
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
42
+ const o = e.editorElement;
43
+ if (o.getAttribute("contenteditable") === "true") return o;
44
+ const a = o.querySelector('[contenteditable="true"]');
45
+ if (a instanceof HTMLElement) return a;
46
+ }
47
+ const t = te();
48
+ if (t && document.contains(t)) return t;
49
+ const n = window.getSelection();
50
+ if (n && n.rangeCount > 0) {
51
+ const o = n.getRangeAt(0).startContainer, a = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement, c = a == null ? void 0 : a.closest(p);
52
+ if (c) return c;
53
+ }
54
+ const r = document.activeElement;
55
+ if (r) {
56
+ if (r.matches(p)) return r;
57
+ const o = r.closest(p);
58
+ if (o) return o;
59
+ }
60
+ return h != null && h.isConnected ? h : document.querySelector(p);
61
+ }
62
+ function R(e, t) {
63
+ var r;
64
+ k(e), H(e);
65
+ let n = B.get(e);
66
+ return n || (n = {
67
+ enabled: !!t.enabledByDefault,
68
+ author: ((r = t.author) == null ? void 0 : r.trim()) || "system",
69
+ includeTimestamp: t.includeTimestamp !== !1
70
+ }, B.set(e, n), n.enabled && (M(e, n), y(e, n.enabled))), S(e, "toggleTrackChanges", n.enabled), n;
71
+ }
72
+ function y(e, t) {
73
+ e.classList.toggle("rte-track-changes-enabled", t), t ? e.setAttribute("data-track-changes", "true") : e.removeAttribute("data-track-changes");
74
+ }
75
+ function re(e) {
76
+ return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
77
+ }
78
+ function S(e, t, n) {
79
+ const r = re(e);
80
+ Array.from(
81
+ r.querySelectorAll(
82
+ `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
83
+ )
84
+ ).forEach((a) => {
85
+ a.classList.toggle("active", n), a.setAttribute("data-active", n ? "true" : "false"), a.setAttribute("aria-pressed", n ? "true" : "false"), a.setAttribute("title", n ? "Track Changes (On)" : "Track Changes (Off)");
86
+ });
87
+ }
88
+ function ae(e) {
89
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
90
+ }
91
+ function oe(e, t) {
92
+ if (t === e.innerHTML) return;
93
+ const n = window.execEditorCommand || window.executeEditorCommand;
94
+ if (typeof n == "function")
95
+ try {
96
+ n("recordDomTransaction", e, t, e.innerHTML);
97
+ } catch (r) {
98
+ }
99
+ }
100
+ function m(e, t) {
101
+ ae(e), oe(e, t);
102
+ }
103
+ function ce(e, t) {
104
+ return e.startContainer === t.startContainer && e.startOffset === t.startOffset && e.endContainer === t.endContainer && e.endOffset === t.endOffset;
105
+ }
106
+ function G(e) {
107
+ return {
108
+ author: e.author,
109
+ timestamp: e.includeTimestamp ? (/* @__PURE__ */ new Date()).toISOString() : ""
110
+ };
111
+ }
112
+ function se(e, t) {
113
+ const n = document.createElement("span");
114
+ n.className = "rte-track-insert", n.setAttribute("data-track-change", "insert"), n.setAttribute("contenteditable", "false");
115
+ const r = G(t);
116
+ return n.setAttribute("data-track-author", r.author), r.timestamp && n.setAttribute("data-track-time", r.timestamp), n.appendChild(document.createTextNode(e)), n;
117
+ }
118
+ function k(e) {
119
+ Array.from(e.querySelectorAll(g)).forEach((n) => {
120
+ n.setAttribute("contenteditable", "false");
121
+ });
122
+ }
123
+ function E(e) {
124
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
125
+ }
126
+ function le(e, t) {
127
+ const n = e.startContainer, r = e.startOffset;
128
+ if (n.nodeType === Node.TEXT_NODE) {
129
+ const o = n, a = o.previousSibling || o.nextSibling;
130
+ if (a instanceof HTMLElement && a.matches(g) && t.contains(a))
131
+ return a;
132
+ }
133
+ if (n.nodeType === Node.ELEMENT_NODE) {
134
+ const o = n, a = o.childNodes[r - 1];
135
+ if (a instanceof HTMLElement && a.matches(g) && t.contains(a))
136
+ return a;
137
+ const c = o.childNodes[r];
138
+ if (c instanceof HTMLElement && c.matches(g) && t.contains(c))
139
+ return c;
140
+ }
141
+ return null;
142
+ }
143
+ function P(e, t, n) {
144
+ const r = t.lastChild;
145
+ r && r.nodeType === Node.TEXT_NODE ? r.data += n : t.appendChild(document.createTextNode(n)), C(e, t);
146
+ }
147
+ function ie(e, t) {
148
+ const n = document.createElement("span");
149
+ n.className = "rte-track-delete", n.setAttribute("data-track-change", "delete"), n.setAttribute("contenteditable", "false");
150
+ const r = G(t);
151
+ return n.setAttribute("data-track-author", r.author), r.timestamp && n.setAttribute("data-track-time", r.timestamp), n.appendChild(e), n;
152
+ }
153
+ function b(e) {
154
+ const t = window.getSelection();
155
+ if (!t || t.rangeCount === 0) return null;
156
+ const n = t.getRangeAt(0);
157
+ return e.contains(n.commonAncestorContainer) ? n : null;
158
+ }
159
+ function ue() {
160
+ j || typeof document == "undefined" || (j = !0, document.addEventListener(
161
+ "selectionchange",
162
+ () => {
163
+ const e = window.getSelection();
164
+ if (!e || e.rangeCount === 0) return;
165
+ const t = e.getRangeAt(0), n = E(t.startContainer), r = (n == null ? void 0 : n.closest(p)) || null;
166
+ r && (L.set(r, t.cloneRange()), h = r);
167
+ },
168
+ !0
169
+ ));
170
+ }
171
+ function C(e, t) {
172
+ if (!t.parentNode) {
173
+ e.focus({ preventScroll: !0 });
174
+ return;
175
+ }
176
+ const n = window.getSelection();
177
+ if (!n) return;
178
+ const r = document.createRange();
179
+ r.setStartAfter(t), r.collapse(!0), n.removeAllRanges(), n.addRange(r), e.focus({ preventScroll: !0 });
180
+ }
181
+ function O(e, t) {
182
+ if (!t.parentNode) {
183
+ e.focus({ preventScroll: !0 });
184
+ return;
185
+ }
186
+ const n = window.getSelection();
187
+ if (!n) return;
188
+ const r = document.createRange();
189
+ r.setStartBefore(t), r.collapse(!0), n.removeAllRanges(), n.addRange(r), e.focus({ preventScroll: !0 });
190
+ }
191
+ function de(e, t, n) {
192
+ const r = window.getSelection();
193
+ if (!r) return;
194
+ const o = document.createRange();
195
+ o.setStart(t, Math.max(0, n)), o.collapse(!0), r.removeAllRanges(), r.addRange(o), e.focus({ preventScroll: !0 });
196
+ }
197
+ function V(e) {
198
+ let t = b(e);
199
+ if (!t) {
200
+ const c = L.get(e);
201
+ c && e.contains(c.commonAncestorContainer) && (t = c.cloneRange());
202
+ }
203
+ if (!t || !t.collapsed) return;
204
+ const n = E(t.startContainer);
205
+ if (!n) return;
206
+ const r = n.closest(g);
207
+ if (!r || !e.contains(r) || !r.parentNode) return;
208
+ const o = window.getSelection();
209
+ if (!o) return;
210
+ const a = document.createRange();
211
+ a.setStartAfter(r), a.collapse(!0), o.removeAllRanges(), o.addRange(a), e.focus({ preventScroll: !0 });
212
+ }
213
+ function K(e, t) {
214
+ const n = e.innerHTML;
215
+ k(e), V(e), e.focus({ preventScroll: !0 });
216
+ const r = t === "insertLineBreak" ? "insertLineBreak" : "insertParagraph", o = document.execCommand(r, !1);
217
+ return k(e), m(e, n), o !== !1;
218
+ }
219
+ function fe(e) {
220
+ const t = b(e);
221
+ if (t && t.collapsed) return t;
222
+ const n = L.get(e);
223
+ return n && n.collapsed && e.contains(n.commonAncestorContainer) ? n.cloneRange() : null;
224
+ }
225
+ function ge(e) {
226
+ return e.matches(g) || e.matches(f) ? (e.textContent || "").replace(/\u200B/g, "").trim().length > 0 : Q.has(e.tagName);
227
+ }
228
+ function W(e, t) {
229
+ if (t !== "insertParagraph") return !1;
230
+ const n = fe(e);
231
+ if (!n) return !1;
232
+ const r = E(n.startContainer);
233
+ if (!r) return !1;
234
+ const o = r.closest("li");
235
+ return !(o instanceof HTMLElement) || !e.contains(o) || (o.textContent || "").replace(/\u200B/g, "").trim().length > 0 ? !1 : !Array.from(o.querySelectorAll("*")).some(
236
+ (s) => ge(s)
237
+ );
238
+ }
239
+ function he(e) {
240
+ const t = document.createRange(), n = window.getSelection();
241
+ if (n && n.rangeCount > 0) {
242
+ const r = n.getRangeAt(0);
243
+ if (e.contains(r.commonAncestorContainer))
244
+ return t.setStart(r.endContainer, r.endOffset), t.collapse(!0), t;
245
+ }
246
+ return t.selectNodeContents(e), t.collapse(!1), t;
247
+ }
248
+ function me(e) {
249
+ return (e.textContent || "").length > 0 ? !0 : Array.from(e.childNodes).some((n) => {
250
+ if (n.nodeType !== Node.ELEMENT_NODE) return !1;
251
+ const r = n;
252
+ return ["BR", "IMG", "TABLE", "VIDEO", "AUDIO", "SVG", "MATH"].includes(r.tagName);
253
+ });
254
+ }
255
+ function pe(e) {
256
+ return Array.from(e.childNodes).some((t) => {
257
+ if (t.nodeType === Node.TEXT_NODE)
258
+ return (t.textContent || "").length > 0;
259
+ if (t.nodeType !== Node.ELEMENT_NODE) return !1;
260
+ const n = t;
261
+ return ["BR", "IMG", "TABLE", "VIDEO", "AUDIO", "SVG", "MATH"].includes(n.tagName);
262
+ });
263
+ }
264
+ function Ee(e, t, n) {
265
+ if (!e.collapsed) return null;
266
+ const r = e.startContainer, o = e.startOffset;
267
+ let a = null;
268
+ if (r.nodeType === Node.TEXT_NODE) {
269
+ const c = r;
270
+ t === "backward" && o === 0 ? a = c.previousSibling : t === "forward" && o === c.length && (a = c.nextSibling);
271
+ } else if (r.nodeType === Node.ELEMENT_NODE) {
272
+ const c = r;
273
+ t === "backward" && o > 0 ? a = c.childNodes[o - 1] || null : t === "forward" && o < c.childNodes.length && (a = c.childNodes[o] || null);
274
+ }
275
+ return !(a instanceof HTMLElement) || !a.matches(g) || !n.contains(a) ? null : a;
276
+ }
277
+ function ke(e, t) {
278
+ const n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = [];
279
+ let o = n.nextNode();
280
+ for (; o; ) {
281
+ const a = o;
282
+ a.data.length > 0 && r.push(a), o = n.nextNode();
283
+ }
284
+ return r.length === 0 ? null : t ? r[r.length - 1] : r[0];
285
+ }
286
+ function Te(e, t, n) {
287
+ const r = Ee(t, n, e);
288
+ return r ? x(e, r, n) : !1;
289
+ }
290
+ function x(e, t, n) {
291
+ const r = t.parentNode;
292
+ if (!r) return !1;
293
+ const o = Array.prototype.indexOf.call(r.childNodes, t), a = ke(t, n === "backward");
294
+ return a ? (n === "backward" ? a.data = a.data.slice(0, -1) : a.data = a.data.slice(1), a.data.length === 0 && a.remove(), pe(t) ? (n === "backward" ? C(e, t) : O(e, t), !0) : (t.remove(), de(e, r, o), !0)) : !1;
295
+ }
296
+ function Z(e) {
297
+ if (e.startContainer !== e.endContainer || e.startContainer.nodeType !== Node.ELEMENT_NODE) return null;
298
+ const t = e.startContainer;
299
+ return e.endOffset - e.startOffset !== 1 ? null : t.childNodes[e.startOffset] || null;
300
+ }
301
+ function I(e, t) {
302
+ const n = Z(e);
303
+ return !(n instanceof HTMLElement) || !n.matches(f) || !t.contains(n) ? null : n;
304
+ }
305
+ function be(e, t) {
306
+ const n = Z(e);
307
+ return !(n instanceof HTMLElement) || !n.matches(g) || !t.contains(n) ? null : n;
308
+ }
309
+ function Ce(e, t) {
310
+ var a, c;
311
+ if (t.collapsed) {
312
+ const s = E(t.startContainer), l = s == null ? void 0 : s.closest(f);
313
+ if (l && e.contains(l)) {
314
+ const i = document.createRange();
315
+ return i.setStartAfter(l), i.collapse(!0), i;
316
+ }
317
+ return t;
318
+ }
319
+ const n = I(t, e);
320
+ if (n) {
321
+ const s = document.createRange();
322
+ return s.setStartAfter(n), s.collapse(!0), s;
323
+ }
324
+ const r = (a = E(t.startContainer)) == null ? void 0 : a.closest(f), o = (c = E(t.endContainer)) == null ? void 0 : c.closest(f);
325
+ if (r && o && r === o && e.contains(r)) {
326
+ const s = document.createRange();
327
+ return s.setStartAfter(r), s.collapse(!0), s;
328
+ }
329
+ return t;
330
+ }
331
+ function Ae(e, t) {
332
+ const r = Array.from(t.querySelectorAll(g)).filter((s) => {
333
+ try {
334
+ return e.intersectsNode(s);
335
+ } catch (l) {
336
+ return !1;
337
+ }
338
+ });
339
+ if (r.length !== 1) return null;
340
+ const o = r[0], a = (e.toString() || "").replace(/\s+/g, ""), c = (o.textContent || "").replace(/\s+/g, "");
341
+ return !c || a !== c ? null : o;
342
+ }
343
+ function U(e, t, n) {
344
+ if (t.collapsed) return null;
345
+ const r = t.cloneContents();
346
+ if (!me(r)) return null;
347
+ const o = ie(r, n);
348
+ return t.deleteContents(), t.insertNode(o), C(e, o), o;
349
+ }
350
+ function Ne(e, t, n) {
351
+ if (!t.collapsed) return t;
352
+ const r = t.startContainer, o = t.startOffset;
353
+ if (r.nodeType === Node.TEXT_NODE) {
354
+ const s = r;
355
+ if (n === "backward" && o > 0) {
356
+ const l = t.cloneRange();
357
+ return l.setStart(s, o - 1), l;
358
+ }
359
+ if (n === "forward" && o < s.length) {
360
+ const l = t.cloneRange();
361
+ return l.setEnd(s, o + 1), l;
362
+ }
363
+ }
364
+ if (r.nodeType === Node.ELEMENT_NODE) {
365
+ const s = r;
366
+ if (n === "backward" && o > 0)
367
+ for (let l = o - 1; l >= 0; l -= 1) {
368
+ const i = s.childNodes[l];
369
+ if (!i || i instanceof HTMLElement && i.matches(f))
370
+ continue;
371
+ const u = t.cloneRange();
372
+ if (i.nodeType === Node.TEXT_NODE) {
373
+ const d = i;
374
+ if (d.length === 0) continue;
375
+ u.setStart(d, d.length - 1), u.setEnd(d, d.length);
376
+ } else
377
+ u.setStartBefore(i), u.setEndAfter(i);
378
+ return u;
379
+ }
380
+ if (n === "forward" && o < s.childNodes.length)
381
+ for (let l = o; l < s.childNodes.length; l += 1) {
382
+ const i = s.childNodes[l];
383
+ if (!i || i instanceof HTMLElement && i.matches(f))
384
+ continue;
385
+ const u = t.cloneRange();
386
+ if (i.nodeType === Node.TEXT_NODE) {
387
+ const d = i;
388
+ if (d.length === 0) continue;
389
+ u.setStart(d, 0), u.setEnd(d, 1);
390
+ } else
391
+ u.setStartBefore(i), u.setEndAfter(i);
392
+ return u;
393
+ }
394
+ }
395
+ const a = window.getSelection();
396
+ if (!a || typeof a.modify != "function")
397
+ return null;
398
+ const c = t.cloneRange();
399
+ a.removeAllRanges(), a.addRange(c);
400
+ try {
401
+ if (a.modify("extend", n, "character"), a.rangeCount === 0)
402
+ return null;
403
+ const s = a.getRangeAt(0).cloneRange();
404
+ if (s.collapsed || !e.contains(s.commonAncestorContainer))
405
+ return null;
406
+ const l = I(s, e);
407
+ return l ? (n === "backward" ? O(e, l) : C(e, l), null) : s;
408
+ } catch (s) {
409
+ return null;
410
+ } finally {
411
+ a.removeAllRanges(), a.addRange(c);
412
+ }
413
+ }
414
+ function z(e, t, n) {
415
+ let r = b(e);
416
+ if (!r) return !1;
417
+ const o = Ce(e, r.cloneRange());
418
+ if (!ce(o, r)) {
419
+ const d = window.getSelection();
420
+ d && (d.removeAllRanges(), d.addRange(o)), r = o;
421
+ }
422
+ const a = e.innerHTML;
423
+ r.collapsed || U(e, r.cloneRange(), t);
424
+ const c = E(r.startContainer), s = c == null ? void 0 : c.closest(g);
425
+ if (r.collapsed && s && e.contains(s))
426
+ return P(e, s, n), m(e, a), !0;
427
+ const l = r.collapsed ? le(r, e) : null;
428
+ if (l)
429
+ return P(e, l, n), m(e, a), !0;
430
+ const i = he(e), u = se(n, t);
431
+ return i.insertNode(u), C(e, u), m(e, a), !0;
432
+ }
433
+ function $(e, t, n) {
434
+ const r = b(e);
435
+ if (!r) return !1;
436
+ const o = n.includes("Backward") ? "backward" : "forward", a = e.innerHTML;
437
+ if (r.collapsed && Te(e, r.cloneRange(), o))
438
+ return m(e, a), !0;
439
+ const c = be(r, e);
440
+ if (c && x(e, c, o))
441
+ return m(e, a), !0;
442
+ if (!r.collapsed) {
443
+ const u = Ae(r, e);
444
+ if (u && x(e, u, o))
445
+ return m(e, a), !0;
446
+ }
447
+ const s = r.collapsed ? Ne(e, r.cloneRange(), o) : r.cloneRange();
448
+ if (!s) return !1;
449
+ const l = I(s, e);
450
+ return l ? (o === "backward" ? O(e, l) : C(e, l), !0) : U(e, s, t) ? (H(e), m(e, a), !0) : !1;
451
+ }
452
+ function v(e) {
453
+ const t = e.parentNode;
454
+ if (t) {
455
+ for (; e.firstChild; )
456
+ t.insertBefore(e.firstChild, e);
457
+ t.removeChild(e);
458
+ }
459
+ }
460
+ function H(e) {
461
+ Array.from(e.querySelectorAll(f)).forEach((r) => {
462
+ r.setAttribute("contenteditable", "false"), Array.from(r.querySelectorAll(f)).forEach((a) => {
463
+ a !== r && v(a);
464
+ });
465
+ });
466
+ let n = !0;
467
+ for (; n; )
468
+ n = !1, Array.from(e.querySelectorAll(f)).forEach((o) => {
469
+ if (!o.isConnected) return;
470
+ let a = o.nextSibling;
471
+ for (; a && a.nodeType === Node.TEXT_NODE && !(a.textContent || "").trim(); )
472
+ a = a.nextSibling;
473
+ if (a instanceof HTMLElement && a.matches(f)) {
474
+ for (; a.firstChild; )
475
+ o.appendChild(a.firstChild);
476
+ a.remove(), n = !0;
477
+ }
478
+ o.firstChild || (o.remove(), n = !0);
479
+ });
480
+ }
481
+ function Y(e) {
482
+ return Array.from(e.querySelectorAll(w));
483
+ }
484
+ function ye(e) {
485
+ const t = b(e);
486
+ if (!t) return [];
487
+ const n = /* @__PURE__ */ new Set(), r = t.startContainer.nodeType === Node.ELEMENT_NODE ? t.startContainer : t.startContainer.parentElement, o = t.endContainer.nodeType === Node.ELEMENT_NODE ? t.endContainer : t.endContainer.parentElement, a = r == null ? void 0 : r.closest(w);
488
+ a && e.contains(a) && n.add(a);
489
+ const c = o == null ? void 0 : o.closest(w);
490
+ return c && e.contains(c) && n.add(c), Y(e).filter((l) => {
491
+ try {
492
+ return t.intersectsNode(l);
493
+ } catch (i) {
494
+ return !1;
495
+ }
496
+ }).forEach((l) => n.add(l)), Array.from(n);
497
+ }
498
+ function A(e, t, n) {
499
+ const r = n === "all" ? Y(e) : ye(e);
500
+ if (r.length === 0) return !1;
501
+ const o = e.innerHTML;
502
+ return r.forEach((a) => {
503
+ if (!a.isConnected) return;
504
+ const c = a.matches(g), s = a.matches(f);
505
+ if (!(!c && !s)) {
506
+ if (t === "accept") {
507
+ c ? v(a) : a.remove();
508
+ return;
509
+ }
510
+ c ? a.remove() : (a.removeAttribute("contenteditable"), v(a));
511
+ }
512
+ }), H(e), m(e, o), !0;
513
+ }
514
+ function Se(e) {
515
+ if (!(e instanceof Node)) return null;
516
+ const t = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
517
+ return (t == null ? void 0 : t.closest(p)) || null;
518
+ }
519
+ function Me() {
520
+ F || typeof document == "undefined" || (F = !0, document.addEventListener(
521
+ "focusin",
522
+ (e) => {
523
+ if (!T.enabledByDefault) return;
524
+ const t = Se(e.target);
525
+ if (!t) return;
526
+ h = t;
527
+ const n = R(t, T);
528
+ n.enabled ? (M(t, n), y(t, !0), S(t, "toggleTrackChanges", !0)) : k(t);
529
+ },
530
+ !0
531
+ ));
532
+ }
533
+ function we(e, t) {
534
+ return (n) => {
535
+ if (!t.enabled || e.getAttribute("data-track-changes") !== "true") return;
536
+ h = e;
537
+ const r = n.inputType || "";
538
+ if (r === "insertParagraph" || r === "insertLineBreak") {
539
+ if (W(e, r))
540
+ return;
541
+ n.preventDefault(), K(e, r);
542
+ return;
543
+ }
544
+ if (r.startsWith("delete")) {
545
+ n.preventDefault(), $(e, t, r);
546
+ return;
547
+ }
548
+ if (r === "insertText" || r === "insertCompositionText") {
549
+ const o = n.data || "";
550
+ if (!o) return;
551
+ n.preventDefault(), z(e, t, o);
552
+ }
553
+ };
554
+ }
555
+ function Re(e, t) {
556
+ return (n) => {
557
+ if (!t.enabled || e.getAttribute("data-track-changes") !== "true" || n.key !== "Enter" || J) return;
558
+ const r = n.shiftKey ? "insertLineBreak" : "insertParagraph";
559
+ W(e, r) || (h = e, n.preventDefault(), n.stopPropagation(), K(e, r));
560
+ };
561
+ }
562
+ function xe(e, t) {
563
+ return (n) => {
564
+ var o;
565
+ if (n.__editoraSmartPasteHandled === !0 || n.defaultPrevented || !t.enabled || e.getAttribute("data-track-changes") !== "true") return;
566
+ const r = ((o = n.clipboardData) == null ? void 0 : o.getData("text/plain")) || "";
567
+ r && (n.preventDefault(), h = e, z(e, t, r));
568
+ };
569
+ }
570
+ function ve(e, t) {
571
+ return (n) => {
572
+ if (!t.enabled || e.getAttribute("data-track-changes") !== "true") return;
573
+ const r = b(e);
574
+ if (!r || r.collapsed) return;
575
+ const o = r.toString();
576
+ n.clipboardData && (n.clipboardData.setData("text/plain", o), n.preventDefault()), h = e, $(e, t, "deleteByCut");
577
+ };
578
+ }
579
+ function M(e, t) {
580
+ if (N.has(e)) return;
581
+ k(e);
582
+ const n = {
583
+ beforeInput: we(e, t),
584
+ keydown: Re(e, t),
585
+ paste: xe(e, t),
586
+ cut: ve(e, t)
587
+ };
588
+ e.addEventListener("beforeinput", n.beforeInput), e.addEventListener("keydown", n.keydown), e.addEventListener("paste", n.paste), e.addEventListener("cut", n.cut), N.set(e, n), D.add(e);
589
+ }
590
+ function X(e) {
591
+ const t = N.get(e);
592
+ t && (e.removeEventListener("beforeinput", t.beforeInput), e.removeEventListener("keydown", t.keydown), e.removeEventListener("paste", t.paste), e.removeEventListener("cut", t.cut), N.delete(e), D.delete(e));
593
+ }
594
+ function Le() {
595
+ if (q || typeof document == "undefined") return;
596
+ q = !0;
597
+ const e = document.createElement("style");
598
+ e.id = "rte-track-changes-styles", e.textContent = `
599
+ .rte-track-insert[data-track-change="insert"] {
600
+ background: rgba(22, 163, 74, 0.2);
601
+ color: inherit;
602
+ text-decoration: underline;
603
+ text-decoration-color: #16a34a;
604
+ text-decoration-thickness: 2px;
605
+ border-radius: 2px;
606
+ padding: 0 1px;
607
+ white-space: pre-wrap;
608
+ }
609
+
610
+ .rte-track-delete[data-track-change="delete"] {
611
+ background: rgba(220, 38, 38, 0.16);
612
+ color: inherit;
613
+ text-decoration: line-through;
614
+ text-decoration-color: #dc2626;
615
+ text-decoration-thickness: 2px;
616
+ border-radius: 2px;
617
+ padding: 0 1px;
618
+ white-space: pre-wrap;
619
+ cursor: pointer;
620
+ }
621
+
622
+ .editora-theme-dark .rte-track-insert[data-track-change="insert"],
623
+ .rte-theme-dark .rte-track-insert[data-track-change="insert"] {
624
+ background: rgba(74, 222, 128, 0.2);
625
+ text-decoration-color: #4ade80;
626
+ }
627
+
628
+ .editora-theme-dark .rte-track-delete[data-track-change="delete"],
629
+ .rte-theme-dark .rte-track-delete[data-track-change="delete"] {
630
+ background: rgba(248, 113, 113, 0.18);
631
+ text-decoration-color: #f87171;
632
+ }
633
+
634
+ .rte-content[data-track-changes="true"],
635
+ .editora-content[data-track-changes="true"] {
636
+ caret-color: currentColor;
637
+ }
638
+
639
+ .rte-toolbar-group-items.track-changes,
640
+ .editora-toolbar-group-items.track-changes {
641
+ display: flex;
642
+ border: 1px solid #ccc;
643
+ border-radius: 3px;
644
+ background: #fff;
645
+ }
646
+ .rte-toolbar-group-items.track-changes .rte-toolbar-button,
647
+ .editora-toolbar-group-items.track-changes .editora-toolbar-button {
648
+ border: none;
649
+ border-radius: 0px;
650
+ }
651
+ .rte-toolbar-group-items.track-changes .rte-toolbar-button,
652
+ .editora-toolbar-group-items.track-changes .editora-toolbar-button {
653
+ border-right: 1px solid #ccc;
654
+ }
655
+ .rte-toolbar-group-items.track-changes .rte-toolbar-item:last-child .rte-toolbar-button,
656
+ .editora-toolbar-group-items.track-changes .editora-toolbar-item:last-child .editora-toolbar-button {
657
+ border-right: none;
658
+ }
659
+
660
+ :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .rte-toolbar-group-items.track-changes,
661
+ :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .editora-toolbar-group-items.track-changes {
662
+ border-color: #566275;
663
+ }
664
+
665
+ :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .rte-toolbar-group-items.track-changes .rte-toolbar-button,
666
+ :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .editora-toolbar-group-items.track-changes .editora-toolbar-button {
667
+ border-right-color: #566275;
668
+ }
669
+
670
+ .rte-toolbar-button[data-command="toggleTrackChanges"].active,
671
+ .editora-toolbar-button[data-command="toggleTrackChanges"].active {
672
+ background-color: #ccc;
673
+ }
674
+ `, document.head.appendChild(e);
675
+ }
676
+ const De = (e = {}) => {
677
+ Le(), ue(), T = { ...T, ...e }, Me(), T.enabledByDefault && typeof document != "undefined" && (typeof requestAnimationFrame == "function" ? requestAnimationFrame : (o) => window.setTimeout(o, 0))(() => {
678
+ Array.from(document.querySelectorAll(p)).forEach((a) => {
679
+ const c = R(a, T);
680
+ c.enabled ? (M(a, c), y(a, !0), S(a, "toggleTrackChanges", !0)) : k(a);
681
+ });
682
+ });
683
+ const t = (r) => {
684
+ const o = ne(r);
685
+ return o ? (h = o, o) : null;
686
+ }, n = (r) => {
687
+ const o = t(r);
688
+ if (!o) return null;
689
+ const a = R(o, e);
690
+ return { editor: o, state: a };
691
+ };
692
+ return {
693
+ name: "trackChanges",
694
+ toolbar: [
695
+ {
696
+ label: "Track Changes",
697
+ command: "toggleTrackChanges",
698
+ type: "group",
699
+ items: [
700
+ {
701
+ label: "Track Changes",
702
+ command: "toggleTrackChanges",
703
+ icon: '<svg width="24" height="24" focusable="false"><path d="M4 6h10a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h7a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h8a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm13.3-3.6 1.3 1.3 2.9-2.9a1 1 0 1 1 1.4 1.4l-3.6 3.6a1 1 0 0 1-1.4 0l-2-2a1 1 0 1 1 1.4-1.4Z"></path></svg>',
704
+ shortcut: "Mod-Shift-t"
705
+ },
706
+ {
707
+ label: "Accept All Changes",
708
+ command: "acceptAllTrackChanges",
709
+ icon: '<svg width="24" height="24" focusable="false"><path d="M9.2 16.2 5.8 12.8a1 1 0 1 1 1.4-1.4l2.1 2.1 7.5-7.5a1 1 0 1 1 1.4 1.4l-8.2 8.2a1 1 0 0 1-1.4 0Z"></path></svg>'
710
+ },
711
+ {
712
+ label: "Reject All Changes",
713
+ command: "rejectAllTrackChanges",
714
+ icon: '<svg width="24" height="24" focusable="false"><path d="M7.8 7.8a1 1 0 0 1 1.4 0L12 10.6l2.8-2.8a1 1 0 1 1 1.4 1.4L13.4 12l2.8 2.8a1 1 0 1 1-1.4 1.4L12 13.4l-2.8 2.8a1 1 0 1 1-1.4-1.4l2.8-2.8-2.8-2.8a1 1 0 0 1 0-1.4Z"></path></svg>'
715
+ }
716
+ ]
717
+ }
718
+ ],
719
+ commands: {
720
+ toggleTrackChanges: (r, o) => {
721
+ const a = n(o);
722
+ if (!a) return !1;
723
+ const { editor: c, state: s } = a;
724
+ return s.enabled = !s.enabled, s.enabled ? M(c, s) : (X(c), k(c), V(c)), y(c, s.enabled), S(c, "toggleTrackChanges", s.enabled), c.dispatchEvent(new CustomEvent("editora:track-changes-toggle", {
725
+ bubbles: !0,
726
+ detail: {
727
+ enabled: s.enabled,
728
+ author: s.author
729
+ }
730
+ })), s.enabled;
731
+ },
732
+ acceptAllTrackChanges: (r, o) => {
733
+ const a = n(o);
734
+ return a ? A(a.editor, "accept", "all") : !1;
735
+ },
736
+ rejectAllTrackChanges: (r, o) => {
737
+ const a = n(o);
738
+ return a ? A(a.editor, "reject", "all") : !1;
739
+ },
740
+ acceptSelectedTrackChanges: (r, o) => {
741
+ const a = n(o);
742
+ return a ? A(a.editor, "accept", "selection") : !1;
743
+ },
744
+ rejectSelectedTrackChanges: (r, o) => {
745
+ const a = n(o);
746
+ return a ? A(a.editor, "reject", "selection") : !1;
747
+ }
748
+ },
749
+ keymap: {
750
+ "Mod-Shift-t": "toggleTrackChanges",
751
+ "Mod-Shift-T": "toggleTrackChanges"
752
+ },
753
+ destroy: () => {
754
+ Array.from(D).forEach((r) => X(r));
755
+ }
756
+ };
757
+ };
758
+ export {
759
+ De as TrackChangesPlugin
760
+ };
761
+ //# sourceMappingURL=TrackChangesPlugin.native-Bghu2q4a.mjs.map