@editora/plugins 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -4
  3. package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
  4. package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
  5. package/dist/anchor.cjs.js +11 -11
  6. package/dist/anchor.esm.js +130 -107
  7. package/dist/anchoredPopover-BzqGPOAE.js +1 -0
  8. package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
  9. package/dist/approval-workflow.cjs.js +447 -0
  10. package/dist/approval-workflow.esm.js +1070 -0
  11. package/dist/background-color.cjs.js +3 -3
  12. package/dist/background-color.esm.js +116 -119
  13. package/dist/blocks-library.cjs.js +442 -0
  14. package/dist/blocks-library.esm.js +1317 -0
  15. package/dist/citations.cjs.js +548 -0
  16. package/dist/citations.esm.js +1457 -0
  17. package/dist/code.cjs.js +82 -102
  18. package/dist/code.esm.js +1172 -662
  19. package/dist/comments.cjs.js +10 -10
  20. package/dist/comments.esm.js +195 -177
  21. package/dist/conditional-content.cjs.js +626 -0
  22. package/dist/conditional-content.esm.js +1360 -0
  23. package/dist/content-rules.cjs.js +408 -0
  24. package/dist/content-rules.esm.js +1093 -0
  25. package/dist/data-binding.cjs.js +321 -0
  26. package/dist/data-binding.esm.js +913 -0
  27. package/dist/doc-schema.cjs.js +398 -0
  28. package/dist/doc-schema.esm.js +1310 -0
  29. package/dist/document-manager.cjs.js +1 -1
  30. package/dist/document-manager.esm.js +1 -1
  31. package/dist/documentManager-CTqRftU8.mjs +8369 -0
  32. package/dist/documentManager-Jf0RbSks.js +17 -0
  33. package/dist/embed-iframe.cjs.js +2 -2
  34. package/dist/embed-iframe.esm.js +8 -5
  35. package/dist/emojis.cjs.js +64 -39
  36. package/dist/emojis.esm.js +133 -104
  37. package/dist/enterprise.cjs.js +1 -0
  38. package/dist/enterprise.esm.js +56 -0
  39. package/dist/html2canvas.esm-B5qzocYs.js +5 -0
  40. package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
  41. package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
  42. package/dist/index-CvJk4DKa.js +221 -0
  43. package/dist/index-D3CycEFU.mjs +16543 -0
  44. package/dist/index-tqLTHcO6.js +1 -0
  45. package/dist/index.cjs.js +1 -1
  46. package/dist/{index.es-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
  47. package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
  48. package/dist/index.esm.js +111 -75
  49. package/dist/jspdf.es.min-BoS80556.js +77 -0
  50. package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
  51. package/dist/link.cjs.js +6 -6
  52. package/dist/link.esm.js +41 -39
  53. package/dist/math.cjs.js +21 -21
  54. package/dist/math.esm.js +151 -112
  55. package/dist/media-manager.cjs.js +15 -15
  56. package/dist/media-manager.esm.js +227 -206
  57. package/dist/mentions.cjs.js +105 -0
  58. package/dist/mentions.esm.js +726 -0
  59. package/dist/merge-tag.cjs.js +44 -12
  60. package/dist/merge-tag.esm.js +368 -241
  61. package/dist/page-break.cjs.js +2 -2
  62. package/dist/page-break.esm.js +85 -77
  63. package/dist/pii-redaction.cjs.js +436 -0
  64. package/dist/pii-redaction.esm.js +1377 -0
  65. package/dist/preview.cjs.js +3 -3
  66. package/dist/preview.esm.js +29 -29
  67. package/dist/slash-commands.cjs.js +90 -0
  68. package/dist/slash-commands.esm.js +752 -0
  69. package/dist/smart-paste.cjs.js +398 -0
  70. package/dist/smart-paste.esm.js +1388 -0
  71. package/dist/special-characters.cjs.js +83 -45
  72. package/dist/special-characters.esm.js +149 -100
  73. package/dist/spell-check.cjs.js +9 -9
  74. package/dist/spell-check.esm.js +235 -216
  75. package/dist/template.cjs.js +14 -14
  76. package/dist/template.esm.js +157 -131
  77. package/dist/text-color.cjs.js +9 -9
  78. package/dist/text-color.esm.js +131 -115
  79. package/dist/track-changes.cjs.js +77 -0
  80. package/dist/track-changes.esm.js +755 -0
  81. package/dist/translation-workflow.cjs.js +626 -0
  82. package/dist/translation-workflow.esm.js +1718 -0
  83. package/dist/version-diff.cjs.js +362 -0
  84. package/dist/version-diff.esm.js +768 -0
  85. package/index.d.ts +849 -1
  86. package/package.json +105 -6
  87. package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
  88. package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
  89. package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
  90. package/dist/documentManager-_tQQfQi9.js +0 -317
  91. package/dist/index-D3pJyAsj.js +0 -1
@@ -0,0 +1,1317 @@
1
+ const v = ".rte-content, .editora-content", fe = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", ye = "__editoraCommandEditorRoot", he = "rte-blocks-library-styles", u = "rte-blocks-library-panel", E = "blocks-library", B = "blocksLibrary", $ = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)';
2
+ const Ce = /* @__PURE__ */ new Set(["script", "style", "meta", "link", "object", "embed", "iframe"]), Pe = /^(https?:|mailto:|tel:|#|\/)/i, De = /^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i, Oe = {
3
+ panelTitle: "Blocks Library",
4
+ panelAriaLabel: "Blocks library panel",
5
+ searchLabel: "Search blocks",
6
+ searchPlaceholder: "Search by name, category, or keyword",
7
+ categoryLabel: "Category",
8
+ allCategoriesText: "All categories",
9
+ recentHeading: "Recent inserts",
10
+ insertText: "Insert Selected",
11
+ closeText: "Close",
12
+ noResultsText: "No matching blocks found.",
13
+ summaryPrefix: "Blocks",
14
+ loadingText: "Loading blocks...",
15
+ loadErrorText: "Unable to load blocks right now.",
16
+ readonlyMessage: "Editor is read-only. Block insertion is disabled.",
17
+ shortcutText: "Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",
18
+ helperText: "Use Arrow keys to move through blocks, Enter to insert, Esc to close.",
19
+ lastInsertedPrefix: "Last inserted",
20
+ resultsListLabel: "Block results"
21
+ }, b = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new WeakMap(), oe = /* @__PURE__ */ new Set();
22
+ let X = 0, Ne = 0, ke = 0, M = null, y = null, _ = null, P = null, A = null, D = null;
23
+ function m(e) {
24
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
25
+ }
26
+ function Ke(e) {
27
+ return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
28
+ }
29
+ function je(e) {
30
+ return e.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
31
+ }
32
+ function ce(e) {
33
+ const t = e.trim();
34
+ return t && (Pe.test(t) || De.test(t)) ? t : "";
35
+ }
36
+ function xe(e) {
37
+ let t = e;
38
+ return Ce.forEach((r) => {
39
+ const o = new RegExp(`<${r}[\\s\\S]*?>[\\s\\S]*?<\\/${r}>`, "gi"), l = new RegExp(`<${r}\\b[^>]*\\/?>`, "gi");
40
+ t = t.replace(o, "").replace(l, "");
41
+ }), t = t.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi, "").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi, "").replace(
42
+ /\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,
43
+ ""
44
+ ).replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi, "").replace(
45
+ /\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,
46
+ (r, o, l, n, a) => {
47
+ const s = typeof n == "string" && n.length > 0 ? n : a || "", i = ce(s);
48
+ if (!i) return "";
49
+ const c = l.startsWith('"') ? '"' : "'";
50
+ return ` ${o}=${c}${i}${c}`;
51
+ }
52
+ ).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi, (r, o, l) => {
53
+ const n = ce(l);
54
+ return n ? ` ${o}="${n}"` : "";
55
+ }).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi, (r, o, l, n) => {
56
+ const a = typeof l == "string" && l.length > 0 ? l : n || "";
57
+ if (/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))
58
+ return "";
59
+ const s = o.startsWith('"') ? '"' : "'";
60
+ return ` style=${s}${a}${s}`;
61
+ }).trim(), t;
62
+ }
63
+ function We(e) {
64
+ if (!e) return "";
65
+ if (typeof document > "u")
66
+ return xe(e);
67
+ const t = document.createElement("template");
68
+ t.innerHTML = e;
69
+ const r = t.content;
70
+ return !r || typeof r.querySelectorAll != "function" ? xe(e) : (Array.from(r.querySelectorAll("*")).forEach((l) => {
71
+ const n = l.tagName.toLowerCase();
72
+ if (Ce.has(n)) {
73
+ l.remove();
74
+ return;
75
+ }
76
+ Array.from(l.attributes).forEach((s) => {
77
+ const i = s.name.toLowerCase(), c = s.value;
78
+ if (i.startsWith("on")) {
79
+ l.removeAttribute(s.name);
80
+ return;
81
+ }
82
+ if (i === "style") {
83
+ /expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(c) && l.removeAttribute(s.name);
84
+ return;
85
+ }
86
+ if (i === "href" || i === "src" || i === "xlink:href") {
87
+ const d = ce(c);
88
+ if (!d) {
89
+ l.removeAttribute(s.name);
90
+ return;
91
+ }
92
+ d !== c && l.setAttribute(s.name, d);
93
+ }
94
+ });
95
+ }), t.innerHTML.trim());
96
+ }
97
+ function ne(e) {
98
+ return e.trim().toLowerCase();
99
+ }
100
+ function Fe(e) {
101
+ if (!e) return "";
102
+ if (typeof document > "u")
103
+ return e.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
104
+ const t = document.createElement("template");
105
+ t.innerHTML = e;
106
+ const r = t.content;
107
+ return !r || typeof r.textContent != "string" ? e.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim() : r.textContent.replace(/\s+/g, " ").trim();
108
+ }
109
+ function Be(e, t) {
110
+ if (!Array.isArray(e) || e.length === 0) return [];
111
+ const r = /* @__PURE__ */ new Set(), o = [];
112
+ return e.forEach((l) => {
113
+ const n = t.normalizeText(l.label || ""), a = t.sanitizeBlockHtml(l.html || "", l).trim();
114
+ if (!n || !a) return;
115
+ const s = t.normalizeText(l.category || "General") || "General", i = ne(s);
116
+ let d = je(t.normalizeText(l.id || n)) || `block-${ke++}`;
117
+ for (; r.has(d); )
118
+ d = `${d}-${ke++}`;
119
+ r.add(d);
120
+ 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 = Fe(a), V = [n, h, s, ...f, ...g, R].join(" ").toLowerCase();
121
+ o.push({
122
+ id: d,
123
+ label: n,
124
+ html: a,
125
+ description: h,
126
+ category: s,
127
+ categoryKey: i,
128
+ tags: f,
129
+ keywords: g,
130
+ previewText: R,
131
+ searchBlob: V
132
+ });
133
+ }), o;
134
+ }
135
+ function Q(e = {}) {
136
+ const t = e.normalizeText || Ke, r = e.sanitizeBlockHtml || We, o = {
137
+ blocks: [],
138
+ defaultCategory: t(e.defaultCategory || ""),
139
+ maxResults: Math.max(4, Math.min(300, Number(e.maxResults ?? 80))),
140
+ maxRecentBlocks: Math.max(1, Math.min(20, Number(e.maxRecentBlocks ?? 6))),
141
+ debounceMs: Math.max(0, Math.min(700, Number(e.debounceMs ?? 90))),
142
+ cacheTtlMs: Math.max(0, Number(e.cacheTtlMs ?? 6e4)),
143
+ labels: {
144
+ ...Oe,
145
+ ...e.labels || {}
146
+ },
147
+ normalizeText: t,
148
+ sanitizeBlockHtml: r,
149
+ getBlocks: typeof e.getBlocks == "function" ? e.getBlocks : void 0
150
+ };
151
+ return o.blocks = Be(e.blocks, o), o;
152
+ }
153
+ function Ge(e) {
154
+ return {
155
+ blocks: e.blocks.map((t) => ({
156
+ id: t.id,
157
+ label: t.label,
158
+ html: t.html,
159
+ description: t.description || void 0,
160
+ category: t.category || void 0,
161
+ tags: t.tags.length ? [...t.tags] : void 0,
162
+ keywords: t.keywords.length ? [...t.keywords] : void 0
163
+ })),
164
+ defaultCategory: e.defaultCategory,
165
+ maxResults: e.maxResults,
166
+ maxRecentBlocks: e.maxRecentBlocks,
167
+ debounceMs: e.debounceMs,
168
+ cacheTtlMs: e.cacheTtlMs,
169
+ labels: { ...e.labels },
170
+ normalizeText: e.normalizeText,
171
+ sanitizeBlockHtml: e.sanitizeBlockHtml,
172
+ getBlocks: e.getBlocks
173
+ };
174
+ }
175
+ function le(e) {
176
+ return e.closest(fe) || e;
177
+ }
178
+ function G(e) {
179
+ if (!e) return null;
180
+ if (e.matches(v)) return e;
181
+ const t = e.querySelector(v);
182
+ return t instanceof HTMLElement ? t : null;
183
+ }
184
+ function Ue() {
185
+ if (typeof window > "u") return null;
186
+ const e = window[ye];
187
+ if (!(e instanceof HTMLElement)) return null;
188
+ window[ye] = null;
189
+ const t = G(e);
190
+ if (t) return t;
191
+ const r = e.closest(fe);
192
+ if (r) {
193
+ const l = G(r);
194
+ if (l) return l;
195
+ }
196
+ const o = e.closest(v);
197
+ return o instanceof HTMLElement ? o : null;
198
+ }
199
+ function Ve(e) {
200
+ const t = e.closest("[data-editora-editor]");
201
+ if (t && G(t) === e)
202
+ return t;
203
+ let r = e;
204
+ for (; r; ) {
205
+ if (r.matches(fe) && (r === e || G(r) === e))
206
+ return r;
207
+ r = r.parentElement;
208
+ }
209
+ return le(e);
210
+ }
211
+ function $e(e) {
212
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
213
+ }
214
+ function ee() {
215
+ Array.from(oe).forEach((t) => {
216
+ t.isConnected || ge(t);
217
+ });
218
+ }
219
+ function T(e, t = !0, r = !0) {
220
+ if (ee(), e?.contentElement instanceof HTMLElement) return e.contentElement;
221
+ if (e?.editorElement instanceof HTMLElement) {
222
+ const a = G(e.editorElement);
223
+ if (a) return a;
224
+ }
225
+ const o = Ue();
226
+ if (o) return o;
227
+ const l = window.getSelection();
228
+ if (l && l.rangeCount > 0) {
229
+ const s = $e(l.getRangeAt(0).startContainer)?.closest(v);
230
+ if (s) return s;
231
+ }
232
+ const n = document.activeElement;
233
+ if (n) {
234
+ if (n.matches(v)) return n;
235
+ const a = n.closest(v);
236
+ if (a) return a;
237
+ }
238
+ if (r) {
239
+ if (y && y.isConnected) return y;
240
+ y && !y.isConnected && (y = null);
241
+ }
242
+ return t ? document.querySelector(v) : null;
243
+ }
244
+ function Ye(e) {
245
+ const t = e.target;
246
+ if (t) {
247
+ const o = t.closest(v);
248
+ if (o) return o;
249
+ }
250
+ const r = window.getSelection();
251
+ if (r && r.rangeCount > 0) {
252
+ const l = $e(r.getRangeAt(0).startContainer)?.closest(v);
253
+ if (l) return l;
254
+ }
255
+ return null;
256
+ }
257
+ function Z(e) {
258
+ 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;
259
+ }
260
+ function Xe(e) {
261
+ const t = le(e);
262
+ if (Z(t)) return !0;
263
+ const r = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
264
+ return Z(r) ? !0 : Z(document.documentElement) || Z(document.body);
265
+ }
266
+ function re(e, t) {
267
+ e.classList.remove("rte-blocks-library-theme-dark"), Xe(t) && e.classList.add("rte-blocks-library-theme-dark");
268
+ }
269
+ function Te(e) {
270
+ return e.getAttribute("contenteditable") === "false" || e.getAttribute("data-readonly") === "true";
271
+ }
272
+ function we(e, t, r) {
273
+ const o = Ve(e);
274
+ Array.from(
275
+ o.querySelectorAll(
276
+ `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
277
+ )
278
+ ).forEach((n) => {
279
+ n.classList.toggle("active", r), n.setAttribute("data-active", r ? "true" : "false"), n.setAttribute("aria-pressed", r ? "true" : "false");
280
+ });
281
+ }
282
+ function Ee(e, t) {
283
+ const r = e.querySelector(".rte-blocks-library-live");
284
+ r && (r.textContent = t);
285
+ }
286
+ function se(e) {
287
+ const t = Re(e);
288
+ if (t)
289
+ try {
290
+ q.set(e, t.cloneRange());
291
+ } catch {
292
+ }
293
+ }
294
+ function Se(e) {
295
+ const t = q.get(e);
296
+ if (!t) return null;
297
+ if (!e.isConnected)
298
+ return q.delete(e), null;
299
+ try {
300
+ const r = t.cloneRange();
301
+ return e.contains(r.commonAncestorContainer) ? r : (q.delete(e), null);
302
+ } catch {
303
+ return q.delete(e), null;
304
+ }
305
+ }
306
+ function Ze(e) {
307
+ const t = Se(e);
308
+ return t ? (He(e, t), !0) : !1;
309
+ }
310
+ function Je(e) {
311
+ if (te.has(e)) return;
312
+ const t = () => {
313
+ const r = window.getSelection();
314
+ if (!r || r.rangeCount === 0) return;
315
+ const o = r.getRangeAt(0);
316
+ e.contains(o.commonAncestorContainer) && se(e);
317
+ };
318
+ e.addEventListener("keyup", t), e.addEventListener("mouseup", t), e.addEventListener("touchend", t), te.set(e, t);
319
+ }
320
+ function Qe(e) {
321
+ const t = te.get(e);
322
+ t && (e.removeEventListener("keyup", t), e.removeEventListener("mouseup", t), e.removeEventListener("touchend", t), te.delete(e));
323
+ }
324
+ function k(e, t) {
325
+ b.has(e) || b.set(e, t), I.has(e) || (I.set(e, t.blocks), O.set(e, Date.now()));
326
+ let r = w.get(e);
327
+ return r || (r = {
328
+ query: "",
329
+ category: t.defaultCategory ? ne(t.defaultCategory) : "all",
330
+ selectedBlockId: null,
331
+ recentBlockIds: [],
332
+ lastInsertedBlockId: null,
333
+ loading: !1,
334
+ loadError: null,
335
+ totalMatches: 0,
336
+ visibleMatches: 0,
337
+ filterCache: /* @__PURE__ */ new Map(),
338
+ debounceTimer: null
339
+ }, w.set(e, r)), oe.add(e), Je(e), r;
340
+ }
341
+ function Me(e) {
342
+ const t = w.get(e);
343
+ !t || t.debounceTimer === null || (window.clearTimeout(t.debounceTimer), t.debounceTimer = null);
344
+ }
345
+ function ge(e) {
346
+ Me(e), Qe(e), q.delete(e);
347
+ const t = W.get(e);
348
+ 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), O.delete(e), oe.delete(e), y === e && (y = null);
349
+ }
350
+ function et(e) {
351
+ for (let t = 0; t < e.length; t += 1) {
352
+ const r = e[t];
353
+ if (!(r.type !== "childList" || r.removedNodes.length === 0))
354
+ for (let o = 0; o < r.removedNodes.length; o += 1) {
355
+ const l = r.removedNodes[o];
356
+ if (l.nodeType !== Node.ELEMENT_NODE) continue;
357
+ const n = l;
358
+ if (n.matches?.(v) || n.matches?.(`.${u}`) || n.querySelector?.(v) || n.querySelector?.(`.${u}`))
359
+ return !0;
360
+ }
361
+ }
362
+ return !1;
363
+ }
364
+ function pe(e) {
365
+ return U.get(e) === !0;
366
+ }
367
+ function de(e, t) {
368
+ if (!t.classList.contains("show")) return;
369
+ 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));
370
+ 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`;
371
+ }
372
+ function ae(e) {
373
+ return I.get(e) || b.get(e)?.blocks || [];
374
+ }
375
+ function tt(e, t) {
376
+ const r = /* @__PURE__ */ new Map();
377
+ ae(e).forEach((l) => {
378
+ r.has(l.categoryKey) || r.set(l.categoryKey, l.category);
379
+ });
380
+ const o = Array.from(r.entries()).sort((l, n) => l[1].localeCompare(n[1])).map(([l, n]) => ({ value: l, label: n }));
381
+ return [{ value: "all", label: t.labels.allCategoriesText }, ...o];
382
+ }
383
+ function Ae(e, t) {
384
+ 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);
385
+ if (s) {
386
+ const d = new Map(o.map((g) => [g.id, g])), f = s.ids.map((g) => d.get(g)).filter(Boolean);
387
+ return r.totalMatches = s.total, r.visibleMatches = f.length, f;
388
+ }
389
+ const i = [];
390
+ let c = 0;
391
+ for (let d = 0; d < o.length; d += 1) {
392
+ const f = o[d];
393
+ n !== "all" && f.categoryKey !== n || l && !f.searchBlob.includes(l) || (c += 1, i.length < t.maxResults && i.push(f));
394
+ }
395
+ if (r.totalMatches = c, r.visibleMatches = i.length, r.filterCache.set(a, {
396
+ ids: i.map((d) => d.id),
397
+ total: c
398
+ }), r.filterCache.size > 80) {
399
+ const d = r.filterCache.keys().next().value;
400
+ typeof d == "string" && r.filterCache.delete(d);
401
+ }
402
+ return i;
403
+ }
404
+ function rt(e, t) {
405
+ const r = w.get(e);
406
+ if (!r) return;
407
+ if (t.length === 0) {
408
+ r.selectedBlockId = null;
409
+ return;
410
+ }
411
+ t.some((l) => l.id === r.selectedBlockId) || (r.selectedBlockId = t[0].id);
412
+ }
413
+ function N(e) {
414
+ const t = w.get(e);
415
+ we(e, "toggleBlocksLibraryPanel", pe(e)), we(e, "insertLastBlockSnippet", !!t?.lastInsertedBlockId);
416
+ }
417
+ function L(e) {
418
+ const t = x.get(e), r = b.get(e) || M, o = w.get(e);
419
+ if (!t || !r || !o) return;
420
+ re(t, e);
421
+ const l = t.querySelector(".rte-blocks-library-title");
422
+ l && (l.textContent = r.labels.panelTitle);
423
+ const n = t.querySelector('[data-action="close"]');
424
+ n && (n.setAttribute("aria-label", r.labels.closeText), n.textContent = "✕");
425
+ const a = t.querySelector(".rte-blocks-library-search-label");
426
+ a && (a.textContent = r.labels.searchLabel);
427
+ const s = t.querySelector('[data-field="query"]');
428
+ s && (s.setAttribute("placeholder", r.labels.searchPlaceholder), s.value !== o.query && (s.value = o.query));
429
+ const i = t.querySelector(".rte-blocks-library-category-label");
430
+ i && (i.textContent = r.labels.categoryLabel);
431
+ const c = t.querySelector('[data-field="category"]');
432
+ if (c) {
433
+ const C = tt(e, r);
434
+ c.innerHTML = C.map((p) => `<option value="${m(p.value)}">${m(p.label)}</option>`).join(""), C.some((p) => p.value === o.category) || (o.category = "all"), c.value = o.category;
435
+ }
436
+ const d = t.querySelector(".rte-blocks-library-helper");
437
+ d && (d.textContent = r.labels.helperText);
438
+ const f = t.querySelector('.rte-blocks-library-list[role="listbox"]');
439
+ f && f.setAttribute("aria-label", r.labels.resultsListLabel);
440
+ const g = t.querySelector(".rte-blocks-library-shortcut");
441
+ g && (g.textContent = r.labels.shortcutText);
442
+ const h = t.querySelector('[data-action="insert-selected"]');
443
+ if (h) {
444
+ h.textContent = r.labels.insertText;
445
+ const C = !Te(e) && !!o.selectedBlockId;
446
+ h.disabled = !C, h.setAttribute("aria-disabled", C ? "false" : "true");
447
+ }
448
+ const R = t.querySelector(".rte-blocks-library-empty"), V = t.querySelector(".rte-blocks-library-list"), H = Ae(e, r);
449
+ rt(e, H);
450
+ const Y = t.querySelector(".rte-blocks-library-status");
451
+ 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) {
452
+ const C = new Set(o.recentBlockIds);
453
+ V.innerHTML = H.map((p) => {
454
+ const ie = o.selectedBlockId === p.id, qe = p.tags.length ? ` • ${p.tags.join(", ")}` : "", _e = C.has(p.id), me = p.previewText.slice(0, 180);
455
+ return `
456
+ <li class="rte-blocks-library-item-wrapper" role="presentation">
457
+ <button
458
+ type="button"
459
+ class="rte-blocks-library-item${ie ? " active" : ""}"
460
+ data-block-id="${m(p.id)}"
461
+ role="option"
462
+ aria-selected="${ie ? "true" : "false"}"
463
+ aria-label="${m(p.label)}"
464
+ tabindex="${ie ? "0" : "-1"}"
465
+ >
466
+ <span class="rte-blocks-library-item-head">
467
+ <span class="rte-blocks-library-item-label">${m(p.label)}</span>
468
+ ${_e ? `<span class="rte-blocks-library-recent-pill">${m(r.labels.recentHeading)}</span>` : ""}
469
+ </span>
470
+ <span class="rte-blocks-library-item-meta">${m(p.category)}${m(qe)}</span>
471
+ ${p.description ? `<span class="rte-blocks-library-item-description">${m(p.description)}</span>` : ""}
472
+ ${me ? `<span class="rte-blocks-library-item-preview">${m(me)}</span>` : ""}
473
+ </button>
474
+ </li>
475
+ `;
476
+ }).join("");
477
+ }
478
+ R && (R.hidden = H.length > 0, R.textContent = r.labels.noResultsText);
479
+ const K = t.querySelector(".rte-blocks-library-last-inserted");
480
+ if (K)
481
+ if (o.lastInsertedBlockId) {
482
+ const C = ae(e).find((p) => p.id === o.lastInsertedBlockId);
483
+ C ? (K.hidden = !1, K.textContent = `${r.labels.lastInsertedPrefix}: ${C.label}`) : K.hidden = !0;
484
+ } else
485
+ K.hidden = !0;
486
+ t.setAttribute("aria-label", r.labels.panelAriaLabel);
487
+ }
488
+ function S(e, t = !1) {
489
+ const r = x.get(e);
490
+ r && (r.classList.remove("show"), U.set(e, !1), N(e), t && (e.focus({ preventScroll: !0 }), Ze(e)));
491
+ }
492
+ function ot(e) {
493
+ e.querySelector(".rte-blocks-library-item.active")?.focus();
494
+ }
495
+ function ve(e, t) {
496
+ const r = b.get(e) || M;
497
+ if (!r) return;
498
+ const o = w.get(e);
499
+ if (!o) return;
500
+ const l = Ae(e, r);
501
+ if (l.length === 0) return;
502
+ const a = (Math.max(
503
+ 0,
504
+ l.findIndex((i) => i.id === o.selectedBlockId)
505
+ ) + t + l.length) % l.length;
506
+ o.selectedBlockId = l[a].id, L(e);
507
+ const s = x.get(e);
508
+ s && ot(s);
509
+ }
510
+ function ue(e) {
511
+ const t = it(e);
512
+ se(e), x.forEach((o, l) => {
513
+ l !== e && S(l, !1);
514
+ }), t.classList.add("show"), U.set(e, !0), L(e), de(e, t), N(e), t.querySelector('[data-field="query"]')?.focus(), be(e, !1);
515
+ }
516
+ function Ie(e, t) {
517
+ const r = pe(e);
518
+ return (typeof t == "boolean" ? t : !r) ? ue(e) : S(e, !1), !0;
519
+ }
520
+ function Re(e) {
521
+ const t = window.getSelection();
522
+ if (!t || t.rangeCount === 0) return null;
523
+ const r = t.getRangeAt(0);
524
+ return e.contains(r.commonAncestorContainer) ? r : null;
525
+ }
526
+ function He(e, t) {
527
+ if (!e.isConnected) return;
528
+ const r = window.getSelection();
529
+ r && (r.removeAllRanges(), r.addRange(t));
530
+ }
531
+ function Le(e, t, r) {
532
+ const o = t.cloneRange();
533
+ if (!e.contains(o.commonAncestorContainer)) return !1;
534
+ o.deleteContents();
535
+ const l = document.createElement("template");
536
+ l.innerHTML = r;
537
+ const n = l.content;
538
+ if (!n) return !1;
539
+ const a = n.lastChild;
540
+ if (o.insertNode(n), a) {
541
+ const s = document.createRange();
542
+ s.setStartAfter(a), s.collapse(!0), He(e, s);
543
+ }
544
+ return se(e), !0;
545
+ }
546
+ function nt(e, t) {
547
+ e.focus({ preventScroll: !0 });
548
+ const r = Se(e);
549
+ if (r && Le(e, r, t))
550
+ return !0;
551
+ try {
552
+ if (document.execCommand("insertHTML", !1, t))
553
+ return se(e), !0;
554
+ } catch {
555
+ }
556
+ const o = Re(e);
557
+ return o ? Le(e, o, t) : !1;
558
+ }
559
+ function lt(e, t) {
560
+ if (t === e.innerHTML) return;
561
+ const r = window.execEditorCommand || window.executeEditorCommand;
562
+ if (typeof r == "function")
563
+ try {
564
+ r("recordDomTransaction", e, t, e.innerHTML);
565
+ } catch {
566
+ }
567
+ }
568
+ function st(e) {
569
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
570
+ }
571
+ function F(e, t) {
572
+ const r = b.get(e) || M;
573
+ if (!r) return !1;
574
+ const o = k(e, r), l = x.get(e);
575
+ if (Te(e))
576
+ return l && Ee(l, r.labels.readonlyMessage), !1;
577
+ const n = ae(e).find((i) => i.id === t);
578
+ if (!n) return !1;
579
+ const a = e.innerHTML;
580
+ return nt(e, n.html) ? (o.lastInsertedBlockId = n.id, o.selectedBlockId = n.id, o.recentBlockIds = [n.id, ...o.recentBlockIds.filter((i) => i !== n.id)].slice(
581
+ 0,
582
+ r.maxRecentBlocks
583
+ ), lt(e, a), st(e), N(e), e.dispatchEvent(
584
+ new CustomEvent("editora:blocks-library-insert", {
585
+ bubbles: !0,
586
+ detail: {
587
+ blockId: n.id,
588
+ label: n.label,
589
+ category: n.category
590
+ }
591
+ })
592
+ ), L(e), l && Ee(l, `${r.labels.lastInsertedPrefix}: ${n.label}`), !0) : !1;
593
+ }
594
+ function ze(e) {
595
+ const t = w.get(e);
596
+ return t?.lastInsertedBlockId ? F(e, t.lastInsertedBlockId) : !1;
597
+ }
598
+ function at(e) {
599
+ const t = b.get(e) || M;
600
+ if (!t) return;
601
+ const r = w.get(e);
602
+ if (!r) return;
603
+ Me(e);
604
+ const o = () => {
605
+ r.debounceTimer = null, r.filterCache.clear(), L(e);
606
+ };
607
+ if (t.debounceMs <= 0) {
608
+ o();
609
+ return;
610
+ }
611
+ r.debounceTimer = window.setTimeout(o, t.debounceMs);
612
+ }
613
+ function it(e) {
614
+ const t = x.get(e);
615
+ if (t) return t;
616
+ const r = b.get(e) || M || Q(), o = k(e, r), l = `rte-blocks-library-panel-${Ne++}`, n = `${l}-query`, a = `${l}-category`, s = document.createElement("section");
617
+ return s.className = u, s.id = l, s.setAttribute("role", "dialog"), s.setAttribute("aria-modal", "false"), s.setAttribute("aria-label", r.labels.panelAriaLabel), s.innerHTML = `
618
+ <header class="rte-blocks-library-header">
619
+ <h2 class="rte-blocks-library-title">${m(r.labels.panelTitle)}</h2>
620
+ <button type="button" class="rte-blocks-library-icon-btn" data-action="close" aria-label="${m(r.labels.closeText)}">✕</button>
621
+ </header>
622
+ <div class="rte-blocks-library-body">
623
+ <label class="rte-blocks-library-search-label" for="${m(n)}"></label>
624
+ <input id="${m(n)}" class="rte-blocks-library-input" type="text" data-field="query" autocomplete="off" />
625
+ <label class="rte-blocks-library-category-label" for="${m(a)}"></label>
626
+ <select id="${m(a)}" class="rte-blocks-library-select" data-field="category"></select>
627
+ <p class="rte-blocks-library-status" aria-live="polite"></p>
628
+ <p class="rte-blocks-library-helper"></p>
629
+ <p class="rte-blocks-library-last-inserted" hidden></p>
630
+ <div class="rte-blocks-library-list-wrap">
631
+ <ul class="rte-blocks-library-list" role="listbox" aria-label="${m(r.labels.resultsListLabel)}"></ul>
632
+ <p class="rte-blocks-library-empty" hidden></p>
633
+ </div>
634
+ <div class="rte-blocks-library-actions">
635
+ <button type="button" class="rte-blocks-library-btn rte-blocks-library-btn-primary" data-action="insert-selected"></button>
636
+ </div>
637
+ <p class="rte-blocks-library-shortcut"></p>
638
+ </div>
639
+ <div class="rte-blocks-library-live" aria-live="polite" aria-atomic="true"></div>
640
+ `, s.addEventListener("click", (i) => {
641
+ const c = i.target, d = c?.closest("[data-action]");
642
+ if (d) {
643
+ const h = d.getAttribute("data-action");
644
+ if (h === "close") {
645
+ S(e, !0);
646
+ return;
647
+ }
648
+ if (h === "insert-selected") {
649
+ if (!o.selectedBlockId) return;
650
+ F(e, o.selectedBlockId) && S(e, !0);
651
+ }
652
+ return;
653
+ }
654
+ const f = c?.closest("[data-block-id]");
655
+ if (!f) return;
656
+ const g = f.getAttribute("data-block-id");
657
+ g && (o.selectedBlockId = g, L(e), i.detail >= 2 && F(e, g) && S(e, !0));
658
+ }), s.addEventListener("input", (i) => {
659
+ const c = i.target;
660
+ !(c instanceof HTMLInputElement) || c.getAttribute("data-field") !== "query" || (o.query = r.normalizeText(c.value).toLowerCase(), o.filterCache.clear(), at(e));
661
+ }), s.addEventListener("change", (i) => {
662
+ const c = i.target;
663
+ !(c instanceof HTMLSelectElement) || c.getAttribute("data-field") !== "category" || (o.category = ne(c.value || "all") || "all", o.filterCache.clear(), L(e));
664
+ }), s.addEventListener("keydown", (i) => {
665
+ if (i.key === "Escape") {
666
+ i.preventDefault(), S(e, !0);
667
+ return;
668
+ }
669
+ if (i.key === "ArrowDown") {
670
+ i.preventDefault(), ve(e, 1);
671
+ return;
672
+ }
673
+ if (i.key === "ArrowUp") {
674
+ i.preventDefault(), ve(e, -1);
675
+ return;
676
+ }
677
+ if (i.key === "Enter") {
678
+ if (!i.target?.matches('[data-field="query"], [data-field="category"], [data-block-id]') || !o.selectedBlockId) return;
679
+ i.preventDefault(), F(e, o.selectedBlockId) && S(e, !0);
680
+ }
681
+ }), re(s, e), document.body.appendChild(s), x.set(e, s), U.set(e, !1), L(e), s;
682
+ }
683
+ function ct(e) {
684
+ const t = w.get(e);
685
+ return {
686
+ query: t?.query || "",
687
+ category: t?.category || "all",
688
+ selectedBlockId: t?.selectedBlockId || null,
689
+ totalMatches: t?.totalMatches || 0,
690
+ visibleMatches: t?.visibleMatches || 0,
691
+ recentBlockIds: t?.recentBlockIds ? [...t.recentBlockIds] : [],
692
+ lastInsertedBlockId: t?.lastInsertedBlockId || null,
693
+ loading: t?.loading === !0,
694
+ loadError: t?.loadError || null
695
+ };
696
+ }
697
+ async function be(e, t) {
698
+ const r = b.get(e) || M;
699
+ if (!r || typeof r.getBlocks != "function") return;
700
+ const o = k(e, r), l = O.get(e) || 0;
701
+ if (!t && r.cacheTtlMs > 0 && Date.now() - l < r.cacheTtlMs)
702
+ return;
703
+ const n = j.get(e);
704
+ if (n && !t)
705
+ return n;
706
+ const a = W.get(e);
707
+ a && a.abort(), t && n && j.delete(e);
708
+ const s = new AbortController();
709
+ W.set(e, s);
710
+ const i = (z.get(e) || 0) + 1;
711
+ z.set(e, i), o.loading = !0, o.loadError = null, L(e);
712
+ const c = Promise.resolve().then(async () => {
713
+ const d = {
714
+ editor: e,
715
+ editorRoot: le(e),
716
+ signal: s.signal
717
+ }, f = await r.getBlocks?.(d);
718
+ if (s.signal.aborted || z.get(e) !== i) return;
719
+ const g = Be(f || [], r);
720
+ I.set(e, g), O.set(e, Date.now());
721
+ const h = w.get(e);
722
+ h && (h.loading = !1, h.loadError = null, h.filterCache.clear());
723
+ }).catch(() => {
724
+ if (s.signal.aborted || z.get(e) !== i) return;
725
+ const d = w.get(e);
726
+ d && (d.loading = !1, d.loadError = r.labels.loadErrorText);
727
+ }).finally(() => {
728
+ z.get(e) === i && (j.delete(e), W.delete(e)), L(e);
729
+ });
730
+ return j.set(e, c), c;
731
+ }
732
+ function dt(e) {
733
+ const t = e.key.toLowerCase();
734
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "b";
735
+ }
736
+ function ut(e) {
737
+ const t = e.key.toLowerCase();
738
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "l";
739
+ }
740
+ function bt(e) {
741
+ M = e, _ || (_ = (t) => {
742
+ ee();
743
+ const o = t.target?.closest(v);
744
+ if (!o) return;
745
+ const l = b.get(o) || e;
746
+ k(o, l), b.set(o, l), y = o, N(o);
747
+ const n = x.get(o);
748
+ n && (re(n, o), de(o, n), L(o));
749
+ }, document.addEventListener("focusin", _, !0)), P || (P = (t) => {
750
+ if (t.defaultPrevented) return;
751
+ const r = `.${u} input, .${u} textarea, .${u} select`, o = t.target;
752
+ if (o?.closest(r)) {
753
+ if (t.key === "Escape") {
754
+ const a = o.closest(`.${u}`), s = Array.from(x.entries()).find(([, i]) => i === a);
755
+ s && (t.preventDefault(), S(s[0], !0));
756
+ }
757
+ return;
758
+ }
759
+ const l = Ye(t);
760
+ if (!l) return;
761
+ const n = b.get(l) || M || e;
762
+ if (k(l, n), b.set(l, n), y = l, t.key === "Escape" && pe(l)) {
763
+ t.preventDefault(), S(l, !0);
764
+ return;
765
+ }
766
+ if (dt(t)) {
767
+ t.preventDefault(), t.stopPropagation(), Ie(l);
768
+ return;
769
+ }
770
+ ut(t) && (t.preventDefault(), t.stopPropagation(), ze(l));
771
+ }, document.addEventListener("keydown", P, !0)), A || (A = () => {
772
+ ee(), x.forEach((t, r) => {
773
+ !r.isConnected || !t.isConnected || (re(t, r), de(r, t));
774
+ });
775
+ }, window.addEventListener("scroll", A, !0), window.addEventListener("resize", A)), !D && typeof MutationObserver < "u" && document.body && (D = new MutationObserver((t) => {
776
+ et(t) && ee();
777
+ }), D.observe(document.body, {
778
+ childList: !0,
779
+ subtree: !0
780
+ }));
781
+ }
782
+ function ft() {
783
+ _ && (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), D && (D.disconnect(), D = null), x.forEach((t) => t.remove()), x.clear(), Array.from(oe).forEach((t) => ge(t)), M = null, y = null;
784
+ }
785
+ function gt() {
786
+ if (typeof document > "u" || document.getElementById(he)) return;
787
+ const e = document.createElement("style");
788
+ e.id = he, e.textContent = `
789
+ .rte-toolbar-group-items.${E},
790
+ .editora-toolbar-group-items.${E},
791
+ .rte-toolbar-group-items.${B},
792
+ .editora-toolbar-group-items.${B} {
793
+ display: flex;
794
+ border: 1px solid #cbd5e1;
795
+ border-radius: 4px;
796
+ background: #ffffff;
797
+ }
798
+
799
+ .rte-toolbar-group-items.${E} .rte-toolbar-button,
800
+ .editora-toolbar-group-items.${E} .editora-toolbar-button,
801
+ .rte-toolbar-group-items.${B} .rte-toolbar-button,
802
+ .editora-toolbar-group-items.${B} .editora-toolbar-button {
803
+ border: none;
804
+ border-right: 1px solid #cbd5e1;
805
+ border-radius: 0;
806
+ }
807
+
808
+ .rte-toolbar-group-items.${E} .rte-toolbar-item:last-child .rte-toolbar-button,
809
+ .editora-toolbar-group-items.${E} .editora-toolbar-item:last-child .editora-toolbar-button,
810
+ .rte-toolbar-group-items.${B} .rte-toolbar-item:last-child .rte-toolbar-button,
811
+ .editora-toolbar-group-items.${B} .editora-toolbar-item:last-child .editora-toolbar-button {
812
+ border-right: none;
813
+ }
814
+
815
+ .rte-toolbar-button[data-command="insertLastBlockSnippet"].active,
816
+ .editora-toolbar-button[data-command="insertLastBlockSnippet"].active {
817
+ background: rgba(15, 118, 110, 0.12);
818
+ }
819
+
820
+ ${$} .rte-toolbar-group-items.${E},
821
+ ${$} .editora-toolbar-group-items.${E},
822
+ ${$} .rte-toolbar-group-items.${B},
823
+ ${$} .editora-toolbar-group-items.${B} {
824
+ border-color: #566275;
825
+ }
826
+ ${$} .rte-toolbar-group-items.${E} .rte-toolbar-button svg,
827
+ ${$} .editora-toolbar-group-items.${E} .editora-toolbar-button svg,
828
+ ${$} .rte-toolbar-group-items.${B} .rte-toolbar-button svg,
829
+ ${$} .editora-toolbar-group-items.${B} .editora-toolbar-button svg
830
+ {
831
+ fill: none;
832
+ }
833
+ ${$} .rte-toolbar-group-items.${E} .rte-toolbar-button,
834
+ ${$} .editora-toolbar-group-items.${E} .editora-toolbar-button
835
+ {
836
+ border-color: #566275;
837
+ }
838
+ .${u} {
839
+ position: fixed;
840
+ z-index: 12000;
841
+ display: none;
842
+ width: min(420px, calc(100vw - 20px));
843
+ max-height: calc(100vh - 20px);
844
+ border: 1px solid #d1d5db;
845
+ border-radius: 14px;
846
+ background: #ffffff;
847
+ color: #0f172a;
848
+ box-shadow: 0 24px 48px rgba(15, 23, 42, 0.24);
849
+ overflow: hidden;
850
+ }
851
+
852
+ .${u}.show {
853
+ display: flex;
854
+ flex-direction: column;
855
+ }
856
+
857
+ .${u}.rte-blocks-library-theme-dark {
858
+ border-color: #334155;
859
+ background: #0f172a;
860
+ color: #e2e8f0;
861
+ box-shadow: 0 24px 52px rgba(2, 6, 23, 0.68);
862
+ }
863
+
864
+ .rte-blocks-library-header {
865
+ display: flex;
866
+ align-items: center;
867
+ justify-content: space-between;
868
+ gap: 8px;
869
+ padding: 12px 14px;
870
+ border-bottom: 1px solid #e2e8f0;
871
+ background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
872
+ }
873
+
874
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-header {
875
+ border-color: #1e293b;
876
+ background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
877
+ }
878
+
879
+ .rte-blocks-library-title {
880
+ margin: 0;
881
+ font-size: 15px;
882
+ line-height: 1.2;
883
+ font-weight: 700;
884
+ }
885
+
886
+ .rte-blocks-library-icon-btn {
887
+ border: 1px solid #cbd5e1;
888
+ border-radius: 6px;
889
+ min-height: 34px;
890
+ min-width: 34px;
891
+ width: 34px;
892
+ height: 34px;
893
+ padding: 0;
894
+ background: #ffffff;
895
+ color: #0f172a;
896
+ font-size: 16px;
897
+ line-height: 1;
898
+ font-weight: 600;
899
+ display: inline-flex;
900
+ align-items: center;
901
+ justify-content: center;
902
+ cursor: pointer;
903
+ }
904
+
905
+ .rte-blocks-library-icon-btn:hover,
906
+ .rte-blocks-library-icon-btn:focus-visible {
907
+ outline: none;
908
+ border-color: #3b82f6;
909
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
910
+ }
911
+
912
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-icon-btn {
913
+ border-color: #475569;
914
+ background: #0f172a;
915
+ color: #e2e8f0;
916
+ }
917
+
918
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-icon-btn:hover,
919
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-icon-btn:focus-visible {
920
+ border-color: #60a5fa;
921
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
922
+ }
923
+
924
+ .rte-blocks-library-body {
925
+ display: flex;
926
+ flex-direction: column;
927
+ gap: 8px;
928
+ padding: 12px;
929
+ overflow: auto;
930
+ }
931
+
932
+ .rte-blocks-library-search-label,
933
+ .rte-blocks-library-category-label {
934
+ font-size: 12px;
935
+ line-height: 1.3;
936
+ font-weight: 700;
937
+ color: #334155;
938
+ }
939
+
940
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-search-label,
941
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-category-label {
942
+ color: #cbd5e1;
943
+ }
944
+
945
+ .rte-blocks-library-input,
946
+ .rte-blocks-library-select {
947
+ border: 1px solid #cbd5e1;
948
+ border-radius: 8px;
949
+ min-height: 34px;
950
+ padding: 0 10px;
951
+ font-size: 13px;
952
+ background: #ffffff;
953
+ color: inherit;
954
+ }
955
+
956
+ .rte-blocks-library-input:focus-visible,
957
+ .rte-blocks-library-select:focus-visible {
958
+ border-color: #0f766e;
959
+ box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
960
+ outline: none;
961
+ }
962
+
963
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-input,
964
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-select {
965
+ border-color: #334155;
966
+ background: #0b1220;
967
+ color: #e2e8f0;
968
+ }
969
+
970
+ .rte-blocks-library-status,
971
+ .rte-blocks-library-helper,
972
+ .rte-blocks-library-shortcut,
973
+ .rte-blocks-library-last-inserted {
974
+ margin: 0;
975
+ font-size: 12px;
976
+ line-height: 1.35;
977
+ color: #475569;
978
+ }
979
+
980
+ .rte-blocks-library-last-inserted {
981
+ font-weight: 600;
982
+ color: #0f766e;
983
+ }
984
+
985
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-status,
986
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-helper,
987
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-shortcut {
988
+ color: #94a3b8;
989
+ }
990
+
991
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-last-inserted {
992
+ color: #5eead4;
993
+ }
994
+
995
+ .rte-blocks-library-list-wrap {
996
+ border: 1px solid #e2e8f0;
997
+ border-radius: 10px;
998
+ padding: 6px;
999
+ background: #f8fafc;
1000
+ max-height: min(44vh, 360px);
1001
+ overflow: auto;
1002
+ }
1003
+
1004
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-list-wrap {
1005
+ border-color: #334155;
1006
+ background: #0b1220;
1007
+ }
1008
+
1009
+ .rte-blocks-library-list {
1010
+ margin: 0;
1011
+ padding: 0;
1012
+ list-style: none;
1013
+ display: grid;
1014
+ gap: 6px;
1015
+ }
1016
+
1017
+ .rte-blocks-library-item-wrapper {
1018
+ margin: 0;
1019
+ padding: 0;
1020
+ }
1021
+
1022
+ .rte-blocks-library-item {
1023
+ width: 100%;
1024
+ border: 1px solid #cbd5e1;
1025
+ border-radius: 8px;
1026
+ background: #ffffff;
1027
+ color: inherit;
1028
+ text-align: left;
1029
+ padding: 8px;
1030
+ display: grid;
1031
+ gap: 3px;
1032
+ cursor: pointer;
1033
+ }
1034
+
1035
+ .rte-blocks-library-item:hover,
1036
+ .rte-blocks-library-item:focus-visible {
1037
+ border-color: #0f766e;
1038
+ outline: none;
1039
+ }
1040
+
1041
+ .rte-blocks-library-item.active {
1042
+ border-color: #0f766e;
1043
+ background: rgba(15, 118, 110, 0.12);
1044
+ }
1045
+
1046
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-item {
1047
+ border-color: #334155;
1048
+ background: #111827;
1049
+ color: #e2e8f0;
1050
+ }
1051
+
1052
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-item.active {
1053
+ border-color: #2dd4bf;
1054
+ background: rgba(45, 212, 191, 0.15);
1055
+ }
1056
+
1057
+ .rte-blocks-library-item-head {
1058
+ display: flex;
1059
+ align-items: center;
1060
+ justify-content: space-between;
1061
+ gap: 8px;
1062
+ }
1063
+
1064
+ .rte-blocks-library-item-label {
1065
+ font-size: 13px;
1066
+ line-height: 1.3;
1067
+ font-weight: 700;
1068
+ }
1069
+
1070
+ .rte-blocks-library-recent-pill {
1071
+ font-size: 10px;
1072
+ line-height: 1;
1073
+ font-weight: 700;
1074
+ text-transform: uppercase;
1075
+ letter-spacing: 0.02em;
1076
+ color: #0f766e;
1077
+ border: 1px solid rgba(15, 118, 110, 0.38);
1078
+ border-radius: 999px;
1079
+ padding: 2px 6px;
1080
+ }
1081
+
1082
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-recent-pill {
1083
+ color: #5eead4;
1084
+ border-color: rgba(94, 234, 212, 0.45);
1085
+ }
1086
+
1087
+ .rte-blocks-library-item-meta,
1088
+ .rte-blocks-library-item-description,
1089
+ .rte-blocks-library-item-preview {
1090
+ font-size: 11px;
1091
+ line-height: 1.3;
1092
+ color: #64748b;
1093
+ }
1094
+
1095
+ .rte-blocks-library-item-preview {
1096
+ color: #334155;
1097
+ display: -webkit-box;
1098
+ -webkit-line-clamp: 2;
1099
+ line-clamp: 2;
1100
+ -webkit-box-orient: vertical;
1101
+ overflow: hidden;
1102
+ }
1103
+
1104
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-item-meta,
1105
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-item-description {
1106
+ color: #94a3b8;
1107
+ }
1108
+
1109
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-item-preview {
1110
+ color: #cbd5e1;
1111
+ }
1112
+
1113
+ .rte-blocks-library-empty {
1114
+ margin: 8px;
1115
+ font-size: 12px;
1116
+ color: #64748b;
1117
+ }
1118
+
1119
+ .rte-blocks-library-actions {
1120
+ display: flex;
1121
+ gap: 8px;
1122
+ }
1123
+
1124
+ .rte-blocks-library-btn {
1125
+ border: 1px solid #cbd5e1;
1126
+ border-radius: 8px;
1127
+ min-height: 34px;
1128
+ padding: 0 12px;
1129
+ background: #ffffff;
1130
+ color: inherit;
1131
+ font-size: 12px;
1132
+ font-weight: 700;
1133
+ cursor: pointer;
1134
+ }
1135
+
1136
+ .rte-blocks-library-btn:disabled {
1137
+ opacity: 0.6;
1138
+ cursor: not-allowed;
1139
+ }
1140
+
1141
+ .rte-blocks-library-btn-primary {
1142
+ border-color: #0f766e;
1143
+ background: #0f766e;
1144
+ color: #f8fafc;
1145
+ }
1146
+
1147
+ .rte-blocks-library-btn-primary:hover,
1148
+ .rte-blocks-library-btn-primary:focus-visible {
1149
+ border-color: #115e59;
1150
+ background: #115e59;
1151
+ outline: none;
1152
+ }
1153
+
1154
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-btn {
1155
+ border-color: #334155;
1156
+ background: #111827;
1157
+ color: #e2e8f0;
1158
+ }
1159
+
1160
+ .${u}.rte-blocks-library-theme-dark .rte-blocks-library-btn-primary {
1161
+ border-color: #14b8a6;
1162
+ background: #0f766e;
1163
+ color: #f0fdfa;
1164
+ }
1165
+
1166
+ .rte-blocks-library-live {
1167
+ position: absolute;
1168
+ width: 1px;
1169
+ height: 1px;
1170
+ margin: -1px;
1171
+ padding: 0;
1172
+ overflow: hidden;
1173
+ clip: rect(0 0 0 0);
1174
+ border: 0;
1175
+ }
1176
+
1177
+ @media (max-width: 768px) {
1178
+ .${u} {
1179
+ left: 10px !important;
1180
+ right: 10px;
1181
+ top: 10px !important;
1182
+ width: auto !important;
1183
+ max-height: calc(100vh - 20px);
1184
+ }
1185
+ }
1186
+ `, document.head.appendChild(e);
1187
+ }
1188
+ const pt = (e = {}) => {
1189
+ const t = Q(e), r = /* @__PURE__ */ new Set();
1190
+ return gt(), {
1191
+ name: "blocksLibrary",
1192
+ toolbar: [
1193
+ {
1194
+ id: "blocksLibraryGroup",
1195
+ label: "Blocks Library",
1196
+ type: "group",
1197
+ command: "blocksLibrary",
1198
+ items: [
1199
+ {
1200
+ id: "blocksLibraryPanel",
1201
+ label: "Blocks Library Panel",
1202
+ command: "toggleBlocksLibraryPanel",
1203
+ shortcut: "Mod-Alt-Shift-b",
1204
+ 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>'
1205
+ },
1206
+ {
1207
+ id: "insertLastBlockSnippet",
1208
+ label: "Insert Last Block",
1209
+ command: "insertLastBlockSnippet",
1210
+ shortcut: "Mod-Alt-Shift-l",
1211
+ 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>'
1212
+ }
1213
+ ]
1214
+ }
1215
+ ],
1216
+ commands: {
1217
+ blocksLibrary: (o, l) => {
1218
+ const n = T(l, !1, !1);
1219
+ if (!n) return !1;
1220
+ const a = b.get(n) || t;
1221
+ return k(n, a), b.set(n, a), y = n, ue(n), !0;
1222
+ },
1223
+ openBlocksLibraryPanel: (o, l) => {
1224
+ const n = T(l, !1, !1);
1225
+ if (!n) return !1;
1226
+ const a = b.get(n) || t;
1227
+ return k(n, a), b.set(n, a), y = n, ue(n), !0;
1228
+ },
1229
+ toggleBlocksLibraryPanel: (o, l) => {
1230
+ const n = T(l, !1, !1);
1231
+ if (!n) return !1;
1232
+ const a = b.get(n) || t;
1233
+ return k(n, a), b.set(n, a), y = n, Ie(n, typeof o == "boolean" ? o : void 0);
1234
+ },
1235
+ insertBlockSnippet: (o, l) => {
1236
+ const n = T(l, !1, !1);
1237
+ if (!n) return !1;
1238
+ const a = b.get(n) || t;
1239
+ k(n, a), b.set(n, a);
1240
+ const s = typeof o == "string" ? o : o?.id;
1241
+ return s ? (y = n, F(n, s)) : !1;
1242
+ },
1243
+ insertLastBlockSnippet: (o, l) => {
1244
+ const n = T(l, !1, !1);
1245
+ if (!n) return !1;
1246
+ const a = b.get(n) || t;
1247
+ return k(n, a), b.set(n, a), y = n, ze(n);
1248
+ },
1249
+ refreshBlocksLibraryData: (o, l) => {
1250
+ const n = T(l, !1, !1);
1251
+ if (!n) return !1;
1252
+ const a = b.get(n) || t;
1253
+ return k(n, a), b.set(n, a), be(n, !0), !0;
1254
+ },
1255
+ setBlocksLibraryOptions: (o, l) => {
1256
+ const n = T(l, !1, !1);
1257
+ if (!n || !o || typeof o != "object") return !1;
1258
+ const a = b.get(n) || t, s = J.get(n) || Ge(a), i = {
1259
+ ...s,
1260
+ ...o,
1261
+ labels: {
1262
+ ...s.labels || {},
1263
+ ...o.labels || {}
1264
+ },
1265
+ blocks: Array.isArray(o.blocks) ? o.blocks : s.blocks,
1266
+ normalizeText: o.normalizeText || a.normalizeText,
1267
+ sanitizeBlockHtml: o.sanitizeBlockHtml || a.sanitizeBlockHtml,
1268
+ getBlocks: o.getBlocks || a.getBlocks
1269
+ }, c = Q(i), d = Array.isArray(o.blocks), f = o.getBlocks !== void 0;
1270
+ b.set(n, c), J.set(n, i), (d || f || !I.has(n)) && (I.set(n, c.blocks), O.set(n, f ? 0 : Date.now()));
1271
+ const g = k(n, c);
1272
+ return g.filterCache.clear(), typeof o.defaultCategory == "string" && (g.category = ne(c.defaultCategory) || "all"), L(n), N(n), f && be(n, !0), !0;
1273
+ },
1274
+ getBlocksLibraryState: (o, l) => {
1275
+ const n = T(l, !1, !1);
1276
+ if (!n) return !1;
1277
+ const a = b.get(n) || t;
1278
+ k(n, a);
1279
+ const s = ct(n);
1280
+ if (typeof o == "function")
1281
+ try {
1282
+ o(s);
1283
+ } catch {
1284
+ }
1285
+ return n.__blocksLibraryState = s, n.dispatchEvent(
1286
+ new CustomEvent("editora:blocks-library-state", {
1287
+ bubbles: !0,
1288
+ detail: s
1289
+ })
1290
+ ), !0;
1291
+ }
1292
+ },
1293
+ keymap: {
1294
+ "Mod-Alt-Shift-b": "toggleBlocksLibraryPanel",
1295
+ "Mod-Alt-Shift-B": "toggleBlocksLibraryPanel",
1296
+ "Mod-Alt-Shift-l": "insertLastBlockSnippet",
1297
+ "Mod-Alt-Shift-L": "insertLastBlockSnippet"
1298
+ },
1299
+ init: function(l) {
1300
+ X += 1;
1301
+ const n = this && typeof this.__pluginConfig == "object" ? { ...e, ...this.__pluginConfig } : e, a = Q(n);
1302
+ bt(a);
1303
+ const s = T(
1304
+ l?.editorElement ? { editorElement: l.editorElement } : void 0,
1305
+ !1,
1306
+ !1
1307
+ );
1308
+ s && (y = s, r.add(s), k(s, a), b.set(s, a), J.set(s, n), I.set(s, a.blocks), O.set(s, Date.now()), N(s));
1309
+ },
1310
+ destroy: () => {
1311
+ r.forEach((o) => ge(o)), r.clear(), X = Math.max(0, X - 1), !(X > 0) && ft();
1312
+ }
1313
+ };
1314
+ };
1315
+ export {
1316
+ pt as BlocksLibraryPlugin
1317
+ };