@editora/core 1.0.6 → 1.0.8

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 (60) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
  3. package/dist/ApprovalWorkflowPlugin.native-C3jtAYjG.mjs +1076 -0
  4. package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
  5. package/dist/BlocksLibraryPlugin.native-HMWKxWNs.mjs +1327 -0
  6. package/dist/CitationsPlugin.native-BnU0qCwR.mjs +1464 -0
  7. package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
  8. package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
  9. package/dist/ConditionalContentPlugin.native-CfhY46rU.mjs +1367 -0
  10. package/dist/ContentRulesPlugin.native-nBLQ8QFZ.mjs +1099 -0
  11. package/dist/DataBindingPlugin.native-jQ1JPRTp.mjs +917 -0
  12. package/dist/DocSchemaPlugin.native-CHOge18O.mjs +1325 -0
  13. package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
  14. package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
  15. package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
  16. package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
  17. package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
  18. package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
  19. package/dist/MentionPlugin.native-BMDlOqur.mjs +734 -0
  20. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
  21. package/dist/PIIRedactionPlugin.native-DcsjmtV1.mjs +1396 -0
  22. package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-DijGuHJZ.mjs} +86 -77
  23. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-WuIwOAOR.mjs} +30 -30
  24. package/dist/SlashCommandsPlugin.native-CmxvMEaE.mjs +755 -0
  25. package/dist/SmartPastePlugin.native-BOKKtF07.mjs +1398 -0
  26. package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
  27. package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
  28. package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
  29. package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
  30. package/dist/TrackChangesPlugin.native-Bghu2q4a.mjs +761 -0
  31. package/dist/TranslationWorkflowPlugin.native-Bz6jDGvj.mjs +1728 -0
  32. package/dist/VersionDiffPlugin.native-Bvxgy--t.mjs +776 -0
  33. package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
  34. package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
  35. package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
  36. package/dist/editora.min.js +13 -13
  37. package/dist/editora.umd.js +13 -13
  38. package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
  39. package/dist/index-BslAFzmv.mjs +16544 -0
  40. package/dist/index-D1LOqg5C.js +10 -0
  41. package/dist/{index-OwnkG39N.mjs → index-DqC57IEH.mjs} +438 -328
  42. package/dist/index.cjs.js +1 -1
  43. package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
  44. package/dist/index.esm.js +2 -2
  45. package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
  46. package/dist/plugin-loader.js +77 -40
  47. package/dist/webcomponent-core.js +456 -346
  48. package/dist/webcomponent-core.min.css +1 -1
  49. package/dist/webcomponent-core.min.js +87 -107
  50. package/dist/webcomponent.cjs.js +1 -1
  51. package/dist/webcomponent.esm.js +1 -1
  52. package/dist/webcomponent.js +503 -356
  53. package/dist/webcomponent.min.css +1 -1
  54. package/dist/webcomponent.min.js +6003 -658
  55. package/package.json +2 -2
  56. package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
  57. package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
  58. package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
  59. package/dist/documentManager-irzj9n3V.mjs +0 -37627
  60. package/dist/index-CqWQFb3D.js +0 -10
@@ -0,0 +1,1464 @@
1
+ const $ = ".rte-content, .editora-content", gt = "rte-citations-styles", m = "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 = {
2
+ panelTitle: "Citations",
3
+ panelAriaLabel: "Citations panel",
4
+ styleLabel: "Citation style",
5
+ authorLabel: "Author",
6
+ yearLabel: "Year",
7
+ titleLabel: "Title",
8
+ sourceLabel: "Source",
9
+ urlLabel: "URL",
10
+ noteLabel: "Footnote note",
11
+ insertText: "Insert Citation",
12
+ refreshText: "Refresh Bibliography",
13
+ closeText: "Close",
14
+ bibliographyTitle: "References",
15
+ footnotesTitle: "Citation Notes",
16
+ noCitationsText: "No citations inserted yet.",
17
+ styleButtonPrefix: "Style",
18
+ recentHeading: "Recent citations",
19
+ deleteRecentText: "x",
20
+ summaryPrefix: "Citations",
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;
24
+ function g(t) {
25
+ return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
26
+ }
27
+ function Pt(t) {
28
+ return t.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
29
+ }
30
+ function ht(t, o) {
31
+ const e = o(t);
32
+ if (!e) return "";
33
+ const i = e.match(/\d{4}/);
34
+ return i ? i[0] : e;
35
+ }
36
+ function xt(t, o) {
37
+ const e = o(t);
38
+ return e ? /^https?:\/\//i.test(e) ? e : `https://${e}` : "";
39
+ }
40
+ function F(t) {
41
+ return t.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
42
+ }
43
+ function yt(t, o) {
44
+ return {
45
+ id: F(o.normalizeText(t.id || "")),
46
+ author: o.normalizeText(t.author || ""),
47
+ year: ht(t.year || "", o.normalizeText) || void 0,
48
+ title: o.normalizeText(t.title || ""),
49
+ source: o.normalizeText(t.source || "") || void 0,
50
+ url: xt(t.url || "", o.normalizeText) || void 0,
51
+ note: o.normalizeText(t.note || "") || void 0
52
+ };
53
+ }
54
+ function Z(t = {}) {
55
+ var i, n;
56
+ const o = t.defaultStyle && L.includes(t.defaultStyle) ? t.defaultStyle : "apa", e = {
57
+ ...Bt,
58
+ ...t.labels || {}
59
+ };
60
+ return {
61
+ defaultStyle: o,
62
+ enableFootnoteSync: t.enableFootnoteSync !== !1,
63
+ debounceMs: Math.max(80, Number((i = t.debounceMs) != null ? i : 220)),
64
+ maxRecentCitations: Math.max(3, Math.min(30, Number((n = t.maxRecentCitations) != null ? n : 8))),
65
+ labels: e,
66
+ normalizeText: t.normalizeText || Pt,
67
+ generateCitationId: typeof t.generateCitationId == "function" ? t.generateCitationId : void 0
68
+ };
69
+ }
70
+ function Ct(t) {
71
+ return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
72
+ }
73
+ function lt(t) {
74
+ return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || t;
75
+ }
76
+ function X(t) {
77
+ 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;
78
+ }
79
+ function Dt(t) {
80
+ const o = lt(t);
81
+ if (X(o)) return !0;
82
+ const e = o.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
83
+ return X(e) ? !0 : X(document.documentElement) || X(document.body);
84
+ }
85
+ function tt(t, o) {
86
+ t.classList.remove("rte-citations-theme-dark"), Dt(o) && t.classList.add("rte-citations-theme-dark");
87
+ }
88
+ function h(t, o = !0) {
89
+ if ((t == null ? void 0 : t.contentElement) instanceof HTMLElement) return t.contentElement;
90
+ if ((t == null ? void 0 : t.editorElement) instanceof HTMLElement) {
91
+ const n = t.editorElement;
92
+ if (n.matches($)) return n;
93
+ const r = n.querySelector($);
94
+ if (r instanceof HTMLElement) return r;
95
+ }
96
+ const e = window.getSelection();
97
+ if (e && e.rangeCount > 0) {
98
+ const n = e.getRangeAt(0).startContainer, r = Ct(n), a = r == null ? void 0 : r.closest($);
99
+ if (a) return a;
100
+ }
101
+ const i = document.activeElement;
102
+ if (i) {
103
+ if (i.matches($)) return i;
104
+ const n = i.closest($);
105
+ if (n) return n;
106
+ }
107
+ return p && p.isConnected ? p : (p && !p.isConnected && (p = null), o ? document.querySelector($) : null);
108
+ }
109
+ function S(t) {
110
+ return t.getAttribute("contenteditable") === "false" || t.getAttribute("data-readonly") === "true";
111
+ }
112
+ function j(t) {
113
+ const o = Ct(t);
114
+ return o ? !!(o.closest(W) || o.closest(G)) : !1;
115
+ }
116
+ function Ht(t, o) {
117
+ if (at += 1, o.generateCitationId) {
118
+ const e = o.generateCitationId({ editor: t, index: at }), i = F(o.normalizeText(e || ""));
119
+ if (i) return i;
120
+ }
121
+ return `cite-${Date.now().toString(36)}-${at.toString(36)}`;
122
+ }
123
+ function st(t) {
124
+ return t.map((o) => (o || "").trim()).filter(Boolean).join(" ").trim();
125
+ }
126
+ function Ft(t, o) {
127
+ const e = t.author || "Unknown", i = t.year || "n.d.";
128
+ return o === "mla" ? `(${e} ${i})` : o === "chicago" ? `(${e} ${i})` : `(${e}, ${i})`;
129
+ }
130
+ function ut(t, o) {
131
+ const e = t.author || "Unknown", i = t.year || "n.d.", n = t.title || "Untitled", r = t.source || "", a = t.url || "";
132
+ return st(o === "mla" ? [
133
+ `${e}.`,
134
+ `"${n}."`,
135
+ r ? `${r},` : "",
136
+ `${i}.`,
137
+ a
138
+ ] : o === "chicago" ? [
139
+ `${e}.`,
140
+ `${n}.`,
141
+ r ? `${r}.` : "",
142
+ `(${i}).`,
143
+ a
144
+ ] : [
145
+ `${e}.`,
146
+ `(${i}).`,
147
+ `${n}.`,
148
+ r ? `${r}.` : "",
149
+ a
150
+ ]);
151
+ }
152
+ function R(t) {
153
+ return Array.from(t.querySelectorAll(ot)).filter(
154
+ (o) => !o.closest(W) && !o.closest(G)
155
+ );
156
+ }
157
+ function wt(t, o) {
158
+ const e = F(o.normalizeText(t.getAttribute("data-citation-id") || ""));
159
+ if (!e) return null;
160
+ const i = o.normalizeText(t.getAttribute("data-citation-author") || ""), n = o.normalizeText(t.getAttribute("data-citation-title") || "");
161
+ return {
162
+ id: e,
163
+ author: i || "Unknown",
164
+ year: ht(t.getAttribute("data-citation-year") || "", o.normalizeText) || void 0,
165
+ title: n || "Untitled",
166
+ source: o.normalizeText(t.getAttribute("data-citation-source") || "") || void 0,
167
+ url: xt(t.getAttribute("data-citation-url") || "", o.normalizeText) || void 0,
168
+ note: o.normalizeText(t.getAttribute("data-citation-note") || "") || void 0
169
+ };
170
+ }
171
+ function vt(t, o, e) {
172
+ t.classList.add("rte-citation-ref"), t.setAttribute("data-citation-id", o.id), t.setAttribute("data-citation-author", o.author || ""), t.setAttribute("data-citation-year", o.year || ""), t.setAttribute("data-citation-title", o.title || ""), t.setAttribute("data-citation-source", o.source || ""), t.setAttribute("data-citation-url", o.url || ""), t.setAttribute("data-citation-note", o.note || ""), t.setAttribute("contenteditable", "false"), t.setAttribute("tabindex", "0"), t.setAttribute("role", "doc-biblioref"), t.setAttribute("data-style", e), t.textContent = Ft(o, e);
173
+ }
174
+ function it(t, o, e) {
175
+ const i = lt(t);
176
+ Array.from(
177
+ i.querySelectorAll(
178
+ `.rte-toolbar-button[data-command="${o}"], .editora-toolbar-button[data-command="${o}"]`
179
+ )
180
+ ).forEach((r) => {
181
+ r.classList.toggle("active", e), r.setAttribute("data-active", e ? "true" : "false"), r.setAttribute("aria-pressed", e ? "true" : "false");
182
+ });
183
+ }
184
+ function N(t, o) {
185
+ const e = T.get(t);
186
+ return e && L.includes(e) ? e : (o == null ? void 0 : o.defaultStyle) || "apa";
187
+ }
188
+ function K(t, o) {
189
+ const e = R(t), i = /* @__PURE__ */ new Map();
190
+ return e.forEach((n) => {
191
+ const r = wt(n, o);
192
+ if (!r) return;
193
+ if (!i.has(r.id)) {
194
+ i.set(r.id, r);
195
+ return;
196
+ }
197
+ const a = i.get(r.id);
198
+ i.set(r.id, {
199
+ ...a,
200
+ author: a.author || r.author,
201
+ title: a.title || r.title,
202
+ year: a.year || r.year,
203
+ source: a.source || r.source,
204
+ url: a.url || r.url,
205
+ note: a.note || r.note
206
+ });
207
+ }), Array.from(i.values());
208
+ }
209
+ function _t(t, o, e) {
210
+ const i = yt(o, e);
211
+ if (!i.id || !i.author || !i.title) return;
212
+ const r = (D.get(t) || []).filter((a) => a.id !== i.id);
213
+ D.set(t, [i, ...r].slice(0, e.maxRecentCitations));
214
+ }
215
+ function rt(t, o, e) {
216
+ const i = D.get(t) || [], n = /* @__PURE__ */ new Map();
217
+ o.slice(Math.max(0, o.length - e.maxRecentCitations)).reverse().forEach((a) => {
218
+ a.id && n.set(a.id, a);
219
+ }), i.forEach((a) => {
220
+ !a.id || n.has(a.id) || n.set(a.id, a);
221
+ });
222
+ const r = Array.from(n.values()).slice(0, e.maxRecentCitations);
223
+ return D.set(t, r), r;
224
+ }
225
+ function Et(t, o, e, i) {
226
+ const n = F(i.normalizeText(o || ""));
227
+ return n && rt(t, e, i).find((a) => a.id === n) || null;
228
+ }
229
+ function qt(t, o, e) {
230
+ const i = F(e.normalizeText(o || ""));
231
+ if (!i) return !1;
232
+ const n = D.get(t) || [], r = n.filter((a) => a.id !== i);
233
+ return r.length === n.length ? !1 : (D.set(t, r), !0);
234
+ }
235
+ function $t(t, o, e) {
236
+ const i = document.createElement("section");
237
+ i.className = t, i.setAttribute("data-type", o), i.setAttribute("contenteditable", "false"), i.setAttribute("aria-label", e), o === "citation-bibliography" ? i.setAttribute("role", "doc-bibliography") : o === "citation-footnotes" && i.setAttribute("role", "doc-endnotes");
238
+ const n = document.createElement("h3");
239
+ n.className = "rte-citation-section-title", n.textContent = e;
240
+ const r = document.createElement("ol");
241
+ return r.className = "rte-citation-list", r.setAttribute("role", "list"), i.appendChild(n), i.appendChild(r), i;
242
+ }
243
+ function jt(t, o) {
244
+ let e = t.querySelector(W);
245
+ e || (e = $t("rte-citation-bibliography", "citation-bibliography", o.labels.bibliographyTitle), t.appendChild(e));
246
+ const i = e.querySelector(".rte-citation-section-title");
247
+ return i && (i.textContent = o.labels.bibliographyTitle), e.setAttribute("aria-label", o.labels.bibliographyTitle), e;
248
+ }
249
+ function Kt(t, o) {
250
+ let e = t.querySelector(G);
251
+ e || (e = $t("rte-citation-footnotes", "citation-footnotes", o.labels.footnotesTitle), t.appendChild(e));
252
+ const i = e.querySelector(".rte-citation-section-title");
253
+ return i && (i.textContent = o.labels.footnotesTitle), e.setAttribute("aria-label", o.labels.footnotesTitle), e;
254
+ }
255
+ function St(t, o) {
256
+ const e = t.querySelector(o);
257
+ e == null || e.remove();
258
+ }
259
+ function Ut(t, o, e, i) {
260
+ if (o.length === 0) {
261
+ St(t, W);
262
+ return;
263
+ }
264
+ const r = jt(t, e).querySelector(".rte-citation-list");
265
+ if (!r) return;
266
+ const a = document.createDocumentFragment();
267
+ o.forEach((s, d) => {
268
+ const c = document.createElement("li");
269
+ 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(d + 1)), c.textContent = ut(s, i), a.appendChild(c);
270
+ }), r.innerHTML = "", r.appendChild(a);
271
+ }
272
+ function Wt(t, o, e, i) {
273
+ if (!e.enableFootnoteSync || o.length === 0) {
274
+ St(t, G), R(t).forEach((l) => {
275
+ l.removeAttribute("data-footnote-number"), l.removeAttribute("data-footnote-target");
276
+ });
277
+ return;
278
+ }
279
+ const r = Kt(t, e).querySelector(".rte-citation-list");
280
+ if (!r) return;
281
+ const a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
282
+ o.forEach((l, u) => {
283
+ s.set(l.id, u + 1);
284
+ });
285
+ const d = /* @__PURE__ */ new Map();
286
+ R(t).forEach((l) => {
287
+ const u = l.getAttribute("data-citation-id") || "";
288
+ if (!u || !s.has(u)) return;
289
+ const b = (d.get(u) || 0) + 1;
290
+ d.set(u, b);
291
+ const w = `rte-citation-ref-${u}-${b}`;
292
+ l.id = w;
293
+ const A = s.get(u);
294
+ l.setAttribute("data-footnote-number", String(A)), l.setAttribute("data-footnote-target", `rte-citation-note-${u}`), a.has(u) || a.set(u, w);
295
+ });
296
+ const c = document.createDocumentFragment();
297
+ o.forEach((l, u) => {
298
+ const b = document.createElement("li");
299
+ b.className = "rte-citation-item rte-citation-footnote-item", b.id = `rte-citation-note-${l.id}`, b.setAttribute("data-citation-id", l.id);
300
+ const w = document.createElement("span");
301
+ w.className = "rte-citation-footnote-number", w.textContent = `${u + 1}. `;
302
+ const A = document.createElement("span");
303
+ A.className = "rte-citation-footnote-text";
304
+ const It = l.note ? `${l.note}. ` : "";
305
+ A.textContent = `${It}${ut(l, i)}`, b.appendChild(w), b.appendChild(A);
306
+ const mt = a.get(l.id);
307
+ if (mt) {
308
+ const _ = document.createElement("a");
309
+ _.className = "rte-citation-backref", _.href = `#${mt}`, _.setAttribute("aria-label", `Back to citation ${u + 1}`), _.textContent = "Back", b.appendChild(_);
310
+ }
311
+ c.appendChild(b);
312
+ }), r.innerHTML = "", r.appendChild(c);
313
+ }
314
+ function Gt(t, o, e, i) {
315
+ const n = ut(o, e);
316
+ t.setAttribute("data-citation-number", String(i)), t.setAttribute("aria-label", `Citation ${i}: ${n}`);
317
+ }
318
+ function Vt(t, o, e) {
319
+ const i = R(t);
320
+ let n = `${o}:${e ? "1" : "0"}:${i.length}`;
321
+ return i.forEach((r) => {
322
+ 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") || ""}`;
323
+ }), n;
324
+ }
325
+ function H(t) {
326
+ const o = v.get(t);
327
+ if (!o) return;
328
+ const e = f.get(t) || M;
329
+ if (!e) return;
330
+ const i = N(t, e), n = K(t, e), r = rt(t, n, e), a = o.querySelector(".rte-citations-status"), s = o.querySelector('[data-action="cycle-style"]'), d = o.querySelector(".rte-citations-recent-list");
331
+ if (a) {
332
+ const c = n.length;
333
+ a.textContent = `${e.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${e.enableFootnoteSync ? "On" : "Off"}`;
334
+ }
335
+ if (s && (s.textContent = `${e.labels.styleButtonPrefix}: ${i.toUpperCase()}`, s.setAttribute("aria-label", `${e.labels.styleButtonPrefix}: ${i.toUpperCase()}`)), d) {
336
+ if (r.length === 0) {
337
+ d.innerHTML = `<li class="rte-citations-empty">${g(e.labels.noCitationsText)}</li>`;
338
+ return;
339
+ }
340
+ d.innerHTML = r.map(
341
+ (c) => `
342
+ <li class="rte-citations-recent-item">
343
+ <div class="rte-citations-recent-row">
344
+ <button
345
+ type="button"
346
+ class="rte-citations-recent-btn"
347
+ data-action="insert-from-recent"
348
+ data-citation-id="${g(c.id)}"
349
+ aria-label="Insert citation: ${g(c.title)}"
350
+ >
351
+ <span class="rte-citations-recent-title">${g(c.title)}</span>
352
+ <span class="rte-citations-recent-meta">${g(c.author)}${c.year ? ` (${g(c.year)})` : ""}</span>
353
+ </button>
354
+ <button
355
+ type="button"
356
+ class="rte-citations-recent-delete"
357
+ data-action="delete-by-id"
358
+ data-citation-id="${g(c.id)}"
359
+ aria-label="Delete citation: ${g(c.title)}"
360
+ >${g(e.labels.deleteRecentText)}</button>
361
+ </div>
362
+ </li>
363
+ `
364
+ ).join("");
365
+ }
366
+ }
367
+ function y(t, o, e = !1) {
368
+ const i = N(t, o), n = Vt(t, i, o.enableFootnoteSync);
369
+ if (!e && pt.get(t) === n)
370
+ return K(t, o);
371
+ const r = R(t), a = /* @__PURE__ */ new Map();
372
+ r.forEach((c) => {
373
+ const l = wt(c, o);
374
+ l && (a.has(l.id) || a.set(l.id, l));
375
+ });
376
+ const s = Array.from(a.values());
377
+ rt(t, s, o);
378
+ const d = /* @__PURE__ */ new Map();
379
+ return s.forEach((c, l) => {
380
+ d.set(c.id, l + 1);
381
+ }), r.forEach((c) => {
382
+ const l = c.getAttribute("data-citation-id") || "", u = a.get(l);
383
+ if (!u) return;
384
+ vt(c, u, i);
385
+ const b = d.get(u.id) || 1;
386
+ Gt(c, u, i, Math.max(1, b));
387
+ }), Ut(t, s, o, i), Wt(t, s, o, i), pt.set(t, n), H(t), t.dispatchEvent(
388
+ new CustomEvent("editora:citations-refreshed", {
389
+ bubbles: !0,
390
+ detail: {
391
+ citations: s,
392
+ style: i,
393
+ footnoteSync: o.enableFootnoteSync
394
+ }
395
+ })
396
+ ), s;
397
+ }
398
+ function At(t) {
399
+ const o = Q.get(t);
400
+ typeof o == "number" && (window.clearTimeout(o), q.delete(o), Q.delete(t));
401
+ }
402
+ function kt(t) {
403
+ const o = f.get(t) || M;
404
+ if (!o) return;
405
+ At(t);
406
+ const e = window.setTimeout(() => {
407
+ q.delete(e), Q.delete(t), y(t, o, !1);
408
+ }, o.debounceMs);
409
+ q.add(e), Q.set(t, e);
410
+ }
411
+ function Yt(t) {
412
+ const o = window.getSelection();
413
+ if (!o) throw new Error("Selection unavailable");
414
+ if (o.rangeCount > 0) {
415
+ const a = o.getRangeAt(0);
416
+ if (t.contains(a.commonAncestorContainer) && !j(a.commonAncestorContainer))
417
+ return a.cloneRange();
418
+ }
419
+ const e = document.createRange(), i = t.querySelector(W), n = t.querySelector(G), r = i || n;
420
+ return r ? (e.setStartBefore(r), e.collapse(!0), e) : (e.selectNodeContents(t), e.collapse(!1), e);
421
+ }
422
+ function dt(t) {
423
+ t.dispatchEvent(new Event("input", { bubbles: !0 }));
424
+ }
425
+ function ft(t, o) {
426
+ if (o === t.innerHTML) return;
427
+ const e = window.execEditorCommand || window.executeEditorCommand;
428
+ if (typeof e == "function")
429
+ try {
430
+ e("recordDomTransaction", t, o, t.innerHTML);
431
+ } catch (i) {
432
+ }
433
+ }
434
+ function Tt(t, o) {
435
+ const e = window.getSelection();
436
+ if (!e) return;
437
+ const i = document.createRange();
438
+ if (t.nodeType === Node.TEXT_NODE) {
439
+ const n = t, r = Math.max(0, Math.min(o, n.length));
440
+ i.setStart(n, r);
441
+ } else {
442
+ const n = t.childNodes.length, r = Math.max(0, Math.min(o, n));
443
+ i.setStart(t, r);
444
+ }
445
+ i.collapse(!0), e.removeAllRanges(), e.addRange(i);
446
+ }
447
+ function Mt(t) {
448
+ if (t.collapsed || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1 || !(t.startContainer instanceof Element || t.startContainer instanceof DocumentFragment))
449
+ return null;
450
+ const o = t.startContainer.childNodes[t.startOffset];
451
+ return !(o instanceof HTMLElement) || !o.matches(ot) ? null : o;
452
+ }
453
+ function J(t, o, e) {
454
+ const { startContainer: i, startOffset: n } = t;
455
+ if (i.nodeType === Node.ELEMENT_NODE) {
456
+ const a = i;
457
+ if (e === "previous") {
458
+ if (n > 0) return a.childNodes[n - 1] || null;
459
+ } else if (n < a.childNodes.length)
460
+ return a.childNodes[n] || null;
461
+ }
462
+ if (i.nodeType === Node.TEXT_NODE && (e === "previous" && n < i.data.length || e === "next" && n > 0))
463
+ return null;
464
+ let r = i;
465
+ for (; r && r !== o; ) {
466
+ const a = e === "previous" ? r.previousSibling : r.nextSibling;
467
+ if (a) return a;
468
+ r = r.parentNode;
469
+ }
470
+ return null;
471
+ }
472
+ function Lt(t, o, e) {
473
+ if (!t.collapsed) return null;
474
+ const i = (a) => a instanceof HTMLElement && a.matches(ot) ? a : null, { startContainer: n, startOffset: r } = t;
475
+ if (n.nodeType === Node.ELEMENT_NODE) {
476
+ const a = n;
477
+ return e === "Backspace" && r > 0 ? i(a.childNodes[r - 1] || null) : e === "Delete" ? i(a.childNodes[r] || null) : null;
478
+ }
479
+ if (n.nodeType === Node.TEXT_NODE) {
480
+ const a = n;
481
+ if (e === "Backspace" && r === 0) {
482
+ const s = i(a.previousSibling);
483
+ return s || i(J(t, o, "previous"));
484
+ }
485
+ if (e === "Delete" && r === a.data.length) {
486
+ const s = i(a.nextSibling);
487
+ return s || i(J(t, o, "next"));
488
+ }
489
+ }
490
+ return i(e === "Backspace" ? J(t, o, "previous") : J(t, o, "next"));
491
+ }
492
+ function P(t, o, e) {
493
+ const i = t.closest($);
494
+ if (!i || j(t)) return !1;
495
+ const n = t.parentNode;
496
+ if (!n) return !1;
497
+ const r = i.innerHTML, a = Array.from(n.childNodes).indexOf(t);
498
+ if (a < 0) return !1;
499
+ const s = t.nextSibling;
500
+ return s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), t.remove(), Tt(n, a), y(i, e, !0), ft(i, r), dt(i), o === "Delete" && i.focus({ preventScroll: !0 }), !0;
501
+ }
502
+ function Xt(t, o, e) {
503
+ if (t.key !== "Backspace" && t.key !== "Delete") return !1;
504
+ const i = t.key, n = t.target;
505
+ if (n != null && n.matches(ot) && o.contains(n) && !j(n))
506
+ return t.preventDefault(), t.stopPropagation(), P(n, i, e);
507
+ const r = window.getSelection();
508
+ if (!r || r.rangeCount === 0) return !1;
509
+ const a = r.getRangeAt(0);
510
+ if (!o.contains(a.commonAncestorContainer) || j(a.commonAncestorContainer)) return !1;
511
+ const s = Mt(a);
512
+ if (s)
513
+ return t.preventDefault(), t.stopPropagation(), P(s, i, e);
514
+ const d = Lt(a, o, i);
515
+ return d ? (t.preventDefault(), t.stopPropagation(), P(d, i, e)) : !1;
516
+ }
517
+ function Rt(t, o, e) {
518
+ const i = F(e.normalizeText(o || ""));
519
+ if (!i) return !1;
520
+ const n = R(t).filter((a) => a.getAttribute("data-citation-id") === i);
521
+ if (n.length === 0) return !1;
522
+ if (n.length === 1)
523
+ return P(n[0], "Delete", e);
524
+ const r = t.innerHTML;
525
+ return n.forEach((a) => {
526
+ const s = a.nextSibling;
527
+ s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), a.remove();
528
+ }), Tt(t, t.childNodes.length), y(t, e, !0), ft(t, r), dt(t), t.focus({ preventScroll: !0 }), !0;
529
+ }
530
+ function Jt(t, o) {
531
+ const e = window.getSelection();
532
+ if (!e || e.rangeCount === 0) return !1;
533
+ const i = e.getRangeAt(0);
534
+ if (!t.contains(i.commonAncestorContainer) || j(i.commonAncestorContainer)) return !1;
535
+ const n = Mt(i);
536
+ if (n)
537
+ return P(n, "Delete", o);
538
+ const r = Lt(i, t, "Backspace");
539
+ return r ? P(r, "Backspace", o) : !1;
540
+ }
541
+ function et(t, o, e) {
542
+ var l, u;
543
+ const i = yt(o, e);
544
+ if (!i.author || !i.title) return !1;
545
+ i.id || (i.id = Ht(t, e));
546
+ const n = t.innerHTML;
547
+ let r;
548
+ try {
549
+ r = Yt(t);
550
+ } catch (b) {
551
+ return !1;
552
+ }
553
+ const a = window.getSelection();
554
+ if (!a) return !1;
555
+ r.collapsed || r.deleteContents();
556
+ const s = document.createElement("span");
557
+ vt(s, i, N(t, e));
558
+ try {
559
+ r.insertNode(s);
560
+ } catch (b) {
561
+ return !1;
562
+ }
563
+ const d = document.createTextNode(" ");
564
+ s.nextSibling ? (l = s.parentNode) == null || l.insertBefore(d, s.nextSibling) : (u = s.parentNode) == null || u.appendChild(d);
565
+ const c = document.createRange();
566
+ if (d.parentNode) {
567
+ const b = Array.from(d.parentNode.childNodes).indexOf(d) + 1;
568
+ c.setStart(d.parentNode, Math.max(0, b));
569
+ } else
570
+ c.setStartAfter(s);
571
+ return c.collapse(!0), a.removeAllRanges(), a.addRange(c), _t(t, i, e), y(t, e, !0), ft(t, n), dt(t), !0;
572
+ }
573
+ function Zt(t, o) {
574
+ if (!o) return !1;
575
+ const e = R(t).find((r) => r.getAttribute("data-citation-id") === o) || null;
576
+ if (!e) return !1;
577
+ e.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), e.focus({ preventScroll: !0 });
578
+ const i = window.getSelection();
579
+ if (!i) return !0;
580
+ const n = document.createRange();
581
+ return n.selectNode(e), i.removeAllRanges(), i.addRange(n), !0;
582
+ }
583
+ function nt(t) {
584
+ return V.get(t) === !0;
585
+ }
586
+ function U(t, o = !1) {
587
+ const e = v.get(t);
588
+ e && (e.classList.remove("show"), V.set(t, !1), it(t, "toggleCitationsPanel", !1), o && t.focus({ preventScroll: !0 }));
589
+ }
590
+ function Qt(t) {
591
+ v.forEach((o, e) => {
592
+ e !== t && U(e, !1);
593
+ });
594
+ }
595
+ function ct(t, o) {
596
+ if (!o.classList.contains("show")) return;
597
+ const i = lt(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));
598
+ o.style.width = `${n}px`, o.style.left = `${a}px`, o.style.top = `${s}px`, o.style.maxHeight = `${Math.max(260, window.innerHeight - 24)}px`;
599
+ }
600
+ function C(t, o) {
601
+ return t.querySelector(`[data-field="${o}"]`);
602
+ }
603
+ function te(t) {
604
+ var s, d, c, l, u, b;
605
+ const o = ((s = C(t, "author")) == null ? void 0 : s.value) || "", e = ((d = C(t, "year")) == null ? void 0 : d.value) || "", i = ((c = C(t, "title")) == null ? void 0 : c.value) || "", n = ((l = C(t, "source")) == null ? void 0 : l.value) || "", r = ((u = C(t, "url")) == null ? void 0 : u.value) || "", a = ((b = C(t, "note")) == null ? void 0 : b.value) || "";
606
+ return {
607
+ author: o,
608
+ year: e,
609
+ title: i,
610
+ source: n,
611
+ url: r,
612
+ note: a
613
+ };
614
+ }
615
+ function E(t, o) {
616
+ const e = t.querySelector(".rte-citations-live");
617
+ e && (e.textContent = o);
618
+ }
619
+ function ee(t, o, e) {
620
+ const i = C(o, "style");
621
+ i && (i.value = N(t, e));
622
+ }
623
+ function Nt(t, o, e) {
624
+ const i = L.includes(o) ? o : e.defaultStyle;
625
+ return T.set(t, i), y(t, e, !0), i;
626
+ }
627
+ function bt(t, o) {
628
+ const e = N(t, o), i = L.indexOf(e), n = L[(i + 1) % L.length];
629
+ return T.set(t, n), y(t, o, !0), n;
630
+ }
631
+ function ne(t) {
632
+ const o = v.get(t);
633
+ if (o) return o;
634
+ const e = f.get(t) || M || Z(), i = `rte-citations-panel-${Ot++}`, n = document.createElement("section");
635
+ n.className = m, n.id = i, n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "false"), n.setAttribute("aria-label", e.labels.panelAriaLabel), n.setAttribute("tabindex", "-1"), n.innerHTML = `
636
+ <header class="rte-citations-header">
637
+ <h2 class="rte-citations-title">${g(e.labels.panelTitle)}</h2>
638
+ <button type="button" class="rte-citations-icon-btn" data-action="close" aria-label="${g(e.labels.closeText)}">✕</button>
639
+ </header>
640
+ <div class="rte-citations-body">
641
+ <p class="rte-citations-status" aria-live="polite"></p>
642
+
643
+ <div class="rte-citations-grid">
644
+ <label class="rte-citations-label">
645
+ ${g(e.labels.styleLabel)}
646
+ <select data-field="style" class="rte-citations-field">
647
+ <option value="apa">APA</option>
648
+ <option value="mla">MLA</option>
649
+ <option value="chicago">Chicago</option>
650
+ </select>
651
+ </label>
652
+ <label class="rte-citations-label">
653
+ ${g(e.labels.authorLabel)}
654
+ <input type="text" data-field="author" class="rte-citations-field" autocomplete="off" />
655
+ </label>
656
+ <label class="rte-citations-label">
657
+ ${g(e.labels.yearLabel)}
658
+ <input type="text" data-field="year" class="rte-citations-field" inputmode="numeric" autocomplete="off" />
659
+ </label>
660
+ <label class="rte-citations-label">
661
+ ${g(e.labels.titleLabel)}
662
+ <input type="text" data-field="title" class="rte-citations-field" autocomplete="off" />
663
+ </label>
664
+ <label class="rte-citations-label">
665
+ ${g(e.labels.sourceLabel)}
666
+ <input type="text" data-field="source" class="rte-citations-field" autocomplete="off" />
667
+ </label>
668
+ <label class="rte-citations-label">
669
+ ${g(e.labels.urlLabel)}
670
+ <input type="url" data-field="url" class="rte-citations-field" autocomplete="off" />
671
+ </label>
672
+ <label class="rte-citations-label rte-citations-label-note">
673
+ ${g(e.labels.noteLabel)}
674
+ <textarea data-field="note" class="rte-citations-field" rows="2"></textarea>
675
+ </label>
676
+ </div>
677
+
678
+ <div class="rte-citations-controls" role="toolbar" aria-label="Citation actions">
679
+ <button type="button" class="rte-citations-btn rte-citations-btn-primary" data-action="insert">${g(e.labels.insertText)}</button>
680
+ <button type="button" class="rte-citations-btn" data-action="refresh">${g(e.labels.refreshText)}</button>
681
+ <button type="button" class="rte-citations-btn" data-action="cycle-style"></button>
682
+ </div>
683
+
684
+ <section class="rte-citations-recent" aria-label="${g(e.labels.recentHeading)}">
685
+ <h3 class="rte-citations-recent-heading">${g(e.labels.recentHeading)}</h3>
686
+ <ul class="rte-citations-recent-list" role="list"></ul>
687
+ </section>
688
+
689
+ <p class="rte-citations-shortcut">Shortcut: Ctrl/Cmd + Alt + Shift + C</p>
690
+ <span class="rte-citations-live" aria-live="polite"></span>
691
+ </div>
692
+ `, n.addEventListener("click", (a) => {
693
+ const s = a.target;
694
+ if (!s) return;
695
+ const d = s.closest("[data-action]");
696
+ if (!d) return;
697
+ const c = d.getAttribute("data-action") || "", l = f.get(t) || M || e;
698
+ if (f.set(t, l), c === "close") {
699
+ U(t, !0);
700
+ return;
701
+ }
702
+ if (c === "insert") {
703
+ if (S(t)) return;
704
+ const u = te(n);
705
+ if (!l.normalizeText(u.author) || !l.normalizeText(u.title)) {
706
+ E(n, l.labels.invalidMessage);
707
+ return;
708
+ }
709
+ if (!et(t, u, l)) {
710
+ E(n, l.labels.invalidMessage);
711
+ return;
712
+ }
713
+ E(n, "Citation inserted.");
714
+ const w = C(n, "title"), A = C(n, "note");
715
+ w && (w.value = ""), A && (A.value = "");
716
+ return;
717
+ }
718
+ if (c === "refresh") {
719
+ const u = y(t, l, !0);
720
+ E(n, `Refreshed ${u.length} citation${u.length === 1 ? "" : "s"}.`);
721
+ return;
722
+ }
723
+ if (c === "cycle-style") {
724
+ const u = bt(t, l);
725
+ ee(t, n, l), E(n, `Style changed to ${u.toUpperCase()}.`);
726
+ return;
727
+ }
728
+ if (c === "insert-from-recent") {
729
+ if (S(t)) return;
730
+ const u = d.getAttribute("data-citation-id") || "", b = Et(t, u, K(t, l), l);
731
+ if (!b) return;
732
+ et(t, b, l), E(n, `Inserted citation: ${b.title}.`);
733
+ return;
734
+ }
735
+ if (c === "delete-by-id") {
736
+ if (S(t)) return;
737
+ const u = d.getAttribute("data-citation-id") || "";
738
+ if (Rt(t, u, l)) {
739
+ E(n, "Citation deleted.");
740
+ return;
741
+ }
742
+ qt(t, u, l) && (H(t), E(n, "Removed from recent citations."));
743
+ }
744
+ }), n.addEventListener("keydown", (a) => {
745
+ if (a.key === "Escape") {
746
+ a.preventDefault(), U(t, !0);
747
+ return;
748
+ }
749
+ const s = a.target;
750
+ if (!s || !s.matches(".rte-citations-recent-btn") || a.key !== "ArrowDown" && a.key !== "ArrowUp") return;
751
+ const d = Array.from(n.querySelectorAll(".rte-citations-recent-btn"));
752
+ if (d.length === 0) return;
753
+ const c = d.indexOf(s);
754
+ if (c < 0) return;
755
+ a.preventDefault();
756
+ const l = a.key === "ArrowDown" ? 1 : -1, u = (c + l + d.length) % d.length;
757
+ d[u].focus();
758
+ });
759
+ const r = C(n, "style");
760
+ return r == null || r.addEventListener("change", () => {
761
+ const a = f.get(t) || M || e, s = r.value;
762
+ Nt(t, s, a), E(n, `Style changed to ${s.toUpperCase()}.`);
763
+ }), tt(n, t), document.body.appendChild(n), v.set(t, n), V.set(t, !1), H(t), n;
764
+ }
765
+ function z(t) {
766
+ const o = ne(t);
767
+ Qt(t), o.classList.add("show"), V.set(t, !0), it(t, "toggleCitationsPanel", !0), tt(o, t), ct(t, o), H(t);
768
+ const e = C(o, "author");
769
+ e == null || e.focus();
770
+ }
771
+ function zt(t, o) {
772
+ const e = nt(t);
773
+ return (typeof o == "boolean" ? o : !e) ? z(t) : U(t, !1), !0;
774
+ }
775
+ function oe(t) {
776
+ const o = t.key.toLowerCase();
777
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && o === "c";
778
+ }
779
+ function ie(t) {
780
+ const o = t.key.toLowerCase();
781
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && o === "b";
782
+ }
783
+ function re(t) {
784
+ const o = t.key.toLowerCase();
785
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && o === "j";
786
+ }
787
+ function ae(t) {
788
+ M = t, I || (I = (o) => {
789
+ const e = o.target, i = e == null ? void 0 : e.closest($);
790
+ if (!i) return;
791
+ p = i, f.has(i) || f.set(i, t), T.has(i) || T.set(i, t.defaultStyle);
792
+ const n = v.get(i);
793
+ n && (tt(n, i), ct(i, n)), it(i, "toggleCitationsPanel", nt(i));
794
+ }, document.addEventListener("focusin", I, !0)), B || (B = (o) => {
795
+ const e = o.target, i = e == null ? void 0 : e.closest($);
796
+ i && (p = i, kt(i));
797
+ }, document.addEventListener("input", B, !0)), O || (O = (o) => {
798
+ if (o.defaultPrevented) return;
799
+ const e = o.target, i = !!(e != null && e.closest(`.${m} input, .${m} textarea, .${m} select`)), n = h(void 0, !1);
800
+ if (!n || S(n)) return;
801
+ const r = f.get(n) || M || t;
802
+ if (f.set(n, r), p = n, o.key === "Escape" && nt(n)) {
803
+ o.preventDefault(), U(n, !0);
804
+ return;
805
+ }
806
+ if (!i && !Xt(o, n, r)) {
807
+ if (oe(o)) {
808
+ o.preventDefault(), o.stopPropagation(), zt(n);
809
+ return;
810
+ }
811
+ if (ie(o)) {
812
+ o.preventDefault(), o.stopPropagation(), y(n, r, !0), z(n);
813
+ return;
814
+ }
815
+ re(o) && (o.preventDefault(), o.stopPropagation(), bt(n, r));
816
+ }
817
+ }, document.addEventListener("keydown", O, !0)), k || (k = () => {
818
+ v.forEach((o, e) => {
819
+ if (!e.isConnected || !o.isConnected) {
820
+ At(e), o.remove(), v.delete(e), V.delete(e);
821
+ return;
822
+ }
823
+ tt(o, e), ct(e, o);
824
+ });
825
+ }, window.addEventListener("scroll", k, !0), window.addEventListener("resize", k));
826
+ }
827
+ function se() {
828
+ 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;
829
+ }
830
+ function ce() {
831
+ if (typeof document == "undefined" || document.getElementById(gt)) return;
832
+ const t = document.createElement("style");
833
+ t.id = gt, t.textContent = `
834
+ .rte-toolbar-group-items.citations,
835
+ .editora-toolbar-group-items.citations {
836
+ display: flex;
837
+ border: 1px solid #ccc;
838
+ border-radius: 3px;
839
+ background: #fff;
840
+ }
841
+
842
+ .rte-toolbar-group-items.citations .rte-toolbar-button,
843
+ .editora-toolbar-group-items.citations .editora-toolbar-button {
844
+ border: none;
845
+ border-radius: 0;
846
+ border-right: 1px solid #ccc;
847
+ }
848
+
849
+ .rte-toolbar-group-items.citations .rte-toolbar-item:last-child .rte-toolbar-button,
850
+ .editora-toolbar-group-items.citations .editora-toolbar-item:last-child .editora-toolbar-button {
851
+ border-right: none;
852
+ }
853
+
854
+ .rte-toolbar-button[data-command="toggleCitationsPanel"].active,
855
+ .editora-toolbar-button[data-command="toggleCitationsPanel"].active {
856
+ background: #ccc;
857
+ }
858
+
859
+ ${x} .rte-toolbar-group-items.citations,
860
+ ${x} .editora-toolbar-group-items.citations,
861
+ .${m}.rte-citations-theme-dark {
862
+ border-color: #566275;
863
+ }
864
+
865
+ ${x} .rte-toolbar-group-items.citations .rte-toolbar-button[data-command="refreshCitations"] svg,
866
+ ${x} .editora-toolbar-group-items.citations .editora-toolbar-button[data-command="refreshCitations"] svg
867
+ {
868
+ fill: none;
869
+ }
870
+ ${x} .rte-toolbar-group-items.citations .rte-toolbar-button,
871
+ ${x} .editora-toolbar-group-items.citations .editora-toolbar-button
872
+ {
873
+ border-color: #566275;
874
+ }
875
+ ${x} .rte-toolbar-button[data-command="toggleCitationsPanel"].active,
876
+ ${x} .editora-toolbar-button[data-command="toggleCitationsPanel"].active {
877
+ background: linear-gradient(180deg, #5eaaf6 0%, #4a95de 100%);
878
+ }
879
+ .${m} {
880
+ position: fixed;
881
+ z-index: 1500;
882
+ right: 16px;
883
+ top: 16px;
884
+ width: min(380px, calc(100vw - 20px));
885
+ max-height: calc(100vh - 24px);
886
+ display: none;
887
+ flex-direction: column;
888
+ border-radius: 12px;
889
+ border: 1px solid #d1d5db;
890
+ background: #ffffff;
891
+ color: #0f172a;
892
+ box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16);
893
+ overflow: hidden;
894
+ }
895
+
896
+ .${m}.show {
897
+ display: flex;
898
+ }
899
+
900
+ .${m}.rte-citations-theme-dark {
901
+ background: #0f172a;
902
+ color: #e2e8f0;
903
+ border-color: #334155;
904
+ box-shadow: 0 20px 40px rgba(2, 6, 23, 0.5);
905
+ }
906
+
907
+ .rte-citations-header {
908
+ display: flex;
909
+ align-items: center;
910
+ justify-content: space-between;
911
+ padding: 10px 12px;
912
+ border-bottom: 1px solid #e2e8f0;
913
+ background: #f8fafc;
914
+ }
915
+
916
+ .${m}.rte-citations-theme-dark .rte-citations-header {
917
+ border-bottom-color: #334155;
918
+ background: #111827;
919
+ }
920
+
921
+ .rte-citations-title {
922
+ margin: 0;
923
+ font-size: 14px;
924
+ font-weight: 700;
925
+ }
926
+
927
+ .rte-citations-icon-btn {
928
+ border: 1px solid #cbd5e1;
929
+ background: #ffffff;
930
+ color: #0f172a;
931
+ border-radius: 6px;
932
+ cursor: pointer;
933
+ min-width: 34px;
934
+ min-height: 34px;
935
+ width: 34px;
936
+ height: 34px;
937
+ padding: 0;
938
+ display: inline-flex;
939
+ align-items: center;
940
+ justify-content: center;
941
+ font-size: 16px;
942
+ line-height: 1;
943
+ font-weight: 600;
944
+ }
945
+
946
+ .rte-citations-icon-btn:hover,
947
+ .rte-citations-icon-btn:focus-visible {
948
+ outline: none;
949
+ border-color: #3b82f6;
950
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
951
+ }
952
+
953
+ .${m}.rte-citations-theme-dark .rte-citations-icon-btn {
954
+ background: #0f172a;
955
+ border-color: #475569;
956
+ color: #e2e8f0;
957
+ }
958
+
959
+ .${m}.rte-citations-theme-dark .rte-citations-icon-btn:hover,
960
+ .${m}.rte-citations-theme-dark .rte-citations-icon-btn:focus-visible {
961
+ border-color: #60a5fa;
962
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
963
+ }
964
+
965
+ .rte-citations-body {
966
+ display: flex;
967
+ flex-direction: column;
968
+ gap: 10px;
969
+ padding: 12px;
970
+ overflow: auto;
971
+ }
972
+
973
+ .rte-citations-status {
974
+ margin: 0;
975
+ font-size: 12px;
976
+ color: #475569;
977
+ }
978
+
979
+ .${m}.rte-citations-theme-dark .rte-citations-status {
980
+ color: #94a3b8;
981
+ }
982
+
983
+ .rte-citations-grid {
984
+ display: grid;
985
+ grid-template-columns: 1fr 1fr;
986
+ gap: 8px;
987
+ }
988
+
989
+ .rte-citations-label {
990
+ display: flex;
991
+ flex-direction: column;
992
+ gap: 4px;
993
+ font-size: 12px;
994
+ font-weight: 600;
995
+ color: inherit;
996
+ }
997
+
998
+ .rte-citations-label-note {
999
+ grid-column: 1 / -1;
1000
+ }
1001
+
1002
+ .rte-citations-field {
1003
+ width: 100%;
1004
+ box-sizing: border-box;
1005
+ min-height: 30px;
1006
+ border-radius: 8px;
1007
+ border: 1px solid #cbd5e1;
1008
+ background: #ffffff;
1009
+ color: inherit;
1010
+ font-size: 13px;
1011
+ padding: 6px 8px;
1012
+ }
1013
+
1014
+ .rte-citations-field:focus-visible {
1015
+ outline: none;
1016
+ border-color: #1d4ed8;
1017
+ box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.2);
1018
+ }
1019
+
1020
+ .${m}.rte-citations-theme-dark .rte-citations-field {
1021
+ border-color: #334155;
1022
+ background: #0b1220;
1023
+ color: #e2e8f0;
1024
+ }
1025
+
1026
+ .rte-citations-controls {
1027
+ display: flex;
1028
+ flex-wrap: wrap;
1029
+ gap: 8px;
1030
+ }
1031
+
1032
+ .rte-citations-btn {
1033
+ border: 1px solid #cbd5e1;
1034
+ background: #f8fafc;
1035
+ color: inherit;
1036
+ border-radius: 8px;
1037
+ padding: 6px 10px;
1038
+ font-size: 12px;
1039
+ font-weight: 600;
1040
+ cursor: pointer;
1041
+ }
1042
+
1043
+ .rte-citations-btn:hover,
1044
+ .rte-citations-btn:focus-visible {
1045
+ outline: none;
1046
+ border-color: #1d4ed8;
1047
+ box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.2);
1048
+ }
1049
+
1050
+ .rte-citations-btn-primary {
1051
+ background: #1d4ed8;
1052
+ border-color: #1d4ed8;
1053
+ color: #ffffff;
1054
+ }
1055
+
1056
+ .rte-citations-btn-primary:hover,
1057
+ .rte-citations-btn-primary:focus-visible {
1058
+ background: #1e40af;
1059
+ border-color: #1e40af;
1060
+ }
1061
+
1062
+ .${m}.rte-citations-theme-dark .rte-citations-btn {
1063
+ border-color: #334155;
1064
+ background: #0b1220;
1065
+ color: #e2e8f0;
1066
+ }
1067
+
1068
+ .${m}.rte-citations-theme-dark .rte-citations-btn-primary {
1069
+ border-color: #2563eb;
1070
+ background: #2563eb;
1071
+ color: #ffffff;
1072
+ }
1073
+
1074
+ .rte-citations-recent {
1075
+ border: 1px solid #e2e8f0;
1076
+ border-radius: 10px;
1077
+ padding: 8px;
1078
+ }
1079
+
1080
+ .${m}.rte-citations-theme-dark .rte-citations-recent {
1081
+ border-color: #334155;
1082
+ }
1083
+
1084
+ .rte-citations-recent-heading {
1085
+ margin: 0 0 8px;
1086
+ font-size: 12px;
1087
+ font-weight: 700;
1088
+ }
1089
+
1090
+ .rte-citations-recent-list {
1091
+ margin: 0;
1092
+ padding: 0;
1093
+ list-style: none;
1094
+ display: flex;
1095
+ flex-direction: column;
1096
+ gap: 6px;
1097
+ max-height: 170px;
1098
+ overflow: auto;
1099
+ }
1100
+
1101
+ .rte-citations-recent-btn {
1102
+ width: 100%;
1103
+ text-align: left;
1104
+ border: 1px solid #cbd5e1;
1105
+ background: #ffffff;
1106
+ color: inherit;
1107
+ border-radius: 8px;
1108
+ padding: 7px;
1109
+ cursor: pointer;
1110
+ display: flex;
1111
+ flex-direction: column;
1112
+ gap: 2px;
1113
+ }
1114
+
1115
+ .rte-citations-recent-row {
1116
+ display: flex;
1117
+ gap: 6px;
1118
+ align-items: stretch;
1119
+ }
1120
+
1121
+ .rte-citations-recent-delete {
1122
+ flex: 0 0 auto;
1123
+ border: 1px solid #fecaca;
1124
+ background: #fff1f2;
1125
+ color: #b91c1c;
1126
+ border-radius: 8px;
1127
+ padding: 0 8px;
1128
+ font-size: 11px;
1129
+ font-weight: 700;
1130
+ cursor: pointer;
1131
+ min-height: 34px;
1132
+ }
1133
+
1134
+ .rte-citations-recent-delete:hover,
1135
+ .rte-citations-recent-delete:focus-visible {
1136
+ outline: none;
1137
+ border-color: #f87171;
1138
+ box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.2);
1139
+ }
1140
+
1141
+ .rte-citations-recent-btn:focus-visible,
1142
+ .rte-citations-recent-btn:hover {
1143
+ outline: none;
1144
+ border-color: #1d4ed8;
1145
+ box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.18);
1146
+ }
1147
+
1148
+ .${m}.rte-citations-theme-dark .rte-citations-recent-btn {
1149
+ border-color: #334155;
1150
+ background: #0b1220;
1151
+ color: #e2e8f0;
1152
+ }
1153
+
1154
+ .${m}.rte-citations-theme-dark .rte-citations-recent-delete {
1155
+ border-color: #7f1d1d;
1156
+ background: #2b1218;
1157
+ color: #fca5a5;
1158
+ }
1159
+
1160
+ .rte-citations-recent-title {
1161
+ font-size: 12px;
1162
+ font-weight: 700;
1163
+ line-height: 1.3;
1164
+ }
1165
+
1166
+ .rte-citations-recent-meta {
1167
+ font-size: 11px;
1168
+ color: #64748b;
1169
+ line-height: 1.3;
1170
+ }
1171
+
1172
+ .${m}.rte-citations-theme-dark .rte-citations-recent-meta {
1173
+ color: #94a3b8;
1174
+ }
1175
+
1176
+ .rte-citations-empty {
1177
+ border: 1px dashed #cbd5e1;
1178
+ border-radius: 8px;
1179
+ padding: 8px;
1180
+ font-size: 12px;
1181
+ color: #64748b;
1182
+ }
1183
+
1184
+ .${m}.rte-citations-theme-dark .rte-citations-empty {
1185
+ border-color: #334155;
1186
+ color: #94a3b8;
1187
+ }
1188
+
1189
+ .rte-citations-shortcut {
1190
+ margin: 0;
1191
+ font-size: 11px;
1192
+ color: #64748b;
1193
+ }
1194
+
1195
+ .${m}.rte-citations-theme-dark .rte-citations-shortcut {
1196
+ color: #94a3b8;
1197
+ }
1198
+
1199
+ .rte-citations-live {
1200
+ position: absolute;
1201
+ width: 1px;
1202
+ height: 1px;
1203
+ margin: -1px;
1204
+ padding: 0;
1205
+ overflow: hidden;
1206
+ clip: rect(0 0 0 0);
1207
+ border: 0;
1208
+ }
1209
+
1210
+ .rte-citation-ref {
1211
+ display: inline-flex;
1212
+ align-items: center;
1213
+ border-radius: 6px;
1214
+ border: 1px solid rgba(29, 78, 216, 0.24);
1215
+ background: rgba(29, 78, 216, 0.08);
1216
+ color: #1e3a8a;
1217
+ padding: 0 4px;
1218
+ margin: 0 1px;
1219
+ font-size: 0.92em;
1220
+ line-height: 1.35;
1221
+ white-space: nowrap;
1222
+ cursor: pointer;
1223
+ user-select: all;
1224
+ }
1225
+
1226
+ .rte-citation-ref:focus,
1227
+ .rte-citation-ref:focus-visible {
1228
+ outline: none;
1229
+ border-color: #1d4ed8;
1230
+ box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.22);
1231
+ }
1232
+
1233
+ .${x} .rte-citation-ref {
1234
+ border-color: rgba(96, 165, 250, 0.45);
1235
+ background: rgba(37, 99, 235, 0.22);
1236
+ color: #bfdbfe;
1237
+ }
1238
+
1239
+ .rte-citation-bibliography,
1240
+ .rte-citation-footnotes {
1241
+ margin-top: 16px;
1242
+ border-top: 1px solid #d1d5db;
1243
+ padding-top: 10px;
1244
+ }
1245
+
1246
+ .${x} .rte-citation-bibliography,
1247
+ .${x} .rte-citation-footnotes {
1248
+ border-top-color: #475569;
1249
+ }
1250
+
1251
+ .rte-citation-section-title {
1252
+ margin: 0 0 8px;
1253
+ font-size: 1em;
1254
+ font-weight: 700;
1255
+ }
1256
+
1257
+ .rte-citation-list {
1258
+ margin: 0;
1259
+ padding-left: 22px;
1260
+ }
1261
+
1262
+ .rte-citation-item {
1263
+ margin: 0 0 8px;
1264
+ line-height: 1.45;
1265
+ }
1266
+
1267
+ .rte-citation-backref {
1268
+ margin-left: 8px;
1269
+ color: #1d4ed8;
1270
+ text-decoration: none;
1271
+ font-size: 0.9em;
1272
+ }
1273
+
1274
+ .rte-citation-backref:hover,
1275
+ .rte-citation-backref:focus-visible {
1276
+ text-decoration: underline;
1277
+ outline: none;
1278
+ }
1279
+
1280
+ .${x} .rte-citation-backref {
1281
+ color: #93c5fd;
1282
+ }
1283
+
1284
+ @media (max-width: 768px) {
1285
+ .${m} {
1286
+ left: 10px !important;
1287
+ right: 10px;
1288
+ top: 10px !important;
1289
+ width: auto !important;
1290
+ max-height: calc(100vh - 20px);
1291
+ }
1292
+
1293
+ .rte-citations-grid {
1294
+ grid-template-columns: 1fr;
1295
+ }
1296
+
1297
+ .rte-citations-recent-list {
1298
+ max-height: 34vh;
1299
+ }
1300
+ }
1301
+ `, document.head.appendChild(t);
1302
+ }
1303
+ const le = (t = {}) => {
1304
+ const o = Z(t);
1305
+ return ce(), {
1306
+ name: "citations",
1307
+ toolbar: [
1308
+ {
1309
+ id: "citationsGroup",
1310
+ label: "Citations",
1311
+ type: "group",
1312
+ command: "citations",
1313
+ items: [
1314
+ {
1315
+ id: "citations",
1316
+ label: "Citations",
1317
+ command: "toggleCitationsPanel",
1318
+ shortcut: "Mod-Alt-Shift-c",
1319
+ 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>'
1320
+ },
1321
+ {
1322
+ id: "citationsRefresh",
1323
+ label: "Refresh Citations",
1324
+ command: "refreshCitations",
1325
+ shortcut: "Mod-Alt-Shift-b",
1326
+ 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>'
1327
+ },
1328
+ {
1329
+ id: "citationsStyle",
1330
+ label: "Cycle Citation Style",
1331
+ command: "cycleCitationStyle",
1332
+ shortcut: "Mod-Alt-Shift-j",
1333
+ 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>'
1334
+ }
1335
+ ]
1336
+ }
1337
+ ],
1338
+ commands: {
1339
+ citations: (e, i) => {
1340
+ const n = h(i);
1341
+ if (!n || S(n)) return !1;
1342
+ const r = f.get(n) || o;
1343
+ return f.set(n, r), T.set(n, N(n, r)), p = n, z(n), y(n, r, !1), !0;
1344
+ },
1345
+ toggleCitationsPanel: (e, i) => {
1346
+ const n = h(i);
1347
+ if (!n || S(n)) return !1;
1348
+ const r = f.get(n) || o;
1349
+ f.set(n, r), p = n;
1350
+ const a = zt(n, typeof e == "boolean" ? e : void 0);
1351
+ return nt(n) && y(n, r, !1), a;
1352
+ },
1353
+ insertCitation: (e, i) => {
1354
+ const n = h(i);
1355
+ if (!n || S(n) || !e || typeof e != "object") return !1;
1356
+ const r = f.get(n) || o;
1357
+ f.set(n, r), p = n;
1358
+ const a = et(n, e, r);
1359
+ return a && z(n), a;
1360
+ },
1361
+ refreshCitations: (e, i) => {
1362
+ const n = h(i);
1363
+ if (!n) return !1;
1364
+ const r = f.get(n) || o;
1365
+ return f.set(n, r), p = n, y(n, r, !0), z(n), !0;
1366
+ },
1367
+ setCitationStyle: (e, i) => {
1368
+ const n = h(i);
1369
+ if (!n || !e) return !1;
1370
+ const r = f.get(n) || o;
1371
+ return f.set(n, r), p = n, Nt(n, e, r), !0;
1372
+ },
1373
+ cycleCitationStyle: (e, i) => {
1374
+ const n = h(i);
1375
+ if (!n) return !1;
1376
+ const r = f.get(n) || o;
1377
+ return f.set(n, r), p = n, bt(n, r), H(n), !0;
1378
+ },
1379
+ getCitationRecords: (e, i) => {
1380
+ const n = h(i);
1381
+ if (!n) return !1;
1382
+ const r = f.get(n) || o, a = K(n, r);
1383
+ if (typeof e == "function")
1384
+ try {
1385
+ e(a);
1386
+ } catch (s) {
1387
+ }
1388
+ return n.__citationRecords = a, n.dispatchEvent(
1389
+ new CustomEvent("editora:citations-data", {
1390
+ bubbles: !0,
1391
+ detail: {
1392
+ records: a,
1393
+ style: N(n, r)
1394
+ }
1395
+ })
1396
+ ), !0;
1397
+ },
1398
+ setCitationsOptions: (e, i) => {
1399
+ const n = h(i);
1400
+ if (!n || !e || typeof e != "object") return !1;
1401
+ const r = f.get(n) || o, a = Z({
1402
+ ...r,
1403
+ ...e,
1404
+ labels: {
1405
+ ...r.labels,
1406
+ ...e.labels || {}
1407
+ },
1408
+ normalizeText: e.normalizeText || r.normalizeText,
1409
+ generateCitationId: e.generateCitationId || r.generateCitationId
1410
+ });
1411
+ return f.set(n, a), e.defaultStyle && L.includes(e.defaultStyle) && T.set(n, e.defaultStyle), y(n, a, !0), H(n), !0;
1412
+ },
1413
+ locateCitation: (e, i) => {
1414
+ const n = h(i);
1415
+ return !n || typeof e != "string" ? !1 : Zt(n, e);
1416
+ },
1417
+ deleteCitation: (e, i) => {
1418
+ const n = h(i);
1419
+ if (!n || S(n)) return !1;
1420
+ const r = f.get(n) || o;
1421
+ return f.set(n, r), typeof e == "string" && e.trim() ? Rt(n, e, r) : Jt(n, r);
1422
+ },
1423
+ insertRecentCitation: (e, i) => {
1424
+ const n = h(i);
1425
+ if (!n || S(n)) return !1;
1426
+ const r = f.get(n) || o;
1427
+ f.set(n, r);
1428
+ const a = K(n, r), s = rt(n, a, r);
1429
+ if (s.length === 0) return !1;
1430
+ const d = typeof e == "string" && e.trim() ? Et(n, e, a, r) : s[0];
1431
+ if (!d) return !1;
1432
+ const c = et(n, d, r);
1433
+ return c && z(n), c;
1434
+ }
1435
+ },
1436
+ keymap: {
1437
+ "Mod-Alt-Shift-c": "toggleCitationsPanel",
1438
+ "Mod-Alt-Shift-C": "toggleCitationsPanel",
1439
+ "Mod-Alt-Shift-b": "refreshCitations",
1440
+ "Mod-Alt-Shift-B": "refreshCitations",
1441
+ "Mod-Alt-Shift-j": "cycleCitationStyle",
1442
+ "Mod-Alt-Shift-J": "cycleCitationStyle"
1443
+ },
1444
+ init: function(i) {
1445
+ Y += 1;
1446
+ const n = this && typeof this.__pluginConfig == "object" ? Z({ ...o, ...this.__pluginConfig }) : o;
1447
+ ae(n);
1448
+ const r = h(
1449
+ i && i.editorElement ? { editorElement: i.editorElement } : void 0,
1450
+ !1
1451
+ );
1452
+ r && (p = r, f.set(r, n), T.set(r, n.defaultStyle), it(r, "toggleCitationsPanel", !1), kt(r));
1453
+ },
1454
+ destroy: () => {
1455
+ Y = Math.max(0, Y - 1), !(Y > 0) && (q.forEach((e) => {
1456
+ window.clearTimeout(e);
1457
+ }), q.clear(), se());
1458
+ }
1459
+ };
1460
+ };
1461
+ export {
1462
+ le as CitationsPlugin
1463
+ };
1464
+ //# sourceMappingURL=CitationsPlugin.native-BnU0qCwR.mjs.map