@editora/plugins 1.0.22 → 1.1.0
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.
- package/README.md +1 -1
- package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-BwhZsI5v.js} +11 -11
- package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-CojLCp6C.mjs} +61 -53
- package/dist/MediaManagerPlugin.native-CycfjOi4.js +1841 -0
- package/dist/MediaManagerPlugin.native-DZrmcmnm.mjs +4688 -0
- package/dist/a11y-checker.cjs.js +3 -3
- package/dist/a11y-checker.esm.js +6 -4
- package/dist/anchor.cjs.js +4 -4
- package/dist/anchor.esm.js +19 -18
- package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
- package/dist/anchoredPopover-Cygmit_o.js +1 -0
- package/dist/approval-workflow.cjs.js +7 -7
- package/dist/approval-workflow.esm.js +55 -54
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +72 -67
- package/dist/blocks-library.cjs.js +18 -19
- package/dist/blocks-library.esm.js +41 -42
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +50 -50
- package/dist/code-sample.cjs.js +10 -10
- package/dist/code-sample.esm.js +4 -4
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/comments.cjs.js +23 -11
- package/dist/comments.esm.js +167 -149
- package/dist/conditional-content.cjs.js +2 -2
- package/dist/conditional-content.esm.js +2 -2
- package/dist/confirmDialog-D3S8BhIM.js +42 -0
- package/dist/confirmDialog-DR4c8j6S.mjs +87 -0
- package/dist/content-rules.cjs.js +6 -6
- package/dist/content-rules.esm.js +51 -51
- package/dist/data-binding.cjs.js +2 -2
- package/dist/data-binding.esm.js +2 -2
- package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
- package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
- package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
- package/dist/embed-iframe.cjs.js +6 -6
- package/dist/embed-iframe.esm.js +6 -6
- package/dist/emojis.cjs.js +5 -5
- package/dist/emojis.esm.js +3 -3
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +12 -12
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +172 -151
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +96 -83
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +176 -97
- package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
- package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +90 -83
- package/dist/katex-Cc3-mvOY.js +257 -0
- package/dist/katex-DoRnZ_sp.mjs +11682 -0
- package/dist/katex.min--Ws3c9be.mjs +5 -0
- package/dist/katex.min-Dk2VscxB.js +2 -0
- package/dist/link.cjs.js +3 -3
- package/dist/link.esm.js +3 -3
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +140 -52
- package/dist/math.cjs.js +14 -14
- package/dist/math.esm.js +149 -136
- package/dist/media-manager.cjs.js +1 -619
- package/dist/media-manager.esm.js +30 -1017
- package/dist/mentions.cjs.js +12 -12
- package/dist/mentions.esm.js +149 -143
- package/dist/merge-tag.cjs.js +5 -3
- package/dist/merge-tag.esm.js +5 -3
- package/dist/notify-BkbzMopb.js +32 -0
- package/dist/notify-zOp-mUOJ.mjs +59 -0
- package/dist/pii-redaction.cjs.js +1 -1
- package/dist/pii-redaction.esm.js +1 -1
- package/dist/preview.cjs.js +1 -1
- package/dist/preview.esm.js +1 -1
- package/dist/shared-config.cjs.js +1 -1
- package/dist/shared-config.esm.js +14 -14
- package/dist/slash-commands.cjs.js +5 -5
- package/dist/slash-commands.esm.js +259 -236
- package/dist/smart-paste.cjs.js +1 -1
- package/dist/smart-paste.esm.js +1 -1
- package/dist/special-characters.cjs.js +3 -3
- package/dist/special-characters.esm.js +3 -3
- package/dist/spell-check.cjs.js +9 -9
- package/dist/spell-check.esm.js +288 -251
- package/dist/table.cjs.js +14 -14
- package/dist/table.esm.js +175 -154
- package/dist/template.cjs.js +5 -3
- package/dist/template.esm.js +15 -13
- package/dist/text-color.cjs.js +4 -4
- package/dist/text-color.esm.js +38 -34
- package/dist/translation-workflow.cjs.js +9 -9
- package/dist/translation-workflow.esm.js +98 -95
- package/dist/version-diff.cjs.js +4 -4
- package/dist/version-diff.esm.js +36 -36
- package/index.d.ts +183 -2
- package/package.json +6 -5
- package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
- package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
- package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
- package/dist/dialogHelpers-zU6zpMIA.js +0 -12
|
@@ -19,8 +19,8 @@ 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(), I = /* @__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, je = 0, ke = 0, M = null,
|
|
23
|
-
function
|
|
22
|
+
let X = 0, je = 0, ke = 0, M = null, m = null, _ = null, P = null, A = null, D = null;
|
|
23
|
+
function h(e) {
|
|
24
24
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
25
25
|
}
|
|
26
26
|
function We(e) {
|
|
@@ -117,12 +117,12 @@ function $e(e, t) {
|
|
|
117
117
|
for (; r.has(u); )
|
|
118
118
|
u = `${u}-${ke++}`;
|
|
119
119
|
r.add(u);
|
|
120
|
-
const f = (l.tags || []).map((H) => t.normalizeText(H)).filter(Boolean), g = (l.keywords || []).map((H) => t.normalizeText(H)).filter(Boolean),
|
|
120
|
+
const f = (l.tags || []).map((H) => t.normalizeText(H)).filter(Boolean), g = (l.keywords || []).map((H) => t.normalizeText(H)).filter(Boolean), y = t.normalizeText(l.description || ""), R = Ue(a), V = [n, y, s, ...f, ...g, R].join(" ").toLowerCase();
|
|
121
121
|
o.push({
|
|
122
122
|
id: u,
|
|
123
123
|
label: n,
|
|
124
124
|
html: a,
|
|
125
|
-
description:
|
|
125
|
+
description: y,
|
|
126
126
|
category: s,
|
|
127
127
|
categoryKey: i,
|
|
128
128
|
tags: f,
|
|
@@ -236,8 +236,8 @@ function T(e, t = !0, r = !0) {
|
|
|
236
236
|
if (a) return a;
|
|
237
237
|
}
|
|
238
238
|
if (r) {
|
|
239
|
-
if (
|
|
240
|
-
|
|
239
|
+
if (m && m.isConnected) return m;
|
|
240
|
+
m && !m.isConnected && (m = null);
|
|
241
241
|
}
|
|
242
242
|
return t ? document.querySelector(L) : null;
|
|
243
243
|
}
|
|
@@ -345,7 +345,7 @@ function Ae(e) {
|
|
|
345
345
|
function ge(e) {
|
|
346
346
|
Ae(e), tt(e), q.delete(e);
|
|
347
347
|
const t = W.get(e);
|
|
348
|
-
t && (t.abort(), W.delete(e)), j.delete(e), z.delete(e), x.get(e)?.remove(), x.delete(e), U.delete(e), b.delete(e), J.delete(e), w.delete(e), I.delete(e), O.delete(e), oe.delete(e),
|
|
348
|
+
t && (t.abort(), W.delete(e)), j.delete(e), z.delete(e), x.get(e)?.remove(), x.delete(e), U.delete(e), b.delete(e), J.delete(e), w.delete(e), I.delete(e), O.delete(e), oe.delete(e), m === e && (m = null);
|
|
349
349
|
}
|
|
350
350
|
function rt(e) {
|
|
351
351
|
for (let t = 0; t < e.length; t += 1) {
|
|
@@ -431,7 +431,7 @@ function v(e) {
|
|
|
431
431
|
const c = t.querySelector('[data-field="category"]');
|
|
432
432
|
if (c) {
|
|
433
433
|
const C = ot(e, r);
|
|
434
|
-
c.innerHTML = C.map((p) => `<option value="${
|
|
434
|
+
c.innerHTML = C.map((p) => `<option value="${h(p.value)}">${h(p.label)}</option>`).join(""), C.some((p) => p.value === o.category) || (o.category = "all"), c.value = o.category;
|
|
435
435
|
}
|
|
436
436
|
const u = t.querySelector(".rte-blocks-library-helper");
|
|
437
437
|
u && (u.textContent = r.labels.helperText);
|
|
@@ -439,11 +439,11 @@ function v(e) {
|
|
|
439
439
|
f && f.setAttribute("aria-label", r.labels.resultsListLabel);
|
|
440
440
|
const g = t.querySelector(".rte-blocks-library-shortcut");
|
|
441
441
|
g && (g.textContent = r.labels.shortcutText);
|
|
442
|
-
const
|
|
443
|
-
if (
|
|
444
|
-
|
|
442
|
+
const y = t.querySelector('[data-action="insert-selected"]');
|
|
443
|
+
if (y) {
|
|
444
|
+
y.textContent = r.labels.insertText;
|
|
445
445
|
const C = !Se(e) && !!o.selectedBlockId;
|
|
446
|
-
|
|
446
|
+
y.disabled = !C, y.setAttribute("aria-disabled", C ? "false" : "true");
|
|
447
447
|
}
|
|
448
448
|
const R = t.querySelector(".rte-blocks-library-empty"), V = t.querySelector(".rte-blocks-library-list"), H = Ie(e, r);
|
|
449
449
|
nt(e, H);
|
|
@@ -457,19 +457,18 @@ function v(e) {
|
|
|
457
457
|
<button
|
|
458
458
|
type="button"
|
|
459
459
|
class="rte-blocks-library-item${ie ? " active" : ""}"
|
|
460
|
-
data-block-id="${
|
|
460
|
+
data-block-id="${h(p.id)}"
|
|
461
461
|
role="option"
|
|
462
462
|
aria-selected="${ie ? "true" : "false"}"
|
|
463
|
-
aria-label="${m(p.label)}"
|
|
464
463
|
tabindex="${ie ? "0" : "-1"}"
|
|
465
464
|
>
|
|
466
465
|
<span class="rte-blocks-library-item-head">
|
|
467
|
-
<span class="rte-blocks-library-item-label">${
|
|
468
|
-
${De ? `<span class="rte-blocks-library-recent-pill">${
|
|
466
|
+
<span class="rte-blocks-library-item-label">${h(p.label)}</span>
|
|
467
|
+
${De ? `<span class="rte-blocks-library-recent-pill">${h(r.labels.recentHeading)}</span>` : ""}
|
|
469
468
|
</span>
|
|
470
|
-
<span class="rte-blocks-library-item-meta">${
|
|
471
|
-
${p.description ? `<span class="rte-blocks-library-item-description">${
|
|
472
|
-
${me ? `<span class="rte-blocks-library-item-preview">${
|
|
469
|
+
<span class="rte-blocks-library-item-meta">${h(p.category)}${h(Pe)}</span>
|
|
470
|
+
${p.description ? `<span class="rte-blocks-library-item-description">${h(p.description)}</span>` : ""}
|
|
471
|
+
${me ? `<span class="rte-blocks-library-item-preview">${h(me)}</span>` : ""}
|
|
473
472
|
</button>
|
|
474
473
|
</li>
|
|
475
474
|
`;
|
|
@@ -640,19 +639,19 @@ function dt(e) {
|
|
|
640
639
|
const r = b.get(e) || M || Q(), o = k(e, r), l = `rte-blocks-library-panel-${je++}`, n = `${l}-query`, a = `${l}-category`, s = document.createElement("section");
|
|
641
640
|
return s.className = d, s.id = l, s.setAttribute("role", "dialog"), s.setAttribute("aria-modal", "false"), s.setAttribute("aria-label", r.labels.panelAriaLabel), s.innerHTML = `
|
|
642
641
|
<header class="rte-blocks-library-header">
|
|
643
|
-
<h2 class="rte-blocks-library-title">${
|
|
644
|
-
<button type="button" class="rte-blocks-library-icon-btn" data-action="close" aria-label="${
|
|
642
|
+
<h2 class="rte-blocks-library-title">${h(r.labels.panelTitle)}</h2>
|
|
643
|
+
<button type="button" class="rte-blocks-library-icon-btn" data-action="close" aria-label="${h(r.labels.closeText)}">✕</button>
|
|
645
644
|
</header>
|
|
646
645
|
<div class="rte-blocks-library-body">
|
|
647
|
-
<label class="rte-blocks-library-search-label" for="${
|
|
648
|
-
<input id="${
|
|
649
|
-
<label class="rte-blocks-library-category-label" for="${
|
|
650
|
-
<select id="${
|
|
646
|
+
<label class="rte-blocks-library-search-label" for="${h(n)}"></label>
|
|
647
|
+
<input id="${h(n)}" class="rte-blocks-library-input" type="text" data-field="query" autocomplete="off" />
|
|
648
|
+
<label class="rte-blocks-library-category-label" for="${h(a)}"></label>
|
|
649
|
+
<select id="${h(a)}" class="rte-blocks-library-select" data-field="category"></select>
|
|
651
650
|
<p class="rte-blocks-library-status" aria-live="polite"></p>
|
|
652
651
|
<p class="rte-blocks-library-helper"></p>
|
|
653
652
|
<p class="rte-blocks-library-last-inserted" hidden></p>
|
|
654
653
|
<div class="rte-blocks-library-list-wrap">
|
|
655
|
-
<ul class="rte-blocks-library-list" role="listbox" aria-label="${
|
|
654
|
+
<ul class="rte-blocks-library-list" role="listbox" aria-label="${h(r.labels.resultsListLabel)}"></ul>
|
|
656
655
|
<p class="rte-blocks-library-empty" hidden></p>
|
|
657
656
|
</div>
|
|
658
657
|
<div class="rte-blocks-library-actions">
|
|
@@ -664,12 +663,12 @@ function dt(e) {
|
|
|
664
663
|
`, s.addEventListener("click", (i) => {
|
|
665
664
|
const c = i.target, u = c?.closest("[data-action]");
|
|
666
665
|
if (u) {
|
|
667
|
-
const
|
|
668
|
-
if (
|
|
666
|
+
const y = u.getAttribute("data-action");
|
|
667
|
+
if (y === "close") {
|
|
669
668
|
S(e, !0);
|
|
670
669
|
return;
|
|
671
670
|
}
|
|
672
|
-
if (
|
|
671
|
+
if (y === "insert-selected") {
|
|
673
672
|
if (!o.selectedBlockId) return;
|
|
674
673
|
F(e, o.selectedBlockId) && S(e, !0);
|
|
675
674
|
}
|
|
@@ -742,8 +741,8 @@ async function be(e, t) {
|
|
|
742
741
|
if (s.signal.aborted || z.get(e) !== i) return;
|
|
743
742
|
const g = $e(f || [], r);
|
|
744
743
|
I.set(e, g), O.set(e, Date.now());
|
|
745
|
-
const
|
|
746
|
-
|
|
744
|
+
const y = w.get(e);
|
|
745
|
+
y && (y.loading = !1, y.loadError = null, y.filterCache.clear());
|
|
747
746
|
}).catch(() => {
|
|
748
747
|
if (s.signal.aborted || z.get(e) !== i) return;
|
|
749
748
|
const u = w.get(e);
|
|
@@ -770,7 +769,7 @@ function pt(e) {
|
|
|
770
769
|
const o = t.target?.closest(L);
|
|
771
770
|
if (!o) return;
|
|
772
771
|
const l = b.get(o) || e;
|
|
773
|
-
k(o, l), b.set(o, l),
|
|
772
|
+
k(o, l), b.set(o, l), m = o, N(o);
|
|
774
773
|
const n = x.get(o);
|
|
775
774
|
n && (re(n, o), ue(o, n), v(o));
|
|
776
775
|
}, document.addEventListener("focusin", _, !0)), P || (P = (t) => {
|
|
@@ -786,7 +785,7 @@ function pt(e) {
|
|
|
786
785
|
const l = Ze(t);
|
|
787
786
|
if (!l) return;
|
|
788
787
|
const n = b.get(l) || M || e;
|
|
789
|
-
if (k(l, n), b.set(l, n),
|
|
788
|
+
if (k(l, n), b.set(l, n), m = l, t.key === "Escape" && pe(l)) {
|
|
790
789
|
t.preventDefault(), S(l, !0);
|
|
791
790
|
return;
|
|
792
791
|
}
|
|
@@ -807,7 +806,7 @@ function pt(e) {
|
|
|
807
806
|
}));
|
|
808
807
|
}
|
|
809
808
|
function mt() {
|
|
810
|
-
_ && (document.removeEventListener("focusin", _, !0), _ = null), P && (document.removeEventListener("keydown", P, !0), P = null), A && (window.removeEventListener("scroll", A, !0), window.removeEventListener("resize", A), A = null), D && (D.disconnect(), D = null), x.forEach((t) => t.remove()), x.clear(), Array.from(oe).forEach((t) => ge(t)), M = null,
|
|
809
|
+
_ && (document.removeEventListener("focusin", _, !0), _ = null), P && (document.removeEventListener("keydown", P, !0), P = null), A && (window.removeEventListener("scroll", A, !0), window.removeEventListener("resize", A), A = null), D && (D.disconnect(), D = null), x.forEach((t) => t.remove()), x.clear(), Array.from(oe).forEach((t) => ge(t)), M = null, m = null;
|
|
811
810
|
}
|
|
812
811
|
function yt() {
|
|
813
812
|
if (typeof document > "u" || document.getElementById(he)) return;
|
|
@@ -1116,7 +1115,7 @@ function yt() {
|
|
|
1116
1115
|
.rte-blocks-library-item-preview {
|
|
1117
1116
|
font-size: 11px;
|
|
1118
1117
|
line-height: 1.3;
|
|
1119
|
-
color: #
|
|
1118
|
+
color: #475569;
|
|
1120
1119
|
}
|
|
1121
1120
|
|
|
1122
1121
|
.rte-blocks-library-item-preview {
|
|
@@ -1140,7 +1139,7 @@ function yt() {
|
|
|
1140
1139
|
.rte-blocks-library-empty {
|
|
1141
1140
|
margin: 8px;
|
|
1142
1141
|
font-size: 12px;
|
|
1143
|
-
color: #
|
|
1142
|
+
color: #475569;
|
|
1144
1143
|
}
|
|
1145
1144
|
|
|
1146
1145
|
.rte-blocks-library-actions {
|
|
@@ -1245,19 +1244,19 @@ const ht = (e = {}) => {
|
|
|
1245
1244
|
const n = T(l, !1, !1);
|
|
1246
1245
|
if (!n) return !1;
|
|
1247
1246
|
const a = b.get(n) || t;
|
|
1248
|
-
return k(n, a), b.set(n, a),
|
|
1247
|
+
return k(n, a), b.set(n, a), m = n, de(n), !0;
|
|
1249
1248
|
},
|
|
1250
1249
|
openBlocksLibraryPanel: (o, l) => {
|
|
1251
1250
|
const n = T(l, !1, !1);
|
|
1252
1251
|
if (!n) return !1;
|
|
1253
1252
|
const a = b.get(n) || t;
|
|
1254
|
-
return k(n, a), b.set(n, a),
|
|
1253
|
+
return k(n, a), b.set(n, a), m = n, de(n), !0;
|
|
1255
1254
|
},
|
|
1256
1255
|
toggleBlocksLibraryPanel: (o, l) => {
|
|
1257
1256
|
const n = T(l, !1, !1);
|
|
1258
1257
|
if (!n) return !1;
|
|
1259
1258
|
const a = b.get(n) || t;
|
|
1260
|
-
return k(n, a), b.set(n, a),
|
|
1259
|
+
return k(n, a), b.set(n, a), m = n, Re(n, typeof o == "boolean" ? o : void 0);
|
|
1261
1260
|
},
|
|
1262
1261
|
insertBlockSnippet: (o, l) => {
|
|
1263
1262
|
const n = T(l, !1, !1);
|
|
@@ -1265,13 +1264,13 @@ const ht = (e = {}) => {
|
|
|
1265
1264
|
const a = b.get(n) || t;
|
|
1266
1265
|
k(n, a), b.set(n, a);
|
|
1267
1266
|
const s = typeof o == "string" ? o : o?.id;
|
|
1268
|
-
return s ? (
|
|
1267
|
+
return s ? (m = n, F(n, s)) : !1;
|
|
1269
1268
|
},
|
|
1270
1269
|
insertLastBlockSnippet: (o, l) => {
|
|
1271
1270
|
const n = T(l, !1, !1);
|
|
1272
1271
|
if (!n) return !1;
|
|
1273
1272
|
const a = b.get(n) || t;
|
|
1274
|
-
return k(n, a), b.set(n, a),
|
|
1273
|
+
return k(n, a), b.set(n, a), m = n, qe(n);
|
|
1275
1274
|
},
|
|
1276
1275
|
refreshBlocksLibraryData: (o, l) => {
|
|
1277
1276
|
const n = T(l, !1, !1);
|
|
@@ -1332,7 +1331,7 @@ const ht = (e = {}) => {
|
|
|
1332
1331
|
!1,
|
|
1333
1332
|
!1
|
|
1334
1333
|
);
|
|
1335
|
-
s && (
|
|
1334
|
+
s && (m = s, r.add(s), k(s, a), b.set(s, a), J.set(s, n), I.set(s, a.blocks), O.set(s, Date.now()), N(s));
|
|
1336
1335
|
},
|
|
1337
1336
|
destroy: () => {
|
|
1338
1337
|
r.forEach((o) => ge(o)), r.clear(), X = Math.max(0, X - 1), !(X > 0) && mt();
|
package/dist/citations.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=".rte-content, .editora-content",ht="rte-citations-styles",b="rte-citations-panel",it=".rte-citation-ref[data-citation-id]",G='.rte-citation-bibliography[data-type="citation-bibliography"]',V='.rte-citation-footnotes[data-type="citation-footnotes"]',x=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',L=["apa","mla","chicago"],Ot={panelTitle:"Citations",panelAriaLabel:"Citations panel",styleLabel:"Citation style",authorLabel:"Author",yearLabel:"Year",titleLabel:"Title",sourceLabel:"Source",urlLabel:"URL",noteLabel:"Footnote note",insertText:"Insert Citation",refreshText:"Refresh Bibliography",closeText:"Close",bibliographyTitle:"References",footnotesTitle:"Citation Notes",noCitationsText:"No citations inserted yet.",styleButtonPrefix:"Style",recentHeading:"Recent citations",deleteRecentText:"x",summaryPrefix:"Citations",invalidMessage:"Author and title are required."},f=new WeakMap,T=new WeakMap,xt=new WeakMap,H=new WeakMap,v=new Map,Y=new WeakMap,tt=new WeakMap,K=new Set;let P=null,B=null,O=null,k=null,X=0,Dt=0,st=0,M=null,p=null;function g(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ht(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function yt(t,e){const o=e(t);if(!o)return"";const i=o.match(/\d{4}/);return i?i[0]:o}function Ct(t,e){const o=e(t);return o?/^https?:\/\//i.test(o)?o:`https://${o}`:""}function _(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function wt(t,e){return{id:_(e.normalizeText(t.id||"")),author:e.normalizeText(t.author||""),year:yt(t.year||"",e.normalizeText)||void 0,title:e.normalizeText(t.title||""),source:e.normalizeText(t.source||"")||void 0,url:Ct(t.url||"",e.normalizeText)||void 0,note:e.normalizeText(t.note||"")||void 0}}function Q(t={}){const e=t.defaultStyle&&L.includes(t.defaultStyle)?t.defaultStyle:"apa",o={...Ot,...t.labels||{}};return{defaultStyle:e,enableFootnoteSync:t.enableFootnoteSync!==!1,debounceMs:Math.max(80,Number(t.debounceMs??220)),maxRecentCitations:Math.max(3,Math.min(30,Number(t.maxRecentCitations??8))),labels:o,normalizeText:t.normalizeText||Ht,generateCitationId:typeof t.generateCitationId=="function"?t.generateCitationId:void 0}}function vt(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function ut(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function J(t){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}function Ft(t){const e=ut(t);if(J(e))return!0;const o=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return J(o)?!0:J(document.documentElement)||J(document.body)}function et(t,e){t.classList.remove("rte-citations-theme-dark"),Ft(e)&&t.classList.add("rte-citations-theme-dark")}function h(t,e=!0){if(t?.contentElement instanceof HTMLElement)return t.contentElement;if(t?.editorElement instanceof HTMLElement){const n=t.editorElement;if(n.matches(E))return n;const r=n.querySelector(E);if(r instanceof HTMLElement)return r}const o=window.getSelection();if(o&&o.rangeCount>0){const n=o.getRangeAt(0).startContainer,a=vt(n)?.closest(E);if(a)return a}const i=document.activeElement;if(i){if(i.matches(E))return i;const n=i.closest(E);if(n)return n}return p&&p.isConnected?p:(p&&!p.isConnected&&(p=null),e?document.querySelector(E):null)}function $(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function j(t){const e=vt(t);return e?!!(e.closest(G)||e.closest(V)):!1}function _t(t,e){if(st+=1,e.generateCitationId){const o=e.generateCitationId({editor:t,index:st}),i=_(e.normalizeText(o||""));if(i)return i}return`cite-${Date.now().toString(36)}-${st.toString(36)}`}function ct(t){return t.map(e=>(e||"").trim()).filter(Boolean).join(" ").trim()}function qt(t,e){const o=t.author||"Unknown",i=t.year||"n.d.";return e==="mla"?`(${o} ${i})`:e==="chicago"?`(${o} ${i})`:`(${o}, ${i})`}function N(t){const e=t.trim();return!e||/[.!?]$/.test(e)?e:`${e}.`}function dt(t,e){const o=N(t.author||"Unknown"),i=t.year||"n.d.",n=t.title||"Untitled",r=(t.source||"").trim(),a=t.url||"";return ct(e==="mla"?[o,`"${N(n)}"`,r?`${r.replace(/[.,]$/,"")},`:"",`${i}.`,a]:e==="chicago"?[o,N(n),N(r),`(${i}).`,a]:[o,`(${i}).`,N(n),N(r),a])}function R(t){return Array.from(t.querySelectorAll(it)).filter(e=>!e.closest(G)&&!e.closest(V))}function St(t,e){const o=_(e.normalizeText(t.getAttribute("data-citation-id")||""));if(!o)return null;const i=e.normalizeText(t.getAttribute("data-citation-author")||""),n=e.normalizeText(t.getAttribute("data-citation-title")||"");return{id:o,author:i||"Unknown",year:yt(t.getAttribute("data-citation-year")||"",e.normalizeText)||void 0,title:n||"Untitled",source:e.normalizeText(t.getAttribute("data-citation-source")||"")||void 0,url:Ct(t.getAttribute("data-citation-url")||"",e.normalizeText)||void 0,note:e.normalizeText(t.getAttribute("data-citation-note")||"")||void 0}}function Et(t,e,o){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",o),t.textContent=qt(e,o)}function rt(t,e,o){const i=ut(t);Array.from(i.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(r=>{r.classList.toggle("active",o),r.setAttribute("data-active",o?"true":"false"),r.setAttribute("aria-pressed",o?"true":"false")})}function z(t,e){const o=T.get(t);return o&&L.includes(o)?o:e?.defaultStyle||"apa"}function U(t,e){const o=R(t),i=new Map;return o.forEach(n=>{const r=St(n,e);if(!r)return;if(!i.has(r.id)){i.set(r.id,r);return}const a=i.get(r.id);i.set(r.id,{...a,author:a.author||r.author,title:a.title||r.title,year:a.year||r.year,source:a.source||r.source,url:a.url||r.url,note:a.note||r.note})}),Array.from(i.values())}function Kt(t,e,o){const i=wt(e,o);if(!i.id||!i.author||!i.title)return;const r=(H.get(t)||[]).filter(a=>a.id!==i.id);H.set(t,[i,...r].slice(0,o.maxRecentCitations))}function at(t,e,o){const i=H.get(t)||[],n=new Map;e.slice(Math.max(0,e.length-o.maxRecentCitations)).reverse().forEach(a=>{a.id&&n.set(a.id,a)}),i.forEach(a=>{!a.id||n.has(a.id)||n.set(a.id,a)});const r=Array.from(n.values()).slice(0,o.maxRecentCitations);return H.set(t,r),r}function $t(t,e,o,i){const n=_(i.normalizeText(e||""));return n&&at(t,o,i).find(a=>a.id===n)||null}function jt(t,e,o){const i=_(o.normalizeText(e||""));if(!i)return!1;const n=H.get(t)||[],r=n.filter(a=>a.id!==i);return r.length===n.length?!1:(H.set(t,r),!0)}function At(t,e,o){const i=document.createElement("section");i.className=t,i.setAttribute("data-type",e),i.setAttribute("contenteditable","false"),i.setAttribute("aria-label",o),e==="citation-bibliography"?i.setAttribute("role","doc-bibliography"):e==="citation-footnotes"&&i.setAttribute("role","doc-endnotes");const n=document.createElement("h3");n.className="rte-citation-section-title",n.textContent=o;const r=document.createElement("ol");return r.className="rte-citation-list",r.setAttribute("role","list"),i.appendChild(n),i.appendChild(r),i}function Ut(t,e){let o=t.querySelector(G);o||(o=At("rte-citation-bibliography","citation-bibliography",e.labels.bibliographyTitle),t.appendChild(o));const i=o.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.bibliographyTitle),o.setAttribute("aria-label",e.labels.bibliographyTitle),o}function Wt(t,e){let o=t.querySelector(V);o||(o=At("rte-citation-footnotes","citation-footnotes",e.labels.footnotesTitle),t.appendChild(o));const i=o.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.footnotesTitle),o.setAttribute("aria-label",e.labels.footnotesTitle),o}function kt(t,e){t.querySelector(e)?.remove()}function Gt(t,e,o,i){if(e.length===0){kt(t,G);return}const r=Ut(t,o).querySelector(".rte-citation-list");if(!r)return;const a=document.createDocumentFragment();e.forEach((s,u)=>{const c=document.createElement("li");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=dt(s,i),a.appendChild(c)}),r.innerHTML="",r.appendChild(a)}function Vt(t,e,o,i){if(!o.enableFootnoteSync||e.length===0){kt(t,V),R(t).forEach(l=>{l.removeAttribute("data-footnote-number"),l.removeAttribute("data-footnote-target")});return}const r=Wt(t,o).querySelector(".rte-citation-list");if(!r)return;const a=new Map,s=new Map;e.forEach((l,d)=>{s.set(l.id,d+1)});const u=new Map;R(t).forEach(l=>{const d=l.getAttribute("data-citation-id")||"";if(!d||!s.has(d))return;const m=(u.get(d)||0)+1;u.set(d,m);const w=`rte-citation-ref-${d}-${m}`;l.id=w;const A=s.get(d);l.setAttribute("data-footnote-number",String(A)),l.setAttribute("data-footnote-target",`rte-citation-note-${d}`),a.has(d)||a.set(d,w)});const c=document.createDocumentFragment();e.forEach((l,d)=>{const m=document.createElement("li");m.className="rte-citation-item rte-citation-footnote-item",m.id=`rte-citation-note-${l.id}`,m.setAttribute("data-citation-id",l.id);const w=document.createElement("span");w.className="rte-citation-footnote-number",w.textContent=`${d+1}. `;const A=document.createElement("span");A.className="rte-citation-footnote-text";const Bt=l.note?`${l.note}. `:"";A.textContent=`${Bt}${dt(l,i)}`,m.appendChild(w),m.appendChild(A);const pt=a.get(l.id);if(pt){const q=document.createElement("a");q.className="rte-citation-backref",q.href=`#${pt}`,q.setAttribute("aria-label",`Back to citation ${d+1}`),q.textContent="Back",m.appendChild(q)}c.appendChild(m)}),r.innerHTML="",r.appendChild(c)}function Yt(t,e,o,i){const n=dt(e,o);t.setAttribute("data-citation-number",String(i)),t.setAttribute("aria-label",`Citation ${i}: ${n}`)}function Xt(t,e,o){const i=R(t);let n=`${e}:${o?"1":"0"}:${i.length}`;return i.forEach(r=>{n+=`|${r.getAttribute("data-citation-id")||""}`,n+=`|${r.getAttribute("data-citation-author")||""}`,n+=`|${r.getAttribute("data-citation-year")||""}`,n+=`|${r.getAttribute("data-citation-title")||""}`,n+=`|${r.getAttribute("data-citation-source")||""}`,n+=`|${r.getAttribute("data-citation-url")||""}`,n+=`|${r.getAttribute("data-citation-note")||""}`}),n}function F(t){const e=v.get(t);if(!e)return;const o=f.get(t)||M;if(!o)return;const i=z(t,o),n=U(t,o),r=at(t,n,o),a=e.querySelector(".rte-citations-status"),s=e.querySelector('[data-action="cycle-style"]'),u=e.querySelector(".rte-citations-recent-list");if(a){const c=n.length;a.textContent=`${o.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${o.enableFootnoteSync?"On":"Off"}`}if(s&&(s.textContent=`${o.labels.styleButtonPrefix}: ${i.toUpperCase()}`,s.setAttribute("aria-label",`${o.labels.styleButtonPrefix}: ${i.toUpperCase()}`)),u){if(r.length===0){u.innerHTML=`<li class="rte-citations-empty">${g(o.labels.noCitationsText)}</li>`;return}u.innerHTML=r.map(c=>`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=".rte-content, .editora-content",ht="rte-citations-styles",b="rte-citations-panel",it=".rte-citation-ref[data-citation-id]",G='.rte-citation-bibliography[data-type="citation-bibliography"]',V='.rte-citation-footnotes[data-type="citation-footnotes"]',x=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',L=["apa","mla","chicago"],Dt={panelTitle:"Citations",panelAriaLabel:"Citations panel",styleLabel:"Citation style",authorLabel:"Author",yearLabel:"Year",titleLabel:"Title",sourceLabel:"Source",urlLabel:"URL",noteLabel:"Footnote note",insertText:"Insert Citation",refreshText:"Refresh Bibliography",closeText:"Close",bibliographyTitle:"References",footnotesTitle:"Citation Notes",noCitationsText:"No citations inserted yet.",styleButtonPrefix:"Style",recentHeading:"Recent citations",deleteRecentText:"x",summaryPrefix:"Citations",invalidMessage:"Author and title are required."},f=new WeakMap,T=new WeakMap,xt=new WeakMap,H=new WeakMap,v=new Map,Y=new WeakMap,tt=new WeakMap,K=new Set;let P=null,B=null,O=null,k=null,X=0,Ht=0,st=0,M=null,p=null;function g(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ft(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function yt(t,e){const o=e(t);if(!o)return"";const i=o.match(/\d{4}/);return i?i[0]:o}function Ct(t,e){const o=e(t);return o?/^https?:\/\//i.test(o)?o:`https://${o}`:""}function _(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function wt(t,e){return{id:_(e.normalizeText(t.id||"")),author:e.normalizeText(t.author||""),year:yt(t.year||"",e.normalizeText)||void 0,title:e.normalizeText(t.title||""),source:e.normalizeText(t.source||"")||void 0,url:Ct(t.url||"",e.normalizeText)||void 0,note:e.normalizeText(t.note||"")||void 0}}function Q(t={}){const e=t.defaultStyle&&L.includes(t.defaultStyle)?t.defaultStyle:"apa",o={...Dt,...t.labels||{}};return{defaultStyle:e,enableFootnoteSync:t.enableFootnoteSync!==!1,debounceMs:Math.max(80,Number(t.debounceMs??220)),maxRecentCitations:Math.max(3,Math.min(30,Number(t.maxRecentCitations??8))),labels:o,normalizeText:t.normalizeText||Ft,generateCitationId:typeof t.generateCitationId=="function"?t.generateCitationId:void 0}}function vt(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function ut(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function J(t){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}function _t(t){const e=ut(t);if(J(e))return!0;const o=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return J(o)?!0:J(document.documentElement)||J(document.body)}function et(t,e){t.classList.remove("rte-citations-theme-dark"),_t(e)&&t.classList.add("rte-citations-theme-dark")}function h(t,e=!0){if(t?.contentElement instanceof HTMLElement)return t.contentElement;if(t?.editorElement instanceof HTMLElement){const n=t.editorElement;if(n.matches(E))return n;const r=n.querySelector(E);if(r instanceof HTMLElement)return r}const o=window.getSelection();if(o&&o.rangeCount>0){const n=o.getRangeAt(0).startContainer,a=vt(n)?.closest(E);if(a)return a}const i=document.activeElement;if(i){if(i.matches(E))return i;const n=i.closest(E);if(n)return n}return p&&p.isConnected?p:(p&&!p.isConnected&&(p=null),e?document.querySelector(E):null)}function $(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function j(t){const e=vt(t);return e?!!(e.closest(G)||e.closest(V)):!1}function qt(t,e){if(st+=1,e.generateCitationId){const o=e.generateCitationId({editor:t,index:st}),i=_(e.normalizeText(o||""));if(i)return i}return`cite-${Date.now().toString(36)}-${st.toString(36)}`}function ct(t){return t.map(e=>(e||"").trim()).filter(Boolean).join(" ").trim()}function Kt(t,e){const o=t.author||"Unknown",i=t.year||"n.d.";return e==="mla"?`(${o} ${i})`:e==="chicago"?`(${o} ${i})`:`(${o}, ${i})`}function N(t){const e=t.trim();return!e||/[.!?]$/.test(e)?e:`${e}.`}function dt(t,e){const o=N(t.author||"Unknown"),i=t.year||"n.d.",n=t.title||"Untitled",r=(t.source||"").trim(),a=t.url||"";return ct(e==="mla"?[o,`"${N(n)}"`,r?`${r.replace(/[.,]$/,"")},`:"",`${i}.`,a]:e==="chicago"?[o,N(n),N(r),`(${i}).`,a]:[o,`(${i}).`,N(n),N(r),a])}function R(t){return Array.from(t.querySelectorAll(it)).filter(e=>!e.closest(G)&&!e.closest(V))}function St(t,e){const o=_(e.normalizeText(t.getAttribute("data-citation-id")||""));if(!o)return null;const i=e.normalizeText(t.getAttribute("data-citation-author")||""),n=e.normalizeText(t.getAttribute("data-citation-title")||"");return{id:o,author:i||"Unknown",year:yt(t.getAttribute("data-citation-year")||"",e.normalizeText)||void 0,title:n||"Untitled",source:e.normalizeText(t.getAttribute("data-citation-source")||"")||void 0,url:Ct(t.getAttribute("data-citation-url")||"",e.normalizeText)||void 0,note:e.normalizeText(t.getAttribute("data-citation-note")||"")||void 0}}function Et(t,e,o){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",o),t.textContent=Kt(e,o)}function rt(t,e,o){const i=ut(t);Array.from(i.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(r=>{r.classList.toggle("active",o),r.setAttribute("data-active",o?"true":"false"),r.setAttribute("aria-pressed",o?"true":"false")})}function z(t,e){const o=T.get(t);return o&&L.includes(o)?o:e?.defaultStyle||"apa"}function U(t,e){const o=R(t),i=new Map;return o.forEach(n=>{const r=St(n,e);if(!r)return;if(!i.has(r.id)){i.set(r.id,r);return}const a=i.get(r.id);i.set(r.id,{...a,author:a.author||r.author,title:a.title||r.title,year:a.year||r.year,source:a.source||r.source,url:a.url||r.url,note:a.note||r.note})}),Array.from(i.values())}function jt(t,e,o){const i=wt(e,o);if(!i.id||!i.author||!i.title)return;const r=(H.get(t)||[]).filter(a=>a.id!==i.id);H.set(t,[i,...r].slice(0,o.maxRecentCitations))}function at(t,e,o){const i=H.get(t)||[],n=new Map;e.slice(Math.max(0,e.length-o.maxRecentCitations)).reverse().forEach(a=>{a.id&&n.set(a.id,a)}),i.forEach(a=>{!a.id||n.has(a.id)||n.set(a.id,a)});const r=Array.from(n.values()).slice(0,o.maxRecentCitations);return H.set(t,r),r}function $t(t,e,o,i){const n=_(i.normalizeText(e||""));return n&&at(t,o,i).find(a=>a.id===n)||null}function Ut(t,e,o){const i=_(o.normalizeText(e||""));if(!i)return!1;const n=H.get(t)||[],r=n.filter(a=>a.id!==i);return r.length===n.length?!1:(H.set(t,r),!0)}function At(t,e,o){const i=document.createElement("section");i.className=t,i.setAttribute("data-type",e),i.setAttribute("contenteditable","false"),i.setAttribute("aria-label",o),e==="citation-bibliography"?i.setAttribute("role","doc-bibliography"):e==="citation-footnotes"&&i.setAttribute("role","doc-endnotes");const n=document.createElement("h3");n.className="rte-citation-section-title",n.textContent=o;const r=document.createElement("ol");return r.className="rte-citation-list",r.setAttribute("role","list"),i.appendChild(n),i.appendChild(r),i}function Wt(t,e){let o=t.querySelector(G);o||(o=At("rte-citation-bibliography","citation-bibliography",e.labels.bibliographyTitle),t.appendChild(o));const i=o.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.bibliographyTitle),o.setAttribute("aria-label",e.labels.bibliographyTitle),o}function Gt(t,e){let o=t.querySelector(V);o||(o=At("rte-citation-footnotes","citation-footnotes",e.labels.footnotesTitle),t.appendChild(o));const i=o.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.footnotesTitle),o.setAttribute("aria-label",e.labels.footnotesTitle),o}function kt(t,e){t.querySelector(e)?.remove()}function Vt(t,e,o,i){if(e.length===0){kt(t,G);return}const r=Wt(t,o).querySelector(".rte-citation-list");if(!r)return;const a=document.createDocumentFragment();e.forEach((s,u)=>{const c=document.createElement("li");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=dt(s,i),a.appendChild(c)}),r.innerHTML="",r.appendChild(a)}function Yt(t,e,o,i){if(!o.enableFootnoteSync||e.length===0){kt(t,V),R(t).forEach(l=>{l.removeAttribute("data-footnote-number"),l.removeAttribute("data-footnote-target")});return}const r=Gt(t,o).querySelector(".rte-citation-list");if(!r)return;const a=new Map,s=new Map;e.forEach((l,d)=>{s.set(l.id,d+1)});const u=new Map;R(t).forEach(l=>{const d=l.getAttribute("data-citation-id")||"";if(!d||!s.has(d))return;const m=(u.get(d)||0)+1;u.set(d,m);const w=`rte-citation-ref-${d}-${m}`;l.id=w;const A=s.get(d);l.setAttribute("data-footnote-number",String(A)),l.setAttribute("data-footnote-target",`rte-citation-note-${d}`),a.has(d)||a.set(d,w)});const c=document.createDocumentFragment();e.forEach((l,d)=>{const m=document.createElement("li");m.className="rte-citation-item rte-citation-footnote-item",m.id=`rte-citation-note-${l.id}`,m.setAttribute("data-citation-id",l.id);const w=document.createElement("span");w.className="rte-citation-footnote-number",w.textContent=`${d+1}. `;const A=document.createElement("span");A.className="rte-citation-footnote-text";const Ot=l.note?`${l.note}. `:"";A.textContent=`${Ot}${dt(l,i)}`,m.appendChild(w),m.appendChild(A);const pt=a.get(l.id);if(pt){const q=document.createElement("a");q.className="rte-citation-backref",q.href=`#${pt}`,q.setAttribute("aria-label",`Back to citation ${d+1}`),q.textContent="Back",m.appendChild(q)}c.appendChild(m)}),r.innerHTML="",r.appendChild(c)}function Xt(t,e,o,i){const n=dt(e,o);t.setAttribute("data-citation-number",String(i)),t.setAttribute("aria-label",`Citation ${i}: ${n}`)}function Jt(t,e,o){const i=R(t);let n=`${e}:${o?"1":"0"}:${i.length}`;return i.forEach(r=>{n+=`|${r.getAttribute("data-citation-id")||""}`,n+=`|${r.getAttribute("data-citation-author")||""}`,n+=`|${r.getAttribute("data-citation-year")||""}`,n+=`|${r.getAttribute("data-citation-title")||""}`,n+=`|${r.getAttribute("data-citation-source")||""}`,n+=`|${r.getAttribute("data-citation-url")||""}`,n+=`|${r.getAttribute("data-citation-note")||""}`}),n}function F(t){const e=v.get(t);if(!e)return;const o=f.get(t)||M;if(!o)return;const i=z(t,o),n=U(t,o),r=at(t,n,o),a=e.querySelector(".rte-citations-status"),s=e.querySelector('[data-action="cycle-style"]'),u=e.querySelector(".rte-citations-recent-list");if(a){const c=n.length;a.textContent=`${o.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${o.enableFootnoteSync?"On":"Off"}`}if(It(t,e,o),s&&(s.textContent=`${o.labels.styleButtonPrefix}: ${i.toUpperCase()}`,s.setAttribute("aria-label",`${o.labels.styleButtonPrefix}: ${i.toUpperCase()}`)),u){if(r.length===0){u.innerHTML=`<li class="rte-citations-empty">${g(o.labels.noCitationsText)}</li>`;return}u.innerHTML=r.map(c=>`
|
|
2
2
|
<li class="rte-citations-recent-item">
|
|
3
3
|
<div class="rte-citations-recent-row">
|
|
4
4
|
<button
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
>${g(o.labels.deleteRecentText)}</button>
|
|
21
21
|
</div>
|
|
22
22
|
</li>
|
|
23
|
-
`).join("")}}function y(t,e,o=!1){const i=z(t,e),n=
|
|
23
|
+
`).join("")}}function y(t,e,o=!1){const i=z(t,e),n=Jt(t,i,e.enableFootnoteSync);if(!o&&xt.get(t)===n)return U(t,e);const r=R(t),a=new Map;r.forEach(c=>{const l=St(c,e);l&&(a.has(l.id)||a.set(l.id,l))});const s=Array.from(a.values());at(t,s,e);const u=new Map;return s.forEach((c,l)=>{u.set(c.id,l+1)}),r.forEach(c=>{const l=c.getAttribute("data-citation-id")||"",d=a.get(l);if(!d)return;Et(c,d,i);const m=u.get(d.id)||1;Xt(c,d,i,Math.max(1,m))}),Vt(t,s,e,i),Yt(t,s,e,i),xt.set(t,n),F(t),t.dispatchEvent(new CustomEvent("editora:citations-refreshed",{bubbles:!0,detail:{citations:s,style:i,footnoteSync:e.enableFootnoteSync}})),s}function Tt(t){const e=tt.get(t);typeof e=="number"&&(window.clearTimeout(e),K.delete(e),tt.delete(t))}function Mt(t){const e=f.get(t)||M;if(!e)return;Tt(t);const o=window.setTimeout(()=>{K.delete(o),tt.delete(t),y(t,e,!1)},e.debounceMs);K.add(o),tt.set(t,o)}function Zt(t){const e=window.getSelection();if(!e)throw new Error("Selection unavailable");if(e.rangeCount>0){const a=e.getRangeAt(0);if(t.contains(a.commonAncestorContainer)&&!j(a.commonAncestorContainer))return a.cloneRange()}const o=document.createRange(),i=t.querySelector(G),n=t.querySelector(V),r=i||n;return r?(o.setStartBefore(r),o.collapse(!0),o):(o.selectNodeContents(t),o.collapse(!1),o)}function ft(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function bt(t,e){if(e===t.innerHTML)return;const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",t,e,t.innerHTML)}catch{}}function Lt(t,e){const o=window.getSelection();if(!o)return;const i=document.createRange();if(t.nodeType===Node.TEXT_NODE){const n=t,r=Math.max(0,Math.min(e,n.length));i.setStart(n,r)}else{const n=t.childNodes.length,r=Math.max(0,Math.min(e,n));i.setStart(t,r)}i.collapse(!0),o.removeAllRanges(),o.addRange(i)}function Rt(t){if(t.collapsed||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1||!(t.startContainer instanceof Element||t.startContainer instanceof DocumentFragment))return null;const e=t.startContainer.childNodes[t.startOffset];return!(e instanceof HTMLElement)||!e.matches(it)?null:e}function Z(t,e,o){const{startContainer:i,startOffset:n}=t;if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(o==="previous"){if(n>0)return a.childNodes[n-1]||null}else if(n<a.childNodes.length)return a.childNodes[n]||null}if(i.nodeType===Node.TEXT_NODE&&(o==="previous"&&n<i.data.length||o==="next"&&n>0))return null;let r=i;for(;r&&r!==e;){const a=o==="previous"?r.previousSibling:r.nextSibling;if(a)return a;r=r.parentNode}return null}function zt(t,e,o){if(!t.collapsed)return null;const i=a=>a instanceof HTMLElement&&a.matches(it)?a:null,{startContainer:n,startOffset:r}=t;if(n.nodeType===Node.ELEMENT_NODE){const a=n;return o==="Backspace"&&r>0?i(a.childNodes[r-1]||null):o==="Delete"?i(a.childNodes[r]||null):null}if(n.nodeType===Node.TEXT_NODE){const a=n;if(o==="Backspace"&&r===0){const s=i(a.previousSibling);return s||i(Z(t,e,"previous"))}if(o==="Delete"&&r===a.data.length){const s=i(a.nextSibling);return s||i(Z(t,e,"next"))}}return i(o==="Backspace"?Z(t,e,"previous"):Z(t,e,"next"))}function D(t,e,o){const i=t.closest(E);if(!i||j(t))return!1;const n=t.parentNode;if(!n)return!1;const r=i.innerHTML,a=Array.from(n.childNodes).indexOf(t);if(a<0)return!1;const s=t.nextSibling;return s instanceof Text&&(s.data===" "?s.remove():s.data.startsWith(" ")&&(s.data=s.data.slice(1))),t.remove(),Lt(n,a),y(i,o,!0),bt(i,r),ft(i),e==="Delete"&&i.focus({preventScroll:!0}),!0}function Qt(t,e,o){if(t.key!=="Backspace"&&t.key!=="Delete")return!1;const i=t.key,n=t.target;if(n?.matches(it)&&e.contains(n)&&!j(n))return t.preventDefault(),t.stopPropagation(),D(n,i,o);const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const a=r.getRangeAt(0);if(!e.contains(a.commonAncestorContainer)||j(a.commonAncestorContainer))return!1;const s=Rt(a);if(s)return t.preventDefault(),t.stopPropagation(),D(s,i,o);const u=zt(a,e,i);return u?(t.preventDefault(),t.stopPropagation(),D(u,i,o)):!1}function Nt(t,e,o){const i=_(o.normalizeText(e||""));if(!i)return!1;const n=R(t).filter(a=>a.getAttribute("data-citation-id")===i);if(n.length===0)return!1;if(n.length===1)return D(n[0],"Delete",o);const r=t.innerHTML;return n.forEach(a=>{const s=a.nextSibling;s instanceof Text&&(s.data===" "?s.remove():s.data.startsWith(" ")&&(s.data=s.data.slice(1))),a.remove()}),Lt(t,t.childNodes.length),y(t,o,!0),bt(t,r),ft(t),t.focus({preventScroll:!0}),!0}function te(t,e){const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const i=o.getRangeAt(0);if(!t.contains(i.commonAncestorContainer)||j(i.commonAncestorContainer))return!1;const n=Rt(i);if(n)return D(n,"Delete",e);const r=zt(i,t,"Backspace");return r?D(r,"Backspace",e):!1}function nt(t,e,o){const i=wt(e,o);if(!i.author||!i.title)return!1;i.id||(i.id=qt(t,o));const n=t.innerHTML;let r;try{r=Zt(t)}catch{return!1}const a=window.getSelection();if(!a)return!1;r.collapsed||r.deleteContents();const s=document.createElement("span");Et(s,i,z(t,o));try{r.insertNode(s)}catch{return!1}const u=document.createTextNode(" ");s.nextSibling?s.parentNode?.insertBefore(u,s.nextSibling):s.parentNode?.appendChild(u);const c=document.createRange();if(u.parentNode){const l=Array.from(u.parentNode.childNodes).indexOf(u)+1;c.setStart(u.parentNode,Math.max(0,l))}else c.setStartAfter(s);return c.collapse(!0),a.removeAllRanges(),a.addRange(c),jt(t,i,o),y(t,o,!0),bt(t,n),ft(t),!0}function ee(t,e){if(!e)return!1;const o=R(t).find(r=>r.getAttribute("data-citation-id")===e)||null;if(!o)return!1;o.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),o.focus({preventScroll:!0});const i=window.getSelection();if(!i)return!0;const n=document.createRange();return n.selectNode(o),i.removeAllRanges(),i.addRange(n),!0}function ot(t){return Y.get(t)===!0}function W(t,e=!1){const o=v.get(t);o&&(o.classList.remove("show"),Y.set(t,!1),rt(t,"toggleCitationsPanel",!1),e&&t.focus({preventScroll:!0}))}function ne(t){v.forEach((e,o)=>{o!==t&&W(o,!1)})}function lt(t,e){if(!e.classList.contains("show"))return;const i=ut(t).getBoundingClientRect(),n=Math.min(window.innerWidth-20,380),r=Math.max(10,window.innerWidth-n-10),a=Math.min(Math.max(10,i.right-n),r),s=Math.max(10,Math.min(window.innerHeight-10-260,i.top+10));e.style.width=`${n}px`,e.style.left=`${a}px`,e.style.top=`${s}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-24)}px`}function C(t,e){return t.querySelector(`[data-field="${e}"]`)}function oe(t){const e=C(t,"author")?.value||"",o=C(t,"year")?.value||"",i=C(t,"title")?.value||"",n=C(t,"source")?.value||"",r=C(t,"url")?.value||"",a=C(t,"note")?.value||"";return{author:e,year:o,title:i,source:n,url:r,note:a}}function S(t,e,o=!1){const i=t.querySelector(".rte-citations-live");i&&(i.textContent=e);const n=t.querySelector(".rte-citations-status");n&&(n.textContent=e,n.classList.toggle("rte-citations-status-error",o))}function It(t,e,o){const i=C(e,"style");i&&(i.value=z(t,o))}function Pt(t,e,o){const i=L.includes(e)?e:o.defaultStyle;return T.set(t,i),y(t,o,!0),i}function gt(t,e){const o=z(t,e),i=L.indexOf(o),n=L[(i+1)%L.length];return T.set(t,n),y(t,e,!0),n}function ie(t){const e=v.get(t);if(e)return e;const o=f.get(t)||M||Q(),i=`rte-citations-panel-${Ht++}`,n=document.createElement("section");n.className=b,n.id=i,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","false"),n.setAttribute("aria-label",o.labels.panelAriaLabel),n.setAttribute("tabindex","-1"),n.innerHTML=`
|
|
24
24
|
<header class="rte-citations-header">
|
|
25
25
|
<h2 class="rte-citations-title">${g(o.labels.panelTitle)}</h2>
|
|
26
26
|
<button type="button" class="rte-citations-icon-btn" data-action="close" aria-label="${g(o.labels.closeText)}">✕</button>
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
<p class="rte-citations-shortcut">Shortcut: Ctrl/Cmd + Alt + Shift + C</p>
|
|
79
79
|
<span class="rte-citations-live" aria-live="polite"></span>
|
|
80
80
|
</div>
|
|
81
|
-
`,n.addEventListener("click",a=>{const s=a.target;if(!s)return;const u=s.closest("[data-action]");if(!u)return;const c=u.getAttribute("data-action")||"",l=f.get(t)||M||o;if(f.set(t,l),c==="close"){W(t,!0);return}if(c==="insert"){if($(t))return;const d=
|
|
81
|
+
`,n.addEventListener("click",a=>{const s=a.target;if(!s)return;const u=s.closest("[data-action]");if(!u)return;const c=u.getAttribute("data-action")||"",l=f.get(t)||M||o;if(f.set(t,l),c==="close"){W(t,!0);return}if(c==="insert"){if($(t))return;const d=oe(n);if(!l.normalizeText(d.author)||!l.normalizeText(d.title)){S(n,l.labels.invalidMessage,!0);return}if(!nt(t,d,l)){S(n,l.labels.invalidMessage,!0);return}S(n,"Citation inserted.");const w=C(n,"title"),A=C(n,"note");w&&(w.value=""),A&&(A.value="");return}if(c==="refresh"){const d=y(t,l,!0);S(n,`Refreshed ${d.length} citation${d.length===1?"":"s"}.`);return}if(c==="cycle-style"){const d=gt(t,l);It(t,n,l),S(n,`Style changed to ${d.toUpperCase()}.`);return}if(c==="insert-from-recent"){if($(t))return;const d=u.getAttribute("data-citation-id")||"",m=$t(t,d,U(t,l),l);if(!m)return;nt(t,m,l),S(n,`Inserted citation: ${m.title}.`);return}if(c==="delete-by-id"){if($(t))return;const d=u.getAttribute("data-citation-id")||"";if(Nt(t,d,l)){S(n,"Citation deleted.");return}Ut(t,d,l)&&(F(t),S(n,"Removed from recent citations."))}}),n.addEventListener("keydown",a=>{if(a.key==="Escape"){a.preventDefault(),W(t,!0);return}const s=a.target;if(!s||!s.matches(".rte-citations-recent-btn")||a.key!=="ArrowDown"&&a.key!=="ArrowUp")return;const u=Array.from(n.querySelectorAll(".rte-citations-recent-btn"));if(u.length===0)return;const c=u.indexOf(s);if(c<0)return;a.preventDefault();const l=a.key==="ArrowDown"?1:-1,d=(c+l+u.length)%u.length;u[d].focus()});const r=C(n,"style");return r?.addEventListener("change",()=>{const a=f.get(t)||M||o,s=r.value;Pt(t,s,a),S(n,`Style changed to ${s.toUpperCase()}.`)}),et(n,t),document.body.appendChild(n),v.set(t,n),Y.set(t,!1),F(t),n}function I(t){const e=ie(t);ne(t),e.classList.add("show"),Y.set(t,!0),rt(t,"toggleCitationsPanel",!0),et(e,t),lt(t,e),F(t),C(e,"author")?.focus()}function Bt(t,e){const o=ot(t);return(typeof e=="boolean"?e:!o)?I(t):W(t,!1),!0}function mt(t){return typeof t.key=="string"?t.key.toLowerCase():""}function re(t){const e=mt(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="c"}function ae(t){const e=mt(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="b"}function se(t){const e=mt(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="j"}function ce(t){M=t,P||(P=e=>{const i=e.target?.closest(E);if(!i)return;p=i,f.has(i)||f.set(i,t),T.has(i)||T.set(i,t.defaultStyle);const n=v.get(i);n&&(et(n,i),lt(i,n)),rt(i,"toggleCitationsPanel",ot(i))},document.addEventListener("focusin",P,!0)),B||(B=e=>{const i=e.target?.closest(E);i&&(p=i,Mt(i))},document.addEventListener("input",B,!0)),O||(O=e=>{if(e.defaultPrevented)return;const i=!!e.target?.closest(`.${b} input, .${b} textarea, .${b} select`),n=h(void 0,!1);if(!n||$(n))return;const r=f.get(n)||M||t;if(f.set(n,r),p=n,e.key==="Escape"&&ot(n)){e.preventDefault(),W(n,!0);return}if(!i&&!Qt(e,n,r)){if(re(e)){e.preventDefault(),e.stopPropagation(),Bt(n);return}if(ae(e)){e.preventDefault(),e.stopPropagation(),y(n,r,!0),I(n);return}se(e)&&(e.preventDefault(),e.stopPropagation(),gt(n,r))}},document.addEventListener("keydown",O,!0)),k||(k=()=>{v.forEach((e,o)=>{if(!o.isConnected||!e.isConnected){Tt(o),e.remove(),v.delete(o),Y.delete(o);return}et(e,o),lt(o,e)})},window.addEventListener("scroll",k,!0),window.addEventListener("resize",k))}function le(){P&&(document.removeEventListener("focusin",P,!0),P=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}function ue(){if(typeof document>"u"||document.getElementById(ht))return;const t=document.createElement("style");t.id=ht,t.textContent=`
|
|
82
82
|
.rte-toolbar-group-items.citations,
|
|
83
83
|
.editora-toolbar-group-items.citations {
|
|
84
84
|
display: flex;
|
|
@@ -570,4 +570,4 @@
|
|
|
570
570
|
max-height: 34vh;
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
|
-
`,document.head.appendChild(t)}const de=(t={})=>{const e=Q(t);return ue(),{name:"citations",toolbar:[{id:"citationsGroup",label:"Citations",type:"group",command:"citations",items:[{id:"citations",label:"Citations",command:"toggleCitationsPanel",shortcut:"Mod-Alt-Shift-c",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12M6 9h12M6 13h8M6 17h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17 14.5a2.5 2.5 0 0 1 2.5 2.5v2H15v-2a2 2 0 0 1 2-2Z" stroke="currentColor" stroke-width="1.5"/></svg>'},{id:"citationsRefresh",label:"Refresh Citations",command:"refreshCitations",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.34-5.66" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M20 4v6h-6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"citationsStyle",label:"Cycle Citation Style",command:"cycleCitationStyle",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 6h14M5 10h8M5 14h14M5 18h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="18" cy="10" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{citations:(o,i)=>{const n=h(i);if(!n||$(n))return!1;const r=f.get(n)||e;return f.set(n,r),T.set(n,z(n,r)),p=n,I(n),y(n,r,!1),!0},toggleCitationsPanel:(o,i)=>{const n=h(i);if(!n||$(n))return!1;const r=f.get(n)||e;f.set(n,r),p=n;const a=
|
|
573
|
+
`,document.head.appendChild(t)}const de=(t={})=>{const e=Q(t);return ue(),{name:"citations",toolbar:[{id:"citationsGroup",label:"Citations",type:"group",command:"citations",items:[{id:"citations",label:"Citations",command:"toggleCitationsPanel",shortcut:"Mod-Alt-Shift-c",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12M6 9h12M6 13h8M6 17h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17 14.5a2.5 2.5 0 0 1 2.5 2.5v2H15v-2a2 2 0 0 1 2-2Z" stroke="currentColor" stroke-width="1.5"/></svg>'},{id:"citationsRefresh",label:"Refresh Citations",command:"refreshCitations",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.34-5.66" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M20 4v6h-6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"citationsStyle",label:"Cycle Citation Style",command:"cycleCitationStyle",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 6h14M5 10h8M5 14h14M5 18h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="18" cy="10" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{citations:(o,i)=>{const n=h(i);if(!n||$(n))return!1;const r=f.get(n)||e;return f.set(n,r),T.set(n,z(n,r)),p=n,I(n),y(n,r,!1),!0},toggleCitationsPanel:(o,i)=>{const n=h(i);if(!n||$(n))return!1;const r=f.get(n)||e;f.set(n,r),p=n;const a=Bt(n,typeof o=="boolean"?o:void 0);return ot(n)&&y(n,r,!1),a},insertCitation:(o,i)=>{const n=h(i);if(!n||$(n)||!o||typeof o!="object")return!1;const r=f.get(n)||e;f.set(n,r),p=n;const a=nt(n,o,r);return a&&I(n),a},refreshCitations:(o,i)=>{const n=h(i);if(!n)return!1;const r=f.get(n)||e;return f.set(n,r),p=n,y(n,r,!0),I(n),!0},setCitationStyle:(o,i)=>{const n=h(i);if(!n||!o)return!1;const r=f.get(n)||e;return f.set(n,r),p=n,Pt(n,o,r),!0},cycleCitationStyle:(o,i)=>{const n=h(i);if(!n)return!1;const r=f.get(n)||e;return f.set(n,r),p=n,gt(n,r),F(n),!0},getCitationRecords:(o,i)=>{const n=h(i);if(!n)return!1;const r=f.get(n)||e,a=U(n,r);if(typeof o=="function")try{o(a)}catch{}return n.__citationRecords=a,n.dispatchEvent(new CustomEvent("editora:citations-data",{bubbles:!0,detail:{records:a,style:z(n,r)}})),!0},setCitationsOptions:(o,i)=>{const n=h(i);if(!n||!o||typeof o!="object")return!1;const r=f.get(n)||e,a=Q({...r,...o,labels:{...r.labels,...o.labels||{}},normalizeText:o.normalizeText||r.normalizeText,generateCitationId:o.generateCitationId||r.generateCitationId});return f.set(n,a),o.defaultStyle&&L.includes(o.defaultStyle)&&T.set(n,o.defaultStyle),y(n,a,!0),F(n),!0},locateCitation:(o,i)=>{const n=h(i);return!n||typeof o!="string"?!1:ee(n,o)},deleteCitation:(o,i)=>{const n=h(i);if(!n||$(n))return!1;const r=f.get(n)||e;return f.set(n,r),typeof o=="string"&&o.trim()?Nt(n,o,r):te(n,r)},insertRecentCitation:(o,i)=>{const n=h(i);if(!n||$(n))return!1;const r=f.get(n)||e;f.set(n,r);const a=U(n,r),s=at(n,a,r);if(s.length===0)return!1;const u=typeof o=="string"&&o.trim()?$t(n,o,a,r):s[0];if(!u)return!1;const c=nt(n,u,r);return c&&I(n),c}},keymap:{"Mod-Alt-Shift-c":"toggleCitationsPanel","Mod-Alt-Shift-C":"toggleCitationsPanel","Mod-Alt-Shift-b":"refreshCitations","Mod-Alt-Shift-B":"refreshCitations","Mod-Alt-Shift-j":"cycleCitationStyle","Mod-Alt-Shift-J":"cycleCitationStyle"},init:function(i){X+=1;const n=this&&typeof this.__pluginConfig=="object"?Q({...e,...this.__pluginConfig}):e;ce(n);const r=h(i&&i.editorElement?{editorElement:i.editorElement}:void 0,!1);r&&(p=r,f.set(r,n),T.set(r,n.defaultStyle),rt(r,"toggleCitationsPanel",!1),Mt(r))},destroy:()=>{X=Math.max(0,X-1),!(X>0)&&(K.forEach(o=>{window.clearTimeout(o)}),K.clear(),le())}}};exports.CitationsPlugin=de;
|