@editora/core 1.0.6 → 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 (60) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
  3. package/dist/ApprovalWorkflowPlugin.native-C3jtAYjG.mjs +1076 -0
  4. package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
  5. package/dist/BlocksLibraryPlugin.native-HMWKxWNs.mjs +1327 -0
  6. package/dist/CitationsPlugin.native-BnU0qCwR.mjs +1464 -0
  7. package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
  8. package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
  9. package/dist/ConditionalContentPlugin.native-CfhY46rU.mjs +1367 -0
  10. package/dist/ContentRulesPlugin.native-nBLQ8QFZ.mjs +1099 -0
  11. package/dist/DataBindingPlugin.native-jQ1JPRTp.mjs +917 -0
  12. package/dist/DocSchemaPlugin.native-CHOge18O.mjs +1325 -0
  13. package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
  14. package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
  15. package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
  16. package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
  17. package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
  18. package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
  19. package/dist/MentionPlugin.native-BMDlOqur.mjs +734 -0
  20. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
  21. package/dist/PIIRedactionPlugin.native-DcsjmtV1.mjs +1396 -0
  22. package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-DijGuHJZ.mjs} +86 -77
  23. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-WuIwOAOR.mjs} +30 -30
  24. package/dist/SlashCommandsPlugin.native-CmxvMEaE.mjs +755 -0
  25. package/dist/SmartPastePlugin.native-BOKKtF07.mjs +1398 -0
  26. package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
  27. package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
  28. package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
  29. package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
  30. package/dist/TrackChangesPlugin.native-Bghu2q4a.mjs +761 -0
  31. package/dist/TranslationWorkflowPlugin.native-Bz6jDGvj.mjs +1728 -0
  32. package/dist/VersionDiffPlugin.native-Bvxgy--t.mjs +776 -0
  33. package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
  34. package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
  35. package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
  36. package/dist/editora.min.js +13 -13
  37. package/dist/editora.umd.js +13 -13
  38. package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
  39. package/dist/index-BslAFzmv.mjs +16544 -0
  40. package/dist/index-D1LOqg5C.js +10 -0
  41. package/dist/{index-OwnkG39N.mjs → index-DqC57IEH.mjs} +438 -328
  42. package/dist/index.cjs.js +1 -1
  43. package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
  44. package/dist/index.esm.js +2 -2
  45. package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
  46. package/dist/plugin-loader.js +77 -40
  47. package/dist/webcomponent-core.js +456 -346
  48. package/dist/webcomponent-core.min.css +1 -1
  49. package/dist/webcomponent-core.min.js +87 -107
  50. package/dist/webcomponent.cjs.js +1 -1
  51. package/dist/webcomponent.esm.js +1 -1
  52. package/dist/webcomponent.js +503 -356
  53. package/dist/webcomponent.min.css +1 -1
  54. package/dist/webcomponent.min.js +6003 -658
  55. package/package.json +2 -2
  56. package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
  57. package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
  58. package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
  59. package/dist/documentManager-irzj9n3V.mjs +0 -37627
  60. package/dist/index-CqWQFb3D.js +0 -10
@@ -0,0 +1,776 @@
1
+ const $ = ".rte-content, .editora-content", d = '[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark', l = "rte-version-diff-overlay", J = "rte-version-diff-styles", fe = {
2
+ title: "Version Diff",
3
+ baseline: "Baseline",
4
+ current: "Current",
5
+ noChanges: "No changes detected between baseline and current content.",
6
+ loading: "Preparing diff...",
7
+ tabInline: "Inline Diff",
8
+ tabSideBySide: "Side by Side",
9
+ refresh: "Refresh",
10
+ setBaseline: "Set Current as Baseline",
11
+ close: "Close",
12
+ mode: "Mode",
13
+ ignoreWhitespace: "Ignore whitespace",
14
+ largeDocFallback: "Large document fallback mode applied for performance."
15
+ }, w = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap();
16
+ let j = 0, H = null, z = null, V = null, S = null, M = null, D = null;
17
+ function u(e) {
18
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
19
+ }
20
+ function de(e) {
21
+ return {
22
+ ...fe,
23
+ ...e || {}
24
+ };
25
+ }
26
+ function N(e, i = !0) {
27
+ if ((e == null ? void 0 : e.contentElement) instanceof HTMLElement) return e.contentElement;
28
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
29
+ const r = e.editorElement;
30
+ if (r.matches($)) return r;
31
+ const o = r.querySelector($);
32
+ if (o instanceof HTMLElement) return o;
33
+ }
34
+ const t = window.getSelection();
35
+ if (t && t.rangeCount > 0) {
36
+ const r = t.getRangeAt(0).startContainer, o = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement, f = o == null ? void 0 : o.closest($);
37
+ if (f) return f;
38
+ }
39
+ const n = document.activeElement;
40
+ if (n) {
41
+ if (n.matches($)) return n;
42
+ const r = n.closest($);
43
+ if (r) return r;
44
+ }
45
+ return D && D.isConnected ? D : i ? document.querySelector($) : null;
46
+ }
47
+ function O(e) {
48
+ return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
49
+ }
50
+ function P(e) {
51
+ if (!e) return !1;
52
+ const i = e.getAttribute("data-theme") || e.getAttribute("theme");
53
+ if (i && i.toLowerCase() === "dark") return !0;
54
+ const t = e.classList;
55
+ return t.contains("dark") || t.contains("editora-theme-dark") || t.contains("rte-theme-dark");
56
+ }
57
+ function Q(e) {
58
+ const i = O(e);
59
+ if (P(i)) return !0;
60
+ const t = i.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
61
+ return !!(P(t) || P(document.documentElement) || P(document.body));
62
+ }
63
+ function ce(e) {
64
+ const i = document.createElement("textarea");
65
+ return i.innerHTML = e, i.value;
66
+ }
67
+ function W(e) {
68
+ const t = O(e).getAttribute("data-initial-content");
69
+ return t ? ce(t) : e.innerHTML;
70
+ }
71
+ function te(e) {
72
+ return e.replace(/\r\n?/g, `
73
+ `);
74
+ }
75
+ function X(e) {
76
+ const i = document.createElement("div"), t = e.replace(/<br\s*\/?>/gi, `
77
+ `).replace(/<\/(p|div|h1|h2|h3|h4|h5|h6|li|tr|blockquote|pre|section|article)>/gi, `$&
78
+ `);
79
+ i.innerHTML = t;
80
+ const n = i.textContent || "";
81
+ return te(n).replace(/\u00a0/g, " ").replace(/\n{3,}/g, `
82
+
83
+ `).trim();
84
+ }
85
+ function Z(e, i, t) {
86
+ let n = te(e);
87
+ if (t && (n = n.replace(/[ \t]+/g, " ").replace(/\n{3,}/g, `
88
+
89
+ `).trim()), !n) return [];
90
+ if (i === "line")
91
+ return n.split(`
92
+ `);
93
+ if (t)
94
+ return n.split(/\s+/).filter(Boolean);
95
+ const r = [], o = n.split(`
96
+ `);
97
+ return o.forEach((f, g) => {
98
+ const c = f.split(/[ \t]+/).filter(Boolean);
99
+ r.push(...c), g < o.length - 1 && r.push(`
100
+ `);
101
+ }), r;
102
+ }
103
+ function ue(e, i, t) {
104
+ if (e.length === 0) return "";
105
+ if (i === "line") return e.join(`
106
+ `);
107
+ if (t) return e.join(" ");
108
+ let n = "";
109
+ for (let r = 0; r < e.length; r += 1) {
110
+ const o = e[r];
111
+ if (o === `
112
+ `) {
113
+ n = n.replace(/[ \t]+$/g, ""), n += `
114
+ `;
115
+ continue;
116
+ }
117
+ n.length > 0 && !n.endsWith(`
118
+ `) && (n += " "), n += o;
119
+ }
120
+ return n;
121
+ }
122
+ function pe(e, i, t) {
123
+ const n = [];
124
+ return e.forEach((r) => {
125
+ const o = n[n.length - 1];
126
+ if (o && o.type === r.type) {
127
+ o.tokens.push(r.token);
128
+ return;
129
+ }
130
+ n.push({ type: r.type, tokens: [r.token] });
131
+ }), n.map((r) => ({
132
+ type: r.type,
133
+ value: ue(r.tokens, i, t),
134
+ count: r.tokens.length
135
+ }));
136
+ }
137
+ function be(e, i) {
138
+ let t = 0;
139
+ for (; t < e.length && t < i.length && e[t] === i[t]; )
140
+ t += 1;
141
+ let n = e.length - 1, r = i.length - 1;
142
+ for (; n >= t && r >= t && e[n] === i[r]; )
143
+ n -= 1, r -= 1;
144
+ const o = e.slice(0, t), f = n < e.length - 1 ? e.slice(n + 1) : [], g = t <= n ? e.slice(t, n + 1) : [], c = t <= r ? i.slice(t, r + 1) : [];
145
+ return { prefix: o, suffix: f, aMiddle: g, bMiddle: c };
146
+ }
147
+ function he(e, i, t, n, r, o) {
148
+ if (e.length === 0 && i.length === 0)
149
+ return { segments: [], insertedCount: 0, deletedCount: 0, equalCount: 0, usedFallback: !1 };
150
+ const { prefix: f, suffix: g, aMiddle: c, bMiddle: b } = be(e, i);
151
+ let m = [];
152
+ f.forEach((a) => m.push({ type: "equal", token: a }));
153
+ const F = c.length * b.length, T = c.length > o || b.length > o || F > r;
154
+ if (T)
155
+ c.forEach((a) => m.push({ type: "delete", token: a })), b.forEach((a) => m.push({ type: "insert", token: a }));
156
+ else {
157
+ const a = Array.from({ length: c.length + 1 }, () => new Uint32Array(b.length + 1));
158
+ for (let k = c.length - 1; k >= 0; k -= 1) {
159
+ const A = a[k], I = a[k + 1];
160
+ for (let x = b.length - 1; x >= 0; x -= 1)
161
+ A[x] = c[k] === b[x] ? I[x + 1] + 1 : Math.max(I[x], A[x + 1]);
162
+ }
163
+ let h = 0, p = 0;
164
+ for (; h < c.length && p < b.length; )
165
+ c[h] === b[p] ? (m.push({ type: "equal", token: c[h] }), h += 1, p += 1) : a[h + 1][p] >= a[h][p + 1] ? (m.push({ type: "delete", token: c[h] }), h += 1) : (m.push({ type: "insert", token: b[p] }), p += 1);
166
+ for (; h < c.length; )
167
+ m.push({ type: "delete", token: c[h] }), h += 1;
168
+ for (; p < b.length; )
169
+ m.push({ type: "insert", token: b[p] }), p += 1;
170
+ }
171
+ g.forEach((a) => m.push({ type: "equal", token: a }));
172
+ const q = pe(m, t, n);
173
+ let B = 0, L = 0, K = 0;
174
+ return q.forEach((a) => {
175
+ a.type === "insert" && (B += a.count), a.type === "delete" && (L += a.count), a.type === "equal" && (K += a.count);
176
+ }), {
177
+ segments: q,
178
+ insertedCount: B,
179
+ deletedCount: L,
180
+ equalCount: K,
181
+ usedFallback: T
182
+ };
183
+ }
184
+ function re(e) {
185
+ return u(e.value).replace(/\n/g, `
186
+ `);
187
+ }
188
+ function ve(e, i) {
189
+ return e.length === 0 ? `<p class="rte-version-diff-empty">${u(i.noChanges)}</p>` : e.map((t) => `<span class="${t.type === "equal" ? "rte-version-diff-equal" : t.type === "insert" ? "rte-version-diff-insert" : "rte-version-diff-delete"}">${re(t)}</span>`).join("");
190
+ }
191
+ function me(e, i) {
192
+ if (e.length === 0) {
193
+ const r = `<p class="rte-version-diff-empty">${u(i.noChanges)}</p>`;
194
+ return { baselineHtml: r, currentHtml: r };
195
+ }
196
+ const t = [], n = [];
197
+ return e.forEach((r) => {
198
+ const o = re(r);
199
+ if (r.type === "equal") {
200
+ t.push(`<span class="rte-version-diff-equal">${o}</span>`), n.push(`<span class="rte-version-diff-equal">${o}</span>`);
201
+ return;
202
+ }
203
+ if (r.type === "delete") {
204
+ t.push(`<span class="rte-version-diff-delete">${o}</span>`);
205
+ return;
206
+ }
207
+ n.push(`<span class="rte-version-diff-insert">${o}</span>`);
208
+ }), {
209
+ baselineHtml: t.join(""),
210
+ currentHtml: n.join("")
211
+ };
212
+ }
213
+ function ge(e) {
214
+ const i = e.metaKey || e.ctrlKey, n = (typeof e.key == "string" ? e.key : "").toLowerCase(), r = typeof e.code == "string" ? e.code.toLowerCase() : "", o = i && e.altKey && !e.shiftKey && (n === "d" || r === "keyd"), f = !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && (n === "f8" || r === "f8");
215
+ return o || f;
216
+ }
217
+ function ye() {
218
+ if (typeof document == "undefined" || document.getElementById(J)) return;
219
+ const e = document.createElement("style");
220
+ e.id = J, e.textContent = `
221
+ .${l} {
222
+ position: fixed;
223
+ inset: 0;
224
+ background: rgba(15, 23, 42, 0.55);
225
+ z-index: 2147483646;
226
+ display: flex;
227
+ align-items: center;
228
+ justify-content: center;
229
+ padding: 20px;
230
+ }
231
+
232
+ .rte-version-diff-dialog {
233
+ width: min(980px, 96vw);
234
+ max-height: min(90vh, 860px);
235
+ background: #ffffff;
236
+ color: #0f172a;
237
+ border: 1px solid #d7dee8;
238
+ border-radius: 8px;
239
+ display: flex;
240
+ flex-direction: column;
241
+ box-shadow: 0 24px 48px rgba(15, 23, 42, 0.3);
242
+ overflow: hidden;
243
+ }
244
+
245
+ .rte-version-diff-header,
246
+ .rte-version-diff-footer {
247
+ padding: 12px 14px;
248
+ border-bottom: 1px solid #e2e8f0;
249
+ background: #f8fafc;
250
+ display: flex;
251
+ align-items: center;
252
+ gap: 10px;
253
+ flex-wrap: wrap;
254
+ }
255
+
256
+ .rte-version-diff-footer {
257
+ border-top: 1px solid #e2e8f0;
258
+ border-bottom: none;
259
+ justify-content: space-between;
260
+ }
261
+
262
+ .rte-version-diff-title {
263
+ margin: 0;
264
+ font-size: 16px;
265
+ font-weight: 700;
266
+ flex: 1;
267
+ }
268
+
269
+ .rte-version-diff-controls {
270
+ display: flex;
271
+ align-items: center;
272
+ gap: 10px;
273
+ flex-wrap: wrap;
274
+ }
275
+
276
+ .rte-version-diff-select,
277
+ .rte-version-diff-btn {
278
+ border: 1px solid #cbd5e1;
279
+ background: #ffffff;
280
+ color: #0f172a;
281
+ border-radius: 6px;
282
+ min-height: 34px;
283
+ padding: 6px 10px;
284
+ font-size: 13px;
285
+ cursor: pointer;
286
+ }
287
+
288
+ .rte-version-diff-btn:hover,
289
+ .rte-version-diff-btn:focus-visible,
290
+ .rte-version-diff-select:focus-visible {
291
+ outline: none;
292
+ border-color: #3b82f6;
293
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
294
+ }
295
+
296
+ .rte-version-diff-btn-primary {
297
+ background: #2563eb;
298
+ border-color: #2563eb;
299
+ color: #ffffff;
300
+ }
301
+
302
+ .rte-version-diff-btn-primary:hover {
303
+ background: #1d4ed8;
304
+ }
305
+
306
+ .rte-version-diff-close-btn {
307
+ border: 1px solid #cbd5e1;
308
+ border-radius: 6px;
309
+ min-height: 34px;
310
+ min-width: 34px;
311
+ width: 34px;
312
+ height: 34px;
313
+ padding: 0;
314
+ display: inline-flex;
315
+ align-items: center;
316
+ justify-content: center;
317
+ background: #ffffff;
318
+ color: #0f172a;
319
+ font-size: 16px;
320
+ line-height: 1;
321
+ font-weight: 600;
322
+ }
323
+
324
+ .rte-version-diff-close-btn:hover,
325
+ .rte-version-diff-close-btn:focus-visible {
326
+ border-color: #3b82f6;
327
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
328
+ background: #ffffff;
329
+ outline: none;
330
+ }
331
+
332
+ .rte-version-diff-tabs {
333
+ display: flex;
334
+ gap: 6px;
335
+ border-bottom: 1px solid #e2e8f0;
336
+ background: #f8fafc;
337
+ padding: 8px 14px;
338
+ }
339
+
340
+ .rte-version-diff-tab {
341
+ border: 1px solid #cbd5e1;
342
+ background: #ffffff;
343
+ color: #0f172a;
344
+ border-radius: 6px;
345
+ min-height: 32px;
346
+ padding: 4px 10px;
347
+ font-size: 13px;
348
+ cursor: pointer;
349
+ }
350
+
351
+ .rte-version-diff-tab[aria-selected="true"] {
352
+ background: #dbeafe;
353
+ border-color: #60a5fa;
354
+ color: #1e3a8a;
355
+ }
356
+
357
+ .rte-version-diff-body {
358
+ flex: 1;
359
+ overflow: auto;
360
+ padding: 10px 14px 14px;
361
+ background: #ffffff;
362
+ }
363
+
364
+ .rte-version-diff-summary {
365
+ font-size: 12px;
366
+ color: #475569;
367
+ margin-bottom: 10px;
368
+ display: flex;
369
+ gap: 14px;
370
+ flex-wrap: wrap;
371
+ }
372
+
373
+ .rte-version-diff-panel {
374
+ display: none;
375
+ }
376
+
377
+ .rte-version-diff-panel.active {
378
+ display: block;
379
+ }
380
+
381
+ .rte-version-diff-inline,
382
+ .rte-version-diff-side-pane {
383
+ border: 1px solid #dbe3ec;
384
+ border-radius: 6px;
385
+ padding: 10px;
386
+ min-height: 140px;
387
+ max-height: 50vh;
388
+ overflow: auto;
389
+ white-space: pre-wrap;
390
+ word-break: break-word;
391
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
392
+ font-size: 12px;
393
+ line-height: 1.5;
394
+ background: #ffffff;
395
+ }
396
+
397
+ .rte-version-diff-side-grid {
398
+ display: grid;
399
+ grid-template-columns: 1fr 1fr;
400
+ gap: 10px;
401
+ }
402
+
403
+ .rte-version-diff-pane-title {
404
+ margin: 0 0 6px;
405
+ font-size: 12px;
406
+ font-weight: 700;
407
+ color: #334155;
408
+ }
409
+
410
+ .rte-version-diff-equal { color: inherit; }
411
+ .rte-version-diff-insert {
412
+ background: rgba(22, 163, 74, 0.18);
413
+ color: #14532d;
414
+ border-radius: 2px;
415
+ }
416
+ .rte-version-diff-delete {
417
+ background: rgba(220, 38, 38, 0.18);
418
+ color: #7f1d1d;
419
+ text-decoration: line-through;
420
+ border-radius: 2px;
421
+ }
422
+
423
+ .rte-version-diff-empty {
424
+ margin: 0;
425
+ color: #64748b;
426
+ font-size: 13px;
427
+ }
428
+
429
+ ${d} .rte-version-diff-dialog,
430
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-dialog {
431
+ background: #1f2937;
432
+ color: #e5e7eb;
433
+ border-color: #334155;
434
+ }
435
+
436
+ ${d} .rte-version-diff-header,
437
+ ${d} .rte-version-diff-footer,
438
+ ${d} .rte-version-diff-tabs,
439
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-header,
440
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-footer,
441
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-tabs {
442
+ background: #111827;
443
+ border-color: #334155;
444
+ }
445
+
446
+ ${d} .rte-version-diff-body,
447
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-body {
448
+ background: #1f2937;
449
+ }
450
+
451
+ ${d} .rte-version-diff-select,
452
+ ${d} .rte-version-diff-btn,
453
+ ${d} .rte-version-diff-tab,
454
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-select,
455
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-btn,
456
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-tab {
457
+ background: #0f172a;
458
+ color: #e5e7eb;
459
+ border-color: #475569;
460
+ }
461
+
462
+ ${d} .rte-version-diff-close-btn,
463
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-close-btn {
464
+ background: #0f172a;
465
+ border-color: #475569;
466
+ color: #e2e8f0;
467
+ }
468
+
469
+ ${d} .rte-version-diff-close-btn:hover,
470
+ ${d} .rte-version-diff-close-btn:focus-visible,
471
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-close-btn:hover,
472
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-close-btn:focus-visible {
473
+ border-color: #60a5fa;
474
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
475
+ outline: none;
476
+ }
477
+
478
+ ${d} .rte-version-diff-tab[aria-selected="true"],
479
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-tab[aria-selected="true"] {
480
+ background: #1e3a8a;
481
+ border-color: #3b82f6;
482
+ color: #dbeafe;
483
+ }
484
+
485
+ ${d} .rte-version-diff-inline,
486
+ ${d} .rte-version-diff-side-pane,
487
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-inline,
488
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-side-pane {
489
+ background: #0f172a;
490
+ border-color: #334155;
491
+ color: #e5e7eb;
492
+ }
493
+
494
+ ${d} .rte-version-diff-pane-title,
495
+ ${d} .rte-version-diff-summary,
496
+ ${d} .rte-version-diff-empty,
497
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-pane-title,
498
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-summary,
499
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-empty {
500
+ color: #94a3b8;
501
+ }
502
+
503
+ ${d} .rte-version-diff-insert,
504
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-insert {
505
+ background: rgba(22, 163, 74, 0.25);
506
+ color: #bbf7d0;
507
+ }
508
+
509
+ ${d} .rte-version-diff-delete,
510
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-delete {
511
+ background: rgba(220, 38, 38, 0.25);
512
+ color: #fecaca;
513
+ }
514
+ :is(${d}) .rte-toolbar-item .rte-toolbar-button[data-command="openVersionDiff"] svg{
515
+ fill: none;
516
+ }
517
+ `, document.head.appendChild(e);
518
+ }
519
+ async function ke(e, i, t) {
520
+ if (t != null) return t;
521
+ if (typeof i.getBaselineHtml == "function") {
522
+ const o = O(e), f = await Promise.resolve(i.getBaselineHtml({ editor: e, editorRoot: o }));
523
+ if (typeof f == "string") return f;
524
+ }
525
+ const n = w.get(e);
526
+ if (typeof n == "string") return n;
527
+ if (typeof i.baselineHtml == "string") return i.baselineHtml;
528
+ const r = W(e);
529
+ return w.set(e, r), r;
530
+ }
531
+ function xe(e) {
532
+ const i = e.querySelector(
533
+ 'button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
534
+ );
535
+ i == null || i.focus();
536
+ }
537
+ function $e(e, i) {
538
+ if (e.key !== "Tab") return;
539
+ const t = Array.from(i.querySelectorAll(
540
+ 'button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
541
+ )).filter((f) => !f.hasAttribute("disabled"));
542
+ if (t.length === 0) return;
543
+ const n = t[0], r = t[t.length - 1], o = document.activeElement;
544
+ e.shiftKey && o === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && o === r && (e.preventDefault(), n.focus());
545
+ }
546
+ function ne() {
547
+ z && (z(), z = null);
548
+ }
549
+ function ee(e) {
550
+ !e || w.has(e) || w.set(e, W(e));
551
+ }
552
+ function Ee(e) {
553
+ var i, t;
554
+ return {
555
+ baselineHtml: e.baselineHtml,
556
+ getBaselineHtml: e.getBaselineHtml,
557
+ mode: e.mode || "word",
558
+ ignoreWhitespace: e.ignoreWhitespace !== !1,
559
+ maxTokens: Math.max(200, (i = e.maxTokens) != null ? i : 1200),
560
+ maxMatrixSize: Math.max(5e4, (t = e.maxMatrixSize) != null ? t : 1e6),
561
+ labels: de(e.labels)
562
+ };
563
+ }
564
+ function ie(e, i, t) {
565
+ var _;
566
+ ne(), D = e, R.set(e, i);
567
+ const n = document.createElement("div");
568
+ n.className = l, Q(e) && n.classList.add("rte-version-diff-theme-dark");
569
+ const r = document.createElement("section");
570
+ r.className = "rte-version-diff-dialog", r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "true"), r.setAttribute("aria-labelledby", "rte-version-diff-title");
571
+ const o = i.labels;
572
+ let f = (t == null ? void 0 : t.mode) || i.mode, g = (_ = t == null ? void 0 : t.ignoreWhitespace) != null ? _ : i.ignoreWhitespace, c = "inline";
573
+ r.innerHTML = `
574
+ <header class="rte-version-diff-header">
575
+ <h2 id="rte-version-diff-title" class="rte-version-diff-title">${u(o.title)}</h2>
576
+ <div class="rte-version-diff-controls">
577
+ <label>
578
+ <span>${u(o.mode)}:</span>
579
+ <select class="rte-version-diff-select" aria-label="${u(o.mode)}">
580
+ <option value="word">Word</option>
581
+ <option value="line">Line</option>
582
+ </select>
583
+ </label>
584
+ <label class="rte-version-diff-checkbox">
585
+ <input type="checkbox" class="rte-version-diff-ignore-ws" ${g ? "checked" : ""}>
586
+ ${u(o.ignoreWhitespace)}
587
+ </label>
588
+ <button type="button" class="rte-version-diff-btn rte-version-diff-set-baseline" aria-label="${u(o.setBaseline)}">${u(o.setBaseline)}</button>
589
+ <button type="button" class="rte-version-diff-btn" data-action="refresh" aria-label="${u(o.refresh)}">${u(o.refresh)}</button>
590
+ <button type="button" class="rte-version-diff-btn rte-version-diff-close-btn" data-action="close" aria-label="${u(o.close)}">✕</button>
591
+ </div>
592
+ </header>
593
+
594
+ <div class="rte-version-diff-tabs" role="tablist" aria-label="Diff views">
595
+ <button type="button" role="tab" class="rte-version-diff-tab" data-tab="inline" aria-selected="true">${u(o.tabInline)}</button>
596
+ <button type="button" role="tab" class="rte-version-diff-tab" data-tab="side" aria-selected="false">${u(o.tabSideBySide)}</button>
597
+ </div>
598
+
599
+ <main class="rte-version-diff-body">
600
+ <div class="rte-version-diff-summary" aria-live="polite"></div>
601
+ <section class="rte-version-diff-panel active" data-panel="inline" role="tabpanel">
602
+ <div class="rte-version-diff-inline" aria-label="Inline diff result"></div>
603
+ </section>
604
+ <section class="rte-version-diff-panel" data-panel="side" role="tabpanel">
605
+ <div class="rte-version-diff-side-grid">
606
+ <div>
607
+ <h3 class="rte-version-diff-pane-title">${u(o.baseline)}</h3>
608
+ <div class="rte-version-diff-side-pane" data-side="baseline" aria-label="${u(o.baseline)}"></div>
609
+ </div>
610
+ <div>
611
+ <h3 class="rte-version-diff-pane-title">${u(o.current)}</h3>
612
+ <div class="rte-version-diff-side-pane" data-side="current" aria-label="${u(o.current)}"></div>
613
+ </div>
614
+ </div>
615
+ </section>
616
+ </main>
617
+
618
+ <footer class="rte-version-diff-footer">
619
+ <small>Shortcut: Ctrl/Cmd + Alt + D (fallback: F8)</small>
620
+ <small>Esc: close</small>
621
+ </footer>
622
+ `, n.appendChild(r), document.body.appendChild(n);
623
+ const b = r.querySelector(".rte-version-diff-select");
624
+ b.value = f;
625
+ const m = r.querySelector(".rte-version-diff-ignore-ws"), F = r.querySelector(".rte-version-diff-summary"), T = r.querySelector(".rte-version-diff-inline"), q = r.querySelector('[data-side="baseline"]'), B = r.querySelector('[data-side="current"]');
626
+ let L = 0;
627
+ const K = () => {
628
+ const s = `<p class="rte-version-diff-empty">${u(o.loading)}</p>`;
629
+ T.innerHTML = s, q.innerHTML = s, B.innerHTML = s, F.textContent = "";
630
+ }, a = async (s) => {
631
+ var Y;
632
+ L += 1;
633
+ const v = L;
634
+ n.classList.toggle("rte-version-diff-theme-dark", Q(e)), K();
635
+ const y = e.innerHTML;
636
+ let E = "";
637
+ try {
638
+ E = await ke(e, i, s != null ? s : t == null ? void 0 : t.baselineHtml);
639
+ } catch (Se) {
640
+ E = (Y = w.get(e)) != null ? Y : W(e);
641
+ }
642
+ if (v !== L || !n.isConnected) return;
643
+ const oe = X(E), se = X(y), ae = Z(oe, f, g), le = Z(se, f, g), C = he(
644
+ ae,
645
+ le,
646
+ f,
647
+ g,
648
+ i.maxMatrixSize,
649
+ i.maxTokens
650
+ ), G = me(C.segments, o);
651
+ T.innerHTML = ve(C.segments, o), q.innerHTML = G.baselineHtml, B.innerHTML = G.currentHtml;
652
+ const U = [
653
+ `+${C.insertedCount} inserted`,
654
+ `-${C.deletedCount} deleted`,
655
+ `${C.equalCount} unchanged`
656
+ ];
657
+ C.usedFallback && U.push(o.largeDocFallback), F.textContent = U.join(" | ");
658
+ }, h = (s) => {
659
+ c = s, r.querySelectorAll(".rte-version-diff-tab").forEach((v) => {
660
+ const y = v.getAttribute("data-tab") === s;
661
+ v.setAttribute("aria-selected", y ? "true" : "false"), v.tabIndex = y ? 0 : -1;
662
+ }), r.querySelectorAll(".rte-version-diff-panel").forEach((v) => {
663
+ v.classList.toggle("active", v.getAttribute("data-panel") === s);
664
+ });
665
+ }, p = () => {
666
+ n.removeEventListener("keydown", I, !0), n.removeEventListener("click", A), document.removeEventListener("keydown", k, !0), n.parentNode && n.parentNode.removeChild(n), z = null, e.focus({ preventScroll: !0 });
667
+ }, k = (s) => {
668
+ s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), p());
669
+ }, A = (s) => {
670
+ s.target === n && p();
671
+ }, I = (s) => {
672
+ if (s.key === "Escape") {
673
+ s.preventDefault(), p();
674
+ return;
675
+ }
676
+ if ($e(s, r), s.target && s.target.classList.contains("rte-version-diff-tab") && (s.key === "ArrowRight" || s.key === "ArrowLeft")) {
677
+ s.preventDefault();
678
+ const v = c === "inline" ? "side" : "inline";
679
+ h(v);
680
+ const y = r.querySelector(`.rte-version-diff-tab[data-tab="${v}"]`);
681
+ y == null || y.focus();
682
+ }
683
+ };
684
+ r.addEventListener("click", (s) => {
685
+ const v = s.target, y = v.getAttribute("data-action");
686
+ if (y === "close") {
687
+ p();
688
+ return;
689
+ }
690
+ if (y === "refresh") {
691
+ a();
692
+ return;
693
+ }
694
+ const E = v.getAttribute("data-tab");
695
+ (E === "inline" || E === "side") && h(E);
696
+ }), b.addEventListener("change", () => {
697
+ f = b.value === "line" ? "line" : "word", a();
698
+ }), m.addEventListener("change", () => {
699
+ g = m.checked, a();
700
+ }), r.querySelector(".rte-version-diff-set-baseline").addEventListener("click", () => {
701
+ w.set(e, e.innerHTML), a(e.innerHTML);
702
+ }), n.addEventListener("keydown", I, !0), n.addEventListener("click", A), document.addEventListener("keydown", k, !0), z = p, xe(r), a();
703
+ }
704
+ function we(e) {
705
+ V = e, !H && (H = (i) => {
706
+ if (!ge(i)) return;
707
+ if (document.querySelector(`.${l}`)) {
708
+ i.preventDefault();
709
+ return;
710
+ }
711
+ const t = i.target;
712
+ if (!!(t != null && t.closest("input, textarea, select"))) return;
713
+ const r = N(void 0, !1);
714
+ if (!r || r.getAttribute("contenteditable") === "false") return;
715
+ i.preventDefault(), i.stopPropagation();
716
+ const o = R.get(r) || V || e;
717
+ ie(r, o);
718
+ }, document.addEventListener("keydown", H, !0));
719
+ }
720
+ function Le() {
721
+ H && (document.removeEventListener("keydown", H, !0), H = null, V = null);
722
+ }
723
+ function Ce() {
724
+ S || (S = (e) => {
725
+ const i = e.target, t = i == null ? void 0 : i.closest($);
726
+ t && (D = t, ee(t));
727
+ }, document.addEventListener("focusin", S, !0)), M || (M = (e) => {
728
+ const t = e.target, n = t == null ? void 0 : t.closest($);
729
+ n && n.getAttribute("contenteditable") !== "false" && (D = n, ee(n));
730
+ }, document.addEventListener("beforeinput", M, !0));
731
+ }
732
+ function He() {
733
+ S && (document.removeEventListener("focusin", S, !0), S = null), M && (document.removeEventListener("beforeinput", M, !0), M = null);
734
+ }
735
+ const Me = (e = {}) => {
736
+ const i = Ee(e);
737
+ return ye(), {
738
+ name: "versionDiff",
739
+ toolbar: [
740
+ {
741
+ id: "versionDiff",
742
+ label: "Version Diff",
743
+ command: "openVersionDiff",
744
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3.5" y="4.5" width="7" height="15" rx="1.5" stroke="currentColor" stroke-width="1.8"></rect><rect x="13.5" y="4.5" width="7" height="15" rx="1.5" stroke="currentColor" stroke-width="1.8"></rect><path d="M5.5 12h3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"></path><path d="M15.5 12h3m-1.5-1.5v3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"></path></svg>'
745
+ }
746
+ ],
747
+ commands: {
748
+ openVersionDiff: (t, n) => {
749
+ const r = N(n);
750
+ return r ? (R.set(r, i), ie(r, i, t), !0) : !1;
751
+ },
752
+ setVersionDiffBaseline: (t, n) => {
753
+ const r = N(n);
754
+ if (!r) return !1;
755
+ R.set(r, i);
756
+ const o = typeof t == "string" ? t : typeof (t == null ? void 0 : t.html) == "string" ? t.html : r.innerHTML;
757
+ return w.set(r, o), !0;
758
+ }
759
+ },
760
+ keymap: {
761
+ "Mod-Alt-d": "openVersionDiff",
762
+ "Mod-Alt-D": "openVersionDiff",
763
+ F8: "openVersionDiff"
764
+ },
765
+ init: () => {
766
+ j += 1, we(i), Ce();
767
+ },
768
+ destroy: () => {
769
+ j = Math.max(0, j - 1), j === 0 && (ne(), Le(), He());
770
+ }
771
+ };
772
+ };
773
+ export {
774
+ Me as VersionDiffPlugin
775
+ };
776
+ //# sourceMappingURL=VersionDiffPlugin.native-Bvxgy--t.mjs.map