@editora/plugins 1.0.8 → 1.0.10

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