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