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