@editora/plugins 1.0.12 → 1.0.14

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 (53) hide show
  1. package/dist/approval-workflow.cjs.js +14 -14
  2. package/dist/approval-workflow.esm.js +265 -262
  3. package/dist/blockquote.cjs.js +1 -1
  4. package/dist/blockquote.esm.js +177 -15
  5. package/dist/blocks-library.cjs.js +6 -6
  6. package/dist/blocks-library.esm.js +95 -92
  7. package/dist/bold.cjs.js +1 -1
  8. package/dist/bold.esm.js +10 -6
  9. package/dist/capitalization.cjs.js +1 -1
  10. package/dist/capitalization.esm.js +124 -44
  11. package/dist/checklist.cjs.js +1 -1
  12. package/dist/checklist.esm.js +251 -191
  13. package/dist/citations.cjs.js +4 -4
  14. package/dist/citations.esm.js +131 -128
  15. package/dist/clear-formatting.cjs.js +1 -1
  16. package/dist/clear-formatting.esm.js +68 -36
  17. package/dist/code.cjs.js +27 -21
  18. package/dist/code.esm.js +72 -43
  19. package/dist/content-rules.cjs.js +5 -5
  20. package/dist/content-rules.esm.js +104 -101
  21. package/dist/data-binding.cjs.js +3 -3
  22. package/dist/data-binding.esm.js +51 -48
  23. package/dist/direction.cjs.js +1 -1
  24. package/dist/direction.esm.js +97 -74
  25. package/dist/doc-schema.cjs.js +4 -4
  26. package/dist/doc-schema.esm.js +104 -101
  27. package/dist/embed-iframe.cjs.js +21 -4
  28. package/dist/embed-iframe.esm.js +279 -116
  29. package/dist/heading.cjs.js +1 -1
  30. package/dist/heading.esm.js +239 -56
  31. package/dist/history.cjs.js +1 -1
  32. package/dist/history.esm.js +74 -89
  33. package/dist/inlineFormatting-DOYOJdnD.js +1 -0
  34. package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
  35. package/dist/italic.cjs.js +1 -1
  36. package/dist/italic.esm.js +12 -8
  37. package/dist/math.cjs.js +27 -21
  38. package/dist/math.esm.js +218 -146
  39. package/dist/merge-tag.cjs.js +8 -2
  40. package/dist/merge-tag.esm.js +130 -111
  41. package/dist/pii-redaction.cjs.js +6 -6
  42. package/dist/pii-redaction.esm.js +169 -166
  43. package/dist/smart-paste.cjs.js +5 -5
  44. package/dist/smart-paste.esm.js +120 -117
  45. package/dist/special-characters.cjs.js +6 -10
  46. package/dist/special-characters.esm.js +97 -75
  47. package/dist/strikethrough.cjs.js +1 -1
  48. package/dist/strikethrough.esm.js +11 -25
  49. package/dist/translation-workflow.cjs.js +7 -7
  50. package/dist/translation-workflow.esm.js +103 -100
  51. package/dist/underline.cjs.js +1 -1
  52. package/dist/underline.esm.js +7 -3
  53. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- const S = ".rte-content, .editora-content", mt = "rte-citations-styles", b = "rte-citations-panel", ot = ".rte-citation-ref[data-citation-id]", W = '.rte-citation-bibliography[data-type="citation-bibliography"]', G = '.rte-citation-footnotes[data-type="citation-footnotes"]', x = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', L = ["apa", "mla", "chicago"], Bt = {
1
+ const S = ".rte-content, .editora-content", pt = "rte-citations-styles", b = "rte-citations-panel", ot = ".rte-citation-ref[data-citation-id]", W = '.rte-citation-bibliography[data-type="citation-bibliography"]', G = '.rte-citation-footnotes[data-type="citation-footnotes"]', x = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', L = ["apa", "mla", "chicago"], Ot = {
2
2
  panelTitle: "Citations",
3
3
  panelAriaLabel: "Citations panel",
4
4
  styleLabel: "Citation style",
@@ -19,41 +19,41 @@ const S = ".rte-content, .editora-content", mt = "rte-citations-styles", b = "rt
19
19
  deleteRecentText: "x",
20
20
  summaryPrefix: "Citations",
21
21
  invalidMessage: "Author and title are required."
22
- }, f = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), pt = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new Set();
23
- let I = null, B = null, O = null, k = null, Y = 0, Ot = 0, at = 0, M = null, p = null;
22
+ }, f = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), ht = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new Set();
23
+ let I = null, B = null, O = null, k = null, Y = 0, Pt = 0, at = 0, M = null, p = null;
24
24
  function g(t) {
25
25
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
26
26
  }
27
- function Pt(t) {
27
+ function Dt(t) {
28
28
  return t.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
29
29
  }
30
- function ht(t, e) {
30
+ function xt(t, e) {
31
31
  const n = e(t);
32
32
  if (!n) return "";
33
33
  const i = n.match(/\d{4}/);
34
34
  return i ? i[0] : n;
35
35
  }
36
- function xt(t, e) {
36
+ function yt(t, e) {
37
37
  const n = e(t);
38
38
  return n ? /^https?:\/\//i.test(n) ? n : `https://${n}` : "";
39
39
  }
40
40
  function F(t) {
41
41
  return t.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
42
42
  }
43
- function yt(t, e) {
43
+ function Ct(t, e) {
44
44
  return {
45
45
  id: F(e.normalizeText(t.id || "")),
46
46
  author: e.normalizeText(t.author || ""),
47
- year: ht(t.year || "", e.normalizeText) || void 0,
47
+ year: xt(t.year || "", e.normalizeText) || void 0,
48
48
  title: e.normalizeText(t.title || ""),
49
49
  source: e.normalizeText(t.source || "") || void 0,
50
- url: xt(t.url || "", e.normalizeText) || void 0,
50
+ url: yt(t.url || "", e.normalizeText) || void 0,
51
51
  note: e.normalizeText(t.note || "") || void 0
52
52
  };
53
53
  }
54
54
  function Z(t = {}) {
55
55
  const e = t.defaultStyle && L.includes(t.defaultStyle) ? t.defaultStyle : "apa", n = {
56
- ...Bt,
56
+ ...Ot,
57
57
  ...t.labels || {}
58
58
  };
59
59
  return {
@@ -62,11 +62,11 @@ function Z(t = {}) {
62
62
  debounceMs: Math.max(80, Number(t.debounceMs ?? 220)),
63
63
  maxRecentCitations: Math.max(3, Math.min(30, Number(t.maxRecentCitations ?? 8))),
64
64
  labels: n,
65
- normalizeText: t.normalizeText || Pt,
65
+ normalizeText: t.normalizeText || Dt,
66
66
  generateCitationId: typeof t.generateCitationId == "function" ? t.generateCitationId : void 0
67
67
  };
68
68
  }
69
- function Ct(t) {
69
+ function wt(t) {
70
70
  return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
71
71
  }
72
72
  function lt(t) {
@@ -75,14 +75,14 @@ function lt(t) {
75
75
  function X(t) {
76
76
  return t ? (t.getAttribute("data-theme") || t.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : t.classList.contains("dark") || t.classList.contains("editora-theme-dark") || t.classList.contains("rte-theme-dark") : !1;
77
77
  }
78
- function Dt(t) {
78
+ function Ht(t) {
79
79
  const e = lt(t);
80
80
  if (X(e)) return !0;
81
81
  const n = e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
82
82
  return X(n) ? !0 : X(document.documentElement) || X(document.body);
83
83
  }
84
84
  function tt(t, e) {
85
- t.classList.remove("rte-citations-theme-dark"), Dt(e) && t.classList.add("rte-citations-theme-dark");
85
+ t.classList.remove("rte-citations-theme-dark"), Ht(e) && t.classList.add("rte-citations-theme-dark");
86
86
  }
87
87
  function h(t, e = !0) {
88
88
  if (t?.contentElement instanceof HTMLElement) return t.contentElement;
@@ -94,7 +94,7 @@ function h(t, e = !0) {
94
94
  }
95
95
  const n = window.getSelection();
96
96
  if (n && n.rangeCount > 0) {
97
- const o = n.getRangeAt(0).startContainer, a = Ct(o)?.closest(S);
97
+ const o = n.getRangeAt(0).startContainer, a = wt(o)?.closest(S);
98
98
  if (a) return a;
99
99
  }
100
100
  const i = document.activeElement;
@@ -108,11 +108,11 @@ function h(t, e = !0) {
108
108
  function $(t) {
109
109
  return t.getAttribute("contenteditable") === "false" || t.getAttribute("data-readonly") === "true";
110
110
  }
111
- function j(t) {
112
- const e = Ct(t);
111
+ function K(t) {
112
+ const e = wt(t);
113
113
  return e ? !!(e.closest(W) || e.closest(G)) : !1;
114
114
  }
115
- function Ht(t, e) {
115
+ function Ft(t, e) {
116
116
  if (at += 1, e.generateCitationId) {
117
117
  const n = e.generateCitationId({ editor: t, index: at }), i = F(e.normalizeText(n || ""));
118
118
  if (i) return i;
@@ -122,7 +122,7 @@ function Ht(t, e) {
122
122
  function st(t) {
123
123
  return t.map((e) => (e || "").trim()).filter(Boolean).join(" ").trim();
124
124
  }
125
- function Ft(t, e) {
125
+ function _t(t, e) {
126
126
  const n = t.author || "Unknown", i = t.year || "n.d.";
127
127
  return e === "mla" ? `(${n} ${i})` : e === "chicago" ? `(${n} ${i})` : `(${n}, ${i})`;
128
128
  }
@@ -153,22 +153,22 @@ function R(t) {
153
153
  (e) => !e.closest(W) && !e.closest(G)
154
154
  );
155
155
  }
156
- function wt(t, e) {
156
+ function vt(t, e) {
157
157
  const n = F(e.normalizeText(t.getAttribute("data-citation-id") || ""));
158
158
  if (!n) return null;
159
159
  const i = e.normalizeText(t.getAttribute("data-citation-author") || ""), o = e.normalizeText(t.getAttribute("data-citation-title") || "");
160
160
  return {
161
161
  id: n,
162
162
  author: i || "Unknown",
163
- year: ht(t.getAttribute("data-citation-year") || "", e.normalizeText) || void 0,
163
+ year: xt(t.getAttribute("data-citation-year") || "", e.normalizeText) || void 0,
164
164
  title: o || "Untitled",
165
165
  source: e.normalizeText(t.getAttribute("data-citation-source") || "") || void 0,
166
- url: xt(t.getAttribute("data-citation-url") || "", e.normalizeText) || void 0,
166
+ url: yt(t.getAttribute("data-citation-url") || "", e.normalizeText) || void 0,
167
167
  note: e.normalizeText(t.getAttribute("data-citation-note") || "") || void 0
168
168
  };
169
169
  }
170
- function vt(t, e, n) {
171
- t.classList.add("rte-citation-ref"), t.setAttribute("data-citation-id", e.id), t.setAttribute("data-citation-author", e.author || ""), t.setAttribute("data-citation-year", e.year || ""), t.setAttribute("data-citation-title", e.title || ""), t.setAttribute("data-citation-source", e.source || ""), t.setAttribute("data-citation-url", e.url || ""), t.setAttribute("data-citation-note", e.note || ""), t.setAttribute("contenteditable", "false"), t.setAttribute("tabindex", "0"), t.setAttribute("role", "doc-biblioref"), t.setAttribute("data-style", n), t.textContent = Ft(e, n);
170
+ function Et(t, e, n) {
171
+ t.classList.add("rte-citation-ref"), t.setAttribute("data-citation-id", e.id), t.setAttribute("data-citation-author", e.author || ""), t.setAttribute("data-citation-year", e.year || ""), t.setAttribute("data-citation-title", e.title || ""), t.setAttribute("data-citation-source", e.source || ""), t.setAttribute("data-citation-url", e.url || ""), t.setAttribute("data-citation-note", e.note || ""), t.setAttribute("contenteditable", "false"), t.setAttribute("tabindex", "0"), t.setAttribute("role", "doc-biblioref"), t.setAttribute("data-style", n), t.textContent = _t(e, n);
172
172
  }
173
173
  function it(t, e, n) {
174
174
  const i = lt(t);
@@ -184,10 +184,10 @@ function N(t, e) {
184
184
  const n = T.get(t);
185
185
  return n && L.includes(n) ? n : e?.defaultStyle || "apa";
186
186
  }
187
- function K(t, e) {
187
+ function j(t, e) {
188
188
  const n = R(t), i = /* @__PURE__ */ new Map();
189
189
  return n.forEach((o) => {
190
- const r = wt(o, e);
190
+ const r = vt(o, e);
191
191
  if (!r) return;
192
192
  if (!i.has(r.id)) {
193
193
  i.set(r.id, r);
@@ -205,8 +205,8 @@ function K(t, e) {
205
205
  });
206
206
  }), Array.from(i.values());
207
207
  }
208
- function _t(t, e, n) {
209
- const i = yt(e, n);
208
+ function qt(t, e, n) {
209
+ const i = Ct(e, n);
210
210
  if (!i.id || !i.author || !i.title) return;
211
211
  const r = (D.get(t) || []).filter((a) => a.id !== i.id);
212
212
  D.set(t, [i, ...r].slice(0, n.maxRecentCitations));
@@ -221,17 +221,17 @@ function rt(t, e, n) {
221
221
  const r = Array.from(o.values()).slice(0, n.maxRecentCitations);
222
222
  return D.set(t, r), r;
223
223
  }
224
- function Et(t, e, n, i) {
224
+ function St(t, e, n, i) {
225
225
  const o = F(i.normalizeText(e || ""));
226
226
  return o && rt(t, n, i).find((a) => a.id === o) || null;
227
227
  }
228
- function qt(t, e, n) {
228
+ function Kt(t, e, n) {
229
229
  const i = F(n.normalizeText(e || ""));
230
230
  if (!i) return !1;
231
231
  const o = D.get(t) || [], r = o.filter((a) => a.id !== i);
232
232
  return r.length === o.length ? !1 : (D.set(t, r), !0);
233
233
  }
234
- function St(t, e, n) {
234
+ function $t(t, e, n) {
235
235
  const i = document.createElement("section");
236
236
  i.className = t, i.setAttribute("data-type", e), i.setAttribute("contenteditable", "false"), i.setAttribute("aria-label", n), e === "citation-bibliography" ? i.setAttribute("role", "doc-bibliography") : e === "citation-footnotes" && i.setAttribute("role", "doc-endnotes");
237
237
  const o = document.createElement("h3");
@@ -241,22 +241,22 @@ function St(t, e, n) {
241
241
  }
242
242
  function jt(t, e) {
243
243
  let n = t.querySelector(W);
244
- n || (n = St("rte-citation-bibliography", "citation-bibliography", e.labels.bibliographyTitle), t.appendChild(n));
244
+ n || (n = $t("rte-citation-bibliography", "citation-bibliography", e.labels.bibliographyTitle), t.appendChild(n));
245
245
  const i = n.querySelector(".rte-citation-section-title");
246
246
  return i && (i.textContent = e.labels.bibliographyTitle), n.setAttribute("aria-label", e.labels.bibliographyTitle), n;
247
247
  }
248
- function Kt(t, e) {
248
+ function Ut(t, e) {
249
249
  let n = t.querySelector(G);
250
- n || (n = St("rte-citation-footnotes", "citation-footnotes", e.labels.footnotesTitle), t.appendChild(n));
250
+ n || (n = $t("rte-citation-footnotes", "citation-footnotes", e.labels.footnotesTitle), t.appendChild(n));
251
251
  const i = n.querySelector(".rte-citation-section-title");
252
252
  return i && (i.textContent = e.labels.footnotesTitle), n.setAttribute("aria-label", e.labels.footnotesTitle), n;
253
253
  }
254
- function $t(t, e) {
254
+ function At(t, e) {
255
255
  t.querySelector(e)?.remove();
256
256
  }
257
- function Ut(t, e, n, i) {
257
+ function Wt(t, e, n, i) {
258
258
  if (e.length === 0) {
259
- $t(t, W);
259
+ At(t, W);
260
260
  return;
261
261
  }
262
262
  const r = jt(t, n).querySelector(".rte-citation-list");
@@ -267,14 +267,14 @@ function Ut(t, e, n, i) {
267
267
  c.className = "rte-citation-item", c.id = `rte-citation-entry-${s.id}`, c.setAttribute("data-citation-id", s.id), c.setAttribute("data-citation-number", String(u + 1)), c.textContent = ut(s, i), a.appendChild(c);
268
268
  }), r.innerHTML = "", r.appendChild(a);
269
269
  }
270
- function Wt(t, e, n, i) {
270
+ function Gt(t, e, n, i) {
271
271
  if (!n.enableFootnoteSync || e.length === 0) {
272
- $t(t, G), R(t).forEach((l) => {
272
+ At(t, G), R(t).forEach((l) => {
273
273
  l.removeAttribute("data-footnote-number"), l.removeAttribute("data-footnote-target");
274
274
  });
275
275
  return;
276
276
  }
277
- const r = Kt(t, n).querySelector(".rte-citation-list");
277
+ const r = Ut(t, n).querySelector(".rte-citation-list");
278
278
  if (!r) return;
279
279
  const a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
280
280
  e.forEach((l, d) => {
@@ -299,21 +299,21 @@ function Wt(t, e, n, i) {
299
299
  w.className = "rte-citation-footnote-number", w.textContent = `${d + 1}. `;
300
300
  const A = document.createElement("span");
301
301
  A.className = "rte-citation-footnote-text";
302
- const It = l.note ? `${l.note}. ` : "";
303
- A.textContent = `${It}${ut(l, i)}`, m.appendChild(w), m.appendChild(A);
304
- const gt = a.get(l.id);
305
- if (gt) {
302
+ const Bt = l.note ? `${l.note}. ` : "";
303
+ A.textContent = `${Bt}${ut(l, i)}`, m.appendChild(w), m.appendChild(A);
304
+ const mt = a.get(l.id);
305
+ if (mt) {
306
306
  const _ = document.createElement("a");
307
- _.className = "rte-citation-backref", _.href = `#${gt}`, _.setAttribute("aria-label", `Back to citation ${d + 1}`), _.textContent = "Back", m.appendChild(_);
307
+ _.className = "rte-citation-backref", _.href = `#${mt}`, _.setAttribute("aria-label", `Back to citation ${d + 1}`), _.textContent = "Back", m.appendChild(_);
308
308
  }
309
309
  c.appendChild(m);
310
310
  }), r.innerHTML = "", r.appendChild(c);
311
311
  }
312
- function Gt(t, e, n, i) {
312
+ function Vt(t, e, n, i) {
313
313
  const o = ut(e, n);
314
314
  t.setAttribute("data-citation-number", String(i)), t.setAttribute("aria-label", `Citation ${i}: ${o}`);
315
315
  }
316
- function Vt(t, e, n) {
316
+ function Yt(t, e, n) {
317
317
  const i = R(t);
318
318
  let o = `${e}:${n ? "1" : "0"}:${i.length}`;
319
319
  return i.forEach((r) => {
@@ -325,7 +325,7 @@ function H(t) {
325
325
  if (!e) return;
326
326
  const n = f.get(t) || M;
327
327
  if (!n) return;
328
- const i = N(t, n), o = K(t, n), r = rt(t, o, n), a = e.querySelector(".rte-citations-status"), s = e.querySelector('[data-action="cycle-style"]'), u = e.querySelector(".rte-citations-recent-list");
328
+ const i = N(t, n), o = j(t, n), r = rt(t, o, n), a = e.querySelector(".rte-citations-status"), s = e.querySelector('[data-action="cycle-style"]'), u = e.querySelector(".rte-citations-recent-list");
329
329
  if (a) {
330
330
  const c = o.length;
331
331
  a.textContent = `${n.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${n.enableFootnoteSync ? "On" : "Off"}`;
@@ -363,12 +363,12 @@ function H(t) {
363
363
  }
364
364
  }
365
365
  function y(t, e, n = !1) {
366
- const i = N(t, e), o = Vt(t, i, e.enableFootnoteSync);
367
- if (!n && pt.get(t) === o)
368
- return K(t, e);
366
+ const i = N(t, e), o = Yt(t, i, e.enableFootnoteSync);
367
+ if (!n && ht.get(t) === o)
368
+ return j(t, e);
369
369
  const r = R(t), a = /* @__PURE__ */ new Map();
370
370
  r.forEach((c) => {
371
- const l = wt(c, e);
371
+ const l = vt(c, e);
372
372
  l && (a.has(l.id) || a.set(l.id, l));
373
373
  });
374
374
  const s = Array.from(a.values());
@@ -379,10 +379,10 @@ function y(t, e, n = !1) {
379
379
  }), r.forEach((c) => {
380
380
  const l = c.getAttribute("data-citation-id") || "", d = a.get(l);
381
381
  if (!d) return;
382
- vt(c, d, i);
382
+ Et(c, d, i);
383
383
  const m = u.get(d.id) || 1;
384
- Gt(c, d, i, Math.max(1, m));
385
- }), Ut(t, s, e, i), Wt(t, s, e, i), pt.set(t, o), H(t), t.dispatchEvent(
384
+ Vt(c, d, i, Math.max(1, m));
385
+ }), Wt(t, s, e, i), Gt(t, s, e, i), ht.set(t, o), H(t), t.dispatchEvent(
386
386
  new CustomEvent("editora:citations-refreshed", {
387
387
  bubbles: !0,
388
388
  detail: {
@@ -393,25 +393,25 @@ function y(t, e, n = !1) {
393
393
  })
394
394
  ), s;
395
395
  }
396
- function At(t) {
396
+ function kt(t) {
397
397
  const e = Q.get(t);
398
398
  typeof e == "number" && (window.clearTimeout(e), q.delete(e), Q.delete(t));
399
399
  }
400
- function kt(t) {
400
+ function Tt(t) {
401
401
  const e = f.get(t) || M;
402
402
  if (!e) return;
403
- At(t);
403
+ kt(t);
404
404
  const n = window.setTimeout(() => {
405
405
  q.delete(n), Q.delete(t), y(t, e, !1);
406
406
  }, e.debounceMs);
407
407
  q.add(n), Q.set(t, n);
408
408
  }
409
- function Yt(t) {
409
+ function Xt(t) {
410
410
  const e = window.getSelection();
411
411
  if (!e) throw new Error("Selection unavailable");
412
412
  if (e.rangeCount > 0) {
413
413
  const a = e.getRangeAt(0);
414
- if (t.contains(a.commonAncestorContainer) && !j(a.commonAncestorContainer))
414
+ if (t.contains(a.commonAncestorContainer) && !K(a.commonAncestorContainer))
415
415
  return a.cloneRange();
416
416
  }
417
417
  const n = document.createRange(), i = t.querySelector(W), o = t.querySelector(G), r = i || o;
@@ -429,7 +429,7 @@ function ft(t, e) {
429
429
  } catch {
430
430
  }
431
431
  }
432
- function Tt(t, e) {
432
+ function Mt(t, e) {
433
433
  const n = window.getSelection();
434
434
  if (!n) return;
435
435
  const i = document.createRange();
@@ -442,7 +442,7 @@ function Tt(t, e) {
442
442
  }
443
443
  i.collapse(!0), n.removeAllRanges(), n.addRange(i);
444
444
  }
445
- function Mt(t) {
445
+ function Lt(t) {
446
446
  if (t.collapsed || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1 || !(t.startContainer instanceof Element || t.startContainer instanceof DocumentFragment))
447
447
  return null;
448
448
  const e = t.startContainer.childNodes[t.startOffset];
@@ -467,7 +467,7 @@ function J(t, e, n) {
467
467
  }
468
468
  return null;
469
469
  }
470
- function Lt(t, e, n) {
470
+ function Rt(t, e, n) {
471
471
  if (!t.collapsed) return null;
472
472
  const i = (a) => a instanceof HTMLElement && a.matches(ot) ? a : null, { startContainer: o, startOffset: r } = t;
473
473
  if (o.nodeType === Node.ELEMENT_NODE) {
@@ -489,30 +489,30 @@ function Lt(t, e, n) {
489
489
  }
490
490
  function P(t, e, n) {
491
491
  const i = t.closest(S);
492
- if (!i || j(t)) return !1;
492
+ if (!i || K(t)) return !1;
493
493
  const o = t.parentNode;
494
494
  if (!o) return !1;
495
495
  const r = i.innerHTML, a = Array.from(o.childNodes).indexOf(t);
496
496
  if (a < 0) return !1;
497
497
  const s = t.nextSibling;
498
- return s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), t.remove(), Tt(o, a), y(i, n, !0), ft(i, r), dt(i), e === "Delete" && i.focus({ preventScroll: !0 }), !0;
498
+ return s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), t.remove(), Mt(o, a), y(i, n, !0), ft(i, r), dt(i), e === "Delete" && i.focus({ preventScroll: !0 }), !0;
499
499
  }
500
- function Xt(t, e, n) {
500
+ function Jt(t, e, n) {
501
501
  if (t.key !== "Backspace" && t.key !== "Delete") return !1;
502
502
  const i = t.key, o = t.target;
503
- if (o?.matches(ot) && e.contains(o) && !j(o))
503
+ if (o?.matches(ot) && e.contains(o) && !K(o))
504
504
  return t.preventDefault(), t.stopPropagation(), P(o, i, n);
505
505
  const r = window.getSelection();
506
506
  if (!r || r.rangeCount === 0) return !1;
507
507
  const a = r.getRangeAt(0);
508
- if (!e.contains(a.commonAncestorContainer) || j(a.commonAncestorContainer)) return !1;
509
- const s = Mt(a);
508
+ if (!e.contains(a.commonAncestorContainer) || K(a.commonAncestorContainer)) return !1;
509
+ const s = Lt(a);
510
510
  if (s)
511
511
  return t.preventDefault(), t.stopPropagation(), P(s, i, n);
512
- const u = Lt(a, e, i);
512
+ const u = Rt(a, e, i);
513
513
  return u ? (t.preventDefault(), t.stopPropagation(), P(u, i, n)) : !1;
514
514
  }
515
- function Rt(t, e, n) {
515
+ function Nt(t, e, n) {
516
516
  const i = F(n.normalizeText(e || ""));
517
517
  if (!i) return !1;
518
518
  const o = R(t).filter((a) => a.getAttribute("data-citation-id") === i);
@@ -523,27 +523,27 @@ function Rt(t, e, n) {
523
523
  return o.forEach((a) => {
524
524
  const s = a.nextSibling;
525
525
  s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), a.remove();
526
- }), Tt(t, t.childNodes.length), y(t, n, !0), ft(t, r), dt(t), t.focus({ preventScroll: !0 }), !0;
526
+ }), Mt(t, t.childNodes.length), y(t, n, !0), ft(t, r), dt(t), t.focus({ preventScroll: !0 }), !0;
527
527
  }
528
- function Jt(t, e) {
528
+ function Zt(t, e) {
529
529
  const n = window.getSelection();
530
530
  if (!n || n.rangeCount === 0) return !1;
531
531
  const i = n.getRangeAt(0);
532
- if (!t.contains(i.commonAncestorContainer) || j(i.commonAncestorContainer)) return !1;
533
- const o = Mt(i);
532
+ if (!t.contains(i.commonAncestorContainer) || K(i.commonAncestorContainer)) return !1;
533
+ const o = Lt(i);
534
534
  if (o)
535
535
  return P(o, "Delete", e);
536
- const r = Lt(i, t, "Backspace");
536
+ const r = Rt(i, t, "Backspace");
537
537
  return r ? P(r, "Backspace", e) : !1;
538
538
  }
539
539
  function et(t, e, n) {
540
- const i = yt(e, n);
540
+ const i = Ct(e, n);
541
541
  if (!i.author || !i.title) return !1;
542
- i.id || (i.id = Ht(t, n));
542
+ i.id || (i.id = Ft(t, n));
543
543
  const o = t.innerHTML;
544
544
  let r;
545
545
  try {
546
- r = Yt(t);
546
+ r = Xt(t);
547
547
  } catch {
548
548
  return !1;
549
549
  }
@@ -551,7 +551,7 @@ function et(t, e, n) {
551
551
  if (!a) return !1;
552
552
  r.collapsed || r.deleteContents();
553
553
  const s = document.createElement("span");
554
- vt(s, i, N(t, n));
554
+ Et(s, i, N(t, n));
555
555
  try {
556
556
  r.insertNode(s);
557
557
  } catch {
@@ -565,9 +565,9 @@ function et(t, e, n) {
565
565
  c.setStart(u.parentNode, Math.max(0, l));
566
566
  } else
567
567
  c.setStartAfter(s);
568
- return c.collapse(!0), a.removeAllRanges(), a.addRange(c), _t(t, i, n), y(t, n, !0), ft(t, o), dt(t), !0;
568
+ return c.collapse(!0), a.removeAllRanges(), a.addRange(c), qt(t, i, n), y(t, n, !0), ft(t, o), dt(t), !0;
569
569
  }
570
- function Zt(t, e) {
570
+ function Qt(t, e) {
571
571
  if (!e) return !1;
572
572
  const n = R(t).find((r) => r.getAttribute("data-citation-id") === e) || null;
573
573
  if (!n) return !1;
@@ -584,7 +584,7 @@ function U(t, e = !1) {
584
584
  const n = v.get(t);
585
585
  n && (n.classList.remove("show"), V.set(t, !1), it(t, "toggleCitationsPanel", !1), e && t.focus({ preventScroll: !0 }));
586
586
  }
587
- function Qt(t) {
587
+ function te(t) {
588
588
  v.forEach((e, n) => {
589
589
  n !== t && U(n, !1);
590
590
  });
@@ -597,7 +597,7 @@ function ct(t, e) {
597
597
  function C(t, e) {
598
598
  return t.querySelector(`[data-field="${e}"]`);
599
599
  }
600
- function te(t) {
600
+ function ee(t) {
601
601
  const e = C(t, "author")?.value || "", n = C(t, "year")?.value || "", i = C(t, "title")?.value || "", o = C(t, "source")?.value || "", r = C(t, "url")?.value || "", a = C(t, "note")?.value || "";
602
602
  return {
603
603
  author: e,
@@ -612,11 +612,11 @@ function E(t, e) {
612
612
  const n = t.querySelector(".rte-citations-live");
613
613
  n && (n.textContent = e);
614
614
  }
615
- function ee(t, e, n) {
615
+ function ne(t, e, n) {
616
616
  const i = C(e, "style");
617
617
  i && (i.value = N(t, n));
618
618
  }
619
- function Nt(t, e, n) {
619
+ function zt(t, e, n) {
620
620
  const i = L.includes(e) ? e : n.defaultStyle;
621
621
  return T.set(t, i), y(t, n, !0), i;
622
622
  }
@@ -624,10 +624,10 @@ function bt(t, e) {
624
624
  const n = N(t, e), i = L.indexOf(n), o = L[(i + 1) % L.length];
625
625
  return T.set(t, o), y(t, e, !0), o;
626
626
  }
627
- function ne(t) {
627
+ function oe(t) {
628
628
  const e = v.get(t);
629
629
  if (e) return e;
630
- const n = f.get(t) || M || Z(), i = `rte-citations-panel-${Ot++}`, o = document.createElement("section");
630
+ const n = f.get(t) || M || Z(), i = `rte-citations-panel-${Pt++}`, o = document.createElement("section");
631
631
  o.className = b, o.id = i, o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false"), o.setAttribute("aria-label", n.labels.panelAriaLabel), o.setAttribute("tabindex", "-1"), o.innerHTML = `
632
632
  <header class="rte-citations-header">
633
633
  <h2 class="rte-citations-title">${g(n.labels.panelTitle)}</h2>
@@ -697,7 +697,7 @@ function ne(t) {
697
697
  }
698
698
  if (c === "insert") {
699
699
  if ($(t)) return;
700
- const d = te(o);
700
+ const d = ee(o);
701
701
  if (!l.normalizeText(d.author) || !l.normalizeText(d.title)) {
702
702
  E(o, l.labels.invalidMessage);
703
703
  return;
@@ -718,12 +718,12 @@ function ne(t) {
718
718
  }
719
719
  if (c === "cycle-style") {
720
720
  const d = bt(t, l);
721
- ee(t, o, l), E(o, `Style changed to ${d.toUpperCase()}.`);
721
+ ne(t, o, l), E(o, `Style changed to ${d.toUpperCase()}.`);
722
722
  return;
723
723
  }
724
724
  if (c === "insert-from-recent") {
725
725
  if ($(t)) return;
726
- const d = u.getAttribute("data-citation-id") || "", m = Et(t, d, K(t, l), l);
726
+ const d = u.getAttribute("data-citation-id") || "", m = St(t, d, j(t, l), l);
727
727
  if (!m) return;
728
728
  et(t, m, l), E(o, `Inserted citation: ${m.title}.`);
729
729
  return;
@@ -731,11 +731,11 @@ function ne(t) {
731
731
  if (c === "delete-by-id") {
732
732
  if ($(t)) return;
733
733
  const d = u.getAttribute("data-citation-id") || "";
734
- if (Rt(t, d, l)) {
734
+ if (Nt(t, d, l)) {
735
735
  E(o, "Citation deleted.");
736
736
  return;
737
737
  }
738
- qt(t, d, l) && (H(t), E(o, "Removed from recent citations."));
738
+ Kt(t, d, l) && (H(t), E(o, "Removed from recent citations."));
739
739
  }
740
740
  }), o.addEventListener("keydown", (a) => {
741
741
  if (a.key === "Escape") {
@@ -755,30 +755,33 @@ function ne(t) {
755
755
  const r = C(o, "style");
756
756
  return r?.addEventListener("change", () => {
757
757
  const a = f.get(t) || M || n, s = r.value;
758
- Nt(t, s, a), E(o, `Style changed to ${s.toUpperCase()}.`);
758
+ zt(t, s, a), E(o, `Style changed to ${s.toUpperCase()}.`);
759
759
  }), tt(o, t), document.body.appendChild(o), v.set(t, o), V.set(t, !1), H(t), o;
760
760
  }
761
761
  function z(t) {
762
- const e = ne(t);
763
- Qt(t), e.classList.add("show"), V.set(t, !0), it(t, "toggleCitationsPanel", !0), tt(e, t), ct(t, e), H(t), C(e, "author")?.focus();
762
+ const e = oe(t);
763
+ te(t), e.classList.add("show"), V.set(t, !0), it(t, "toggleCitationsPanel", !0), tt(e, t), ct(t, e), H(t), C(e, "author")?.focus();
764
764
  }
765
- function zt(t, e) {
765
+ function It(t, e) {
766
766
  const n = nt(t);
767
767
  return (typeof e == "boolean" ? e : !n) ? z(t) : U(t, !1), !0;
768
768
  }
769
- function oe(t) {
770
- const e = t.key.toLowerCase();
771
- return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "c";
769
+ function gt(t) {
770
+ return typeof t.key == "string" ? t.key.toLowerCase() : "";
772
771
  }
773
772
  function ie(t) {
774
- const e = t.key.toLowerCase();
775
- return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "b";
773
+ const e = gt(t);
774
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "c";
776
775
  }
777
776
  function re(t) {
778
- const e = t.key.toLowerCase();
779
- return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "j";
777
+ const e = gt(t);
778
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "b";
780
779
  }
781
780
  function ae(t) {
781
+ const e = gt(t);
782
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "j";
783
+ }
784
+ function se(t) {
782
785
  M = t, I || (I = (e) => {
783
786
  const i = e.target?.closest(S);
784
787
  if (!i) return;
@@ -787,7 +790,7 @@ function ae(t) {
787
790
  o && (tt(o, i), ct(i, o)), it(i, "toggleCitationsPanel", nt(i));
788
791
  }, document.addEventListener("focusin", I, !0)), B || (B = (e) => {
789
792
  const i = e.target?.closest(S);
790
- i && (p = i, kt(i));
793
+ i && (p = i, Tt(i));
791
794
  }, document.addEventListener("input", B, !0)), O || (O = (e) => {
792
795
  if (e.defaultPrevented) return;
793
796
  const i = !!e.target?.closest(`.${b} input, .${b} textarea, .${b} select`), o = h(void 0, !1);
@@ -797,34 +800,34 @@ function ae(t) {
797
800
  e.preventDefault(), U(o, !0);
798
801
  return;
799
802
  }
800
- if (!i && !Xt(e, o, r)) {
801
- if (oe(e)) {
802
- e.preventDefault(), e.stopPropagation(), zt(o);
803
+ if (!i && !Jt(e, o, r)) {
804
+ if (ie(e)) {
805
+ e.preventDefault(), e.stopPropagation(), It(o);
803
806
  return;
804
807
  }
805
- if (ie(e)) {
808
+ if (re(e)) {
806
809
  e.preventDefault(), e.stopPropagation(), y(o, r, !0), z(o);
807
810
  return;
808
811
  }
809
- re(e) && (e.preventDefault(), e.stopPropagation(), bt(o, r));
812
+ ae(e) && (e.preventDefault(), e.stopPropagation(), bt(o, r));
810
813
  }
811
814
  }, document.addEventListener("keydown", O, !0)), k || (k = () => {
812
815
  v.forEach((e, n) => {
813
816
  if (!n.isConnected || !e.isConnected) {
814
- At(n), e.remove(), v.delete(n), V.delete(n);
817
+ kt(n), e.remove(), v.delete(n), V.delete(n);
815
818
  return;
816
819
  }
817
820
  tt(e, n), ct(n, e);
818
821
  });
819
822
  }, window.addEventListener("scroll", k, !0), window.addEventListener("resize", k));
820
823
  }
821
- function se() {
824
+ function ce() {
822
825
  I && (document.removeEventListener("focusin", I, !0), I = null), B && (document.removeEventListener("input", B, !0), B = null), O && (document.removeEventListener("keydown", O, !0), O = null), k && (window.removeEventListener("scroll", k, !0), window.removeEventListener("resize", k), k = null), v.forEach((t) => t.remove()), v.clear(), M = null, p = null;
823
826
  }
824
- function ce() {
825
- if (typeof document > "u" || document.getElementById(mt)) return;
827
+ function le() {
828
+ if (typeof document > "u" || document.getElementById(pt)) return;
826
829
  const t = document.createElement("style");
827
- t.id = mt, t.textContent = `
830
+ t.id = pt, t.textContent = `
828
831
  .rte-toolbar-group-items.citations,
829
832
  .editora-toolbar-group-items.citations {
830
833
  display: flex;
@@ -1294,9 +1297,9 @@ function ce() {
1294
1297
  }
1295
1298
  `, document.head.appendChild(t);
1296
1299
  }
1297
- const le = (t = {}) => {
1300
+ const ue = (t = {}) => {
1298
1301
  const e = Z(t);
1299
- return ce(), {
1302
+ return le(), {
1300
1303
  name: "citations",
1301
1304
  toolbar: [
1302
1305
  {
@@ -1341,7 +1344,7 @@ const le = (t = {}) => {
1341
1344
  if (!o || $(o)) return !1;
1342
1345
  const r = f.get(o) || e;
1343
1346
  f.set(o, r), p = o;
1344
- const a = zt(o, typeof n == "boolean" ? n : void 0);
1347
+ const a = It(o, typeof n == "boolean" ? n : void 0);
1345
1348
  return nt(o) && y(o, r, !1), a;
1346
1349
  },
1347
1350
  insertCitation: (n, i) => {
@@ -1362,7 +1365,7 @@ const le = (t = {}) => {
1362
1365
  const o = h(i);
1363
1366
  if (!o || !n) return !1;
1364
1367
  const r = f.get(o) || e;
1365
- return f.set(o, r), p = o, Nt(o, n, r), !0;
1368
+ return f.set(o, r), p = o, zt(o, n, r), !0;
1366
1369
  },
1367
1370
  cycleCitationStyle: (n, i) => {
1368
1371
  const o = h(i);
@@ -1373,7 +1376,7 @@ const le = (t = {}) => {
1373
1376
  getCitationRecords: (n, i) => {
1374
1377
  const o = h(i);
1375
1378
  if (!o) return !1;
1376
- const r = f.get(o) || e, a = K(o, r);
1379
+ const r = f.get(o) || e, a = j(o, r);
1377
1380
  if (typeof n == "function")
1378
1381
  try {
1379
1382
  n(a);
@@ -1406,22 +1409,22 @@ const le = (t = {}) => {
1406
1409
  },
1407
1410
  locateCitation: (n, i) => {
1408
1411
  const o = h(i);
1409
- return !o || typeof n != "string" ? !1 : Zt(o, n);
1412
+ return !o || typeof n != "string" ? !1 : Qt(o, n);
1410
1413
  },
1411
1414
  deleteCitation: (n, i) => {
1412
1415
  const o = h(i);
1413
1416
  if (!o || $(o)) return !1;
1414
1417
  const r = f.get(o) || e;
1415
- return f.set(o, r), typeof n == "string" && n.trim() ? Rt(o, n, r) : Jt(o, r);
1418
+ return f.set(o, r), typeof n == "string" && n.trim() ? Nt(o, n, r) : Zt(o, r);
1416
1419
  },
1417
1420
  insertRecentCitation: (n, i) => {
1418
1421
  const o = h(i);
1419
1422
  if (!o || $(o)) return !1;
1420
1423
  const r = f.get(o) || e;
1421
1424
  f.set(o, r);
1422
- const a = K(o, r), s = rt(o, a, r);
1425
+ const a = j(o, r), s = rt(o, a, r);
1423
1426
  if (s.length === 0) return !1;
1424
- const u = typeof n == "string" && n.trim() ? Et(o, n, a, r) : s[0];
1427
+ const u = typeof n == "string" && n.trim() ? St(o, n, a, r) : s[0];
1425
1428
  if (!u) return !1;
1426
1429
  const c = et(o, u, r);
1427
1430
  return c && z(o), c;
@@ -1438,20 +1441,20 @@ const le = (t = {}) => {
1438
1441
  init: function(i) {
1439
1442
  Y += 1;
1440
1443
  const o = this && typeof this.__pluginConfig == "object" ? Z({ ...e, ...this.__pluginConfig }) : e;
1441
- ae(o);
1444
+ se(o);
1442
1445
  const r = h(
1443
1446
  i && i.editorElement ? { editorElement: i.editorElement } : void 0,
1444
1447
  !1
1445
1448
  );
1446
- r && (p = r, f.set(r, o), T.set(r, o.defaultStyle), it(r, "toggleCitationsPanel", !1), kt(r));
1449
+ r && (p = r, f.set(r, o), T.set(r, o.defaultStyle), it(r, "toggleCitationsPanel", !1), Tt(r));
1447
1450
  },
1448
1451
  destroy: () => {
1449
1452
  Y = Math.max(0, Y - 1), !(Y > 0) && (q.forEach((n) => {
1450
1453
  window.clearTimeout(n);
1451
- }), q.clear(), se());
1454
+ }), q.clear(), ce());
1452
1455
  }
1453
1456
  };
1454
1457
  };
1455
1458
  export {
1456
- le as CitationsPlugin
1459
+ ue as CitationsPlugin
1457
1460
  };