@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,1444 @@
1
+ const v = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", se = "__editoraCommandEditorRoot", le = "rte-smart-paste-styles", u = "rte-smart-paste-panel", x = "smart-paste", E = "smartPaste", k = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', Ee = typeof NodeFilter < "u" ? NodeFilter.SHOW_COMMENT : 128, ie = "__editoraSmartPasteHandled", ke = /* @__PURE__ */ new Set([
2
+ "script",
3
+ "style",
4
+ "meta",
5
+ "link",
6
+ "object",
7
+ "embed",
8
+ "iframe",
9
+ "svg",
10
+ "canvas",
11
+ "math",
12
+ "form",
13
+ "input",
14
+ "button",
15
+ "textarea",
16
+ "select",
17
+ "option"
18
+ ]), Ce = /* @__PURE__ */ new Set(["table", "thead", "tbody", "tfoot", "tr", "td", "th", "colgroup", "col"]), Te = /* @__PURE__ */ new Set(["span", "font"]), Ae = /^(https?:|mailto:|tel:|#|\/)/i, Pe = /^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i, Le = /* @__PURE__ */ new Set([
19
+ "color",
20
+ "background-color",
21
+ "font-weight",
22
+ "font-style",
23
+ "text-decoration",
24
+ "text-align",
25
+ "font-size",
26
+ "font-family",
27
+ "line-height",
28
+ "letter-spacing",
29
+ "word-spacing",
30
+ "white-space",
31
+ "vertical-align",
32
+ "margin-left",
33
+ "margin-right",
34
+ "margin-top",
35
+ "margin-bottom",
36
+ "padding-left",
37
+ "padding-right",
38
+ "padding-top",
39
+ "padding-bottom",
40
+ "text-indent",
41
+ "border",
42
+ "border-top",
43
+ "border-right",
44
+ "border-bottom",
45
+ "border-left",
46
+ "border-color",
47
+ "border-width",
48
+ "border-style",
49
+ "list-style-type"
50
+ ]), we = {
51
+ panelTitle: "Smart Paste",
52
+ panelAriaLabel: "Smart paste panel",
53
+ enabledText: "Smart paste is enabled",
54
+ disabledText: "Smart paste is disabled",
55
+ toggleOnText: "Disable Smart Paste",
56
+ toggleOffText: "Enable Smart Paste",
57
+ cycleProfileText: "Cycle Profile",
58
+ profileLabel: "Profile",
59
+ fidelityText: "Fidelity",
60
+ balancedText: "Balanced",
61
+ plainText: "Plain Text",
62
+ lastPasteHeading: "Last Paste Result",
63
+ lastPasteEmptyText: "Paste content to see cleanup metrics.",
64
+ lastPasteSourceLabel: "Source",
65
+ lastPasteProfileLabel: "Profile",
66
+ lastPasteRemovedLabel: "Removed",
67
+ lastPasteCharsLabel: "Output Chars",
68
+ closeText: "Close",
69
+ shortcutText: "Shortcuts: Ctrl/Cmd+Alt+Shift+S/V/G",
70
+ readonlyMessage: "Editor is read-only. Smart paste was skipped."
71
+ }, Y = {
72
+ fidelity: {
73
+ keepStyles: !0,
74
+ keepClasses: !1,
75
+ keepDataAttributes: !1,
76
+ preserveTables: !0
77
+ },
78
+ balanced: {
79
+ keepStyles: !1,
80
+ keepClasses: !1,
81
+ keepDataAttributes: !1,
82
+ preserveTables: !0
83
+ },
84
+ plain: {
85
+ keepStyles: !1,
86
+ keepClasses: !1,
87
+ keepDataAttributes: !1,
88
+ preserveTables: !1
89
+ }
90
+ }, d = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new Set();
91
+ let W = 0, $e = 0, O = null, b = null, L = null, w = null, A = null, $ = null;
92
+ function X(e) {
93
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
94
+ }
95
+ function Me(e) {
96
+ return e.replace(/\u00A0/g, " ").replace(/\r\n?/g, `
97
+ `);
98
+ }
99
+ function H(e) {
100
+ return e === "balanced" || e === "plain" ? e : "fidelity";
101
+ }
102
+ function Z(e, t) {
103
+ return {
104
+ keepStyles: (e == null ? void 0 : e.keepStyles) ?? t.keepStyles,
105
+ keepClasses: (e == null ? void 0 : e.keepClasses) ?? t.keepClasses,
106
+ keepDataAttributes: (e == null ? void 0 : e.keepDataAttributes) ?? t.keepDataAttributes,
107
+ preserveTables: (e == null ? void 0 : e.preserveTables) ?? t.preserveTables
108
+ };
109
+ }
110
+ function V(e = {}) {
111
+ const t = e.profileOptions || {};
112
+ return {
113
+ enabled: e.enabled !== !1,
114
+ defaultProfile: H(e.defaultProfile),
115
+ maxHtmlLength: Math.max(8e3, Math.min(8e5, Number(e.maxHtmlLength ?? 22e4))),
116
+ removeComments: e.removeComments !== !1,
117
+ normalizeWhitespace: e.normalizeWhitespace !== !1,
118
+ labels: {
119
+ ...we,
120
+ ...e.labels || {}
121
+ },
122
+ normalizeText: e.normalizeText || Me,
123
+ profileOptions: {
124
+ fidelity: Z(t.fidelity, Y.fidelity),
125
+ balanced: Z(t.balanced, Y.balanced),
126
+ plain: Z(t.plain, Y.plain)
127
+ }
128
+ };
129
+ }
130
+ function ce(e) {
131
+ return {
132
+ enabled: e.enabled,
133
+ defaultProfile: e.defaultProfile,
134
+ maxHtmlLength: e.maxHtmlLength,
135
+ removeComments: e.removeComments,
136
+ normalizeWhitespace: e.normalizeWhitespace,
137
+ labels: { ...e.labels },
138
+ normalizeText: e.normalizeText,
139
+ profileOptions: {
140
+ fidelity: { ...e.profileOptions.fidelity },
141
+ balanced: { ...e.profileOptions.balanced },
142
+ plain: { ...e.profileOptions.plain }
143
+ }
144
+ };
145
+ }
146
+ function te(e) {
147
+ return e.closest(ee) || e;
148
+ }
149
+ function D(e) {
150
+ if (!e)
151
+ return null;
152
+ if (e.matches(v))
153
+ return e;
154
+ const t = e.querySelector(v);
155
+ return t instanceof HTMLElement ? t : null;
156
+ }
157
+ function Oe() {
158
+ if (typeof window > "u")
159
+ return null;
160
+ const e = window[se];
161
+ if (!(e instanceof HTMLElement))
162
+ return null;
163
+ window[se] = null;
164
+ const t = D(e);
165
+ if (t)
166
+ return t;
167
+ const a = e.closest(ee);
168
+ if (a) {
169
+ const n = D(a);
170
+ if (n)
171
+ return n;
172
+ }
173
+ const r = e.closest(v);
174
+ return r instanceof HTMLElement ? r : null;
175
+ }
176
+ function Re(e) {
177
+ const t = e.closest("[data-editora-editor]");
178
+ if (t && D(t) === e)
179
+ return t;
180
+ let a = e;
181
+ for (; a; ) {
182
+ if (a.matches(ee) && (a === e || D(a) === e))
183
+ return a;
184
+ a = a.parentElement;
185
+ }
186
+ return te(e);
187
+ }
188
+ function pe(e) {
189
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
190
+ }
191
+ function T(e, t = !0, a = !0) {
192
+ if (j(), (e == null ? void 0 : e.contentElement) instanceof HTMLElement)
193
+ return e.contentElement;
194
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
195
+ const s = D(e.editorElement);
196
+ if (s)
197
+ return s;
198
+ }
199
+ const r = Oe();
200
+ if (r)
201
+ return r;
202
+ const n = window.getSelection();
203
+ if (n && n.rangeCount > 0) {
204
+ const s = pe(n.getRangeAt(0).startContainer), l = s == null ? void 0 : s.closest(v);
205
+ if (l)
206
+ return l;
207
+ }
208
+ const o = document.activeElement;
209
+ if (o) {
210
+ if (o.matches(v))
211
+ return o;
212
+ const s = o.closest(v);
213
+ if (s)
214
+ return s;
215
+ }
216
+ if (a) {
217
+ if (b && b.isConnected)
218
+ return b;
219
+ b && !b.isConnected && (b = null);
220
+ }
221
+ return t ? document.querySelector(v) : null;
222
+ }
223
+ function ze(e) {
224
+ const t = e.target;
225
+ if (t) {
226
+ const r = t.closest(v);
227
+ if (r)
228
+ return r;
229
+ }
230
+ const a = window.getSelection();
231
+ if (a && a.rangeCount > 0) {
232
+ const r = pe(a.getRangeAt(0).startContainer), n = r == null ? void 0 : r.closest(v);
233
+ if (n)
234
+ return n;
235
+ }
236
+ return null;
237
+ }
238
+ function B(e) {
239
+ return e ? (e.getAttribute("data-theme") || e.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : e.classList.contains("dark") || e.classList.contains("editora-theme-dark") || e.classList.contains("rte-theme-dark") : !1;
240
+ }
241
+ function _e(e) {
242
+ const t = te(e);
243
+ if (B(t))
244
+ return !0;
245
+ const a = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
246
+ return B(a) ? !0 : B(document.documentElement) || B(document.body);
247
+ }
248
+ function G(e, t) {
249
+ e.classList.remove("rte-smart-paste-theme-dark"), _e(t) && e.classList.add("rte-smart-paste-theme-dark");
250
+ }
251
+ function de(e) {
252
+ return e.getAttribute("contenteditable") === "false" || e.getAttribute("data-readonly") === "true";
253
+ }
254
+ function N(e, t, a) {
255
+ const r = Re(e);
256
+ Array.from(
257
+ r.querySelectorAll(
258
+ `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
259
+ )
260
+ ).forEach((o) => {
261
+ o.classList.toggle("active", a), o.setAttribute("data-active", a ? "true" : "false"), o.setAttribute("aria-pressed", a ? "true" : "false");
262
+ });
263
+ }
264
+ function m(e, t) {
265
+ d.has(e) || d.set(e, t);
266
+ let a = M.get(e);
267
+ return a || (a = {
268
+ enabled: t.enabled,
269
+ profile: t.defaultProfile,
270
+ lastReport: null
271
+ }, M.set(e, a)), Qe(e), _.add(e), a;
272
+ }
273
+ function me(e) {
274
+ const t = F.get(e);
275
+ t && (e.removeEventListener("paste", t, !0), F.delete(e));
276
+ }
277
+ function be(e) {
278
+ var t;
279
+ me(e), (t = h.get(e)) == null || t.remove(), h.delete(e), I.delete(e), d.delete(e), M.delete(e), _.delete(e), b === e && (b = null);
280
+ }
281
+ function j() {
282
+ Array.from(_).forEach((t) => {
283
+ t.isConnected || be(t);
284
+ });
285
+ }
286
+ function He(e) {
287
+ var t, a, r, n;
288
+ for (let o = 0; o < e.length; o += 1) {
289
+ const s = e[o];
290
+ if (!(s.type !== "childList" || s.removedNodes.length === 0))
291
+ for (let l = 0; l < s.removedNodes.length; l += 1) {
292
+ const c = s.removedNodes[l];
293
+ if (c.nodeType !== Node.ELEMENT_NODE)
294
+ continue;
295
+ const i = c;
296
+ if ((t = i.matches) != null && t.call(i, v) || (a = i.matches) != null && a.call(i, `.${u}`) || (r = i.querySelector) != null && r.call(i, v) || (n = i.querySelector) != null && n.call(i, `.${u}`))
297
+ return !0;
298
+ }
299
+ }
300
+ return !1;
301
+ }
302
+ function re(e) {
303
+ return I.get(e) === !0;
304
+ }
305
+ function R(e, t) {
306
+ const a = e.querySelector(".rte-smart-paste-live");
307
+ a && (a.textContent = t);
308
+ }
309
+ function J(e, t) {
310
+ const a = t.normalizeText(e);
311
+ return t.normalizeWhitespace ? a.split(`
312
+ `).map((n) => n.replace(/[\t ]+/g, " ").trimEnd()).join(`
313
+ `).replace(/\n{3,}/g, `
314
+
315
+ `).trim() : a;
316
+ }
317
+ function De(e) {
318
+ return /class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(e);
319
+ }
320
+ function Ne(e) {
321
+ return /id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(e);
322
+ }
323
+ function qe(e, t) {
324
+ return e ? De(e) ? "word" : Ne(e) ? "google-docs" : "html" : t ? "plain" : "html";
325
+ }
326
+ function Ie(e) {
327
+ return e.split(/\s+/).map((a) => a.trim()).filter(Boolean).filter((a) => !/^mso/i.test(a)).filter((a) => !/^docs-/i.test(a)).filter((a) => !/^c\d+$/i.test(a)).join(" ");
328
+ }
329
+ function We(e) {
330
+ if (!e)
331
+ return { value: "", changed: !1 };
332
+ const t = e.split(";"), a = [];
333
+ let r = !1;
334
+ return t.forEach((n) => {
335
+ const o = n.indexOf(":");
336
+ if (o <= 0) {
337
+ n.trim() && (r = !0);
338
+ return;
339
+ }
340
+ const s = n.slice(0, o).trim().toLowerCase(), l = n.slice(o + 1).trim();
341
+ if (!s || !l) {
342
+ r = !0;
343
+ return;
344
+ }
345
+ if (!Le.has(s)) {
346
+ r = !0;
347
+ return;
348
+ }
349
+ if (/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(l)) {
350
+ r = !0;
351
+ return;
352
+ }
353
+ a.push(`${s}: ${l}`);
354
+ }), {
355
+ value: a.join("; "),
356
+ changed: r
357
+ };
358
+ }
359
+ function ue(e) {
360
+ const t = e.trim();
361
+ return t && (Ae.test(t) || Pe.test(t)) ? t : "";
362
+ }
363
+ function fe(e) {
364
+ const t = e.parentNode;
365
+ if (t) {
366
+ for (; e.firstChild; )
367
+ t.insertBefore(e.firstChild, e);
368
+ t.removeChild(e);
369
+ }
370
+ }
371
+ function Be(e, t, a, r) {
372
+ const n = e.tagName.toLowerCase();
373
+ if (ke.has(n)) {
374
+ r.removedElements += 1, e.remove();
375
+ return;
376
+ }
377
+ if (!t.preserveTables && Ce.has(n)) {
378
+ const s = e.textContent || "", l = document.createTextNode(s);
379
+ e.replaceWith(l), r.removedElements += 1;
380
+ return;
381
+ }
382
+ if (Array.from(e.attributes).forEach((s) => {
383
+ const l = s.name.toLowerCase(), c = s.value;
384
+ if (l.startsWith("on")) {
385
+ e.removeAttribute(s.name), r.removedAttributes += 1;
386
+ return;
387
+ }
388
+ if (l === "style") {
389
+ if (!t.keepStyles) {
390
+ e.removeAttribute(s.name), r.removedAttributes += 1;
391
+ return;
392
+ }
393
+ const i = We(c);
394
+ if (!i.value) {
395
+ e.removeAttribute(s.name), r.removedAttributes += 1, i.changed && (r.normalizedStyles += 1);
396
+ return;
397
+ }
398
+ (i.changed || i.value !== c) && (e.setAttribute("style", i.value), r.normalizedStyles += 1);
399
+ return;
400
+ }
401
+ if (l === "class") {
402
+ if (!t.keepClasses) {
403
+ e.removeAttribute(s.name), r.removedAttributes += 1;
404
+ return;
405
+ }
406
+ const i = Ie(c);
407
+ if (!i) {
408
+ e.removeAttribute(s.name), r.removedAttributes += 1;
409
+ return;
410
+ }
411
+ i !== c && (e.setAttribute("class", i), r.removedAttributes += 1);
412
+ return;
413
+ }
414
+ if (l.startsWith("data-") && !t.keepDataAttributes) {
415
+ e.removeAttribute(s.name), r.removedAttributes += 1;
416
+ return;
417
+ }
418
+ if (l === "id" || l === "xmlns" || l.startsWith("xml")) {
419
+ e.removeAttribute(s.name), r.removedAttributes += 1;
420
+ return;
421
+ }
422
+ if ((a === "word" || a === "google-docs") && (l === "lang" || l === "dir")) {
423
+ e.removeAttribute(s.name), r.removedAttributes += 1;
424
+ return;
425
+ }
426
+ if (l === "href" || l === "src" || l === "xlink:href") {
427
+ const i = ue(c);
428
+ if (!i) {
429
+ e.removeAttribute(s.name), r.removedAttributes += 1;
430
+ return;
431
+ }
432
+ i !== c && e.setAttribute(s.name, i);
433
+ }
434
+ }), n === "a") {
435
+ if (!e.getAttribute("href")) {
436
+ fe(e), r.removedElements += 1;
437
+ return;
438
+ }
439
+ e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer");
440
+ }
441
+ if (n === "img") {
442
+ const s = e.getAttribute("src");
443
+ if (!s || !ue(s)) {
444
+ r.removedElements += 1, e.remove();
445
+ return;
446
+ }
447
+ }
448
+ if (Te.has(n) && !e.attributes.length && !e.className && !e.style.cssText) {
449
+ const s = e.children.length > 0, l = (e.textContent || "").trim().length > 0;
450
+ if (!s && !l) {
451
+ e.remove(), r.removedElements += 1;
452
+ return;
453
+ }
454
+ !s && l && (fe(e), r.removedElements += 1);
455
+ }
456
+ }
457
+ function Ke(e, t, a, r, n) {
458
+ const o = document.createElement("template");
459
+ o.innerHTML = e;
460
+ const s = {
461
+ removedElements: 0,
462
+ removedAttributes: 0,
463
+ removedComments: 0,
464
+ normalizedStyles: 0
465
+ };
466
+ if (r.removeComments)
467
+ try {
468
+ const f = document.createTreeWalker(o.content, Ee, null), p = [];
469
+ let y = f.nextNode();
470
+ for (; y; )
471
+ p.push(y), y = f.nextNode();
472
+ p.forEach((g) => {
473
+ g.remove(), s.removedComments += 1;
474
+ });
475
+ } catch {
476
+ }
477
+ Array.from(o.content.querySelectorAll("*")).forEach((f) => {
478
+ f.isConnected && Be(f, t, a, s);
479
+ });
480
+ let c = o.innerHTML;
481
+ r.normalizeWhitespace && n !== "fidelity" ? c = c.replace(/\s{2,}/g, " ").replace(/>\s+</g, "><").trim() : r.normalizeWhitespace && (c = c.trim());
482
+ const i = (o.content.textContent || "").trim().length;
483
+ return {
484
+ html: c,
485
+ textLength: i,
486
+ counters: s
487
+ };
488
+ }
489
+ function ge(e) {
490
+ const t = window.getSelection();
491
+ if (!t || t.rangeCount === 0)
492
+ return null;
493
+ const a = t.getRangeAt(0);
494
+ return e.contains(a.commonAncestorContainer) ? a : null;
495
+ }
496
+ function he(e, t) {
497
+ if (!e.isConnected)
498
+ return;
499
+ const a = window.getSelection();
500
+ a && (a.removeAllRanges(), a.addRange(t));
501
+ }
502
+ function Ve(e, t) {
503
+ e.focus({ preventScroll: !0 });
504
+ try {
505
+ if (document.execCommand("insertHTML", !1, t))
506
+ return !0;
507
+ } catch {
508
+ }
509
+ const a = ge(e);
510
+ if (!a)
511
+ return !1;
512
+ a.deleteContents();
513
+ const r = document.createElement("template");
514
+ r.innerHTML = t;
515
+ const n = r.content, o = n.lastChild;
516
+ if (a.insertNode(n), o) {
517
+ const s = document.createRange();
518
+ s.setStartAfter(o), s.collapse(!0), he(e, s);
519
+ }
520
+ return !0;
521
+ }
522
+ function je(e, t) {
523
+ e.focus({ preventScroll: !0 });
524
+ try {
525
+ if (document.execCommand("insertText", !1, t))
526
+ return !0;
527
+ } catch {
528
+ }
529
+ const a = ge(e);
530
+ if (!a)
531
+ return !1;
532
+ a.deleteContents();
533
+ const r = document.createTextNode(t);
534
+ a.insertNode(r);
535
+ const n = document.createRange();
536
+ return n.setStart(r, r.length), n.collapse(!0), he(e, n), !0;
537
+ }
538
+ function Fe(e, t) {
539
+ if (t === e.innerHTML)
540
+ return;
541
+ const a = window.execEditorCommand || window.executeEditorCommand;
542
+ if (typeof a == "function")
543
+ try {
544
+ a("recordDomTransaction", e, t, e.innerHTML);
545
+ } catch {
546
+ }
547
+ }
548
+ function Ge(e) {
549
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
550
+ }
551
+ function K(e, t, a, r, n, o) {
552
+ return {
553
+ source: e,
554
+ profile: t,
555
+ inputHtmlLength: a,
556
+ outputHtmlLength: r,
557
+ outputTextLength: n,
558
+ removedElements: o.removedElements,
559
+ removedAttributes: o.removedAttributes,
560
+ removedComments: o.removedComments,
561
+ normalizedStyles: o.normalizedStyles,
562
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
563
+ };
564
+ }
565
+ function Ue(e, t, a, r) {
566
+ const n = qe(e, t);
567
+ if (a === "plain") {
568
+ const l = t || e.replace(/<[^>]*>/g, " "), c = J(l, r);
569
+ return {
570
+ mode: "text",
571
+ value: c,
572
+ report: K(
573
+ n,
574
+ a,
575
+ e.length,
576
+ 0,
577
+ c.length,
578
+ {
579
+ removedElements: 0,
580
+ removedAttributes: 0,
581
+ removedComments: 0,
582
+ normalizedStyles: 0
583
+ }
584
+ )
585
+ };
586
+ }
587
+ if (!e || e.length > r.maxHtmlLength) {
588
+ const l = J(t || e.replace(/<[^>]*>/g, " "), r);
589
+ return {
590
+ mode: "text",
591
+ value: l,
592
+ report: K(
593
+ n,
594
+ a,
595
+ e.length,
596
+ 0,
597
+ l.length,
598
+ {
599
+ removedElements: 0,
600
+ removedAttributes: 0,
601
+ removedComments: 0,
602
+ normalizedStyles: 0
603
+ }
604
+ )
605
+ };
606
+ }
607
+ const o = r.profileOptions[a], s = Ke(e, o, n, r, a);
608
+ if (!s.html) {
609
+ const l = J(t || e.replace(/<[^>]*>/g, " "), r);
610
+ return {
611
+ mode: "text",
612
+ value: l,
613
+ report: K(n, a, e.length, 0, l.length, s.counters)
614
+ };
615
+ }
616
+ return {
617
+ mode: "html",
618
+ value: s.html,
619
+ report: K(
620
+ n,
621
+ a,
622
+ e.length,
623
+ s.html.length,
624
+ s.textLength,
625
+ s.counters
626
+ )
627
+ };
628
+ }
629
+ function U(e, t) {
630
+ return e === "balanced" ? t.balancedText : e === "plain" ? t.plainText : t.fidelityText;
631
+ }
632
+ function ae(e) {
633
+ return e === "fidelity" ? "balanced" : e === "balanced" ? "plain" : "fidelity";
634
+ }
635
+ function Ye(e, t) {
636
+ e.setAttribute("aria-label", t.labels.panelAriaLabel);
637
+ const a = e.querySelector(".rte-smart-paste-title");
638
+ a && (a.textContent = t.labels.panelTitle);
639
+ const r = e.querySelector('[data-action="close"]');
640
+ r && r.setAttribute("aria-label", t.labels.closeText);
641
+ const n = e.querySelector('[data-action="toggle-enabled"]');
642
+ if (n) {
643
+ const Se = n.getAttribute("data-enabled") === "true";
644
+ n.textContent = Se ? t.labels.toggleOnText : t.labels.toggleOffText;
645
+ }
646
+ const o = e.querySelector('[data-action="cycle-profile"]');
647
+ o && (o.textContent = t.labels.cycleProfileText);
648
+ const s = e.querySelector(".rte-smart-paste-profile-heading");
649
+ s && (s.textContent = t.labels.profileLabel);
650
+ const l = e.querySelector('.rte-smart-paste-profile[role="group"]');
651
+ l && l.setAttribute("aria-label", t.labels.profileLabel);
652
+ const c = e.querySelector('[data-action="set-profile"][data-profile="fidelity"]');
653
+ c && (c.textContent = t.labels.fidelityText);
654
+ const i = e.querySelector('[data-action="set-profile"][data-profile="balanced"]');
655
+ i && (i.textContent = t.labels.balancedText);
656
+ const f = e.querySelector('[data-action="set-profile"][data-profile="plain"]');
657
+ f && (f.textContent = t.labels.plainText);
658
+ const p = e.querySelector(".rte-smart-paste-report-title");
659
+ p && (p.textContent = t.labels.lastPasteHeading);
660
+ const y = e.querySelector(".rte-smart-paste-empty");
661
+ y && (y.textContent = t.labels.lastPasteEmptyText);
662
+ const g = e.querySelector('[data-key="source-label"]');
663
+ g && (g.textContent = t.labels.lastPasteSourceLabel);
664
+ const P = e.querySelector('[data-key="profile-label"]');
665
+ P && (P.textContent = t.labels.lastPasteProfileLabel);
666
+ const C = e.querySelector('[data-key="removed-label"]');
667
+ C && (C.textContent = t.labels.lastPasteRemovedLabel);
668
+ const oe = e.querySelector('[data-key="chars-label"]');
669
+ oe && (oe.textContent = t.labels.lastPasteCharsLabel);
670
+ const ne = e.querySelector(".rte-smart-paste-shortcut");
671
+ ne && (ne.textContent = t.labels.shortcutText);
672
+ }
673
+ function S(e) {
674
+ const t = h.get(e), a = d.get(e) || O, r = M.get(e);
675
+ if (!t || !a || !r)
676
+ return;
677
+ Ye(t, a);
678
+ const n = t.querySelector(".rte-smart-paste-status");
679
+ n && (n.textContent = r.enabled ? a.labels.enabledText : a.labels.disabledText);
680
+ const o = t.querySelector('[data-action="toggle-enabled"]');
681
+ o && (o.setAttribute("data-enabled", r.enabled ? "true" : "false"), o.textContent = r.enabled ? a.labels.toggleOnText : a.labels.toggleOffText, o.setAttribute("aria-pressed", r.enabled ? "true" : "false")), Array.from(
682
+ t.querySelectorAll('[data-action="set-profile"][data-profile]')
683
+ ).forEach((g) => {
684
+ const C = H(g.getAttribute("data-profile")) === r.profile;
685
+ g.classList.toggle("active", C), g.setAttribute("aria-pressed", C ? "true" : "false");
686
+ });
687
+ const l = t.querySelector(".rte-smart-paste-empty"), c = t.querySelector(".rte-smart-paste-report"), i = t.querySelector('[data-key="source-value"]'), f = t.querySelector('[data-key="profile-value"]'), p = t.querySelector('[data-key="removed-value"]'), y = t.querySelector('[data-key="chars-value"]');
688
+ if (!r.lastReport) {
689
+ l && (l.hidden = !1), c && (c.hidden = !0);
690
+ return;
691
+ }
692
+ if (l && (l.hidden = !0), c && (c.hidden = !1), i && (i.textContent = r.lastReport.source), f && (f.textContent = U(r.lastReport.profile, a.labels)), p) {
693
+ const g = r.lastReport.removedElements + r.lastReport.removedAttributes + r.lastReport.removedComments + r.lastReport.normalizedStyles;
694
+ p.textContent = String(g);
695
+ }
696
+ y && (y.textContent = String(r.lastReport.outputTextLength));
697
+ }
698
+ function Q(e, t) {
699
+ if (!t.classList.contains("show"))
700
+ return;
701
+ const a = te(e).getBoundingClientRect(), r = Math.min(window.innerWidth - 20, 360), n = Math.max(10, window.innerWidth - r - 10), o = Math.min(Math.max(10, a.right - r), n), s = Math.max(10, Math.min(window.innerHeight - 10, a.top + 12));
702
+ t.style.width = `${r}px`, t.style.left = `${o}px`, t.style.top = `${s}px`, t.style.maxHeight = `${Math.max(240, window.innerHeight - 20)}px`;
703
+ }
704
+ function q(e, t = !1) {
705
+ const a = h.get(e);
706
+ a && (a.classList.remove("show"), I.set(e, !1), N(e, "toggleSmartPastePanel", !1), t && e.focus({ preventScroll: !0 }));
707
+ }
708
+ function Xe(e) {
709
+ const t = h.get(e);
710
+ if (t)
711
+ return t;
712
+ const a = d.get(e) || O || V(), r = `rte-smart-paste-panel-${$e++}`, n = document.createElement("section");
713
+ return n.className = u, n.id = r, n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "false"), n.setAttribute("aria-label", a.labels.panelAriaLabel), n.innerHTML = `
714
+ <header class="rte-smart-paste-header">
715
+ <h2 class="rte-smart-paste-title">${X(a.labels.panelTitle)}</h2>
716
+ <button type="button" class="rte-smart-paste-icon-btn" data-action="close" aria-label="${X(a.labels.closeText)}">✕</button>
717
+ </header>
718
+ <div class="rte-smart-paste-body">
719
+ <p class="rte-smart-paste-status"></p>
720
+ <div class="rte-smart-paste-controls">
721
+ <button type="button" class="rte-smart-paste-btn rte-smart-paste-btn-primary" data-action="toggle-enabled" data-enabled="true"></button>
722
+ <button type="button" class="rte-smart-paste-btn" data-action="cycle-profile"></button>
723
+ </div>
724
+ <div class="rte-smart-paste-profile" role="group" aria-label="${X(a.labels.profileLabel)}">
725
+ <p class="rte-smart-paste-profile-heading"></p>
726
+ <div class="rte-smart-paste-profile-grid">
727
+ <button type="button" class="rte-smart-paste-chip" data-action="set-profile" data-profile="fidelity" aria-pressed="false"></button>
728
+ <button type="button" class="rte-smart-paste-chip" data-action="set-profile" data-profile="balanced" aria-pressed="false"></button>
729
+ <button type="button" class="rte-smart-paste-chip" data-action="set-profile" data-profile="plain" aria-pressed="false"></button>
730
+ </div>
731
+ </div>
732
+ <section class="rte-smart-paste-metrics" aria-live="polite">
733
+ <h3 class="rte-smart-paste-report-title"></h3>
734
+ <p class="rte-smart-paste-empty"></p>
735
+ <dl class="rte-smart-paste-report" hidden>
736
+ <div class="rte-smart-paste-line"><dt data-key="source-label"></dt><dd data-key="source-value"></dd></div>
737
+ <div class="rte-smart-paste-line"><dt data-key="profile-label"></dt><dd data-key="profile-value"></dd></div>
738
+ <div class="rte-smart-paste-line"><dt data-key="removed-label"></dt><dd data-key="removed-value"></dd></div>
739
+ <div class="rte-smart-paste-line"><dt data-key="chars-label"></dt><dd data-key="chars-value"></dd></div>
740
+ </dl>
741
+ </section>
742
+ <p class="rte-smart-paste-shortcut"></p>
743
+ </div>
744
+ <div class="rte-smart-paste-live" aria-live="polite" aria-atomic="true"></div>
745
+ `, n.addEventListener("click", (o) => {
746
+ const s = o.target, l = s == null ? void 0 : s.closest("[data-action]");
747
+ if (!l)
748
+ return;
749
+ const c = l.getAttribute("data-action");
750
+ if (c) {
751
+ if (c === "close") {
752
+ q(e, !0);
753
+ return;
754
+ }
755
+ if (c === "toggle-enabled") {
756
+ const i = m(e, d.get(e) || a);
757
+ i.enabled = !i.enabled, N(e, "toggleSmartPasteEnabled", i.enabled), S(e), R(n, i.enabled ? a.labels.enabledText : a.labels.disabledText);
758
+ return;
759
+ }
760
+ if (c === "cycle-profile") {
761
+ const i = m(e, d.get(e) || a);
762
+ i.profile = ae(i.profile), S(e), R(n, `${a.labels.profileLabel}: ${U(i.profile, a.labels)}`);
763
+ return;
764
+ }
765
+ if (c === "set-profile") {
766
+ const i = m(e, d.get(e) || a);
767
+ i.profile = H(l.getAttribute("data-profile")), S(e), R(n, `${a.labels.profileLabel}: ${U(i.profile, a.labels)}`);
768
+ }
769
+ }
770
+ }), n.addEventListener("keydown", (o) => {
771
+ if (o.key === "Escape") {
772
+ o.preventDefault(), q(e, !0);
773
+ return;
774
+ }
775
+ if (o.key !== "ArrowRight" && o.key !== "ArrowLeft")
776
+ return;
777
+ const s = Array.from(
778
+ n.querySelectorAll('[data-action="set-profile"][data-profile]')
779
+ );
780
+ if (s.length === 0)
781
+ return;
782
+ const l = s.findIndex((f) => f === document.activeElement);
783
+ if (l < 0)
784
+ return;
785
+ const c = o.key === "ArrowRight" ? 1 : -1, i = (l + c + s.length) % s.length;
786
+ o.preventDefault(), s[i].focus();
787
+ }), G(n, e), document.body.appendChild(n), h.set(e, n), I.set(e, !1), S(e), n;
788
+ }
789
+ function ye(e) {
790
+ const t = Xe(e);
791
+ h.forEach((r, n) => {
792
+ n !== e && q(n, !1);
793
+ }), t.classList.add("show"), I.set(e, !0), N(e, "toggleSmartPastePanel", !0), G(t, e), Q(e, t);
794
+ const a = t.querySelector('[data-action="toggle-enabled"]');
795
+ a == null || a.focus();
796
+ }
797
+ function xe(e, t) {
798
+ const a = re(e);
799
+ return (typeof t == "boolean" ? t : !a) ? ye(e) : q(e, !1), !0;
800
+ }
801
+ function ve(e) {
802
+ return {
803
+ enabled: e.enabled,
804
+ profile: e.profile,
805
+ lastReport: e.lastReport ? { ...e.lastReport } : null
806
+ };
807
+ }
808
+ function Ze(e, t) {
809
+ const a = d.get(e) || O;
810
+ if (!a)
811
+ return !1;
812
+ const r = m(e, a);
813
+ if (!r.enabled || de(e)) {
814
+ const p = h.get(e);
815
+ return p && de(e) && R(p, a.labels.readonlyMessage), !1;
816
+ }
817
+ const n = t.clipboardData;
818
+ if (!n)
819
+ return !1;
820
+ const o = n.getData("text/html") || "", s = n.getData("text/plain") || "";
821
+ if (!o && !s)
822
+ return !1;
823
+ const l = Ue(o, s, r.profile, a);
824
+ if (!l.value)
825
+ return !1;
826
+ const c = e.innerHTML;
827
+ if (!(l.mode === "html" ? Ve(e, l.value) : je(e, l.value)))
828
+ return !1;
829
+ r.lastReport = { ...l.report }, M.set(e, r), Fe(e, c), Ge(e), e.dispatchEvent(
830
+ new CustomEvent("editora:smart-paste", {
831
+ bubbles: !0,
832
+ detail: ve(r)
833
+ })
834
+ ), S(e);
835
+ const f = h.get(e);
836
+ if (f) {
837
+ const p = l.report.removedElements + l.report.removedAttributes + l.report.removedComments + l.report.normalizedStyles;
838
+ R(
839
+ f,
840
+ `${a.labels.panelTitle}: ${U(r.profile, a.labels)}. ${a.labels.lastPasteRemovedLabel}: ${p}.`
841
+ );
842
+ }
843
+ return !0;
844
+ }
845
+ function Je(e) {
846
+ return (t) => {
847
+ t.defaultPrevented || t[ie] === !0 || (b = e, !Ze(e, t)) || (t[ie] = !0, t.preventDefault(), typeof t.stopImmediatePropagation == "function" ? t.stopImmediatePropagation() : t.stopPropagation());
848
+ };
849
+ }
850
+ function Qe(e) {
851
+ if (F.has(e))
852
+ return;
853
+ const t = Je(e);
854
+ e.addEventListener("paste", t, !0), F.set(e, t);
855
+ }
856
+ function z(e) {
857
+ const t = M.get(e);
858
+ N(e, "toggleSmartPastePanel", re(e)), N(e, "toggleSmartPasteEnabled", (t == null ? void 0 : t.enabled) === !0);
859
+ }
860
+ function et(e) {
861
+ const t = e.key.toLowerCase();
862
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "s";
863
+ }
864
+ function tt(e) {
865
+ const t = e.key.toLowerCase();
866
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "v";
867
+ }
868
+ function rt(e) {
869
+ const t = e.key.toLowerCase();
870
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "g";
871
+ }
872
+ function at(e) {
873
+ O = e, L || (L = (t) => {
874
+ j();
875
+ const a = t.target, r = a == null ? void 0 : a.closest(v);
876
+ if (!r)
877
+ return;
878
+ const n = d.get(r) || e;
879
+ m(r, n), d.set(r, n), b = r, z(r);
880
+ const o = h.get(r);
881
+ o && (G(o, r), Q(r, o), S(r));
882
+ }, document.addEventListener("focusin", L, !0)), w || (w = (t) => {
883
+ if (t.defaultPrevented)
884
+ return;
885
+ const a = t.target;
886
+ if (a != null && a.closest(`.${u} input, .${u} textarea, .${u} select`))
887
+ return;
888
+ const r = ze(t);
889
+ if (!r)
890
+ return;
891
+ const n = d.get(r) || O || e;
892
+ if (m(r, n), d.set(r, n), b = r, t.key === "Escape" && re(r)) {
893
+ t.preventDefault(), q(r, !0);
894
+ return;
895
+ }
896
+ if (et(t)) {
897
+ t.preventDefault(), t.stopPropagation(), xe(r);
898
+ return;
899
+ }
900
+ if (tt(t)) {
901
+ t.preventDefault(), t.stopPropagation();
902
+ const o = m(r, n);
903
+ o.profile = ae(o.profile), S(r);
904
+ return;
905
+ }
906
+ if (rt(t)) {
907
+ t.preventDefault(), t.stopPropagation();
908
+ const o = m(r, n);
909
+ o.enabled = !o.enabled, z(r), S(r);
910
+ }
911
+ }, document.addEventListener("keydown", w, !0)), A || (A = () => {
912
+ j(), h.forEach((t, a) => {
913
+ !a.isConnected || !t.isConnected || (G(t, a), Q(a, t));
914
+ });
915
+ }, window.addEventListener("scroll", A, !0), window.addEventListener("resize", A)), !$ && typeof MutationObserver < "u" && document.body && ($ = new MutationObserver((t) => {
916
+ He(t) && j();
917
+ }), $.observe(document.body, {
918
+ childList: !0,
919
+ subtree: !0
920
+ }));
921
+ }
922
+ function ot() {
923
+ L && (document.removeEventListener("focusin", L, !0), L = null), w && (document.removeEventListener("keydown", w, !0), w = null), A && (window.removeEventListener("scroll", A, !0), window.removeEventListener("resize", A), A = null), $ && ($.disconnect(), $ = null), h.forEach((e) => e.remove()), h.clear(), _.forEach((e) => me(e)), _.clear(), O = null, b = null;
924
+ }
925
+ function nt() {
926
+ if (typeof document > "u" || document.getElementById(le))
927
+ return;
928
+ const e = document.createElement("style");
929
+ e.id = le, e.textContent = `
930
+ .rte-toolbar-group-items.${x},
931
+ .editora-toolbar-group-items.${x},
932
+ .rte-toolbar-group-items.${E},
933
+ .editora-toolbar-group-items.${E} {
934
+ display: flex;
935
+ border: 1px solid #ccc;
936
+ border-radius: 3px;
937
+ background: #fff;
938
+ }
939
+
940
+ .rte-toolbar-group-items.${x} .rte-toolbar-button,
941
+ .editora-toolbar-group-items.${x} .editora-toolbar-button,
942
+ .rte-toolbar-group-items.${E} .rte-toolbar-button,
943
+ .editora-toolbar-group-items.${E} .editora-toolbar-button {
944
+ border: none;
945
+ border-right: 1px solid #ccc;
946
+ border-radius: 0;
947
+ }
948
+
949
+ .rte-toolbar-group-items.${x} .rte-toolbar-item:last-child .rte-toolbar-button,
950
+ .editora-toolbar-group-items.${x} .editora-toolbar-item:last-child .editora-toolbar-button,
951
+ .rte-toolbar-group-items.${E} .rte-toolbar-item:last-child .rte-toolbar-button,
952
+ .editora-toolbar-group-items.${E} .editora-toolbar-item:last-child .editora-toolbar-button {
953
+ border-right: none;
954
+ }
955
+
956
+ .rte-toolbar-button[data-command="toggleSmartPasteEnabled"].active,
957
+ .editora-toolbar-button[data-command="toggleSmartPasteEnabled"].active {
958
+ background-color: #ccc;
959
+ }
960
+
961
+ ${k} .rte-toolbar-group-items.${x},
962
+ ${k} .editora-toolbar-group-items.${x},
963
+ ${k} .rte-toolbar-group-items.${E},
964
+ ${k} .editora-toolbar-group-items.${E},
965
+ .${u}.rte-smart-paste-theme-dark {
966
+ border-color: #566275;
967
+ }
968
+
969
+ ${k} .rte-toolbar-group-items.${x} .rte-toolbar-button svg,
970
+ ${k} .editora-toolbar-group-items.${x} .editora-toolbar-button svg,
971
+ ${k} .rte-toolbar-group-items.${E} .rte-toolbar-button svg,
972
+ ${k} .editora-toolbar-group-items.${E} .editora-toolbar-button svg {
973
+ fill: none;
974
+ }
975
+
976
+ ${k} .rte-toolbar-group-items.${x} .rte-toolbar-button,
977
+ ${k} .editora-toolbar-group-items.${x} .editora-toolbar-button
978
+ {
979
+ border-color: #566275;
980
+ }
981
+
982
+ .${u} {
983
+ position: fixed;
984
+ z-index: 12000;
985
+ display: none;
986
+ width: min(360px, calc(100vw - 20px));
987
+ max-height: calc(100vh - 20px);
988
+ border: 1px solid #d1d5db;
989
+ border-radius: 14px;
990
+ background: #ffffff;
991
+ color: #111827;
992
+ box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
993
+ overflow: hidden;
994
+ }
995
+
996
+ .${u}.show {
997
+ display: flex;
998
+ flex-direction: column;
999
+ }
1000
+
1001
+ .${u}.rte-smart-paste-theme-dark {
1002
+ border-color: #334155;
1003
+ background: #0f172a;
1004
+ color: #e2e8f0;
1005
+ box-shadow: 0 20px 46px rgba(2, 6, 23, 0.68);
1006
+ }
1007
+
1008
+ .rte-smart-paste-header {
1009
+ display: flex;
1010
+ align-items: center;
1011
+ justify-content: space-between;
1012
+ gap: 8px;
1013
+ padding: 12px 14px;
1014
+ border-bottom: 1px solid #e5e7eb;
1015
+ background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
1016
+ }
1017
+
1018
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-header {
1019
+ border-color: #1e293b;
1020
+ background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
1021
+ }
1022
+
1023
+ .rte-smart-paste-title {
1024
+ margin: 0;
1025
+ font-size: 15px;
1026
+ line-height: 1.2;
1027
+ font-weight: 700;
1028
+ }
1029
+
1030
+ .rte-smart-paste-icon-btn {
1031
+ width: 34px;
1032
+ height: 34px;
1033
+ border: 1px solid #cbd5e1;
1034
+ border-radius: 6px;
1035
+ background: #ffffff;
1036
+ color: #0f172a;
1037
+ font-size: 16px;
1038
+ line-height: 1;
1039
+ font-weight: 600;
1040
+ padding: 0;
1041
+ display: inline-flex;
1042
+ align-items: center;
1043
+ justify-content: center;
1044
+ cursor: pointer;
1045
+ }
1046
+
1047
+ .rte-smart-paste-icon-btn:hover,
1048
+ .rte-smart-paste-icon-btn:focus-visible {
1049
+ outline: none;
1050
+ border-color: #3b82f6;
1051
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
1052
+ }
1053
+
1054
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-icon-btn {
1055
+ background: #0f172a;
1056
+ border-color: #475569;
1057
+ color: #e2e8f0;
1058
+ }
1059
+
1060
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-icon-btn:hover,
1061
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-icon-btn:focus-visible {
1062
+ border-color: #60a5fa;
1063
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
1064
+ }
1065
+
1066
+ .rte-smart-paste-body {
1067
+ display: flex;
1068
+ flex-direction: column;
1069
+ gap: 10px;
1070
+ padding: 12px;
1071
+ overflow: auto;
1072
+ }
1073
+
1074
+ .rte-smart-paste-status {
1075
+ margin: 0;
1076
+ font-size: 12px;
1077
+ line-height: 1.35;
1078
+ color: #475569;
1079
+ font-weight: 600;
1080
+ }
1081
+
1082
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-status {
1083
+ color: #94a3b8;
1084
+ }
1085
+
1086
+ .rte-smart-paste-controls {
1087
+ display: flex;
1088
+ gap: 8px;
1089
+ flex-wrap: wrap;
1090
+ }
1091
+
1092
+ .rte-smart-paste-btn {
1093
+ border: 1px solid #cbd5e1;
1094
+ border-radius: 8px;
1095
+ height: 34px;
1096
+ padding: 0 10px;
1097
+ background: #ffffff;
1098
+ color: inherit;
1099
+ font-size: 12px;
1100
+ font-weight: 600;
1101
+ cursor: pointer;
1102
+ }
1103
+
1104
+ .rte-smart-paste-btn:hover,
1105
+ .rte-smart-paste-btn:focus-visible {
1106
+ border-color: #94a3b8;
1107
+ background: #f8fafc;
1108
+ outline: none;
1109
+ }
1110
+
1111
+ .rte-smart-paste-btn-primary {
1112
+ border-color: #0284c7;
1113
+ background: #0ea5e9;
1114
+ color: #f8fafc;
1115
+ }
1116
+
1117
+ .rte-smart-paste-btn-primary:hover,
1118
+ .rte-smart-paste-btn-primary:focus-visible {
1119
+ border-color: #0369a1;
1120
+ background: #0284c7;
1121
+ color: #ffffff;
1122
+ }
1123
+
1124
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-btn {
1125
+ border-color: #334155;
1126
+ background: #111827;
1127
+ color: #e2e8f0;
1128
+ }
1129
+
1130
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-btn:hover,
1131
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-btn:focus-visible {
1132
+ border-color: #475569;
1133
+ background: #1e293b;
1134
+ }
1135
+
1136
+ .rte-smart-paste-profile {
1137
+ display: grid;
1138
+ gap: 6px;
1139
+ }
1140
+
1141
+ .rte-smart-paste-profile-heading {
1142
+ margin: 0;
1143
+ font-size: 12px;
1144
+ line-height: 1.35;
1145
+ font-weight: 700;
1146
+ color: #334155;
1147
+ }
1148
+
1149
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-profile-heading {
1150
+ color: #cbd5e1;
1151
+ }
1152
+
1153
+ .rte-smart-paste-profile-grid {
1154
+ display: grid;
1155
+ grid-template-columns: repeat(3, minmax(0, 1fr));
1156
+ gap: 8px;
1157
+ }
1158
+
1159
+ .rte-smart-paste-chip {
1160
+ height: 34px;
1161
+ border-radius: 9px;
1162
+ border: 1px solid #cbd5e1;
1163
+ background: #ffffff;
1164
+ color: inherit;
1165
+ font-size: 12px;
1166
+ font-weight: 600;
1167
+ cursor: pointer;
1168
+ }
1169
+
1170
+ .rte-smart-paste-chip:hover,
1171
+ .rte-smart-paste-chip:focus-visible {
1172
+ border-color: #0284c7;
1173
+ outline: none;
1174
+ }
1175
+
1176
+ .rte-smart-paste-chip.active {
1177
+ border-color: #0284c7;
1178
+ background: rgba(14, 165, 233, 0.14);
1179
+ color: #0c4a6e;
1180
+ }
1181
+
1182
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-chip {
1183
+ border-color: #334155;
1184
+ background: #0b1220;
1185
+ color: #e2e8f0;
1186
+ }
1187
+
1188
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-chip.active {
1189
+ border-color: #38bdf8;
1190
+ background: rgba(14, 165, 233, 0.2);
1191
+ color: #e0f2fe;
1192
+ }
1193
+
1194
+ .rte-smart-paste-metrics {
1195
+ border: 1px solid #e2e8f0;
1196
+ border-radius: 10px;
1197
+ padding: 10px;
1198
+ background: #f8fafc;
1199
+ display: grid;
1200
+ gap: 8px;
1201
+ }
1202
+
1203
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-metrics {
1204
+ border-color: #334155;
1205
+ background: #0b1220;
1206
+ }
1207
+
1208
+ .rte-smart-paste-report-title {
1209
+ margin: 0;
1210
+ font-size: 12px;
1211
+ line-height: 1.3;
1212
+ font-weight: 700;
1213
+ }
1214
+
1215
+ .rte-smart-paste-empty {
1216
+ margin: 0;
1217
+ font-size: 12px;
1218
+ line-height: 1.35;
1219
+ color: #475569;
1220
+ }
1221
+
1222
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-empty {
1223
+ color: #94a3b8;
1224
+ }
1225
+
1226
+ .rte-smart-paste-report {
1227
+ margin: 0;
1228
+ display: grid;
1229
+ gap: 6px;
1230
+ }
1231
+
1232
+ .rte-smart-paste-line {
1233
+ display: flex;
1234
+ justify-content: space-between;
1235
+ gap: 10px;
1236
+ font-size: 12px;
1237
+ line-height: 1.3;
1238
+ }
1239
+
1240
+ .rte-smart-paste-line dt {
1241
+ margin: 0;
1242
+ color: #475569;
1243
+ font-weight: 600;
1244
+ }
1245
+
1246
+ .rte-smart-paste-line dd {
1247
+ margin: 0;
1248
+ font-weight: 700;
1249
+ }
1250
+
1251
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-line dt {
1252
+ color: #94a3b8;
1253
+ }
1254
+
1255
+ .rte-smart-paste-shortcut {
1256
+ margin: 2px 0 0;
1257
+ font-size: 11px;
1258
+ color: #64748b;
1259
+ }
1260
+
1261
+ .${u}.rte-smart-paste-theme-dark .rte-smart-paste-shortcut {
1262
+ color: #94a3b8;
1263
+ }
1264
+
1265
+ .rte-smart-paste-live {
1266
+ position: absolute;
1267
+ width: 1px;
1268
+ height: 1px;
1269
+ margin: -1px;
1270
+ padding: 0;
1271
+ overflow: hidden;
1272
+ clip: rect(0 0 0 0);
1273
+ border: 0;
1274
+ }
1275
+
1276
+ @media (max-width: 768px) {
1277
+ .${u} {
1278
+ left: 10px !important;
1279
+ right: 10px;
1280
+ top: 10px !important;
1281
+ width: auto !important;
1282
+ max-height: calc(100vh - 20px);
1283
+ }
1284
+
1285
+ .rte-smart-paste-profile-grid {
1286
+ grid-template-columns: 1fr;
1287
+ }
1288
+ }
1289
+ `, document.head.appendChild(e);
1290
+ }
1291
+ const st = (e = {}) => {
1292
+ const t = V(e), a = /* @__PURE__ */ new Set();
1293
+ return nt(), {
1294
+ name: "smartPaste",
1295
+ toolbar: [
1296
+ {
1297
+ id: "smartPasteGroup",
1298
+ label: "Smart Paste",
1299
+ type: "group",
1300
+ command: "smartPaste",
1301
+ items: [
1302
+ {
1303
+ id: "smartPaste",
1304
+ label: "Smart Paste Panel",
1305
+ command: "toggleSmartPastePanel",
1306
+ shortcut: "Mod-Alt-Shift-s",
1307
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8.5 4.5h7l3 3V18a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 6.5 18V7a2.5 2.5 0 0 1 2-2.45Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M15.5 4.5V8h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.3 12h5.4M9.3 15h5.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'
1308
+ },
1309
+ {
1310
+ id: "smartPasteProfile",
1311
+ label: "Cycle Smart Paste Profile",
1312
+ command: "cycleSmartPasteProfile",
1313
+ shortcut: "Mod-Alt-Shift-v",
1314
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 7.5h10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="17.5" cy="7.5" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 12h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12.5" cy="12" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 16.5h12" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="9.5" cy="16.5" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'
1315
+ },
1316
+ {
1317
+ id: "smartPasteToggle",
1318
+ label: "Toggle Smart Paste",
1319
+ command: "toggleSmartPasteEnabled",
1320
+ shortcut: "Mod-Alt-Shift-g",
1321
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3.5" y="8" width="17" height="8" rx="4" stroke="currentColor" stroke-width="1.6"/><circle cx="8" cy="12" r="2.6" fill="currentColor"/><path d="M14.5 12h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'
1322
+ }
1323
+ ]
1324
+ }
1325
+ ],
1326
+ commands: {
1327
+ smartPaste: (r, n) => {
1328
+ const o = T(n, !1, !1);
1329
+ if (!o)
1330
+ return !1;
1331
+ const s = d.get(o) || t;
1332
+ return m(o, s), d.set(o, s), b = o, ye(o), !0;
1333
+ },
1334
+ toggleSmartPastePanel: (r, n) => {
1335
+ const o = T(n, !1, !1);
1336
+ if (!o)
1337
+ return !1;
1338
+ const s = d.get(o) || t;
1339
+ return m(o, s), d.set(o, s), b = o, xe(o, typeof r == "boolean" ? r : void 0);
1340
+ },
1341
+ cycleSmartPasteProfile: (r, n) => {
1342
+ const o = T(n, !1, !1);
1343
+ if (!o)
1344
+ return !1;
1345
+ const s = d.get(o) || t, l = m(o, s);
1346
+ return d.set(o, s), l.profile = ae(l.profile), S(o), !0;
1347
+ },
1348
+ setSmartPasteProfile: (r, n) => {
1349
+ const o = T(n, !1, !1);
1350
+ if (!o)
1351
+ return !1;
1352
+ const s = d.get(o) || t, l = m(o, s);
1353
+ return d.set(o, s), l.profile = H(r), S(o), !0;
1354
+ },
1355
+ toggleSmartPasteEnabled: (r, n) => {
1356
+ const o = T(n, !1, !1);
1357
+ if (!o)
1358
+ return !1;
1359
+ const s = d.get(o) || t, l = m(o, s);
1360
+ return d.set(o, s), l.enabled = typeof r == "boolean" ? r : !l.enabled, z(o), S(o), !0;
1361
+ },
1362
+ setSmartPasteOptions: (r, n) => {
1363
+ var f, p, y, g, P, C;
1364
+ const o = T(n, !1, !1);
1365
+ if (!o || !r || typeof r != "object")
1366
+ return !1;
1367
+ const s = d.get(o) || t, l = ce(s), c = V({
1368
+ ...l,
1369
+ ...r,
1370
+ labels: {
1371
+ ...s.labels,
1372
+ ...r.labels || {}
1373
+ },
1374
+ profileOptions: {
1375
+ ...l.profileOptions,
1376
+ ...r.profileOptions || {},
1377
+ fidelity: {
1378
+ ...((f = l.profileOptions) == null ? void 0 : f.fidelity) || {},
1379
+ ...((p = r.profileOptions) == null ? void 0 : p.fidelity) || {}
1380
+ },
1381
+ balanced: {
1382
+ ...((y = l.profileOptions) == null ? void 0 : y.balanced) || {},
1383
+ ...((g = r.profileOptions) == null ? void 0 : g.balanced) || {}
1384
+ },
1385
+ plain: {
1386
+ ...((P = l.profileOptions) == null ? void 0 : P.plain) || {},
1387
+ ...((C = r.profileOptions) == null ? void 0 : C.plain) || {}
1388
+ }
1389
+ },
1390
+ normalizeText: r.normalizeText || s.normalizeText
1391
+ });
1392
+ d.set(o, c);
1393
+ const i = m(o, c);
1394
+ return typeof r.enabled == "boolean" && (i.enabled = r.enabled), r.defaultProfile && (i.profile = H(r.defaultProfile)), S(o), z(o), !0;
1395
+ },
1396
+ getSmartPasteState: (r, n) => {
1397
+ const o = T(n, !1, !1);
1398
+ if (!o)
1399
+ return !1;
1400
+ const s = d.get(o) || t, l = m(o, s), c = ve(l);
1401
+ if (typeof r == "function")
1402
+ try {
1403
+ r(c);
1404
+ } catch {
1405
+ }
1406
+ return o.__smartPasteState = c, o.dispatchEvent(
1407
+ new CustomEvent("editora:smart-paste-state", {
1408
+ bubbles: !0,
1409
+ detail: c
1410
+ })
1411
+ ), !0;
1412
+ }
1413
+ },
1414
+ keymap: {
1415
+ "Mod-Alt-Shift-s": "toggleSmartPastePanel",
1416
+ "Mod-Alt-Shift-S": "toggleSmartPastePanel",
1417
+ "Mod-Alt-Shift-v": "cycleSmartPasteProfile",
1418
+ "Mod-Alt-Shift-V": "cycleSmartPasteProfile",
1419
+ "Mod-Alt-Shift-g": "toggleSmartPasteEnabled",
1420
+ "Mod-Alt-Shift-G": "toggleSmartPasteEnabled"
1421
+ },
1422
+ init: function(n) {
1423
+ W += 1;
1424
+ const o = this && typeof this.__pluginConfig == "object" ? V({ ...ce(t), ...this.__pluginConfig }) : t;
1425
+ at(o);
1426
+ const s = T(
1427
+ n != null && n.editorElement ? { editorElement: n.editorElement } : void 0,
1428
+ !1,
1429
+ !1
1430
+ );
1431
+ if (!s)
1432
+ return;
1433
+ b = s, a.add(s);
1434
+ const l = m(s, o);
1435
+ l.enabled = o.enabled, l.profile = o.defaultProfile, d.set(s, o), z(s);
1436
+ },
1437
+ destroy: () => {
1438
+ a.forEach((r) => be(r)), a.clear(), W = Math.max(0, W - 1), !(W > 0) && ot();
1439
+ }
1440
+ };
1441
+ };
1442
+ export {
1443
+ st as SmartPastePlugin
1444
+ };