@editora/plugins 1.0.8 → 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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -0
  3. package/dist/approval-workflow.cjs.js +447 -0
  4. package/dist/approval-workflow.esm.js +1070 -0
  5. package/dist/blocks-library.cjs.js +442 -0
  6. package/dist/blocks-library.esm.js +1317 -0
  7. package/dist/citations.cjs.js +548 -0
  8. package/dist/citations.esm.js +1457 -0
  9. package/dist/conditional-content.cjs.js +626 -0
  10. package/dist/conditional-content.esm.js +1360 -0
  11. package/dist/content-rules.cjs.js +408 -0
  12. package/dist/content-rules.esm.js +1093 -0
  13. package/dist/data-binding.cjs.js +321 -0
  14. package/dist/data-binding.esm.js +913 -0
  15. package/dist/doc-schema.cjs.js +398 -0
  16. package/dist/doc-schema.esm.js +1310 -0
  17. package/dist/enterprise.cjs.js +1 -0
  18. package/dist/enterprise.esm.js +56 -0
  19. package/dist/index.cjs.js +1 -1
  20. package/dist/index.esm.js +109 -81
  21. package/dist/mentions.cjs.js +105 -0
  22. package/dist/mentions.esm.js +726 -0
  23. package/dist/page-break.cjs.js +2 -2
  24. package/dist/page-break.esm.js +32 -32
  25. package/dist/pii-redaction.cjs.js +436 -0
  26. package/dist/pii-redaction.esm.js +1377 -0
  27. package/dist/preview.cjs.js +3 -3
  28. package/dist/preview.esm.js +29 -29
  29. package/dist/slash-commands.cjs.js +90 -0
  30. package/dist/slash-commands.esm.js +752 -0
  31. package/dist/smart-paste.cjs.js +398 -0
  32. package/dist/smart-paste.esm.js +1388 -0
  33. package/dist/track-changes.cjs.js +77 -0
  34. package/dist/track-changes.esm.js +755 -0
  35. package/dist/translation-workflow.cjs.js +626 -0
  36. package/dist/translation-workflow.esm.js +1718 -0
  37. package/dist/version-diff.cjs.js +362 -0
  38. package/dist/version-diff.esm.js +768 -0
  39. package/index.d.ts +798 -0
  40. package/package.json +104 -5
@@ -0,0 +1,768 @@
1
+ const $ = ".rte-content, .editora-content", d = '[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark', l = "rte-version-diff-overlay", U = "rte-version-diff-styles", ae = {
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 le(e) {
21
+ return {
22
+ ...ae,
23
+ ...e || {}
24
+ };
25
+ }
26
+ function N(e, i = !0) {
27
+ if (e?.contentElement instanceof HTMLElement) return e.contentElement;
28
+ if (e?.editorElement instanceof HTMLElement) {
29
+ const t = e.editorElement;
30
+ if (t.matches($)) return t;
31
+ const o = t.querySelector($);
32
+ if (o instanceof HTMLElement) return o;
33
+ }
34
+ const n = window.getSelection();
35
+ if (n && n.rangeCount > 0) {
36
+ const t = n.getRangeAt(0).startContainer, f = (t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement)?.closest($);
37
+ if (f) return f;
38
+ }
39
+ const r = document.activeElement;
40
+ if (r) {
41
+ if (r.matches($)) return r;
42
+ const t = r.closest($);
43
+ if (t) return t;
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 n = e.classList;
55
+ return n.contains("dark") || n.contains("editora-theme-dark") || n.contains("rte-theme-dark");
56
+ }
57
+ function Y(e) {
58
+ const i = O(e);
59
+ if (P(i)) return !0;
60
+ const n = i.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
61
+ return !!(P(n) || P(document.documentElement) || P(document.body));
62
+ }
63
+ function fe(e) {
64
+ const i = document.createElement("textarea");
65
+ return i.innerHTML = e, i.value;
66
+ }
67
+ function W(e) {
68
+ const n = O(e).getAttribute("data-initial-content");
69
+ return n ? fe(n) : e.innerHTML;
70
+ }
71
+ function Z(e) {
72
+ return e.replace(/\r\n?/g, `
73
+ `);
74
+ }
75
+ function J(e) {
76
+ const i = document.createElement("div"), n = 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 = n;
80
+ const r = i.textContent || "";
81
+ return Z(r).replace(/\u00a0/g, " ").replace(/\n{3,}/g, `
82
+
83
+ `).trim();
84
+ }
85
+ function Q(e, i, n) {
86
+ let r = Z(e);
87
+ if (n && (r = r.replace(/[ \t]+/g, " ").replace(/\n{3,}/g, `
88
+
89
+ `).trim()), !r) return [];
90
+ if (i === "line")
91
+ return r.split(`
92
+ `);
93
+ if (n)
94
+ return r.split(/\s+/).filter(Boolean);
95
+ const t = [], o = r.split(`
96
+ `);
97
+ return o.forEach((f, g) => {
98
+ const c = f.split(/[ \t]+/).filter(Boolean);
99
+ t.push(...c), g < o.length - 1 && t.push(`
100
+ `);
101
+ }), t;
102
+ }
103
+ function de(e, i, n) {
104
+ if (e.length === 0) return "";
105
+ if (i === "line") return e.join(`
106
+ `);
107
+ if (n) return e.join(" ");
108
+ let r = "";
109
+ for (let t = 0; t < e.length; t += 1) {
110
+ const o = e[t];
111
+ if (o === `
112
+ `) {
113
+ r = r.replace(/[ \t]+$/g, ""), r += `
114
+ `;
115
+ continue;
116
+ }
117
+ r.length > 0 && !r.endsWith(`
118
+ `) && (r += " "), r += o;
119
+ }
120
+ return r;
121
+ }
122
+ function ce(e, i, n) {
123
+ const r = [];
124
+ return e.forEach((t) => {
125
+ const o = r[r.length - 1];
126
+ if (o && o.type === t.type) {
127
+ o.tokens.push(t.token);
128
+ return;
129
+ }
130
+ r.push({ type: t.type, tokens: [t.token] });
131
+ }), r.map((t) => ({
132
+ type: t.type,
133
+ value: de(t.tokens, i, n),
134
+ count: t.tokens.length
135
+ }));
136
+ }
137
+ function ue(e, i) {
138
+ let n = 0;
139
+ for (; n < e.length && n < i.length && e[n] === i[n]; )
140
+ n += 1;
141
+ let r = e.length - 1, t = i.length - 1;
142
+ for (; r >= n && t >= n && e[r] === i[t]; )
143
+ r -= 1, t -= 1;
144
+ const o = e.slice(0, n), f = r < e.length - 1 ? e.slice(r + 1) : [], g = n <= r ? e.slice(n, r + 1) : [], c = n <= t ? i.slice(n, t + 1) : [];
145
+ return { prefix: o, suffix: f, aMiddle: g, bMiddle: c };
146
+ }
147
+ function pe(e, i, n, r, t, 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 } = ue(e, i);
151
+ let v = [];
152
+ f.forEach((a) => v.push({ type: "equal", token: a }));
153
+ const F = c.length * b.length, T = c.length > o || b.length > o || F > t;
154
+ if (T)
155
+ c.forEach((a) => v.push({ type: "delete", token: a })), b.forEach((a) => v.push({ type: "insert", token: a }));
156
+ else {
157
+ const a = Array.from({ length: c.length + 1 }, () => new Uint32Array(b.length + 1));
158
+ for (let y = c.length - 1; y >= 0; y -= 1) {
159
+ const B = a[y], I = a[y + 1];
160
+ for (let x = b.length - 1; x >= 0; x -= 1)
161
+ B[x] = c[y] === b[x] ? I[x + 1] + 1 : Math.max(I[x], B[x + 1]);
162
+ }
163
+ let h = 0, p = 0;
164
+ for (; h < c.length && p < b.length; )
165
+ c[h] === b[p] ? (v.push({ type: "equal", token: c[h] }), h += 1, p += 1) : a[h + 1][p] >= a[h][p + 1] ? (v.push({ type: "delete", token: c[h] }), h += 1) : (v.push({ type: "insert", token: b[p] }), p += 1);
166
+ for (; h < c.length; )
167
+ v.push({ type: "delete", token: c[h] }), h += 1;
168
+ for (; p < b.length; )
169
+ v.push({ type: "insert", token: b[p] }), p += 1;
170
+ }
171
+ g.forEach((a) => v.push({ type: "equal", token: a }));
172
+ const q = ce(v, n, r);
173
+ let A = 0, L = 0, K = 0;
174
+ return q.forEach((a) => {
175
+ a.type === "insert" && (A += a.count), a.type === "delete" && (L += a.count), a.type === "equal" && (K += a.count);
176
+ }), {
177
+ segments: q,
178
+ insertedCount: A,
179
+ deletedCount: L,
180
+ equalCount: K,
181
+ usedFallback: T
182
+ };
183
+ }
184
+ function ee(e) {
185
+ return u(e.value).replace(/\n/g, `
186
+ `);
187
+ }
188
+ function be(e, i) {
189
+ return e.length === 0 ? `<p class="rte-version-diff-empty">${u(i.noChanges)}</p>` : e.map((n) => `<span class="${n.type === "equal" ? "rte-version-diff-equal" : n.type === "insert" ? "rte-version-diff-insert" : "rte-version-diff-delete"}">${ee(n)}</span>`).join("");
190
+ }
191
+ function he(e, i) {
192
+ if (e.length === 0) {
193
+ const t = `<p class="rte-version-diff-empty">${u(i.noChanges)}</p>`;
194
+ return { baselineHtml: t, currentHtml: t };
195
+ }
196
+ const n = [], r = [];
197
+ return e.forEach((t) => {
198
+ const o = ee(t);
199
+ if (t.type === "equal") {
200
+ n.push(`<span class="rte-version-diff-equal">${o}</span>`), r.push(`<span class="rte-version-diff-equal">${o}</span>`);
201
+ return;
202
+ }
203
+ if (t.type === "delete") {
204
+ n.push(`<span class="rte-version-diff-delete">${o}</span>`);
205
+ return;
206
+ }
207
+ r.push(`<span class="rte-version-diff-insert">${o}</span>`);
208
+ }), {
209
+ baselineHtml: n.join(""),
210
+ currentHtml: r.join("")
211
+ };
212
+ }
213
+ function me(e) {
214
+ const i = e.metaKey || e.ctrlKey, r = (typeof e.key == "string" ? e.key : "").toLowerCase(), t = typeof e.code == "string" ? e.code.toLowerCase() : "", o = i && e.altKey && !e.shiftKey && (r === "d" || t === "keyd"), f = !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && (r === "f8" || t === "f8");
215
+ return o || f;
216
+ }
217
+ function ve() {
218
+ if (typeof document > "u" || document.getElementById(U)) return;
219
+ const e = document.createElement("style");
220
+ e.id = U, 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 ge(e, i, n) {
520
+ if (n != null) return n;
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 r = w.get(e);
526
+ if (typeof r == "string") return r;
527
+ if (typeof i.baselineHtml == "string") return i.baselineHtml;
528
+ const t = W(e);
529
+ return w.set(e, t), t;
530
+ }
531
+ function ye(e) {
532
+ e.querySelector(
533
+ 'button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
534
+ )?.focus();
535
+ }
536
+ function xe(e, i) {
537
+ if (e.key !== "Tab") return;
538
+ const n = Array.from(i.querySelectorAll(
539
+ 'button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
540
+ )).filter((f) => !f.hasAttribute("disabled"));
541
+ if (n.length === 0) return;
542
+ const r = n[0], t = n[n.length - 1], o = document.activeElement;
543
+ e.shiftKey && o === r ? (e.preventDefault(), t.focus()) : !e.shiftKey && o === t && (e.preventDefault(), r.focus());
544
+ }
545
+ function te() {
546
+ z && (z(), z = null);
547
+ }
548
+ function X(e) {
549
+ !e || w.has(e) || w.set(e, W(e));
550
+ }
551
+ function ke(e) {
552
+ return {
553
+ baselineHtml: e.baselineHtml,
554
+ getBaselineHtml: e.getBaselineHtml,
555
+ mode: e.mode || "word",
556
+ ignoreWhitespace: e.ignoreWhitespace !== !1,
557
+ maxTokens: Math.max(200, e.maxTokens ?? 1200),
558
+ maxMatrixSize: Math.max(5e4, e.maxMatrixSize ?? 1e6),
559
+ labels: le(e.labels)
560
+ };
561
+ }
562
+ function re(e, i, n) {
563
+ te(), D = e, R.set(e, i);
564
+ const r = document.createElement("div");
565
+ r.className = l, Y(e) && r.classList.add("rte-version-diff-theme-dark");
566
+ const t = document.createElement("section");
567
+ t.className = "rte-version-diff-dialog", t.setAttribute("role", "dialog"), t.setAttribute("aria-modal", "true"), t.setAttribute("aria-labelledby", "rte-version-diff-title");
568
+ const o = i.labels;
569
+ let f = n?.mode || i.mode, g = n?.ignoreWhitespace ?? i.ignoreWhitespace, c = "inline";
570
+ t.innerHTML = `
571
+ <header class="rte-version-diff-header">
572
+ <h2 id="rte-version-diff-title" class="rte-version-diff-title">${u(o.title)}</h2>
573
+ <div class="rte-version-diff-controls">
574
+ <label>
575
+ <span>${u(o.mode)}:</span>
576
+ <select class="rte-version-diff-select" aria-label="${u(o.mode)}">
577
+ <option value="word">Word</option>
578
+ <option value="line">Line</option>
579
+ </select>
580
+ </label>
581
+ <label class="rte-version-diff-checkbox">
582
+ <input type="checkbox" class="rte-version-diff-ignore-ws" ${g ? "checked" : ""}>
583
+ ${u(o.ignoreWhitespace)}
584
+ </label>
585
+ <button type="button" class="rte-version-diff-btn rte-version-diff-set-baseline" aria-label="${u(o.setBaseline)}">${u(o.setBaseline)}</button>
586
+ <button type="button" class="rte-version-diff-btn" data-action="refresh" aria-label="${u(o.refresh)}">${u(o.refresh)}</button>
587
+ <button type="button" class="rte-version-diff-btn rte-version-diff-close-btn" data-action="close" aria-label="${u(o.close)}">✕</button>
588
+ </div>
589
+ </header>
590
+
591
+ <div class="rte-version-diff-tabs" role="tablist" aria-label="Diff views">
592
+ <button type="button" role="tab" class="rte-version-diff-tab" data-tab="inline" aria-selected="true">${u(o.tabInline)}</button>
593
+ <button type="button" role="tab" class="rte-version-diff-tab" data-tab="side" aria-selected="false">${u(o.tabSideBySide)}</button>
594
+ </div>
595
+
596
+ <main class="rte-version-diff-body">
597
+ <div class="rte-version-diff-summary" aria-live="polite"></div>
598
+ <section class="rte-version-diff-panel active" data-panel="inline" role="tabpanel">
599
+ <div class="rte-version-diff-inline" aria-label="Inline diff result"></div>
600
+ </section>
601
+ <section class="rte-version-diff-panel" data-panel="side" role="tabpanel">
602
+ <div class="rte-version-diff-side-grid">
603
+ <div>
604
+ <h3 class="rte-version-diff-pane-title">${u(o.baseline)}</h3>
605
+ <div class="rte-version-diff-side-pane" data-side="baseline" aria-label="${u(o.baseline)}"></div>
606
+ </div>
607
+ <div>
608
+ <h3 class="rte-version-diff-pane-title">${u(o.current)}</h3>
609
+ <div class="rte-version-diff-side-pane" data-side="current" aria-label="${u(o.current)}"></div>
610
+ </div>
611
+ </div>
612
+ </section>
613
+ </main>
614
+
615
+ <footer class="rte-version-diff-footer">
616
+ <small>Shortcut: Ctrl/Cmd + Alt + D (fallback: F8)</small>
617
+ <small>Esc: close</small>
618
+ </footer>
619
+ `, r.appendChild(t), document.body.appendChild(r);
620
+ const b = t.querySelector(".rte-version-diff-select");
621
+ b.value = f;
622
+ const v = t.querySelector(".rte-version-diff-ignore-ws"), F = t.querySelector(".rte-version-diff-summary"), T = t.querySelector(".rte-version-diff-inline"), q = t.querySelector('[data-side="baseline"]'), A = t.querySelector('[data-side="current"]');
623
+ let L = 0;
624
+ const K = () => {
625
+ const s = `<p class="rte-version-diff-empty">${u(o.loading)}</p>`;
626
+ T.innerHTML = s, q.innerHTML = s, A.innerHTML = s, F.textContent = "";
627
+ }, a = async (s) => {
628
+ L += 1;
629
+ const m = L;
630
+ r.classList.toggle("rte-version-diff-theme-dark", Y(e)), K();
631
+ const k = e.innerHTML;
632
+ let E = "";
633
+ try {
634
+ E = await ge(e, i, s ?? n?.baselineHtml);
635
+ } catch {
636
+ E = w.get(e) ?? W(e);
637
+ }
638
+ if (m !== L || !r.isConnected) return;
639
+ const ne = J(E), ie = J(k), oe = Q(ne, f, g), se = Q(ie, f, g), C = pe(
640
+ oe,
641
+ se,
642
+ f,
643
+ g,
644
+ i.maxMatrixSize,
645
+ i.maxTokens
646
+ ), _ = he(C.segments, o);
647
+ T.innerHTML = be(C.segments, o), q.innerHTML = _.baselineHtml, A.innerHTML = _.currentHtml;
648
+ const G = [
649
+ `+${C.insertedCount} inserted`,
650
+ `-${C.deletedCount} deleted`,
651
+ `${C.equalCount} unchanged`
652
+ ];
653
+ C.usedFallback && G.push(o.largeDocFallback), F.textContent = G.join(" | ");
654
+ }, h = (s) => {
655
+ c = s, t.querySelectorAll(".rte-version-diff-tab").forEach((m) => {
656
+ const k = m.getAttribute("data-tab") === s;
657
+ m.setAttribute("aria-selected", k ? "true" : "false"), m.tabIndex = k ? 0 : -1;
658
+ }), t.querySelectorAll(".rte-version-diff-panel").forEach((m) => {
659
+ m.classList.toggle("active", m.getAttribute("data-panel") === s);
660
+ });
661
+ }, p = () => {
662
+ r.removeEventListener("keydown", I, !0), r.removeEventListener("click", B), document.removeEventListener("keydown", y, !0), r.parentNode && r.parentNode.removeChild(r), z = null, e.focus({ preventScroll: !0 });
663
+ }, y = (s) => {
664
+ s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), p());
665
+ }, B = (s) => {
666
+ s.target === r && p();
667
+ }, I = (s) => {
668
+ if (s.key === "Escape") {
669
+ s.preventDefault(), p();
670
+ return;
671
+ }
672
+ if (xe(s, t), s.target && s.target.classList.contains("rte-version-diff-tab") && (s.key === "ArrowRight" || s.key === "ArrowLeft")) {
673
+ s.preventDefault();
674
+ const m = c === "inline" ? "side" : "inline";
675
+ h(m), t.querySelector(`.rte-version-diff-tab[data-tab="${m}"]`)?.focus();
676
+ }
677
+ };
678
+ t.addEventListener("click", (s) => {
679
+ const m = s.target, k = m.getAttribute("data-action");
680
+ if (k === "close") {
681
+ p();
682
+ return;
683
+ }
684
+ if (k === "refresh") {
685
+ a();
686
+ return;
687
+ }
688
+ const E = m.getAttribute("data-tab");
689
+ (E === "inline" || E === "side") && h(E);
690
+ }), b.addEventListener("change", () => {
691
+ f = b.value === "line" ? "line" : "word", a();
692
+ }), v.addEventListener("change", () => {
693
+ g = v.checked, a();
694
+ }), t.querySelector(".rte-version-diff-set-baseline").addEventListener("click", () => {
695
+ w.set(e, e.innerHTML), a(e.innerHTML);
696
+ }), r.addEventListener("keydown", I, !0), r.addEventListener("click", B), document.addEventListener("keydown", y, !0), z = p, ye(t), a();
697
+ }
698
+ function $e(e) {
699
+ V = e, !H && (H = (i) => {
700
+ if (!me(i)) return;
701
+ if (document.querySelector(`.${l}`)) {
702
+ i.preventDefault();
703
+ return;
704
+ }
705
+ if (!!i.target?.closest("input, textarea, select")) return;
706
+ const t = N(void 0, !1);
707
+ if (!t || t.getAttribute("contenteditable") === "false") return;
708
+ i.preventDefault(), i.stopPropagation();
709
+ const o = R.get(t) || V || e;
710
+ re(t, o);
711
+ }, document.addEventListener("keydown", H, !0));
712
+ }
713
+ function Ee() {
714
+ H && (document.removeEventListener("keydown", H, !0), H = null, V = null);
715
+ }
716
+ function we() {
717
+ S || (S = (e) => {
718
+ const n = e.target?.closest($);
719
+ n && (D = n, X(n));
720
+ }, document.addEventListener("focusin", S, !0)), M || (M = (e) => {
721
+ const r = e.target?.closest($);
722
+ r && r.getAttribute("contenteditable") !== "false" && (D = r, X(r));
723
+ }, document.addEventListener("beforeinput", M, !0));
724
+ }
725
+ function Le() {
726
+ S && (document.removeEventListener("focusin", S, !0), S = null), M && (document.removeEventListener("beforeinput", M, !0), M = null);
727
+ }
728
+ const Ce = (e = {}) => {
729
+ const i = ke(e);
730
+ return ve(), {
731
+ name: "versionDiff",
732
+ toolbar: [
733
+ {
734
+ id: "versionDiff",
735
+ label: "Version Diff",
736
+ command: "openVersionDiff",
737
+ 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>'
738
+ }
739
+ ],
740
+ commands: {
741
+ openVersionDiff: (n, r) => {
742
+ const t = N(r);
743
+ return t ? (R.set(t, i), re(t, i, n), !0) : !1;
744
+ },
745
+ setVersionDiffBaseline: (n, r) => {
746
+ const t = N(r);
747
+ if (!t) return !1;
748
+ R.set(t, i);
749
+ const o = typeof n == "string" ? n : typeof n?.html == "string" ? n.html : t.innerHTML;
750
+ return w.set(t, o), !0;
751
+ }
752
+ },
753
+ keymap: {
754
+ "Mod-Alt-d": "openVersionDiff",
755
+ "Mod-Alt-D": "openVersionDiff",
756
+ F8: "openVersionDiff"
757
+ },
758
+ init: () => {
759
+ j += 1, $e(i), we();
760
+ },
761
+ destroy: () => {
762
+ j = Math.max(0, j - 1), j === 0 && (te(), Ee(), Le());
763
+ }
764
+ };
765
+ };
766
+ export {
767
+ Ce as VersionDiffPlugin
768
+ };