@editora/core 1.0.23 → 1.0.25
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/dist/{A11yCheckerPlugin.native-qW_njhLY.mjs → A11yCheckerPlugin.native-BBCsR5Ur.mjs} +7 -5
- package/dist/{AnchorPlugin.native-Drmxhy98.mjs → AnchorPlugin.native-Dk9R26cF.mjs} +20 -19
- package/dist/{ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs → ApprovalWorkflowPlugin.native-AeJsehXM.mjs} +56 -55
- package/dist/{BackgroundColorPlugin.native-H3XyYD7_.mjs → BackgroundColorPlugin.native-DCAd94kp.mjs} +103 -98
- package/dist/{BlocksLibraryPlugin.native-CownM6Rk.mjs → BlocksLibraryPlugin.native-D9OPcnQV.mjs} +42 -43
- package/dist/{CitationsPlugin.native-C_7wWQ-k.mjs → CitationsPlugin.native-BFChgCSV.mjs} +51 -51
- package/dist/{CodePlugin.native-DZgIez08.mjs → CodePlugin.native-CPfKDrkr.mjs} +1383 -1094
- package/dist/{CodePlugin.native-CAHk9ecG.mjs → CodePlugin.native-CRpX2G93.mjs} +167 -113
- package/dist/{CodeSamplePlugin.native-svbAFWh_.mjs → CodeSamplePlugin.native-Bai8bgl3.mjs} +5 -5
- package/dist/{CommentsPlugin.native-DncTHiEe.mjs → CommentsPlugin.native-DHCDUm9f.mjs} +161 -141
- package/dist/{ConditionalContentPlugin.native-Bf7XgRSW.mjs → ConditionalContentPlugin.native-B3R6xcqn.mjs} +3 -3
- package/dist/{ContentRulesPlugin.native-vPx5nC73.mjs → ContentRulesPlugin.native-BISqhQKJ.mjs} +52 -52
- package/dist/{DataBindingPlugin.native-B7lpI_0c.mjs → DataBindingPlugin.native-DbaDeXNp.mjs} +37 -37
- package/dist/{DocumentManagerPlugin.native-B8K-Oqom.mjs → DocumentManagerPlugin.native-CaBqCH-p.mjs} +21 -20
- package/dist/{EmbedIframePlugin.native-BfZ_HGlV.mjs → EmbedIframePlugin.native-qHMf1Jtg.mjs} +7 -7
- package/dist/{EmojisPlugin.native-D92aaOKi.mjs → EmojisPlugin.native-B64efKg5.mjs} +4 -4
- package/dist/{FormatPainterPlugin.native-BhjzsiVq.mjs → FormatPainterPlugin.native-CAc1N6xU.mjs} +183 -161
- package/dist/{HeadingPlugin.native-DZdvubrQ.mjs → HeadingPlugin.native-C3YiGERx.mjs} +85 -72
- package/dist/HistoryPlugin.native-C8GyxsgC.mjs +330 -0
- package/dist/{LinkPlugin.native-BsQXYsK6.mjs → LinkPlugin.native-Dt_p6Ukb.mjs} +4 -4
- package/dist/ListPlugin.native-UYaoRiub.mjs +239 -0
- package/dist/{MathPlugin.native-Byo3WL0f.mjs → MathPlugin.native-Cq9WQ7cq.mjs} +148 -130
- package/dist/MediaManagerPlugin.native-0YFHZfsb.mjs +4823 -0
- package/dist/MediaManagerPlugin.native-mXWWARRX.mjs +4908 -0
- package/dist/{MentionPlugin.native-S_lwGZQO.mjs → MentionPlugin.native-Zb1dwdxU.mjs} +304 -300
- package/dist/{MergeTagPlugin.native-7-6F3S1Y.mjs → MergeTagPlugin.native-BXkVPvCo.mjs} +6 -4
- package/dist/{PIIRedactionPlugin.native-g7j4jOmm.mjs → PIIRedactionPlugin.native-Cm0bpzQb.mjs} +2 -2
- package/dist/{PreviewPlugin.native-Dv5OsffK.mjs → PreviewPlugin.native-CrfiwP2J.mjs} +2 -2
- package/dist/{SlashCommandsPlugin.native-BDIIwGNs.mjs → SlashCommandsPlugin.native-BzGTRmMB.mjs} +264 -240
- package/dist/{SmartPastePlugin.native-BATLCds5.mjs → SmartPastePlugin.native-DnOJhDsf.mjs} +2 -2
- package/dist/{SpecialCharactersPlugin.native-CdZoc1GB.mjs → SpecialCharactersPlugin.native-B0XaCfjZ.mjs} +4 -4
- package/dist/{SpellCheckPlugin.native-BGm2qPfn.mjs → SpellCheckPlugin.native-BE7os1Xj.mjs} +302 -265
- package/dist/{TablePlugin.native-C1YZ372P.mjs → TablePlugin.native-CWxEFpV8.mjs} +159 -136
- package/dist/{TemplatePlugin.native-Dwk8TgxI.mjs → TemplatePlugin.native-OD8Wc1R7.mjs} +6 -4
- package/dist/{TextColorPlugin.native-KMZ2uzlq.mjs → TextColorPlugin.native-C2IjioNM.mjs} +75 -71
- package/dist/{TranslationWorkflowPlugin.native-CZtG--06.mjs → TranslationWorkflowPlugin.native-BGXVJD9f.mjs} +101 -98
- package/dist/{VersionDiffPlugin.native-Ca1fMWUJ.mjs → VersionDiffPlugin.native-DJZIzFSK.mjs} +11 -11
- package/dist/anchoredPopover-QN4jNbW1.mjs +134 -0
- package/dist/confirmDialog-CNqPHT5x.mjs +92 -0
- package/dist/dialogHelpers-Dzn8DHoF.mjs +194 -0
- package/dist/{documentManager-BWK_-KJp.mjs → documentManager-DHLCoWzw.mjs} +1963 -1969
- package/dist/editora.min.js +21 -21
- package/dist/editora.umd.js +10 -10
- package/dist/index-DHPPVQwx.js +12 -0
- package/dist/{index-DGMYWPLx.mjs → index-gI4djib2.mjs} +407 -327
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/katex-DLIObQUm.mjs +11683 -0
- package/dist/katex.min--Ws3c9be.mjs +6 -0
- package/dist/notify-DCQGpmq-.mjs +60 -0
- package/dist/plugin-loader.js +54 -54
- package/dist/shared-config-DuA34Iii.mjs +26 -0
- package/dist/webcomponent-core.js +315 -235
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +153 -80
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +672 -592
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +3099 -1532
- package/package.json +1 -1
- package/dist/HistoryPlugin.native-DPvhks6h.mjs +0 -246
- package/dist/ListPlugin.native-Bt0LANbO.mjs +0 -139
- package/dist/MediaManagerPlugin.native-BT1NZIJS.mjs +0 -998
- package/dist/anchoredPopover-DJFD2oAP.mjs +0 -116
- package/dist/dialogHelpers-DBf7WqYH.mjs +0 -40
- package/dist/index-C1sO7DAC.js +0 -12
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { a as T } from "./dialogHelpers-Dzn8DHoF.mjs";
|
|
2
|
+
const g = ".rte-content, .editora-content", ae = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", w = '.rte-mention[data-mention="true"]', y = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', R = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
let Q = !1, S = !1, C = null, L = 0;
|
|
4
|
+
function J(e, n) {
|
|
4
5
|
if (n === e.innerHTML) return;
|
|
5
6
|
const o = window.execEditorCommand || window.executeEditorCommand;
|
|
6
7
|
if (typeof o == "function")
|
|
7
8
|
try {
|
|
8
9
|
o("recordDomTransaction", e, n, e.innerHTML);
|
|
9
|
-
} catch (
|
|
10
|
+
} catch (r) {
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
+
function Z(e) {
|
|
13
14
|
e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
14
15
|
}
|
|
15
16
|
function h(e, n) {
|
|
16
17
|
const o = window.getSelection();
|
|
17
18
|
o && (o.removeAllRanges(), o.addRange(n), e.focus({ preventScroll: !0 }));
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function O(e, n) {
|
|
20
21
|
return e.startContainer === n.startContainer && e.startOffset === n.startOffset && e.endContainer === n.endContainer && e.endOffset === n.endOffset;
|
|
21
22
|
}
|
|
22
23
|
function E(e) {
|
|
@@ -25,82 +26,82 @@ function E(e) {
|
|
|
25
26
|
const o = n.getRangeAt(0);
|
|
26
27
|
return e.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
+
function v(e) {
|
|
29
30
|
Array.from(e.querySelectorAll(w)).forEach((o) => {
|
|
30
31
|
o.setAttribute("data-mention", "true"), o.setAttribute("contenteditable", "false"), o.setAttribute("spellcheck", "false"), o.setAttribute("draggable", "false"), o.classList.add("rte-mention");
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
+
function U(e) {
|
|
34
35
|
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
-
return e.closest(
|
|
37
|
+
function le(e) {
|
|
38
|
+
return e.closest(ae) || e;
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function M(e) {
|
|
40
41
|
return e ? (e.getAttribute("data-theme") || e.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : e.classList.contains("dark") || e.classList.contains("editora-theme-dark") || e.classList.contains("rte-theme-dark") : !1;
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
const n =
|
|
44
|
-
if (
|
|
43
|
+
function se(e) {
|
|
44
|
+
const n = le(e);
|
|
45
|
+
if (M(n)) return !0;
|
|
45
46
|
const o = n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
|
|
46
|
-
return
|
|
47
|
+
return M(o) ? !0 : M(document.documentElement) || M(document.body);
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
-
e.classList.remove("rte-mention-theme-dark"),
|
|
49
|
+
function Y(e, n) {
|
|
50
|
+
e.classList.remove("rte-mention-theme-dark"), se(n) && e.classList.add("rte-mention-theme-dark");
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
+
function ce(e) {
|
|
52
53
|
if ((e == null ? void 0 : e.contentElement) instanceof HTMLElement) return e.contentElement;
|
|
53
54
|
if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
55
|
+
const r = e.editorElement;
|
|
56
|
+
if (r.matches(g)) return r;
|
|
57
|
+
const t = r.querySelector(g);
|
|
58
|
+
if (t instanceof HTMLElement) return t;
|
|
58
59
|
}
|
|
59
60
|
const n = window.getSelection();
|
|
60
61
|
if (n && n.rangeCount > 0) {
|
|
61
|
-
const
|
|
62
|
+
const r = n.getRangeAt(0).startContainer, t = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement, i = t == null ? void 0 : t.closest(g);
|
|
62
63
|
if (i) return i;
|
|
63
64
|
}
|
|
64
65
|
const o = document.activeElement;
|
|
65
66
|
if (o) {
|
|
66
|
-
if (o.matches(
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
67
|
+
if (o.matches(g)) return o;
|
|
68
|
+
const r = o.closest(g);
|
|
69
|
+
if (r) return r;
|
|
69
70
|
}
|
|
70
|
-
return document.querySelector(
|
|
71
|
+
return document.querySelector(g);
|
|
71
72
|
}
|
|
72
73
|
function x(e) {
|
|
73
74
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
74
75
|
}
|
|
75
|
-
function
|
|
76
|
+
function P(e) {
|
|
76
77
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
-
return n ? n.split(".").filter(Boolean).reduce((o,
|
|
80
|
-
if (!(!
|
|
81
|
-
return o[
|
|
79
|
+
function ue(e, n) {
|
|
80
|
+
return n ? n.split(".").filter(Boolean).reduce((o, r) => {
|
|
81
|
+
if (!(!P(o) && !Array.isArray(o)))
|
|
82
|
+
return o[r];
|
|
82
83
|
}, e) : e;
|
|
83
84
|
}
|
|
84
|
-
function
|
|
85
|
+
function de(e) {
|
|
85
86
|
return e ? /\s|[([{"'`]/.test(e) : !0;
|
|
86
87
|
}
|
|
87
|
-
function
|
|
88
|
+
function fe(e) {
|
|
88
89
|
if (!e.collapsed) return null;
|
|
89
90
|
const n = e.startContainer, o = e.startOffset;
|
|
90
91
|
if (n.nodeType === Node.TEXT_NODE) {
|
|
91
|
-
const
|
|
92
|
+
const r = n;
|
|
92
93
|
return {
|
|
93
|
-
node:
|
|
94
|
-
textBefore:
|
|
94
|
+
node: r,
|
|
95
|
+
textBefore: r.data.slice(0, o),
|
|
95
96
|
caretOffset: o
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
99
|
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
99
|
-
const
|
|
100
|
+
const r = n;
|
|
100
101
|
if (o > 0) {
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
103
|
-
const i =
|
|
102
|
+
const t = r.childNodes[o - 1];
|
|
103
|
+
if (t && t.nodeType === Node.TEXT_NODE) {
|
|
104
|
+
const i = t;
|
|
104
105
|
return {
|
|
105
106
|
node: i,
|
|
106
107
|
textBefore: i.data,
|
|
@@ -111,98 +112,99 @@ function de(e) {
|
|
|
111
112
|
}
|
|
112
113
|
return null;
|
|
113
114
|
}
|
|
114
|
-
function
|
|
115
|
-
let
|
|
115
|
+
function me(e, n, o) {
|
|
116
|
+
let r = -1, t = "";
|
|
116
117
|
if (n.forEach((a) => {
|
|
117
118
|
const l = e.lastIndexOf(a);
|
|
118
|
-
l >
|
|
119
|
-
}),
|
|
120
|
-
const i = e.slice(
|
|
119
|
+
l > r && (r = l, t = a);
|
|
120
|
+
}), r < 0 || !de(e[r - 1])) return null;
|
|
121
|
+
const i = e.slice(r + 1);
|
|
121
122
|
return /\s/.test(i) || i.length > o ? null : {
|
|
122
|
-
trigger:
|
|
123
|
+
trigger: t,
|
|
123
124
|
query: i,
|
|
124
|
-
startOffset:
|
|
125
|
+
startOffset: r
|
|
125
126
|
};
|
|
126
127
|
}
|
|
127
|
-
function
|
|
128
|
+
function pe(e, n) {
|
|
128
129
|
const o = n.cloneRange();
|
|
129
130
|
o.collapse(!1);
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
return
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
const i =
|
|
136
|
-
return
|
|
137
|
-
}
|
|
138
|
-
|
|
131
|
+
const r = o.getClientRects();
|
|
132
|
+
if (r.length > 0)
|
|
133
|
+
return r[r.length - 1];
|
|
134
|
+
const t = document.createElement("span");
|
|
135
|
+
t.textContent = "", t.style.position = "relative", o.insertNode(t);
|
|
136
|
+
const i = t.getBoundingClientRect();
|
|
137
|
+
return t.remove(), e.normalize(), i;
|
|
138
|
+
}
|
|
139
|
+
let ge = 0;
|
|
140
|
+
function he(e, n) {
|
|
139
141
|
if (e.panel && e.list) return;
|
|
140
142
|
const o = document.createElement("div");
|
|
141
143
|
o.className = "rte-mention-panel", o.style.display = "none";
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}), o.addEventListener("click", (
|
|
146
|
-
const i =
|
|
144
|
+
const r = document.createElement("div");
|
|
145
|
+
r.className = "rte-mention-list", r.setAttribute("role", "listbox"), r.setAttribute("aria-label", "Mentions"), r.id = `rte-mention-list-${++ge}`, o.appendChild(r), document.body.appendChild(o), Y(o, e.editor), e.panel = o, e.list = r, o.addEventListener("mousedown", (t) => {
|
|
146
|
+
t.preventDefault();
|
|
147
|
+
}), o.addEventListener("click", (t) => {
|
|
148
|
+
const i = t.target;
|
|
147
149
|
if (!i) return;
|
|
148
150
|
const a = i.closest(".rte-mention-item");
|
|
149
151
|
if (!a) return;
|
|
150
152
|
const l = Number(a.getAttribute("data-index"));
|
|
151
|
-
Number.isFinite(l) &&
|
|
153
|
+
Number.isFinite(l) && ne(e, n, l);
|
|
152
154
|
});
|
|
153
155
|
}
|
|
154
156
|
function m(e) {
|
|
155
|
-
e.panel && (e.debounceHandle !== null && (window.clearTimeout(e.debounceHandle), e.debounceHandle = null), e.abortController && (e.abortController.abort(), e.abortController = null), e.panel.style.display = "none", e.panel.classList.remove("show"), e.isOpen = !1, e.loading = !1, e.items = [], e.activeIndex = 0, e.query = "", e.replaceRange = null);
|
|
157
|
+
e.panel && (e.debounceHandle !== null && (window.clearTimeout(e.debounceHandle), e.debounceHandle = null), e.abortController && (e.abortController.abort(), e.abortController = null), e.panel.style.display = "none", e.panel.classList.remove("show"), e.isOpen = !1, e.loading = !1, e.items = [], e.activeIndex = 0, e.query = "", e.replaceRange = null, T(e.editor, null, null));
|
|
156
158
|
}
|
|
157
|
-
function
|
|
159
|
+
function W(e, n) {
|
|
158
160
|
if (!e.panel) return;
|
|
159
|
-
|
|
160
|
-
const o =
|
|
161
|
-
|
|
162
|
-
const
|
|
161
|
+
Y(e.panel, e.editor);
|
|
162
|
+
const o = pe(e.editor, n), r = e.panel;
|
|
163
|
+
r.style.display = "block", r.classList.add("show"), r.style.left = "0px", r.style.top = "0px";
|
|
164
|
+
const t = r.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight, l = Math.max(8, Math.min(o.left, i - t.width - 8));
|
|
163
165
|
let s = o.bottom + 8;
|
|
164
|
-
s +
|
|
166
|
+
s + t.height > a - 8 && (s = Math.max(8, o.top - t.height - 8)), r.style.position = "fixed", r.style.left = `${l}px`, r.style.top = `${s}px`;
|
|
165
167
|
}
|
|
166
|
-
function
|
|
168
|
+
function be(e, n) {
|
|
167
169
|
if (!n) return x(e);
|
|
168
|
-
const o = e.toLowerCase(),
|
|
169
|
-
if (
|
|
170
|
-
const i = x(e.slice(0,
|
|
170
|
+
const o = e.toLowerCase(), r = n.toLowerCase(), t = o.indexOf(r);
|
|
171
|
+
if (t < 0) return x(e);
|
|
172
|
+
const i = x(e.slice(0, t)), a = x(e.slice(t, t + n.length)), l = x(e.slice(t + n.length));
|
|
171
173
|
return `${i}<mark>${a}</mark>${l}`;
|
|
172
174
|
}
|
|
173
|
-
function
|
|
175
|
+
function G(e, n) {
|
|
174
176
|
if (!e.list) return;
|
|
175
177
|
const o = e.list;
|
|
176
178
|
if (o.innerHTML = "", e.loading) {
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
+
const r = document.createElement("div");
|
|
180
|
+
r.className = "rte-mention-empty", r.textContent = n.loadingText, o.appendChild(r), T(e.editor, null, null);
|
|
179
181
|
return;
|
|
180
182
|
}
|
|
181
183
|
if (e.items.length === 0) {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
+
const r = document.createElement("div");
|
|
185
|
+
r.className = "rte-mention-empty", r.textContent = e.query.length > 0 ? n.noResultsText : n.emptyStateText, o.appendChild(r), T(e.editor, null, null);
|
|
184
186
|
return;
|
|
185
187
|
}
|
|
186
|
-
e.items.forEach((
|
|
188
|
+
e.items.forEach((r, t) => {
|
|
187
189
|
const i = document.createElement("button");
|
|
188
|
-
i.type = "button", i.className = "rte-mention-item",
|
|
189
|
-
const a = n.itemRenderer ? n.itemRenderer(
|
|
190
|
+
i.type = "button", i.className = "rte-mention-item", t === e.activeIndex && i.classList.add("active"), i.setAttribute("data-index", String(t)), i.setAttribute("role", "option"), i.id = `${o.id}-${t}`, i.setAttribute("aria-selected", t === e.activeIndex ? "true" : "false");
|
|
191
|
+
const a = n.itemRenderer ? n.itemRenderer(r, e.query) : `<span class="rte-mention-item-label">${be(r.label, e.query)}</span>${r.meta ? `<span class="rte-mention-item-meta">${x(r.meta)}</span>` : ""}`;
|
|
190
192
|
i.innerHTML = a, o.appendChild(i);
|
|
191
|
-
});
|
|
193
|
+
}), T(e.editor, o, o.children[e.activeIndex]);
|
|
192
194
|
}
|
|
193
|
-
function
|
|
194
|
-
const o = /* @__PURE__ */ new Set(),
|
|
195
|
-
return e.forEach((
|
|
196
|
-
const i = (
|
|
197
|
-
!i || o.has(i) || (o.add(i),
|
|
195
|
+
function ee(e, n) {
|
|
196
|
+
const o = /* @__PURE__ */ new Set(), r = [];
|
|
197
|
+
return e.forEach((t) => {
|
|
198
|
+
const i = (t.id || "").trim();
|
|
199
|
+
!i || o.has(i) || (o.add(i), r.push({
|
|
198
200
|
id: i,
|
|
199
|
-
label:
|
|
200
|
-
value:
|
|
201
|
-
meta:
|
|
201
|
+
label: t.label || i,
|
|
202
|
+
value: t.value,
|
|
203
|
+
meta: t.meta
|
|
202
204
|
}));
|
|
203
|
-
}),
|
|
205
|
+
}), r.slice(0, n);
|
|
204
206
|
}
|
|
205
|
-
function
|
|
207
|
+
function ye(e, n) {
|
|
206
208
|
if (e.buildRequest) {
|
|
207
209
|
const c = e.buildRequest(n);
|
|
208
210
|
return {
|
|
@@ -210,9 +212,9 @@ function he(e, n) {
|
|
|
210
212
|
init: c.init || {}
|
|
211
213
|
};
|
|
212
214
|
}
|
|
213
|
-
const o = (e.method || "GET").toUpperCase(),
|
|
215
|
+
const o = (e.method || "GET").toUpperCase(), r = typeof e.headers == "function" ? e.headers(n) : e.headers || {}, t = e.queryParam || "q", i = e.triggerParam || "trigger", a = e.limitParam || "limit", l = e.staticParams || {}, s = {
|
|
214
216
|
method: o,
|
|
215
|
-
headers: { ...
|
|
217
|
+
headers: { ...r },
|
|
216
218
|
credentials: e.credentials,
|
|
217
219
|
mode: e.mode,
|
|
218
220
|
cache: e.cache,
|
|
@@ -220,192 +222,192 @@ function he(e, n) {
|
|
|
220
222
|
}, f = new URL(e.url, window.location.origin);
|
|
221
223
|
if (o === "GET" || o === "HEAD") {
|
|
222
224
|
const c = new URLSearchParams(f.search);
|
|
223
|
-
Object.entries(l).forEach(([u,
|
|
225
|
+
Object.entries(l).forEach(([u, p]) => c.set(u, String(p))), c.set(t, n.query), c.set(i, n.trigger), c.set(a, String(n.limit)), f.search = c.toString();
|
|
224
226
|
} else {
|
|
225
227
|
const c = typeof e.body == "function" ? e.body(n) : e.body, u = {
|
|
226
|
-
[
|
|
228
|
+
[t]: n.query,
|
|
227
229
|
[i]: n.trigger,
|
|
228
230
|
[a]: n.limit,
|
|
229
231
|
...l
|
|
230
|
-
},
|
|
231
|
-
if (
|
|
232
|
-
s.body = JSON.stringify(
|
|
233
|
-
const
|
|
234
|
-
!
|
|
232
|
+
}, p = c != null ? c : u;
|
|
233
|
+
if (P(p)) {
|
|
234
|
+
s.body = JSON.stringify(p);
|
|
235
|
+
const b = s.headers;
|
|
236
|
+
!b["Content-Type"] && !b["content-type"] && (b["Content-Type"] = "application/json");
|
|
235
237
|
} else
|
|
236
|
-
s.body =
|
|
238
|
+
s.body = p;
|
|
237
239
|
}
|
|
238
240
|
return { url: f.toString(), init: s };
|
|
239
241
|
}
|
|
240
|
-
async function
|
|
242
|
+
async function Ee(e, n, o, r) {
|
|
241
243
|
var f, c;
|
|
242
|
-
const
|
|
243
|
-
if (!
|
|
244
|
+
const t = n.api;
|
|
245
|
+
if (!t) return [];
|
|
244
246
|
e.abortController && e.abortController.abort();
|
|
245
247
|
const i = new AbortController();
|
|
246
248
|
e.abortController = i;
|
|
247
249
|
const a = {
|
|
248
250
|
query: o,
|
|
249
|
-
trigger:
|
|
251
|
+
trigger: r,
|
|
250
252
|
limit: n.maxSuggestions,
|
|
251
253
|
signal: i.signal
|
|
252
|
-
}, l = Math.max(0, (f =
|
|
254
|
+
}, l = Math.max(0, (f = t.timeoutMs) != null ? f : 1e4);
|
|
253
255
|
let s = null;
|
|
254
256
|
l > 0 && (s = window.setTimeout(() => i.abort(), l));
|
|
255
257
|
try {
|
|
256
|
-
const { url: u, init:
|
|
257
|
-
...
|
|
258
|
+
const { url: u, init: p } = ye(t, a), b = await fetch(u, {
|
|
259
|
+
...p,
|
|
258
260
|
signal: i.signal
|
|
259
261
|
});
|
|
260
|
-
if (!
|
|
261
|
-
throw new Error(`Mention API request failed: ${
|
|
262
|
-
const
|
|
263
|
-
let
|
|
264
|
-
if (
|
|
265
|
-
|
|
262
|
+
if (!b.ok)
|
|
263
|
+
throw new Error(`Mention API request failed: ${b.status}`);
|
|
264
|
+
const k = (t.responseType || "json") === "text" ? await b.text() : await b.json();
|
|
265
|
+
let H = [];
|
|
266
|
+
if (t.transformResponse)
|
|
267
|
+
H = t.transformResponse(k, a) || [];
|
|
266
268
|
else {
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
var _,
|
|
270
|
-
if (
|
|
271
|
-
return
|
|
272
|
-
if (!
|
|
273
|
-
const
|
|
274
|
-
if (!
|
|
275
|
-
const
|
|
269
|
+
const $ = ue(k, t.responsePath);
|
|
270
|
+
H = (Array.isArray($) ? $ : Array.isArray(k) ? k : []).map((d, oe) => {
|
|
271
|
+
var _, B, j, z, F;
|
|
272
|
+
if (t.mapItem)
|
|
273
|
+
return t.mapItem(d, oe);
|
|
274
|
+
if (!P(d)) return null;
|
|
275
|
+
const D = String((j = (B = (_ = d.id) != null ? _ : d.value) != null ? B : d.key) != null ? j : "").trim();
|
|
276
|
+
if (!D) return null;
|
|
277
|
+
const ie = String((F = (z = d.label) != null ? z : d.name) != null ? F : D).trim();
|
|
276
278
|
return {
|
|
277
|
-
id:
|
|
278
|
-
label:
|
|
279
|
+
id: D,
|
|
280
|
+
label: ie,
|
|
279
281
|
value: d.value ? String(d.value) : void 0,
|
|
280
282
|
meta: d.meta ? String(d.meta) : void 0
|
|
281
283
|
};
|
|
282
284
|
}).filter((d) => !!d);
|
|
283
285
|
}
|
|
284
|
-
return
|
|
286
|
+
return ee(H, n.maxSuggestions);
|
|
285
287
|
} catch (u) {
|
|
286
|
-
return (u == null ? void 0 : u.name) !== "AbortError" && ((c =
|
|
288
|
+
return (u == null ? void 0 : u.name) !== "AbortError" && ((c = t.onError) == null || c.call(t, u, a)), [];
|
|
287
289
|
} finally {
|
|
288
290
|
s !== null && window.clearTimeout(s), e.abortController === i && (e.abortController = null);
|
|
289
291
|
}
|
|
290
292
|
}
|
|
291
|
-
async function
|
|
292
|
-
const
|
|
293
|
+
async function xe(e, n, o, r) {
|
|
294
|
+
const t = ++e.requestId;
|
|
293
295
|
let i = [];
|
|
294
296
|
if (n.search) {
|
|
295
|
-
const a = await n.search(o,
|
|
297
|
+
const a = await n.search(o, r);
|
|
296
298
|
i = Array.isArray(a) ? a : [];
|
|
297
299
|
} else if (n.api)
|
|
298
|
-
i = await
|
|
300
|
+
i = await Ee(e, n, o, r);
|
|
299
301
|
else {
|
|
300
302
|
const a = o.toLowerCase();
|
|
301
303
|
i = n.items.filter((l) => a ? l.label.toLowerCase().includes(a) || l.id.toLowerCase().includes(a) : !0);
|
|
302
304
|
}
|
|
303
|
-
return
|
|
304
|
-
}
|
|
305
|
-
function
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
const i =
|
|
309
|
-
let a = e.replaceRange ? e.replaceRange.cloneRange() : E(
|
|
310
|
-
if (!a || !
|
|
305
|
+
return t !== e.requestId ? [] : ee(i, n.maxSuggestions);
|
|
306
|
+
}
|
|
307
|
+
function we(e, n, o) {
|
|
308
|
+
const r = e.editor;
|
|
309
|
+
if (v(r), !window.getSelection()) return !1;
|
|
310
|
+
const i = r.innerHTML;
|
|
311
|
+
let a = e.replaceRange ? e.replaceRange.cloneRange() : E(r);
|
|
312
|
+
if (!a || !r.contains(a.commonAncestorContainer) && (a = E(r), !a))
|
|
311
313
|
return !1;
|
|
312
|
-
const l =
|
|
313
|
-
|
|
314
|
+
const l = I(r, a.cloneRange(), "after");
|
|
315
|
+
O(l, a) || (h(r, l), a = l), a.deleteContents();
|
|
314
316
|
const s = document.createElement("span");
|
|
315
317
|
s.className = "rte-mention", s.setAttribute("data-mention", "true"), s.setAttribute("data-mention-id", o.id), s.setAttribute("contenteditable", "false"), s.textContent = o.value || `${e.trigger}${o.label}`, a.insertNode(s);
|
|
316
318
|
let f = s, c = 1;
|
|
317
319
|
if (n.insertSpaceAfterMention) {
|
|
318
|
-
const
|
|
319
|
-
s.after(
|
|
320
|
+
const p = document.createTextNode(" ");
|
|
321
|
+
s.after(p), f = p, c = 1;
|
|
320
322
|
}
|
|
321
323
|
const u = document.createRange();
|
|
322
|
-
return u.setStart(f, c), u.collapse(!0), h(
|
|
324
|
+
return u.setStart(f, c), u.collapse(!0), h(r, u), m(e), v(r), Z(r), J(r, i), !0;
|
|
323
325
|
}
|
|
324
|
-
function
|
|
326
|
+
function ne(e, n, o) {
|
|
325
327
|
if (o < 0 || o >= e.items.length) return;
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
+
const r = e.items[o];
|
|
329
|
+
we(e, n, r);
|
|
328
330
|
}
|
|
329
|
-
function
|
|
331
|
+
function Te(e) {
|
|
330
332
|
return e.startContainer !== e.endContainer || e.startContainer.nodeType !== Node.ELEMENT_NODE || e.endOffset - e.startOffset !== 1 ? null : e.startContainer.childNodes[e.startOffset] || null;
|
|
331
333
|
}
|
|
332
|
-
function
|
|
333
|
-
const o =
|
|
334
|
+
function Ce(e, n) {
|
|
335
|
+
const o = Te(e);
|
|
334
336
|
return !(o instanceof HTMLElement) || !o.matches(w) || !n.contains(o) ? null : o;
|
|
335
337
|
}
|
|
336
|
-
function
|
|
337
|
-
const o =
|
|
338
|
+
function te(e, n) {
|
|
339
|
+
const o = Ce(e, n);
|
|
338
340
|
if (o) return o;
|
|
339
|
-
const
|
|
340
|
-
if (
|
|
341
|
-
const i =
|
|
341
|
+
const r = U(e.startContainer), t = r == null ? void 0 : r.closest(w);
|
|
342
|
+
if (t && n.contains(t)) return t;
|
|
343
|
+
const i = U(e.endContainer), a = i == null ? void 0 : i.closest(w);
|
|
342
344
|
return a && n.contains(a) ? a : null;
|
|
343
345
|
}
|
|
344
|
-
function
|
|
345
|
-
const
|
|
346
|
-
if (!
|
|
347
|
-
const r = document.createRange();
|
|
348
|
-
return o === "before" ? r.setStartBefore(t) : r.setStartAfter(t), r.collapse(!0), r;
|
|
349
|
-
}
|
|
350
|
-
function G(e, n, o = "after") {
|
|
346
|
+
function I(e, n, o = "after") {
|
|
347
|
+
const r = te(n, e);
|
|
348
|
+
if (!r) return n;
|
|
351
349
|
const t = document.createRange();
|
|
352
|
-
o === "before" ? t.setStartBefore(
|
|
350
|
+
return o === "before" ? t.setStartBefore(r) : t.setStartAfter(r), t.collapse(!0), t;
|
|
351
|
+
}
|
|
352
|
+
function K(e, n, o = "after") {
|
|
353
|
+
const r = document.createRange();
|
|
354
|
+
o === "before" ? r.setStartBefore(n) : r.setStartAfter(n), r.collapse(!0), h(e, r);
|
|
353
355
|
}
|
|
354
|
-
function
|
|
356
|
+
function ve(e, n, o) {
|
|
355
357
|
if (!e.collapsed) return null;
|
|
356
|
-
const
|
|
358
|
+
const r = e.startContainer, t = e.startOffset;
|
|
357
359
|
let i = null;
|
|
358
|
-
if (
|
|
359
|
-
const a =
|
|
360
|
-
n === "backward" &&
|
|
361
|
-
} else if (
|
|
362
|
-
const a =
|
|
363
|
-
n === "backward" &&
|
|
360
|
+
if (r.nodeType === Node.TEXT_NODE) {
|
|
361
|
+
const a = r;
|
|
362
|
+
n === "backward" && t === 0 ? i = a.previousSibling : n === "forward" && t === a.length && (i = a.nextSibling);
|
|
363
|
+
} else if (r.nodeType === Node.ELEMENT_NODE) {
|
|
364
|
+
const a = r;
|
|
365
|
+
n === "backward" && t > 0 ? i = a.childNodes[t - 1] || null : n === "forward" && t < a.childNodes.length && (i = a.childNodes[t] || null);
|
|
364
366
|
}
|
|
365
367
|
return !(i instanceof HTMLElement) || !i.matches(w) || !o.contains(i) ? null : i;
|
|
366
368
|
}
|
|
367
|
-
function
|
|
369
|
+
function V(e, n) {
|
|
368
370
|
const o = E(e);
|
|
369
371
|
if (!o) return !1;
|
|
370
|
-
const
|
|
371
|
-
if (!t) return !1;
|
|
372
|
-
const r = t.parentNode;
|
|
372
|
+
const r = ve(o, n, e);
|
|
373
373
|
if (!r) return !1;
|
|
374
|
-
const
|
|
375
|
-
t
|
|
374
|
+
const t = r.parentNode;
|
|
375
|
+
if (!t) return !1;
|
|
376
|
+
const i = e.innerHTML, a = Array.prototype.indexOf.call(t.childNodes, r);
|
|
377
|
+
r.remove();
|
|
376
378
|
const l = document.createRange();
|
|
377
|
-
return l.setStart(
|
|
379
|
+
return l.setStart(t, Math.max(0, a)), l.collapse(!0), h(e, l), Z(e), J(e, i), !0;
|
|
378
380
|
}
|
|
379
|
-
function
|
|
381
|
+
function re(e, n, o, r, t, i) {
|
|
380
382
|
var s;
|
|
381
|
-
if (
|
|
382
|
-
e.isOpen || (e.panel.style.display = "block", e.panel.classList.add("show"), e.isOpen = !0),
|
|
383
|
+
if (he(e, n), e.query = r, e.trigger = t, e.replaceRange = i.cloneRange(), e.loading = !!(n.api && !n.search), e.debounceHandle !== null && (window.clearTimeout(e.debounceHandle), e.debounceHandle = null), !e.panel) return;
|
|
384
|
+
e.isOpen || (e.panel.style.display = "block", e.panel.classList.add("show"), e.isOpen = !0), G(e, n), W(e, o);
|
|
383
385
|
const a = () => {
|
|
384
|
-
e.debounceHandle = null,
|
|
385
|
-
e.loading = !1, e.items = f, e.activeIndex = 0, e.panel && (
|
|
386
|
+
e.debounceHandle = null, xe(e, n, r, t).then((f) => {
|
|
387
|
+
e.loading = !1, e.items = f, e.activeIndex = 0, e.panel && (G(e, n), W(e, o));
|
|
386
388
|
});
|
|
387
389
|
}, l = n.api && !n.search ? Math.max(0, (s = n.api.debounceMs) != null ? s : 180) : 0;
|
|
388
390
|
l > 0 ? e.debounceHandle = window.setTimeout(a, l) : a();
|
|
389
391
|
}
|
|
390
|
-
function
|
|
392
|
+
function ke(e, n) {
|
|
391
393
|
const o = e.editor;
|
|
392
|
-
|
|
393
|
-
let
|
|
394
|
-
if (!
|
|
394
|
+
v(o);
|
|
395
|
+
let r = E(o);
|
|
396
|
+
if (!r || !r.collapsed) {
|
|
395
397
|
m(e);
|
|
396
398
|
return;
|
|
397
399
|
}
|
|
398
|
-
const
|
|
399
|
-
if (!
|
|
400
|
-
h(o,
|
|
400
|
+
const t = I(o, r.cloneRange(), "after");
|
|
401
|
+
if (!O(t, r)) {
|
|
402
|
+
h(o, t), r = t, m(e);
|
|
401
403
|
return;
|
|
402
404
|
}
|
|
403
|
-
const i =
|
|
405
|
+
const i = fe(r);
|
|
404
406
|
if (!i) {
|
|
405
407
|
m(e);
|
|
406
408
|
return;
|
|
407
409
|
}
|
|
408
|
-
const a =
|
|
410
|
+
const a = me(i.textBefore, n.triggerChars, n.maxQueryLength);
|
|
409
411
|
if (!a) {
|
|
410
412
|
m(e);
|
|
411
413
|
return;
|
|
@@ -417,19 +419,21 @@ function Ce(e, n) {
|
|
|
417
419
|
if (e.dismissedNode === i.node && e.dismissedOffset === a.startOffset)
|
|
418
420
|
return;
|
|
419
421
|
e.dismissedNode = null, e.dismissedOffset = -1;
|
|
420
|
-
const l =
|
|
421
|
-
l.setStart(i.node, a.startOffset), l.setEnd(i.node, i.caretOffset),
|
|
422
|
+
const l = r.cloneRange();
|
|
423
|
+
l.setStart(i.node, a.startOffset), l.setEnd(i.node, i.caretOffset), re(e, n, r, a.query, a.trigger, l);
|
|
422
424
|
}
|
|
423
|
-
function
|
|
425
|
+
function X(e, n) {
|
|
424
426
|
if (e.items.length === 0) return;
|
|
425
427
|
const o = e.items.length;
|
|
426
428
|
if (e.activeIndex = ((e.activeIndex + n) % o + o) % o, !e.list) return;
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
const r = Array.from(e.list.querySelectorAll(".rte-mention-item"));
|
|
430
|
+
r.forEach((i, a) => {
|
|
431
|
+
i.classList.toggle("active", a === e.activeIndex), i.setAttribute("aria-selected", a === e.activeIndex ? "true" : "false");
|
|
432
|
+
});
|
|
433
|
+
const t = r[e.activeIndex];
|
|
434
|
+
T(e.editor, e.list, t != null ? t : null), t == null || t.scrollIntoView({ block: "nearest" });
|
|
431
435
|
}
|
|
432
|
-
function
|
|
436
|
+
function Le(e) {
|
|
433
437
|
return {
|
|
434
438
|
editor: e,
|
|
435
439
|
panel: null,
|
|
@@ -448,104 +452,104 @@ function ve(e) {
|
|
|
448
452
|
dismissedOffset: -1
|
|
449
453
|
};
|
|
450
454
|
}
|
|
451
|
-
function
|
|
455
|
+
function Me(e) {
|
|
452
456
|
var o;
|
|
453
|
-
const n =
|
|
454
|
-
n && ((o = n.panel) != null && o.parentNode && n.panel.parentNode.removeChild(n.panel),
|
|
455
|
-
}
|
|
456
|
-
function
|
|
457
|
-
if (
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
beforeInput: (
|
|
461
|
-
|
|
457
|
+
const n = R.get(e);
|
|
458
|
+
n && ((o = n.panel) != null && o.parentNode && n.panel.parentNode.removeChild(n.panel), R.delete(e));
|
|
459
|
+
}
|
|
460
|
+
function q(e, n, o) {
|
|
461
|
+
if (A.has(e)) return;
|
|
462
|
+
v(e);
|
|
463
|
+
const r = {
|
|
464
|
+
beforeInput: (t) => {
|
|
465
|
+
v(e);
|
|
462
466
|
const i = E(e);
|
|
463
467
|
if (!i) return;
|
|
464
|
-
const a =
|
|
468
|
+
const a = te(i, e);
|
|
465
469
|
if (!a) return;
|
|
466
|
-
const l =
|
|
470
|
+
const l = t.inputType || "";
|
|
467
471
|
if (l.startsWith("insert")) {
|
|
468
|
-
if (
|
|
472
|
+
if (t.preventDefault(), K(e, a, "after"), l === "insertParagraph" || l === "insertLineBreak") {
|
|
469
473
|
const s = l === "insertLineBreak" ? "insertLineBreak" : "insertParagraph";
|
|
470
474
|
document.execCommand(s, !1);
|
|
471
475
|
return;
|
|
472
476
|
}
|
|
473
477
|
if (l === "insertText" || l === "insertCompositionText") {
|
|
474
|
-
const s =
|
|
478
|
+
const s = t.data || "";
|
|
475
479
|
if (!s) return;
|
|
476
480
|
document.execCommand("insertText", !1, s);
|
|
477
481
|
}
|
|
478
482
|
}
|
|
479
483
|
},
|
|
480
484
|
input: () => {
|
|
481
|
-
|
|
485
|
+
ke(n, o);
|
|
482
486
|
},
|
|
483
|
-
keydown: (
|
|
487
|
+
keydown: (t) => {
|
|
484
488
|
if (n.isOpen) {
|
|
485
|
-
if (
|
|
486
|
-
|
|
489
|
+
if (t.key === "ArrowDown") {
|
|
490
|
+
t.preventDefault(), X(n, 1);
|
|
487
491
|
return;
|
|
488
492
|
}
|
|
489
|
-
if (
|
|
490
|
-
|
|
493
|
+
if (t.key === "ArrowUp") {
|
|
494
|
+
t.preventDefault(), X(n, -1);
|
|
491
495
|
return;
|
|
492
496
|
}
|
|
493
|
-
if (
|
|
494
|
-
|
|
497
|
+
if (t.key === "Enter" || t.key === "Tab") {
|
|
498
|
+
t.preventDefault(), ne(n, o, n.activeIndex);
|
|
495
499
|
return;
|
|
496
500
|
}
|
|
497
|
-
if (
|
|
498
|
-
|
|
501
|
+
if (t.key === "Escape") {
|
|
502
|
+
t.preventDefault(), n.replaceRange && (n.dismissedNode = n.replaceRange.startContainer, n.dismissedOffset = n.replaceRange.startOffset), m(n);
|
|
499
503
|
return;
|
|
500
504
|
}
|
|
501
505
|
}
|
|
502
506
|
const i = E(e);
|
|
503
507
|
if (i) {
|
|
504
|
-
const a =
|
|
505
|
-
if (!
|
|
506
|
-
if (
|
|
507
|
-
|
|
508
|
+
const a = I(e, i.cloneRange(), "after");
|
|
509
|
+
if (!O(a, i)) {
|
|
510
|
+
if (t.key === "Enter") {
|
|
511
|
+
t.preventDefault(), h(e, a), document.execCommand("insertParagraph", !1);
|
|
508
512
|
return;
|
|
509
513
|
}
|
|
510
|
-
|
|
514
|
+
t.key.length === 1 && !t.metaKey && !t.ctrlKey && !t.altKey && h(e, a);
|
|
511
515
|
}
|
|
512
516
|
}
|
|
513
|
-
if (
|
|
514
|
-
|
|
517
|
+
if (t.key === "Backspace" && V(e, "backward")) {
|
|
518
|
+
t.preventDefault();
|
|
515
519
|
return;
|
|
516
520
|
}
|
|
517
|
-
if (
|
|
518
|
-
|
|
521
|
+
if (t.key === "Delete" && V(e, "forward")) {
|
|
522
|
+
t.preventDefault();
|
|
519
523
|
return;
|
|
520
524
|
}
|
|
521
525
|
},
|
|
522
|
-
click: (
|
|
523
|
-
const i =
|
|
526
|
+
click: (t) => {
|
|
527
|
+
const i = t.target;
|
|
524
528
|
if (!i) return;
|
|
525
529
|
const a = i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement, l = a == null ? void 0 : a.closest(w);
|
|
526
|
-
!l || !e.contains(l) || (
|
|
530
|
+
!l || !e.contains(l) || (t.preventDefault(), t.stopPropagation(), K(e, l, "after"), m(n));
|
|
527
531
|
},
|
|
528
532
|
blur: () => {
|
|
529
533
|
window.setTimeout(() => {
|
|
530
|
-
const
|
|
531
|
-
n.panel &&
|
|
534
|
+
const t = document.activeElement;
|
|
535
|
+
n.panel && t && n.panel.contains(t) || m(n);
|
|
532
536
|
}, 0);
|
|
533
537
|
},
|
|
534
|
-
mousedown: (
|
|
538
|
+
mousedown: (t) => {
|
|
535
539
|
if (!n.isOpen || !n.panel) return;
|
|
536
|
-
const i =
|
|
540
|
+
const i = t.target;
|
|
537
541
|
i && !n.panel.contains(i) && !e.contains(i) && m(n);
|
|
538
542
|
}
|
|
539
543
|
};
|
|
540
|
-
e.addEventListener("beforeinput",
|
|
544
|
+
e.addEventListener("beforeinput", r.beforeInput), e.addEventListener("input", r.input), e.addEventListener("keydown", r.keydown), e.addEventListener("click", r.click), e.addEventListener("blur", r.blur), document.addEventListener("mousedown", r.mousedown, !0), A.set(e, r);
|
|
541
545
|
}
|
|
542
|
-
function
|
|
543
|
-
const n =
|
|
544
|
-
n && (e.removeEventListener("beforeinput", n.beforeInput), e.removeEventListener("input", n.input), e.removeEventListener("keydown", n.keydown), e.removeEventListener("click", n.click), e.removeEventListener("blur", n.blur), document.removeEventListener("mousedown", n.mousedown, !0),
|
|
546
|
+
function Ne(e) {
|
|
547
|
+
const n = A.get(e);
|
|
548
|
+
n && (e.removeEventListener("beforeinput", n.beforeInput), e.removeEventListener("input", n.input), e.removeEventListener("keydown", n.keydown), e.removeEventListener("click", n.click), e.removeEventListener("blur", n.blur), document.removeEventListener("mousedown", n.mousedown, !0), A.delete(e));
|
|
545
549
|
}
|
|
546
|
-
function
|
|
547
|
-
if (
|
|
548
|
-
|
|
550
|
+
function Re() {
|
|
551
|
+
if (Q || typeof document == "undefined") return;
|
|
552
|
+
Q = !0;
|
|
549
553
|
const e = document.createElement("style");
|
|
550
554
|
e.id = "rte-mention-plugin-styles", e.textContent = `
|
|
551
555
|
.rte-mention {
|
|
@@ -609,58 +613,58 @@ function Me() {
|
|
|
609
613
|
|
|
610
614
|
.rte-mention-item-meta {
|
|
611
615
|
font-size: 12px;
|
|
612
|
-
color: #
|
|
616
|
+
color: #475569;
|
|
613
617
|
white-space: nowrap;
|
|
614
618
|
}
|
|
615
619
|
|
|
616
620
|
.rte-mention-empty {
|
|
617
621
|
padding: 12px;
|
|
618
|
-
color: #
|
|
622
|
+
color: #475569;
|
|
619
623
|
font-size: 13px;
|
|
620
624
|
text-align: center;
|
|
621
625
|
}
|
|
622
626
|
|
|
623
|
-
${
|
|
627
|
+
${y} .rte-mention {
|
|
624
628
|
background: rgba(37, 99, 235, 0.25);
|
|
625
629
|
color: #bfdbfe;
|
|
626
630
|
}
|
|
627
631
|
|
|
628
|
-
${
|
|
632
|
+
${y} .rte-mention-panel,
|
|
629
633
|
.rte-mention-panel.rte-mention-theme-dark {
|
|
630
634
|
border-color: #364152;
|
|
631
635
|
background: #1f2937;
|
|
632
636
|
box-shadow: 0 22px 44px rgba(0, 0, 0, 0.48);
|
|
633
637
|
}
|
|
634
638
|
|
|
635
|
-
${
|
|
639
|
+
${y} .rte-mention-item,
|
|
636
640
|
.rte-mention-panel.rte-mention-theme-dark .rte-mention-item {
|
|
637
641
|
color: #e5e7eb;
|
|
638
642
|
}
|
|
639
643
|
|
|
640
|
-
${
|
|
641
|
-
${
|
|
644
|
+
${y} .rte-mention-item:hover,
|
|
645
|
+
${y} .rte-mention-item.active,
|
|
642
646
|
.rte-mention-panel.rte-mention-theme-dark .rte-mention-item:hover,
|
|
643
647
|
.rte-mention-panel.rte-mention-theme-dark .rte-mention-item.active {
|
|
644
648
|
background: #334155;
|
|
645
649
|
color: #bfdbfe;
|
|
646
650
|
}
|
|
647
651
|
|
|
648
|
-
${
|
|
649
|
-
${
|
|
652
|
+
${y} .rte-mention-item-meta,
|
|
653
|
+
${y} .rte-mention-empty,
|
|
650
654
|
.rte-mention-panel.rte-mention-theme-dark .rte-mention-item-meta,
|
|
651
655
|
.rte-mention-panel.rte-mention-theme-dark .rte-mention-empty {
|
|
652
|
-
color: #
|
|
656
|
+
color: #cbd5e1;
|
|
653
657
|
}
|
|
654
658
|
`, document.head.appendChild(e);
|
|
655
659
|
}
|
|
656
|
-
function
|
|
657
|
-
var o,
|
|
660
|
+
function Ae(e) {
|
|
661
|
+
var o, r, t;
|
|
658
662
|
const n = (e.triggerChars || ["@"]).filter((i) => typeof i == "string" && i.length > 0).map((i) => i[0]);
|
|
659
663
|
return {
|
|
660
664
|
triggerChars: n.length > 0 ? n : ["@"],
|
|
661
665
|
minChars: Math.max(0, (o = e.minChars) != null ? o : 1),
|
|
662
|
-
maxQueryLength: Math.max(1, (
|
|
663
|
-
maxSuggestions: Math.max(1, (
|
|
666
|
+
maxQueryLength: Math.max(1, (r = e.maxQueryLength) != null ? r : 32),
|
|
667
|
+
maxSuggestions: Math.max(1, (t = e.maxSuggestions) != null ? t : 8),
|
|
664
668
|
items: e.items || [
|
|
665
669
|
{ id: "john.doe", label: "John Doe", meta: "john@acme.com" },
|
|
666
670
|
{ id: "sarah.lee", label: "Sarah Lee", meta: "sarah@acme.com" },
|
|
@@ -675,28 +679,28 @@ function Ne(e) {
|
|
|
675
679
|
insertSpaceAfterMention: e.insertSpaceAfterMention !== !1
|
|
676
680
|
};
|
|
677
681
|
}
|
|
678
|
-
function
|
|
679
|
-
const n =
|
|
682
|
+
function N(e) {
|
|
683
|
+
const n = R.get(e);
|
|
680
684
|
if (n) return n;
|
|
681
|
-
const o =
|
|
682
|
-
return
|
|
685
|
+
const o = Le(e);
|
|
686
|
+
return R.set(e, o), o;
|
|
683
687
|
}
|
|
684
|
-
function
|
|
685
|
-
S || (S = !0,
|
|
688
|
+
function Se(e) {
|
|
689
|
+
S || (S = !0, C = (n) => {
|
|
686
690
|
const o = n.target;
|
|
687
691
|
if (!(o instanceof Node)) return;
|
|
688
|
-
const
|
|
689
|
-
if (!
|
|
690
|
-
const i =
|
|
691
|
-
|
|
692
|
-
}, document.addEventListener("focusin",
|
|
693
|
-
}
|
|
694
|
-
function
|
|
695
|
-
!S || !
|
|
696
|
-
}
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
const n =
|
|
692
|
+
const r = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement, t = (r == null ? void 0 : r.closest(g)) || null;
|
|
693
|
+
if (!t) return;
|
|
694
|
+
const i = N(t);
|
|
695
|
+
q(t, i, e);
|
|
696
|
+
}, document.addEventListener("focusin", C, !0));
|
|
697
|
+
}
|
|
698
|
+
function Oe() {
|
|
699
|
+
!S || !C || (document.removeEventListener("focusin", C, !0), S = !1, C = null);
|
|
700
|
+
}
|
|
701
|
+
const qe = (e = {}) => {
|
|
702
|
+
Re();
|
|
703
|
+
const n = Ae(e);
|
|
700
704
|
return {
|
|
701
705
|
name: "mentions",
|
|
702
706
|
toolbar: [
|
|
@@ -707,33 +711,33 @@ const Ie = (e = {}) => {
|
|
|
707
711
|
}
|
|
708
712
|
],
|
|
709
713
|
commands: {
|
|
710
|
-
insertMention: (o,
|
|
711
|
-
const
|
|
712
|
-
if (!
|
|
713
|
-
const i =
|
|
714
|
-
|
|
715
|
-
let a = E(
|
|
716
|
-
a || (a = document.createRange(), a.selectNodeContents(
|
|
717
|
-
const l =
|
|
718
|
-
|
|
714
|
+
insertMention: (o, r) => {
|
|
715
|
+
const t = ce(r);
|
|
716
|
+
if (!t) return !1;
|
|
717
|
+
const i = N(t);
|
|
718
|
+
q(t, i, n);
|
|
719
|
+
let a = E(t);
|
|
720
|
+
a || (a = document.createRange(), a.selectNodeContents(t), a.collapse(!1), h(t, a));
|
|
721
|
+
const l = I(t, a.cloneRange(), "after");
|
|
722
|
+
O(l, a) || (h(t, l), a = l), i.query = "";
|
|
719
723
|
const s = a.cloneRange();
|
|
720
|
-
return i.trigger = n.triggerChars[0],
|
|
724
|
+
return i.trigger = n.triggerChars[0], re(i, n, a, "", i.trigger, s), !0;
|
|
721
725
|
}
|
|
722
726
|
},
|
|
723
727
|
init: () => {
|
|
724
|
-
|
|
725
|
-
const
|
|
726
|
-
|
|
728
|
+
L += 1, Se(n), Array.from(document.querySelectorAll(g)).forEach((r) => {
|
|
729
|
+
const t = N(r);
|
|
730
|
+
q(r, t, n);
|
|
727
731
|
});
|
|
728
732
|
},
|
|
729
733
|
destroy: () => {
|
|
730
|
-
|
|
731
|
-
m(
|
|
732
|
-
}),
|
|
734
|
+
L = Math.max(0, L - 1), Array.from(document.querySelectorAll(g)).forEach((r) => {
|
|
735
|
+
m(N(r)), Ne(r), Me(r);
|
|
736
|
+
}), L === 0 && Oe();
|
|
733
737
|
}
|
|
734
738
|
};
|
|
735
739
|
};
|
|
736
740
|
export {
|
|
737
|
-
|
|
741
|
+
qe as MentionPlugin
|
|
738
742
|
};
|
|
739
|
-
//# sourceMappingURL=MentionPlugin.native-
|
|
743
|
+
//# sourceMappingURL=MentionPlugin.native-Zb1dwdxU.mjs.map
|