@editora/plugins 1.0.9 → 1.0.11

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.
@@ -1,8 +1,8 @@
1
1
  function O(e, t) {
2
- const r = Array.from({ length: t }).map(() => "<th><p><br></p></th>").join(""), n = Array.from({ length: e }).map(
2
+ const o = Array.from({ length: t }).map(() => "<th><p><br></p></th>").join(""), n = Array.from({ length: e }).map(
3
3
  () => `<tr>${Array.from({ length: t }).map(() => "<td><p><br></p></td>").join("")}</tr>`
4
4
  ).join("");
5
- return `<table class="rte-table"><thead><tr>${r}</tr></thead><tbody>${n}</tbody></table><p><br></p>`;
5
+ return `<table class="rte-table"><thead><tr>${o}</tr></thead><tbody>${n}</tbody></table><p><br></p>`;
6
6
  }
7
7
  function q() {
8
8
  return [
@@ -107,12 +107,12 @@ function q() {
107
107
  ];
108
108
  }
109
109
  function $(e) {
110
- const t = [], r = /* @__PURE__ */ new Set();
110
+ const t = [], o = /* @__PURE__ */ new Set();
111
111
  return e.forEach((n) => {
112
- const o = String(n.id || "").trim(), i = String(n.label || "").trim();
113
- !o || !i || r.has(o) || (r.add(o), t.push({
112
+ const r = String(n.id || "").trim(), i = String(n.label || "").trim();
113
+ !r || !i || o.has(r) || (o.add(r), t.push({
114
114
  ...n,
115
- id: o,
115
+ id: r,
116
116
  label: i,
117
117
  description: n.description ? String(n.description) : void 0,
118
118
  keywords: Array.isArray(n.keywords) ? n.keywords.map((a) => String(a)).filter(Boolean) : void 0
@@ -120,16 +120,16 @@ function $(e) {
120
120
  }), t;
121
121
  }
122
122
  function D(e) {
123
- const t = (e.triggerChar || "/")[0] || "/", r = e.includeDefaultItems !== !1, n = r ? [...e.items || [], ...q()] : e.items || [];
123
+ const t = (e.triggerChar || "/")[0] || "/", o = e.includeDefaultItems !== !1, n = o ? [...e.items || [], ...q()] : e.items || [];
124
124
  return {
125
125
  triggerChar: t,
126
126
  minChars: Math.max(0, e.minChars ?? 0),
127
127
  maxQueryLength: Math.max(1, e.maxQueryLength ?? 48),
128
128
  maxSuggestions: Math.max(1, e.maxSuggestions ?? 10),
129
129
  requireBoundary: e.requireBoundary !== !1,
130
- includeDefaultItems: r,
130
+ includeDefaultItems: o,
131
131
  items: $(n),
132
- itemRenderer: e.itemRenderer,
132
+ itemRenderer: e.itemRenderer || ((r) => r.label),
133
133
  emptyStateText: e.emptyStateText || "No commands found",
134
134
  panelLabel: e.panelLabel || "Slash commands"
135
135
  };
@@ -241,18 +241,18 @@ function F(e) {
241
241
  if (e?.editorElement instanceof HTMLElement) {
242
242
  const n = e.editorElement;
243
243
  if (n.matches(s)) return n;
244
- const o = n.querySelector(s);
245
- if (o instanceof HTMLElement) return o;
244
+ const r = n.querySelector(s);
245
+ if (r instanceof HTMLElement) return r;
246
246
  }
247
247
  const t = window.getSelection();
248
248
  if (t && t.rangeCount > 0) {
249
249
  const n = t.getRangeAt(0).startContainer, i = (n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(s);
250
250
  if (i) return i;
251
251
  }
252
- const r = document.activeElement;
253
- if (r) {
254
- if (r.matches(s)) return r;
255
- const n = r.closest(s);
252
+ const o = document.activeElement;
253
+ if (o) {
254
+ if (o.matches(s)) return o;
255
+ const n = o.closest(s);
256
256
  if (n) return n;
257
257
  }
258
258
  return document.querySelector(s);
@@ -266,30 +266,30 @@ function _(e) {
266
266
  function E(e) {
267
267
  const t = window.getSelection();
268
268
  if (!t || t.rangeCount === 0) return null;
269
- const r = t.getRangeAt(0);
270
- return e.contains(r.commonAncestorContainer) ? r.cloneRange() : null;
269
+ const o = t.getRangeAt(0);
270
+ return e.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
271
271
  }
272
272
  function y(e, t) {
273
- const r = window.getSelection();
274
- r && (r.removeAllRanges(), r.addRange(t), e.focus({ preventScroll: !0 }));
273
+ const o = window.getSelection();
274
+ o && (o.removeAllRanges(), o.addRange(t), e.focus({ preventScroll: !0 }));
275
275
  }
276
276
  function j(e) {
277
277
  if (!e.collapsed) return null;
278
- const t = e.startContainer, r = e.startOffset;
278
+ const t = e.startContainer, o = e.startOffset;
279
279
  if (t.nodeType === Node.TEXT_NODE) {
280
280
  const n = t;
281
281
  return {
282
282
  node: n,
283
- textBefore: n.data.slice(0, r),
284
- caretOffset: r
283
+ textBefore: n.data.slice(0, o),
284
+ caretOffset: o
285
285
  };
286
286
  }
287
287
  if (t.nodeType === Node.ELEMENT_NODE) {
288
288
  const n = t;
289
- if (r > 0) {
290
- const o = n.childNodes[r - 1];
291
- if (o && o.nodeType === Node.TEXT_NODE) {
292
- const i = o;
289
+ if (o > 0) {
290
+ const r = n.childNodes[o - 1];
291
+ if (r && r.nodeType === Node.TEXT_NODE) {
292
+ const i = r;
293
293
  return {
294
294
  node: i,
295
295
  textBefore: i.data,
@@ -300,52 +300,52 @@ function j(e) {
300
300
  }
301
301
  return null;
302
302
  }
303
- function K(e, t, r, n) {
304
- const o = e.lastIndexOf(t);
305
- if (o < 0 || n && !_(e[o - 1]))
303
+ function K(e, t, o, n) {
304
+ const r = e.lastIndexOf(t);
305
+ if (r < 0 || n && !_(e[r - 1]))
306
306
  return null;
307
- const i = e.slice(o + 1);
308
- return /\s/.test(i) || i.length > r ? null : {
307
+ const i = e.slice(r + 1);
308
+ return /\s/.test(i) || i.length > o ? null : {
309
309
  trigger: t,
310
310
  query: i,
311
- startOffset: o
311
+ startOffset: r
312
312
  };
313
313
  }
314
314
  function Q(e, t) {
315
- const r = t.cloneRange();
316
- r.collapse(!1);
317
- const n = r.getClientRects();
315
+ const o = t.cloneRange();
316
+ o.collapse(!1);
317
+ const n = o.getClientRects();
318
318
  if (n.length > 0)
319
319
  return n[n.length - 1];
320
- const o = document.createElement("span");
321
- o.textContent = "​", r.insertNode(o);
322
- const i = o.getBoundingClientRect();
323
- return o.remove(), e.normalize(), i;
320
+ const r = document.createElement("span");
321
+ r.textContent = "​", o.insertNode(r);
322
+ const i = r.getBoundingClientRect();
323
+ return r.remove(), e.normalize(), i;
324
324
  }
325
325
  function A(e, t) {
326
326
  if (!e.panel) return;
327
- const r = Q(e.editor, t), n = e.panel;
327
+ const o = Q(e.editor, t), n = e.panel;
328
328
  n.style.display = "block", n.classList.add("show"), n.style.left = "0px", n.style.top = "0px";
329
- const o = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight;
330
- let l = Math.max(8, Math.min(r.left, i - o.width - 8)), d = r.bottom + 8;
331
- d + o.height > a - 8 && (d = Math.max(8, r.top - o.height - 8)), n.style.position = "fixed", n.style.left = `${l}px`, n.style.top = `${d}px`;
329
+ const r = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight;
330
+ let l = Math.max(8, Math.min(o.left, i - r.width - 8)), d = o.bottom + 8;
331
+ d + r.height > a - 8 && (d = Math.max(8, o.top - r.height - 8)), n.style.position = "fixed", n.style.left = `${l}px`, n.style.top = `${d}px`;
332
332
  }
333
333
  function k(e, t) {
334
334
  if (!t) return m(e);
335
- const r = e.toLowerCase(), n = t.toLowerCase(), o = r.indexOf(n);
336
- if (o < 0) return m(e);
337
- const i = m(e.slice(0, o)), a = m(e.slice(o, o + t.length)), l = m(e.slice(o + t.length));
335
+ const o = e.toLowerCase(), n = t.toLowerCase(), r = o.indexOf(n);
336
+ if (r < 0) return m(e);
337
+ const i = m(e.slice(0, r)), a = m(e.slice(r, r + t.length)), l = m(e.slice(r + t.length));
338
338
  return `${i}<mark>${a}</mark>${l}`;
339
339
  }
340
340
  function U(e, t) {
341
341
  if (e.panel && e.list) return;
342
- const r = document.createElement("div");
343
- r.className = "rte-slash-panel", r.style.display = "none", r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "false");
342
+ const o = document.createElement("div");
343
+ o.className = "rte-slash-panel", o.style.display = "none", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false");
344
344
  const n = document.createElement("div");
345
- n.className = "rte-slash-list", n.setAttribute("role", "listbox"), n.setAttribute("aria-label", t.panelLabel), r.appendChild(n), document.body.appendChild(r), e.panel = r, e.list = n, r.addEventListener("mousedown", (o) => {
346
- o.preventDefault();
347
- }), r.addEventListener("click", (o) => {
348
- const i = o.target;
345
+ n.className = "rte-slash-list", n.setAttribute("role", "listbox"), n.setAttribute("aria-label", t.panelLabel), o.appendChild(n), document.body.appendChild(o), e.panel = o, e.list = n, o.addEventListener("mousedown", (r) => {
346
+ r.preventDefault();
347
+ }), o.addEventListener("click", (r) => {
348
+ const i = r.target;
349
349
  if (!i) return;
350
350
  const a = i.closest(".rte-slash-item");
351
351
  if (!a) return;
@@ -356,8 +356,8 @@ function U(e, t) {
356
356
  function c(e) {
357
357
  e.panel && (e.panel.style.display = "none", e.panel.classList.remove("show"), e.isOpen = !1, e.filteredItems = [], e.activeIndex = 0, e.query = "", e.replaceRange = null, e.anchorRange = null);
358
358
  }
359
- function W(e, t, r) {
360
- if (!t) return e.slice(0, r);
359
+ function W(e, t, o) {
360
+ if (!t) return e.slice(0, o);
361
361
  const n = t.toLowerCase();
362
362
  return e.filter((i) => [
363
363
  i.id,
@@ -365,30 +365,30 @@ function W(e, t, r) {
365
365
  i.description || "",
366
366
  i.command || "",
367
367
  ...i.keywords || []
368
- ].join(" ").toLowerCase().includes(n)).slice(0, r);
368
+ ].join(" ").toLowerCase().includes(n)).slice(0, o);
369
369
  }
370
370
  function Z(e, t) {
371
371
  if (!e.list) return;
372
- const r = e.list;
373
- if (r.innerHTML = "", e.filteredItems.length === 0) {
372
+ const o = e.list;
373
+ if (o.innerHTML = "", e.filteredItems.length === 0) {
374
374
  const n = document.createElement("div");
375
- n.className = "rte-slash-empty", n.textContent = t.emptyStateText, r.appendChild(n), r.removeAttribute("aria-activedescendant");
375
+ n.className = "rte-slash-empty", n.textContent = t.emptyStateText, o.appendChild(n), o.removeAttribute("aria-activedescendant");
376
376
  return;
377
377
  }
378
- e.filteredItems.forEach((n, o) => {
378
+ e.filteredItems.forEach((n, r) => {
379
379
  const i = document.createElement("button");
380
- i.type = "button", i.className = "rte-slash-item", i.setAttribute("role", "option"), i.setAttribute("data-index", String(o)), i.setAttribute("id", `rte-slash-item-${e.instanceId}-${o}`), i.setAttribute("aria-selected", o === e.activeIndex ? "true" : "false"), i.setAttribute("aria-label", n.description ? `${n.label} - ${n.description}` : n.label), o === e.activeIndex && i.classList.add("active"), t.itemRenderer ? i.innerHTML = t.itemRenderer(n, e.query) : i.innerHTML = `
380
+ i.type = "button", i.className = "rte-slash-item", i.setAttribute("role", "option"), i.setAttribute("data-index", String(r)), i.setAttribute("id", `rte-slash-item-${e.instanceId}-${r}`), i.setAttribute("aria-selected", r === e.activeIndex ? "true" : "false"), i.setAttribute("aria-label", n.description ? `${n.label} - ${n.description}` : n.label), r === e.activeIndex && i.classList.add("active"), t.itemRenderer ? i.innerHTML = t.itemRenderer(n, e.query) : i.innerHTML = `
381
381
  <span class="rte-slash-item-title">${k(n.label, e.query)}</span>
382
382
  ${n.description ? `<span class="rte-slash-item-description">${k(n.description, e.query)}</span>` : ""}
383
- `, r.appendChild(i);
384
- }), e.filteredItems.length > 0 && r.setAttribute("aria-activedescendant", `rte-slash-item-${e.instanceId}-${e.activeIndex}`);
383
+ `, o.appendChild(i);
384
+ }), e.filteredItems.length > 0 && o.setAttribute("aria-activedescendant", `rte-slash-item-${e.instanceId}-${e.activeIndex}`);
385
385
  }
386
386
  function G(e, t) {
387
387
  if (t === e.innerHTML) return;
388
- const r = window.execEditorCommand || window.executeEditorCommand;
389
- if (typeof r == "function")
388
+ const o = window.execEditorCommand || window.executeEditorCommand;
389
+ if (typeof o == "function")
390
390
  try {
391
- r("recordDomTransaction", e, t, e.innerHTML);
391
+ o("recordDomTransaction", e, t, e.innerHTML);
392
392
  } catch {
393
393
  }
394
394
  }
@@ -402,14 +402,14 @@ function L(e, t) {
402
402
  return !0;
403
403
  } catch {
404
404
  }
405
- const r = window.getSelection();
406
- if (!r || r.rangeCount === 0) return !1;
407
- const n = r.getRangeAt(0);
405
+ const o = window.getSelection();
406
+ if (!o || o.rangeCount === 0) return !1;
407
+ const n = o.getRangeAt(0);
408
408
  if (!e.contains(n.commonAncestorContainer)) return !1;
409
409
  n.deleteContents();
410
- const o = document.createElement("template");
411
- o.innerHTML = t;
412
- const i = o.content, a = i.lastChild;
410
+ const r = document.createElement("template");
411
+ r.innerHTML = t;
412
+ const i = r.content, a = i.lastChild;
413
413
  if (n.insertNode(i), a) {
414
414
  const l = document.createRange();
415
415
  l.setStartAfter(a), l.collapse(!0), y(e, l);
@@ -423,15 +423,15 @@ function X(e, t) {
423
423
  return !0;
424
424
  } catch {
425
425
  }
426
- const r = window.getSelection();
427
- if (!r || r.rangeCount === 0) return !1;
428
- const n = r.getRangeAt(0);
426
+ const o = window.getSelection();
427
+ if (!o || o.rangeCount === 0) return !1;
428
+ const n = o.getRangeAt(0);
429
429
  if (!e.contains(n.commonAncestorContainer)) return !1;
430
430
  n.deleteContents();
431
- const o = document.createTextNode(t);
432
- n.insertNode(o);
431
+ const r = document.createTextNode(t);
432
+ n.insertNode(r);
433
433
  const i = document.createRange();
434
- return i.setStart(o, o.length), i.collapse(!0), y(e, i), !0;
434
+ return i.setStart(r, r.length), i.collapse(!0), y(e, i), !0;
435
435
  }
436
436
  function J(e, t) {
437
437
  switch (e.toLowerCase()) {
@@ -485,38 +485,38 @@ function J(e, t) {
485
485
  }
486
486
  }
487
487
  }
488
- function S(e, t, r) {
488
+ function S(e, t, o) {
489
489
  const n = I(e);
490
490
  if (n && typeof n.execCommand == "function")
491
491
  try {
492
- if (n.execCommand(t, r) !== !1) return !0;
492
+ if (n.execCommand(t, o) !== !1) return !0;
493
493
  } catch {
494
494
  }
495
- const o = window.execEditorCommand || window.executeEditorCommand;
496
- if (typeof o == "function")
495
+ const r = window.execEditorCommand || window.executeEditorCommand;
496
+ if (typeof r == "function")
497
497
  try {
498
- if (o(t, r, {
498
+ if (r(t, o, {
499
499
  editorElement: n,
500
500
  contentElement: e
501
501
  }) !== !1) return !0;
502
502
  } catch {
503
503
  }
504
- return J(t, r);
504
+ return J(t, o);
505
505
  }
506
506
  async function Y(e, t) {
507
- const r = e.editor, n = I(r), o = {
508
- editor: r,
507
+ const o = e.editor, n = I(o), r = {
508
+ editor: o,
509
509
  editorRoot: n,
510
510
  query: e.query,
511
511
  trigger: e.trigger,
512
- executeCommand: (i, a) => S(r, i, a),
513
- insertHTML: (i) => L(r, i)
512
+ executeCommand: (i, a) => S(o, i, a),
513
+ insertHTML: (i) => L(o, i)
514
514
  };
515
- return t.action ? await Promise.resolve(t.action(o)) !== !1 : t.insertHTML ? L(r, t.insertHTML) : t.command ? S(r, t.command, t.commandValue) : !1;
515
+ return t.action ? await Promise.resolve(t.action(r)) !== !1 : t.insertHTML ? L(o, t.insertHTML) : t.command ? S(o, t.command, t.commandValue) : !1;
516
516
  }
517
517
  async function M(e, t) {
518
518
  if (t < 0 || t >= e.filteredItems.length || !e.replaceRange) return;
519
- const r = e.filteredItems[t], n = e.editor, o = n.innerHTML, i = `${e.trigger}${e.query}`;
519
+ const o = e.filteredItems[t], n = e.editor, r = n.innerHTML, i = `${e.trigger}${e.query}`;
520
520
  if (!window.getSelection()) return;
521
521
  const l = e.replaceRange.cloneRange();
522
522
  if (!n.contains(l.commonAncestorContainer)) return;
@@ -525,23 +525,23 @@ async function M(e, t) {
525
525
  d.collapse(!0), y(n, d);
526
526
  let x = !1;
527
527
  try {
528
- x = await Y(e, r);
528
+ x = await Y(e, o);
529
529
  } catch {
530
530
  x = !1;
531
531
  }
532
- c(e), x ? (V(n), G(n, o)) : i && X(n, i), n.focus({ preventScroll: !0 });
532
+ c(e), x ? (V(n), G(n, r)) : i && X(n, i), n.focus({ preventScroll: !0 });
533
533
  }
534
534
  function R(e, t) {
535
535
  if (e.filteredItems.length === 0) return;
536
- const r = e.filteredItems.length;
537
- if (e.activeIndex = ((e.activeIndex + t) % r + r) % r, !e.list) return;
536
+ const o = e.filteredItems.length;
537
+ if (e.activeIndex = ((e.activeIndex + t) % o + o) % o, !e.list) return;
538
538
  const n = Array.from(e.list.querySelectorAll(".rte-slash-item"));
539
539
  n.forEach((i, a) => {
540
540
  const l = a === e.activeIndex;
541
541
  i.classList.toggle("active", l), i.setAttribute("aria-selected", l ? "true" : "false");
542
542
  });
543
- const o = n[e.activeIndex];
544
- o && (e.list.setAttribute("aria-activedescendant", o.id), o.scrollIntoView({ block: "nearest" }));
543
+ const r = n[e.activeIndex];
544
+ r && (e.list.setAttribute("aria-activedescendant", r.id), r.scrollIntoView({ block: "nearest" }));
545
545
  }
546
546
  function T(e) {
547
547
  if (!(!e.isOpen || !e.panel || !e.anchorRange)) {
@@ -552,27 +552,27 @@ function T(e) {
552
552
  A(e, e.anchorRange);
553
553
  }
554
554
  }
555
- function N(e, t, r, n, o, i) {
556
- U(e, t), e.query = n, e.trigger = o, e.replaceRange = i.cloneRange(), e.anchorRange = r.cloneRange(), e.filteredItems = W(e.items, n, t.maxSuggestions), e.activeIndex = 0, e.isOpen = !0, e.panel && (Z(e, t), A(e, r));
555
+ function N(e, t, o, n, r, i) {
556
+ U(e, t), e.query = n, e.trigger = r, e.replaceRange = i.cloneRange(), e.anchorRange = o.cloneRange(), e.filteredItems = W(e.items, n, t.maxSuggestions), e.activeIndex = 0, e.isOpen = !0, e.panel && (Z(e, t), A(e, o));
557
557
  }
558
558
  function ee(e, t) {
559
- const r = e.editor;
560
- if (r.getAttribute("contenteditable") === "false") {
559
+ const o = e.editor;
560
+ if (o.getAttribute("contenteditable") === "false") {
561
561
  c(e);
562
562
  return;
563
563
  }
564
- const n = E(r);
564
+ const n = E(o);
565
565
  if (!n || !n.collapsed) {
566
566
  c(e);
567
567
  return;
568
568
  }
569
- const o = j(n);
570
- if (!o) {
569
+ const r = j(n);
570
+ if (!r) {
571
571
  c(e);
572
572
  return;
573
573
  }
574
574
  const i = K(
575
- o.textBefore,
575
+ r.textBefore,
576
576
  t.triggerChar,
577
577
  t.maxQueryLength,
578
578
  t.requireBoundary
@@ -586,16 +586,16 @@ function ee(e, t) {
586
586
  return;
587
587
  }
588
588
  const a = n.cloneRange();
589
- a.setStart(o.node, i.startOffset), a.setEnd(o.node, o.caretOffset), N(e, t, n, i.query, i.trigger, a);
589
+ a.setStart(r.node, i.startOffset), a.setEnd(r.node, r.caretOffset), N(e, t, n, i.query, i.trigger, a);
590
590
  }
591
591
  function H(e, t) {
592
- const r = e.editor;
593
- if (r.getAttribute("contenteditable") === "false")
592
+ const o = e.editor;
593
+ if (o.getAttribute("contenteditable") === "false")
594
594
  return !1;
595
- let n = E(r);
596
- n || (n = document.createRange(), n.selectNodeContents(r), n.collapse(!1), y(r, n));
597
- const o = n.cloneRange();
598
- return o.collapse(!0), N(e, t, n, "", t.triggerChar, o), !0;
595
+ let n = E(o);
596
+ n || (n = document.createRange(), n.selectNodeContents(o), n.collapse(!1), y(o, n));
597
+ const r = n.cloneRange();
598
+ return r.collapse(!0), N(e, t, n, "", t.triggerChar, r), !0;
599
599
  }
600
600
  function te(e) {
601
601
  return !(e.metaKey || e.ctrlKey) || e.altKey ? !1 : e.key === "/" || e.code === "Slash";
@@ -617,9 +617,9 @@ function ne(e, t) {
617
617
  };
618
618
  }
619
619
  function w(e, t) {
620
- const r = g.get(e);
621
- if (r)
622
- return r.items = t.items, r;
620
+ const o = g.get(e);
621
+ if (o)
622
+ return o.items = t.items, o;
623
623
  const n = ne(e, t);
624
624
  return g.set(e, n), n;
625
625
  }
@@ -627,63 +627,63 @@ function re(e) {
627
627
  const t = g.get(e);
628
628
  t && (t.panel?.parentNode && t.panel.parentNode.removeChild(t.panel), g.delete(e));
629
629
  }
630
- function C(e, t, r) {
630
+ function C(e, t, o) {
631
631
  if (p.has(e)) return;
632
632
  const n = {
633
633
  input: () => {
634
- ee(t, r);
634
+ ee(t, o);
635
635
  },
636
- keydown: (o) => {
636
+ keydown: (r) => {
637
637
  if (t.editor.getAttribute("contenteditable") === "false") {
638
638
  c(t);
639
639
  return;
640
640
  }
641
- if (!t.isOpen && te(o)) {
642
- o.preventDefault(), H(t, r);
641
+ if (!t.isOpen && te(r)) {
642
+ r.preventDefault(), H(t, o);
643
643
  return;
644
644
  }
645
645
  if (t.isOpen) {
646
- if (o.key === "ArrowDown") {
647
- o.preventDefault(), R(t, 1);
646
+ if (r.key === "ArrowDown") {
647
+ r.preventDefault(), R(t, 1);
648
648
  return;
649
649
  }
650
- if (o.key === "ArrowUp") {
651
- o.preventDefault(), R(t, -1);
650
+ if (r.key === "ArrowUp") {
651
+ r.preventDefault(), R(t, -1);
652
652
  return;
653
653
  }
654
- if (o.key === "Enter" || o.key === "Tab") {
654
+ if (r.key === "Enter" || r.key === "Tab") {
655
655
  if (t.filteredItems.length === 0) {
656
- o.key === "Tab" && o.preventDefault(), c(t);
656
+ r.key === "Tab" && r.preventDefault(), c(t);
657
657
  return;
658
658
  }
659
- o.preventDefault(), M(t, t.activeIndex);
659
+ r.preventDefault(), M(t, t.activeIndex);
660
660
  return;
661
661
  }
662
- if (o.key === "Escape") {
663
- o.preventDefault(), c(t);
662
+ if (r.key === "Escape") {
663
+ r.preventDefault(), c(t);
664
664
  return;
665
665
  }
666
666
  }
667
667
  },
668
668
  blur: () => {
669
669
  window.setTimeout(() => {
670
- const o = document.activeElement;
671
- t.panel && o && t.panel.contains(o) || c(t);
670
+ const r = document.activeElement;
671
+ t.panel && r && t.panel.contains(r) || c(t);
672
672
  }, 0);
673
673
  },
674
- mousedown: (o) => {
674
+ mousedown: (r) => {
675
675
  if (!t.isOpen || !t.panel) return;
676
- const i = o.target;
676
+ const i = r.target;
677
677
  i && !t.panel.contains(i) && !e.contains(i) && c(t);
678
678
  },
679
679
  selectionchange: () => {
680
680
  if (!t.isOpen) return;
681
- const o = E(e);
682
- if (!o || !o.collapsed) {
681
+ const r = E(e);
682
+ if (!r || !r.collapsed) {
683
683
  c(t);
684
684
  return;
685
685
  }
686
- t.anchorRange = o.cloneRange(), T(t);
686
+ t.anchorRange = r.cloneRange(), T(t);
687
687
  },
688
688
  reposition: () => {
689
689
  T(t);
@@ -697,12 +697,12 @@ function oe(e) {
697
697
  }
698
698
  function ie(e) {
699
699
  b || (b = !0, f = (t) => {
700
- const r = t.target;
701
- if (!(r instanceof Node)) return;
702
- const o = P(r)?.closest(s) || null;
703
- if (!o) return;
704
- const i = w(o, e);
705
- C(o, i, e);
700
+ const o = t.target;
701
+ if (!(o instanceof Node)) return;
702
+ const r = P(o)?.closest(s) || null;
703
+ if (!r) return;
704
+ const i = w(r, e);
705
+ C(r, i, e);
706
706
  }, document.addEventListener("focusin", f, !0));
707
707
  }
708
708
  function ae() {
@@ -722,11 +722,11 @@ const le = (e = {}) => {
722
722
  }
723
723
  ],
724
724
  commands: {
725
- openSlashCommands: (r, n) => {
726
- const o = F(n);
727
- if (!o) return !1;
728
- const i = w(o, t);
729
- return C(o, i, t), H(i, t);
725
+ openSlashCommands: (o, n) => {
726
+ const r = F(n);
727
+ if (!r) return !1;
728
+ const i = w(r, t);
729
+ return C(r, i, t), H(i, t);
730
730
  }
731
731
  },
732
732
  keymap: {
@@ -735,14 +735,14 @@ const le = (e = {}) => {
735
735
  },
736
736
  init: () => {
737
737
  h += 1, ie(t), Array.from(document.querySelectorAll(s)).forEach((n) => {
738
- const o = w(n, t);
739
- C(n, o, t);
738
+ const r = w(n, t);
739
+ C(n, r, t);
740
740
  });
741
741
  },
742
742
  destroy: () => {
743
743
  h = Math.max(0, h - 1), Array.from(document.querySelectorAll(s)).forEach((n) => {
744
- const o = g.get(n);
745
- o && (c(o), oe(n), re(n));
744
+ const r = g.get(n);
745
+ r && (c(r), oe(n), re(n));
746
746
  }), h === 0 && ae();
747
747
  }
748
748
  };