@editora/plugins 1.0.8 → 1.0.9

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