@editora/core 1.0.15 → 1.0.16

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 (68) hide show
  1. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-DIKuCeFw.mjs} +82 -79
  2. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-DXZdK3zr.mjs} +72 -71
  3. package/dist/{ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs → ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs} +239 -238
  4. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-H3XyYD7_.mjs} +2 -2
  5. package/dist/{BlocksLibraryPlugin.native-5sdsXsiE.mjs → BlocksLibraryPlugin.native-CownM6Rk.mjs} +140 -116
  6. package/dist/{CapitalizationPlugin.native-DLV4oPmB.mjs → CapitalizationPlugin.native-C-HRbXGh.mjs} +10 -5
  7. package/dist/{ChecklistPlugin.native-BS-kMz9O.mjs → ChecklistPlugin.native-NVrBUkaL.mjs} +141 -103
  8. package/dist/{CitationsPlugin.native-DQgoCd1B.mjs → CitationsPlugin.native-C_7wWQ-k.mjs} +441 -422
  9. package/dist/{ClearFormattingPlugin.native-B6ro3a1h.mjs → ClearFormattingPlugin.native-Pp0O-SBf.mjs} +24 -23
  10. package/dist/{CodePlugin.native-knhM8NNo.mjs → CodePlugin.native-BH-K4xmW.mjs} +474 -342
  11. package/dist/CodePlugin.native-hNgfXlfS.mjs +4767 -0
  12. package/dist/CodeSamplePlugin.native-svbAFWh_.mjs +501 -0
  13. package/dist/CollaborationPlugin.native-oSybCGPW.mjs +7468 -0
  14. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-CLip9wAO.mjs} +233 -185
  15. package/dist/{ConditionalContentPlugin.native-CfhY46rU.mjs → ConditionalContentPlugin.native-Bf7XgRSW.mjs} +401 -351
  16. package/dist/{DataBindingPlugin.native-BoXwghTz.mjs → DataBindingPlugin.native-B7lpI_0c.mjs} +29 -28
  17. package/dist/{DocumentManagerPlugin.native-D1YHQ2NN.mjs → DocumentManagerPlugin.native-iFip6s4Q.mjs} +94 -45
  18. package/dist/{EmbedIframePlugin.native-BF_-LjTq.mjs → EmbedIframePlugin.native-BfZ_HGlV.mjs} +231 -186
  19. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-D92aaOKi.mjs} +288 -76
  20. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-M3cNQ0KA.mjs} +57 -50
  21. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-DsLrH8eq.mjs} +41 -34
  22. package/dist/{FormatPainterPlugin.native-CsMrKfFU.mjs → FormatPainterPlugin.native-BhjzsiVq.mjs} +3 -2
  23. package/dist/{HistoryPlugin.native-D2wl32jV.mjs → HistoryPlugin.native-DPvhks6h.mjs} +36 -32
  24. package/dist/LinkPlugin.native-BsQXYsK6.mjs +352 -0
  25. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-Bt0LANbO.mjs} +68 -35
  26. package/dist/{MathPlugin.native-NwWPHVmj.mjs → MathPlugin.native-Byo3WL0f.mjs} +211 -115
  27. package/dist/{MediaManagerPlugin.native-eOsTJFpw.mjs → MediaManagerPlugin.native-BT1NZIJS.mjs} +139 -134
  28. package/dist/{MentionPlugin.native-BMDlOqur.mjs → MentionPlugin.native-S_lwGZQO.mjs} +23 -18
  29. package/dist/{MergeTagPlugin.native-BzRVoD9-.mjs → MergeTagPlugin.native-7-6F3S1Y.mjs} +44 -43
  30. package/dist/{PreviewPlugin.native-WuIwOAOR.mjs → PreviewPlugin.native-CiR51jql.mjs} +31 -28
  31. package/dist/{SlashCommandsPlugin.native-BiN6ODw5.mjs → SlashCommandsPlugin.native-BDIIwGNs.mjs} +90 -79
  32. package/dist/{SmartPastePlugin.native-CZAEHkyt.mjs → SmartPastePlugin.native-BATLCds5.mjs} +89 -85
  33. package/dist/{SpecialCharactersPlugin.native-DaG4b19I.mjs → SpecialCharactersPlugin.native-CdZoc1GB.mjs} +73 -26
  34. package/dist/SpellCheckPlugin.native-Bef2oTLB.mjs +10935 -0
  35. package/dist/TablePlugin.native-BjIxYZ2X.mjs +772 -0
  36. package/dist/{TemplatePlugin.native-DLjFUaPW.mjs → TemplatePlugin.native-D6n5RUnC.mjs} +288 -262
  37. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-KMZ2uzlq.mjs} +2 -2
  38. package/dist/{TranslationWorkflowPlugin.native-DdF16tgT.mjs → TranslationWorkflowPlugin.native-CZtG--06.mjs} +67 -65
  39. package/dist/{VersionDiffPlugin.native-Bvxgy--t.mjs → VersionDiffPlugin.native-Ca1fMWUJ.mjs} +42 -42
  40. package/dist/anchoredPopover-DJFD2oAP.mjs +116 -0
  41. package/dist/core.css +1 -1
  42. package/dist/dialogHelpers-DBf7WqYH.mjs +40 -0
  43. package/dist/editora.min.js +26 -24
  44. package/dist/editora.umd.js +26 -24
  45. package/dist/escapeHtml-CX8RelZ1.mjs +7 -0
  46. package/dist/historyHelpers-B0-4mq1E.mjs +15 -0
  47. package/dist/index-B1_vtXRz.mjs +3910 -0
  48. package/dist/index-C6BoNR2t.js +12 -0
  49. package/dist/index.cjs.js +3 -3
  50. package/dist/index.esm.js +17 -14
  51. package/dist/plugin-loader.js +53 -52
  52. package/dist/webcomponent-core.js +2039 -473
  53. package/dist/webcomponent-core.min.css +1 -1
  54. package/dist/webcomponent-core.min.js +96 -66
  55. package/dist/webcomponent.cjs.js +1 -1
  56. package/dist/webcomponent.esm.js +1 -1
  57. package/dist/webcomponent.js +2208 -641
  58. package/dist/webcomponent.min.css +1 -1
  59. package/dist/webcomponent.min.js +1564 -1198
  60. package/index.d.ts +32 -0
  61. package/package.json +10 -3
  62. package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +0 -384
  63. package/dist/LinkPlugin.native-DYCIcdTm.mjs +0 -283
  64. package/dist/SpellCheckPlugin.native-BZB9AewP.mjs +0 -1039
  65. package/dist/TablePlugin.native-DrHX-efe.mjs +0 -495
  66. package/dist/anchoredPopover-Bxds0VoB.mjs +0 -110
  67. package/dist/index-BLm1MtzH.js +0 -10
  68. package/dist/index-Cd9jEuZP.mjs +0 -2341
@@ -1,5 +1,5 @@
1
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 Be = /* @__PURE__ */ new Set(["script", "style", "meta", "link", "object", "embed", "iframe"]), De = /^(https?:|mailto:|tel:|#|\/)/i, Oe = /^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i, Ke = {
2
+ const Be = /* @__PURE__ */ new Set(["script", "style", "meta", "link", "object", "embed", "iframe"]), Oe = /^(https?:|mailto:|tel:|#|\/)/i, Ne = /^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i, Ke = {
3
3
  panelTitle: "Blocks Library",
4
4
  panelAriaLabel: "Blocks library panel",
5
5
  searchLabel: "Search blocks",
@@ -19,19 +19,19 @@ const Be = /* @__PURE__ */ new Set(["script", "style", "meta", "link", "object",
19
19
  lastInsertedPrefix: "Last inserted",
20
20
  resultsListLabel: "Block results"
21
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;
22
+ let X = 0, je = 0, ke = 0, A = null, y = null, _ = null, P = null, I = null, D = null;
23
23
  function m(e) {
24
24
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
25
25
  }
26
- function je(e) {
26
+ function We(e) {
27
27
  return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
28
28
  }
29
- function We(e) {
29
+ function Fe(e) {
30
30
  return e.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
31
31
  }
32
32
  function ce(e) {
33
33
  const t = e.trim();
34
- return t && (De.test(t) || Oe.test(t)) ? t : "";
34
+ return t && (Oe.test(t) || Ne.test(t)) ? t : "";
35
35
  }
36
36
  function xe(e) {
37
37
  let t = e;
@@ -60,7 +60,7 @@ function xe(e) {
60
60
  return ` style=${s}${a}${s}`;
61
61
  }).trim(), t;
62
62
  }
63
- function Fe(e) {
63
+ function Ge(e) {
64
64
  if (!e) return "";
65
65
  if (typeof document == "undefined")
66
66
  return xe(e);
@@ -97,7 +97,7 @@ function Fe(e) {
97
97
  function ne(e) {
98
98
  return e.trim().toLowerCase();
99
99
  }
100
- function Ge(e) {
100
+ function Ue(e) {
101
101
  if (!e) return "";
102
102
  if (typeof document == "undefined")
103
103
  return e.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
@@ -106,18 +106,18 @@ function Ge(e) {
106
106
  const r = t.content;
107
107
  return !r || typeof r.textContent != "string" ? e.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim() : r.textContent.replace(/\s+/g, " ").trim();
108
108
  }
109
- function Ce(e, t) {
109
+ function $e(e, t) {
110
110
  if (!Array.isArray(e) || e.length === 0) return [];
111
111
  const r = /* @__PURE__ */ new Set(), o = [];
112
112
  return e.forEach((l) => {
113
113
  const n = t.normalizeText(l.label || ""), a = t.sanitizeBlockHtml(l.html || "", l).trim();
114
114
  if (!n || !a) return;
115
115
  const s = t.normalizeText(l.category || "General") || "General", i = ne(s);
116
- let d = We(t.normalizeText(l.id || n)) || `block-${ke++}`;
116
+ let d = Fe(t.normalizeText(l.id || n)) || `block-${ke++}`;
117
117
  for (; r.has(d); )
118
118
  d = `${d}-${ke++}`;
119
119
  r.add(d);
120
- const f = (l.tags || []).map((H) => t.normalizeText(H)).filter(Boolean), g = (l.keywords || []).map((H) => t.normalizeText(H)).filter(Boolean), h = t.normalizeText(l.description || ""), B = Ge(a), V = [n, h, s, ...f, ...g, B].join(" ").toLowerCase();
120
+ const f = (l.tags || []).map((H) => t.normalizeText(H)).filter(Boolean), g = (l.keywords || []).map((H) => t.normalizeText(H)).filter(Boolean), h = t.normalizeText(l.description || ""), C = Ue(a), V = [n, h, s, ...f, ...g, C].join(" ").toLowerCase();
121
121
  o.push({
122
122
  id: d,
123
123
  label: n,
@@ -127,14 +127,14 @@ function Ce(e, t) {
127
127
  categoryKey: i,
128
128
  tags: f,
129
129
  keywords: g,
130
- previewText: B,
130
+ previewText: C,
131
131
  searchBlob: V
132
132
  });
133
133
  }), o;
134
134
  }
135
135
  function Q(e = {}) {
136
136
  var l, n, a, s;
137
- const t = e.normalizeText || je, r = e.sanitizeBlockHtml || Fe, o = {
137
+ const t = e.normalizeText || We, r = e.sanitizeBlockHtml || Ge, o = {
138
138
  blocks: [],
139
139
  defaultCategory: t(e.defaultCategory || ""),
140
140
  maxResults: Math.max(4, Math.min(300, Number((l = e.maxResults) != null ? l : 80))),
@@ -149,9 +149,9 @@ function Q(e = {}) {
149
149
  sanitizeBlockHtml: r,
150
150
  getBlocks: typeof e.getBlocks == "function" ? e.getBlocks : void 0
151
151
  };
152
- return o.blocks = Ce(e.blocks, o), o;
152
+ return o.blocks = $e(e.blocks, o), o;
153
153
  }
154
- function Ue(e) {
154
+ function Ve(e) {
155
155
  return {
156
156
  blocks: e.blocks.map((t) => ({
157
157
  id: t.id,
@@ -182,7 +182,7 @@ function G(e) {
182
182
  const t = e.querySelector(L);
183
183
  return t instanceof HTMLElement ? t : null;
184
184
  }
185
- function Ve() {
185
+ function Ye() {
186
186
  if (typeof window == "undefined") return null;
187
187
  const e = window[ye];
188
188
  if (!(e instanceof HTMLElement)) return null;
@@ -197,7 +197,7 @@ function Ve() {
197
197
  const o = e.closest(L);
198
198
  return o instanceof HTMLElement ? o : null;
199
199
  }
200
- function Ye(e) {
200
+ function Xe(e) {
201
201
  const t = e.closest("[data-editora-editor]");
202
202
  if (t && G(t) === e)
203
203
  return t;
@@ -209,7 +209,7 @@ function Ye(e) {
209
209
  }
210
210
  return le(e);
211
211
  }
212
- function $e(e) {
212
+ function Te(e) {
213
213
  return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
214
214
  }
215
215
  function ee() {
@@ -223,11 +223,11 @@ function S(e, t = !0, r = !0) {
223
223
  const a = G(e.editorElement);
224
224
  if (a) return a;
225
225
  }
226
- const o = Ve();
226
+ const o = Ye();
227
227
  if (o) return o;
228
228
  const l = window.getSelection();
229
229
  if (l && l.rangeCount > 0) {
230
- const a = $e(l.getRangeAt(0).startContainer), s = a == null ? void 0 : a.closest(L);
230
+ const a = Te(l.getRangeAt(0).startContainer), s = a == null ? void 0 : a.closest(L);
231
231
  if (s) return s;
232
232
  }
233
233
  const n = document.activeElement;
@@ -242,7 +242,7 @@ function S(e, t = !0, r = !0) {
242
242
  }
243
243
  return t ? document.querySelector(L) : null;
244
244
  }
245
- function Xe(e) {
245
+ function Ze(e) {
246
246
  const t = e.target;
247
247
  if (t) {
248
248
  const o = t.closest(L);
@@ -250,7 +250,7 @@ function Xe(e) {
250
250
  }
251
251
  const r = window.getSelection();
252
252
  if (r && r.rangeCount > 0) {
253
- const o = $e(r.getRangeAt(0).startContainer), l = o == null ? void 0 : o.closest(L);
253
+ const o = Te(r.getRangeAt(0).startContainer), l = o == null ? void 0 : o.closest(L);
254
254
  if (l) return l;
255
255
  }
256
256
  return null;
@@ -258,20 +258,20 @@ function Xe(e) {
258
258
  function Z(e) {
259
259
  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;
260
260
  }
261
- function Ze(e) {
261
+ function Je(e) {
262
262
  const t = le(e);
263
263
  if (Z(t)) return !0;
264
264
  const r = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
265
265
  return Z(r) ? !0 : Z(document.documentElement) || Z(document.body);
266
266
  }
267
267
  function re(e, t) {
268
- e.classList.remove("rte-blocks-library-theme-dark"), Ze(t) && e.classList.add("rte-blocks-library-theme-dark");
268
+ e.classList.remove("rte-blocks-library-theme-dark"), Je(t) && e.classList.add("rte-blocks-library-theme-dark");
269
269
  }
270
- function Te(e) {
270
+ function Se(e) {
271
271
  return e.getAttribute("contenteditable") === "false" || e.getAttribute("data-readonly") === "true";
272
272
  }
273
273
  function we(e, t, r) {
274
- const o = Ye(e);
274
+ const o = Xe(e);
275
275
  Array.from(
276
276
  o.querySelectorAll(
277
277
  `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
@@ -285,14 +285,14 @@ function Ee(e, t) {
285
285
  r && (r.textContent = t);
286
286
  }
287
287
  function se(e) {
288
- const t = Re(e);
288
+ const t = He(e);
289
289
  if (t)
290
290
  try {
291
291
  q.set(e, t.cloneRange());
292
292
  } catch (r) {
293
293
  }
294
294
  }
295
- function Se(e) {
295
+ function Me(e) {
296
296
  const t = q.get(e);
297
297
  if (!t) return null;
298
298
  if (!e.isConnected)
@@ -304,11 +304,11 @@ function Se(e) {
304
304
  return q.delete(e), null;
305
305
  }
306
306
  }
307
- function Je(e) {
308
- const t = Se(e);
309
- return t ? (He(e, t), !0) : !1;
310
- }
311
307
  function Qe(e) {
308
+ const t = Me(e);
309
+ return t ? (ze(e, t), !0) : !1;
310
+ }
311
+ function et(e) {
312
312
  if (te.has(e)) return;
313
313
  const t = () => {
314
314
  const r = window.getSelection();
@@ -318,7 +318,7 @@ function Qe(e) {
318
318
  };
319
319
  e.addEventListener("keyup", t), e.addEventListener("mouseup", t), e.addEventListener("touchend", t), te.set(e, t);
320
320
  }
321
- function et(e) {
321
+ function tt(e) {
322
322
  const t = te.get(e);
323
323
  t && (e.removeEventListener("keyup", t), e.removeEventListener("mouseup", t), e.removeEventListener("touchend", t), te.delete(e));
324
324
  }
@@ -337,19 +337,19 @@ function k(e, t) {
337
337
  visibleMatches: 0,
338
338
  filterCache: /* @__PURE__ */ new Map(),
339
339
  debounceTimer: null
340
- }, w.set(e, r)), oe.add(e), Qe(e), r;
340
+ }, w.set(e, r)), oe.add(e), et(e), r;
341
341
  }
342
- function Me(e) {
342
+ function Ae(e) {
343
343
  const t = w.get(e);
344
344
  !t || t.debounceTimer === null || (window.clearTimeout(t.debounceTimer), t.debounceTimer = null);
345
345
  }
346
346
  function ge(e) {
347
347
  var r;
348
- Me(e), et(e), q.delete(e);
348
+ Ae(e), tt(e), q.delete(e);
349
349
  const t = W.get(e);
350
350
  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);
351
351
  }
352
- function tt(e) {
352
+ function rt(e) {
353
353
  var t, r, o, l;
354
354
  for (let n = 0; n < e.length; n += 1) {
355
355
  const a = e[n];
@@ -376,7 +376,7 @@ function ae(e) {
376
376
  var t;
377
377
  return R.get(e) || ((t = b.get(e)) == null ? void 0 : t.blocks) || [];
378
378
  }
379
- function rt(e, t) {
379
+ function ot(e, t) {
380
380
  const r = /* @__PURE__ */ new Map();
381
381
  ae(e).forEach((l) => {
382
382
  r.has(l.categoryKey) || r.set(l.categoryKey, l.category);
@@ -384,7 +384,7 @@ function rt(e, t) {
384
384
  const o = Array.from(r.entries()).sort((l, n) => l[1].localeCompare(n[1])).map(([l, n]) => ({ value: l, label: n }));
385
385
  return [{ value: "all", label: t.labels.allCategoriesText }, ...o];
386
386
  }
387
- function Ae(e, t) {
387
+ function Ie(e, t) {
388
388
  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);
389
389
  if (s) {
390
390
  const d = new Map(o.map((g) => [g.id, g])), f = s.ids.map((g) => d.get(g)).filter(Boolean);
@@ -405,7 +405,7 @@ function Ae(e, t) {
405
405
  }
406
406
  return i;
407
407
  }
408
- function ot(e, t) {
408
+ function nt(e, t) {
409
409
  const r = w.get(e);
410
410
  if (!r) return;
411
411
  if (t.length === 0) {
@@ -414,7 +414,7 @@ function ot(e, t) {
414
414
  }
415
415
  t.some((l) => l.id === r.selectedBlockId) || (r.selectedBlockId = t[0].id);
416
416
  }
417
- function K(e) {
417
+ function N(e) {
418
418
  const t = w.get(e);
419
419
  we(e, "toggleBlocksLibraryPanel", pe(e)), we(e, "insertLastBlockSnippet", !!(t != null && t.lastInsertedBlockId));
420
420
  }
@@ -434,8 +434,8 @@ function v(e) {
434
434
  i && (i.textContent = r.labels.categoryLabel);
435
435
  const c = t.querySelector('[data-field="category"]');
436
436
  if (c) {
437
- const C = rt(e, r);
438
- c.innerHTML = C.map((p) => `<option value="${m(p.value)}">${m(p.label)}</option>`).join(""), C.some((p) => p.value === o.category) || (o.category = "all"), c.value = o.category;
437
+ const B = ot(e, r);
438
+ 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;
439
439
  }
440
440
  const d = t.querySelector(".rte-blocks-library-helper");
441
441
  d && (d.textContent = r.labels.helperText);
@@ -446,16 +446,16 @@ function v(e) {
446
446
  const h = t.querySelector('[data-action="insert-selected"]');
447
447
  if (h) {
448
448
  h.textContent = r.labels.insertText;
449
- const C = !Te(e) && !!o.selectedBlockId;
450
- h.disabled = !C, h.setAttribute("aria-disabled", C ? "false" : "true");
449
+ const B = !Se(e) && !!o.selectedBlockId;
450
+ h.disabled = !B, h.setAttribute("aria-disabled", B ? "false" : "true");
451
451
  }
452
- const B = t.querySelector(".rte-blocks-library-empty"), V = t.querySelector(".rte-blocks-library-list"), H = Ae(e, r);
453
- ot(e, H);
452
+ const C = t.querySelector(".rte-blocks-library-empty"), V = t.querySelector(".rte-blocks-library-list"), H = Ie(e, r);
453
+ nt(e, H);
454
454
  const Y = t.querySelector(".rte-blocks-library-status");
455
455
  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) {
456
- const C = new Set(o.recentBlockIds);
456
+ const B = new Set(o.recentBlockIds);
457
457
  V.innerHTML = H.map((p) => {
458
- const ie = o.selectedBlockId === p.id, _e = p.tags.length ? ` • ${p.tags.join(", ")}` : "", Pe = C.has(p.id), me = p.previewText.slice(0, 180);
458
+ const ie = o.selectedBlockId === p.id, Pe = p.tags.length ? ` • ${p.tags.join(", ")}` : "", De = B.has(p.id), me = p.previewText.slice(0, 180);
459
459
  return `
460
460
  <li class="rte-blocks-library-item-wrapper" role="presentation">
461
461
  <button
@@ -469,9 +469,9 @@ function v(e) {
469
469
  >
470
470
  <span class="rte-blocks-library-item-head">
471
471
  <span class="rte-blocks-library-item-label">${m(p.label)}</span>
472
- ${Pe ? `<span class="rte-blocks-library-recent-pill">${m(r.labels.recentHeading)}</span>` : ""}
472
+ ${De ? `<span class="rte-blocks-library-recent-pill">${m(r.labels.recentHeading)}</span>` : ""}
473
473
  </span>
474
- <span class="rte-blocks-library-item-meta">${m(p.category)}${m(_e)}</span>
474
+ <span class="rte-blocks-library-item-meta">${m(p.category)}${m(Pe)}</span>
475
475
  ${p.description ? `<span class="rte-blocks-library-item-description">${m(p.description)}</span>` : ""}
476
476
  ${me ? `<span class="rte-blocks-library-item-preview">${m(me)}</span>` : ""}
477
477
  </button>
@@ -479,21 +479,21 @@ function v(e) {
479
479
  `;
480
480
  }).join("");
481
481
  }
482
- B && (B.hidden = H.length > 0, B.textContent = r.labels.noResultsText);
483
- const N = t.querySelector(".rte-blocks-library-last-inserted");
484
- if (N)
482
+ C && (C.hidden = H.length > 0, C.textContent = r.labels.noResultsText);
483
+ const K = t.querySelector(".rte-blocks-library-last-inserted");
484
+ if (K)
485
485
  if (o.lastInsertedBlockId) {
486
- const C = ae(e).find((p) => p.id === o.lastInsertedBlockId);
487
- C ? (N.hidden = !1, N.textContent = `${r.labels.lastInsertedPrefix}: ${C.label}`) : N.hidden = !0;
486
+ const B = ae(e).find((p) => p.id === o.lastInsertedBlockId);
487
+ B ? (K.hidden = !1, K.textContent = `${r.labels.lastInsertedPrefix}: ${B.label}`) : K.hidden = !0;
488
488
  } else
489
- N.hidden = !0;
489
+ K.hidden = !0;
490
490
  t.setAttribute("aria-label", r.labels.panelAriaLabel);
491
491
  }
492
492
  function M(e, t = !1) {
493
493
  const r = x.get(e);
494
- r && (r.classList.remove("show"), U.set(e, !1), K(e), t && (e.focus({ preventScroll: !0 }), Je(e)));
494
+ r && (r.classList.remove("show"), U.set(e, !1), N(e), t && (e.focus({ preventScroll: !0 }), Qe(e)));
495
495
  }
496
- function nt(e) {
496
+ function lt(e) {
497
497
  const t = e.querySelector(".rte-blocks-library-item.active");
498
498
  t == null || t.focus();
499
499
  }
@@ -502,7 +502,7 @@ function Le(e, t) {
502
502
  if (!r) return;
503
503
  const o = w.get(e);
504
504
  if (!o) return;
505
- const l = Ae(e, r);
505
+ const l = Ie(e, r);
506
506
  if (l.length === 0) return;
507
507
  const a = (Math.max(
508
508
  0,
@@ -510,32 +510,56 @@ function Le(e, t) {
510
510
  ) + t + l.length) % l.length;
511
511
  o.selectedBlockId = l[a].id, v(e);
512
512
  const s = x.get(e);
513
- s && nt(s);
513
+ s && lt(s);
514
514
  }
515
515
  function ue(e) {
516
- const t = ct(e);
516
+ const t = ut(e);
517
517
  se(e), x.forEach((o, l) => {
518
518
  l !== e && M(l, !1);
519
- }), t.classList.add("show"), U.set(e, !0), v(e), de(e, t), K(e);
519
+ }), t.classList.add("show"), U.set(e, !0), v(e), de(e, t), N(e);
520
520
  const r = t.querySelector('[data-field="query"]');
521
521
  r == null || r.focus(), be(e, !1);
522
522
  }
523
- function Ie(e, t) {
523
+ function Re(e, t) {
524
524
  const r = pe(e);
525
525
  return (typeof t == "boolean" ? t : !r) ? ue(e) : M(e, !1), !0;
526
526
  }
527
- function Re(e) {
527
+ function He(e) {
528
528
  const t = window.getSelection();
529
529
  if (!t || t.rangeCount === 0) return null;
530
530
  const r = t.getRangeAt(0);
531
531
  return e.contains(r.commonAncestorContainer) ? r : null;
532
532
  }
533
- function He(e, t) {
533
+ function ze(e, t) {
534
534
  if (!e.isConnected) return;
535
535
  const r = window.getSelection();
536
536
  r && (r.removeAllRanges(), r.addRange(t));
537
537
  }
538
- function ve(e, t, r) {
538
+ const st = /* @__PURE__ */ new Set([
539
+ "DIV",
540
+ "P",
541
+ "BLOCKQUOTE",
542
+ "PRE",
543
+ "H1",
544
+ "H2",
545
+ "H3",
546
+ "H4",
547
+ "H5",
548
+ "H6",
549
+ "LI",
550
+ "TD",
551
+ "TH"
552
+ ]);
553
+ function ve(e, t) {
554
+ let r = e;
555
+ for (; r && r !== t; ) {
556
+ if (r.nodeType === Node.ELEMENT_NODE && st.has(r.tagName))
557
+ return r;
558
+ r = r.parentNode;
559
+ }
560
+ return null;
561
+ }
562
+ function Ce(e, t, r) {
539
563
  const o = t.cloneRange();
540
564
  if (!e.contains(o.commonAncestorContainer)) return !1;
541
565
  o.deleteContents();
@@ -543,27 +567,27 @@ function ve(e, t, r) {
543
567
  l.innerHTML = r;
544
568
  const n = l.content;
545
569
  if (!n) return !1;
546
- const a = n.lastChild;
547
- if (o.insertNode(n), a) {
548
- const s = document.createRange();
549
- s.setStartAfter(a), s.collapse(!0), He(e, s);
570
+ const a = n.lastChild, s = ve(o.endContainer, e) || ve(o.startContainer, e);
571
+ if (s && s.parentNode ? s.parentNode.insertBefore(n, s.nextSibling) : o.insertNode(n), a) {
572
+ const i = document.createRange();
573
+ i.setStartAfter(a), i.collapse(!0), ze(e, i);
550
574
  }
551
575
  return se(e), !0;
552
576
  }
553
- function lt(e, t) {
577
+ function at(e, t) {
554
578
  e.focus({ preventScroll: !0 });
555
- const r = Se(e);
556
- if (r && ve(e, r, t))
579
+ const r = Me(e);
580
+ if (r && Ce(e, r, t))
557
581
  return !0;
558
582
  try {
559
583
  if (document.execCommand("insertHTML", !1, t))
560
584
  return se(e), !0;
561
585
  } catch (l) {
562
586
  }
563
- const o = Re(e);
564
- return o ? ve(e, o, t) : !1;
587
+ const o = He(e);
588
+ return o ? Ce(e, o, t) : !1;
565
589
  }
566
- function st(e, t) {
590
+ function it(e, t) {
567
591
  if (t === e.innerHTML) return;
568
592
  const r = window.execEditorCommand || window.executeEditorCommand;
569
593
  if (typeof r == "function")
@@ -572,22 +596,22 @@ function st(e, t) {
572
596
  } catch (o) {
573
597
  }
574
598
  }
575
- function at(e) {
599
+ function ct(e) {
576
600
  e.dispatchEvent(new Event("input", { bubbles: !0 }));
577
601
  }
578
602
  function F(e, t) {
579
603
  const r = b.get(e) || A;
580
604
  if (!r) return !1;
581
605
  const o = k(e, r), l = x.get(e);
582
- if (Te(e))
606
+ if (Se(e))
583
607
  return l && Ee(l, r.labels.readonlyMessage), !1;
584
608
  const n = ae(e).find((i) => i.id === t);
585
609
  if (!n) return !1;
586
610
  const a = e.innerHTML;
587
- return lt(e, n.html) ? (o.lastInsertedBlockId = n.id, o.selectedBlockId = n.id, o.recentBlockIds = [n.id, ...o.recentBlockIds.filter((i) => i !== n.id)].slice(
611
+ return at(e, n.html) ? (o.lastInsertedBlockId = n.id, o.selectedBlockId = n.id, o.recentBlockIds = [n.id, ...o.recentBlockIds.filter((i) => i !== n.id)].slice(
588
612
  0,
589
613
  r.maxRecentBlocks
590
- ), st(e, a), at(e), K(e), e.dispatchEvent(
614
+ ), it(e, a), ct(e), N(e), e.dispatchEvent(
591
615
  new CustomEvent("editora:blocks-library-insert", {
592
616
  bubbles: !0,
593
617
  detail: {
@@ -598,16 +622,16 @@ function F(e, t) {
598
622
  })
599
623
  ), v(e), l && Ee(l, `${r.labels.lastInsertedPrefix}: ${n.label}`), !0) : !1;
600
624
  }
601
- function ze(e) {
625
+ function qe(e) {
602
626
  const t = w.get(e);
603
627
  return t != null && t.lastInsertedBlockId ? F(e, t.lastInsertedBlockId) : !1;
604
628
  }
605
- function it(e) {
629
+ function dt(e) {
606
630
  const t = b.get(e) || A;
607
631
  if (!t) return;
608
632
  const r = w.get(e);
609
633
  if (!r) return;
610
- Me(e);
634
+ Ae(e);
611
635
  const o = () => {
612
636
  r.debounceTimer = null, r.filterCache.clear(), v(e);
613
637
  };
@@ -617,10 +641,10 @@ function it(e) {
617
641
  }
618
642
  r.debounceTimer = window.setTimeout(o, t.debounceMs);
619
643
  }
620
- function ct(e) {
644
+ function ut(e) {
621
645
  const t = x.get(e);
622
646
  if (t) return t;
623
- 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");
647
+ const r = b.get(e) || A || Q(), o = k(e, r), l = `rte-blocks-library-panel-${je++}`, n = `${l}-query`, a = `${l}-category`, s = document.createElement("section");
624
648
  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 = `
625
649
  <header class="rte-blocks-library-header">
626
650
  <h2 class="rte-blocks-library-title">${m(r.labels.panelTitle)}</h2>
@@ -664,7 +688,7 @@ function ct(e) {
664
688
  g && (o.selectedBlockId = g, v(e), i.detail >= 2 && F(e, g) && M(e, !0));
665
689
  }), s.addEventListener("input", (i) => {
666
690
  const c = i.target;
667
- !(c instanceof HTMLInputElement) || c.getAttribute("data-field") !== "query" || (o.query = r.normalizeText(c.value).toLowerCase(), o.filterCache.clear(), it(e));
691
+ !(c instanceof HTMLInputElement) || c.getAttribute("data-field") !== "query" || (o.query = r.normalizeText(c.value).toLowerCase(), o.filterCache.clear(), dt(e));
668
692
  }), s.addEventListener("change", (i) => {
669
693
  const c = i.target;
670
694
  !(c instanceof HTMLSelectElement) || c.getAttribute("data-field") !== "category" || (o.category = ne(c.value || "all") || "all", o.filterCache.clear(), v(e));
@@ -688,7 +712,7 @@ function ct(e) {
688
712
  }
689
713
  }), re(s, e), document.body.appendChild(s), x.set(e, s), U.set(e, !1), v(e), s;
690
714
  }
691
- function dt(e) {
715
+ function bt(e) {
692
716
  const t = w.get(e);
693
717
  return {
694
718
  query: (t == null ? void 0 : t.query) || "",
@@ -718,14 +742,14 @@ async function be(e, t) {
718
742
  const i = (z.get(e) || 0) + 1;
719
743
  z.set(e, i), o.loading = !0, o.loadError = null, v(e);
720
744
  const c = Promise.resolve().then(async () => {
721
- var B;
745
+ var C;
722
746
  const d = {
723
747
  editor: e,
724
748
  editorRoot: le(e),
725
749
  signal: s.signal
726
- }, f = await ((B = r.getBlocks) == null ? void 0 : B.call(r, d));
750
+ }, f = await ((C = r.getBlocks) == null ? void 0 : C.call(r, d));
727
751
  if (s.signal.aborted || z.get(e) !== i) return;
728
- const g = Ce(f || [], r);
752
+ const g = $e(f || [], r);
729
753
  R.set(e, g), O.set(e, Date.now());
730
754
  const h = w.get(e);
731
755
  h && (h.loading = !1, h.loadError = null, h.filterCache.clear());
@@ -738,24 +762,24 @@ async function be(e, t) {
738
762
  });
739
763
  return j.set(e, c), c;
740
764
  }
741
- function qe(e) {
765
+ function _e(e) {
742
766
  return typeof e.key == "string" ? e.key.toLowerCase() : "";
743
767
  }
744
- function ut(e) {
745
- const t = qe(e);
768
+ function ft(e) {
769
+ const t = _e(e);
746
770
  return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "b";
747
771
  }
748
- function bt(e) {
749
- const t = qe(e);
772
+ function gt(e) {
773
+ const t = _e(e);
750
774
  return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "l";
751
775
  }
752
- function ft(e) {
776
+ function pt(e) {
753
777
  A = e, _ || (_ = (t) => {
754
778
  ee();
755
779
  const r = t.target, o = r == null ? void 0 : r.closest(L);
756
780
  if (!o) return;
757
781
  const l = b.get(o) || e;
758
- k(o, l), b.set(o, l), y = o, K(o);
782
+ k(o, l), b.set(o, l), y = o, N(o);
759
783
  const n = x.get(o);
760
784
  n && (re(n, o), de(o, n), v(o));
761
785
  }, document.addEventListener("focusin", _, !0)), P || (P = (t) => {
@@ -768,33 +792,33 @@ function ft(e) {
768
792
  }
769
793
  return;
770
794
  }
771
- const l = Xe(t);
795
+ const l = Ze(t);
772
796
  if (!l) return;
773
797
  const n = b.get(l) || A || e;
774
798
  if (k(l, n), b.set(l, n), y = l, t.key === "Escape" && pe(l)) {
775
799
  t.preventDefault(), M(l, !0);
776
800
  return;
777
801
  }
778
- if (ut(t)) {
779
- t.preventDefault(), t.stopPropagation(), Ie(l);
802
+ if (ft(t)) {
803
+ t.preventDefault(), t.stopPropagation(), Re(l);
780
804
  return;
781
805
  }
782
- bt(t) && (t.preventDefault(), t.stopPropagation(), ze(l));
806
+ gt(t) && (t.preventDefault(), t.stopPropagation(), qe(l));
783
807
  }, document.addEventListener("keydown", P, !0)), I || (I = () => {
784
808
  ee(), x.forEach((t, r) => {
785
809
  !r.isConnected || !t.isConnected || (re(t, r), de(r, t));
786
810
  });
787
811
  }, window.addEventListener("scroll", I, !0), window.addEventListener("resize", I)), !D && typeof MutationObserver != "undefined" && document.body && (D = new MutationObserver((t) => {
788
- tt(t) && ee();
812
+ rt(t) && ee();
789
813
  }), D.observe(document.body, {
790
814
  childList: !0,
791
815
  subtree: !0
792
816
  }));
793
817
  }
794
- function gt() {
818
+ function mt() {
795
819
  _ && (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;
796
820
  }
797
- function pt() {
821
+ function yt() {
798
822
  if (typeof document == "undefined" || document.getElementById(he)) return;
799
823
  const e = document.createElement("style");
800
824
  e.id = he, e.textContent = `
@@ -1197,9 +1221,9 @@ function pt() {
1197
1221
  }
1198
1222
  `, document.head.appendChild(e);
1199
1223
  }
1200
- const mt = (e = {}) => {
1224
+ const ht = (e = {}) => {
1201
1225
  const t = Q(e), r = /* @__PURE__ */ new Set();
1202
- return pt(), {
1226
+ return yt(), {
1203
1227
  name: "blocksLibrary",
1204
1228
  toolbar: [
1205
1229
  {
@@ -1242,7 +1266,7 @@ const mt = (e = {}) => {
1242
1266
  const n = S(l, !1, !1);
1243
1267
  if (!n) return !1;
1244
1268
  const a = b.get(n) || t;
1245
- return k(n, a), b.set(n, a), y = n, Ie(n, typeof o == "boolean" ? o : void 0);
1269
+ return k(n, a), b.set(n, a), y = n, Re(n, typeof o == "boolean" ? o : void 0);
1246
1270
  },
1247
1271
  insertBlockSnippet: (o, l) => {
1248
1272
  const n = S(l, !1, !1);
@@ -1256,7 +1280,7 @@ const mt = (e = {}) => {
1256
1280
  const n = S(l, !1, !1);
1257
1281
  if (!n) return !1;
1258
1282
  const a = b.get(n) || t;
1259
- return k(n, a), b.set(n, a), y = n, ze(n);
1283
+ return k(n, a), b.set(n, a), y = n, qe(n);
1260
1284
  },
1261
1285
  refreshBlocksLibraryData: (o, l) => {
1262
1286
  const n = S(l, !1, !1);
@@ -1267,7 +1291,7 @@ const mt = (e = {}) => {
1267
1291
  setBlocksLibraryOptions: (o, l) => {
1268
1292
  const n = S(l, !1, !1);
1269
1293
  if (!n || !o || typeof o != "object") return !1;
1270
- const a = b.get(n) || t, s = J.get(n) || Ue(a), i = {
1294
+ const a = b.get(n) || t, s = J.get(n) || Ve(a), i = {
1271
1295
  ...s,
1272
1296
  ...o,
1273
1297
  labels: {
@@ -1281,14 +1305,14 @@ const mt = (e = {}) => {
1281
1305
  }, c = Q(i), d = Array.isArray(o.blocks), f = o.getBlocks !== void 0;
1282
1306
  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()));
1283
1307
  const g = k(n, c);
1284
- return g.filterCache.clear(), typeof o.defaultCategory == "string" && (g.category = ne(c.defaultCategory) || "all"), v(n), K(n), f && be(n, !0), !0;
1308
+ return g.filterCache.clear(), typeof o.defaultCategory == "string" && (g.category = ne(c.defaultCategory) || "all"), v(n), N(n), f && be(n, !0), !0;
1285
1309
  },
1286
1310
  getBlocksLibraryState: (o, l) => {
1287
1311
  const n = S(l, !1, !1);
1288
1312
  if (!n) return !1;
1289
1313
  const a = b.get(n) || t;
1290
1314
  k(n, a);
1291
- const s = dt(n);
1315
+ const s = bt(n);
1292
1316
  if (typeof o == "function")
1293
1317
  try {
1294
1318
  o(s);
@@ -1311,20 +1335,20 @@ const mt = (e = {}) => {
1311
1335
  init: function(l) {
1312
1336
  X += 1;
1313
1337
  const n = this && typeof this.__pluginConfig == "object" ? { ...e, ...this.__pluginConfig } : e, a = Q(n);
1314
- ft(a);
1338
+ pt(a);
1315
1339
  const s = S(
1316
1340
  l != null && l.editorElement ? { editorElement: l.editorElement } : void 0,
1317
1341
  !1,
1318
1342
  !1
1319
1343
  );
1320
- 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()), K(s));
1344
+ 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));
1321
1345
  },
1322
1346
  destroy: () => {
1323
- r.forEach((o) => ge(o)), r.clear(), X = Math.max(0, X - 1), !(X > 0) && gt();
1347
+ r.forEach((o) => ge(o)), r.clear(), X = Math.max(0, X - 1), !(X > 0) && mt();
1324
1348
  }
1325
1349
  };
1326
1350
  };
1327
1351
  export {
1328
- mt as BlocksLibraryPlugin
1352
+ ht as BlocksLibraryPlugin
1329
1353
  };
1330
- //# sourceMappingURL=BlocksLibraryPlugin.native-5sdsXsiE.mjs.map
1354
+ //# sourceMappingURL=BlocksLibraryPlugin.native-CownM6Rk.mjs.map