@editora/plugins 1.0.21 → 1.0.23
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/README.md +259 -645
- package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-DESvGCrJ.mjs} +61 -53
- package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-DJqwsRPZ.js} +11 -11
- package/dist/a11y-checker.cjs.js +3 -3
- package/dist/a11y-checker.esm.js +6 -4
- package/dist/anchor.cjs.js +4 -4
- package/dist/anchor.esm.js +19 -18
- package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
- package/dist/anchoredPopover-Cygmit_o.js +1 -0
- package/dist/approval-workflow.cjs.js +7 -7
- package/dist/approval-workflow.esm.js +55 -54
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +72 -67
- package/dist/blocks-library.cjs.js +18 -19
- package/dist/blocks-library.esm.js +41 -42
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +50 -50
- package/dist/code-sample.cjs.js +10 -10
- package/dist/code-sample.esm.js +4 -4
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/comments.cjs.js +23 -11
- package/dist/comments.esm.js +167 -149
- package/dist/conditional-content.cjs.js +2 -2
- package/dist/conditional-content.esm.js +2 -2
- package/dist/confirmDialog-6BPaNPis.mjs +106 -0
- package/dist/confirmDialog-C4UWENes.js +46 -0
- package/dist/content-rules.cjs.js +6 -6
- package/dist/content-rules.esm.js +51 -51
- package/dist/data-binding.cjs.js +2 -2
- package/dist/data-binding.esm.js +2 -2
- package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
- package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
- package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
- package/dist/embed-iframe.cjs.js +6 -6
- package/dist/embed-iframe.esm.js +6 -6
- package/dist/emojis.cjs.js +5 -5
- package/dist/emojis.esm.js +3 -3
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +1 -1
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +172 -151
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +96 -83
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +176 -97
- package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
- package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/katex-Cc3-mvOY.js +257 -0
- package/dist/katex-DoRnZ_sp.mjs +11682 -0
- package/dist/katex.min--Ws3c9be.mjs +5 -0
- package/dist/katex.min-Dk2VscxB.js +2 -0
- package/dist/link.cjs.js +3 -3
- package/dist/link.esm.js +3 -3
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +140 -52
- package/dist/math.cjs.js +14 -14
- package/dist/math.esm.js +149 -136
- package/dist/media-manager.cjs.js +46 -46
- package/dist/media-manager.esm.js +320 -264
- package/dist/mentions.cjs.js +12 -12
- package/dist/mentions.esm.js +149 -143
- package/dist/merge-tag.cjs.js +5 -3
- package/dist/merge-tag.esm.js +5 -3
- package/dist/notify-BkbzMopb.js +32 -0
- package/dist/notify-zOp-mUOJ.mjs +59 -0
- package/dist/pii-redaction.cjs.js +1 -1
- package/dist/pii-redaction.esm.js +1 -1
- package/dist/preview.cjs.js +1 -1
- package/dist/preview.esm.js +1 -1
- package/dist/shared-config.cjs.js +1 -1
- package/dist/shared-config.esm.js +14 -14
- package/dist/slash-commands.cjs.js +5 -5
- package/dist/slash-commands.esm.js +259 -236
- package/dist/smart-paste.cjs.js +1 -1
- package/dist/smart-paste.esm.js +1 -1
- package/dist/special-characters.cjs.js +3 -3
- package/dist/special-characters.esm.js +3 -3
- package/dist/spell-check.cjs.js +9 -9
- package/dist/spell-check.esm.js +288 -251
- package/dist/table.cjs.js +14 -14
- package/dist/table.esm.js +175 -154
- package/dist/template.cjs.js +5 -3
- package/dist/template.esm.js +15 -13
- package/dist/text-color.cjs.js +4 -4
- package/dist/text-color.esm.js +38 -34
- package/dist/translation-workflow.cjs.js +9 -9
- package/dist/translation-workflow.esm.js +98 -95
- package/dist/version-diff.cjs.js +4 -4
- package/dist/version-diff.esm.js +36 -36
- package/package.json +6 -5
- package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
- package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
- package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
- package/dist/dialogHelpers-zU6zpMIA.js +0 -12
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { n as P } from "./notify-zOp-mUOJ.mjs";
|
|
2
|
+
import { a as R, b as T } from "./anchoredPopover-BNJ8e7j-.mjs";
|
|
3
|
+
import { r as I } from "./dialogHelpers-BbwpIXD9.mjs";
|
|
4
|
+
let l = null, L = null, g = null, y = null, i = "#ffff00";
|
|
5
|
+
const k = '[data-theme="dark"], .dark, .editora-theme-dark', M = [
|
|
4
6
|
"#000000",
|
|
5
7
|
"#ffffff",
|
|
6
8
|
"#808080",
|
|
@@ -30,15 +32,15 @@ function A() {
|
|
|
30
32
|
'[data-editora-editor="true"], .rte-editor, .editora-editor'
|
|
31
33
|
) : null;
|
|
32
34
|
}
|
|
33
|
-
function
|
|
35
|
+
function U(e) {
|
|
34
36
|
const t = window.__editoraLastCommand, c = window.__editoraLastCommandButton;
|
|
35
37
|
if (t === e && c && c.isConnected) {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
+
const a = window.getComputedStyle(c), s = c.getBoundingClientRect();
|
|
39
|
+
if (a.display !== "none" && a.visibility !== "hidden" && a.pointerEvents !== "none" && !(s.width === 0 && s.height === 0))
|
|
38
40
|
return c;
|
|
39
41
|
}
|
|
40
|
-
const r = (
|
|
41
|
-
for (const s of
|
|
42
|
+
const r = (a) => {
|
|
43
|
+
for (const s of a) {
|
|
42
44
|
const d = window.getComputedStyle(s), p = s.getBoundingClientRect();
|
|
43
45
|
if (!(d.display === "none" || d.visibility === "hidden" || d.pointerEvents === "none") && !(p.width === 0 && p.height === 0))
|
|
44
46
|
return s;
|
|
@@ -46,9 +48,9 @@ function M(e) {
|
|
|
46
48
|
return null;
|
|
47
49
|
}, n = A();
|
|
48
50
|
if (n) {
|
|
49
|
-
const
|
|
51
|
+
const a = Array.from(
|
|
50
52
|
n.querySelectorAll(`[data-command="${e}"]`)
|
|
51
|
-
), s = r(
|
|
53
|
+
), s = r(a);
|
|
52
54
|
if (s) return s;
|
|
53
55
|
}
|
|
54
56
|
const o = Array.from(
|
|
@@ -56,7 +58,7 @@ function M(e) {
|
|
|
56
58
|
);
|
|
57
59
|
return r(o);
|
|
58
60
|
}
|
|
59
|
-
function
|
|
61
|
+
function q(e) {
|
|
60
62
|
if (e?.closest(k)) return !0;
|
|
61
63
|
const t = window.getSelection();
|
|
62
64
|
if (t && t.rangeCount > 0) {
|
|
@@ -65,7 +67,7 @@ function T(e) {
|
|
|
65
67
|
}
|
|
66
68
|
return document.activeElement?.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
|
|
67
69
|
}
|
|
68
|
-
function
|
|
70
|
+
function F() {
|
|
69
71
|
if (document.getElementById("rte-bg-color-picker-styles"))
|
|
70
72
|
return;
|
|
71
73
|
const e = document.createElement("style");
|
|
@@ -288,9 +290,9 @@ function U() {
|
|
|
288
290
|
}
|
|
289
291
|
`, document.head.appendChild(e);
|
|
290
292
|
}
|
|
291
|
-
function
|
|
293
|
+
function _() {
|
|
292
294
|
const e = document.createElement("div");
|
|
293
|
-
e.className = "rte-bg-color-picker",
|
|
295
|
+
e.className = "rte-bg-color-picker", q(L) && e.classList.add("rte-theme-dark"), e.addEventListener("click", (h) => h.stopPropagation());
|
|
294
296
|
const t = document.createElement("div");
|
|
295
297
|
t.className = "rte-bg-color-picker-header";
|
|
296
298
|
const c = document.createElement("span");
|
|
@@ -301,71 +303,71 @@ function q() {
|
|
|
301
303
|
n.className = "rte-bg-color-picker-body";
|
|
302
304
|
const o = document.createElement("div");
|
|
303
305
|
o.className = "rte-bg-color-section";
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
+
const a = document.createElement("div");
|
|
307
|
+
a.className = "rte-bg-color-preview";
|
|
306
308
|
const s = document.createElement("div");
|
|
307
309
|
s.className = "rte-bg-color-preview-swatch", s.id = "rte-bg-color-preview-swatch";
|
|
308
310
|
const d = document.createElement("span");
|
|
309
|
-
d.className = "rte-bg-color-preview-hex", d.id = "rte-bg-color-preview-hex",
|
|
311
|
+
d.className = "rte-bg-color-preview-hex", d.id = "rte-bg-color-preview-hex", a.appendChild(s), a.appendChild(d), o.appendChild(a);
|
|
310
312
|
const p = document.createElement("div");
|
|
311
313
|
p.className = "rte-bg-color-section";
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
+
const E = document.createElement("div");
|
|
315
|
+
E.className = "rte-bg-color-section-label", E.textContent = "Colors";
|
|
314
316
|
const x = document.createElement("div");
|
|
315
|
-
x.className = "rte-bg-color-grid", x.id = "rte-bg-color-grid",
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
}), p.appendChild(
|
|
317
|
+
x.className = "rte-bg-color-grid", x.id = "rte-bg-color-grid", M.forEach((h) => {
|
|
318
|
+
const f = document.createElement("button");
|
|
319
|
+
f.type = "button", f.className = "rte-bg-color-swatch", f.style.backgroundColor = h, f.dataset.color = h, f.title = h, x.appendChild(f);
|
|
320
|
+
}), p.appendChild(E), p.appendChild(x);
|
|
319
321
|
const C = document.createElement("div");
|
|
320
322
|
C.className = "rte-bg-color-section";
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
+
const S = document.createElement("div");
|
|
324
|
+
S.className = "rte-bg-color-section-label", S.textContent = "Custom";
|
|
323
325
|
const w = document.createElement("div");
|
|
324
326
|
w.className = "rte-bg-color-custom";
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
+
const b = document.createElement("input");
|
|
328
|
+
b.type = "color", b.className = "rte-bg-color-input", b.id = "rte-bg-color-input", b.setAttribute("aria-label", "Custom background colour"), b.value = i;
|
|
327
329
|
const u = document.createElement("input");
|
|
328
|
-
return u.type = "text", u.className = "rte-bg-color-text-input", u.id = "rte-bg-color-text-input", u.placeholder = "#FFFF00", u.value = i.toUpperCase(), u.maxLength = 7, w.appendChild(
|
|
330
|
+
return u.type = "text", u.className = "rte-bg-color-text-input", u.id = "rte-bg-color-text-input", u.placeholder = "#FFFF00", u.value = i.toUpperCase(), u.maxLength = 7, w.appendChild(b), w.appendChild(u), C.appendChild(S), C.appendChild(w), n.appendChild(o), n.appendChild(p), n.appendChild(C), e.appendChild(t), e.appendChild(n), e;
|
|
329
331
|
}
|
|
330
|
-
function
|
|
331
|
-
if (!
|
|
332
|
-
|
|
333
|
-
const t =
|
|
332
|
+
function z() {
|
|
333
|
+
if (!l) return;
|
|
334
|
+
l.querySelector("#rte-bg-color-close")?.addEventListener("click", () => m());
|
|
335
|
+
const t = l.querySelector("#rte-bg-color-grid");
|
|
334
336
|
t && t.addEventListener("click", (n) => {
|
|
335
337
|
const o = n.target;
|
|
336
338
|
if (o.classList.contains("rte-bg-color-swatch")) {
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
+
const a = o.dataset.color;
|
|
340
|
+
a && (i = a, v(a), m());
|
|
339
341
|
}
|
|
340
342
|
});
|
|
341
|
-
const c =
|
|
343
|
+
const c = l.querySelector("#rte-bg-color-input");
|
|
342
344
|
c && (c.addEventListener("change", (n) => {
|
|
343
345
|
const o = n.target.value.toUpperCase();
|
|
344
|
-
i = o, v(o),
|
|
346
|
+
i = o, v(o), m();
|
|
345
347
|
}), c.addEventListener("input", (n) => {
|
|
346
|
-
i = n.target.value.toUpperCase(),
|
|
348
|
+
i = n.target.value.toUpperCase(), B(), N();
|
|
347
349
|
}));
|
|
348
|
-
const r =
|
|
350
|
+
const r = l.querySelector("#rte-bg-color-text-input");
|
|
349
351
|
r && (r.addEventListener("change", (n) => {
|
|
350
352
|
let o = n.target.value.trim();
|
|
351
|
-
o && !o.startsWith("#") && (o = "#" + o), /^#[0-9A-F]{6}$/i.test(o) && (i = o.toUpperCase(), v(i),
|
|
353
|
+
o && !o.startsWith("#") && (o = "#" + o), /^#[0-9A-F]{6}$/i.test(o) && (i = o.toUpperCase(), v(i), m());
|
|
352
354
|
}), r.addEventListener("input", (n) => {
|
|
353
355
|
let o = n.target.value.trim();
|
|
354
|
-
o && !o.startsWith("#") && (o = "#" + o, r.value = o), /^#[0-9A-F]{6}$/i.test(o) && (i = o.toUpperCase(),
|
|
356
|
+
o && !o.startsWith("#") && (o = "#" + o, r.value = o), /^#[0-9A-F]{6}$/i.test(o) && (i = o.toUpperCase(), B(), N());
|
|
355
357
|
}));
|
|
356
358
|
}
|
|
357
|
-
function
|
|
358
|
-
if (!
|
|
359
|
-
const e =
|
|
359
|
+
function B() {
|
|
360
|
+
if (!l) return;
|
|
361
|
+
const e = l.querySelector("#rte-bg-color-preview-swatch"), t = l.querySelector("#rte-bg-color-preview-hex"), c = l.querySelector("#rte-bg-color-input"), r = l.querySelector("#rte-bg-color-text-input");
|
|
360
362
|
e && (e.style.backgroundColor = i), t && (t.textContent = i.toUpperCase()), c && (c.value = i), r && (r.value = i.toUpperCase());
|
|
361
363
|
}
|
|
362
|
-
function
|
|
363
|
-
if (!
|
|
364
|
-
|
|
364
|
+
function N() {
|
|
365
|
+
if (!l) return;
|
|
366
|
+
l.querySelectorAll(".rte-bg-color-swatch").forEach((t) => {
|
|
365
367
|
t.dataset.color?.toUpperCase() === i.toUpperCase() ? t.classList.add("selected") : t.classList.remove("selected");
|
|
366
368
|
});
|
|
367
369
|
}
|
|
368
|
-
function
|
|
370
|
+
function H() {
|
|
369
371
|
try {
|
|
370
372
|
const e = window.getSelection();
|
|
371
373
|
if (!e || e.rangeCount === 0)
|
|
@@ -376,7 +378,7 @@ function z() {
|
|
|
376
378
|
if (n) {
|
|
377
379
|
const o = n.style.backgroundColor;
|
|
378
380
|
if (o)
|
|
379
|
-
return
|
|
381
|
+
return D(o);
|
|
380
382
|
}
|
|
381
383
|
}
|
|
382
384
|
return "#ffff00";
|
|
@@ -384,51 +386,54 @@ function z() {
|
|
|
384
386
|
return "#ffff00";
|
|
385
387
|
}
|
|
386
388
|
}
|
|
387
|
-
function
|
|
389
|
+
function D(e) {
|
|
388
390
|
if (e.startsWith("#"))
|
|
389
391
|
return e.toUpperCase();
|
|
390
392
|
const t = e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
391
393
|
if (t) {
|
|
392
394
|
const c = parseInt(t[1]), r = parseInt(t[2]), n = parseInt(t[3]);
|
|
393
395
|
return "#" + [c, r, n].map((o) => {
|
|
394
|
-
const
|
|
395
|
-
return
|
|
396
|
+
const a = o.toString(16);
|
|
397
|
+
return a.length === 1 ? "0" + a : a;
|
|
396
398
|
}).join("").toUpperCase();
|
|
397
399
|
}
|
|
398
400
|
return "#ffff00";
|
|
399
401
|
}
|
|
400
402
|
function v(e) {
|
|
401
|
-
const t =
|
|
403
|
+
const t = R({
|
|
402
404
|
color: e,
|
|
403
405
|
className: "rte-bg-color",
|
|
404
406
|
styleProperty: "backgroundColor",
|
|
405
407
|
commands: ["hiliteColor", "backColor"],
|
|
406
|
-
savedRange:
|
|
408
|
+
savedRange: y,
|
|
407
409
|
getActiveEditorRoot: A,
|
|
408
410
|
warnMessage: "[BackgroundColor] Could not apply highlight for current selection"
|
|
409
411
|
});
|
|
410
412
|
return t && console.log("[BackgroundColor] Applied color:", e), t;
|
|
411
413
|
}
|
|
412
|
-
function
|
|
413
|
-
|
|
414
|
+
function m() {
|
|
415
|
+
const e = !!l && l.contains(document.activeElement), t = y, c = e ? A() : null;
|
|
416
|
+
g && (g.destroy(), g = null), l && (l.remove(), l = null), L = null, y = null, e && I(c, t);
|
|
414
417
|
}
|
|
415
|
-
function
|
|
416
|
-
if (
|
|
417
|
-
return
|
|
418
|
-
const e =
|
|
418
|
+
function O() {
|
|
419
|
+
if (F(), l)
|
|
420
|
+
return m(), !0;
|
|
421
|
+
const e = U("openBackgroundColorPicker");
|
|
419
422
|
if (!e)
|
|
420
423
|
return !1;
|
|
421
424
|
const t = window.getSelection();
|
|
422
|
-
return !t || t.isCollapsed ? (
|
|
423
|
-
popover:
|
|
425
|
+
return !t || t.isCollapsed ? (P("Please select text to apply background color"), !1) : (t.rangeCount > 0 && (y = t.getRangeAt(0).cloneRange()), i = H(), l = _(), document.body.appendChild(l), L = e, g && (g.destroy(), g = null), g = T({
|
|
426
|
+
popover: l,
|
|
424
427
|
anchor: e,
|
|
425
|
-
onClose:
|
|
428
|
+
onClose: m,
|
|
426
429
|
gap: 8,
|
|
427
430
|
margin: 8,
|
|
428
|
-
zIndex: 1e4
|
|
429
|
-
|
|
431
|
+
zIndex: 1e4,
|
|
432
|
+
label: "Background color",
|
|
433
|
+
initialFocus: ".rte-bg-color-swatch.selected, .rte-bg-color-swatch"
|
|
434
|
+
}), B(), N(), z(), !0);
|
|
430
435
|
}
|
|
431
|
-
const
|
|
436
|
+
const V = () => ({
|
|
432
437
|
name: "backgroundColor",
|
|
433
438
|
marks: {
|
|
434
439
|
backgroundColor: {
|
|
@@ -467,7 +472,7 @@ const O = () => ({
|
|
|
467
472
|
}
|
|
468
473
|
],
|
|
469
474
|
commands: {
|
|
470
|
-
openBackgroundColorPicker: () =>
|
|
475
|
+
openBackgroundColorPicker: () => O(),
|
|
471
476
|
setBackgroundColor: (e) => e ? v(e) : !1
|
|
472
477
|
},
|
|
473
478
|
keymap: {
|
|
@@ -475,5 +480,5 @@ const O = () => ({
|
|
|
475
480
|
}
|
|
476
481
|
});
|
|
477
482
|
export {
|
|
478
|
-
|
|
483
|
+
V as BackgroundColorPlugin
|
|
479
484
|
};
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",fe="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ye="__editoraCommandEditorRoot",he="rte-blocks-library-styles",d="rte-blocks-library-panel",E="blocks-library",C="blocksLibrary",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',De=80,Ce=new Set(["script","style","meta","link","object","embed","iframe"]),Ne=/^(https?:|mailto:|tel:|#|\/)/i,Ke=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,je={panelTitle:"Blocks Library",panelAriaLabel:"Blocks library panel",searchLabel:"Search blocks",searchPlaceholder:"Search by name, category, or keyword",categoryLabel:"Category",allCategoriesText:"All categories",recentHeading:"Recent inserts",insertText:"Insert Selected",closeText:"Close",noResultsText:"No matching blocks found.",summaryPrefix:"Blocks",loadingText:"Loading blocks...",loadErrorText:"Unable to load blocks right now.",readonlyMessage:"Editor is read-only. Block insertion is disabled.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",helperText:"Use Arrow keys to move through blocks, Enter to insert, Esc to close.",lastInsertedPrefix:"Last inserted",resultsListLabel:"Block results"},b=new WeakMap,J=new WeakMap,w=new WeakMap,I=new WeakMap,D=new WeakMap,j=new WeakMap,W=new WeakMap,z=new WeakMap,q=new WeakMap,te=new WeakMap,x=new Map,U=new WeakMap,oe=new Set;let X=0,We=0,ke=0,M=null,y=null,_=null,P=null,A=null,O=null;function m(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Fe(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function Ge(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e){const t=e.trim();return t&&(Ne.test(t)||Ke.test(t))?t:""}function xe(e){let t=e;return Ce.forEach(r=>{const o=new RegExp(`<${r}[\\s\\S]*?>[\\s\\S]*?<\\/${r}>`,"gi"),l=new RegExp(`<${r}\\b[^>]*\\/?>`,"gi");t=t.replace(o,"").replace(l,"")}),t=t.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n,a)=>{const s=typeof n=="string"&&n.length>0?n:a||"",i=ce(s);if(!i)return"";const c=l.startsWith('"')?'"':"'";return` ${o}=${c}${i}${c}`}).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi,(r,o,l)=>{const n=ce(l);return n?` ${o}="${n}"`:""}).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n)=>{const a=typeof l=="string"&&l.length>0?l:n||"";if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))return"";const s=o.startsWith('"')?'"':"'";return` style=${s}${a}${s}`}).trim(),t}function Ue(e){if(!e)return"";if(typeof document>"u")return xe(e);const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.querySelectorAll!="function"?xe(e):(Array.from(r.querySelectorAll("*")).forEach(l=>{const n=l.tagName.toLowerCase();if(Ce.has(n)){l.remove();return}Array.from(l.attributes).forEach(s=>{const i=s.name.toLowerCase(),c=s.value;if(i.startsWith("on")){l.removeAttribute(s.name);return}if(i==="style"){/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(c)&&l.removeAttribute(s.name);return}if(i==="href"||i==="src"||i==="xlink:href"){const u=ce(c);if(!u){l.removeAttribute(s.name);return}u!==c&&l.setAttribute(s.name,u)}})}),t.innerHTML.trim())}function ne(e){return e.trim().toLowerCase()}function Ve(e){if(!e)return"";if(typeof document>"u")return e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.textContent!="string"?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():r.textContent.replace(/\s+/g," ").trim()}function $e(e,t){if(!Array.isArray(e)||e.length===0)return[];const r=new Set,o=[];return e.forEach(l=>{const n=t.normalizeText(l.label||""),a=t.sanitizeBlockHtml(l.html||"",l).trim();if(!n||!a)return;const s=t.normalizeText(l.category||"General")||"General",i=ne(s);let u=Ge(t.normalizeText(l.id||n))||`block-${ke++}`;for(;r.has(u);)u=`${u}-${ke++}`;r.add(u);const f=(l.tags||[]).map(H=>t.normalizeText(H)).filter(Boolean),g=(l.keywords||[]).map(H=>t.normalizeText(H)).filter(Boolean),h=t.normalizeText(l.description||""),R=Ve(a),V=[n,h,s,...f,...g,R].join(" ").toLowerCase();o.push({id:u,label:n,html:a,description:h,category:s,categoryKey:i,tags:f,keywords:g,previewText:R,searchBlob:V})}),o}function Q(e={}){const t=e.normalizeText||Fe,r=e.sanitizeBlockHtml||Ue,o={blocks:[],defaultCategory:t(e.defaultCategory||""),maxResults:Math.max(4,Math.min(300,Number(e.maxResults??80))),maxRecentBlocks:Math.max(1,Math.min(20,Number(e.maxRecentBlocks??6))),debounceMs:Math.max(0,Math.min(700,Number(e.debounceMs??90))),cacheTtlMs:Math.max(0,Number(e.cacheTtlMs??6e4)),labels:{...je,...e.labels||{}},normalizeText:t,sanitizeBlockHtml:r,getBlocks:typeof e.getBlocks=="function"?e.getBlocks:void 0};return o.blocks=$e(e.blocks,o),o}function Ye(e){return{blocks:e.blocks.map(t=>({id:t.id,label:t.label,html:t.html,description:t.description||void 0,category:t.category||void 0,tags:t.tags.length?[...t.tags]:void 0,keywords:t.keywords.length?[...t.keywords]:void 0})),defaultCategory:e.defaultCategory,maxResults:e.maxResults,maxRecentBlocks:e.maxRecentBlocks,debounceMs:e.debounceMs,cacheTtlMs:e.cacheTtlMs,labels:{...e.labels},normalizeText:e.normalizeText,sanitizeBlockHtml:e.sanitizeBlockHtml,getBlocks:e.getBlocks}}function le(e){return e.closest(fe)||e}function G(e){if(!e)return null;if(e.matches(v))return e;const t=e.querySelector(v);return t instanceof HTMLElement?t:null}function Xe(){if(typeof window>"u")return null;const e=window[ye];if(!(e instanceof HTMLElement))return null;window[ye]=null;const t=G(e);if(t)return t;const r=e.closest(fe);if(r){const l=G(r);if(l)return l}const o=e.closest(v);return o instanceof HTMLElement?o:null}function Ze(e){const t=e.closest("[data-editora-editor]");if(t&&G(t)===e)return t;let r=e;for(;r;){if(r.matches(fe)&&(r===e||G(r)===e))return r;r=r.parentElement}return le(e)}function Te(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(){Array.from(oe).forEach(t=>{t.isConnected||ge(t)})}function T(e,t=!0,r=!0){if(ee(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const a=G(e.editorElement);if(a)return a}const o=Xe();if(o)return o;const l=window.getSelection();if(l&&l.rangeCount>0){const s=Te(l.getRangeAt(0).startContainer)?.closest(v);if(s)return s}const n=document.activeElement;if(n){if(n.matches(v))return n;const a=n.closest(v);if(a)return a}if(r){if(y&&y.isConnected)return y;y&&!y.isConnected&&(y=null)}return t?document.querySelector(v):null}function Je(e){const t=e.target;if(t){const o=t.closest(v);if(o)return o}const r=window.getSelection();if(r&&r.rangeCount>0){const l=Te(r.getRangeAt(0).startContainer)?.closest(v);if(l)return l}return null}function Z(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 Qe(e){const t=le(e);if(Z(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Z(r)?!0:Z(document.documentElement)||Z(document.body)}function re(e,t){e.classList.remove("rte-blocks-library-theme-dark"),Qe(t)&&e.classList.add("rte-blocks-library-theme-dark")}function Se(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function we(e,t,r){const o=Ze(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(n=>{n.classList.toggle("active",r),n.setAttribute("data-active",r?"true":"false"),n.setAttribute("aria-pressed",r?"true":"false")})}function Ee(e,t){const r=e.querySelector(".rte-blocks-library-live");r&&(r.textContent=t)}function se(e){const t=He(e);if(t)try{q.set(e,t.cloneRange())}catch{}}function Me(e){const t=q.get(e);if(!t)return null;if(!e.isConnected)return q.delete(e),null;try{const r=t.cloneRange();return e.contains(r.commonAncestorContainer)?r:(q.delete(e),null)}catch{return q.delete(e),null}}function et(e){const t=Me(e);return t?(ze(e,t),!0):!1}function tt(e){if(te.has(e))return;const t=()=>{const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);e.contains(o.commonAncestorContainer)&&se(e)};e.addEventListener("keyup",t),e.addEventListener("mouseup",t),e.addEventListener("touchend",t),te.set(e,t)}function rt(e){const t=te.get(e);t&&(e.removeEventListener("keyup",t),e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t),te.delete(e))}function k(e,t){b.has(e)||b.set(e,t),I.has(e)||(I.set(e,t.blocks),D.set(e,Date.now()));let r=w.get(e);return r||(r={query:"",category:t.defaultCategory?ne(t.defaultCategory):"all",selectedBlockId:null,recentBlockIds:[],lastInsertedBlockId:null,loading:!1,loadError:null,totalMatches:0,visibleMatches:0,filterCache:new Map,debounceTimer:null},w.set(e,r)),oe.add(e),tt(e),r}function Ae(e){const t=w.get(e);!t||t.debounceTimer===null||(window.clearTimeout(t.debounceTimer),t.debounceTimer=null)}function ge(e){Ae(e),rt(e),q.delete(e);const t=W.get(e);t&&(t.abort(),W.delete(e)),j.delete(e),z.delete(e),x.get(e)?.remove(),x.delete(e),U.delete(e),b.delete(e),J.delete(e),w.delete(e),I.delete(e),D.delete(e),oe.delete(e),y===e&&(y=null)}function ot(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let o=0;o<r.removedNodes.length;o+=1){const l=r.removedNodes[o];if(l.nodeType!==Node.ELEMENT_NODE)continue;const n=l;if(n.matches?.(v)||n.matches?.(`.${d}`)||n.querySelector?.(v)||n.querySelector?.(`.${d}`))return!0}}return!1}function pe(e){return U.get(e)===!0}function ue(e,t){if(!t.classList.contains("show"))return;const r=le(e).getBoundingClientRect(),o=Math.min(window.innerWidth-20,420),l=Math.max(10,window.innerWidth-o-10),n=Math.min(Math.max(10,r.right-o),l),a=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${o}px`,t.style.left=`${n}px`,t.style.top=`${a}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ae(e){return I.get(e)||b.get(e)?.blocks||[]}function nt(e,t){const r=new Map;ae(e).forEach(l=>{r.has(l.categoryKey)||r.set(l.categoryKey,l.category)});const o=Array.from(r.entries()).sort((l,n)=>l[1].localeCompare(n[1])).map(([l,n])=>({value:l,label:n}));return[{value:"all",label:t.labels.allCategoriesText},...o]}function Ie(e,t){const r=k(e,t),o=ae(e),l=r.query.trim().toLowerCase(),n=r.category||"all",a=`${l}|${n}|${t.maxResults}`,s=r.filterCache.get(a);if(s){const u=new Map(o.map(g=>[g.id,g])),f=s.ids.map(g=>u.get(g)).filter(Boolean);return r.totalMatches=s.total,r.visibleMatches=f.length,f}const i=[];let c=0;for(let u=0;u<o.length;u+=1){const f=o[u];n!=="all"&&f.categoryKey!==n||l&&!f.searchBlob.includes(l)||(c+=1,i.length<t.maxResults&&i.push(f))}if(r.totalMatches=c,r.visibleMatches=i.length,r.filterCache.set(a,{ids:i.map(u=>u.id),total:c}),r.filterCache.size>De){const u=r.filterCache.keys().next().value;typeof u=="string"&&r.filterCache.delete(u)}return i}function lt(e,t){const r=w.get(e);if(!r)return;if(t.length===0){r.selectedBlockId=null;return}t.some(l=>l.id===r.selectedBlockId)||(r.selectedBlockId=t[0].id)}function N(e){const t=w.get(e);we(e,"toggleBlocksLibraryPanel",pe(e)),we(e,"insertLastBlockSnippet",!!t?.lastInsertedBlockId)}function L(e){const t=x.get(e),r=b.get(e)||M,o=w.get(e);if(!t||!r||!o)return;re(t,e);const l=t.querySelector(".rte-blocks-library-title");l&&(l.textContent=r.labels.panelTitle);const n=t.querySelector('[data-action="close"]');n&&(n.setAttribute("aria-label",r.labels.closeText),n.textContent="✕");const a=t.querySelector(".rte-blocks-library-search-label");a&&(a.textContent=r.labels.searchLabel);const s=t.querySelector('[data-field="query"]');s&&(s.setAttribute("placeholder",r.labels.searchPlaceholder),s.value!==o.query&&(s.value=o.query));const i=t.querySelector(".rte-blocks-library-category-label");i&&(i.textContent=r.labels.categoryLabel);const c=t.querySelector('[data-field="category"]');if(c){const B=nt(e,r);c.innerHTML=B.map(p=>`<option value="${m(p.value)}">${m(p.label)}</option>`).join(""),B.some(p=>p.value===o.category)||(o.category="all"),c.value=o.category}const u=t.querySelector(".rte-blocks-library-helper");u&&(u.textContent=r.labels.helperText);const f=t.querySelector('.rte-blocks-library-list[role="listbox"]');f&&f.setAttribute("aria-label",r.labels.resultsListLabel);const g=t.querySelector(".rte-blocks-library-shortcut");g&&(g.textContent=r.labels.shortcutText);const h=t.querySelector('[data-action="insert-selected"]');if(h){h.textContent=r.labels.insertText;const B=!Se(e)&&!!o.selectedBlockId;h.disabled=!B,h.setAttribute("aria-disabled",B?"false":"true")}const R=t.querySelector(".rte-blocks-library-empty"),V=t.querySelector(".rte-blocks-library-list"),H=Ie(e,r);lt(e,H);const Y=t.querySelector(".rte-blocks-library-status");if(Y&&(o.loading?Y.textContent=r.labels.loadingText:o.loadError?Y.textContent=o.loadError:Y.textContent=`${r.labels.summaryPrefix}: ${o.visibleMatches}/${o.totalMatches}`),V){const B=new Set(o.recentBlockIds);V.innerHTML=H.map(p=>{const ie=o.selectedBlockId===p.id,Pe=p.tags.length?` • ${p.tags.join(", ")}`:"",Oe=B.has(p.id),me=p.previewText.slice(0,180);return`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",fe="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ye="__editoraCommandEditorRoot",he="rte-blocks-library-styles",d="rte-blocks-library-panel",E="blocks-library",C="blocksLibrary",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',De=80,Ce=new Set(["script","style","meta","link","object","embed","iframe"]),Ne=/^(https?:|mailto:|tel:|#|\/)/i,Ke=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,je={panelTitle:"Blocks Library",panelAriaLabel:"Blocks library panel",searchLabel:"Search blocks",searchPlaceholder:"Search by name, category, or keyword",categoryLabel:"Category",allCategoriesText:"All categories",recentHeading:"Recent inserts",insertText:"Insert Selected",closeText:"Close",noResultsText:"No matching blocks found.",summaryPrefix:"Blocks",loadingText:"Loading blocks...",loadErrorText:"Unable to load blocks right now.",readonlyMessage:"Editor is read-only. Block insertion is disabled.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",helperText:"Use Arrow keys to move through blocks, Enter to insert, Esc to close.",lastInsertedPrefix:"Last inserted",resultsListLabel:"Block results"},b=new WeakMap,J=new WeakMap,w=new WeakMap,I=new WeakMap,D=new WeakMap,j=new WeakMap,W=new WeakMap,z=new WeakMap,q=new WeakMap,te=new WeakMap,x=new Map,U=new WeakMap,oe=new Set;let X=0,We=0,ke=0,M=null,m=null,_=null,P=null,A=null,O=null;function h(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Fe(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function Ge(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e){const t=e.trim();return t&&(Ne.test(t)||Ke.test(t))?t:""}function xe(e){let t=e;return Ce.forEach(r=>{const o=new RegExp(`<${r}[\\s\\S]*?>[\\s\\S]*?<\\/${r}>`,"gi"),l=new RegExp(`<${r}\\b[^>]*\\/?>`,"gi");t=t.replace(o,"").replace(l,"")}),t=t.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n,a)=>{const s=typeof n=="string"&&n.length>0?n:a||"",i=ce(s);if(!i)return"";const c=l.startsWith('"')?'"':"'";return` ${o}=${c}${i}${c}`}).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi,(r,o,l)=>{const n=ce(l);return n?` ${o}="${n}"`:""}).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n)=>{const a=typeof l=="string"&&l.length>0?l:n||"";if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))return"";const s=o.startsWith('"')?'"':"'";return` style=${s}${a}${s}`}).trim(),t}function Ue(e){if(!e)return"";if(typeof document>"u")return xe(e);const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.querySelectorAll!="function"?xe(e):(Array.from(r.querySelectorAll("*")).forEach(l=>{const n=l.tagName.toLowerCase();if(Ce.has(n)){l.remove();return}Array.from(l.attributes).forEach(s=>{const i=s.name.toLowerCase(),c=s.value;if(i.startsWith("on")){l.removeAttribute(s.name);return}if(i==="style"){/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(c)&&l.removeAttribute(s.name);return}if(i==="href"||i==="src"||i==="xlink:href"){const u=ce(c);if(!u){l.removeAttribute(s.name);return}u!==c&&l.setAttribute(s.name,u)}})}),t.innerHTML.trim())}function ne(e){return e.trim().toLowerCase()}function Ve(e){if(!e)return"";if(typeof document>"u")return e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.textContent!="string"?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():r.textContent.replace(/\s+/g," ").trim()}function $e(e,t){if(!Array.isArray(e)||e.length===0)return[];const r=new Set,o=[];return e.forEach(l=>{const n=t.normalizeText(l.label||""),a=t.sanitizeBlockHtml(l.html||"",l).trim();if(!n||!a)return;const s=t.normalizeText(l.category||"General")||"General",i=ne(s);let u=Ge(t.normalizeText(l.id||n))||`block-${ke++}`;for(;r.has(u);)u=`${u}-${ke++}`;r.add(u);const f=(l.tags||[]).map(H=>t.normalizeText(H)).filter(Boolean),g=(l.keywords||[]).map(H=>t.normalizeText(H)).filter(Boolean),y=t.normalizeText(l.description||""),R=Ve(a),V=[n,y,s,...f,...g,R].join(" ").toLowerCase();o.push({id:u,label:n,html:a,description:y,category:s,categoryKey:i,tags:f,keywords:g,previewText:R,searchBlob:V})}),o}function Q(e={}){const t=e.normalizeText||Fe,r=e.sanitizeBlockHtml||Ue,o={blocks:[],defaultCategory:t(e.defaultCategory||""),maxResults:Math.max(4,Math.min(300,Number(e.maxResults??80))),maxRecentBlocks:Math.max(1,Math.min(20,Number(e.maxRecentBlocks??6))),debounceMs:Math.max(0,Math.min(700,Number(e.debounceMs??90))),cacheTtlMs:Math.max(0,Number(e.cacheTtlMs??6e4)),labels:{...je,...e.labels||{}},normalizeText:t,sanitizeBlockHtml:r,getBlocks:typeof e.getBlocks=="function"?e.getBlocks:void 0};return o.blocks=$e(e.blocks,o),o}function Ye(e){return{blocks:e.blocks.map(t=>({id:t.id,label:t.label,html:t.html,description:t.description||void 0,category:t.category||void 0,tags:t.tags.length?[...t.tags]:void 0,keywords:t.keywords.length?[...t.keywords]:void 0})),defaultCategory:e.defaultCategory,maxResults:e.maxResults,maxRecentBlocks:e.maxRecentBlocks,debounceMs:e.debounceMs,cacheTtlMs:e.cacheTtlMs,labels:{...e.labels},normalizeText:e.normalizeText,sanitizeBlockHtml:e.sanitizeBlockHtml,getBlocks:e.getBlocks}}function le(e){return e.closest(fe)||e}function G(e){if(!e)return null;if(e.matches(v))return e;const t=e.querySelector(v);return t instanceof HTMLElement?t:null}function Xe(){if(typeof window>"u")return null;const e=window[ye];if(!(e instanceof HTMLElement))return null;window[ye]=null;const t=G(e);if(t)return t;const r=e.closest(fe);if(r){const l=G(r);if(l)return l}const o=e.closest(v);return o instanceof HTMLElement?o:null}function Ze(e){const t=e.closest("[data-editora-editor]");if(t&&G(t)===e)return t;let r=e;for(;r;){if(r.matches(fe)&&(r===e||G(r)===e))return r;r=r.parentElement}return le(e)}function Te(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(){Array.from(oe).forEach(t=>{t.isConnected||ge(t)})}function T(e,t=!0,r=!0){if(ee(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const a=G(e.editorElement);if(a)return a}const o=Xe();if(o)return o;const l=window.getSelection();if(l&&l.rangeCount>0){const s=Te(l.getRangeAt(0).startContainer)?.closest(v);if(s)return s}const n=document.activeElement;if(n){if(n.matches(v))return n;const a=n.closest(v);if(a)return a}if(r){if(m&&m.isConnected)return m;m&&!m.isConnected&&(m=null)}return t?document.querySelector(v):null}function Je(e){const t=e.target;if(t){const o=t.closest(v);if(o)return o}const r=window.getSelection();if(r&&r.rangeCount>0){const l=Te(r.getRangeAt(0).startContainer)?.closest(v);if(l)return l}return null}function Z(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 Qe(e){const t=le(e);if(Z(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Z(r)?!0:Z(document.documentElement)||Z(document.body)}function re(e,t){e.classList.remove("rte-blocks-library-theme-dark"),Qe(t)&&e.classList.add("rte-blocks-library-theme-dark")}function Se(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function we(e,t,r){const o=Ze(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(n=>{n.classList.toggle("active",r),n.setAttribute("data-active",r?"true":"false"),n.setAttribute("aria-pressed",r?"true":"false")})}function Ee(e,t){const r=e.querySelector(".rte-blocks-library-live");r&&(r.textContent=t)}function se(e){const t=He(e);if(t)try{q.set(e,t.cloneRange())}catch{}}function Me(e){const t=q.get(e);if(!t)return null;if(!e.isConnected)return q.delete(e),null;try{const r=t.cloneRange();return e.contains(r.commonAncestorContainer)?r:(q.delete(e),null)}catch{return q.delete(e),null}}function et(e){const t=Me(e);return t?(ze(e,t),!0):!1}function tt(e){if(te.has(e))return;const t=()=>{const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);e.contains(o.commonAncestorContainer)&&se(e)};e.addEventListener("keyup",t),e.addEventListener("mouseup",t),e.addEventListener("touchend",t),te.set(e,t)}function rt(e){const t=te.get(e);t&&(e.removeEventListener("keyup",t),e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t),te.delete(e))}function k(e,t){b.has(e)||b.set(e,t),I.has(e)||(I.set(e,t.blocks),D.set(e,Date.now()));let r=w.get(e);return r||(r={query:"",category:t.defaultCategory?ne(t.defaultCategory):"all",selectedBlockId:null,recentBlockIds:[],lastInsertedBlockId:null,loading:!1,loadError:null,totalMatches:0,visibleMatches:0,filterCache:new Map,debounceTimer:null},w.set(e,r)),oe.add(e),tt(e),r}function Ae(e){const t=w.get(e);!t||t.debounceTimer===null||(window.clearTimeout(t.debounceTimer),t.debounceTimer=null)}function ge(e){Ae(e),rt(e),q.delete(e);const t=W.get(e);t&&(t.abort(),W.delete(e)),j.delete(e),z.delete(e),x.get(e)?.remove(),x.delete(e),U.delete(e),b.delete(e),J.delete(e),w.delete(e),I.delete(e),D.delete(e),oe.delete(e),m===e&&(m=null)}function ot(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let o=0;o<r.removedNodes.length;o+=1){const l=r.removedNodes[o];if(l.nodeType!==Node.ELEMENT_NODE)continue;const n=l;if(n.matches?.(v)||n.matches?.(`.${d}`)||n.querySelector?.(v)||n.querySelector?.(`.${d}`))return!0}}return!1}function pe(e){return U.get(e)===!0}function ue(e,t){if(!t.classList.contains("show"))return;const r=le(e).getBoundingClientRect(),o=Math.min(window.innerWidth-20,420),l=Math.max(10,window.innerWidth-o-10),n=Math.min(Math.max(10,r.right-o),l),a=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${o}px`,t.style.left=`${n}px`,t.style.top=`${a}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ae(e){return I.get(e)||b.get(e)?.blocks||[]}function nt(e,t){const r=new Map;ae(e).forEach(l=>{r.has(l.categoryKey)||r.set(l.categoryKey,l.category)});const o=Array.from(r.entries()).sort((l,n)=>l[1].localeCompare(n[1])).map(([l,n])=>({value:l,label:n}));return[{value:"all",label:t.labels.allCategoriesText},...o]}function Ie(e,t){const r=k(e,t),o=ae(e),l=r.query.trim().toLowerCase(),n=r.category||"all",a=`${l}|${n}|${t.maxResults}`,s=r.filterCache.get(a);if(s){const u=new Map(o.map(g=>[g.id,g])),f=s.ids.map(g=>u.get(g)).filter(Boolean);return r.totalMatches=s.total,r.visibleMatches=f.length,f}const i=[];let c=0;for(let u=0;u<o.length;u+=1){const f=o[u];n!=="all"&&f.categoryKey!==n||l&&!f.searchBlob.includes(l)||(c+=1,i.length<t.maxResults&&i.push(f))}if(r.totalMatches=c,r.visibleMatches=i.length,r.filterCache.set(a,{ids:i.map(u=>u.id),total:c}),r.filterCache.size>De){const u=r.filterCache.keys().next().value;typeof u=="string"&&r.filterCache.delete(u)}return i}function lt(e,t){const r=w.get(e);if(!r)return;if(t.length===0){r.selectedBlockId=null;return}t.some(l=>l.id===r.selectedBlockId)||(r.selectedBlockId=t[0].id)}function N(e){const t=w.get(e);we(e,"toggleBlocksLibraryPanel",pe(e)),we(e,"insertLastBlockSnippet",!!t?.lastInsertedBlockId)}function L(e){const t=x.get(e),r=b.get(e)||M,o=w.get(e);if(!t||!r||!o)return;re(t,e);const l=t.querySelector(".rte-blocks-library-title");l&&(l.textContent=r.labels.panelTitle);const n=t.querySelector('[data-action="close"]');n&&(n.setAttribute("aria-label",r.labels.closeText),n.textContent="✕");const a=t.querySelector(".rte-blocks-library-search-label");a&&(a.textContent=r.labels.searchLabel);const s=t.querySelector('[data-field="query"]');s&&(s.setAttribute("placeholder",r.labels.searchPlaceholder),s.value!==o.query&&(s.value=o.query));const i=t.querySelector(".rte-blocks-library-category-label");i&&(i.textContent=r.labels.categoryLabel);const c=t.querySelector('[data-field="category"]');if(c){const B=nt(e,r);c.innerHTML=B.map(p=>`<option value="${h(p.value)}">${h(p.label)}</option>`).join(""),B.some(p=>p.value===o.category)||(o.category="all"),c.value=o.category}const u=t.querySelector(".rte-blocks-library-helper");u&&(u.textContent=r.labels.helperText);const f=t.querySelector('.rte-blocks-library-list[role="listbox"]');f&&f.setAttribute("aria-label",r.labels.resultsListLabel);const g=t.querySelector(".rte-blocks-library-shortcut");g&&(g.textContent=r.labels.shortcutText);const y=t.querySelector('[data-action="insert-selected"]');if(y){y.textContent=r.labels.insertText;const B=!Se(e)&&!!o.selectedBlockId;y.disabled=!B,y.setAttribute("aria-disabled",B?"false":"true")}const R=t.querySelector(".rte-blocks-library-empty"),V=t.querySelector(".rte-blocks-library-list"),H=Ie(e,r);lt(e,H);const Y=t.querySelector(".rte-blocks-library-status");if(Y&&(o.loading?Y.textContent=r.labels.loadingText:o.loadError?Y.textContent=o.loadError:Y.textContent=`${r.labels.summaryPrefix}: ${o.visibleMatches}/${o.totalMatches}`),V){const B=new Set(o.recentBlockIds);V.innerHTML=H.map(p=>{const ie=o.selectedBlockId===p.id,Pe=p.tags.length?` • ${p.tags.join(", ")}`:"",Oe=B.has(p.id),me=p.previewText.slice(0,180);return`
|
|
2
2
|
<li class="rte-blocks-library-item-wrapper" role="presentation">
|
|
3
3
|
<button
|
|
4
4
|
type="button"
|
|
5
5
|
class="rte-blocks-library-item${ie?" active":""}"
|
|
6
|
-
data-block-id="${
|
|
6
|
+
data-block-id="${h(p.id)}"
|
|
7
7
|
role="option"
|
|
8
8
|
aria-selected="${ie?"true":"false"}"
|
|
9
|
-
aria-label="${m(p.label)}"
|
|
10
9
|
tabindex="${ie?"0":"-1"}"
|
|
11
10
|
>
|
|
12
11
|
<span class="rte-blocks-library-item-head">
|
|
13
|
-
<span class="rte-blocks-library-item-label">${
|
|
14
|
-
${Oe?`<span class="rte-blocks-library-recent-pill">${
|
|
12
|
+
<span class="rte-blocks-library-item-label">${h(p.label)}</span>
|
|
13
|
+
${Oe?`<span class="rte-blocks-library-recent-pill">${h(r.labels.recentHeading)}</span>`:""}
|
|
15
14
|
</span>
|
|
16
|
-
<span class="rte-blocks-library-item-meta">${
|
|
17
|
-
${p.description?`<span class="rte-blocks-library-item-description">${
|
|
18
|
-
${me?`<span class="rte-blocks-library-item-preview">${
|
|
15
|
+
<span class="rte-blocks-library-item-meta">${h(p.category)}${h(Pe)}</span>
|
|
16
|
+
${p.description?`<span class="rte-blocks-library-item-description">${h(p.description)}</span>`:""}
|
|
17
|
+
${me?`<span class="rte-blocks-library-item-preview">${h(me)}</span>`:""}
|
|
19
18
|
</button>
|
|
20
19
|
</li>
|
|
21
20
|
`}).join("")}R&&(R.hidden=H.length>0,R.textContent=r.labels.noResultsText);const K=t.querySelector(".rte-blocks-library-last-inserted");if(K)if(o.lastInsertedBlockId){const B=ae(e).find(p=>p.id===o.lastInsertedBlockId);B?(K.hidden=!1,K.textContent=`${r.labels.lastInsertedPrefix}: ${B.label}`):K.hidden=!0}else K.hidden=!0;t.setAttribute("aria-label",r.labels.panelAriaLabel)}function S(e,t=!1){const r=x.get(e);r&&(r.classList.remove("show"),U.set(e,!1),N(e),t&&(e.focus({preventScroll:!0}),et(e)))}function st(e){e.querySelector(".rte-blocks-library-item.active")?.focus()}function ve(e,t){const r=b.get(e)||M;if(!r)return;const o=w.get(e);if(!o)return;const l=Ie(e,r);if(l.length===0)return;const a=(Math.max(0,l.findIndex(i=>i.id===o.selectedBlockId))+t+l.length)%l.length;o.selectedBlockId=l[a].id,L(e);const s=x.get(e);s&&st(s)}function de(e){const t=bt(e);se(e),x.forEach((o,l)=>{l!==e&&S(l,!1)}),t.classList.add("show"),U.set(e,!0),L(e),ue(e,t),N(e),t.querySelector('[data-field="query"]')?.focus(),be(e,!1)}function Re(e,t){const r=pe(e);return(typeof t=="boolean"?t:!r)?de(e):S(e,!1),!0}function He(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null}function ze(e,t){if(!e.isConnected)return;const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t))}const at=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]);function Le(e,t){let r=e;for(;r&&r!==t;){if(r.nodeType===Node.ELEMENT_NODE&&at.has(r.tagName))return r;r=r.parentNode}return null}function Be(e,t,r){const o=t.cloneRange();if(!e.contains(o.commonAncestorContainer))return!1;o.deleteContents();const l=document.createElement("template");l.innerHTML=r;const n=l.content;if(!n)return!1;const a=n.lastChild,s=Le(o.endContainer,e)||Le(o.startContainer,e);if(s&&s.parentNode?s.parentNode.insertBefore(n,s.nextSibling):o.insertNode(n),a){const i=document.createRange();i.setStartAfter(a),i.collapse(!0),ze(e,i)}return se(e),!0}function it(e,t){e.focus({preventScroll:!0});const r=Me(e);if(r&&Be(e,r,t))return!0;try{if(document.execCommand("insertHTML",!1,t))return se(e),!0}catch{}const o=He(e);return o?Be(e,o,t):!1}function ct(e,t){if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}}function ut(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function F(e,t){const r=b.get(e)||M;if(!r)return!1;const o=k(e,r),l=x.get(e);if(Se(e))return l&&Ee(l,r.labels.readonlyMessage),!1;const n=ae(e).find(i=>i.id===t);if(!n)return!1;const a=e.innerHTML;return it(e,n.html)?(o.lastInsertedBlockId=n.id,o.selectedBlockId=n.id,o.recentBlockIds=[n.id,...o.recentBlockIds.filter(i=>i!==n.id)].slice(0,r.maxRecentBlocks),ct(e,a),ut(e),N(e),e.dispatchEvent(new CustomEvent("editora:blocks-library-insert",{bubbles:!0,detail:{blockId:n.id,label:n.label,category:n.category}})),L(e),l&&Ee(l,`${r.labels.lastInsertedPrefix}: ${n.label}`),!0):!1}function qe(e){const t=w.get(e);return t?.lastInsertedBlockId?F(e,t.lastInsertedBlockId):!1}function dt(e){const t=b.get(e)||M;if(!t)return;const r=w.get(e);if(!r)return;Ae(e);const o=()=>{r.debounceTimer=null,r.filterCache.clear(),L(e)};if(t.debounceMs<=0){o();return}r.debounceTimer=window.setTimeout(o,t.debounceMs)}function bt(e){const t=x.get(e);if(t)return t;const r=b.get(e)||M||Q(),o=k(e,r),l=`rte-blocks-library-panel-${We++}`,n=`${l}-query`,a=`${l}-category`,s=document.createElement("section");return s.className=d,s.id=l,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","false"),s.setAttribute("aria-label",r.labels.panelAriaLabel),s.innerHTML=`
|
|
22
21
|
<header class="rte-blocks-library-header">
|
|
23
|
-
<h2 class="rte-blocks-library-title">${
|
|
24
|
-
<button type="button" class="rte-blocks-library-icon-btn" data-action="close" aria-label="${
|
|
22
|
+
<h2 class="rte-blocks-library-title">${h(r.labels.panelTitle)}</h2>
|
|
23
|
+
<button type="button" class="rte-blocks-library-icon-btn" data-action="close" aria-label="${h(r.labels.closeText)}">✕</button>
|
|
25
24
|
</header>
|
|
26
25
|
<div class="rte-blocks-library-body">
|
|
27
|
-
<label class="rte-blocks-library-search-label" for="${
|
|
28
|
-
<input id="${
|
|
29
|
-
<label class="rte-blocks-library-category-label" for="${
|
|
30
|
-
<select id="${
|
|
26
|
+
<label class="rte-blocks-library-search-label" for="${h(n)}"></label>
|
|
27
|
+
<input id="${h(n)}" class="rte-blocks-library-input" type="text" data-field="query" autocomplete="off" />
|
|
28
|
+
<label class="rte-blocks-library-category-label" for="${h(a)}"></label>
|
|
29
|
+
<select id="${h(a)}" class="rte-blocks-library-select" data-field="category"></select>
|
|
31
30
|
<p class="rte-blocks-library-status" aria-live="polite"></p>
|
|
32
31
|
<p class="rte-blocks-library-helper"></p>
|
|
33
32
|
<p class="rte-blocks-library-last-inserted" hidden></p>
|
|
34
33
|
<div class="rte-blocks-library-list-wrap">
|
|
35
|
-
<ul class="rte-blocks-library-list" role="listbox" aria-label="${
|
|
34
|
+
<ul class="rte-blocks-library-list" role="listbox" aria-label="${h(r.labels.resultsListLabel)}"></ul>
|
|
36
35
|
<p class="rte-blocks-library-empty" hidden></p>
|
|
37
36
|
</div>
|
|
38
37
|
<div class="rte-blocks-library-actions">
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
<p class="rte-blocks-library-shortcut"></p>
|
|
42
41
|
</div>
|
|
43
42
|
<div class="rte-blocks-library-live" aria-live="polite" aria-atomic="true"></div>
|
|
44
|
-
`,s.addEventListener("click",i=>{const c=i.target,u=c?.closest("[data-action]");if(u){const
|
|
43
|
+
`,s.addEventListener("click",i=>{const c=i.target,u=c?.closest("[data-action]");if(u){const y=u.getAttribute("data-action");if(y==="close"){S(e,!0);return}if(y==="insert-selected"){if(!o.selectedBlockId)return;F(e,o.selectedBlockId)&&S(e,!0)}return}const f=c?.closest("[data-block-id]");if(!f)return;const g=f.getAttribute("data-block-id");g&&(o.selectedBlockId=g,L(e),i.detail>=2&&F(e,g)&&S(e,!0))}),s.addEventListener("input",i=>{const c=i.target;!(c instanceof HTMLInputElement)||c.getAttribute("data-field")!=="query"||(o.query=r.normalizeText(c.value).toLowerCase(),o.filterCache.clear(),dt(e))}),s.addEventListener("change",i=>{const c=i.target;!(c instanceof HTMLSelectElement)||c.getAttribute("data-field")!=="category"||(o.category=ne(c.value||"all")||"all",o.filterCache.clear(),L(e))}),s.addEventListener("keydown",i=>{if(i.key==="Escape"){i.preventDefault(),S(e,!0);return}if(i.key==="ArrowDown"){i.preventDefault(),ve(e,1);return}if(i.key==="ArrowUp"){i.preventDefault(),ve(e,-1);return}if(i.key==="Enter"){if(!i.target?.matches('[data-field="query"], [data-field="category"], [data-block-id]')||!o.selectedBlockId)return;i.preventDefault(),F(e,o.selectedBlockId)&&S(e,!0)}}),re(s,e),document.body.appendChild(s),x.set(e,s),U.set(e,!1),L(e),s}function ft(e){const t=w.get(e);return{query:t?.query||"",category:t?.category||"all",selectedBlockId:t?.selectedBlockId||null,totalMatches:t?.totalMatches||0,visibleMatches:t?.visibleMatches||0,recentBlockIds:t?.recentBlockIds?[...t.recentBlockIds]:[],lastInsertedBlockId:t?.lastInsertedBlockId||null,loading:t?.loading===!0,loadError:t?.loadError||null}}async function be(e,t){const r=b.get(e)||M;if(!r||typeof r.getBlocks!="function")return;const o=k(e,r),l=D.get(e)||0;if(!t&&r.cacheTtlMs>0&&Date.now()-l<r.cacheTtlMs)return;const n=j.get(e);if(n&&!t)return n;const a=W.get(e);a&&a.abort(),t&&n&&j.delete(e);const s=new AbortController;W.set(e,s);const i=(z.get(e)||0)+1;z.set(e,i),o.loading=!0,o.loadError=null,L(e);const c=Promise.resolve().then(async()=>{const u={editor:e,editorRoot:le(e),signal:s.signal},f=await r.getBlocks?.(u);if(s.signal.aborted||z.get(e)!==i)return;const g=$e(f||[],r);I.set(e,g),D.set(e,Date.now());const y=w.get(e);y&&(y.loading=!1,y.loadError=null,y.filterCache.clear())}).catch(()=>{if(s.signal.aborted||z.get(e)!==i)return;const u=w.get(e);u&&(u.loading=!1,u.loadError=r.labels.loadErrorText)}).finally(()=>{z.get(e)===i&&(j.delete(e),W.delete(e)),L(e)});return j.set(e,c),c}function _e(e){return typeof e.key=="string"?e.key.toLowerCase():""}function gt(e){const t=_e(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="b"}function pt(e){const t=_e(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function mt(e){M=e,_||(_=t=>{ee();const o=t.target?.closest(v);if(!o)return;const l=b.get(o)||e;k(o,l),b.set(o,l),m=o,N(o);const n=x.get(o);n&&(re(n,o),ue(o,n),L(o))},document.addEventListener("focusin",_,!0)),P||(P=t=>{if(t.defaultPrevented)return;const r=`.${d} input, .${d} textarea, .${d} select`,o=t.target;if(o?.closest(r)){if(t.key==="Escape"){const a=o.closest(`.${d}`),s=Array.from(x.entries()).find(([,i])=>i===a);s&&(t.preventDefault(),S(s[0],!0))}return}const l=Je(t);if(!l)return;const n=b.get(l)||M||e;if(k(l,n),b.set(l,n),m=l,t.key==="Escape"&&pe(l)){t.preventDefault(),S(l,!0);return}if(gt(t)){t.preventDefault(),t.stopPropagation(),Re(l);return}pt(t)&&(t.preventDefault(),t.stopPropagation(),qe(l))},document.addEventListener("keydown",P,!0)),A||(A=()=>{ee(),x.forEach((t,r)=>{!r.isConnected||!t.isConnected||(re(t,r),ue(r,t))})},window.addEventListener("scroll",A,!0),window.addEventListener("resize",A)),!O&&typeof MutationObserver<"u"&&document.body&&(O=new MutationObserver(t=>{ot(t)&&ee()}),O.observe(document.body,{childList:!0,subtree:!0}))}function yt(){_&&(document.removeEventListener("focusin",_,!0),_=null),P&&(document.removeEventListener("keydown",P,!0),P=null),A&&(window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A),A=null),O&&(O.disconnect(),O=null),x.forEach(t=>t.remove()),x.clear(),Array.from(oe).forEach(t=>ge(t)),M=null,m=null}function ht(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=`
|
|
45
44
|
.rte-toolbar-group-items.${E},
|
|
46
45
|
.editora-toolbar-group-items.${E},
|
|
47
46
|
.rte-toolbar-group-items.${C},
|
|
@@ -345,7 +344,7 @@
|
|
|
345
344
|
.rte-blocks-library-item-preview {
|
|
346
345
|
font-size: 11px;
|
|
347
346
|
line-height: 1.3;
|
|
348
|
-
color: #
|
|
347
|
+
color: #475569;
|
|
349
348
|
}
|
|
350
349
|
|
|
351
350
|
.rte-blocks-library-item-preview {
|
|
@@ -369,7 +368,7 @@
|
|
|
369
368
|
.rte-blocks-library-empty {
|
|
370
369
|
margin: 8px;
|
|
371
370
|
font-size: 12px;
|
|
372
|
-
color: #
|
|
371
|
+
color: #475569;
|
|
373
372
|
}
|
|
374
373
|
|
|
375
374
|
.rte-blocks-library-actions {
|
|
@@ -439,4 +438,4 @@
|
|
|
439
438
|
max-height: calc(100vh - 20px);
|
|
440
439
|
}
|
|
441
440
|
}
|
|
442
|
-
`,document.head.appendChild(e)}const kt=(e={})=>{const t=Q(e),r=new Set;return ht(),{name:"blocksLibrary",toolbar:[{id:"blocksLibraryGroup",label:"Blocks Library",type:"group",command:"blocksLibrary",items:[{id:"blocksLibraryPanel",label:"Blocks Library Panel",command:"toggleBlocksLibraryPanel",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="4" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"insertLastBlockSnippet",label:"Insert Last Block",command:"insertLastBlockSnippet",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 5.5h10a1.5 1.5 0 0 1 1.5 1.5v10A1.5 1.5 0 0 1 17 18.5H7A1.5 1.5 0 0 1 5.5 17V7A1.5 1.5 0 0 1 7 5.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M12 8.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M8.5 12h7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{blocksLibrary:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),
|
|
441
|
+
`,document.head.appendChild(e)}const kt=(e={})=>{const t=Q(e),r=new Set;return ht(),{name:"blocksLibrary",toolbar:[{id:"blocksLibraryGroup",label:"Blocks Library",type:"group",command:"blocksLibrary",items:[{id:"blocksLibraryPanel",label:"Blocks Library Panel",command:"toggleBlocksLibraryPanel",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="4" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"insertLastBlockSnippet",label:"Insert Last Block",command:"insertLastBlockSnippet",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 5.5h10a1.5 1.5 0 0 1 1.5 1.5v10A1.5 1.5 0 0 1 17 18.5H7A1.5 1.5 0 0 1 5.5 17V7A1.5 1.5 0 0 1 7 5.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M12 8.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M8.5 12h7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{blocksLibrary:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),m=n,de(n),!0},openBlocksLibraryPanel:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),m=n,de(n),!0},toggleBlocksLibraryPanel:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),m=n,Re(n,typeof o=="boolean"?o:void 0)},insertBlockSnippet:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a),b.set(n,a);const s=typeof o=="string"?o:o?.id;return s?(m=n,F(n,s)):!1},insertLastBlockSnippet:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),m=n,qe(n)},refreshBlocksLibraryData:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),be(n,!0),!0},setBlocksLibraryOptions:(o,l)=>{const n=T(l,!1,!1);if(!n||!o||typeof o!="object")return!1;const a=b.get(n)||t,s=J.get(n)||Ye(a),i={...s,...o,labels:{...s.labels||{},...o.labels||{}},blocks:Array.isArray(o.blocks)?o.blocks:s.blocks,normalizeText:o.normalizeText||a.normalizeText,sanitizeBlockHtml:o.sanitizeBlockHtml||a.sanitizeBlockHtml,getBlocks:o.getBlocks||a.getBlocks},c=Q(i),u=Array.isArray(o.blocks),f=o.getBlocks!==void 0;b.set(n,c),J.set(n,i),(u||f||!I.has(n))&&(I.set(n,c.blocks),D.set(n,f?0:Date.now()));const g=k(n,c);return g.filterCache.clear(),typeof o.defaultCategory=="string"&&(g.category=ne(c.defaultCategory)||"all"),L(n),N(n),f&&be(n,!0),!0},getBlocksLibraryState:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a);const s=ft(n);if(typeof o=="function")try{o(s)}catch{}return n.__blocksLibraryState=s,n.dispatchEvent(new CustomEvent("editora:blocks-library-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-b":"toggleBlocksLibraryPanel","Mod-Alt-Shift-B":"toggleBlocksLibraryPanel","Mod-Alt-Shift-l":"insertLastBlockSnippet","Mod-Alt-Shift-L":"insertLastBlockSnippet"},init:function(l){X+=1;const n=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,a=Q(n);mt(a);const s=T(l?.editorElement?{editorElement:l.editorElement}:void 0,!1,!1);s&&(m=s,r.add(s),k(s,a),b.set(s,a),J.set(s,n),I.set(s,a.blocks),D.set(s,Date.now()),N(s))},destroy:()=>{r.forEach(o=>ge(o)),r.clear(),X=Math.max(0,X-1),!(X>0)&&yt()}}};exports.BlocksLibraryPlugin=kt;
|