@editora/plugins 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
- package/dist/a11y-checker.cjs.js +12 -12
- package/dist/a11y-checker.esm.js +80 -98
- package/dist/anchor.cjs.js +12 -12
- package/dist/anchor.esm.js +115 -128
- package/dist/anchoredPopover-BzqGPOAE.js +1 -0
- package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
- package/dist/approval-workflow.cjs.js +40 -40
- package/dist/approval-workflow.esm.js +208 -249
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +55 -68
- package/dist/blockquote.esm.js +1 -2
- package/dist/blocks-library.cjs.js +45 -45
- package/dist/blocks-library.esm.js +178 -245
- package/dist/capitalization.esm.js +1 -2
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +58 -82
- package/dist/citations.cjs.js +37 -37
- package/dist/citations.esm.js +439 -512
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +27 -33
- package/dist/code-sample.cjs.js +14 -14
- package/dist/code-sample.esm.js +82 -93
- package/dist/code.cjs.js +119 -42
- package/dist/code.esm.js +2560 -760
- package/dist/comments.cjs.js +6 -6
- package/dist/comments.esm.js +116 -158
- package/dist/conditional-content.cjs.js +90 -90
- package/dist/conditional-content.esm.js +371 -432
- package/dist/content-rules.cjs.js +7 -7
- package/dist/content-rules.esm.js +105 -159
- package/dist/data-binding.cjs.js +46 -46
- package/dist/data-binding.esm.js +328 -368
- package/dist/direction.esm.js +9 -18
- package/dist/doc-schema.cjs.js +29 -29
- package/dist/doc-schema.esm.js +240 -308
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +4 -5
- package/dist/documentManager-CTqRftU8.mjs +8369 -0
- package/dist/documentManager-Jf0RbSks.js +17 -0
- package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +1 -2
- package/dist/embed-iframe.cjs.js +4 -4
- package/dist/embed-iframe.esm.js +73 -81
- package/dist/emojis.cjs.js +8 -8
- package/dist/emojis.esm.js +65 -77
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +54 -56
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +39 -47
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +37 -53
- package/dist/footnote.cjs.js +2 -2
- package/dist/footnote.esm.js +76 -117
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +70 -92
- package/dist/html2canvas.esm-B5qzocYs.js +5 -0
- package/dist/{html2canvas.esm-1a1724a1.mjs → html2canvas.esm-BWVIUcAF.mjs} +141 -225
- package/dist/indent.cjs.js +1 -1
- package/dist/indent.esm.js +12 -24
- package/dist/{index-f04538f2.mjs → index-BFsKNTTj.mjs} +70 -71
- package/dist/index-CvJk4DKa.js +221 -0
- package/dist/index-D3CycEFU.mjs +16543 -0
- package/dist/index-tqLTHcO6.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-CE_A4QSm.js +5 -0
- package/dist/index.es-DQ78mYYo.mjs +6665 -0
- package/dist/index.esm.js +125 -128
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +8 -9
- package/dist/jspdf.es.min-BoS80556.js +77 -0
- package/dist/{jspdf.es.min-c36a4fd8.mjs → jspdf.es.min-DQCoX5yh.mjs} +3658 -4682
- package/dist/line-height.cjs.js +1 -1
- package/dist/line-height.esm.js +11 -24
- package/dist/link.cjs.js +5 -5
- package/dist/link.esm.js +24 -30
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +20 -25
- package/dist/lite.cjs.js +1 -1
- package/dist/lite.esm.js +59 -61
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +139 -146
- package/dist/media-manager.cjs.js +31 -31
- package/dist/media-manager.esm.js +285 -300
- package/dist/mentions.cjs.js +9 -9
- package/dist/mentions.esm.js +238 -286
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +177 -216
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +33 -49
- package/dist/pii-redaction.cjs.js +19 -19
- package/dist/pii-redaction.esm.js +393 -463
- package/dist/plugins.css +1 -0
- package/dist/preview.esm.js +5 -10
- package/dist/print.cjs.js +4 -4
- package/dist/print.esm.js +17 -20
- package/dist/{purify.es-35a15df8.mjs → purify.es-DHhaBdbu.mjs} +9 -19
- package/dist/{purify.es-a8d731c6.js → purify.es-T2a3nLiC.js} +1 -1
- package/dist/slash-commands.cjs.js +2 -2
- package/dist/slash-commands.esm.js +39 -75
- package/dist/smart-paste.cjs.js +27 -27
- package/dist/smart-paste.esm.js +280 -336
- package/dist/special-characters.cjs.js +7 -7
- package/dist/special-characters.esm.js +61 -69
- package/dist/spell-check.cjs.js +5 -5
- package/dist/spell-check.esm.js +97 -123
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +14 -19
- package/dist/table.cjs.js +4 -4
- package/dist/table.esm.js +191 -225
- package/dist/template.cjs.js +21 -20
- package/dist/template.esm.js +715 -196
- package/dist/text-alignment.cjs.js +1 -1
- package/dist/text-alignment.esm.js +21 -27
- package/dist/text-color.cjs.js +3 -3
- package/dist/text-color.esm.js +70 -87
- package/dist/track-changes.cjs.js +2 -2
- package/dist/track-changes.esm.js +100 -162
- package/dist/translation-workflow.cjs.js +74 -74
- package/dist/translation-workflow.esm.js +602 -678
- package/dist/version-diff.cjs.js +14 -14
- package/dist/version-diff.esm.js +128 -157
- package/package.json +1 -1
- package/dist/_commonjsHelpers-6763f629.js +0 -1
- package/dist/_commonjsHelpers-c5d32002.mjs +0 -30
- package/dist/anchoredPopover-33f1358d.mjs +0 -109
- package/dist/anchoredPopover-8151d535.js +0 -1
- package/dist/documentManager-25b6203c.mjs +0 -9122
- package/dist/documentManager-b69e7054.js +0 -17
- package/dist/html2canvas.esm-09133e29.js +0 -22
- package/dist/index-656d224b.js +0 -231
- package/dist/index-6a8c48bb.js +0 -1
- package/dist/index-d027b7e2.mjs +0 -16859
- package/dist/index.es-730f2d98.mjs +0 -5775
- package/dist/index.es-dd40173b.js +0 -18
- package/dist/jspdf.es.min-90db2c97.js +0 -243
- package/dist/style.css +0 -1
- /package/dist/{editorContainerHelpers-36b8ddf3.js → editorContainerHelpers-CFbfiOJI.js} +0 -0
package/dist/citations.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
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
2
|
panelTitle: "Citations",
|
|
3
3
|
panelAriaLabel: "Citations panel",
|
|
4
4
|
styleLabel: "Citation style",
|
|
@@ -27,42 +27,41 @@ function g(t) {
|
|
|
27
27
|
function Pt(t) {
|
|
28
28
|
return t.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
|
|
29
29
|
}
|
|
30
|
-
function ht(t,
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return i ? i[0] : e;
|
|
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;
|
|
36
35
|
}
|
|
37
|
-
function xt(t,
|
|
38
|
-
const
|
|
39
|
-
return
|
|
36
|
+
function xt(t, e) {
|
|
37
|
+
const n = e(t);
|
|
38
|
+
return n ? /^https?:\/\//i.test(n) ? n : `https://${n}` : "";
|
|
40
39
|
}
|
|
41
40
|
function F(t) {
|
|
42
41
|
return t.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
43
42
|
}
|
|
44
|
-
function yt(t,
|
|
43
|
+
function yt(t, e) {
|
|
45
44
|
return {
|
|
46
|
-
id: F(
|
|
47
|
-
author:
|
|
48
|
-
year: ht(t.year || "",
|
|
49
|
-
title:
|
|
50
|
-
source:
|
|
51
|
-
url: xt(t.url || "",
|
|
52
|
-
note:
|
|
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
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
function Z(t = {}) {
|
|
56
|
-
const
|
|
55
|
+
const e = t.defaultStyle && L.includes(t.defaultStyle) ? t.defaultStyle : "apa", n = {
|
|
57
56
|
...Bt,
|
|
58
57
|
...t.labels || {}
|
|
59
58
|
};
|
|
60
59
|
return {
|
|
61
|
-
defaultStyle:
|
|
60
|
+
defaultStyle: e,
|
|
62
61
|
enableFootnoteSync: t.enableFootnoteSync !== !1,
|
|
63
62
|
debounceMs: Math.max(80, Number(t.debounceMs ?? 220)),
|
|
64
63
|
maxRecentCitations: Math.max(3, Math.min(30, Number(t.maxRecentCitations ?? 8))),
|
|
65
|
-
labels:
|
|
64
|
+
labels: n,
|
|
66
65
|
normalizeText: t.normalizeText || Pt,
|
|
67
66
|
generateCitationId: typeof t.generateCitationId == "function" ? t.generateCitationId : void 0
|
|
68
67
|
};
|
|
@@ -77,80 +76,72 @@ function X(t) {
|
|
|
77
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;
|
|
78
77
|
}
|
|
79
78
|
function Dt(t) {
|
|
80
|
-
const
|
|
81
|
-
if (X(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
return t.contentElement;
|
|
92
|
-
if ((t == null ? void 0 : t.editorElement) instanceof HTMLElement) {
|
|
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) {
|
|
93
90
|
const o = t.editorElement;
|
|
94
|
-
if (o.matches(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (r instanceof HTMLElement)
|
|
98
|
-
return r;
|
|
91
|
+
if (o.matches(S)) return o;
|
|
92
|
+
const r = o.querySelector(S);
|
|
93
|
+
if (r instanceof HTMLElement) return r;
|
|
99
94
|
}
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
const o =
|
|
103
|
-
if (a)
|
|
104
|
-
return a;
|
|
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;
|
|
105
99
|
}
|
|
106
100
|
const i = document.activeElement;
|
|
107
101
|
if (i) {
|
|
108
|
-
if (i.matches(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (o)
|
|
112
|
-
return o;
|
|
102
|
+
if (i.matches(S)) return i;
|
|
103
|
+
const o = i.closest(S);
|
|
104
|
+
if (o) return o;
|
|
113
105
|
}
|
|
114
|
-
return p && p.isConnected ? p : (p && !p.isConnected && (p = null),
|
|
106
|
+
return p && p.isConnected ? p : (p && !p.isConnected && (p = null), e ? document.querySelector(S) : null);
|
|
115
107
|
}
|
|
116
|
-
function
|
|
108
|
+
function $(t) {
|
|
117
109
|
return t.getAttribute("contenteditable") === "false" || t.getAttribute("data-readonly") === "true";
|
|
118
110
|
}
|
|
119
111
|
function j(t) {
|
|
120
|
-
const
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
|
-
function Ht(t,
|
|
124
|
-
if (at += 1,
|
|
125
|
-
const
|
|
126
|
-
if (i)
|
|
127
|
-
return i;
|
|
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;
|
|
128
119
|
}
|
|
129
120
|
return `cite-${Date.now().toString(36)}-${at.toString(36)}`;
|
|
130
121
|
}
|
|
131
122
|
function st(t) {
|
|
132
|
-
return t.map((
|
|
123
|
+
return t.map((e) => (e || "").trim()).filter(Boolean).join(" ").trim();
|
|
133
124
|
}
|
|
134
|
-
function Ft(t,
|
|
135
|
-
const
|
|
136
|
-
return
|
|
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})`;
|
|
137
128
|
}
|
|
138
|
-
function ut(t,
|
|
139
|
-
const
|
|
140
|
-
return st(
|
|
141
|
-
`${
|
|
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}.`,
|
|
142
133
|
`"${o}."`,
|
|
143
134
|
r ? `${r},` : "",
|
|
144
135
|
`${i}.`,
|
|
145
136
|
a
|
|
146
|
-
] :
|
|
147
|
-
`${
|
|
137
|
+
] : e === "chicago" ? [
|
|
138
|
+
`${n}.`,
|
|
148
139
|
`${o}.`,
|
|
149
140
|
r ? `${r}.` : "",
|
|
150
141
|
`(${i}).`,
|
|
151
142
|
a
|
|
152
143
|
] : [
|
|
153
|
-
`${
|
|
144
|
+
`${n}.`,
|
|
154
145
|
`(${i}).`,
|
|
155
146
|
`${o}.`,
|
|
156
147
|
r ? `${r}.` : "",
|
|
@@ -159,47 +150,45 @@ function ut(t, n) {
|
|
|
159
150
|
}
|
|
160
151
|
function R(t) {
|
|
161
152
|
return Array.from(t.querySelectorAll(ot)).filter(
|
|
162
|
-
(
|
|
153
|
+
(e) => !e.closest(W) && !e.closest(G)
|
|
163
154
|
);
|
|
164
155
|
}
|
|
165
|
-
function wt(t,
|
|
166
|
-
const
|
|
167
|
-
if (!
|
|
168
|
-
|
|
169
|
-
const i = n.normalizeText(t.getAttribute("data-citation-author") || ""), o = n.normalizeText(t.getAttribute("data-citation-title") || "");
|
|
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") || "");
|
|
170
160
|
return {
|
|
171
|
-
id:
|
|
161
|
+
id: n,
|
|
172
162
|
author: i || "Unknown",
|
|
173
|
-
year: ht(t.getAttribute("data-citation-year") || "",
|
|
163
|
+
year: ht(t.getAttribute("data-citation-year") || "", e.normalizeText) || void 0,
|
|
174
164
|
title: o || "Untitled",
|
|
175
|
-
source:
|
|
176
|
-
url: xt(t.getAttribute("data-citation-url") || "",
|
|
177
|
-
note:
|
|
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
|
|
178
168
|
};
|
|
179
169
|
}
|
|
180
|
-
function vt(t,
|
|
181
|
-
t.classList.add("rte-citation-ref"), t.setAttribute("data-citation-id",
|
|
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);
|
|
182
172
|
}
|
|
183
|
-
function it(t,
|
|
173
|
+
function it(t, e, n) {
|
|
184
174
|
const i = lt(t);
|
|
185
175
|
Array.from(
|
|
186
176
|
i.querySelectorAll(
|
|
187
|
-
`.rte-toolbar-button[data-command="${
|
|
177
|
+
`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`
|
|
188
178
|
)
|
|
189
179
|
).forEach((r) => {
|
|
190
|
-
r.classList.toggle("active",
|
|
180
|
+
r.classList.toggle("active", n), r.setAttribute("data-active", n ? "true" : "false"), r.setAttribute("aria-pressed", n ? "true" : "false");
|
|
191
181
|
});
|
|
192
182
|
}
|
|
193
|
-
function N(t,
|
|
194
|
-
const
|
|
195
|
-
return
|
|
183
|
+
function N(t, e) {
|
|
184
|
+
const n = T.get(t);
|
|
185
|
+
return n && L.includes(n) ? n : e?.defaultStyle || "apa";
|
|
196
186
|
}
|
|
197
|
-
function K(t,
|
|
198
|
-
const
|
|
199
|
-
return
|
|
200
|
-
const r = wt(o,
|
|
201
|
-
if (!r)
|
|
202
|
-
return;
|
|
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;
|
|
203
192
|
if (!i.has(r.id)) {
|
|
204
193
|
i.set(r.id, r);
|
|
205
194
|
return;
|
|
@@ -216,145 +205,137 @@ function K(t, n) {
|
|
|
216
205
|
});
|
|
217
206
|
}), Array.from(i.values());
|
|
218
207
|
}
|
|
219
|
-
function _t(t,
|
|
220
|
-
const i = yt(
|
|
221
|
-
if (!i.id || !i.author || !i.title)
|
|
222
|
-
return;
|
|
208
|
+
function _t(t, e, n) {
|
|
209
|
+
const i = yt(e, n);
|
|
210
|
+
if (!i.id || !i.author || !i.title) return;
|
|
223
211
|
const r = (D.get(t) || []).filter((a) => a.id !== i.id);
|
|
224
|
-
D.set(t, [i, ...r].slice(0,
|
|
212
|
+
D.set(t, [i, ...r].slice(0, n.maxRecentCitations));
|
|
225
213
|
}
|
|
226
|
-
function rt(t,
|
|
214
|
+
function rt(t, e, n) {
|
|
227
215
|
const i = D.get(t) || [], o = /* @__PURE__ */ new Map();
|
|
228
|
-
|
|
216
|
+
e.slice(Math.max(0, e.length - n.maxRecentCitations)).reverse().forEach((a) => {
|
|
229
217
|
a.id && o.set(a.id, a);
|
|
230
218
|
}), i.forEach((a) => {
|
|
231
219
|
!a.id || o.has(a.id) || o.set(a.id, a);
|
|
232
220
|
});
|
|
233
|
-
const r = Array.from(o.values()).slice(0,
|
|
221
|
+
const r = Array.from(o.values()).slice(0, n.maxRecentCitations);
|
|
234
222
|
return D.set(t, r), r;
|
|
235
223
|
}
|
|
236
|
-
function Et(t,
|
|
237
|
-
const o = F(i.normalizeText(
|
|
238
|
-
return o && rt(t,
|
|
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;
|
|
239
227
|
}
|
|
240
|
-
function qt(t,
|
|
241
|
-
const i = F(
|
|
242
|
-
if (!i)
|
|
243
|
-
return !1;
|
|
228
|
+
function qt(t, e, n) {
|
|
229
|
+
const i = F(n.normalizeText(e || ""));
|
|
230
|
+
if (!i) return !1;
|
|
244
231
|
const o = D.get(t) || [], r = o.filter((a) => a.id !== i);
|
|
245
232
|
return r.length === o.length ? !1 : (D.set(t, r), !0);
|
|
246
233
|
}
|
|
247
|
-
function
|
|
234
|
+
function St(t, e, n) {
|
|
248
235
|
const i = document.createElement("section");
|
|
249
|
-
i.className = t, i.setAttribute("data-type",
|
|
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");
|
|
250
237
|
const o = document.createElement("h3");
|
|
251
|
-
o.className = "rte-citation-section-title", o.textContent =
|
|
238
|
+
o.className = "rte-citation-section-title", o.textContent = n;
|
|
252
239
|
const r = document.createElement("ol");
|
|
253
240
|
return r.className = "rte-citation-list", r.setAttribute("role", "list"), i.appendChild(o), i.appendChild(r), i;
|
|
254
241
|
}
|
|
255
|
-
function jt(t,
|
|
256
|
-
let
|
|
257
|
-
|
|
258
|
-
const i =
|
|
259
|
-
return i && (i.textContent =
|
|
260
|
-
}
|
|
261
|
-
function Kt(t,
|
|
262
|
-
let
|
|
263
|
-
|
|
264
|
-
const i =
|
|
265
|
-
return i && (i.textContent =
|
|
266
|
-
}
|
|
267
|
-
function
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
St(t, W);
|
|
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);
|
|
274
260
|
return;
|
|
275
261
|
}
|
|
276
|
-
const r = jt(t,
|
|
277
|
-
if (!r)
|
|
278
|
-
return;
|
|
262
|
+
const r = jt(t, n).querySelector(".rte-citation-list");
|
|
263
|
+
if (!r) return;
|
|
279
264
|
const a = document.createDocumentFragment();
|
|
280
|
-
|
|
265
|
+
e.forEach((s, u) => {
|
|
281
266
|
const c = document.createElement("li");
|
|
282
|
-
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(
|
|
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);
|
|
283
268
|
}), r.innerHTML = "", r.appendChild(a);
|
|
284
269
|
}
|
|
285
|
-
function Wt(t,
|
|
286
|
-
if (!
|
|
287
|
-
|
|
270
|
+
function Wt(t, e, n, i) {
|
|
271
|
+
if (!n.enableFootnoteSync || e.length === 0) {
|
|
272
|
+
$t(t, G), R(t).forEach((l) => {
|
|
288
273
|
l.removeAttribute("data-footnote-number"), l.removeAttribute("data-footnote-target");
|
|
289
274
|
});
|
|
290
275
|
return;
|
|
291
276
|
}
|
|
292
|
-
const r = Kt(t,
|
|
293
|
-
if (!r)
|
|
294
|
-
return;
|
|
277
|
+
const r = Kt(t, n).querySelector(".rte-citation-list");
|
|
278
|
+
if (!r) return;
|
|
295
279
|
const a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
296
|
-
|
|
297
|
-
s.set(l.id,
|
|
280
|
+
e.forEach((l, d) => {
|
|
281
|
+
s.set(l.id, d + 1);
|
|
298
282
|
});
|
|
299
|
-
const
|
|
283
|
+
const u = /* @__PURE__ */ new Map();
|
|
300
284
|
R(t).forEach((l) => {
|
|
301
|
-
const
|
|
302
|
-
if (!
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
d
|
|
306
|
-
const w = `rte-citation-ref-${u}-${b}`;
|
|
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}`;
|
|
307
290
|
l.id = w;
|
|
308
|
-
const A = s.get(
|
|
309
|
-
l.setAttribute("data-footnote-number", String(A)), l.setAttribute("data-footnote-target", `rte-citation-note-${
|
|
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);
|
|
310
293
|
});
|
|
311
294
|
const c = document.createDocumentFragment();
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
|
|
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);
|
|
315
298
|
const w = document.createElement("span");
|
|
316
|
-
w.className = "rte-citation-footnote-number", w.textContent = `${
|
|
299
|
+
w.className = "rte-citation-footnote-number", w.textContent = `${d + 1}. `;
|
|
317
300
|
const A = document.createElement("span");
|
|
318
301
|
A.className = "rte-citation-footnote-text";
|
|
319
302
|
const It = l.note ? `${l.note}. ` : "";
|
|
320
|
-
A.textContent = `${It}${ut(l, i)}`,
|
|
321
|
-
const
|
|
322
|
-
if (
|
|
303
|
+
A.textContent = `${It}${ut(l, i)}`, m.appendChild(w), m.appendChild(A);
|
|
304
|
+
const gt = a.get(l.id);
|
|
305
|
+
if (gt) {
|
|
323
306
|
const _ = document.createElement("a");
|
|
324
|
-
_.className = "rte-citation-backref", _.href = `#${
|
|
307
|
+
_.className = "rte-citation-backref", _.href = `#${gt}`, _.setAttribute("aria-label", `Back to citation ${d + 1}`), _.textContent = "Back", m.appendChild(_);
|
|
325
308
|
}
|
|
326
|
-
c.appendChild(
|
|
309
|
+
c.appendChild(m);
|
|
327
310
|
}), r.innerHTML = "", r.appendChild(c);
|
|
328
311
|
}
|
|
329
|
-
function Gt(t,
|
|
330
|
-
const o = ut(
|
|
312
|
+
function Gt(t, e, n, i) {
|
|
313
|
+
const o = ut(e, n);
|
|
331
314
|
t.setAttribute("data-citation-number", String(i)), t.setAttribute("aria-label", `Citation ${i}: ${o}`);
|
|
332
315
|
}
|
|
333
|
-
function Vt(t,
|
|
316
|
+
function Vt(t, e, n) {
|
|
334
317
|
const i = R(t);
|
|
335
|
-
let o = `${
|
|
318
|
+
let o = `${e}:${n ? "1" : "0"}:${i.length}`;
|
|
336
319
|
return i.forEach((r) => {
|
|
337
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") || ""}`;
|
|
338
321
|
}), o;
|
|
339
322
|
}
|
|
340
323
|
function H(t) {
|
|
341
|
-
const
|
|
342
|
-
if (!
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
return;
|
|
347
|
-
const i = N(t, e), o = K(t, e), r = rt(t, o, e), a = n.querySelector(".rte-citations-status"), s = n.querySelector('[data-action="cycle-style"]'), d = n.querySelector(".rte-citations-recent-list");
|
|
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");
|
|
348
329
|
if (a) {
|
|
349
330
|
const c = o.length;
|
|
350
|
-
a.textContent = `${
|
|
331
|
+
a.textContent = `${n.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${n.enableFootnoteSync ? "On" : "Off"}`;
|
|
351
332
|
}
|
|
352
|
-
if (s && (s.textContent = `${
|
|
333
|
+
if (s && (s.textContent = `${n.labels.styleButtonPrefix}: ${i.toUpperCase()}`, s.setAttribute("aria-label", `${n.labels.styleButtonPrefix}: ${i.toUpperCase()}`)), u) {
|
|
353
334
|
if (r.length === 0) {
|
|
354
|
-
|
|
335
|
+
u.innerHTML = `<li class="rte-citations-empty">${g(n.labels.noCitationsText)}</li>`;
|
|
355
336
|
return;
|
|
356
337
|
}
|
|
357
|
-
|
|
338
|
+
u.innerHTML = r.map(
|
|
358
339
|
(c) => `
|
|
359
340
|
<li class="rte-citations-recent-item">
|
|
360
341
|
<div class="rte-citations-recent-row">
|
|
@@ -374,211 +355,191 @@ function H(t) {
|
|
|
374
355
|
data-action="delete-by-id"
|
|
375
356
|
data-citation-id="${g(c.id)}"
|
|
376
357
|
aria-label="Delete citation: ${g(c.title)}"
|
|
377
|
-
>${g(
|
|
358
|
+
>${g(n.labels.deleteRecentText)}</button>
|
|
378
359
|
</div>
|
|
379
360
|
</li>
|
|
380
361
|
`
|
|
381
362
|
).join("");
|
|
382
363
|
}
|
|
383
364
|
}
|
|
384
|
-
function y(t,
|
|
385
|
-
const i = N(t,
|
|
386
|
-
if (!
|
|
387
|
-
return K(t,
|
|
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);
|
|
388
369
|
const r = R(t), a = /* @__PURE__ */ new Map();
|
|
389
370
|
r.forEach((c) => {
|
|
390
|
-
const l = wt(c,
|
|
371
|
+
const l = wt(c, e);
|
|
391
372
|
l && (a.has(l.id) || a.set(l.id, l));
|
|
392
373
|
});
|
|
393
374
|
const s = Array.from(a.values());
|
|
394
|
-
rt(t, s,
|
|
395
|
-
const
|
|
375
|
+
rt(t, s, e);
|
|
376
|
+
const u = /* @__PURE__ */ new Map();
|
|
396
377
|
return s.forEach((c, l) => {
|
|
397
|
-
|
|
378
|
+
u.set(c.id, l + 1);
|
|
398
379
|
}), r.forEach((c) => {
|
|
399
|
-
const l = c.getAttribute("data-citation-id") || "",
|
|
400
|
-
if (!
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}), Ut(t, s, n, i), Wt(t, s, n, i), pt.set(t, o), H(t), t.dispatchEvent(
|
|
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(
|
|
406
386
|
new CustomEvent("editora:citations-refreshed", {
|
|
407
387
|
bubbles: !0,
|
|
408
388
|
detail: {
|
|
409
389
|
citations: s,
|
|
410
390
|
style: i,
|
|
411
|
-
footnoteSync:
|
|
391
|
+
footnoteSync: e.enableFootnoteSync
|
|
412
392
|
}
|
|
413
393
|
})
|
|
414
394
|
), s;
|
|
415
395
|
}
|
|
416
396
|
function At(t) {
|
|
417
|
-
const
|
|
418
|
-
typeof
|
|
397
|
+
const e = Q.get(t);
|
|
398
|
+
typeof e == "number" && (window.clearTimeout(e), q.delete(e), Q.delete(t));
|
|
419
399
|
}
|
|
420
400
|
function kt(t) {
|
|
421
|
-
const
|
|
422
|
-
if (!
|
|
423
|
-
return;
|
|
401
|
+
const e = f.get(t) || M;
|
|
402
|
+
if (!e) return;
|
|
424
403
|
At(t);
|
|
425
|
-
const
|
|
426
|
-
q.delete(
|
|
427
|
-
},
|
|
428
|
-
q.add(
|
|
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);
|
|
429
408
|
}
|
|
430
409
|
function Yt(t) {
|
|
431
|
-
const
|
|
432
|
-
if (!
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
const a = n.getRangeAt(0);
|
|
410
|
+
const e = window.getSelection();
|
|
411
|
+
if (!e) throw new Error("Selection unavailable");
|
|
412
|
+
if (e.rangeCount > 0) {
|
|
413
|
+
const a = e.getRangeAt(0);
|
|
436
414
|
if (t.contains(a.commonAncestorContainer) && !j(a.commonAncestorContainer))
|
|
437
415
|
return a.cloneRange();
|
|
438
416
|
}
|
|
439
|
-
const
|
|
440
|
-
return r ? (
|
|
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);
|
|
441
419
|
}
|
|
442
420
|
function dt(t) {
|
|
443
421
|
t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
444
422
|
}
|
|
445
|
-
function ft(t,
|
|
446
|
-
if (
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
if (typeof e == "function")
|
|
423
|
+
function ft(t, e) {
|
|
424
|
+
if (e === t.innerHTML) return;
|
|
425
|
+
const n = window.execEditorCommand || window.executeEditorCommand;
|
|
426
|
+
if (typeof n == "function")
|
|
450
427
|
try {
|
|
451
|
-
|
|
428
|
+
n("recordDomTransaction", t, e, t.innerHTML);
|
|
452
429
|
} catch {
|
|
453
430
|
}
|
|
454
431
|
}
|
|
455
|
-
function Tt(t,
|
|
456
|
-
const
|
|
457
|
-
if (!
|
|
458
|
-
return;
|
|
432
|
+
function Tt(t, e) {
|
|
433
|
+
const n = window.getSelection();
|
|
434
|
+
if (!n) return;
|
|
459
435
|
const i = document.createRange();
|
|
460
436
|
if (t.nodeType === Node.TEXT_NODE) {
|
|
461
|
-
const o = t, r = Math.max(0, Math.min(
|
|
437
|
+
const o = t, r = Math.max(0, Math.min(e, o.length));
|
|
462
438
|
i.setStart(o, r);
|
|
463
439
|
} else {
|
|
464
|
-
const o = t.childNodes.length, r = Math.max(0, Math.min(
|
|
440
|
+
const o = t.childNodes.length, r = Math.max(0, Math.min(e, o));
|
|
465
441
|
i.setStart(t, r);
|
|
466
442
|
}
|
|
467
|
-
i.collapse(!0),
|
|
443
|
+
i.collapse(!0), n.removeAllRanges(), n.addRange(i);
|
|
468
444
|
}
|
|
469
445
|
function Mt(t) {
|
|
470
446
|
if (t.collapsed || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1 || !(t.startContainer instanceof Element || t.startContainer instanceof DocumentFragment))
|
|
471
447
|
return null;
|
|
472
|
-
const
|
|
473
|
-
return !(
|
|
448
|
+
const e = t.startContainer.childNodes[t.startOffset];
|
|
449
|
+
return !(e instanceof HTMLElement) || !e.matches(ot) ? null : e;
|
|
474
450
|
}
|
|
475
|
-
function J(t,
|
|
451
|
+
function J(t, e, n) {
|
|
476
452
|
const { startContainer: i, startOffset: o } = t;
|
|
477
453
|
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
478
454
|
const a = i;
|
|
479
|
-
if (
|
|
480
|
-
if (o > 0)
|
|
481
|
-
return a.childNodes[o - 1] || null;
|
|
455
|
+
if (n === "previous") {
|
|
456
|
+
if (o > 0) return a.childNodes[o - 1] || null;
|
|
482
457
|
} else if (o < a.childNodes.length)
|
|
483
458
|
return a.childNodes[o] || null;
|
|
484
459
|
}
|
|
485
|
-
if (i.nodeType === Node.TEXT_NODE && (
|
|
460
|
+
if (i.nodeType === Node.TEXT_NODE && (n === "previous" && o < i.data.length || n === "next" && o > 0))
|
|
486
461
|
return null;
|
|
487
462
|
let r = i;
|
|
488
|
-
for (; r && r !==
|
|
489
|
-
const a =
|
|
490
|
-
if (a)
|
|
491
|
-
return a;
|
|
463
|
+
for (; r && r !== e; ) {
|
|
464
|
+
const a = n === "previous" ? r.previousSibling : r.nextSibling;
|
|
465
|
+
if (a) return a;
|
|
492
466
|
r = r.parentNode;
|
|
493
467
|
}
|
|
494
468
|
return null;
|
|
495
469
|
}
|
|
496
|
-
function Lt(t,
|
|
497
|
-
if (!t.collapsed)
|
|
498
|
-
return null;
|
|
470
|
+
function Lt(t, e, n) {
|
|
471
|
+
if (!t.collapsed) return null;
|
|
499
472
|
const i = (a) => a instanceof HTMLElement && a.matches(ot) ? a : null, { startContainer: o, startOffset: r } = t;
|
|
500
473
|
if (o.nodeType === Node.ELEMENT_NODE) {
|
|
501
474
|
const a = o;
|
|
502
|
-
return
|
|
475
|
+
return n === "Backspace" && r > 0 ? i(a.childNodes[r - 1] || null) : n === "Delete" ? i(a.childNodes[r] || null) : null;
|
|
503
476
|
}
|
|
504
477
|
if (o.nodeType === Node.TEXT_NODE) {
|
|
505
478
|
const a = o;
|
|
506
|
-
if (
|
|
479
|
+
if (n === "Backspace" && r === 0) {
|
|
507
480
|
const s = i(a.previousSibling);
|
|
508
|
-
return s || i(J(t,
|
|
481
|
+
return s || i(J(t, e, "previous"));
|
|
509
482
|
}
|
|
510
|
-
if (
|
|
483
|
+
if (n === "Delete" && r === a.data.length) {
|
|
511
484
|
const s = i(a.nextSibling);
|
|
512
|
-
return s || i(J(t,
|
|
485
|
+
return s || i(J(t, e, "next"));
|
|
513
486
|
}
|
|
514
487
|
}
|
|
515
|
-
return i(
|
|
488
|
+
return i(n === "Backspace" ? J(t, e, "previous") : J(t, e, "next"));
|
|
516
489
|
}
|
|
517
|
-
function P(t,
|
|
518
|
-
const i = t.closest(
|
|
519
|
-
if (!i || j(t))
|
|
520
|
-
return !1;
|
|
490
|
+
function P(t, e, n) {
|
|
491
|
+
const i = t.closest(S);
|
|
492
|
+
if (!i || j(t)) return !1;
|
|
521
493
|
const o = t.parentNode;
|
|
522
|
-
if (!o)
|
|
523
|
-
return !1;
|
|
494
|
+
if (!o) return !1;
|
|
524
495
|
const r = i.innerHTML, a = Array.from(o.childNodes).indexOf(t);
|
|
525
|
-
if (a < 0)
|
|
526
|
-
return !1;
|
|
496
|
+
if (a < 0) return !1;
|
|
527
497
|
const s = t.nextSibling;
|
|
528
|
-
return s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), t.remove(), Tt(o, a), y(i,
|
|
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;
|
|
529
499
|
}
|
|
530
|
-
function Xt(t,
|
|
531
|
-
if (t.key !== "Backspace" && t.key !== "Delete")
|
|
532
|
-
return !1;
|
|
500
|
+
function Xt(t, e, n) {
|
|
501
|
+
if (t.key !== "Backspace" && t.key !== "Delete") return !1;
|
|
533
502
|
const i = t.key, o = t.target;
|
|
534
|
-
if (o
|
|
535
|
-
return t.preventDefault(), t.stopPropagation(), P(o, i,
|
|
503
|
+
if (o?.matches(ot) && e.contains(o) && !j(o))
|
|
504
|
+
return t.preventDefault(), t.stopPropagation(), P(o, i, n);
|
|
536
505
|
const r = window.getSelection();
|
|
537
|
-
if (!r || r.rangeCount === 0)
|
|
538
|
-
return !1;
|
|
506
|
+
if (!r || r.rangeCount === 0) return !1;
|
|
539
507
|
const a = r.getRangeAt(0);
|
|
540
|
-
if (!
|
|
541
|
-
return !1;
|
|
508
|
+
if (!e.contains(a.commonAncestorContainer) || j(a.commonAncestorContainer)) return !1;
|
|
542
509
|
const s = Mt(a);
|
|
543
510
|
if (s)
|
|
544
|
-
return t.preventDefault(), t.stopPropagation(), P(s, i,
|
|
545
|
-
const
|
|
546
|
-
return
|
|
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;
|
|
547
514
|
}
|
|
548
|
-
function Rt(t,
|
|
549
|
-
const i = F(
|
|
550
|
-
if (!i)
|
|
551
|
-
return !1;
|
|
515
|
+
function Rt(t, e, n) {
|
|
516
|
+
const i = F(n.normalizeText(e || ""));
|
|
517
|
+
if (!i) return !1;
|
|
552
518
|
const o = R(t).filter((a) => a.getAttribute("data-citation-id") === i);
|
|
553
|
-
if (o.length === 0)
|
|
554
|
-
return !1;
|
|
519
|
+
if (o.length === 0) return !1;
|
|
555
520
|
if (o.length === 1)
|
|
556
|
-
return P(o[0], "Delete",
|
|
521
|
+
return P(o[0], "Delete", n);
|
|
557
522
|
const r = t.innerHTML;
|
|
558
523
|
return o.forEach((a) => {
|
|
559
524
|
const s = a.nextSibling;
|
|
560
525
|
s instanceof Text && (s.data === " " ? s.remove() : s.data.startsWith(" ") && (s.data = s.data.slice(1))), a.remove();
|
|
561
|
-
}), Tt(t, t.childNodes.length), y(t,
|
|
526
|
+
}), Tt(t, t.childNodes.length), y(t, n, !0), ft(t, r), dt(t), t.focus({ preventScroll: !0 }), !0;
|
|
562
527
|
}
|
|
563
|
-
function Jt(t,
|
|
564
|
-
const
|
|
565
|
-
if (!
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (!t.contains(i.commonAncestorContainer) || j(i.commonAncestorContainer))
|
|
569
|
-
return !1;
|
|
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;
|
|
570
533
|
const o = Mt(i);
|
|
571
534
|
if (o)
|
|
572
|
-
return P(o, "Delete",
|
|
535
|
+
return P(o, "Delete", e);
|
|
573
536
|
const r = Lt(i, t, "Backspace");
|
|
574
|
-
return r ? P(r, "Backspace",
|
|
537
|
+
return r ? P(r, "Backspace", e) : !1;
|
|
575
538
|
}
|
|
576
|
-
function et(t,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
return !1;
|
|
581
|
-
i.id || (i.id = Ht(t, e));
|
|
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));
|
|
582
543
|
const o = t.innerHTML;
|
|
583
544
|
let r;
|
|
584
545
|
try {
|
|
@@ -587,104 +548,97 @@ function et(t, n, e) {
|
|
|
587
548
|
return !1;
|
|
588
549
|
}
|
|
589
550
|
const a = window.getSelection();
|
|
590
|
-
if (!a)
|
|
591
|
-
return !1;
|
|
551
|
+
if (!a) return !1;
|
|
592
552
|
r.collapsed || r.deleteContents();
|
|
593
553
|
const s = document.createElement("span");
|
|
594
|
-
vt(s, i, N(t,
|
|
554
|
+
vt(s, i, N(t, n));
|
|
595
555
|
try {
|
|
596
556
|
r.insertNode(s);
|
|
597
557
|
} catch {
|
|
598
558
|
return !1;
|
|
599
559
|
}
|
|
600
|
-
const
|
|
601
|
-
s.nextSibling ?
|
|
560
|
+
const u = document.createTextNode(" ");
|
|
561
|
+
s.nextSibling ? s.parentNode?.insertBefore(u, s.nextSibling) : s.parentNode?.appendChild(u);
|
|
602
562
|
const c = document.createRange();
|
|
603
|
-
if (
|
|
604
|
-
const
|
|
605
|
-
c.setStart(
|
|
563
|
+
if (u.parentNode) {
|
|
564
|
+
const l = Array.from(u.parentNode.childNodes).indexOf(u) + 1;
|
|
565
|
+
c.setStart(u.parentNode, Math.max(0, l));
|
|
606
566
|
} else
|
|
607
567
|
c.setStartAfter(s);
|
|
608
|
-
return c.collapse(!0), a.removeAllRanges(), a.addRange(c), _t(t, i,
|
|
568
|
+
return c.collapse(!0), a.removeAllRanges(), a.addRange(c), _t(t, i, n), y(t, n, !0), ft(t, o), dt(t), !0;
|
|
609
569
|
}
|
|
610
|
-
function Zt(t,
|
|
611
|
-
if (!
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
return !1;
|
|
616
|
-
e.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), e.focus({ preventScroll: !0 });
|
|
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 });
|
|
617
575
|
const i = window.getSelection();
|
|
618
|
-
if (!i)
|
|
619
|
-
return !0;
|
|
576
|
+
if (!i) return !0;
|
|
620
577
|
const o = document.createRange();
|
|
621
|
-
return o.selectNode(
|
|
578
|
+
return o.selectNode(n), i.removeAllRanges(), i.addRange(o), !0;
|
|
622
579
|
}
|
|
623
580
|
function nt(t) {
|
|
624
581
|
return V.get(t) === !0;
|
|
625
582
|
}
|
|
626
|
-
function U(t,
|
|
627
|
-
const
|
|
628
|
-
|
|
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 }));
|
|
629
586
|
}
|
|
630
587
|
function Qt(t) {
|
|
631
|
-
v.forEach((
|
|
632
|
-
|
|
588
|
+
v.forEach((e, n) => {
|
|
589
|
+
n !== t && U(n, !1);
|
|
633
590
|
});
|
|
634
591
|
}
|
|
635
|
-
function ct(t,
|
|
636
|
-
if (!
|
|
637
|
-
return;
|
|
592
|
+
function ct(t, e) {
|
|
593
|
+
if (!e.classList.contains("show")) return;
|
|
638
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));
|
|
639
|
-
|
|
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`;
|
|
640
596
|
}
|
|
641
|
-
function C(t,
|
|
642
|
-
return t.querySelector(`[data-field="${
|
|
597
|
+
function C(t, e) {
|
|
598
|
+
return t.querySelector(`[data-field="${e}"]`);
|
|
643
599
|
}
|
|
644
600
|
function te(t) {
|
|
645
|
-
|
|
646
|
-
const n = ((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) || "", o = ((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) || "";
|
|
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 || "";
|
|
647
602
|
return {
|
|
648
|
-
author:
|
|
649
|
-
year:
|
|
603
|
+
author: e,
|
|
604
|
+
year: n,
|
|
650
605
|
title: i,
|
|
651
606
|
source: o,
|
|
652
607
|
url: r,
|
|
653
608
|
note: a
|
|
654
609
|
};
|
|
655
610
|
}
|
|
656
|
-
function E(t,
|
|
657
|
-
const
|
|
658
|
-
|
|
611
|
+
function E(t, e) {
|
|
612
|
+
const n = t.querySelector(".rte-citations-live");
|
|
613
|
+
n && (n.textContent = e);
|
|
659
614
|
}
|
|
660
|
-
function ee(t,
|
|
661
|
-
const i = C(
|
|
662
|
-
i && (i.value = N(t,
|
|
615
|
+
function ee(t, e, n) {
|
|
616
|
+
const i = C(e, "style");
|
|
617
|
+
i && (i.value = N(t, n));
|
|
663
618
|
}
|
|
664
|
-
function Nt(t,
|
|
665
|
-
const i = L.includes(
|
|
666
|
-
return T.set(t, i), y(t,
|
|
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;
|
|
667
622
|
}
|
|
668
|
-
function bt(t,
|
|
669
|
-
const
|
|
670
|
-
return T.set(t, o), y(t,
|
|
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;
|
|
671
626
|
}
|
|
672
627
|
function ne(t) {
|
|
673
|
-
const
|
|
674
|
-
if (
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
o.className = m, o.id = i, o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false"), o.setAttribute("aria-label", e.labels.panelAriaLabel), o.setAttribute("tabindex", "-1"), o.innerHTML = `
|
|
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 = `
|
|
678
632
|
<header class="rte-citations-header">
|
|
679
|
-
<h2 class="rte-citations-title">${g(
|
|
680
|
-
<button type="button" class="rte-citations-icon-btn" data-action="close" aria-label="${g(
|
|
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>
|
|
681
635
|
</header>
|
|
682
636
|
<div class="rte-citations-body">
|
|
683
637
|
<p class="rte-citations-status" aria-live="polite"></p>
|
|
684
638
|
|
|
685
639
|
<div class="rte-citations-grid">
|
|
686
640
|
<label class="rte-citations-label">
|
|
687
|
-
${g(
|
|
641
|
+
${g(n.labels.styleLabel)}
|
|
688
642
|
<select data-field="style" class="rte-citations-field">
|
|
689
643
|
<option value="apa">APA</option>
|
|
690
644
|
<option value="mla">MLA</option>
|
|
@@ -692,39 +646,39 @@ function ne(t) {
|
|
|
692
646
|
</select>
|
|
693
647
|
</label>
|
|
694
648
|
<label class="rte-citations-label">
|
|
695
|
-
${g(
|
|
649
|
+
${g(n.labels.authorLabel)}
|
|
696
650
|
<input type="text" data-field="author" class="rte-citations-field" autocomplete="off" />
|
|
697
651
|
</label>
|
|
698
652
|
<label class="rte-citations-label">
|
|
699
|
-
${g(
|
|
653
|
+
${g(n.labels.yearLabel)}
|
|
700
654
|
<input type="text" data-field="year" class="rte-citations-field" inputmode="numeric" autocomplete="off" />
|
|
701
655
|
</label>
|
|
702
656
|
<label class="rte-citations-label">
|
|
703
|
-
${g(
|
|
657
|
+
${g(n.labels.titleLabel)}
|
|
704
658
|
<input type="text" data-field="title" class="rte-citations-field" autocomplete="off" />
|
|
705
659
|
</label>
|
|
706
660
|
<label class="rte-citations-label">
|
|
707
|
-
${g(
|
|
661
|
+
${g(n.labels.sourceLabel)}
|
|
708
662
|
<input type="text" data-field="source" class="rte-citations-field" autocomplete="off" />
|
|
709
663
|
</label>
|
|
710
664
|
<label class="rte-citations-label">
|
|
711
|
-
${g(
|
|
665
|
+
${g(n.labels.urlLabel)}
|
|
712
666
|
<input type="url" data-field="url" class="rte-citations-field" autocomplete="off" />
|
|
713
667
|
</label>
|
|
714
668
|
<label class="rte-citations-label rte-citations-label-note">
|
|
715
|
-
${g(
|
|
669
|
+
${g(n.labels.noteLabel)}
|
|
716
670
|
<textarea data-field="note" class="rte-citations-field" rows="2"></textarea>
|
|
717
671
|
</label>
|
|
718
672
|
</div>
|
|
719
673
|
|
|
720
674
|
<div class="rte-citations-controls" role="toolbar" aria-label="Citation actions">
|
|
721
|
-
<button type="button" class="rte-citations-btn rte-citations-btn-primary" data-action="insert">${g(
|
|
722
|
-
<button type="button" class="rte-citations-btn" data-action="refresh">${g(
|
|
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>
|
|
723
677
|
<button type="button" class="rte-citations-btn" data-action="cycle-style"></button>
|
|
724
678
|
</div>
|
|
725
679
|
|
|
726
|
-
<section class="rte-citations-recent" aria-label="${g(
|
|
727
|
-
<h3 class="rte-citations-recent-heading">${g(
|
|
680
|
+
<section class="rte-citations-recent" aria-label="${g(n.labels.recentHeading)}">
|
|
681
|
+
<h3 class="rte-citations-recent-heading">${g(n.labels.recentHeading)}</h3>
|
|
728
682
|
<ul class="rte-citations-recent-list" role="list"></ul>
|
|
729
683
|
</section>
|
|
730
684
|
|
|
@@ -733,25 +687,22 @@ function ne(t) {
|
|
|
733
687
|
</div>
|
|
734
688
|
`, o.addEventListener("click", (a) => {
|
|
735
689
|
const s = a.target;
|
|
736
|
-
if (!s)
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
return;
|
|
741
|
-
const c = d.getAttribute("data-action") || "", l = f.get(t) || M || e;
|
|
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;
|
|
742
694
|
if (f.set(t, l), c === "close") {
|
|
743
695
|
U(t, !0);
|
|
744
696
|
return;
|
|
745
697
|
}
|
|
746
698
|
if (c === "insert") {
|
|
747
|
-
if (
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
if (!l.normalizeText(u.author) || !l.normalizeText(u.title)) {
|
|
699
|
+
if ($(t)) return;
|
|
700
|
+
const d = te(o);
|
|
701
|
+
if (!l.normalizeText(d.author) || !l.normalizeText(d.title)) {
|
|
751
702
|
E(o, l.labels.invalidMessage);
|
|
752
703
|
return;
|
|
753
704
|
}
|
|
754
|
-
if (!et(t,
|
|
705
|
+
if (!et(t, d, l)) {
|
|
755
706
|
E(o, l.labels.invalidMessage);
|
|
756
707
|
return;
|
|
757
708
|
}
|
|
@@ -761,33 +712,30 @@ function ne(t) {
|
|
|
761
712
|
return;
|
|
762
713
|
}
|
|
763
714
|
if (c === "refresh") {
|
|
764
|
-
const
|
|
765
|
-
E(o, `Refreshed ${
|
|
715
|
+
const d = y(t, l, !0);
|
|
716
|
+
E(o, `Refreshed ${d.length} citation${d.length === 1 ? "" : "s"}.`);
|
|
766
717
|
return;
|
|
767
718
|
}
|
|
768
719
|
if (c === "cycle-style") {
|
|
769
|
-
const
|
|
770
|
-
ee(t, o, l), E(o, `Style changed to ${
|
|
720
|
+
const d = bt(t, l);
|
|
721
|
+
ee(t, o, l), E(o, `Style changed to ${d.toUpperCase()}.`);
|
|
771
722
|
return;
|
|
772
723
|
}
|
|
773
724
|
if (c === "insert-from-recent") {
|
|
774
|
-
if (
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
return;
|
|
779
|
-
et(t, b, l), E(o, `Inserted citation: ${b.title}.`);
|
|
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}.`);
|
|
780
729
|
return;
|
|
781
730
|
}
|
|
782
731
|
if (c === "delete-by-id") {
|
|
783
|
-
if (
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
if (Rt(t, u, l)) {
|
|
732
|
+
if ($(t)) return;
|
|
733
|
+
const d = u.getAttribute("data-citation-id") || "";
|
|
734
|
+
if (Rt(t, d, l)) {
|
|
787
735
|
E(o, "Citation deleted.");
|
|
788
736
|
return;
|
|
789
737
|
}
|
|
790
|
-
qt(t,
|
|
738
|
+
qt(t, d, l) && (H(t), E(o, "Removed from recent citations."));
|
|
791
739
|
}
|
|
792
740
|
}), o.addEventListener("keydown", (a) => {
|
|
793
741
|
if (a.key === "Escape") {
|
|
@@ -795,86 +743,78 @@ function ne(t) {
|
|
|
795
743
|
return;
|
|
796
744
|
}
|
|
797
745
|
const s = a.target;
|
|
798
|
-
if (!s || !s.matches(".rte-citations-recent-btn") || a.key !== "ArrowDown" && a.key !== "ArrowUp")
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
const c = d.indexOf(s);
|
|
804
|
-
if (c < 0)
|
|
805
|
-
return;
|
|
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;
|
|
806
751
|
a.preventDefault();
|
|
807
|
-
const l = a.key === "ArrowDown" ? 1 : -1,
|
|
808
|
-
d
|
|
752
|
+
const l = a.key === "ArrowDown" ? 1 : -1, d = (c + l + u.length) % u.length;
|
|
753
|
+
u[d].focus();
|
|
809
754
|
});
|
|
810
755
|
const r = C(o, "style");
|
|
811
|
-
return r
|
|
812
|
-
const a = f.get(t) || M ||
|
|
756
|
+
return r?.addEventListener("change", () => {
|
|
757
|
+
const a = f.get(t) || M || n, s = r.value;
|
|
813
758
|
Nt(t, s, a), E(o, `Style changed to ${s.toUpperCase()}.`);
|
|
814
759
|
}), tt(o, t), document.body.appendChild(o), v.set(t, o), V.set(t, !1), H(t), o;
|
|
815
760
|
}
|
|
816
761
|
function z(t) {
|
|
817
|
-
const
|
|
818
|
-
Qt(t),
|
|
819
|
-
const e = C(n, "author");
|
|
820
|
-
e == null || e.focus();
|
|
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();
|
|
821
764
|
}
|
|
822
|
-
function zt(t,
|
|
823
|
-
const
|
|
824
|
-
return (typeof
|
|
765
|
+
function zt(t, e) {
|
|
766
|
+
const n = nt(t);
|
|
767
|
+
return (typeof e == "boolean" ? e : !n) ? z(t) : U(t, !1), !0;
|
|
825
768
|
}
|
|
826
769
|
function oe(t) {
|
|
827
|
-
const
|
|
828
|
-
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey &&
|
|
770
|
+
const e = t.key.toLowerCase();
|
|
771
|
+
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "c";
|
|
829
772
|
}
|
|
830
773
|
function ie(t) {
|
|
831
|
-
const
|
|
832
|
-
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey &&
|
|
774
|
+
const e = t.key.toLowerCase();
|
|
775
|
+
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "b";
|
|
833
776
|
}
|
|
834
777
|
function re(t) {
|
|
835
|
-
const
|
|
836
|
-
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey &&
|
|
778
|
+
const e = t.key.toLowerCase();
|
|
779
|
+
return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "j";
|
|
837
780
|
}
|
|
838
781
|
function ae(t) {
|
|
839
|
-
M = t, I || (I = (
|
|
840
|
-
const
|
|
841
|
-
if (!i)
|
|
842
|
-
return;
|
|
782
|
+
M = t, I || (I = (e) => {
|
|
783
|
+
const i = e.target?.closest(S);
|
|
784
|
+
if (!i) return;
|
|
843
785
|
p = i, f.has(i) || f.set(i, t), T.has(i) || T.set(i, t.defaultStyle);
|
|
844
786
|
const o = v.get(i);
|
|
845
787
|
o && (tt(o, i), ct(i, o)), it(i, "toggleCitationsPanel", nt(i));
|
|
846
|
-
}, document.addEventListener("focusin", I, !0)), B || (B = (
|
|
847
|
-
const
|
|
788
|
+
}, document.addEventListener("focusin", I, !0)), B || (B = (e) => {
|
|
789
|
+
const i = e.target?.closest(S);
|
|
848
790
|
i && (p = i, kt(i));
|
|
849
|
-
}, document.addEventListener("input", B, !0)), O || (O = (
|
|
850
|
-
if (
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
if (!o || S(o))
|
|
854
|
-
return;
|
|
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;
|
|
855
795
|
const r = f.get(o) || M || t;
|
|
856
|
-
if (f.set(o, r), p = o,
|
|
857
|
-
|
|
796
|
+
if (f.set(o, r), p = o, e.key === "Escape" && nt(o)) {
|
|
797
|
+
e.preventDefault(), U(o, !0);
|
|
858
798
|
return;
|
|
859
799
|
}
|
|
860
|
-
if (!i && !Xt(
|
|
861
|
-
if (oe(
|
|
862
|
-
|
|
800
|
+
if (!i && !Xt(e, o, r)) {
|
|
801
|
+
if (oe(e)) {
|
|
802
|
+
e.preventDefault(), e.stopPropagation(), zt(o);
|
|
863
803
|
return;
|
|
864
804
|
}
|
|
865
|
-
if (ie(
|
|
866
|
-
|
|
805
|
+
if (ie(e)) {
|
|
806
|
+
e.preventDefault(), e.stopPropagation(), y(o, r, !0), z(o);
|
|
867
807
|
return;
|
|
868
808
|
}
|
|
869
|
-
re(
|
|
809
|
+
re(e) && (e.preventDefault(), e.stopPropagation(), bt(o, r));
|
|
870
810
|
}
|
|
871
811
|
}, document.addEventListener("keydown", O, !0)), k || (k = () => {
|
|
872
|
-
v.forEach((
|
|
873
|
-
if (!
|
|
874
|
-
At(
|
|
812
|
+
v.forEach((e, n) => {
|
|
813
|
+
if (!n.isConnected || !e.isConnected) {
|
|
814
|
+
At(n), e.remove(), v.delete(n), V.delete(n);
|
|
875
815
|
return;
|
|
876
816
|
}
|
|
877
|
-
tt(
|
|
817
|
+
tt(e, n), ct(n, e);
|
|
878
818
|
});
|
|
879
819
|
}, window.addEventListener("scroll", k, !0), window.addEventListener("resize", k));
|
|
880
820
|
}
|
|
@@ -882,10 +822,9 @@ function se() {
|
|
|
882
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;
|
|
883
823
|
}
|
|
884
824
|
function ce() {
|
|
885
|
-
if (typeof document > "u" || document.getElementById(
|
|
886
|
-
return;
|
|
825
|
+
if (typeof document > "u" || document.getElementById(mt)) return;
|
|
887
826
|
const t = document.createElement("style");
|
|
888
|
-
t.id =
|
|
827
|
+
t.id = mt, t.textContent = `
|
|
889
828
|
.rte-toolbar-group-items.citations,
|
|
890
829
|
.editora-toolbar-group-items.citations {
|
|
891
830
|
display: flex;
|
|
@@ -913,7 +852,7 @@ function ce() {
|
|
|
913
852
|
|
|
914
853
|
${x} .rte-toolbar-group-items.citations,
|
|
915
854
|
${x} .editora-toolbar-group-items.citations,
|
|
916
|
-
.${
|
|
855
|
+
.${b}.rte-citations-theme-dark {
|
|
917
856
|
border-color: #566275;
|
|
918
857
|
}
|
|
919
858
|
|
|
@@ -931,7 +870,7 @@ function ce() {
|
|
|
931
870
|
${x} .editora-toolbar-button[data-command="toggleCitationsPanel"].active {
|
|
932
871
|
background: linear-gradient(180deg, #5eaaf6 0%, #4a95de 100%);
|
|
933
872
|
}
|
|
934
|
-
.${
|
|
873
|
+
.${b} {
|
|
935
874
|
position: fixed;
|
|
936
875
|
z-index: 1500;
|
|
937
876
|
right: 16px;
|
|
@@ -948,11 +887,11 @@ function ce() {
|
|
|
948
887
|
overflow: hidden;
|
|
949
888
|
}
|
|
950
889
|
|
|
951
|
-
.${
|
|
890
|
+
.${b}.show {
|
|
952
891
|
display: flex;
|
|
953
892
|
}
|
|
954
893
|
|
|
955
|
-
.${
|
|
894
|
+
.${b}.rte-citations-theme-dark {
|
|
956
895
|
background: #0f172a;
|
|
957
896
|
color: #e2e8f0;
|
|
958
897
|
border-color: #334155;
|
|
@@ -968,7 +907,7 @@ function ce() {
|
|
|
968
907
|
background: #f8fafc;
|
|
969
908
|
}
|
|
970
909
|
|
|
971
|
-
.${
|
|
910
|
+
.${b}.rte-citations-theme-dark .rte-citations-header {
|
|
972
911
|
border-bottom-color: #334155;
|
|
973
912
|
background: #111827;
|
|
974
913
|
}
|
|
@@ -1005,14 +944,14 @@ function ce() {
|
|
|
1005
944
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
1006
945
|
}
|
|
1007
946
|
|
|
1008
|
-
.${
|
|
947
|
+
.${b}.rte-citations-theme-dark .rte-citations-icon-btn {
|
|
1009
948
|
background: #0f172a;
|
|
1010
949
|
border-color: #475569;
|
|
1011
950
|
color: #e2e8f0;
|
|
1012
951
|
}
|
|
1013
952
|
|
|
1014
|
-
.${
|
|
1015
|
-
.${
|
|
953
|
+
.${b}.rte-citations-theme-dark .rte-citations-icon-btn:hover,
|
|
954
|
+
.${b}.rte-citations-theme-dark .rte-citations-icon-btn:focus-visible {
|
|
1016
955
|
border-color: #60a5fa;
|
|
1017
956
|
box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
|
|
1018
957
|
}
|
|
@@ -1031,7 +970,7 @@ function ce() {
|
|
|
1031
970
|
color: #475569;
|
|
1032
971
|
}
|
|
1033
972
|
|
|
1034
|
-
.${
|
|
973
|
+
.${b}.rte-citations-theme-dark .rte-citations-status {
|
|
1035
974
|
color: #94a3b8;
|
|
1036
975
|
}
|
|
1037
976
|
|
|
@@ -1072,7 +1011,7 @@ function ce() {
|
|
|
1072
1011
|
box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.2);
|
|
1073
1012
|
}
|
|
1074
1013
|
|
|
1075
|
-
.${
|
|
1014
|
+
.${b}.rte-citations-theme-dark .rte-citations-field {
|
|
1076
1015
|
border-color: #334155;
|
|
1077
1016
|
background: #0b1220;
|
|
1078
1017
|
color: #e2e8f0;
|
|
@@ -1114,13 +1053,13 @@ function ce() {
|
|
|
1114
1053
|
border-color: #1e40af;
|
|
1115
1054
|
}
|
|
1116
1055
|
|
|
1117
|
-
.${
|
|
1056
|
+
.${b}.rte-citations-theme-dark .rte-citations-btn {
|
|
1118
1057
|
border-color: #334155;
|
|
1119
1058
|
background: #0b1220;
|
|
1120
1059
|
color: #e2e8f0;
|
|
1121
1060
|
}
|
|
1122
1061
|
|
|
1123
|
-
.${
|
|
1062
|
+
.${b}.rte-citations-theme-dark .rte-citations-btn-primary {
|
|
1124
1063
|
border-color: #2563eb;
|
|
1125
1064
|
background: #2563eb;
|
|
1126
1065
|
color: #ffffff;
|
|
@@ -1132,7 +1071,7 @@ function ce() {
|
|
|
1132
1071
|
padding: 8px;
|
|
1133
1072
|
}
|
|
1134
1073
|
|
|
1135
|
-
.${
|
|
1074
|
+
.${b}.rte-citations-theme-dark .rte-citations-recent {
|
|
1136
1075
|
border-color: #334155;
|
|
1137
1076
|
}
|
|
1138
1077
|
|
|
@@ -1200,13 +1139,13 @@ function ce() {
|
|
|
1200
1139
|
box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.18);
|
|
1201
1140
|
}
|
|
1202
1141
|
|
|
1203
|
-
.${
|
|
1142
|
+
.${b}.rte-citations-theme-dark .rte-citations-recent-btn {
|
|
1204
1143
|
border-color: #334155;
|
|
1205
1144
|
background: #0b1220;
|
|
1206
1145
|
color: #e2e8f0;
|
|
1207
1146
|
}
|
|
1208
1147
|
|
|
1209
|
-
.${
|
|
1148
|
+
.${b}.rte-citations-theme-dark .rte-citations-recent-delete {
|
|
1210
1149
|
border-color: #7f1d1d;
|
|
1211
1150
|
background: #2b1218;
|
|
1212
1151
|
color: #fca5a5;
|
|
@@ -1224,7 +1163,7 @@ function ce() {
|
|
|
1224
1163
|
line-height: 1.3;
|
|
1225
1164
|
}
|
|
1226
1165
|
|
|
1227
|
-
.${
|
|
1166
|
+
.${b}.rte-citations-theme-dark .rte-citations-recent-meta {
|
|
1228
1167
|
color: #94a3b8;
|
|
1229
1168
|
}
|
|
1230
1169
|
|
|
@@ -1236,7 +1175,7 @@ function ce() {
|
|
|
1236
1175
|
color: #64748b;
|
|
1237
1176
|
}
|
|
1238
1177
|
|
|
1239
|
-
.${
|
|
1178
|
+
.${b}.rte-citations-theme-dark .rte-citations-empty {
|
|
1240
1179
|
border-color: #334155;
|
|
1241
1180
|
color: #94a3b8;
|
|
1242
1181
|
}
|
|
@@ -1247,7 +1186,7 @@ function ce() {
|
|
|
1247
1186
|
color: #64748b;
|
|
1248
1187
|
}
|
|
1249
1188
|
|
|
1250
|
-
.${
|
|
1189
|
+
.${b}.rte-citations-theme-dark .rte-citations-shortcut {
|
|
1251
1190
|
color: #94a3b8;
|
|
1252
1191
|
}
|
|
1253
1192
|
|
|
@@ -1337,7 +1276,7 @@ function ce() {
|
|
|
1337
1276
|
}
|
|
1338
1277
|
|
|
1339
1278
|
@media (max-width: 768px) {
|
|
1340
|
-
.${
|
|
1279
|
+
.${b} {
|
|
1341
1280
|
left: 10px !important;
|
|
1342
1281
|
right: 10px;
|
|
1343
1282
|
top: 10px !important;
|
|
@@ -1356,7 +1295,7 @@ function ce() {
|
|
|
1356
1295
|
`, document.head.appendChild(t);
|
|
1357
1296
|
}
|
|
1358
1297
|
const le = (t = {}) => {
|
|
1359
|
-
const
|
|
1298
|
+
const e = Z(t);
|
|
1360
1299
|
return ce(), {
|
|
1361
1300
|
name: "citations",
|
|
1362
1301
|
toolbar: [
|
|
@@ -1391,60 +1330,53 @@ const le = (t = {}) => {
|
|
|
1391
1330
|
}
|
|
1392
1331
|
],
|
|
1393
1332
|
commands: {
|
|
1394
|
-
citations: (
|
|
1333
|
+
citations: (n, i) => {
|
|
1395
1334
|
const o = h(i);
|
|
1396
|
-
if (!o ||
|
|
1397
|
-
|
|
1398
|
-
const r = f.get(o) || n;
|
|
1335
|
+
if (!o || $(o)) return !1;
|
|
1336
|
+
const r = f.get(o) || e;
|
|
1399
1337
|
return f.set(o, r), T.set(o, N(o, r)), p = o, z(o), y(o, r, !1), !0;
|
|
1400
1338
|
},
|
|
1401
|
-
toggleCitationsPanel: (
|
|
1339
|
+
toggleCitationsPanel: (n, i) => {
|
|
1402
1340
|
const o = h(i);
|
|
1403
|
-
if (!o ||
|
|
1404
|
-
|
|
1405
|
-
const r = f.get(o) || n;
|
|
1341
|
+
if (!o || $(o)) return !1;
|
|
1342
|
+
const r = f.get(o) || e;
|
|
1406
1343
|
f.set(o, r), p = o;
|
|
1407
|
-
const a = zt(o, typeof
|
|
1344
|
+
const a = zt(o, typeof n == "boolean" ? n : void 0);
|
|
1408
1345
|
return nt(o) && y(o, r, !1), a;
|
|
1409
1346
|
},
|
|
1410
|
-
insertCitation: (
|
|
1347
|
+
insertCitation: (n, i) => {
|
|
1411
1348
|
const o = h(i);
|
|
1412
|
-
if (!o ||
|
|
1413
|
-
|
|
1414
|
-
const r = f.get(o) || n;
|
|
1349
|
+
if (!o || $(o) || !n || typeof n != "object") return !1;
|
|
1350
|
+
const r = f.get(o) || e;
|
|
1415
1351
|
f.set(o, r), p = o;
|
|
1416
|
-
const a = et(o,
|
|
1352
|
+
const a = et(o, n, r);
|
|
1417
1353
|
return a && z(o), a;
|
|
1418
1354
|
},
|
|
1419
|
-
refreshCitations: (
|
|
1355
|
+
refreshCitations: (n, i) => {
|
|
1420
1356
|
const o = h(i);
|
|
1421
|
-
if (!o)
|
|
1422
|
-
|
|
1423
|
-
const r = f.get(o) || n;
|
|
1357
|
+
if (!o) return !1;
|
|
1358
|
+
const r = f.get(o) || e;
|
|
1424
1359
|
return f.set(o, r), p = o, y(o, r, !0), z(o), !0;
|
|
1425
1360
|
},
|
|
1426
|
-
setCitationStyle: (
|
|
1361
|
+
setCitationStyle: (n, i) => {
|
|
1427
1362
|
const o = h(i);
|
|
1428
|
-
if (!o || !
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
return f.set(o, r), p = o, Nt(o, e, r), !0;
|
|
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;
|
|
1432
1366
|
},
|
|
1433
|
-
cycleCitationStyle: (
|
|
1367
|
+
cycleCitationStyle: (n, i) => {
|
|
1434
1368
|
const o = h(i);
|
|
1435
|
-
if (!o)
|
|
1436
|
-
|
|
1437
|
-
const r = f.get(o) || n;
|
|
1369
|
+
if (!o) return !1;
|
|
1370
|
+
const r = f.get(o) || e;
|
|
1438
1371
|
return f.set(o, r), p = o, bt(o, r), H(o), !0;
|
|
1439
1372
|
},
|
|
1440
|
-
getCitationRecords: (
|
|
1373
|
+
getCitationRecords: (n, i) => {
|
|
1441
1374
|
const o = h(i);
|
|
1442
|
-
if (!o)
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
if (typeof e == "function")
|
|
1375
|
+
if (!o) return !1;
|
|
1376
|
+
const r = f.get(o) || e, a = K(o, r);
|
|
1377
|
+
if (typeof n == "function")
|
|
1446
1378
|
try {
|
|
1447
|
-
|
|
1379
|
+
n(a);
|
|
1448
1380
|
} catch {
|
|
1449
1381
|
}
|
|
1450
1382
|
return o.__citationRecords = a, o.dispatchEvent(
|
|
@@ -1457,46 +1389,41 @@ const le = (t = {}) => {
|
|
|
1457
1389
|
})
|
|
1458
1390
|
), !0;
|
|
1459
1391
|
},
|
|
1460
|
-
setCitationsOptions: (
|
|
1392
|
+
setCitationsOptions: (n, i) => {
|
|
1461
1393
|
const o = h(i);
|
|
1462
|
-
if (!o || !
|
|
1463
|
-
|
|
1464
|
-
const r = f.get(o) || n, a = Z({
|
|
1394
|
+
if (!o || !n || typeof n != "object") return !1;
|
|
1395
|
+
const r = f.get(o) || e, a = Z({
|
|
1465
1396
|
...r,
|
|
1466
|
-
...
|
|
1397
|
+
...n,
|
|
1467
1398
|
labels: {
|
|
1468
1399
|
...r.labels,
|
|
1469
|
-
...
|
|
1400
|
+
...n.labels || {}
|
|
1470
1401
|
},
|
|
1471
|
-
normalizeText:
|
|
1472
|
-
generateCitationId:
|
|
1402
|
+
normalizeText: n.normalizeText || r.normalizeText,
|
|
1403
|
+
generateCitationId: n.generateCitationId || r.generateCitationId
|
|
1473
1404
|
});
|
|
1474
|
-
return f.set(o, a),
|
|
1405
|
+
return f.set(o, a), n.defaultStyle && L.includes(n.defaultStyle) && T.set(o, n.defaultStyle), y(o, a, !0), H(o), !0;
|
|
1475
1406
|
},
|
|
1476
|
-
locateCitation: (
|
|
1407
|
+
locateCitation: (n, i) => {
|
|
1477
1408
|
const o = h(i);
|
|
1478
|
-
return !o || typeof
|
|
1409
|
+
return !o || typeof n != "string" ? !1 : Zt(o, n);
|
|
1479
1410
|
},
|
|
1480
|
-
deleteCitation: (
|
|
1411
|
+
deleteCitation: (n, i) => {
|
|
1481
1412
|
const o = h(i);
|
|
1482
|
-
if (!o ||
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
return f.set(o, r), typeof e == "string" && e.trim() ? Rt(o, e, r) : Jt(o, r);
|
|
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);
|
|
1486
1416
|
},
|
|
1487
|
-
insertRecentCitation: (
|
|
1417
|
+
insertRecentCitation: (n, i) => {
|
|
1488
1418
|
const o = h(i);
|
|
1489
|
-
if (!o ||
|
|
1490
|
-
|
|
1491
|
-
const r = f.get(o) || n;
|
|
1419
|
+
if (!o || $(o)) return !1;
|
|
1420
|
+
const r = f.get(o) || e;
|
|
1492
1421
|
f.set(o, r);
|
|
1493
1422
|
const a = K(o, r), s = rt(o, a, r);
|
|
1494
|
-
if (s.length === 0)
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
return !1;
|
|
1499
|
-
const c = et(o, d, 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);
|
|
1500
1427
|
return c && z(o), c;
|
|
1501
1428
|
}
|
|
1502
1429
|
},
|
|
@@ -1510,7 +1437,7 @@ const le = (t = {}) => {
|
|
|
1510
1437
|
},
|
|
1511
1438
|
init: function(i) {
|
|
1512
1439
|
Y += 1;
|
|
1513
|
-
const o = this && typeof this.__pluginConfig == "object" ? Z({ ...
|
|
1440
|
+
const o = this && typeof this.__pluginConfig == "object" ? Z({ ...e, ...this.__pluginConfig }) : e;
|
|
1514
1441
|
ae(o);
|
|
1515
1442
|
const r = h(
|
|
1516
1443
|
i && i.editorElement ? { editorElement: i.editorElement } : void 0,
|
|
@@ -1519,8 +1446,8 @@ const le = (t = {}) => {
|
|
|
1519
1446
|
r && (p = r, f.set(r, o), T.set(r, o.defaultStyle), it(r, "toggleCitationsPanel", !1), kt(r));
|
|
1520
1447
|
},
|
|
1521
1448
|
destroy: () => {
|
|
1522
|
-
Y = Math.max(0, Y - 1), !(Y > 0) && (q.forEach((
|
|
1523
|
-
window.clearTimeout(
|
|
1449
|
+
Y = Math.max(0, Y - 1), !(Y > 0) && (q.forEach((n) => {
|
|
1450
|
+
window.clearTimeout(n);
|
|
1524
1451
|
}), q.clear(), se());
|
|
1525
1452
|
}
|
|
1526
1453
|
};
|