@editora/plugins 1.0.8 → 1.0.10

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 (141) hide show
  1. package/README.md +27 -0
  2. package/dist/_commonjsHelpers-6763f629.js +1 -0
  3. package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
  4. package/dist/a11y-checker.cjs.js +12 -12
  5. package/dist/a11y-checker.esm.js +98 -80
  6. package/dist/anchor.cjs.js +12 -12
  7. package/dist/anchor.esm.js +128 -115
  8. package/dist/anchoredPopover-33f1358d.mjs +109 -0
  9. package/dist/anchoredPopover-8151d535.js +1 -0
  10. package/dist/approval-workflow.cjs.js +447 -0
  11. package/dist/approval-workflow.esm.js +1111 -0
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +68 -55
  14. package/dist/blockquote.esm.js +2 -1
  15. package/dist/blocks-library.cjs.js +442 -0
  16. package/dist/blocks-library.esm.js +1384 -0
  17. package/dist/capitalization.esm.js +2 -1
  18. package/dist/checklist.cjs.js +1 -1
  19. package/dist/checklist.esm.js +82 -58
  20. package/dist/citations.cjs.js +548 -0
  21. package/dist/citations.esm.js +1530 -0
  22. package/dist/clear-formatting.cjs.js +1 -1
  23. package/dist/clear-formatting.esm.js +33 -27
  24. package/dist/code-sample.cjs.js +14 -14
  25. package/dist/code-sample.esm.js +93 -82
  26. package/dist/code.cjs.js +32 -32
  27. package/dist/code.esm.js +653 -594
  28. package/dist/comments.cjs.js +6 -6
  29. package/dist/comments.esm.js +158 -116
  30. package/dist/conditional-content.cjs.js +626 -0
  31. package/dist/conditional-content.esm.js +1421 -0
  32. package/dist/content-rules.cjs.js +408 -0
  33. package/dist/content-rules.esm.js +1147 -0
  34. package/dist/data-binding.cjs.js +321 -0
  35. package/dist/data-binding.esm.js +953 -0
  36. package/dist/direction.esm.js +18 -9
  37. package/dist/doc-schema.cjs.js +398 -0
  38. package/dist/doc-schema.esm.js +1378 -0
  39. package/dist/document-manager.cjs.js +1 -1
  40. package/dist/document-manager.esm.js +5 -4
  41. package/dist/documentManager-25b6203c.mjs +9122 -0
  42. package/dist/documentManager-b69e7054.js +17 -0
  43. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
  44. package/dist/embed-iframe.cjs.js +4 -4
  45. package/dist/embed-iframe.esm.js +81 -73
  46. package/dist/emojis.cjs.js +8 -8
  47. package/dist/emojis.esm.js +77 -65
  48. package/dist/enterprise.cjs.js +1 -0
  49. package/dist/enterprise.esm.js +58 -0
  50. package/dist/font-family.cjs.js +1 -1
  51. package/dist/font-family.esm.js +47 -39
  52. package/dist/font-size.cjs.js +1 -1
  53. package/dist/font-size.esm.js +53 -37
  54. package/dist/footnote.cjs.js +2 -2
  55. package/dist/footnote.esm.js +117 -76
  56. package/dist/history.cjs.js +1 -1
  57. package/dist/history.esm.js +92 -70
  58. package/dist/html2canvas.esm-09133e29.js +22 -0
  59. package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
  60. package/dist/indent.cjs.js +1 -1
  61. package/dist/indent.esm.js +24 -12
  62. package/dist/index-656d224b.js +231 -0
  63. package/dist/index-6a8c48bb.js +1 -0
  64. package/dist/index-d027b7e2.mjs +16859 -0
  65. package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-730f2d98.mjs +5775 -0
  68. package/dist/index.es-dd40173b.js +18 -0
  69. package/dist/index.esm.js +124 -93
  70. package/dist/italic.cjs.js +1 -1
  71. package/dist/italic.esm.js +9 -8
  72. package/dist/jspdf.es.min-90db2c97.js +243 -0
  73. package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
  74. package/dist/line-height.cjs.js +1 -1
  75. package/dist/line-height.esm.js +24 -11
  76. package/dist/link.cjs.js +5 -5
  77. package/dist/link.esm.js +30 -24
  78. package/dist/list.cjs.js +1 -1
  79. package/dist/list.esm.js +25 -20
  80. package/dist/lite.cjs.js +1 -1
  81. package/dist/lite.esm.js +61 -59
  82. package/dist/math.cjs.js +21 -21
  83. package/dist/math.esm.js +146 -139
  84. package/dist/media-manager.cjs.js +38 -38
  85. package/dist/media-manager.esm.js +325 -308
  86. package/dist/mentions.cjs.js +105 -0
  87. package/dist/mentions.esm.js +774 -0
  88. package/dist/merge-tag.cjs.js +2 -2
  89. package/dist/merge-tag.esm.js +216 -177
  90. package/dist/page-break.cjs.js +2 -2
  91. package/dist/page-break.esm.js +67 -51
  92. package/dist/pii-redaction.cjs.js +436 -0
  93. package/dist/pii-redaction.esm.js +1447 -0
  94. package/dist/preview.cjs.js +3 -3
  95. package/dist/preview.esm.js +37 -32
  96. package/dist/print.cjs.js +4 -4
  97. package/dist/print.esm.js +20 -17
  98. package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
  99. package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
  100. package/dist/slash-commands.cjs.js +90 -0
  101. package/dist/slash-commands.esm.js +788 -0
  102. package/dist/smart-paste.cjs.js +398 -0
  103. package/dist/smart-paste.esm.js +1444 -0
  104. package/dist/special-characters.cjs.js +7 -7
  105. package/dist/special-characters.esm.js +69 -61
  106. package/dist/spell-check.cjs.js +5 -5
  107. package/dist/spell-check.esm.js +123 -97
  108. package/dist/strikethrough.cjs.js +1 -1
  109. package/dist/strikethrough.esm.js +19 -14
  110. package/dist/style.css +1 -0
  111. package/dist/table.cjs.js +4 -4
  112. package/dist/table.esm.js +225 -191
  113. package/dist/template.cjs.js +11 -11
  114. package/dist/template.esm.js +153 -124
  115. package/dist/text-alignment.cjs.js +1 -1
  116. package/dist/text-alignment.esm.js +27 -21
  117. package/dist/text-color.cjs.js +3 -3
  118. package/dist/text-color.esm.js +87 -70
  119. package/dist/track-changes.cjs.js +77 -0
  120. package/dist/track-changes.esm.js +817 -0
  121. package/dist/translation-workflow.cjs.js +626 -0
  122. package/dist/translation-workflow.esm.js +1794 -0
  123. package/dist/version-diff.cjs.js +362 -0
  124. package/dist/version-diff.esm.js +797 -0
  125. package/index.d.ts +798 -0
  126. package/package.json +114 -9
  127. package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
  128. package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
  129. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  130. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  131. package/dist/documentManager-CTqRftU8.mjs +0 -8369
  132. package/dist/documentManager-Jf0RbSks.js +0 -17
  133. package/dist/html2canvas.esm-B5qzocYs.js +0 -5
  134. package/dist/index-CvJk4DKa.js +0 -221
  135. package/dist/index-D3CycEFU.mjs +0 -16543
  136. package/dist/index-tqLTHcO6.js +0 -1
  137. package/dist/index.es-CE_A4QSm.js +0 -5
  138. package/dist/index.es-DQ78mYYo.mjs +0 -6665
  139. package/dist/jspdf.es.min-BoS80556.js +0 -77
  140. package/dist/plugins.css +0 -1
  141. /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
@@ -0,0 +1,797 @@
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 == null ? void 0 : e.contentElement) instanceof HTMLElement)
28
+ return e.contentElement;
29
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
30
+ const t = e.editorElement;
31
+ if (t.matches($))
32
+ return t;
33
+ const o = t.querySelector($);
34
+ if (o instanceof HTMLElement)
35
+ return o;
36
+ }
37
+ const r = window.getSelection();
38
+ if (r && r.rangeCount > 0) {
39
+ const t = r.getRangeAt(0).startContainer, o = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement, f = o == null ? void 0 : o.closest($);
40
+ if (f)
41
+ return f;
42
+ }
43
+ const n = document.activeElement;
44
+ if (n) {
45
+ if (n.matches($))
46
+ return n;
47
+ const t = n.closest($);
48
+ if (t)
49
+ return t;
50
+ }
51
+ return D && D.isConnected ? D : i ? document.querySelector($) : null;
52
+ }
53
+ function O(e) {
54
+ return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
55
+ }
56
+ function P(e) {
57
+ if (!e)
58
+ return !1;
59
+ const i = e.getAttribute("data-theme") || e.getAttribute("theme");
60
+ if (i && i.toLowerCase() === "dark")
61
+ return !0;
62
+ const r = e.classList;
63
+ return r.contains("dark") || r.contains("editora-theme-dark") || r.contains("rte-theme-dark");
64
+ }
65
+ function Y(e) {
66
+ const i = O(e);
67
+ if (P(i))
68
+ return !0;
69
+ const r = i.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
70
+ return !!(P(r) || P(document.documentElement) || P(document.body));
71
+ }
72
+ function fe(e) {
73
+ const i = document.createElement("textarea");
74
+ return i.innerHTML = e, i.value;
75
+ }
76
+ function W(e) {
77
+ const r = O(e).getAttribute("data-initial-content");
78
+ return r ? fe(r) : e.innerHTML;
79
+ }
80
+ function Z(e) {
81
+ return e.replace(/\r\n?/g, `
82
+ `);
83
+ }
84
+ function J(e) {
85
+ const i = document.createElement("div"), r = e.replace(/<br\s*\/?>/gi, `
86
+ `).replace(/<\/(p|div|h1|h2|h3|h4|h5|h6|li|tr|blockquote|pre|section|article)>/gi, `$&
87
+ `);
88
+ i.innerHTML = r;
89
+ const n = i.textContent || "";
90
+ return Z(n).replace(/\u00a0/g, " ").replace(/\n{3,}/g, `
91
+
92
+ `).trim();
93
+ }
94
+ function Q(e, i, r) {
95
+ let n = Z(e);
96
+ if (r && (n = n.replace(/[ \t]+/g, " ").replace(/\n{3,}/g, `
97
+
98
+ `).trim()), !n)
99
+ return [];
100
+ if (i === "line")
101
+ return n.split(`
102
+ `);
103
+ if (r)
104
+ return n.split(/\s+/).filter(Boolean);
105
+ const t = [], o = n.split(`
106
+ `);
107
+ return o.forEach((f, g) => {
108
+ const c = f.split(/[ \t]+/).filter(Boolean);
109
+ t.push(...c), g < o.length - 1 && t.push(`
110
+ `);
111
+ }), t;
112
+ }
113
+ function de(e, i, r) {
114
+ if (e.length === 0)
115
+ return "";
116
+ if (i === "line")
117
+ return e.join(`
118
+ `);
119
+ if (r)
120
+ return e.join(" ");
121
+ let n = "";
122
+ for (let t = 0; t < e.length; t += 1) {
123
+ const o = e[t];
124
+ if (o === `
125
+ `) {
126
+ n = n.replace(/[ \t]+$/g, ""), n += `
127
+ `;
128
+ continue;
129
+ }
130
+ n.length > 0 && !n.endsWith(`
131
+ `) && (n += " "), n += o;
132
+ }
133
+ return n;
134
+ }
135
+ function ce(e, i, r) {
136
+ const n = [];
137
+ return e.forEach((t) => {
138
+ const o = n[n.length - 1];
139
+ if (o && o.type === t.type) {
140
+ o.tokens.push(t.token);
141
+ return;
142
+ }
143
+ n.push({ type: t.type, tokens: [t.token] });
144
+ }), n.map((t) => ({
145
+ type: t.type,
146
+ value: de(t.tokens, i, r),
147
+ count: t.tokens.length
148
+ }));
149
+ }
150
+ function ue(e, i) {
151
+ let r = 0;
152
+ for (; r < e.length && r < i.length && e[r] === i[r]; )
153
+ r += 1;
154
+ let n = e.length - 1, t = i.length - 1;
155
+ for (; n >= r && t >= r && e[n] === i[t]; )
156
+ n -= 1, t -= 1;
157
+ const o = e.slice(0, r), f = n < e.length - 1 ? e.slice(n + 1) : [], g = r <= n ? e.slice(r, n + 1) : [], c = r <= t ? i.slice(r, t + 1) : [];
158
+ return { prefix: o, suffix: f, aMiddle: g, bMiddle: c };
159
+ }
160
+ function pe(e, i, r, n, t, o) {
161
+ if (e.length === 0 && i.length === 0)
162
+ return { segments: [], insertedCount: 0, deletedCount: 0, equalCount: 0, usedFallback: !1 };
163
+ const { prefix: f, suffix: g, aMiddle: c, bMiddle: b } = ue(e, i);
164
+ let v = [];
165
+ f.forEach((a) => v.push({ type: "equal", token: a }));
166
+ const F = c.length * b.length, T = c.length > o || b.length > o || F > t;
167
+ if (T)
168
+ c.forEach((a) => v.push({ type: "delete", token: a })), b.forEach((a) => v.push({ type: "insert", token: a }));
169
+ else {
170
+ const a = Array.from({ length: c.length + 1 }, () => new Uint32Array(b.length + 1));
171
+ for (let k = c.length - 1; k >= 0; k -= 1) {
172
+ const A = a[k], I = a[k + 1];
173
+ for (let x = b.length - 1; x >= 0; x -= 1)
174
+ A[x] = c[k] === b[x] ? I[x + 1] + 1 : Math.max(I[x], A[x + 1]);
175
+ }
176
+ let h = 0, p = 0;
177
+ for (; h < c.length && p < b.length; )
178
+ 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);
179
+ for (; h < c.length; )
180
+ v.push({ type: "delete", token: c[h] }), h += 1;
181
+ for (; p < b.length; )
182
+ v.push({ type: "insert", token: b[p] }), p += 1;
183
+ }
184
+ g.forEach((a) => v.push({ type: "equal", token: a }));
185
+ const q = ce(v, r, n);
186
+ let B = 0, L = 0, K = 0;
187
+ return q.forEach((a) => {
188
+ a.type === "insert" && (B += a.count), a.type === "delete" && (L += a.count), a.type === "equal" && (K += a.count);
189
+ }), {
190
+ segments: q,
191
+ insertedCount: B,
192
+ deletedCount: L,
193
+ equalCount: K,
194
+ usedFallback: T
195
+ };
196
+ }
197
+ function ee(e) {
198
+ return u(e.value).replace(/\n/g, `
199
+ `);
200
+ }
201
+ function be(e, i) {
202
+ return e.length === 0 ? `<p class="rte-version-diff-empty">${u(i.noChanges)}</p>` : e.map((r) => `<span class="${r.type === "equal" ? "rte-version-diff-equal" : r.type === "insert" ? "rte-version-diff-insert" : "rte-version-diff-delete"}">${ee(r)}</span>`).join("");
203
+ }
204
+ function he(e, i) {
205
+ if (e.length === 0) {
206
+ const t = `<p class="rte-version-diff-empty">${u(i.noChanges)}</p>`;
207
+ return { baselineHtml: t, currentHtml: t };
208
+ }
209
+ const r = [], n = [];
210
+ return e.forEach((t) => {
211
+ const o = ee(t);
212
+ if (t.type === "equal") {
213
+ r.push(`<span class="rte-version-diff-equal">${o}</span>`), n.push(`<span class="rte-version-diff-equal">${o}</span>`);
214
+ return;
215
+ }
216
+ if (t.type === "delete") {
217
+ r.push(`<span class="rte-version-diff-delete">${o}</span>`);
218
+ return;
219
+ }
220
+ n.push(`<span class="rte-version-diff-insert">${o}</span>`);
221
+ }), {
222
+ baselineHtml: r.join(""),
223
+ currentHtml: n.join("")
224
+ };
225
+ }
226
+ function me(e) {
227
+ const i = e.metaKey || e.ctrlKey, n = (typeof e.key == "string" ? e.key : "").toLowerCase(), t = typeof e.code == "string" ? e.code.toLowerCase() : "", o = i && e.altKey && !e.shiftKey && (n === "d" || t === "keyd"), f = !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && (n === "f8" || t === "f8");
228
+ return o || f;
229
+ }
230
+ function ve() {
231
+ if (typeof document > "u" || document.getElementById(U))
232
+ return;
233
+ const e = document.createElement("style");
234
+ e.id = U, e.textContent = `
235
+ .${l} {
236
+ position: fixed;
237
+ inset: 0;
238
+ background: rgba(15, 23, 42, 0.55);
239
+ z-index: 2147483646;
240
+ display: flex;
241
+ align-items: center;
242
+ justify-content: center;
243
+ padding: 20px;
244
+ }
245
+
246
+ .rte-version-diff-dialog {
247
+ width: min(980px, 96vw);
248
+ max-height: min(90vh, 860px);
249
+ background: #ffffff;
250
+ color: #0f172a;
251
+ border: 1px solid #d7dee8;
252
+ border-radius: 8px;
253
+ display: flex;
254
+ flex-direction: column;
255
+ box-shadow: 0 24px 48px rgba(15, 23, 42, 0.3);
256
+ overflow: hidden;
257
+ }
258
+
259
+ .rte-version-diff-header,
260
+ .rte-version-diff-footer {
261
+ padding: 12px 14px;
262
+ border-bottom: 1px solid #e2e8f0;
263
+ background: #f8fafc;
264
+ display: flex;
265
+ align-items: center;
266
+ gap: 10px;
267
+ flex-wrap: wrap;
268
+ }
269
+
270
+ .rte-version-diff-footer {
271
+ border-top: 1px solid #e2e8f0;
272
+ border-bottom: none;
273
+ justify-content: space-between;
274
+ }
275
+
276
+ .rte-version-diff-title {
277
+ margin: 0;
278
+ font-size: 16px;
279
+ font-weight: 700;
280
+ flex: 1;
281
+ }
282
+
283
+ .rte-version-diff-controls {
284
+ display: flex;
285
+ align-items: center;
286
+ gap: 10px;
287
+ flex-wrap: wrap;
288
+ }
289
+
290
+ .rte-version-diff-select,
291
+ .rte-version-diff-btn {
292
+ border: 1px solid #cbd5e1;
293
+ background: #ffffff;
294
+ color: #0f172a;
295
+ border-radius: 6px;
296
+ min-height: 34px;
297
+ padding: 6px 10px;
298
+ font-size: 13px;
299
+ cursor: pointer;
300
+ }
301
+
302
+ .rte-version-diff-btn:hover,
303
+ .rte-version-diff-btn:focus-visible,
304
+ .rte-version-diff-select:focus-visible {
305
+ outline: none;
306
+ border-color: #3b82f6;
307
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
308
+ }
309
+
310
+ .rte-version-diff-btn-primary {
311
+ background: #2563eb;
312
+ border-color: #2563eb;
313
+ color: #ffffff;
314
+ }
315
+
316
+ .rte-version-diff-btn-primary:hover {
317
+ background: #1d4ed8;
318
+ }
319
+
320
+ .rte-version-diff-close-btn {
321
+ border: 1px solid #cbd5e1;
322
+ border-radius: 6px;
323
+ min-height: 34px;
324
+ min-width: 34px;
325
+ width: 34px;
326
+ height: 34px;
327
+ padding: 0;
328
+ display: inline-flex;
329
+ align-items: center;
330
+ justify-content: center;
331
+ background: #ffffff;
332
+ color: #0f172a;
333
+ font-size: 16px;
334
+ line-height: 1;
335
+ font-weight: 600;
336
+ }
337
+
338
+ .rte-version-diff-close-btn:hover,
339
+ .rte-version-diff-close-btn:focus-visible {
340
+ border-color: #3b82f6;
341
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
342
+ background: #ffffff;
343
+ outline: none;
344
+ }
345
+
346
+ .rte-version-diff-tabs {
347
+ display: flex;
348
+ gap: 6px;
349
+ border-bottom: 1px solid #e2e8f0;
350
+ background: #f8fafc;
351
+ padding: 8px 14px;
352
+ }
353
+
354
+ .rte-version-diff-tab {
355
+ border: 1px solid #cbd5e1;
356
+ background: #ffffff;
357
+ color: #0f172a;
358
+ border-radius: 6px;
359
+ min-height: 32px;
360
+ padding: 4px 10px;
361
+ font-size: 13px;
362
+ cursor: pointer;
363
+ }
364
+
365
+ .rte-version-diff-tab[aria-selected="true"] {
366
+ background: #dbeafe;
367
+ border-color: #60a5fa;
368
+ color: #1e3a8a;
369
+ }
370
+
371
+ .rte-version-diff-body {
372
+ flex: 1;
373
+ overflow: auto;
374
+ padding: 10px 14px 14px;
375
+ background: #ffffff;
376
+ }
377
+
378
+ .rte-version-diff-summary {
379
+ font-size: 12px;
380
+ color: #475569;
381
+ margin-bottom: 10px;
382
+ display: flex;
383
+ gap: 14px;
384
+ flex-wrap: wrap;
385
+ }
386
+
387
+ .rte-version-diff-panel {
388
+ display: none;
389
+ }
390
+
391
+ .rte-version-diff-panel.active {
392
+ display: block;
393
+ }
394
+
395
+ .rte-version-diff-inline,
396
+ .rte-version-diff-side-pane {
397
+ border: 1px solid #dbe3ec;
398
+ border-radius: 6px;
399
+ padding: 10px;
400
+ min-height: 140px;
401
+ max-height: 50vh;
402
+ overflow: auto;
403
+ white-space: pre-wrap;
404
+ word-break: break-word;
405
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
406
+ font-size: 12px;
407
+ line-height: 1.5;
408
+ background: #ffffff;
409
+ }
410
+
411
+ .rte-version-diff-side-grid {
412
+ display: grid;
413
+ grid-template-columns: 1fr 1fr;
414
+ gap: 10px;
415
+ }
416
+
417
+ .rte-version-diff-pane-title {
418
+ margin: 0 0 6px;
419
+ font-size: 12px;
420
+ font-weight: 700;
421
+ color: #334155;
422
+ }
423
+
424
+ .rte-version-diff-equal { color: inherit; }
425
+ .rte-version-diff-insert {
426
+ background: rgba(22, 163, 74, 0.18);
427
+ color: #14532d;
428
+ border-radius: 2px;
429
+ }
430
+ .rte-version-diff-delete {
431
+ background: rgba(220, 38, 38, 0.18);
432
+ color: #7f1d1d;
433
+ text-decoration: line-through;
434
+ border-radius: 2px;
435
+ }
436
+
437
+ .rte-version-diff-empty {
438
+ margin: 0;
439
+ color: #64748b;
440
+ font-size: 13px;
441
+ }
442
+
443
+ ${d} .rte-version-diff-dialog,
444
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-dialog {
445
+ background: #1f2937;
446
+ color: #e5e7eb;
447
+ border-color: #334155;
448
+ }
449
+
450
+ ${d} .rte-version-diff-header,
451
+ ${d} .rte-version-diff-footer,
452
+ ${d} .rte-version-diff-tabs,
453
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-header,
454
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-footer,
455
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-tabs {
456
+ background: #111827;
457
+ border-color: #334155;
458
+ }
459
+
460
+ ${d} .rte-version-diff-body,
461
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-body {
462
+ background: #1f2937;
463
+ }
464
+
465
+ ${d} .rte-version-diff-select,
466
+ ${d} .rte-version-diff-btn,
467
+ ${d} .rte-version-diff-tab,
468
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-select,
469
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-btn,
470
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-tab {
471
+ background: #0f172a;
472
+ color: #e5e7eb;
473
+ border-color: #475569;
474
+ }
475
+
476
+ ${d} .rte-version-diff-close-btn,
477
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-close-btn {
478
+ background: #0f172a;
479
+ border-color: #475569;
480
+ color: #e2e8f0;
481
+ }
482
+
483
+ ${d} .rte-version-diff-close-btn:hover,
484
+ ${d} .rte-version-diff-close-btn:focus-visible,
485
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-close-btn:hover,
486
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-close-btn:focus-visible {
487
+ border-color: #60a5fa;
488
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
489
+ outline: none;
490
+ }
491
+
492
+ ${d} .rte-version-diff-tab[aria-selected="true"],
493
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-tab[aria-selected="true"] {
494
+ background: #1e3a8a;
495
+ border-color: #3b82f6;
496
+ color: #dbeafe;
497
+ }
498
+
499
+ ${d} .rte-version-diff-inline,
500
+ ${d} .rte-version-diff-side-pane,
501
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-inline,
502
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-side-pane {
503
+ background: #0f172a;
504
+ border-color: #334155;
505
+ color: #e5e7eb;
506
+ }
507
+
508
+ ${d} .rte-version-diff-pane-title,
509
+ ${d} .rte-version-diff-summary,
510
+ ${d} .rte-version-diff-empty,
511
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-pane-title,
512
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-summary,
513
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-empty {
514
+ color: #94a3b8;
515
+ }
516
+
517
+ ${d} .rte-version-diff-insert,
518
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-insert {
519
+ background: rgba(22, 163, 74, 0.25);
520
+ color: #bbf7d0;
521
+ }
522
+
523
+ ${d} .rte-version-diff-delete,
524
+ .${l}.rte-version-diff-theme-dark .rte-version-diff-delete {
525
+ background: rgba(220, 38, 38, 0.25);
526
+ color: #fecaca;
527
+ }
528
+ :is(${d}) .rte-toolbar-item .rte-toolbar-button[data-command="openVersionDiff"] svg{
529
+ fill: none;
530
+ }
531
+ `, document.head.appendChild(e);
532
+ }
533
+ async function ge(e, i, r) {
534
+ if (r != null)
535
+ return r;
536
+ if (typeof i.getBaselineHtml == "function") {
537
+ const o = O(e), f = await Promise.resolve(i.getBaselineHtml({ editor: e, editorRoot: o }));
538
+ if (typeof f == "string")
539
+ return f;
540
+ }
541
+ const n = w.get(e);
542
+ if (typeof n == "string")
543
+ return n;
544
+ if (typeof i.baselineHtml == "string")
545
+ return i.baselineHtml;
546
+ const t = W(e);
547
+ return w.set(e, t), t;
548
+ }
549
+ function ye(e) {
550
+ const i = e.querySelector(
551
+ 'button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
552
+ );
553
+ i == null || i.focus();
554
+ }
555
+ function ke(e, i) {
556
+ if (e.key !== "Tab")
557
+ return;
558
+ const r = Array.from(i.querySelectorAll(
559
+ 'button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
560
+ )).filter((f) => !f.hasAttribute("disabled"));
561
+ if (r.length === 0)
562
+ return;
563
+ const n = r[0], t = r[r.length - 1], o = document.activeElement;
564
+ e.shiftKey && o === n ? (e.preventDefault(), t.focus()) : !e.shiftKey && o === t && (e.preventDefault(), n.focus());
565
+ }
566
+ function te() {
567
+ z && (z(), z = null);
568
+ }
569
+ function X(e) {
570
+ !e || w.has(e) || w.set(e, W(e));
571
+ }
572
+ function xe(e) {
573
+ return {
574
+ baselineHtml: e.baselineHtml,
575
+ getBaselineHtml: e.getBaselineHtml,
576
+ mode: e.mode || "word",
577
+ ignoreWhitespace: e.ignoreWhitespace !== !1,
578
+ maxTokens: Math.max(200, e.maxTokens ?? 1200),
579
+ maxMatrixSize: Math.max(5e4, e.maxMatrixSize ?? 1e6),
580
+ labels: le(e.labels)
581
+ };
582
+ }
583
+ function re(e, i, r) {
584
+ te(), D = e, R.set(e, i);
585
+ const n = document.createElement("div");
586
+ n.className = l, Y(e) && n.classList.add("rte-version-diff-theme-dark");
587
+ const t = document.createElement("section");
588
+ t.className = "rte-version-diff-dialog", t.setAttribute("role", "dialog"), t.setAttribute("aria-modal", "true"), t.setAttribute("aria-labelledby", "rte-version-diff-title");
589
+ const o = i.labels;
590
+ let f = (r == null ? void 0 : r.mode) || i.mode, g = (r == null ? void 0 : r.ignoreWhitespace) ?? i.ignoreWhitespace, c = "inline";
591
+ t.innerHTML = `
592
+ <header class="rte-version-diff-header">
593
+ <h2 id="rte-version-diff-title" class="rte-version-diff-title">${u(o.title)}</h2>
594
+ <div class="rte-version-diff-controls">
595
+ <label>
596
+ <span>${u(o.mode)}:</span>
597
+ <select class="rte-version-diff-select" aria-label="${u(o.mode)}">
598
+ <option value="word">Word</option>
599
+ <option value="line">Line</option>
600
+ </select>
601
+ </label>
602
+ <label class="rte-version-diff-checkbox">
603
+ <input type="checkbox" class="rte-version-diff-ignore-ws" ${g ? "checked" : ""}>
604
+ ${u(o.ignoreWhitespace)}
605
+ </label>
606
+ <button type="button" class="rte-version-diff-btn rte-version-diff-set-baseline" aria-label="${u(o.setBaseline)}">${u(o.setBaseline)}</button>
607
+ <button type="button" class="rte-version-diff-btn" data-action="refresh" aria-label="${u(o.refresh)}">${u(o.refresh)}</button>
608
+ <button type="button" class="rte-version-diff-btn rte-version-diff-close-btn" data-action="close" aria-label="${u(o.close)}">✕</button>
609
+ </div>
610
+ </header>
611
+
612
+ <div class="rte-version-diff-tabs" role="tablist" aria-label="Diff views">
613
+ <button type="button" role="tab" class="rte-version-diff-tab" data-tab="inline" aria-selected="true">${u(o.tabInline)}</button>
614
+ <button type="button" role="tab" class="rte-version-diff-tab" data-tab="side" aria-selected="false">${u(o.tabSideBySide)}</button>
615
+ </div>
616
+
617
+ <main class="rte-version-diff-body">
618
+ <div class="rte-version-diff-summary" aria-live="polite"></div>
619
+ <section class="rte-version-diff-panel active" data-panel="inline" role="tabpanel">
620
+ <div class="rte-version-diff-inline" aria-label="Inline diff result"></div>
621
+ </section>
622
+ <section class="rte-version-diff-panel" data-panel="side" role="tabpanel">
623
+ <div class="rte-version-diff-side-grid">
624
+ <div>
625
+ <h3 class="rte-version-diff-pane-title">${u(o.baseline)}</h3>
626
+ <div class="rte-version-diff-side-pane" data-side="baseline" aria-label="${u(o.baseline)}"></div>
627
+ </div>
628
+ <div>
629
+ <h3 class="rte-version-diff-pane-title">${u(o.current)}</h3>
630
+ <div class="rte-version-diff-side-pane" data-side="current" aria-label="${u(o.current)}"></div>
631
+ </div>
632
+ </div>
633
+ </section>
634
+ </main>
635
+
636
+ <footer class="rte-version-diff-footer">
637
+ <small>Shortcut: Ctrl/Cmd + Alt + D (fallback: F8)</small>
638
+ <small>Esc: close</small>
639
+ </footer>
640
+ `, n.appendChild(t), document.body.appendChild(n);
641
+ const b = t.querySelector(".rte-version-diff-select");
642
+ b.value = f;
643
+ 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"]'), B = t.querySelector('[data-side="current"]');
644
+ let L = 0;
645
+ const K = () => {
646
+ const s = `<p class="rte-version-diff-empty">${u(o.loading)}</p>`;
647
+ T.innerHTML = s, q.innerHTML = s, B.innerHTML = s, F.textContent = "";
648
+ }, a = async (s) => {
649
+ L += 1;
650
+ const m = L;
651
+ n.classList.toggle("rte-version-diff-theme-dark", Y(e)), K();
652
+ const y = e.innerHTML;
653
+ let E = "";
654
+ try {
655
+ E = await ge(e, i, s ?? (r == null ? void 0 : r.baselineHtml));
656
+ } catch {
657
+ E = w.get(e) ?? W(e);
658
+ }
659
+ if (m !== L || !n.isConnected)
660
+ return;
661
+ const ne = J(E), ie = J(y), oe = Q(ne, f, g), se = Q(ie, f, g), C = pe(
662
+ oe,
663
+ se,
664
+ f,
665
+ g,
666
+ i.maxMatrixSize,
667
+ i.maxTokens
668
+ ), _ = he(C.segments, o);
669
+ T.innerHTML = be(C.segments, o), q.innerHTML = _.baselineHtml, B.innerHTML = _.currentHtml;
670
+ const G = [
671
+ `+${C.insertedCount} inserted`,
672
+ `-${C.deletedCount} deleted`,
673
+ `${C.equalCount} unchanged`
674
+ ];
675
+ C.usedFallback && G.push(o.largeDocFallback), F.textContent = G.join(" | ");
676
+ }, h = (s) => {
677
+ c = s, t.querySelectorAll(".rte-version-diff-tab").forEach((m) => {
678
+ const y = m.getAttribute("data-tab") === s;
679
+ m.setAttribute("aria-selected", y ? "true" : "false"), m.tabIndex = y ? 0 : -1;
680
+ }), t.querySelectorAll(".rte-version-diff-panel").forEach((m) => {
681
+ m.classList.toggle("active", m.getAttribute("data-panel") === s);
682
+ });
683
+ }, p = () => {
684
+ 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 });
685
+ }, k = (s) => {
686
+ s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), p());
687
+ }, A = (s) => {
688
+ s.target === n && p();
689
+ }, I = (s) => {
690
+ if (s.key === "Escape") {
691
+ s.preventDefault(), p();
692
+ return;
693
+ }
694
+ if (ke(s, t), s.target && s.target.classList.contains("rte-version-diff-tab") && (s.key === "ArrowRight" || s.key === "ArrowLeft")) {
695
+ s.preventDefault();
696
+ const m = c === "inline" ? "side" : "inline";
697
+ h(m);
698
+ const y = t.querySelector(`.rte-version-diff-tab[data-tab="${m}"]`);
699
+ y == null || y.focus();
700
+ }
701
+ };
702
+ t.addEventListener("click", (s) => {
703
+ const m = s.target, y = m.getAttribute("data-action");
704
+ if (y === "close") {
705
+ p();
706
+ return;
707
+ }
708
+ if (y === "refresh") {
709
+ a();
710
+ return;
711
+ }
712
+ const E = m.getAttribute("data-tab");
713
+ (E === "inline" || E === "side") && h(E);
714
+ }), b.addEventListener("change", () => {
715
+ f = b.value === "line" ? "line" : "word", a();
716
+ }), v.addEventListener("change", () => {
717
+ g = v.checked, a();
718
+ }), t.querySelector(".rte-version-diff-set-baseline").addEventListener("click", () => {
719
+ w.set(e, e.innerHTML), a(e.innerHTML);
720
+ }), n.addEventListener("keydown", I, !0), n.addEventListener("click", A), document.addEventListener("keydown", k, !0), z = p, ye(t), a();
721
+ }
722
+ function $e(e) {
723
+ V = e, !H && (H = (i) => {
724
+ if (!me(i))
725
+ return;
726
+ if (document.querySelector(`.${l}`)) {
727
+ i.preventDefault();
728
+ return;
729
+ }
730
+ const r = i.target;
731
+ if (!!(r != null && r.closest("input, textarea, select")))
732
+ return;
733
+ const t = N(void 0, !1);
734
+ if (!t || t.getAttribute("contenteditable") === "false")
735
+ return;
736
+ i.preventDefault(), i.stopPropagation();
737
+ const o = R.get(t) || V || e;
738
+ re(t, o);
739
+ }, document.addEventListener("keydown", H, !0));
740
+ }
741
+ function Ee() {
742
+ H && (document.removeEventListener("keydown", H, !0), H = null, V = null);
743
+ }
744
+ function we() {
745
+ S || (S = (e) => {
746
+ const i = e.target, r = i == null ? void 0 : i.closest($);
747
+ r && (D = r, X(r));
748
+ }, document.addEventListener("focusin", S, !0)), M || (M = (e) => {
749
+ const r = e.target, n = r == null ? void 0 : r.closest($);
750
+ n && n.getAttribute("contenteditable") !== "false" && (D = n, X(n));
751
+ }, document.addEventListener("beforeinput", M, !0));
752
+ }
753
+ function Le() {
754
+ S && (document.removeEventListener("focusin", S, !0), S = null), M && (document.removeEventListener("beforeinput", M, !0), M = null);
755
+ }
756
+ const Ce = (e = {}) => {
757
+ const i = xe(e);
758
+ return ve(), {
759
+ name: "versionDiff",
760
+ toolbar: [
761
+ {
762
+ id: "versionDiff",
763
+ label: "Version Diff",
764
+ command: "openVersionDiff",
765
+ 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>'
766
+ }
767
+ ],
768
+ commands: {
769
+ openVersionDiff: (r, n) => {
770
+ const t = N(n);
771
+ return t ? (R.set(t, i), re(t, i, r), !0) : !1;
772
+ },
773
+ setVersionDiffBaseline: (r, n) => {
774
+ const t = N(n);
775
+ if (!t)
776
+ return !1;
777
+ R.set(t, i);
778
+ const o = typeof r == "string" ? r : typeof (r == null ? void 0 : r.html) == "string" ? r.html : t.innerHTML;
779
+ return w.set(t, o), !0;
780
+ }
781
+ },
782
+ keymap: {
783
+ "Mod-Alt-d": "openVersionDiff",
784
+ "Mod-Alt-D": "openVersionDiff",
785
+ F8: "openVersionDiff"
786
+ },
787
+ init: () => {
788
+ j += 1, $e(i), we();
789
+ },
790
+ destroy: () => {
791
+ j = Math.max(0, j - 1), j === 0 && (te(), Ee(), Le());
792
+ }
793
+ };
794
+ };
795
+ export {
796
+ Ce as VersionDiffPlugin
797
+ };