@editora/plugins 1.0.16 → 1.0.18
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.
- package/dist/CodePlugin.native-Bwf25lLX.js +460 -0
- package/dist/CodePlugin.native-Cpp4u3Jl.mjs +648 -0
- package/dist/a11y-checker.cjs.js +16 -16
- package/dist/a11y-checker.esm.js +79 -75
- package/dist/anchor.cjs.js +9 -9
- package/dist/anchor.esm.js +61 -60
- package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
- package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
- package/dist/approval-workflow.cjs.js +5 -5
- package/dist/approval-workflow.esm.js +105 -104
- package/dist/background-color.cjs.js +1 -1
- package/dist/background-color.esm.js +1 -1
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +226 -202
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +9 -4
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +154 -116
- package/dist/citations.cjs.js +43 -18
- package/dist/citations.esm.js +465 -446
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +21 -20
- package/dist/code-sample.cjs.js +85 -66
- package/dist/code-sample.esm.js +301 -190
- package/dist/code.cjs.js +1 -669
- package/dist/code.esm.js +2 -4560
- package/dist/collaboration.cjs.js +68 -0
- package/dist/collaboration.esm.js +7428 -0
- package/dist/comments.cjs.js +11 -11
- package/dist/comments.esm.js +284 -237
- package/dist/conditional-content.cjs.js +67 -60
- package/dist/conditional-content.esm.js +270 -220
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +28 -27
- package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
- package/dist/dialogHelpers-zU6zpMIA.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-Jf0RbSks.js → documentManager-BDz6tovy.js} +2 -2
- package/dist/{documentManager-CTqRftU8.mjs → documentManager-yjRBab4v.mjs} +3 -3
- package/dist/embed-iframe.cjs.js +37 -17
- package/dist/embed-iframe.esm.js +188 -143
- package/dist/emojis.cjs.js +13 -10
- package/dist/emojis.esm.js +288 -76
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +9 -7
- package/dist/escapeHtml-D2Zh82pD.js +1 -0
- package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +48 -41
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +67 -60
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +2 -1
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +40 -36
- package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
- package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
- package/dist/index-Bm1eqYHh.mjs +194 -0
- package/dist/index-CoflqYuK.js +30 -0
- package/dist/index-CxhJLMPS.js +221 -0
- package/dist/{index-D3CycEFU.mjs → index-Di1ZqIDs.mjs} +6420 -6232
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-DQ78mYYo.mjs → index.es-B7pVaNEV.mjs} +1558 -1542
- package/dist/{index.es-CE_A4QSm.js → index.es-I9N4o4Iq.js} +5 -5
- package/dist/index.esm.js +17 -15
- package/dist/{jspdf.es.min-BoS80556.js → jspdf.es.min-B5Idu0Wl.js} +2 -2
- package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-BCzHIwvz.mjs} +3 -2
- package/dist/link.cjs.js +17 -13
- package/dist/link.esm.js +138 -69
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +66 -33
- package/dist/math.cjs.js +22 -22
- package/dist/math.esm.js +221 -126
- package/dist/media-manager.cjs.js +12 -12
- package/dist/media-manager.esm.js +55 -50
- package/dist/mentions.cjs.js +2 -2
- package/dist/mentions.esm.js +17 -12
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +43 -42
- package/dist/plugins.css +1 -1
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +30 -27
- package/dist/{purify.es-T2a3nLiC.js → purify.es-DWpzYfqy.js} +1 -1
- package/dist/{purify.es-DHhaBdbu.mjs → purify.es-Dewe88eZ.mjs} +2 -2
- package/dist/slash-commands.cjs.js +13 -7
- package/dist/slash-commands.esm.js +90 -79
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +85 -81
- package/dist/special-characters.cjs.js +6 -3
- package/dist/special-characters.esm.js +72 -25
- package/dist/spell-check.cjs.js +8 -8
- package/dist/spell-check.esm.js +10189 -295
- package/dist/table.cjs.js +166 -13
- package/dist/table.esm.js +543 -266
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +290 -264
- package/dist/text-color.cjs.js +1 -1
- package/dist/text-color.esm.js +1 -1
- package/dist/translation-workflow.cjs.js +4 -4
- package/dist/translation-workflow.esm.js +33 -31
- package/dist/version-diff.cjs.js +6 -6
- package/dist/version-diff.esm.js +40 -40
- package/package.json +10 -4
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/index-BFsKNTTj.mjs +0 -145
- package/dist/index-CvJk4DKa.js +0 -221
- package/dist/index-tqLTHcO6.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function H(e, t) {
|
|
2
2
|
const o = Array.from({ length: t }).map(() => "<th><p><br></p></th>").join(""), n = Array.from({ length: e }).map(
|
|
3
3
|
() => `<tr>${Array.from({ length: t }).map(() => "<td><p><br></p></td>").join("")}</tr>`
|
|
4
4
|
).join("");
|
|
@@ -59,7 +59,7 @@ function q() {
|
|
|
59
59
|
id: "table-3x3",
|
|
60
60
|
label: "Table 3x3",
|
|
61
61
|
description: "Insert a 3 x 3 table",
|
|
62
|
-
action: ({ insertHTML: e }) => e(
|
|
62
|
+
action: ({ insertHTML: e }) => e(H(3, 3)),
|
|
63
63
|
keywords: ["table", "grid", "rows", "columns"]
|
|
64
64
|
},
|
|
65
65
|
{
|
|
@@ -206,31 +206,37 @@ function B() {
|
|
|
206
206
|
padding: 12px;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
${u} .rte-slash-panel
|
|
209
|
+
${u} .rte-slash-panel,
|
|
210
|
+
.rte-slash-panel.rte-slash-theme-dark {
|
|
210
211
|
border-color: #364152;
|
|
211
212
|
background: #1f2937;
|
|
212
213
|
box-shadow: 0 22px 44px rgba(0, 0, 0, 0.48);
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
${u} .rte-slash-item
|
|
216
|
+
${u} .rte-slash-item,
|
|
217
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item {
|
|
216
218
|
color: #e5e7eb;
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
${u} .rte-slash-item:hover,
|
|
220
|
-
${u} .rte-slash-item.active
|
|
222
|
+
${u} .rte-slash-item.active,
|
|
223
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item:hover,
|
|
224
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item.active {
|
|
221
225
|
background: #334155;
|
|
222
226
|
color: #bfdbfe;
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
${u} .rte-slash-item-description,
|
|
226
|
-
${u} .rte-slash-empty
|
|
230
|
+
${u} .rte-slash-empty,
|
|
231
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item-description,
|
|
232
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-empty {
|
|
227
233
|
color: #9ca3af;
|
|
228
234
|
}
|
|
229
235
|
`, document.head.appendChild(e);
|
|
230
236
|
}
|
|
231
|
-
const
|
|
232
|
-
let b = !1, f = null, h = 0,
|
|
233
|
-
function
|
|
237
|
+
const c = ".rte-content, .editora-content", z = '[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark', g = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap();
|
|
238
|
+
let b = !1, f = null, h = 0, P = 0;
|
|
239
|
+
function _(e) {
|
|
234
240
|
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
|
|
235
241
|
}
|
|
236
242
|
function I(e) {
|
|
@@ -240,27 +246,27 @@ function F(e) {
|
|
|
240
246
|
if (e?.contentElement instanceof HTMLElement) return e.contentElement;
|
|
241
247
|
if (e?.editorElement instanceof HTMLElement) {
|
|
242
248
|
const n = e.editorElement;
|
|
243
|
-
if (n.matches(
|
|
244
|
-
const r = n.querySelector(
|
|
249
|
+
if (n.matches(c)) return n;
|
|
250
|
+
const r = n.querySelector(c);
|
|
245
251
|
if (r instanceof HTMLElement) return r;
|
|
246
252
|
}
|
|
247
253
|
const t = window.getSelection();
|
|
248
254
|
if (t && t.rangeCount > 0) {
|
|
249
|
-
const n = t.getRangeAt(0).startContainer, i = (n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(
|
|
255
|
+
const n = t.getRangeAt(0).startContainer, i = (n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(c);
|
|
250
256
|
if (i) return i;
|
|
251
257
|
}
|
|
252
258
|
const o = document.activeElement;
|
|
253
259
|
if (o) {
|
|
254
|
-
if (o.matches(
|
|
255
|
-
const n = o.closest(
|
|
260
|
+
if (o.matches(c)) return o;
|
|
261
|
+
const n = o.closest(c);
|
|
256
262
|
if (n) return n;
|
|
257
263
|
}
|
|
258
|
-
return document.querySelector(
|
|
264
|
+
return document.querySelector(c);
|
|
259
265
|
}
|
|
260
266
|
function m(e) {
|
|
261
267
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
262
268
|
}
|
|
263
|
-
function
|
|
269
|
+
function j(e) {
|
|
264
270
|
return e ? /\s|[([{"'`]/.test(e) : !0;
|
|
265
271
|
}
|
|
266
272
|
function E(e) {
|
|
@@ -273,7 +279,7 @@ function y(e, t) {
|
|
|
273
279
|
const o = window.getSelection();
|
|
274
280
|
o && (o.removeAllRanges(), o.addRange(t), e.focus({ preventScroll: !0 }));
|
|
275
281
|
}
|
|
276
|
-
function
|
|
282
|
+
function K(e) {
|
|
277
283
|
if (!e.collapsed) return null;
|
|
278
284
|
const t = e.startContainer, o = e.startOffset;
|
|
279
285
|
if (t.nodeType === Node.TEXT_NODE) {
|
|
@@ -300,9 +306,9 @@ function j(e) {
|
|
|
300
306
|
}
|
|
301
307
|
return null;
|
|
302
308
|
}
|
|
303
|
-
function
|
|
309
|
+
function Q(e, t, o, n) {
|
|
304
310
|
const r = e.lastIndexOf(t);
|
|
305
|
-
if (r < 0 || n && !
|
|
311
|
+
if (r < 0 || n && !j(e[r - 1]))
|
|
306
312
|
return null;
|
|
307
313
|
const i = e.slice(r + 1);
|
|
308
314
|
return /\s/.test(i) || i.length > o ? null : {
|
|
@@ -311,7 +317,7 @@ function K(e, t, o, n) {
|
|
|
311
317
|
startOffset: r
|
|
312
318
|
};
|
|
313
319
|
}
|
|
314
|
-
function
|
|
320
|
+
function U(e, t) {
|
|
315
321
|
const o = t.cloneRange();
|
|
316
322
|
o.collapse(!1);
|
|
317
323
|
const n = o.getClientRects();
|
|
@@ -324,10 +330,10 @@ function Q(e, t) {
|
|
|
324
330
|
}
|
|
325
331
|
function A(e, t) {
|
|
326
332
|
if (!e.panel) return;
|
|
327
|
-
const o =
|
|
328
|
-
n.style.display = "block", n.classList.add("show"), n.style.left = "0px", n.style.top = "0px";
|
|
329
|
-
const r = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight;
|
|
330
|
-
let
|
|
333
|
+
const o = U(e.editor, t), n = e.panel;
|
|
334
|
+
n.classList.toggle("rte-slash-theme-dark", !!e.editor.closest(z)), n.style.display = "block", n.classList.add("show"), n.style.left = "0px", n.style.top = "0px";
|
|
335
|
+
const r = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight, l = Math.max(8, Math.min(o.left, i - r.width - 8));
|
|
336
|
+
let d = o.bottom + 8;
|
|
331
337
|
d + r.height > a - 8 && (d = Math.max(8, o.top - r.height - 8)), n.style.position = "fixed", n.style.left = `${l}px`, n.style.top = `${d}px`;
|
|
332
338
|
}
|
|
333
339
|
function k(e, t) {
|
|
@@ -337,7 +343,7 @@ function k(e, t) {
|
|
|
337
343
|
const i = m(e.slice(0, r)), a = m(e.slice(r, r + t.length)), l = m(e.slice(r + t.length));
|
|
338
344
|
return `${i}<mark>${a}</mark>${l}`;
|
|
339
345
|
}
|
|
340
|
-
function
|
|
346
|
+
function W(e, t) {
|
|
341
347
|
if (e.panel && e.list) return;
|
|
342
348
|
const o = document.createElement("div");
|
|
343
349
|
o.className = "rte-slash-panel", o.style.display = "none", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false");
|
|
@@ -350,13 +356,13 @@ function U(e, t) {
|
|
|
350
356
|
const a = i.closest(".rte-slash-item");
|
|
351
357
|
if (!a) return;
|
|
352
358
|
const l = Number(a.getAttribute("data-index"));
|
|
353
|
-
Number.isFinite(l) &&
|
|
359
|
+
Number.isFinite(l) && N(e, l);
|
|
354
360
|
});
|
|
355
361
|
}
|
|
356
|
-
function
|
|
362
|
+
function s(e) {
|
|
357
363
|
e.panel && (e.panel.style.display = "none", e.panel.classList.remove("show"), e.isOpen = !1, e.filteredItems = [], e.activeIndex = 0, e.query = "", e.replaceRange = null, e.anchorRange = null);
|
|
358
364
|
}
|
|
359
|
-
function
|
|
365
|
+
function Z(e, t, o) {
|
|
360
366
|
if (!t) return e.slice(0, o);
|
|
361
367
|
const n = t.toLowerCase();
|
|
362
368
|
return e.filter((i) => [
|
|
@@ -367,7 +373,7 @@ function W(e, t, o) {
|
|
|
367
373
|
...i.keywords || []
|
|
368
374
|
].join(" ").toLowerCase().includes(n)).slice(0, o);
|
|
369
375
|
}
|
|
370
|
-
function
|
|
376
|
+
function G(e, t) {
|
|
371
377
|
if (!e.list) return;
|
|
372
378
|
const o = e.list;
|
|
373
379
|
if (o.innerHTML = "", e.filteredItems.length === 0) {
|
|
@@ -383,7 +389,7 @@ function Z(e, t) {
|
|
|
383
389
|
`, o.appendChild(i);
|
|
384
390
|
}), e.filteredItems.length > 0 && o.setAttribute("aria-activedescendant", `rte-slash-item-${e.instanceId}-${e.activeIndex}`);
|
|
385
391
|
}
|
|
386
|
-
function
|
|
392
|
+
function V(e, t) {
|
|
387
393
|
if (t === e.innerHTML) return;
|
|
388
394
|
const o = window.execEditorCommand || window.executeEditorCommand;
|
|
389
395
|
if (typeof o == "function")
|
|
@@ -392,7 +398,7 @@ function G(e, t) {
|
|
|
392
398
|
} catch {
|
|
393
399
|
}
|
|
394
400
|
}
|
|
395
|
-
function
|
|
401
|
+
function X(e) {
|
|
396
402
|
e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
397
403
|
}
|
|
398
404
|
function L(e, t) {
|
|
@@ -416,7 +422,7 @@ function L(e, t) {
|
|
|
416
422
|
}
|
|
417
423
|
return !0;
|
|
418
424
|
}
|
|
419
|
-
function
|
|
425
|
+
function J(e, t) {
|
|
420
426
|
e.focus({ preventScroll: !0 });
|
|
421
427
|
try {
|
|
422
428
|
if (document.execCommand("insertText", !1, t))
|
|
@@ -433,7 +439,7 @@ function X(e, t) {
|
|
|
433
439
|
const i = document.createRange();
|
|
434
440
|
return i.setStart(r, r.length), i.collapse(!0), y(e, i), !0;
|
|
435
441
|
}
|
|
436
|
-
function
|
|
442
|
+
function Y(e, t) {
|
|
437
443
|
switch (e.toLowerCase()) {
|
|
438
444
|
case "paragraph":
|
|
439
445
|
case "p":
|
|
@@ -501,9 +507,9 @@ function S(e, t, o) {
|
|
|
501
507
|
}) !== !1) return !0;
|
|
502
508
|
} catch {
|
|
503
509
|
}
|
|
504
|
-
return
|
|
510
|
+
return Y(t, o);
|
|
505
511
|
}
|
|
506
|
-
async function
|
|
512
|
+
async function ee(e, t) {
|
|
507
513
|
const o = e.editor, n = I(o), r = {
|
|
508
514
|
editor: o,
|
|
509
515
|
editorRoot: n,
|
|
@@ -514,7 +520,7 @@ async function Y(e, t) {
|
|
|
514
520
|
};
|
|
515
521
|
return t.action ? await Promise.resolve(t.action(r)) !== !1 : t.insertHTML ? L(o, t.insertHTML) : t.command ? S(o, t.command, t.commandValue) : !1;
|
|
516
522
|
}
|
|
517
|
-
async function
|
|
523
|
+
async function N(e, t) {
|
|
518
524
|
if (t < 0 || t >= e.filteredItems.length || !e.replaceRange) return;
|
|
519
525
|
const o = e.filteredItems[t], n = e.editor, r = n.innerHTML, i = `${e.trigger}${e.query}`;
|
|
520
526
|
if (!window.getSelection()) return;
|
|
@@ -525,11 +531,11 @@ async function M(e, t) {
|
|
|
525
531
|
d.collapse(!0), y(n, d);
|
|
526
532
|
let x = !1;
|
|
527
533
|
try {
|
|
528
|
-
x = await
|
|
534
|
+
x = await ee(e, o);
|
|
529
535
|
} catch {
|
|
530
536
|
x = !1;
|
|
531
537
|
}
|
|
532
|
-
|
|
538
|
+
s(e), x ? (X(n), V(n, r)) : i && J(n, i), n.focus({ preventScroll: !0 });
|
|
533
539
|
}
|
|
534
540
|
function R(e, t) {
|
|
535
541
|
if (e.filteredItems.length === 0) return;
|
|
@@ -546,61 +552,64 @@ function R(e, t) {
|
|
|
546
552
|
function T(e) {
|
|
547
553
|
if (!(!e.isOpen || !e.panel || !e.anchorRange)) {
|
|
548
554
|
if (!e.editor.isConnected) {
|
|
549
|
-
|
|
555
|
+
s(e);
|
|
550
556
|
return;
|
|
551
557
|
}
|
|
552
558
|
A(e, e.anchorRange);
|
|
553
559
|
}
|
|
554
560
|
}
|
|
555
|
-
function
|
|
556
|
-
|
|
561
|
+
function M(e, t, o, n, r, i) {
|
|
562
|
+
W(e, t), e.query = n, e.trigger = r, e.replaceRange = i.cloneRange(), e.anchorRange = o.cloneRange(), e.filteredItems = Z(e.items, n, t.maxSuggestions), e.activeIndex = 0, e.isOpen = !0, e.panel && (G(e, t), A(e, o));
|
|
557
563
|
}
|
|
558
|
-
function
|
|
564
|
+
function te(e, t) {
|
|
559
565
|
const o = e.editor;
|
|
560
566
|
if (o.getAttribute("contenteditable") === "false") {
|
|
561
|
-
|
|
567
|
+
s(e);
|
|
562
568
|
return;
|
|
563
569
|
}
|
|
564
570
|
const n = E(o);
|
|
565
571
|
if (!n || !n.collapsed) {
|
|
566
|
-
|
|
572
|
+
s(e);
|
|
567
573
|
return;
|
|
568
574
|
}
|
|
569
|
-
const r =
|
|
575
|
+
const r = K(n);
|
|
570
576
|
if (!r) {
|
|
571
|
-
|
|
577
|
+
s(e);
|
|
572
578
|
return;
|
|
573
579
|
}
|
|
574
|
-
const i =
|
|
580
|
+
const i = Q(
|
|
575
581
|
r.textBefore,
|
|
576
582
|
t.triggerChar,
|
|
577
583
|
t.maxQueryLength,
|
|
578
584
|
t.requireBoundary
|
|
579
585
|
);
|
|
580
586
|
if (!i) {
|
|
581
|
-
|
|
587
|
+
s(e);
|
|
582
588
|
return;
|
|
583
589
|
}
|
|
584
590
|
if (i.query.length < t.minChars) {
|
|
585
|
-
|
|
591
|
+
s(e);
|
|
586
592
|
return;
|
|
587
593
|
}
|
|
594
|
+
if (e.dismissedNode === r.node && e.dismissedOffset === i.startOffset)
|
|
595
|
+
return;
|
|
596
|
+
e.dismissedNode = null, e.dismissedOffset = -1;
|
|
588
597
|
const a = n.cloneRange();
|
|
589
|
-
a.setStart(r.node, i.startOffset), a.setEnd(r.node, r.caretOffset),
|
|
598
|
+
a.setStart(r.node, i.startOffset), a.setEnd(r.node, r.caretOffset), M(e, t, n, i.query, i.trigger, a);
|
|
590
599
|
}
|
|
591
|
-
function
|
|
600
|
+
function O(e, t) {
|
|
592
601
|
const o = e.editor;
|
|
593
602
|
if (o.getAttribute("contenteditable") === "false")
|
|
594
603
|
return !1;
|
|
595
604
|
let n = E(o);
|
|
596
605
|
n || (n = document.createRange(), n.selectNodeContents(o), n.collapse(!1), y(o, n));
|
|
597
606
|
const r = n.cloneRange();
|
|
598
|
-
return r.collapse(!0),
|
|
607
|
+
return r.collapse(!0), M(e, t, n, "", t.triggerChar, r), !0;
|
|
599
608
|
}
|
|
600
|
-
function
|
|
609
|
+
function ne(e) {
|
|
601
610
|
return !(e.metaKey || e.ctrlKey) || e.altKey ? !1 : e.key === "/" || e.code === "Slash";
|
|
602
611
|
}
|
|
603
|
-
function
|
|
612
|
+
function re(e, t) {
|
|
604
613
|
return {
|
|
605
614
|
editor: e,
|
|
606
615
|
panel: null,
|
|
@@ -612,18 +621,20 @@ function ne(e, t) {
|
|
|
612
621
|
query: "",
|
|
613
622
|
trigger: t.triggerChar,
|
|
614
623
|
isOpen: !1,
|
|
615
|
-
instanceId: ++
|
|
616
|
-
anchorRange: null
|
|
624
|
+
instanceId: ++P,
|
|
625
|
+
anchorRange: null,
|
|
626
|
+
dismissedNode: null,
|
|
627
|
+
dismissedOffset: -1
|
|
617
628
|
};
|
|
618
629
|
}
|
|
619
630
|
function w(e, t) {
|
|
620
631
|
const o = g.get(e);
|
|
621
632
|
if (o)
|
|
622
633
|
return o.items = t.items, o;
|
|
623
|
-
const n =
|
|
634
|
+
const n = re(e, t);
|
|
624
635
|
return g.set(e, n), n;
|
|
625
636
|
}
|
|
626
|
-
function
|
|
637
|
+
function oe(e) {
|
|
627
638
|
const t = g.get(e);
|
|
628
639
|
t && (t.panel?.parentNode && t.panel.parentNode.removeChild(t.panel), g.delete(e));
|
|
629
640
|
}
|
|
@@ -631,15 +642,15 @@ function C(e, t, o) {
|
|
|
631
642
|
if (p.has(e)) return;
|
|
632
643
|
const n = {
|
|
633
644
|
input: () => {
|
|
634
|
-
|
|
645
|
+
te(t, o);
|
|
635
646
|
},
|
|
636
647
|
keydown: (r) => {
|
|
637
648
|
if (t.editor.getAttribute("contenteditable") === "false") {
|
|
638
|
-
|
|
649
|
+
s(t);
|
|
639
650
|
return;
|
|
640
651
|
}
|
|
641
|
-
if (!t.isOpen &&
|
|
642
|
-
r.preventDefault(),
|
|
652
|
+
if (!t.isOpen && ne(r)) {
|
|
653
|
+
r.preventDefault(), O(t, o);
|
|
643
654
|
return;
|
|
644
655
|
}
|
|
645
656
|
if (t.isOpen) {
|
|
@@ -653,14 +664,14 @@ function C(e, t, o) {
|
|
|
653
664
|
}
|
|
654
665
|
if (r.key === "Enter" || r.key === "Tab") {
|
|
655
666
|
if (t.filteredItems.length === 0) {
|
|
656
|
-
r.key === "Tab" && r.preventDefault(),
|
|
667
|
+
r.key === "Tab" && r.preventDefault(), s(t);
|
|
657
668
|
return;
|
|
658
669
|
}
|
|
659
|
-
r.preventDefault(),
|
|
670
|
+
r.preventDefault(), N(t, t.activeIndex);
|
|
660
671
|
return;
|
|
661
672
|
}
|
|
662
673
|
if (r.key === "Escape") {
|
|
663
|
-
r.preventDefault(),
|
|
674
|
+
r.preventDefault(), t.replaceRange && (t.dismissedNode = t.replaceRange.startContainer, t.dismissedOffset = t.replaceRange.startOffset), s(t);
|
|
664
675
|
return;
|
|
665
676
|
}
|
|
666
677
|
}
|
|
@@ -668,19 +679,19 @@ function C(e, t, o) {
|
|
|
668
679
|
blur: () => {
|
|
669
680
|
window.setTimeout(() => {
|
|
670
681
|
const r = document.activeElement;
|
|
671
|
-
t.panel && r && t.panel.contains(r) ||
|
|
682
|
+
t.panel && r && t.panel.contains(r) || s(t);
|
|
672
683
|
}, 0);
|
|
673
684
|
},
|
|
674
685
|
mousedown: (r) => {
|
|
675
686
|
if (!t.isOpen || !t.panel) return;
|
|
676
687
|
const i = r.target;
|
|
677
|
-
i && !t.panel.contains(i) && !e.contains(i) &&
|
|
688
|
+
i && !t.panel.contains(i) && !e.contains(i) && s(t);
|
|
678
689
|
},
|
|
679
690
|
selectionchange: () => {
|
|
680
691
|
if (!t.isOpen) return;
|
|
681
692
|
const r = E(e);
|
|
682
693
|
if (!r || !r.collapsed) {
|
|
683
|
-
|
|
694
|
+
s(t);
|
|
684
695
|
return;
|
|
685
696
|
}
|
|
686
697
|
t.anchorRange = r.cloneRange(), T(t);
|
|
@@ -691,24 +702,24 @@ function C(e, t, o) {
|
|
|
691
702
|
};
|
|
692
703
|
e.addEventListener("input", n.input), e.addEventListener("keydown", n.keydown), e.addEventListener("blur", n.blur), document.addEventListener("mousedown", n.mousedown, !0), document.addEventListener("selectionchange", n.selectionchange), window.addEventListener("resize", n.reposition, { passive: !0 }), window.addEventListener("scroll", n.reposition, !0), p.set(e, n);
|
|
693
704
|
}
|
|
694
|
-
function
|
|
705
|
+
function ie(e) {
|
|
695
706
|
const t = p.get(e);
|
|
696
707
|
t && (e.removeEventListener("input", t.input), e.removeEventListener("keydown", t.keydown), e.removeEventListener("blur", t.blur), document.removeEventListener("mousedown", t.mousedown, !0), document.removeEventListener("selectionchange", t.selectionchange), window.removeEventListener("resize", t.reposition), window.removeEventListener("scroll", t.reposition, !0), p.delete(e));
|
|
697
708
|
}
|
|
698
|
-
function
|
|
709
|
+
function ae(e) {
|
|
699
710
|
b || (b = !0, f = (t) => {
|
|
700
711
|
const o = t.target;
|
|
701
712
|
if (!(o instanceof Node)) return;
|
|
702
|
-
const r =
|
|
713
|
+
const r = _(o)?.closest(c) || null;
|
|
703
714
|
if (!r) return;
|
|
704
715
|
const i = w(r, e);
|
|
705
716
|
C(r, i, e);
|
|
706
717
|
}, document.addEventListener("focusin", f, !0));
|
|
707
718
|
}
|
|
708
|
-
function
|
|
719
|
+
function le() {
|
|
709
720
|
!b || !f || (document.removeEventListener("focusin", f, !0), b = !1, f = null);
|
|
710
721
|
}
|
|
711
|
-
const
|
|
722
|
+
const se = (e = {}) => {
|
|
712
723
|
B();
|
|
713
724
|
const t = D(e);
|
|
714
725
|
return {
|
|
@@ -726,7 +737,7 @@ const le = (e = {}) => {
|
|
|
726
737
|
const r = F(n);
|
|
727
738
|
if (!r) return !1;
|
|
728
739
|
const i = w(r, t);
|
|
729
|
-
return C(r, i, t),
|
|
740
|
+
return C(r, i, t), O(i, t);
|
|
730
741
|
}
|
|
731
742
|
},
|
|
732
743
|
keymap: {
|
|
@@ -734,19 +745,19 @@ const le = (e = {}) => {
|
|
|
734
745
|
"Mod-Shift-7": "openSlashCommands"
|
|
735
746
|
},
|
|
736
747
|
init: () => {
|
|
737
|
-
h += 1,
|
|
748
|
+
h += 1, ae(t), Array.from(document.querySelectorAll(c)).forEach((n) => {
|
|
738
749
|
const r = w(n, t);
|
|
739
750
|
C(n, r, t);
|
|
740
751
|
});
|
|
741
752
|
},
|
|
742
753
|
destroy: () => {
|
|
743
|
-
h = Math.max(0, h - 1), Array.from(document.querySelectorAll(
|
|
754
|
+
h = Math.max(0, h - 1), Array.from(document.querySelectorAll(c)).forEach((n) => {
|
|
744
755
|
const r = g.get(n);
|
|
745
|
-
r && (
|
|
746
|
-
}), h === 0 &&
|
|
756
|
+
r && (s(r), ie(n), oe(n));
|
|
757
|
+
}), h === 0 && le();
|
|
747
758
|
}
|
|
748
759
|
};
|
|
749
760
|
};
|
|
750
761
|
export {
|
|
751
|
-
|
|
762
|
+
se as SlashCommandsPlugin
|
|
752
763
|
};
|
package/dist/smart-paste.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",le="__editoraCommandEditorRoot",ie="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)',ke=typeof NodeFilter<"u"?NodeFilter.SHOW_COMMENT:128,ce="__editoraSmartPasteHandled",
|
|
2
|
-
`)}function z(e){return e==="balanced"||e==="plain"?e:"fidelity"}function Z(e,t){return{keepStyles:e?.keepStyles??t.keepStyles,keepClasses:e?.keepClasses??t.keepClasses,keepDataAttributes:e?.keepDataAttributes??t.keepDataAttributes,preserveTables:e?.preserveTables??t.preserveTables}}function K(e={}){const t=e.profileOptions||{};return{enabled:e.enabled!==!1,defaultProfile:z(e.defaultProfile),maxHtmlLength:Math.max(8e3,Math.min(8e5,Number(e.maxHtmlLength??22e4))),removeComments:e.removeComments!==!1,normalizeWhitespace:e.normalizeWhitespace!==!1,labels:{...$e,...e.labels||{}},normalizeText:e.normalizeText||Oe,profileOptions:{fidelity:Z(t.fidelity,Y.fidelity),balanced:Z(t.balanced,Y.balanced),plain:Z(t.plain,Y.plain)}}}function de(e){return{enabled:e.enabled,defaultProfile:e.defaultProfile,maxHtmlLength:e.maxHtmlLength,removeComments:e.removeComments,normalizeWhitespace:e.normalizeWhitespace,labels:{...e.labels},normalizeText:e.normalizeText,profileOptions:{fidelity:{...e.profileOptions.fidelity},balanced:{...e.profileOptions.balanced},plain:{...e.profileOptions.plain}}}}function te(e){return e.closest(ee)||e}function H(e){if(!e)return null;if(e.matches(y))return e;const t=e.querySelector(y);return t instanceof HTMLElement?t:null}function Re(){if(typeof window>"u")return null;const e=window[le];if(!(e instanceof HTMLElement))return null;window[le]=null;const t=H(e);if(t)return t;const a=e.closest(ee);if(a){const n=H(a);if(n)return n}const r=e.closest(y);return r instanceof HTMLElement?r:null}function _e(e){const t=e.closest("[data-editora-editor]");if(t&&H(t)===e)return t;let a=e;for(;a;){if(a.matches(ee)&&(a===e||H(a)===e))return a;a=a.parentElement}return te(e)}function me(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",le="__editoraCommandEditorRoot",ie="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)',ke=typeof NodeFilter<"u"?NodeFilter.SHOW_COMMENT:128,ce="__editoraSmartPasteHandled",Te=new Set(["script","style","meta","link","object","embed","iframe","svg","canvas","math","form","input","button","textarea","select","option"]),Ce=new Set(["table","thead","tbody","tfoot","tr","td","th","colgroup","col"]),Ae=new Set(["span","font"]),Pe=/^(https?:|mailto:|tel:|#|\/)/i,we=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,Le=new Set(["color","background-color","font-weight","font-style","text-decoration","text-align","font-size","font-family","line-height","letter-spacing","word-spacing","white-space","vertical-align","margin-left","margin-right","margin-top","margin-bottom","padding-left","padding-right","padding-top","padding-bottom","text-indent","border","border-top","border-right","border-bottom","border-left","border-color","border-width","border-style","list-style-type"]),$e={panelTitle:"Smart Paste",panelAriaLabel:"Smart paste panel",enabledText:"Smart paste is enabled",disabledText:"Smart paste is disabled",toggleOnText:"Disable Smart Paste",toggleOffText:"Enable Smart Paste",cycleProfileText:"Cycle Profile",profileLabel:"Profile",fidelityText:"Fidelity",balancedText:"Balanced",plainText:"Plain Text",lastPasteHeading:"Last Paste Result",lastPasteEmptyText:"Paste content to see cleanup metrics.",lastPasteSourceLabel:"Source",lastPasteProfileLabel:"Profile",lastPasteRemovedLabel:"Removed",lastPasteCharsLabel:"Output Chars",closeText:"Close",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+S/V/G",readonlyMessage:"Editor is read-only. Smart paste was skipped."},Y={fidelity:{keepStyles:!0,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},balanced:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},plain:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!1}},d=new WeakMap,L=new WeakMap,g=new Map,q=new WeakMap,j=new WeakMap,_=new Set;let I=0,Me=0,$=null,m=null,A=null,P=null,C=null,w=null;function X(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Oe(e){return e.replace(/\u00A0/g," ").replace(/\r\n?/g,`
|
|
2
|
+
`)}function z(e){return e==="balanced"||e==="plain"?e:"fidelity"}function Z(e,t){return{keepStyles:e?.keepStyles??t.keepStyles,keepClasses:e?.keepClasses??t.keepClasses,keepDataAttributes:e?.keepDataAttributes??t.keepDataAttributes,preserveTables:e?.preserveTables??t.preserveTables}}function K(e={}){const t=e.profileOptions||{};return{enabled:e.enabled!==!1,defaultProfile:z(e.defaultProfile),maxHtmlLength:Math.max(8e3,Math.min(8e5,Number(e.maxHtmlLength??22e4))),removeComments:e.removeComments!==!1,normalizeWhitespace:e.normalizeWhitespace!==!1,labels:{...$e,...e.labels||{}},normalizeText:e.normalizeText||Oe,profileOptions:{fidelity:Z(t.fidelity,Y.fidelity),balanced:Z(t.balanced,Y.balanced),plain:Z(t.plain,Y.plain)}}}function de(e){return{enabled:e.enabled,defaultProfile:e.defaultProfile,maxHtmlLength:e.maxHtmlLength,removeComments:e.removeComments,normalizeWhitespace:e.normalizeWhitespace,labels:{...e.labels},normalizeText:e.normalizeText,profileOptions:{fidelity:{...e.profileOptions.fidelity},balanced:{...e.profileOptions.balanced},plain:{...e.profileOptions.plain}}}}function te(e){return e.closest(ee)||e}function H(e){if(!e)return null;if(e.matches(y))return e;const t=e.querySelector(y);return t instanceof HTMLElement?t:null}function Re(){if(typeof window>"u")return null;const e=window[le];if(!(e instanceof HTMLElement))return null;window[le]=null;const t=H(e);if(t)return t;const a=e.closest(ee);if(a){const n=H(a);if(n)return n}const r=e.closest(y);return r instanceof HTMLElement?r:null}function _e(e){const t=e.closest("[data-editora-editor]");if(t&&H(t)===e)return t;let a=e;for(;a;){if(a.matches(ee)&&(a===e||H(a)===e))return a;a=a.parentElement}return te(e)}function me(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function T(e,t=!0,a=!0){if(V(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=H(e.editorElement);if(s)return s}const r=Re();if(r)return r;const n=window.getSelection();if(n&&n.rangeCount>0){const l=me(n.getRangeAt(0).startContainer)?.closest(y);if(l)return l}const o=document.activeElement;if(o){if(o.matches(y))return o;const s=o.closest(y);if(s)return s}if(a){if(m&&m.isConnected)return m;m&&!m.isConnected&&(m=null)}return t?document.querySelector(y):null}function ze(e){const t=e.target;if(t){const r=t.closest(y);if(r)return r}const a=window.getSelection();if(a&&a.rangeCount>0){const n=me(a.getRangeAt(0).startContainer)?.closest(y);if(n)return n}return null}function B(e){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}function He(e){const t=te(e);if(B(t))return!0;const a=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return B(a)?!0:B(document.documentElement)||B(document.body)}function F(e,t){e.classList.remove("rte-smart-paste-theme-dark"),He(t)&&e.classList.add("rte-smart-paste-theme-dark")}function ue(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function N(e,t,a){const r=_e(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",a),o.setAttribute("data-active",a?"true":"false"),o.setAttribute("aria-pressed",a?"true":"false")})}function p(e,t){d.has(e)||d.set(e,t);let a=L.get(e);return a||(a={enabled:t.enabled,profile:t.defaultProfile,lastReport:null},L.set(e,a)),rt(e),_.add(e),a}function be(e){const t=j.get(e);t&&(e.removeEventListener("paste",t,!0),j.delete(e))}function ge(e){be(e),g.get(e)?.remove(),g.delete(e),q.delete(e),d.delete(e),L.delete(e),_.delete(e),m===e&&(m=null)}function V(){Array.from(_).forEach(t=>{t.isConnected||ge(t)})}function Ne(e){for(let t=0;t<e.length;t+=1){const a=e[t];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let r=0;r<a.removedNodes.length;r+=1){const n=a.removedNodes[r];if(n.nodeType!==Node.ELEMENT_NODE)continue;const o=n;if(o.matches?.(y)||o.matches?.(`.${u}`)||o.querySelector?.(y)||o.querySelector?.(`.${u}`))return!0}}return!1}function re(e){return q.get(e)===!0}function O(e,t){const a=e.querySelector(".rte-smart-paste-live");a&&(a.textContent=t)}function J(e,t){const a=t.normalizeText(e);return t.normalizeWhitespace?a.split(`
|
|
3
3
|
`).map(n=>n.replace(/[\t ]+/g," ").trimEnd()).join(`
|
|
4
4
|
`).replace(/\n{3,}/g,`
|
|
5
5
|
|
|
6
|
-
`).trim():a}function Ne(e){return/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(e)}function qe(e){return/id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(e)}function Ie(e,t){return e?Ne(e)?"word":qe(e)?"google-docs":"html":t?"plain":"html"}function Be(e){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(" ")}function We(e){if(!e)return{value:"",changed:!1};const t=e.split(";"),a=[];let r=!1;return t.forEach(n=>{const o=n.indexOf(":");if(o<=0){n.trim()&&(r=!0);return}const s=n.slice(0,o).trim().toLowerCase(),l=n.slice(o+1).trim();if(!s||!l){r=!0;return}if(!Le.has(s)){r=!0;return}if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(l)){r=!0;return}a.push(`${s}: ${l}`)}),{value:a.join("; "),changed:r}}function fe(e){const t=e.trim();return t&&(Ae.test(t)||we.test(t))?t:""}function pe(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function Ke(e,t,a,r){const n=e.tagName.toLowerCase();if(Ce.has(n)){r.removedElements+=1,e.remove();return}if(!t.preserveTables&&Te.has(n)){const s=e.textContent||"",l=document.createTextNode(s);e.replaceWith(l),r.removedElements+=1;return}if(Array.from(e.attributes).forEach(s=>{const l=s.name.toLowerCase(),i=s.value;if(l.startsWith("on")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="style"){if(!t.keepStyles){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=We(i);if(!c.value){e.removeAttribute(s.name),r.removedAttributes+=1,c.changed&&(r.normalizedStyles+=1);return}(c.changed||c.value!==i)&&(e.setAttribute("style",c.value),r.normalizedStyles+=1);return}if(l==="class"){if(!t.keepClasses){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=Be(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&(e.setAttribute("class",c),r.removedAttributes+=1);return}if(l.startsWith("data-")&&!t.keepDataAttributes){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="id"||l==="xmlns"||l.startsWith("xml")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if((a==="word"||a==="google-docs")&&(l==="lang"||l==="dir")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="href"||l==="src"||l==="xlink:href"){const c=fe(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&e.setAttribute(s.name,c)}}),n==="a"){if(!e.getAttribute("href")){pe(e),r.removedElements+=1;return}e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer")}if(n==="img"){const s=e.getAttribute("src");if(!s||!fe(s)){r.removedElements+=1,e.remove();return}}if(Pe.has(n)&&!e.attributes.length&&!e.className&&!e.style.cssText){const s=e.children.length>0,l=(e.textContent||"").trim().length>0;if(!s&&!l){e.remove(),r.removedElements+=1;return}!s&&l&&(pe(e),r.removedElements+=1)}}function Ve(e,t,a,r,n){const o=document.createElement("template");o.innerHTML=e;const s={removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0};if(r.removeComments)try{const f=document.createTreeWalker(o.content,ke,null),b=[];let k=f.nextNode();for(;k;)b.push(k),k=f.nextNode();b.forEach(v=>{v.remove(),s.removedComments+=1})}catch{}Array.from(o.content.querySelectorAll("*")).forEach(f=>{f.isConnected&&Ke(f,t,a,s)});let i=o.innerHTML;r.normalizeWhitespace&&n!=="fidelity"?i=i.replace(/\s{2,}/g," ").replace(/>\s+</g,"><").trim():r.normalizeWhitespace&&(i=i.trim());const c=(o.content.textContent||"").trim().length;return{html:i,textLength:c,counters:s}}function he(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const a=t.getRangeAt(0);return e.contains(a.commonAncestorContainer)?a:null}function ye(e,t){if(!e.isConnected)return;const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(t))}function je(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,t))return!0}catch{}const a=he(e);if(!a)return!1;a.deleteContents();const r=document.createElement("template");r.innerHTML=t;const n=r.content,o=n.lastChild;if(a.insertNode(n),o){const s=document.createRange();s.setStartAfter(o),s.collapse(!0),ye(e,s)}return!0}function Fe(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,t))return!0}catch{}const a=he(e);if(!a)return!1;a.deleteContents();const r=document.createTextNode(t);a.insertNode(r);const n=document.createRange();return n.setStart(r,r.length),n.collapse(!0),ye(e,n),!0}function Ge(e,t){if(t===e.innerHTML)return;const a=window.execEditorCommand||window.executeEditorCommand;if(typeof a=="function")try{a("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Ue(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function W(e,t,a,r,n,o){return{source:e,profile:t,inputHtmlLength:a,outputHtmlLength:r,outputTextLength:n,removedElements:o.removedElements,removedAttributes:o.removedAttributes,removedComments:o.removedComments,normalizedStyles:o.normalizedStyles,createdAt:new Date().toISOString()}}function Ye(e,t,a,r){const n=Ie(e,t);if(a==="plain"){const l=t||e.replace(/<[^>]*>/g," "),i=J(l,r);return{mode:"text",value:i,report:W(n,a,e.length,0,i.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}if(!e||e.length>r.maxHtmlLength){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}const o=r.profileOptions[a],s=Ve(e,o,n,r,a);if(!s.html){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,s.counters)}}return{mode:"html",value:s.html,report:W(n,a,e.length,s.html.length,s.textLength,s.counters)}}function G(e,t){return e==="balanced"?t.balancedText:e==="plain"?t.plainText:t.fidelityText}function ae(e){return e==="fidelity"?"balanced":e==="balanced"?"plain":"fidelity"}function Xe(e,t){e.setAttribute("aria-label",t.labels.panelAriaLabel);const a=e.querySelector(".rte-smart-paste-title");a&&(a.textContent=t.labels.panelTitle);const r=e.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",t.labels.closeText);const n=e.querySelector('[data-action="toggle-enabled"]');if(n){const Ee=n.getAttribute("data-enabled")==="true";n.textContent=Ee?t.labels.toggleOnText:t.labels.toggleOffText}const o=e.querySelector('[data-action="cycle-profile"]');o&&(o.textContent=t.labels.cycleProfileText);const s=e.querySelector(".rte-smart-paste-profile-heading");s&&(s.textContent=t.labels.profileLabel);const l=e.querySelector('.rte-smart-paste-profile[role="group"]');l&&l.setAttribute("aria-label",t.labels.profileLabel);const i=e.querySelector('[data-action="set-profile"][data-profile="fidelity"]');i&&(i.textContent=t.labels.fidelityText);const c=e.querySelector('[data-action="set-profile"][data-profile="balanced"]');c&&(c.textContent=t.labels.balancedText);const f=e.querySelector('[data-action="set-profile"][data-profile="plain"]');f&&(f.textContent=t.labels.plainText);const b=e.querySelector(".rte-smart-paste-report-title");b&&(b.textContent=t.labels.lastPasteHeading);const k=e.querySelector(".rte-smart-paste-empty");k&&(k.textContent=t.labels.lastPasteEmptyText);const v=e.querySelector('[data-key="source-label"]');v&&(v.textContent=t.labels.lastPasteSourceLabel);const U=e.querySelector('[data-key="profile-label"]');U&&(U.textContent=t.labels.lastPasteProfileLabel);const M=e.querySelector('[data-key="removed-label"]');M&&(M.textContent=t.labels.lastPasteRemovedLabel);const ne=e.querySelector('[data-key="chars-label"]');ne&&(ne.textContent=t.labels.lastPasteCharsLabel);const se=e.querySelector(".rte-smart-paste-shortcut");se&&(se.textContent=t.labels.shortcutText)}function x(e){const t=g.get(e),a=d.get(e)||$,r=L.get(e);if(!t||!a||!r)return;Xe(t,a);const n=t.querySelector(".rte-smart-paste-status");n&&(n.textContent=r.enabled?a.labels.enabledText:a.labels.disabledText);const o=t.querySelector('[data-action="toggle-enabled"]');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(t.querySelectorAll('[data-action="set-profile"][data-profile]')).forEach(v=>{const M=z(v.getAttribute("data-profile"))===r.profile;v.classList.toggle("active",M),v.setAttribute("aria-pressed",M?"true":"false")});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"]');if(!r.lastReport){l&&(l.hidden=!1),i&&(i.hidden=!0);return}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){const v=r.lastReport.removedElements+r.lastReport.removedAttributes+r.lastReport.removedComments+r.lastReport.normalizedStyles;b.textContent=String(v)}k&&(k.textContent=String(r.lastReport.outputTextLength))}function Q(e,t){if(!t.classList.contains("show"))return;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));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`}function N(e,t=!1){const a=g.get(e);a&&(a.classList.remove("show"),q.set(e,!1),D(e,"toggleSmartPastePanel",!1),t&&e.focus({preventScroll:!0}))}function Ze(e){const t=g.get(e);if(t)return t;const a=d.get(e)||$||K(),r=`rte-smart-paste-panel-${Me++}`,n=document.createElement("section");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=`
|
|
6
|
+
`).trim():a}function De(e){return/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(e)}function qe(e){return/id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(e)}function Ie(e,t){return e?De(e)?"word":qe(e)?"google-docs":"html":t?"plain":"html"}function Be(e){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(" ")}function We(e){if(!e)return{value:"",changed:!1};const t=e.split(";"),a=[];let r=!1;return t.forEach(n=>{const o=n.indexOf(":");if(o<=0){n.trim()&&(r=!0);return}const s=n.slice(0,o).trim().toLowerCase(),l=n.slice(o+1).trim();if(!s||!l){r=!0;return}if(!Le.has(s)){r=!0;return}if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(l)){r=!0;return}a.push(`${s}: ${l}`)}),{value:a.join("; "),changed:r}}function fe(e){const t=e.trim();return t&&(Pe.test(t)||we.test(t))?t:""}function pe(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function Ke(e,t,a,r){const n=e.tagName.toLowerCase();if(Te.has(n)){r.removedElements+=1,e.remove();return}if(!t.preserveTables&&Ce.has(n)){const s=e.textContent||"",l=document.createTextNode(s);e.replaceWith(l),r.removedElements+=1;return}if(Array.from(e.attributes).forEach(s=>{const l=s.name.toLowerCase(),i=s.value;if(l.startsWith("on")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="style"){if(!t.keepStyles){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=We(i);if(!c.value){e.removeAttribute(s.name),r.removedAttributes+=1,c.changed&&(r.normalizedStyles+=1);return}(c.changed||c.value!==i)&&(e.setAttribute("style",c.value),r.normalizedStyles+=1);return}if(l==="class"){if(!t.keepClasses){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=Be(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&(e.setAttribute("class",c),r.removedAttributes+=1);return}if(l.startsWith("data-")&&!t.keepDataAttributes){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="id"||l==="xmlns"||l.startsWith("xml")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if((a==="word"||a==="google-docs")&&(l==="lang"||l==="dir")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="href"||l==="src"||l==="xlink:href"){const c=fe(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&e.setAttribute(s.name,c)}}),n==="a"){if(!e.getAttribute("href")){pe(e),r.removedElements+=1;return}e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer")}if(n==="img"){const s=e.getAttribute("src");if(!s||!fe(s)){r.removedElements+=1,e.remove();return}}if(Ae.has(n)&&!e.attributes.length&&!e.className&&!e.style.cssText){const s=e.children.length>0,l=(e.textContent||"").trim().length>0;if(!s&&!l){e.remove(),r.removedElements+=1;return}!s&&l&&(pe(e),r.removedElements+=1)}}const Ve=/\son\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*)/gi;function je(e){return e.replace(Ve,"")}function Fe(e,t,a,r,n){const o=document.createElement("template");o.innerHTML=je(e);const s={removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0};if(r.removeComments)try{const f=document.createTreeWalker(o.content,ke,null),b=[];let k=f.nextNode();for(;k;)b.push(k),k=f.nextNode();b.forEach(v=>{v.remove(),s.removedComments+=1})}catch{}Array.from(o.content.querySelectorAll("*")).forEach(f=>{o.content.contains(f)&&Ke(f,t,a,s)});let i=o.innerHTML;r.normalizeWhitespace&&n!=="fidelity"?i=i.replace(/\s{2,}/g," ").replace(/>\s+</g,"><").trim():r.normalizeWhitespace&&(i=i.trim());const c=(o.content.textContent||"").trim().length;return{html:i,textLength:c,counters:s}}function he(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const a=t.getRangeAt(0);return e.contains(a.commonAncestorContainer)?a:null}function ye(e,t){if(!e.isConnected)return;const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(t))}function Ge(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,t))return!0}catch{}const a=he(e);if(!a)return!1;a.deleteContents();const r=document.createElement("template");r.innerHTML=t;const n=r.content,o=n.lastChild;if(a.insertNode(n),o){const s=document.createRange();s.setStartAfter(o),s.collapse(!0),ye(e,s)}return!0}function Ue(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,t))return!0}catch{}const a=he(e);if(!a)return!1;a.deleteContents();const r=document.createTextNode(t);a.insertNode(r);const n=document.createRange();return n.setStart(r,r.length),n.collapse(!0),ye(e,n),!0}function Ye(e,t){if(t===e.innerHTML)return;const a=window.execEditorCommand||window.executeEditorCommand;if(typeof a=="function")try{a("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Xe(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function W(e,t,a,r,n,o){return{source:e,profile:t,inputHtmlLength:a,outputHtmlLength:r,outputTextLength:n,removedElements:o.removedElements,removedAttributes:o.removedAttributes,removedComments:o.removedComments,normalizedStyles:o.normalizedStyles,createdAt:new Date().toISOString()}}function Ze(e,t,a,r){const n=Ie(e,t);if(a==="plain"){const l=t||e.replace(/<[^>]*>/g," "),i=J(l,r);return{mode:"text",value:i,report:W(n,a,e.length,0,i.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}if(!e||e.length>r.maxHtmlLength){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}const o=r.profileOptions[a],s=Fe(e,o,n,r,a);if(!s.html){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,s.counters)}}return{mode:"html",value:s.html,report:W(n,a,e.length,s.html.length,s.textLength,s.counters)}}function G(e,t){return e==="balanced"?t.balancedText:e==="plain"?t.plainText:t.fidelityText}function ae(e){return e==="fidelity"?"balanced":e==="balanced"?"plain":"fidelity"}function Je(e,t){e.setAttribute("aria-label",t.labels.panelAriaLabel);const a=e.querySelector(".rte-smart-paste-title");a&&(a.textContent=t.labels.panelTitle);const r=e.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",t.labels.closeText);const n=e.querySelector('[data-action="toggle-enabled"]');if(n){const Ee=n.getAttribute("data-enabled")==="true";n.textContent=Ee?t.labels.toggleOnText:t.labels.toggleOffText}const o=e.querySelector('[data-action="cycle-profile"]');o&&(o.textContent=t.labels.cycleProfileText);const s=e.querySelector(".rte-smart-paste-profile-heading");s&&(s.textContent=t.labels.profileLabel);const l=e.querySelector('.rte-smart-paste-profile[role="group"]');l&&l.setAttribute("aria-label",t.labels.profileLabel);const i=e.querySelector('[data-action="set-profile"][data-profile="fidelity"]');i&&(i.textContent=t.labels.fidelityText);const c=e.querySelector('[data-action="set-profile"][data-profile="balanced"]');c&&(c.textContent=t.labels.balancedText);const f=e.querySelector('[data-action="set-profile"][data-profile="plain"]');f&&(f.textContent=t.labels.plainText);const b=e.querySelector(".rte-smart-paste-report-title");b&&(b.textContent=t.labels.lastPasteHeading);const k=e.querySelector(".rte-smart-paste-empty");k&&(k.textContent=t.labels.lastPasteEmptyText);const v=e.querySelector('[data-key="source-label"]');v&&(v.textContent=t.labels.lastPasteSourceLabel);const U=e.querySelector('[data-key="profile-label"]');U&&(U.textContent=t.labels.lastPasteProfileLabel);const M=e.querySelector('[data-key="removed-label"]');M&&(M.textContent=t.labels.lastPasteRemovedLabel);const ne=e.querySelector('[data-key="chars-label"]');ne&&(ne.textContent=t.labels.lastPasteCharsLabel);const se=e.querySelector(".rte-smart-paste-shortcut");se&&(se.textContent=t.labels.shortcutText)}function x(e){const t=g.get(e),a=d.get(e)||$,r=L.get(e);if(!t||!a||!r)return;Je(t,a);const n=t.querySelector(".rte-smart-paste-status");n&&(n.textContent=r.enabled?a.labels.enabledText:a.labels.disabledText);const o=t.querySelector('[data-action="toggle-enabled"]');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(t.querySelectorAll('[data-action="set-profile"][data-profile]')).forEach(v=>{const M=z(v.getAttribute("data-profile"))===r.profile;v.classList.toggle("active",M),v.setAttribute("aria-pressed",M?"true":"false")});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"]');if(!r.lastReport){l&&(l.hidden=!1),i&&(i.hidden=!0);return}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){const v=r.lastReport.removedElements+r.lastReport.removedAttributes+r.lastReport.removedComments+r.lastReport.normalizedStyles;b.textContent=String(v)}k&&(k.textContent=String(r.lastReport.outputTextLength))}function Q(e,t){if(!t.classList.contains("show"))return;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));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`}function D(e,t=!1){const a=g.get(e);a&&(a.classList.remove("show"),q.set(e,!1),N(e,"toggleSmartPastePanel",!1),t&&e.focus({preventScroll:!0}))}function Qe(e){const t=g.get(e);if(t)return t;const a=d.get(e)||$||K(),r=`rte-smart-paste-panel-${Me++}`,n=document.createElement("section");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=`
|
|
7
7
|
<header class="rte-smart-paste-header">
|
|
8
8
|
<h2 class="rte-smart-paste-title">${X(a.labels.panelTitle)}</h2>
|
|
9
9
|
<button type="button" class="rte-smart-paste-icon-btn" data-action="close" aria-label="${X(a.labels.closeText)}">✕</button>
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<p class="rte-smart-paste-shortcut"></p>
|
|
36
36
|
</div>
|
|
37
37
|
<div class="rte-smart-paste-live" aria-live="polite" aria-atomic="true"></div>
|
|
38
|
-
`,n.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const i=l.getAttribute("data-action");if(i){if(i==="close"){
|
|
38
|
+
`,n.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const i=l.getAttribute("data-action");if(i){if(i==="close"){D(e,!0);return}if(i==="toggle-enabled"){const c=p(e,d.get(e)||a);c.enabled=!c.enabled,N(e,"toggleSmartPasteEnabled",c.enabled),x(e),O(n,c.enabled?a.labels.enabledText:a.labels.disabledText);return}if(i==="cycle-profile"){const c=p(e,d.get(e)||a);c.profile=ae(c.profile),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`);return}if(i==="set-profile"){const c=p(e,d.get(e)||a);c.profile=z(l.getAttribute("data-profile")),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`)}}}),n.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),D(e,!0);return}if(o.key!=="ArrowRight"&&o.key!=="ArrowLeft")return;const s=Array.from(n.querySelectorAll('[data-action="set-profile"][data-profile]'));if(s.length===0)return;const l=s.findIndex(f=>f===document.activeElement);if(l<0)return;const i=o.key==="ArrowRight"?1:-1,c=(l+i+s.length)%s.length;o.preventDefault(),s[c].focus()}),F(n,e),document.body.appendChild(n),g.set(e,n),q.set(e,!1),x(e),n}function xe(e){const t=Qe(e);g.forEach((r,n)=>{n!==e&&D(n,!1)}),t.classList.add("show"),q.set(e,!0),N(e,"toggleSmartPastePanel",!0),F(t,e),Q(e,t),t.querySelector('[data-action="toggle-enabled"]')?.focus()}function ve(e,t){const a=re(e);return(typeof t=="boolean"?t:!a)?xe(e):D(e,!1),!0}function Se(e){return{enabled:e.enabled,profile:e.profile,lastReport:e.lastReport?{...e.lastReport}:null}}function et(e,t){const a=d.get(e)||$;if(!a)return!1;const r=p(e,a);if(!r.enabled||ue(e)){const b=g.get(e);return b&&ue(e)&&O(b,a.labels.readonlyMessage),!1}const n=t.clipboardData;if(!n)return!1;const o=n.getData("text/html")||"",s=n.getData("text/plain")||"";if(!o&&!s)return!1;const l=Ze(o,s,r.profile,a);if(!l.value)return!1;const i=e.innerHTML;if(!(l.mode==="html"?Ge(e,l.value):Ue(e,l.value)))return!1;r.lastReport={...l.report},L.set(e,r),Ye(e,i),Xe(e),e.dispatchEvent(new CustomEvent("editora:smart-paste",{bubbles:!0,detail:Se(r)})),x(e);const f=g.get(e);if(f){const b=l.report.removedElements+l.report.removedAttributes+l.report.removedComments+l.report.normalizedStyles;O(f,`${a.labels.panelTitle}: ${G(r.profile,a.labels)}. ${a.labels.lastPasteRemovedLabel}: ${b}.`)}return!0}function tt(e){return t=>{t.defaultPrevented||t[ce]===!0||(m=e,!et(e,t))||(t[ce]=!0,t.preventDefault(),typeof t.stopImmediatePropagation=="function"?t.stopImmediatePropagation():t.stopPropagation())}}function rt(e){if(j.has(e))return;const t=tt(e);e.addEventListener("paste",t,!0),j.set(e,t)}function R(e){const t=L.get(e);N(e,"toggleSmartPastePanel",re(e)),N(e,"toggleSmartPasteEnabled",t?.enabled===!0)}function oe(e){return typeof e.key=="string"?e.key.toLowerCase():""}function at(e){const t=oe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="s"}function ot(e){const t=oe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="v"}function nt(e){const t=oe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="g"}function st(e){$=e,A||(A=t=>{V();const r=t.target?.closest(y);if(!r)return;const n=d.get(r)||e;p(r,n),d.set(r,n),m=r,R(r);const o=g.get(r);o&&(F(o,r),Q(r,o),x(r))},document.addEventListener("focusin",A,!0)),P||(P=t=>{if(t.defaultPrevented||t.target?.closest(`.${u} input, .${u} textarea, .${u} select`))return;const r=ze(t);if(!r)return;const n=d.get(r)||$||e;if(p(r,n),d.set(r,n),m=r,t.key==="Escape"&&re(r)){t.preventDefault(),D(r,!0);return}if(at(t)){t.preventDefault(),t.stopPropagation(),ve(r);return}if(ot(t)){t.preventDefault(),t.stopPropagation();const o=p(r,n);o.profile=ae(o.profile),x(r);return}if(nt(t)){t.preventDefault(),t.stopPropagation();const o=p(r,n);o.enabled=!o.enabled,R(r),x(r)}},document.addEventListener("keydown",P,!0)),C||(C=()=>{V(),g.forEach((t,a)=>{!a.isConnected||!t.isConnected||(F(t,a),Q(a,t))})},window.addEventListener("scroll",C,!0),window.addEventListener("resize",C)),!w&&typeof MutationObserver<"u"&&document.body&&(w=new MutationObserver(t=>{Ne(t)&&V()}),w.observe(document.body,{childList:!0,subtree:!0}))}function lt(){A&&(document.removeEventListener("focusin",A,!0),A=null),P&&(document.removeEventListener("keydown",P,!0),P=null),C&&(window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C),C=null),w&&(w.disconnect(),w=null),g.forEach(e=>e.remove()),g.clear(),_.forEach(e=>be(e)),_.clear(),$=null,m=null}function it(){if(typeof document>"u"||document.getElementById(ie))return;const e=document.createElement("style");e.id=ie,e.textContent=`
|
|
39
39
|
.rte-toolbar-group-items.${h},
|
|
40
40
|
.editora-toolbar-group-items.${h},
|
|
41
41
|
.rte-toolbar-group-items.${S},
|
|
@@ -395,4 +395,4 @@
|
|
|
395
395
|
grid-template-columns: 1fr;
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
`,document.head.appendChild(e)}const
|
|
398
|
+
`,document.head.appendChild(e)}const ct=(e={})=>{const t=K(e),a=new Set;return it(),{name:"smartPaste",toolbar:[{id:"smartPasteGroup",label:"Smart Paste",type:"group",command:"smartPaste",items:[{id:"smartPaste",label:"Smart Paste Panel",command:"toggleSmartPastePanel",shortcut:"Mod-Alt-Shift-s",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>'},{id:"smartPasteProfile",label:"Cycle Smart Paste Profile",command:"cycleSmartPasteProfile",shortcut:"Mod-Alt-Shift-v",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>'},{id:"smartPasteToggle",label:"Toggle Smart Paste",command:"toggleSmartPasteEnabled",shortcut:"Mod-Alt-Shift-g",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>'}]}],commands:{smartPaste:(r,n)=>{const o=T(n,!1,!1);if(!o)return!1;const s=d.get(o)||t;return p(o,s),d.set(o,s),m=o,xe(o),!0},toggleSmartPastePanel:(r,n)=>{const o=T(n,!1,!1);if(!o)return!1;const s=d.get(o)||t;return p(o,s),d.set(o,s),m=o,ve(o,typeof r=="boolean"?r:void 0)},cycleSmartPasteProfile:(r,n)=>{const o=T(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.profile=ae(l.profile),x(o),!0},setSmartPasteProfile:(r,n)=>{const o=T(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.profile=z(r),x(o),!0},toggleSmartPasteEnabled:(r,n)=>{const o=T(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.enabled=typeof r=="boolean"?r:!l.enabled,R(o),x(o),!0},setSmartPasteOptions:(r,n)=>{const o=T(n,!1,!1);if(!o||!r||typeof r!="object")return!1;const s=d.get(o)||t,l=de(s),i=K({...l,...r,labels:{...s.labels,...r.labels||{}},profileOptions:{...l.profileOptions,...r.profileOptions||{},fidelity:{...l.profileOptions?.fidelity||{},...r.profileOptions?.fidelity||{}},balanced:{...l.profileOptions?.balanced||{},...r.profileOptions?.balanced||{}},plain:{...l.profileOptions?.plain||{},...r.profileOptions?.plain||{}}},normalizeText:r.normalizeText||s.normalizeText});d.set(o,i);const c=p(o,i);return typeof r.enabled=="boolean"&&(c.enabled=r.enabled),r.defaultProfile&&(c.profile=z(r.defaultProfile)),x(o),R(o),!0},getSmartPasteState:(r,n)=>{const o=T(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s),i=Se(l);if(typeof r=="function")try{r(i)}catch{}return o.__smartPasteState=i,o.dispatchEvent(new CustomEvent("editora:smart-paste-state",{bubbles:!0,detail:i})),!0}},keymap:{"Mod-Alt-Shift-s":"toggleSmartPastePanel","Mod-Alt-Shift-S":"toggleSmartPastePanel","Mod-Alt-Shift-v":"cycleSmartPasteProfile","Mod-Alt-Shift-V":"cycleSmartPasteProfile","Mod-Alt-Shift-g":"toggleSmartPasteEnabled","Mod-Alt-Shift-G":"toggleSmartPasteEnabled"},init:function(n){I+=1;const o=this&&typeof this.__pluginConfig=="object"?K({...de(t),...this.__pluginConfig}):t;st(o);const s=T(n?.editorElement?{editorElement:n.editorElement}:void 0,!1,!1);if(!s)return;m=s,a.add(s);const l=p(s,o);l.enabled=o.enabled,l.profile=o.defaultProfile,d.set(s,o),R(s)},destroy:()=>{a.forEach(r=>ge(r)),a.clear(),I=Math.max(0,I-1),!(I>0)&<()}}};exports.SmartPastePlugin=ct;
|