@editora/core 1.0.7 → 1.0.9

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 (87) hide show
  1. package/README.md +5 -0
  2. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-58d12bed.mjs} +23 -12
  3. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-289a112a.mjs} +112 -102
  4. package/dist/ApprovalWorkflowPlugin.native-449ce66c.mjs +1115 -0
  5. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-8aceb5cc.mjs} +16 -9
  6. package/dist/{BlockquotePlugin.native-JFmOLsxN.mjs → BlockquotePlugin.native-3541c714.mjs} +3 -2
  7. package/dist/BlocksLibraryPlugin.native-1cc51e63.mjs +1386 -0
  8. package/dist/{BoldPlugin.native-BAzzoqU5.mjs → BoldPlugin.native-f9d7f8e4.mjs} +1 -1
  9. package/dist/{CapitalizationPlugin.native-DOMsh5R7.mjs → CapitalizationPlugin.native-42c135dc.mjs} +3 -2
  10. package/dist/{ChecklistPlugin.native-nuSSEFNI.mjs → ChecklistPlugin.native-3b397ee9.mjs} +43 -22
  11. package/dist/CitationsPlugin.native-169fb1e8.mjs +1532 -0
  12. package/dist/{ClearFormattingPlugin.native-Bq_XcTh2.mjs → ClearFormattingPlugin.native-77baa514.mjs} +11 -6
  13. package/dist/{CodePlugin.native-DlpTPdkd.mjs → CodePlugin.native-989cf0aa.mjs} +629 -580
  14. package/dist/{CodeSamplePlugin.native-CgGoH-X4.mjs → CodeSamplePlugin.native-6cc0148e.mjs} +19 -10
  15. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-03659874.mjs} +55 -28
  16. package/dist/ConditionalContentPlugin.native-4983143a.mjs +1424 -0
  17. package/dist/ContentRulesPlugin.native-63ed405b.mjs +1149 -0
  18. package/dist/DataBindingPlugin.native-427e9d75.mjs +956 -0
  19. package/dist/{DirectionPlugin.native-CDnbdNyl.mjs → DirectionPlugin.native-4e742f42.mjs} +19 -10
  20. package/dist/DocSchemaPlugin.native-8e41eda0.mjs +1382 -0
  21. package/dist/{DocumentManagerPlugin.native-C2cs_1w4.mjs → DocumentManagerPlugin.native-e69895ad.mjs} +4 -4
  22. package/dist/{EmbedIframePlugin.native-DKJx2OS7.mjs → EmbedIframePlugin.native-55209c87.mjs} +70 -70
  23. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-65c5ac47.mjs} +11 -6
  24. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-f9bc255a.mjs} +7 -4
  25. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-f5647872.mjs} +19 -10
  26. package/dist/{FootnotePlugin.native-D730OGRm.mjs → FootnotePlugin.native-494657b3.mjs} +77 -39
  27. package/dist/{FullscreenPlugin.native-ChXyxeNw.mjs → FullscreenPlugin.native-87ce92e9.mjs} +1 -1
  28. package/dist/{HeadingPlugin.native-DrLYwQnQ.mjs → HeadingPlugin.native-e38c4a16.mjs} +1 -1
  29. package/dist/{HistoryPlugin.native-TDnVMsEO.mjs → HistoryPlugin.native-92ed4be4.mjs} +43 -22
  30. package/dist/{IndentPlugin.native-BHixp8sP.mjs → IndentPlugin.native-e4ee902b.mjs} +23 -12
  31. package/dist/{ItalicPlugin.native-CQjjDyUL.mjs → ItalicPlugin.native-7c95cfbc.mjs} +1 -1
  32. package/dist/{LineHeightPlugin.native-CM7iXdQj.mjs → LineHeightPlugin.native-5668f78c.mjs} +19 -10
  33. package/dist/{LinkPlugin.native-DYCIcdTm.mjs → LinkPlugin.native-6df29111.mjs} +9 -5
  34. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-fe2e115a.mjs} +9 -5
  35. package/dist/{MathPlugin.native-f_mDp8VL.mjs → MathPlugin.native-735bbac2.mjs} +9 -5
  36. package/dist/{MediaManagerPlugin.native-BiXiK8FC.mjs → MediaManagerPlugin.native-3cf48a00.mjs} +219 -207
  37. package/dist/MentionPlugin.native-3b1e8c05.mjs +778 -0
  38. package/dist/{MergeTagPlugin.native-C3eOfEgw.mjs → MergeTagPlugin.native-31cf7d48.mjs} +51 -26
  39. package/dist/PIIRedactionPlugin.native-7ab10b9f.mjs +1449 -0
  40. package/dist/{PageBreakPlugin.native-CXdX5fAv.mjs → PageBreakPlugin.native-1794c5fb.mjs} +67 -52
  41. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-f7b67cc0.mjs} +38 -33
  42. package/dist/{PrintPlugin.native-7qt5v7L5.mjs → PrintPlugin.native-f6a168c2.mjs} +5 -3
  43. package/dist/SlashCommandsPlugin.native-8d45e511.mjs +790 -0
  44. package/dist/SmartPastePlugin.native-a6c5efec.mjs +1447 -0
  45. package/dist/{SpecialCharactersPlugin.native-CZDato89.mjs → SpecialCharactersPlugin.native-7f06d4ba.mjs} +17 -9
  46. package/dist/{SpellCheckPlugin.native-BZB9AewP.mjs → SpellCheckPlugin.native-04e20834.mjs} +41 -21
  47. package/dist/{StrikethroughPlugin.native-0Be7j49s.mjs → StrikethroughPlugin.native-905e9501.mjs} +9 -5
  48. package/dist/{TablePlugin.native-DrHX-efe.mjs → TablePlugin.native-7d5458c1.mjs} +58 -30
  49. package/dist/{TemplatePlugin.native-CrpfKRJ8.mjs → TemplatePlugin.native-580f0f63.mjs} +32 -17
  50. package/dist/{TextAlignmentPlugin.native-sM_1s00t.mjs → TextAlignmentPlugin.native-9357b3ed.mjs} +11 -6
  51. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-d53ed459.mjs} +26 -14
  52. package/dist/TrackChangesPlugin.native-e96da509.mjs +818 -0
  53. package/dist/TranslationWorkflowPlugin.native-4e711b1e.mjs +1797 -0
  54. package/dist/{UnderlinePlugin.native-QpIcK4L2.mjs → UnderlinePlugin.native-8080c998.mjs} +1 -1
  55. package/dist/VersionDiffPlugin.native-5bbeff85.mjs +801 -0
  56. package/dist/_commonjsHelpers-69d58be2.mjs +31 -0
  57. package/dist/{anchoredPopover-Bxds0VoB.mjs → anchoredPopover-5cca53ba.mjs} +1 -1
  58. package/dist/documentManager-8327fb6e.mjs +9166 -0
  59. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +3 -2
  60. package/dist/editora.min.js +14 -13
  61. package/dist/editora.umd.js +14 -13
  62. package/dist/{html2canvas.esm-AYkPY5LS.mjs → html2canvas.esm-c51cb3b9.mjs} +978 -894
  63. package/dist/index-072ef022.js +11 -0
  64. package/dist/index-49d31221.mjs +16860 -0
  65. package/dist/{index-yzU4NdPT.mjs → index-7da30697.mjs} +490 -358
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-b47a189f.mjs +5782 -0
  68. package/dist/index.esm.js +12 -7
  69. package/dist/{jspdf.es.min-BJGtOnRT.mjs → jspdf.es.min-780c82db.mjs} +4808 -3784
  70. package/dist/plugin-loader.js +77 -40
  71. package/dist/{purify.es-CKpwg8Tk.mjs → purify.es-3bdbcfc5.mjs} +20 -10
  72. package/dist/style.css +1 -0
  73. package/dist/webcomponent-core.js +546 -414
  74. package/dist/webcomponent-core.min.css +1 -1
  75. package/dist/webcomponent-core.min.js +40 -39
  76. package/dist/webcomponent.cjs.js +1 -1
  77. package/dist/webcomponent.esm.js +1 -1
  78. package/dist/webcomponent.js +484 -315
  79. package/dist/webcomponent.min.css +1 -1
  80. package/dist/webcomponent.min.js +6035 -558
  81. package/package.json +11 -5
  82. package/dist/_commonjsHelpers-DOllISpa.mjs +0 -32
  83. package/dist/core.css +0 -1
  84. package/dist/documentManager-vQ1VkbUY.mjs +0 -8418
  85. package/dist/index-BpE6GFbz.js +0 -10
  86. package/dist/index-BslAFzmv.mjs +0 -16544
  87. package/dist/index.es-BYD2KEo6.mjs +0 -6666
@@ -0,0 +1,818 @@
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)
20
+ return null;
21
+ const t = e.querySelector('[contenteditable="true"]');
22
+ return t instanceof HTMLElement ? t : null;
23
+ }
24
+ function te() {
25
+ if (typeof window == "undefined")
26
+ return null;
27
+ const e = window[_];
28
+ if (!(e instanceof HTMLElement))
29
+ return null;
30
+ window[_] = null;
31
+ 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);
32
+ if (t) {
33
+ const r = ee(t);
34
+ if (r)
35
+ return r;
36
+ if (t.getAttribute("contenteditable") === "true")
37
+ return t;
38
+ }
39
+ if (e.getAttribute("contenteditable") === "true")
40
+ return e;
41
+ const n = e.closest('[contenteditable="true"]');
42
+ return n instanceof HTMLElement ? n : null;
43
+ }
44
+ function ne(e) {
45
+ if ((e == null ? void 0 : e.contentElement) instanceof HTMLElement)
46
+ return e.contentElement;
47
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
48
+ const o = e.editorElement;
49
+ if (o.getAttribute("contenteditable") === "true")
50
+ return o;
51
+ const a = o.querySelector('[contenteditable="true"]');
52
+ if (a instanceof HTMLElement)
53
+ return a;
54
+ }
55
+ const t = te();
56
+ if (t && document.contains(t))
57
+ return t;
58
+ const n = window.getSelection();
59
+ if (n && n.rangeCount > 0) {
60
+ const o = n.getRangeAt(0).startContainer, a = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement, c = a == null ? void 0 : a.closest(p);
61
+ if (c)
62
+ return c;
63
+ }
64
+ const r = document.activeElement;
65
+ if (r) {
66
+ if (r.matches(p))
67
+ return r;
68
+ const o = r.closest(p);
69
+ if (o)
70
+ return o;
71
+ }
72
+ return h != null && h.isConnected ? h : document.querySelector(p);
73
+ }
74
+ function R(e, t) {
75
+ var r;
76
+ k(e), H(e);
77
+ let n = B.get(e);
78
+ return n || (n = {
79
+ enabled: !!t.enabledByDefault,
80
+ author: ((r = t.author) == null ? void 0 : r.trim()) || "system",
81
+ includeTimestamp: t.includeTimestamp !== !1
82
+ }, B.set(e, n), n.enabled && (M(e, n), y(e, n.enabled))), S(e, "toggleTrackChanges", n.enabled), n;
83
+ }
84
+ function y(e, t) {
85
+ e.classList.toggle("rte-track-changes-enabled", t), t ? e.setAttribute("data-track-changes", "true") : e.removeAttribute("data-track-changes");
86
+ }
87
+ function re(e) {
88
+ return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
89
+ }
90
+ function S(e, t, n) {
91
+ const r = re(e);
92
+ Array.from(
93
+ r.querySelectorAll(
94
+ `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
95
+ )
96
+ ).forEach((a) => {
97
+ 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)");
98
+ });
99
+ }
100
+ function ae(e) {
101
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
102
+ }
103
+ function oe(e, t) {
104
+ if (t === e.innerHTML)
105
+ return;
106
+ const n = window.execEditorCommand || window.executeEditorCommand;
107
+ if (typeof n == "function")
108
+ try {
109
+ n("recordDomTransaction", e, t, e.innerHTML);
110
+ } catch (r) {
111
+ }
112
+ }
113
+ function m(e, t) {
114
+ ae(e), oe(e, t);
115
+ }
116
+ function ce(e, t) {
117
+ return e.startContainer === t.startContainer && e.startOffset === t.startOffset && e.endContainer === t.endContainer && e.endOffset === t.endOffset;
118
+ }
119
+ function G(e) {
120
+ return {
121
+ author: e.author,
122
+ timestamp: e.includeTimestamp ? (/* @__PURE__ */ new Date()).toISOString() : ""
123
+ };
124
+ }
125
+ function se(e, t) {
126
+ const n = document.createElement("span");
127
+ n.className = "rte-track-insert", n.setAttribute("data-track-change", "insert"), n.setAttribute("contenteditable", "false");
128
+ const r = G(t);
129
+ return n.setAttribute("data-track-author", r.author), r.timestamp && n.setAttribute("data-track-time", r.timestamp), n.appendChild(document.createTextNode(e)), n;
130
+ }
131
+ function k(e) {
132
+ Array.from(e.querySelectorAll(g)).forEach((n) => {
133
+ n.setAttribute("contenteditable", "false");
134
+ });
135
+ }
136
+ function E(e) {
137
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
138
+ }
139
+ function le(e, t) {
140
+ const n = e.startContainer, r = e.startOffset;
141
+ if (n.nodeType === Node.TEXT_NODE) {
142
+ const o = n, a = o.previousSibling || o.nextSibling;
143
+ if (a instanceof HTMLElement && a.matches(g) && t.contains(a))
144
+ return a;
145
+ }
146
+ if (n.nodeType === Node.ELEMENT_NODE) {
147
+ const o = n, a = o.childNodes[r - 1];
148
+ if (a instanceof HTMLElement && a.matches(g) && t.contains(a))
149
+ return a;
150
+ const c = o.childNodes[r];
151
+ if (c instanceof HTMLElement && c.matches(g) && t.contains(c))
152
+ return c;
153
+ }
154
+ return null;
155
+ }
156
+ function P(e, t, n) {
157
+ const r = t.lastChild;
158
+ r && r.nodeType === Node.TEXT_NODE ? r.data += n : t.appendChild(document.createTextNode(n)), C(e, t);
159
+ }
160
+ function ie(e, t) {
161
+ const n = document.createElement("span");
162
+ n.className = "rte-track-delete", n.setAttribute("data-track-change", "delete"), n.setAttribute("contenteditable", "false");
163
+ const r = G(t);
164
+ return n.setAttribute("data-track-author", r.author), r.timestamp && n.setAttribute("data-track-time", r.timestamp), n.appendChild(e), n;
165
+ }
166
+ function b(e) {
167
+ const t = window.getSelection();
168
+ if (!t || t.rangeCount === 0)
169
+ return null;
170
+ const n = t.getRangeAt(0);
171
+ return e.contains(n.commonAncestorContainer) ? n : null;
172
+ }
173
+ function ue() {
174
+ j || typeof document == "undefined" || (j = !0, document.addEventListener(
175
+ "selectionchange",
176
+ () => {
177
+ const e = window.getSelection();
178
+ if (!e || e.rangeCount === 0)
179
+ return;
180
+ const t = e.getRangeAt(0), n = E(t.startContainer), r = (n == null ? void 0 : n.closest(p)) || null;
181
+ r && (L.set(r, t.cloneRange()), h = r);
182
+ },
183
+ !0
184
+ ));
185
+ }
186
+ function C(e, t) {
187
+ if (!t.parentNode) {
188
+ e.focus({ preventScroll: !0 });
189
+ return;
190
+ }
191
+ const n = window.getSelection();
192
+ if (!n)
193
+ return;
194
+ const r = document.createRange();
195
+ r.setStartAfter(t), r.collapse(!0), n.removeAllRanges(), n.addRange(r), e.focus({ preventScroll: !0 });
196
+ }
197
+ function O(e, t) {
198
+ if (!t.parentNode) {
199
+ e.focus({ preventScroll: !0 });
200
+ return;
201
+ }
202
+ const n = window.getSelection();
203
+ if (!n)
204
+ return;
205
+ const r = document.createRange();
206
+ r.setStartBefore(t), r.collapse(!0), n.removeAllRanges(), n.addRange(r), e.focus({ preventScroll: !0 });
207
+ }
208
+ function de(e, t, n) {
209
+ const r = window.getSelection();
210
+ if (!r)
211
+ return;
212
+ const o = document.createRange();
213
+ o.setStart(t, Math.max(0, n)), o.collapse(!0), r.removeAllRanges(), r.addRange(o), e.focus({ preventScroll: !0 });
214
+ }
215
+ function V(e) {
216
+ let t = b(e);
217
+ if (!t) {
218
+ const c = L.get(e);
219
+ c && e.contains(c.commonAncestorContainer) && (t = c.cloneRange());
220
+ }
221
+ if (!t || !t.collapsed)
222
+ return;
223
+ const n = E(t.startContainer);
224
+ if (!n)
225
+ return;
226
+ const r = n.closest(g);
227
+ if (!r || !e.contains(r) || !r.parentNode)
228
+ return;
229
+ const o = window.getSelection();
230
+ if (!o)
231
+ return;
232
+ const a = document.createRange();
233
+ a.setStartAfter(r), a.collapse(!0), o.removeAllRanges(), o.addRange(a), e.focus({ preventScroll: !0 });
234
+ }
235
+ function K(e, t) {
236
+ const n = e.innerHTML;
237
+ k(e), V(e), e.focus({ preventScroll: !0 });
238
+ const r = t === "insertLineBreak" ? "insertLineBreak" : "insertParagraph", o = document.execCommand(r, !1);
239
+ return k(e), m(e, n), o !== !1;
240
+ }
241
+ function fe(e) {
242
+ const t = b(e);
243
+ if (t && t.collapsed)
244
+ return t;
245
+ const n = L.get(e);
246
+ return n && n.collapsed && e.contains(n.commonAncestorContainer) ? n.cloneRange() : null;
247
+ }
248
+ function ge(e) {
249
+ return e.matches(g) || e.matches(f) ? (e.textContent || "").replace(/\u200B/g, "").trim().length > 0 : Q.has(e.tagName);
250
+ }
251
+ function W(e, t) {
252
+ if (t !== "insertParagraph")
253
+ return !1;
254
+ const n = fe(e);
255
+ if (!n)
256
+ return !1;
257
+ const r = E(n.startContainer);
258
+ if (!r)
259
+ return !1;
260
+ const o = r.closest("li");
261
+ return !(o instanceof HTMLElement) || !e.contains(o) || (o.textContent || "").replace(/\u200B/g, "").trim().length > 0 ? !1 : !Array.from(o.querySelectorAll("*")).some(
262
+ (s) => ge(s)
263
+ );
264
+ }
265
+ function he(e) {
266
+ const t = document.createRange(), n = window.getSelection();
267
+ if (n && n.rangeCount > 0) {
268
+ const r = n.getRangeAt(0);
269
+ if (e.contains(r.commonAncestorContainer))
270
+ return t.setStart(r.endContainer, r.endOffset), t.collapse(!0), t;
271
+ }
272
+ return t.selectNodeContents(e), t.collapse(!1), t;
273
+ }
274
+ function me(e) {
275
+ return (e.textContent || "").length > 0 ? !0 : Array.from(e.childNodes).some((n) => {
276
+ if (n.nodeType !== Node.ELEMENT_NODE)
277
+ return !1;
278
+ const r = n;
279
+ return ["BR", "IMG", "TABLE", "VIDEO", "AUDIO", "SVG", "MATH"].includes(r.tagName);
280
+ });
281
+ }
282
+ function pe(e) {
283
+ return Array.from(e.childNodes).some((t) => {
284
+ if (t.nodeType === Node.TEXT_NODE)
285
+ return (t.textContent || "").length > 0;
286
+ if (t.nodeType !== Node.ELEMENT_NODE)
287
+ return !1;
288
+ const n = t;
289
+ return ["BR", "IMG", "TABLE", "VIDEO", "AUDIO", "SVG", "MATH"].includes(n.tagName);
290
+ });
291
+ }
292
+ function Ee(e, t, n) {
293
+ if (!e.collapsed)
294
+ return null;
295
+ const r = e.startContainer, o = e.startOffset;
296
+ let a = null;
297
+ if (r.nodeType === Node.TEXT_NODE) {
298
+ const c = r;
299
+ t === "backward" && o === 0 ? a = c.previousSibling : t === "forward" && o === c.length && (a = c.nextSibling);
300
+ } else if (r.nodeType === Node.ELEMENT_NODE) {
301
+ const c = r;
302
+ t === "backward" && o > 0 ? a = c.childNodes[o - 1] || null : t === "forward" && o < c.childNodes.length && (a = c.childNodes[o] || null);
303
+ }
304
+ return !(a instanceof HTMLElement) || !a.matches(g) || !n.contains(a) ? null : a;
305
+ }
306
+ function ke(e, t) {
307
+ const n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = [];
308
+ let o = n.nextNode();
309
+ for (; o; ) {
310
+ const a = o;
311
+ a.data.length > 0 && r.push(a), o = n.nextNode();
312
+ }
313
+ return r.length === 0 ? null : t ? r[r.length - 1] : r[0];
314
+ }
315
+ function Te(e, t, n) {
316
+ const r = Ee(t, n, e);
317
+ return r ? x(e, r, n) : !1;
318
+ }
319
+ function x(e, t, n) {
320
+ const r = t.parentNode;
321
+ if (!r)
322
+ return !1;
323
+ const o = Array.prototype.indexOf.call(r.childNodes, t), a = ke(t, n === "backward");
324
+ 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;
325
+ }
326
+ function Z(e) {
327
+ if (e.startContainer !== e.endContainer || e.startContainer.nodeType !== Node.ELEMENT_NODE)
328
+ return null;
329
+ const t = e.startContainer;
330
+ return e.endOffset - e.startOffset !== 1 ? null : t.childNodes[e.startOffset] || null;
331
+ }
332
+ function I(e, t) {
333
+ const n = Z(e);
334
+ return !(n instanceof HTMLElement) || !n.matches(f) || !t.contains(n) ? null : n;
335
+ }
336
+ function be(e, t) {
337
+ const n = Z(e);
338
+ return !(n instanceof HTMLElement) || !n.matches(g) || !t.contains(n) ? null : n;
339
+ }
340
+ function Ce(e, t) {
341
+ var a, c;
342
+ if (t.collapsed) {
343
+ const s = E(t.startContainer), l = s == null ? void 0 : s.closest(f);
344
+ if (l && e.contains(l)) {
345
+ const i = document.createRange();
346
+ return i.setStartAfter(l), i.collapse(!0), i;
347
+ }
348
+ return t;
349
+ }
350
+ const n = I(t, e);
351
+ if (n) {
352
+ const s = document.createRange();
353
+ return s.setStartAfter(n), s.collapse(!0), s;
354
+ }
355
+ const r = (a = E(t.startContainer)) == null ? void 0 : a.closest(f), o = (c = E(t.endContainer)) == null ? void 0 : c.closest(f);
356
+ if (r && o && r === o && e.contains(r)) {
357
+ const s = document.createRange();
358
+ return s.setStartAfter(r), s.collapse(!0), s;
359
+ }
360
+ return t;
361
+ }
362
+ function Ae(e, t) {
363
+ const r = Array.from(t.querySelectorAll(g)).filter((s) => {
364
+ try {
365
+ return e.intersectsNode(s);
366
+ } catch (l) {
367
+ return !1;
368
+ }
369
+ });
370
+ if (r.length !== 1)
371
+ return null;
372
+ const o = r[0], a = (e.toString() || "").replace(/\s+/g, ""), c = (o.textContent || "").replace(/\s+/g, "");
373
+ return !c || a !== c ? null : o;
374
+ }
375
+ function U(e, t, n) {
376
+ if (t.collapsed)
377
+ return null;
378
+ const r = t.cloneContents();
379
+ if (!me(r))
380
+ return null;
381
+ const o = ie(r, n);
382
+ return t.deleteContents(), t.insertNode(o), C(e, o), o;
383
+ }
384
+ function Ne(e, t, n) {
385
+ if (!t.collapsed)
386
+ return t;
387
+ const r = t.startContainer, o = t.startOffset;
388
+ if (r.nodeType === Node.TEXT_NODE) {
389
+ const s = r;
390
+ if (n === "backward" && o > 0) {
391
+ const l = t.cloneRange();
392
+ return l.setStart(s, o - 1), l;
393
+ }
394
+ if (n === "forward" && o < s.length) {
395
+ const l = t.cloneRange();
396
+ return l.setEnd(s, o + 1), l;
397
+ }
398
+ }
399
+ if (r.nodeType === Node.ELEMENT_NODE) {
400
+ const s = r;
401
+ if (n === "backward" && o > 0)
402
+ for (let l = o - 1; l >= 0; l -= 1) {
403
+ const i = s.childNodes[l];
404
+ if (!i || i instanceof HTMLElement && i.matches(f))
405
+ continue;
406
+ const u = t.cloneRange();
407
+ if (i.nodeType === Node.TEXT_NODE) {
408
+ const d = i;
409
+ if (d.length === 0)
410
+ continue;
411
+ u.setStart(d, d.length - 1), u.setEnd(d, d.length);
412
+ } else
413
+ u.setStartBefore(i), u.setEndAfter(i);
414
+ return u;
415
+ }
416
+ if (n === "forward" && o < s.childNodes.length)
417
+ for (let l = o; l < s.childNodes.length; l += 1) {
418
+ const i = s.childNodes[l];
419
+ if (!i || i instanceof HTMLElement && i.matches(f))
420
+ continue;
421
+ const u = t.cloneRange();
422
+ if (i.nodeType === Node.TEXT_NODE) {
423
+ const d = i;
424
+ if (d.length === 0)
425
+ continue;
426
+ u.setStart(d, 0), u.setEnd(d, 1);
427
+ } else
428
+ u.setStartBefore(i), u.setEndAfter(i);
429
+ return u;
430
+ }
431
+ }
432
+ const a = window.getSelection();
433
+ if (!a || typeof a.modify != "function")
434
+ return null;
435
+ const c = t.cloneRange();
436
+ a.removeAllRanges(), a.addRange(c);
437
+ try {
438
+ if (a.modify("extend", n, "character"), a.rangeCount === 0)
439
+ return null;
440
+ const s = a.getRangeAt(0).cloneRange();
441
+ if (s.collapsed || !e.contains(s.commonAncestorContainer))
442
+ return null;
443
+ const l = I(s, e);
444
+ return l ? (n === "backward" ? O(e, l) : C(e, l), null) : s;
445
+ } catch (s) {
446
+ return null;
447
+ } finally {
448
+ a.removeAllRanges(), a.addRange(c);
449
+ }
450
+ }
451
+ function z(e, t, n) {
452
+ let r = b(e);
453
+ if (!r)
454
+ return !1;
455
+ const o = Ce(e, r.cloneRange());
456
+ if (!ce(o, r)) {
457
+ const d = window.getSelection();
458
+ d && (d.removeAllRanges(), d.addRange(o)), r = o;
459
+ }
460
+ const a = e.innerHTML;
461
+ r.collapsed || U(e, r.cloneRange(), t);
462
+ const c = E(r.startContainer), s = c == null ? void 0 : c.closest(g);
463
+ if (r.collapsed && s && e.contains(s))
464
+ return P(e, s, n), m(e, a), !0;
465
+ const l = r.collapsed ? le(r, e) : null;
466
+ if (l)
467
+ return P(e, l, n), m(e, a), !0;
468
+ const i = he(e), u = se(n, t);
469
+ return i.insertNode(u), C(e, u), m(e, a), !0;
470
+ }
471
+ function $(e, t, n) {
472
+ const r = b(e);
473
+ if (!r)
474
+ return !1;
475
+ const o = n.includes("Backward") ? "backward" : "forward", a = e.innerHTML;
476
+ if (r.collapsed && Te(e, r.cloneRange(), o))
477
+ return m(e, a), !0;
478
+ const c = be(r, e);
479
+ if (c && x(e, c, o))
480
+ return m(e, a), !0;
481
+ if (!r.collapsed) {
482
+ const u = Ae(r, e);
483
+ if (u && x(e, u, o))
484
+ return m(e, a), !0;
485
+ }
486
+ const s = r.collapsed ? Ne(e, r.cloneRange(), o) : r.cloneRange();
487
+ if (!s)
488
+ return !1;
489
+ const l = I(s, e);
490
+ return l ? (o === "backward" ? O(e, l) : C(e, l), !0) : U(e, s, t) ? (H(e), m(e, a), !0) : !1;
491
+ }
492
+ function v(e) {
493
+ const t = e.parentNode;
494
+ if (t) {
495
+ for (; e.firstChild; )
496
+ t.insertBefore(e.firstChild, e);
497
+ t.removeChild(e);
498
+ }
499
+ }
500
+ function H(e) {
501
+ Array.from(e.querySelectorAll(f)).forEach((r) => {
502
+ r.setAttribute("contenteditable", "false"), Array.from(r.querySelectorAll(f)).forEach((a) => {
503
+ a !== r && v(a);
504
+ });
505
+ });
506
+ let n = !0;
507
+ for (; n; )
508
+ n = !1, Array.from(e.querySelectorAll(f)).forEach((o) => {
509
+ if (!o.isConnected)
510
+ return;
511
+ let a = o.nextSibling;
512
+ for (; a && a.nodeType === Node.TEXT_NODE && !(a.textContent || "").trim(); )
513
+ a = a.nextSibling;
514
+ if (a instanceof HTMLElement && a.matches(f)) {
515
+ for (; a.firstChild; )
516
+ o.appendChild(a.firstChild);
517
+ a.remove(), n = !0;
518
+ }
519
+ o.firstChild || (o.remove(), n = !0);
520
+ });
521
+ }
522
+ function Y(e) {
523
+ return Array.from(e.querySelectorAll(w));
524
+ }
525
+ function ye(e) {
526
+ const t = b(e);
527
+ if (!t)
528
+ return [];
529
+ 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);
530
+ a && e.contains(a) && n.add(a);
531
+ const c = o == null ? void 0 : o.closest(w);
532
+ return c && e.contains(c) && n.add(c), Y(e).filter((l) => {
533
+ try {
534
+ return t.intersectsNode(l);
535
+ } catch (i) {
536
+ return !1;
537
+ }
538
+ }).forEach((l) => n.add(l)), Array.from(n);
539
+ }
540
+ function A(e, t, n) {
541
+ const r = n === "all" ? Y(e) : ye(e);
542
+ if (r.length === 0)
543
+ return !1;
544
+ const o = e.innerHTML;
545
+ return r.forEach((a) => {
546
+ if (!a.isConnected)
547
+ return;
548
+ const c = a.matches(g), s = a.matches(f);
549
+ if (!(!c && !s)) {
550
+ if (t === "accept") {
551
+ c ? v(a) : a.remove();
552
+ return;
553
+ }
554
+ c ? a.remove() : (a.removeAttribute("contenteditable"), v(a));
555
+ }
556
+ }), H(e), m(e, o), !0;
557
+ }
558
+ function Se(e) {
559
+ if (!(e instanceof Node))
560
+ return null;
561
+ const t = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
562
+ return (t == null ? void 0 : t.closest(p)) || null;
563
+ }
564
+ function Me() {
565
+ F || typeof document == "undefined" || (F = !0, document.addEventListener(
566
+ "focusin",
567
+ (e) => {
568
+ if (!T.enabledByDefault)
569
+ return;
570
+ const t = Se(e.target);
571
+ if (!t)
572
+ return;
573
+ h = t;
574
+ const n = R(t, T);
575
+ n.enabled ? (M(t, n), y(t, !0), S(t, "toggleTrackChanges", !0)) : k(t);
576
+ },
577
+ !0
578
+ ));
579
+ }
580
+ function we(e, t) {
581
+ return (n) => {
582
+ if (!t.enabled || e.getAttribute("data-track-changes") !== "true")
583
+ return;
584
+ h = e;
585
+ const r = n.inputType || "";
586
+ if (r === "insertParagraph" || r === "insertLineBreak") {
587
+ if (W(e, r))
588
+ return;
589
+ n.preventDefault(), K(e, r);
590
+ return;
591
+ }
592
+ if (r.startsWith("delete")) {
593
+ n.preventDefault(), $(e, t, r);
594
+ return;
595
+ }
596
+ if (r === "insertText" || r === "insertCompositionText") {
597
+ const o = n.data || "";
598
+ if (!o)
599
+ return;
600
+ n.preventDefault(), z(e, t, o);
601
+ }
602
+ };
603
+ }
604
+ function Re(e, t) {
605
+ return (n) => {
606
+ if (!t.enabled || e.getAttribute("data-track-changes") !== "true" || n.key !== "Enter" || J)
607
+ return;
608
+ const r = n.shiftKey ? "insertLineBreak" : "insertParagraph";
609
+ W(e, r) || (h = e, n.preventDefault(), n.stopPropagation(), K(e, r));
610
+ };
611
+ }
612
+ function xe(e, t) {
613
+ return (n) => {
614
+ var o;
615
+ if (n.__editoraSmartPasteHandled === !0 || n.defaultPrevented || !t.enabled || e.getAttribute("data-track-changes") !== "true")
616
+ return;
617
+ const r = ((o = n.clipboardData) == null ? void 0 : o.getData("text/plain")) || "";
618
+ r && (n.preventDefault(), h = e, z(e, t, r));
619
+ };
620
+ }
621
+ function ve(e, t) {
622
+ return (n) => {
623
+ if (!t.enabled || e.getAttribute("data-track-changes") !== "true")
624
+ return;
625
+ const r = b(e);
626
+ if (!r || r.collapsed)
627
+ return;
628
+ const o = r.toString();
629
+ n.clipboardData && (n.clipboardData.setData("text/plain", o), n.preventDefault()), h = e, $(e, t, "deleteByCut");
630
+ };
631
+ }
632
+ function M(e, t) {
633
+ if (N.has(e))
634
+ return;
635
+ k(e);
636
+ const n = {
637
+ beforeInput: we(e, t),
638
+ keydown: Re(e, t),
639
+ paste: xe(e, t),
640
+ cut: ve(e, t)
641
+ };
642
+ 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);
643
+ }
644
+ function X(e) {
645
+ const t = N.get(e);
646
+ 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));
647
+ }
648
+ function Le() {
649
+ if (q || typeof document == "undefined")
650
+ return;
651
+ q = !0;
652
+ const e = document.createElement("style");
653
+ e.id = "rte-track-changes-styles", e.textContent = `
654
+ .rte-track-insert[data-track-change="insert"] {
655
+ background: rgba(22, 163, 74, 0.2);
656
+ color: inherit;
657
+ text-decoration: underline;
658
+ text-decoration-color: #16a34a;
659
+ text-decoration-thickness: 2px;
660
+ border-radius: 2px;
661
+ padding: 0 1px;
662
+ white-space: pre-wrap;
663
+ }
664
+
665
+ .rte-track-delete[data-track-change="delete"] {
666
+ background: rgba(220, 38, 38, 0.16);
667
+ color: inherit;
668
+ text-decoration: line-through;
669
+ text-decoration-color: #dc2626;
670
+ text-decoration-thickness: 2px;
671
+ border-radius: 2px;
672
+ padding: 0 1px;
673
+ white-space: pre-wrap;
674
+ cursor: pointer;
675
+ }
676
+
677
+ .editora-theme-dark .rte-track-insert[data-track-change="insert"],
678
+ .rte-theme-dark .rte-track-insert[data-track-change="insert"] {
679
+ background: rgba(74, 222, 128, 0.2);
680
+ text-decoration-color: #4ade80;
681
+ }
682
+
683
+ .editora-theme-dark .rte-track-delete[data-track-change="delete"],
684
+ .rte-theme-dark .rte-track-delete[data-track-change="delete"] {
685
+ background: rgba(248, 113, 113, 0.18);
686
+ text-decoration-color: #f87171;
687
+ }
688
+
689
+ .rte-content[data-track-changes="true"],
690
+ .editora-content[data-track-changes="true"] {
691
+ caret-color: currentColor;
692
+ }
693
+
694
+ .rte-toolbar-group-items.track-changes,
695
+ .editora-toolbar-group-items.track-changes {
696
+ display: flex;
697
+ border: 1px solid #ccc;
698
+ border-radius: 3px;
699
+ background: #fff;
700
+ }
701
+ .rte-toolbar-group-items.track-changes .rte-toolbar-button,
702
+ .editora-toolbar-group-items.track-changes .editora-toolbar-button {
703
+ border: none;
704
+ border-radius: 0px;
705
+ }
706
+ .rte-toolbar-group-items.track-changes .rte-toolbar-button,
707
+ .editora-toolbar-group-items.track-changes .editora-toolbar-button {
708
+ border-right: 1px solid #ccc;
709
+ }
710
+ .rte-toolbar-group-items.track-changes .rte-toolbar-item:last-child .rte-toolbar-button,
711
+ .editora-toolbar-group-items.track-changes .editora-toolbar-item:last-child .editora-toolbar-button {
712
+ border-right: none;
713
+ }
714
+
715
+ :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .rte-toolbar-group-items.track-changes,
716
+ :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .editora-toolbar-group-items.track-changes {
717
+ border-color: #566275;
718
+ }
719
+
720
+ :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .rte-toolbar-group-items.track-changes .rte-toolbar-button,
721
+ :is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark) .editora-toolbar-group-items.track-changes .editora-toolbar-button {
722
+ border-right-color: #566275;
723
+ }
724
+
725
+ .rte-toolbar-button[data-command="toggleTrackChanges"].active,
726
+ .editora-toolbar-button[data-command="toggleTrackChanges"].active {
727
+ background-color: #ccc;
728
+ }
729
+ `, document.head.appendChild(e);
730
+ }
731
+ const De = (e = {}) => {
732
+ Le(), ue(), T = { ...T, ...e }, Me(), T.enabledByDefault && typeof document != "undefined" && (typeof requestAnimationFrame == "function" ? requestAnimationFrame : (o) => window.setTimeout(o, 0))(() => {
733
+ Array.from(document.querySelectorAll(p)).forEach((a) => {
734
+ const c = R(a, T);
735
+ c.enabled ? (M(a, c), y(a, !0), S(a, "toggleTrackChanges", !0)) : k(a);
736
+ });
737
+ });
738
+ const t = (r) => {
739
+ const o = ne(r);
740
+ return o ? (h = o, o) : null;
741
+ }, n = (r) => {
742
+ const o = t(r);
743
+ if (!o)
744
+ return null;
745
+ const a = R(o, e);
746
+ return { editor: o, state: a };
747
+ };
748
+ return {
749
+ name: "trackChanges",
750
+ toolbar: [
751
+ {
752
+ label: "Track Changes",
753
+ command: "toggleTrackChanges",
754
+ type: "group",
755
+ items: [
756
+ {
757
+ label: "Track Changes",
758
+ command: "toggleTrackChanges",
759
+ 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>',
760
+ shortcut: "Mod-Shift-t"
761
+ },
762
+ {
763
+ label: "Accept All Changes",
764
+ command: "acceptAllTrackChanges",
765
+ 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>'
766
+ },
767
+ {
768
+ label: "Reject All Changes",
769
+ command: "rejectAllTrackChanges",
770
+ 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>'
771
+ }
772
+ ]
773
+ }
774
+ ],
775
+ commands: {
776
+ toggleTrackChanges: (r, o) => {
777
+ const a = n(o);
778
+ if (!a)
779
+ return !1;
780
+ const { editor: c, state: s } = a;
781
+ 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", {
782
+ bubbles: !0,
783
+ detail: {
784
+ enabled: s.enabled,
785
+ author: s.author
786
+ }
787
+ })), s.enabled;
788
+ },
789
+ acceptAllTrackChanges: (r, o) => {
790
+ const a = n(o);
791
+ return a ? A(a.editor, "accept", "all") : !1;
792
+ },
793
+ rejectAllTrackChanges: (r, o) => {
794
+ const a = n(o);
795
+ return a ? A(a.editor, "reject", "all") : !1;
796
+ },
797
+ acceptSelectedTrackChanges: (r, o) => {
798
+ const a = n(o);
799
+ return a ? A(a.editor, "accept", "selection") : !1;
800
+ },
801
+ rejectSelectedTrackChanges: (r, o) => {
802
+ const a = n(o);
803
+ return a ? A(a.editor, "reject", "selection") : !1;
804
+ }
805
+ },
806
+ keymap: {
807
+ "Mod-Shift-t": "toggleTrackChanges",
808
+ "Mod-Shift-T": "toggleTrackChanges"
809
+ },
810
+ destroy: () => {
811
+ Array.from(D).forEach((r) => X(r));
812
+ }
813
+ };
814
+ };
815
+ export {
816
+ De as TrackChangesPlugin
817
+ };
818
+ //# sourceMappingURL=TrackChangesPlugin.native-e96da509.mjs.map