@editora/plugins 1.0.22 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-BwhZsI5v.js} +11 -11
- package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-CojLCp6C.mjs} +61 -53
- package/dist/MediaManagerPlugin.native-CycfjOi4.js +1841 -0
- package/dist/MediaManagerPlugin.native-DZrmcmnm.mjs +4688 -0
- package/dist/a11y-checker.cjs.js +3 -3
- package/dist/a11y-checker.esm.js +6 -4
- package/dist/anchor.cjs.js +4 -4
- package/dist/anchor.esm.js +19 -18
- package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
- package/dist/anchoredPopover-Cygmit_o.js +1 -0
- package/dist/approval-workflow.cjs.js +7 -7
- package/dist/approval-workflow.esm.js +55 -54
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +72 -67
- package/dist/blocks-library.cjs.js +18 -19
- package/dist/blocks-library.esm.js +41 -42
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +50 -50
- package/dist/code-sample.cjs.js +10 -10
- package/dist/code-sample.esm.js +4 -4
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/comments.cjs.js +23 -11
- package/dist/comments.esm.js +167 -149
- package/dist/conditional-content.cjs.js +2 -2
- package/dist/conditional-content.esm.js +2 -2
- package/dist/confirmDialog-D3S8BhIM.js +42 -0
- package/dist/confirmDialog-DR4c8j6S.mjs +87 -0
- package/dist/content-rules.cjs.js +6 -6
- package/dist/content-rules.esm.js +51 -51
- package/dist/data-binding.cjs.js +2 -2
- package/dist/data-binding.esm.js +2 -2
- package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
- package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
- package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
- package/dist/embed-iframe.cjs.js +6 -6
- package/dist/embed-iframe.esm.js +6 -6
- package/dist/emojis.cjs.js +5 -5
- package/dist/emojis.esm.js +3 -3
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +12 -12
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +172 -151
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +96 -83
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +176 -97
- package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
- package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +90 -83
- package/dist/katex-Cc3-mvOY.js +257 -0
- package/dist/katex-DoRnZ_sp.mjs +11682 -0
- package/dist/katex.min--Ws3c9be.mjs +5 -0
- package/dist/katex.min-Dk2VscxB.js +2 -0
- package/dist/link.cjs.js +3 -3
- package/dist/link.esm.js +3 -3
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +140 -52
- package/dist/math.cjs.js +14 -14
- package/dist/math.esm.js +149 -136
- package/dist/media-manager.cjs.js +1 -619
- package/dist/media-manager.esm.js +30 -1017
- package/dist/mentions.cjs.js +12 -12
- package/dist/mentions.esm.js +149 -143
- package/dist/merge-tag.cjs.js +5 -3
- package/dist/merge-tag.esm.js +5 -3
- package/dist/notify-BkbzMopb.js +32 -0
- package/dist/notify-zOp-mUOJ.mjs +59 -0
- package/dist/pii-redaction.cjs.js +1 -1
- package/dist/pii-redaction.esm.js +1 -1
- package/dist/preview.cjs.js +1 -1
- package/dist/preview.esm.js +1 -1
- package/dist/shared-config.cjs.js +1 -1
- package/dist/shared-config.esm.js +14 -14
- package/dist/slash-commands.cjs.js +5 -5
- package/dist/slash-commands.esm.js +259 -236
- package/dist/smart-paste.cjs.js +1 -1
- package/dist/smart-paste.esm.js +1 -1
- package/dist/special-characters.cjs.js +3 -3
- package/dist/special-characters.esm.js +3 -3
- package/dist/spell-check.cjs.js +9 -9
- package/dist/spell-check.esm.js +288 -251
- package/dist/table.cjs.js +14 -14
- package/dist/table.esm.js +175 -154
- package/dist/template.cjs.js +5 -3
- package/dist/template.esm.js +15 -13
- package/dist/text-color.cjs.js +4 -4
- package/dist/text-color.esm.js +38 -34
- package/dist/translation-workflow.cjs.js +9 -9
- package/dist/translation-workflow.esm.js +98 -95
- package/dist/version-diff.cjs.js +4 -4
- package/dist/version-diff.esm.js +36 -36
- package/index.d.ts +183 -2
- package/package.json +6 -5
- package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
- package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
- package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
- package/dist/dialogHelpers-zU6zpMIA.js +0 -12
package/dist/mentions.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { a as T } from "./dialogHelpers-BbwpIXD9.mjs";
|
|
2
|
+
const g = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", w = '.rte-mention[data-mention="true"]', b = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', N = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
let $ = !1, A = !1, C = null, k = 0;
|
|
4
|
+
function U(e, n) {
|
|
4
5
|
if (n === e.innerHTML) return;
|
|
5
6
|
const o = window.execEditorCommand || window.executeEditorCommand;
|
|
6
7
|
if (typeof o == "function")
|
|
@@ -9,7 +10,7 @@ function Q(e, n) {
|
|
|
9
10
|
} catch {
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
+
function W(e) {
|
|
13
14
|
e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
14
15
|
}
|
|
15
16
|
function h(e, n) {
|
|
@@ -25,7 +26,7 @@ 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
|
});
|
|
@@ -33,22 +34,22 @@ function C(e) {
|
|
|
33
34
|
function _(e) {
|
|
34
35
|
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
-
return e.closest(
|
|
37
|
+
function ne(e) {
|
|
38
|
+
return e.closest(ee) || e;
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function L(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 te(e) {
|
|
44
|
+
const n = ne(e);
|
|
45
|
+
if (L(n)) return !0;
|
|
45
46
|
const o = n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
|
|
46
|
-
return
|
|
47
|
+
return L(o) ? !0 : L(document.documentElement) || L(document.body);
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
-
e.classList.remove("rte-mention-theme-dark"),
|
|
49
|
+
function G(e, n) {
|
|
50
|
+
e.classList.remove("rte-mention-theme-dark"), te(n) && e.classList.add("rte-mention-theme-dark");
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
+
function re(e) {
|
|
52
53
|
if (e?.contentElement instanceof HTMLElement) return e.contentElement;
|
|
53
54
|
if (e?.editorElement instanceof HTMLElement) {
|
|
54
55
|
const t = e.editorElement;
|
|
@@ -72,19 +73,19 @@ function te(e) {
|
|
|
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 q(e) {
|
|
76
77
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function oe(e, n) {
|
|
79
80
|
return n ? n.split(".").filter(Boolean).reduce((o, t) => {
|
|
80
|
-
if (!(!
|
|
81
|
+
if (!(!q(o) && !Array.isArray(o)))
|
|
81
82
|
return o[t];
|
|
82
83
|
}, e) : e;
|
|
83
84
|
}
|
|
84
|
-
function
|
|
85
|
+
function ie(e) {
|
|
85
86
|
return e ? /\s|[([{"'`]/.test(e) : !0;
|
|
86
87
|
}
|
|
87
|
-
function
|
|
88
|
+
function ae(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) {
|
|
@@ -111,12 +112,12 @@ function ie(e) {
|
|
|
111
112
|
}
|
|
112
113
|
return null;
|
|
113
114
|
}
|
|
114
|
-
function
|
|
115
|
+
function le(e, n, o) {
|
|
115
116
|
let t = -1, r = "";
|
|
116
117
|
if (n.forEach((a) => {
|
|
117
118
|
const l = e.lastIndexOf(a);
|
|
118
119
|
l > t && (t = l, r = a);
|
|
119
|
-
}), t < 0 || !
|
|
120
|
+
}), t < 0 || !ie(e[t - 1])) return null;
|
|
120
121
|
const i = e.slice(t + 1);
|
|
121
122
|
return /\s/.test(i) || i.length > o ? null : {
|
|
122
123
|
trigger: r,
|
|
@@ -124,7 +125,7 @@ function ae(e, n, o) {
|
|
|
124
125
|
startOffset: t
|
|
125
126
|
};
|
|
126
127
|
}
|
|
127
|
-
function
|
|
128
|
+
function se(e, n) {
|
|
128
129
|
const o = n.cloneRange();
|
|
129
130
|
o.collapse(!1);
|
|
130
131
|
const t = o.getClientRects();
|
|
@@ -135,12 +136,13 @@ function le(e, n) {
|
|
|
135
136
|
const i = r.getBoundingClientRect();
|
|
136
137
|
return r.remove(), e.normalize(), i;
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
+
let ce = 0;
|
|
140
|
+
function ue(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
144
|
const t = document.createElement("div");
|
|
143
|
-
t.className = "rte-mention-list", o.appendChild(t), document.body.appendChild(o),
|
|
145
|
+
t.className = "rte-mention-list", t.setAttribute("role", "listbox"), t.setAttribute("aria-label", "Mentions"), t.id = `rte-mention-list-${++ce}`, o.appendChild(t), document.body.appendChild(o), G(o, e.editor), e.panel = o, e.list = t, o.addEventListener("mousedown", (r) => {
|
|
144
146
|
r.preventDefault();
|
|
145
147
|
}), o.addEventListener("click", (r) => {
|
|
146
148
|
const i = r.target;
|
|
@@ -148,49 +150,49 @@ function se(e, n) {
|
|
|
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) && V(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 B(e, n) {
|
|
158
160
|
if (!e.panel) return;
|
|
159
|
-
|
|
160
|
-
const o =
|
|
161
|
+
G(e.panel, e.editor);
|
|
162
|
+
const o = se(e.editor, n), t = e.panel;
|
|
161
163
|
t.style.display = "block", t.classList.add("show"), t.style.left = "0px", t.style.top = "0px";
|
|
162
164
|
const r = t.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight, l = Math.max(8, Math.min(o.left, i - r.width - 8));
|
|
163
165
|
let s = o.bottom + 8;
|
|
164
166
|
s + r.height > a - 8 && (s = Math.max(8, o.top - r.height - 8)), t.style.position = "fixed", t.style.left = `${l}px`, t.style.top = `${s}px`;
|
|
165
167
|
}
|
|
166
|
-
function
|
|
168
|
+
function de(e, n) {
|
|
167
169
|
if (!n) return x(e);
|
|
168
170
|
const o = e.toLowerCase(), t = n.toLowerCase(), r = o.indexOf(t);
|
|
169
171
|
if (r < 0) return x(e);
|
|
170
172
|
const i = x(e.slice(0, r)), a = x(e.slice(r, r + n.length)), l = x(e.slice(r + n.length));
|
|
171
173
|
return `${i}<mark>${a}</mark>${l}`;
|
|
172
174
|
}
|
|
173
|
-
function
|
|
175
|
+
function j(e, n) {
|
|
174
176
|
if (!e.list) return;
|
|
175
177
|
const o = e.list;
|
|
176
178
|
if (o.innerHTML = "", e.loading) {
|
|
177
179
|
const t = document.createElement("div");
|
|
178
|
-
t.className = "rte-mention-empty", t.textContent = n.loadingText, o.appendChild(t);
|
|
180
|
+
t.className = "rte-mention-empty", t.textContent = n.loadingText, o.appendChild(t), T(e.editor, null, null);
|
|
179
181
|
return;
|
|
180
182
|
}
|
|
181
183
|
if (e.items.length === 0) {
|
|
182
184
|
const t = document.createElement("div");
|
|
183
|
-
t.className = "rte-mention-empty", t.textContent = e.query.length > 0 ? n.noResultsText : n.emptyStateText, o.appendChild(t);
|
|
185
|
+
t.className = "rte-mention-empty", t.textContent = e.query.length > 0 ? n.noResultsText : n.emptyStateText, o.appendChild(t), T(e.editor, null, null);
|
|
184
186
|
return;
|
|
185
187
|
}
|
|
186
188
|
e.items.forEach((t, r) => {
|
|
187
189
|
const i = document.createElement("button");
|
|
188
|
-
i.type = "button", i.className = "rte-mention-item", r === e.activeIndex && i.classList.add("active"), i.setAttribute("data-index", String(r));
|
|
189
|
-
const a = n.itemRenderer ? n.itemRenderer(t, e.query) : `<span class="rte-mention-item-label">${
|
|
190
|
+
i.type = "button", i.className = "rte-mention-item", r === e.activeIndex && i.classList.add("active"), i.setAttribute("data-index", String(r)), i.setAttribute("role", "option"), i.id = `${o.id}-${r}`, i.setAttribute("aria-selected", r === e.activeIndex ? "true" : "false");
|
|
191
|
+
const a = n.itemRenderer ? n.itemRenderer(t, e.query) : `<span class="rte-mention-item-label">${de(t.label, e.query)}</span>${t.meta ? `<span class="rte-mention-item-meta">${x(t.meta)}</span>` : ""}`;
|
|
190
192
|
i.innerHTML = a, o.appendChild(i);
|
|
191
|
-
});
|
|
193
|
+
}), T(e.editor, o, o.children[e.activeIndex]);
|
|
192
194
|
}
|
|
193
|
-
function
|
|
195
|
+
function K(e, n) {
|
|
194
196
|
const o = /* @__PURE__ */ new Set(), t = [];
|
|
195
197
|
return e.forEach((r) => {
|
|
196
198
|
const i = (r.id || "").trim();
|
|
@@ -202,7 +204,7 @@ function G(e, n) {
|
|
|
202
204
|
}));
|
|
203
205
|
}), t.slice(0, n);
|
|
204
206
|
}
|
|
205
|
-
function
|
|
207
|
+
function fe(e, n) {
|
|
206
208
|
if (e.buildRequest) {
|
|
207
209
|
const c = e.buildRequest(n);
|
|
208
210
|
return {
|
|
@@ -228,7 +230,7 @@ function ue(e, n) {
|
|
|
228
230
|
[a]: n.limit,
|
|
229
231
|
...l
|
|
230
232
|
}, p = c ?? d;
|
|
231
|
-
if (
|
|
233
|
+
if (q(p)) {
|
|
232
234
|
s.body = JSON.stringify(p);
|
|
233
235
|
const y = s.headers;
|
|
234
236
|
!y["Content-Type"] && !y["content-type"] && (y["Content-Type"] = "application/json");
|
|
@@ -237,7 +239,7 @@ function ue(e, n) {
|
|
|
237
239
|
}
|
|
238
240
|
return { url: f.toString(), init: s };
|
|
239
241
|
}
|
|
240
|
-
async function
|
|
242
|
+
async function me(e, n, o, t) {
|
|
241
243
|
const r = n.api;
|
|
242
244
|
if (!r) return [];
|
|
243
245
|
e.abortController && e.abortController.abort();
|
|
@@ -252,62 +254,62 @@ async function de(e, n, o, t) {
|
|
|
252
254
|
let s = null;
|
|
253
255
|
l > 0 && (s = window.setTimeout(() => i.abort(), l));
|
|
254
256
|
try {
|
|
255
|
-
const { url: f, init: c } =
|
|
257
|
+
const { url: f, init: c } = fe(r, a), d = await fetch(f, {
|
|
256
258
|
...c,
|
|
257
259
|
signal: i.signal
|
|
258
260
|
});
|
|
259
261
|
if (!d.ok)
|
|
260
262
|
throw new Error(`Mention API request failed: ${d.status}`);
|
|
261
263
|
const y = (r.responseType || "json") === "text" ? await d.text() : await d.json();
|
|
262
|
-
let
|
|
264
|
+
let I = [];
|
|
263
265
|
if (r.transformResponse)
|
|
264
|
-
|
|
266
|
+
I = r.transformResponse(y, a) || [];
|
|
265
267
|
else {
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
+
const P = oe(y, r.responsePath);
|
|
269
|
+
I = (Array.isArray(P) ? P : Array.isArray(y) ? y : []).map((u, Z) => {
|
|
268
270
|
if (r.mapItem)
|
|
269
|
-
return r.mapItem(u,
|
|
270
|
-
if (!
|
|
271
|
-
const
|
|
272
|
-
if (!
|
|
273
|
-
const
|
|
271
|
+
return r.mapItem(u, Z);
|
|
272
|
+
if (!q(u)) return null;
|
|
273
|
+
const H = String(u.id ?? u.value ?? u.key ?? "").trim();
|
|
274
|
+
if (!H) return null;
|
|
275
|
+
const Y = String(u.label ?? u.name ?? H).trim();
|
|
274
276
|
return {
|
|
275
|
-
id:
|
|
276
|
-
label:
|
|
277
|
+
id: H,
|
|
278
|
+
label: Y,
|
|
277
279
|
value: u.value ? String(u.value) : void 0,
|
|
278
280
|
meta: u.meta ? String(u.meta) : void 0
|
|
279
281
|
};
|
|
280
282
|
}).filter((u) => !!u);
|
|
281
283
|
}
|
|
282
|
-
return
|
|
284
|
+
return K(I, n.maxSuggestions);
|
|
283
285
|
} catch (f) {
|
|
284
286
|
return f?.name !== "AbortError" && r.onError?.(f, a), [];
|
|
285
287
|
} finally {
|
|
286
288
|
s !== null && window.clearTimeout(s), e.abortController === i && (e.abortController = null);
|
|
287
289
|
}
|
|
288
290
|
}
|
|
289
|
-
async function
|
|
291
|
+
async function pe(e, n, o, t) {
|
|
290
292
|
const r = ++e.requestId;
|
|
291
293
|
let i = [];
|
|
292
294
|
if (n.search) {
|
|
293
295
|
const a = await n.search(o, t);
|
|
294
296
|
i = Array.isArray(a) ? a : [];
|
|
295
297
|
} else if (n.api)
|
|
296
|
-
i = await
|
|
298
|
+
i = await me(e, n, o, t);
|
|
297
299
|
else {
|
|
298
300
|
const a = o.toLowerCase();
|
|
299
301
|
i = n.items.filter((l) => a ? l.label.toLowerCase().includes(a) || l.id.toLowerCase().includes(a) : !0);
|
|
300
302
|
}
|
|
301
|
-
return r !== e.requestId ? [] :
|
|
303
|
+
return r !== e.requestId ? [] : K(i, n.maxSuggestions);
|
|
302
304
|
}
|
|
303
|
-
function
|
|
305
|
+
function ge(e, n, o) {
|
|
304
306
|
const t = e.editor;
|
|
305
|
-
if (
|
|
307
|
+
if (v(t), !window.getSelection()) return !1;
|
|
306
308
|
const i = t.innerHTML;
|
|
307
309
|
let a = e.replaceRange ? e.replaceRange.cloneRange() : E(t);
|
|
308
310
|
if (!a || !t.contains(a.commonAncestorContainer) && (a = E(t), !a))
|
|
309
311
|
return !1;
|
|
310
|
-
const l =
|
|
312
|
+
const l = O(t, a.cloneRange(), "after");
|
|
311
313
|
S(l, a) || (h(t, l), a = l), a.deleteContents();
|
|
312
314
|
const s = document.createElement("span");
|
|
313
315
|
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);
|
|
@@ -317,39 +319,39 @@ function me(e, n, o) {
|
|
|
317
319
|
s.after(p), f = p, c = 1;
|
|
318
320
|
}
|
|
319
321
|
const d = document.createRange();
|
|
320
|
-
return d.setStart(f, c), d.collapse(!0), h(t, d), m(e),
|
|
322
|
+
return d.setStart(f, c), d.collapse(!0), h(t, d), m(e), v(t), W(t), U(t, i), !0;
|
|
321
323
|
}
|
|
322
|
-
function
|
|
324
|
+
function V(e, n, o) {
|
|
323
325
|
if (o < 0 || o >= e.items.length) return;
|
|
324
326
|
const t = e.items[o];
|
|
325
|
-
|
|
327
|
+
ge(e, n, t);
|
|
326
328
|
}
|
|
327
|
-
function
|
|
329
|
+
function he(e) {
|
|
328
330
|
return e.startContainer !== e.endContainer || e.startContainer.nodeType !== Node.ELEMENT_NODE || e.endOffset - e.startOffset !== 1 ? null : e.startContainer.childNodes[e.startOffset] || null;
|
|
329
331
|
}
|
|
330
|
-
function
|
|
331
|
-
const o =
|
|
332
|
+
function ye(e, n) {
|
|
333
|
+
const o = he(e);
|
|
332
334
|
return !(o instanceof HTMLElement) || !o.matches(w) || !n.contains(o) ? null : o;
|
|
333
335
|
}
|
|
334
|
-
function
|
|
335
|
-
const o =
|
|
336
|
+
function X(e, n) {
|
|
337
|
+
const o = ye(e, n);
|
|
336
338
|
if (o) return o;
|
|
337
339
|
const r = _(e.startContainer)?.closest(w);
|
|
338
340
|
if (r && n.contains(r)) return r;
|
|
339
341
|
const a = _(e.endContainer)?.closest(w);
|
|
340
342
|
return a && n.contains(a) ? a : null;
|
|
341
343
|
}
|
|
342
|
-
function
|
|
343
|
-
const t =
|
|
344
|
+
function O(e, n, o = "after") {
|
|
345
|
+
const t = X(n, e);
|
|
344
346
|
if (!t) return n;
|
|
345
347
|
const r = document.createRange();
|
|
346
348
|
return o === "before" ? r.setStartBefore(t) : r.setStartAfter(t), r.collapse(!0), r;
|
|
347
349
|
}
|
|
348
|
-
function
|
|
350
|
+
function z(e, n, o = "after") {
|
|
349
351
|
const t = document.createRange();
|
|
350
352
|
o === "before" ? t.setStartBefore(n) : t.setStartAfter(n), t.collapse(!0), h(e, t);
|
|
351
353
|
}
|
|
352
|
-
function
|
|
354
|
+
function be(e, n, o) {
|
|
353
355
|
if (!e.collapsed) return null;
|
|
354
356
|
const t = e.startContainer, r = e.startOffset;
|
|
355
357
|
let i = null;
|
|
@@ -362,47 +364,47 @@ function he(e, n, o) {
|
|
|
362
364
|
}
|
|
363
365
|
return !(i instanceof HTMLElement) || !i.matches(w) || !o.contains(i) ? null : i;
|
|
364
366
|
}
|
|
365
|
-
function
|
|
367
|
+
function F(e, n) {
|
|
366
368
|
const o = E(e);
|
|
367
369
|
if (!o) return !1;
|
|
368
|
-
const t =
|
|
370
|
+
const t = be(o, n, e);
|
|
369
371
|
if (!t) return !1;
|
|
370
372
|
const r = t.parentNode;
|
|
371
373
|
if (!r) return !1;
|
|
372
374
|
const i = e.innerHTML, a = Array.prototype.indexOf.call(r.childNodes, t);
|
|
373
375
|
t.remove();
|
|
374
376
|
const l = document.createRange();
|
|
375
|
-
return l.setStart(r, Math.max(0, a)), l.collapse(!0), h(e, l),
|
|
377
|
+
return l.setStart(r, Math.max(0, a)), l.collapse(!0), h(e, l), W(e), U(e, i), !0;
|
|
376
378
|
}
|
|
377
|
-
function
|
|
378
|
-
if (
|
|
379
|
-
e.isOpen || (e.panel.style.display = "block", e.panel.classList.add("show"), e.isOpen = !0),
|
|
379
|
+
function J(e, n, o, t, r, i) {
|
|
380
|
+
if (ue(e, n), e.query = t, e.trigger = r, e.replaceRange = i.cloneRange(), e.loading = !!(n.api && !n.search), e.debounceHandle !== null && (window.clearTimeout(e.debounceHandle), e.debounceHandle = null), !e.panel) return;
|
|
381
|
+
e.isOpen || (e.panel.style.display = "block", e.panel.classList.add("show"), e.isOpen = !0), j(e, n), B(e, o);
|
|
380
382
|
const a = () => {
|
|
381
|
-
e.debounceHandle = null,
|
|
382
|
-
e.loading = !1, e.items = s, e.activeIndex = 0, e.panel && (
|
|
383
|
+
e.debounceHandle = null, pe(e, n, t, r).then((s) => {
|
|
384
|
+
e.loading = !1, e.items = s, e.activeIndex = 0, e.panel && (j(e, n), B(e, o));
|
|
383
385
|
});
|
|
384
386
|
}, l = n.api && !n.search ? Math.max(0, n.api.debounceMs ?? 180) : 0;
|
|
385
387
|
l > 0 ? e.debounceHandle = window.setTimeout(a, l) : a();
|
|
386
388
|
}
|
|
387
|
-
function
|
|
389
|
+
function Ee(e, n) {
|
|
388
390
|
const o = e.editor;
|
|
389
|
-
|
|
391
|
+
v(o);
|
|
390
392
|
let t = E(o);
|
|
391
393
|
if (!t || !t.collapsed) {
|
|
392
394
|
m(e);
|
|
393
395
|
return;
|
|
394
396
|
}
|
|
395
|
-
const r =
|
|
397
|
+
const r = O(o, t.cloneRange(), "after");
|
|
396
398
|
if (!S(r, t)) {
|
|
397
399
|
h(o, r), t = r, m(e);
|
|
398
400
|
return;
|
|
399
401
|
}
|
|
400
|
-
const i =
|
|
402
|
+
const i = ae(t);
|
|
401
403
|
if (!i) {
|
|
402
404
|
m(e);
|
|
403
405
|
return;
|
|
404
406
|
}
|
|
405
|
-
const a =
|
|
407
|
+
const a = le(i.textBefore, n.triggerChars, n.maxQueryLength);
|
|
406
408
|
if (!a) {
|
|
407
409
|
m(e);
|
|
408
410
|
return;
|
|
@@ -415,16 +417,20 @@ function ye(e, n) {
|
|
|
415
417
|
return;
|
|
416
418
|
e.dismissedNode = null, e.dismissedOffset = -1;
|
|
417
419
|
const l = t.cloneRange();
|
|
418
|
-
l.setStart(i.node, a.startOffset), l.setEnd(i.node, i.caretOffset),
|
|
420
|
+
l.setStart(i.node, a.startOffset), l.setEnd(i.node, i.caretOffset), J(e, n, t, a.query, a.trigger, l);
|
|
419
421
|
}
|
|
420
|
-
function
|
|
422
|
+
function Q(e, n) {
|
|
421
423
|
if (e.items.length === 0) return;
|
|
422
424
|
const o = e.items.length;
|
|
423
425
|
if (e.activeIndex = ((e.activeIndex + n) % o + o) % o, !e.list) return;
|
|
424
426
|
const t = Array.from(e.list.querySelectorAll(".rte-mention-item"));
|
|
425
|
-
t.forEach((i, a) =>
|
|
427
|
+
t.forEach((i, a) => {
|
|
428
|
+
i.classList.toggle("active", a === e.activeIndex), i.setAttribute("aria-selected", a === e.activeIndex ? "true" : "false");
|
|
429
|
+
});
|
|
430
|
+
const r = t[e.activeIndex];
|
|
431
|
+
T(e.editor, e.list, r ?? null), r?.scrollIntoView({ block: "nearest" });
|
|
426
432
|
}
|
|
427
|
-
function
|
|
433
|
+
function xe(e) {
|
|
428
434
|
return {
|
|
429
435
|
editor: e,
|
|
430
436
|
panel: null,
|
|
@@ -443,23 +449,23 @@ function be(e) {
|
|
|
443
449
|
dismissedOffset: -1
|
|
444
450
|
};
|
|
445
451
|
}
|
|
446
|
-
function
|
|
447
|
-
const n =
|
|
448
|
-
n && (n.panel?.parentNode && n.panel.parentNode.removeChild(n.panel),
|
|
452
|
+
function we(e) {
|
|
453
|
+
const n = N.get(e);
|
|
454
|
+
n && (n.panel?.parentNode && n.panel.parentNode.removeChild(n.panel), N.delete(e));
|
|
449
455
|
}
|
|
450
|
-
function
|
|
451
|
-
if (
|
|
452
|
-
|
|
456
|
+
function D(e, n, o) {
|
|
457
|
+
if (R.has(e)) return;
|
|
458
|
+
v(e);
|
|
453
459
|
const t = {
|
|
454
460
|
beforeInput: (r) => {
|
|
455
|
-
|
|
461
|
+
v(e);
|
|
456
462
|
const i = E(e);
|
|
457
463
|
if (!i) return;
|
|
458
|
-
const a =
|
|
464
|
+
const a = X(i, e);
|
|
459
465
|
if (!a) return;
|
|
460
466
|
const l = r.inputType || "";
|
|
461
467
|
if (l.startsWith("insert")) {
|
|
462
|
-
if (r.preventDefault(),
|
|
468
|
+
if (r.preventDefault(), z(e, a, "after"), l === "insertParagraph" || l === "insertLineBreak") {
|
|
463
469
|
const s = l === "insertLineBreak" ? "insertLineBreak" : "insertParagraph";
|
|
464
470
|
document.execCommand(s, !1);
|
|
465
471
|
return;
|
|
@@ -472,20 +478,20 @@ function H(e, n, o) {
|
|
|
472
478
|
}
|
|
473
479
|
},
|
|
474
480
|
input: () => {
|
|
475
|
-
|
|
481
|
+
Ee(n, o);
|
|
476
482
|
},
|
|
477
483
|
keydown: (r) => {
|
|
478
484
|
if (n.isOpen) {
|
|
479
485
|
if (r.key === "ArrowDown") {
|
|
480
|
-
r.preventDefault(),
|
|
486
|
+
r.preventDefault(), Q(n, 1);
|
|
481
487
|
return;
|
|
482
488
|
}
|
|
483
489
|
if (r.key === "ArrowUp") {
|
|
484
|
-
r.preventDefault(),
|
|
490
|
+
r.preventDefault(), Q(n, -1);
|
|
485
491
|
return;
|
|
486
492
|
}
|
|
487
493
|
if (r.key === "Enter" || r.key === "Tab") {
|
|
488
|
-
r.preventDefault(),
|
|
494
|
+
r.preventDefault(), V(n, o, n.activeIndex);
|
|
489
495
|
return;
|
|
490
496
|
}
|
|
491
497
|
if (r.key === "Escape") {
|
|
@@ -495,7 +501,7 @@ function H(e, n, o) {
|
|
|
495
501
|
}
|
|
496
502
|
const i = E(e);
|
|
497
503
|
if (i) {
|
|
498
|
-
const a =
|
|
504
|
+
const a = O(e, i.cloneRange(), "after");
|
|
499
505
|
if (!S(a, i)) {
|
|
500
506
|
if (r.key === "Enter") {
|
|
501
507
|
r.preventDefault(), h(e, a), document.execCommand("insertParagraph", !1);
|
|
@@ -504,11 +510,11 @@ function H(e, n, o) {
|
|
|
504
510
|
r.key.length === 1 && !r.metaKey && !r.ctrlKey && !r.altKey && h(e, a);
|
|
505
511
|
}
|
|
506
512
|
}
|
|
507
|
-
if (r.key === "Backspace" &&
|
|
513
|
+
if (r.key === "Backspace" && F(e, "backward")) {
|
|
508
514
|
r.preventDefault();
|
|
509
515
|
return;
|
|
510
516
|
}
|
|
511
|
-
if (r.key === "Delete" &&
|
|
517
|
+
if (r.key === "Delete" && F(e, "forward")) {
|
|
512
518
|
r.preventDefault();
|
|
513
519
|
return;
|
|
514
520
|
}
|
|
@@ -517,7 +523,7 @@ function H(e, n, o) {
|
|
|
517
523
|
const i = r.target;
|
|
518
524
|
if (!i) return;
|
|
519
525
|
const l = (i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement)?.closest(w);
|
|
520
|
-
!l || !e.contains(l) || (r.preventDefault(), r.stopPropagation(),
|
|
526
|
+
!l || !e.contains(l) || (r.preventDefault(), r.stopPropagation(), z(e, l, "after"), m(n));
|
|
521
527
|
},
|
|
522
528
|
blur: () => {
|
|
523
529
|
window.setTimeout(() => {
|
|
@@ -531,15 +537,15 @@ function H(e, n, o) {
|
|
|
531
537
|
i && !n.panel.contains(i) && !e.contains(i) && m(n);
|
|
532
538
|
}
|
|
533
539
|
};
|
|
534
|
-
e.addEventListener("beforeinput", t.beforeInput), e.addEventListener("input", t.input), e.addEventListener("keydown", t.keydown), e.addEventListener("click", t.click), e.addEventListener("blur", t.blur), document.addEventListener("mousedown", t.mousedown, !0),
|
|
540
|
+
e.addEventListener("beforeinput", t.beforeInput), e.addEventListener("input", t.input), e.addEventListener("keydown", t.keydown), e.addEventListener("click", t.click), e.addEventListener("blur", t.blur), document.addEventListener("mousedown", t.mousedown, !0), R.set(e, t);
|
|
535
541
|
}
|
|
536
|
-
function
|
|
537
|
-
const n =
|
|
538
|
-
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),
|
|
542
|
+
function Te(e) {
|
|
543
|
+
const n = R.get(e);
|
|
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), R.delete(e));
|
|
539
545
|
}
|
|
540
|
-
function
|
|
541
|
-
if (
|
|
542
|
-
|
|
546
|
+
function Ce() {
|
|
547
|
+
if ($ || typeof document > "u") return;
|
|
548
|
+
$ = !0;
|
|
543
549
|
const e = document.createElement("style");
|
|
544
550
|
e.id = "rte-mention-plugin-styles", e.textContent = `
|
|
545
551
|
.rte-mention {
|
|
@@ -603,13 +609,13 @@ function we() {
|
|
|
603
609
|
|
|
604
610
|
.rte-mention-item-meta {
|
|
605
611
|
font-size: 12px;
|
|
606
|
-
color: #
|
|
612
|
+
color: #475569;
|
|
607
613
|
white-space: nowrap;
|
|
608
614
|
}
|
|
609
615
|
|
|
610
616
|
.rte-mention-empty {
|
|
611
617
|
padding: 12px;
|
|
612
|
-
color: #
|
|
618
|
+
color: #475569;
|
|
613
619
|
font-size: 13px;
|
|
614
620
|
text-align: center;
|
|
615
621
|
}
|
|
@@ -643,11 +649,11 @@ function we() {
|
|
|
643
649
|
${b} .rte-mention-empty,
|
|
644
650
|
.rte-mention-panel.rte-mention-theme-dark .rte-mention-item-meta,
|
|
645
651
|
.rte-mention-panel.rte-mention-theme-dark .rte-mention-empty {
|
|
646
|
-
color: #
|
|
652
|
+
color: #cbd5e1;
|
|
647
653
|
}
|
|
648
654
|
`, document.head.appendChild(e);
|
|
649
655
|
}
|
|
650
|
-
function
|
|
656
|
+
function ve(e) {
|
|
651
657
|
const n = (e.triggerChars || ["@"]).filter((o) => typeof o == "string" && o.length > 0).map((o) => o[0]);
|
|
652
658
|
return {
|
|
653
659
|
triggerChars: n.length > 0 ? n : ["@"],
|
|
@@ -668,28 +674,28 @@ function Te(e) {
|
|
|
668
674
|
insertSpaceAfterMention: e.insertSpaceAfterMention !== !1
|
|
669
675
|
};
|
|
670
676
|
}
|
|
671
|
-
function
|
|
672
|
-
const n =
|
|
677
|
+
function M(e) {
|
|
678
|
+
const n = N.get(e);
|
|
673
679
|
if (n) return n;
|
|
674
|
-
const o =
|
|
675
|
-
return
|
|
680
|
+
const o = xe(e);
|
|
681
|
+
return N.set(e, o), o;
|
|
676
682
|
}
|
|
677
|
-
function
|
|
678
|
-
|
|
683
|
+
function ke(e) {
|
|
684
|
+
A || (A = !0, C = (n) => {
|
|
679
685
|
const o = n.target;
|
|
680
686
|
if (!(o instanceof Node)) return;
|
|
681
687
|
const r = (o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement)?.closest(g) || null;
|
|
682
688
|
if (!r) return;
|
|
683
|
-
const i =
|
|
684
|
-
|
|
685
|
-
}, document.addEventListener("focusin",
|
|
689
|
+
const i = M(r);
|
|
690
|
+
D(r, i, e);
|
|
691
|
+
}, document.addEventListener("focusin", C, !0));
|
|
686
692
|
}
|
|
687
|
-
function
|
|
688
|
-
!
|
|
693
|
+
function Le() {
|
|
694
|
+
!A || !C || (document.removeEventListener("focusin", C, !0), A = !1, C = null);
|
|
689
695
|
}
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
const n =
|
|
696
|
+
const Re = (e = {}) => {
|
|
697
|
+
Ce();
|
|
698
|
+
const n = ve(e);
|
|
693
699
|
return {
|
|
694
700
|
name: "mentions",
|
|
695
701
|
toolbar: [
|
|
@@ -701,31 +707,31 @@ const Le = (e = {}) => {
|
|
|
701
707
|
],
|
|
702
708
|
commands: {
|
|
703
709
|
insertMention: (o, t) => {
|
|
704
|
-
const r =
|
|
710
|
+
const r = re(t);
|
|
705
711
|
if (!r) return !1;
|
|
706
|
-
const i =
|
|
707
|
-
|
|
712
|
+
const i = M(r);
|
|
713
|
+
D(r, i, n);
|
|
708
714
|
let a = E(r);
|
|
709
715
|
a || (a = document.createRange(), a.selectNodeContents(r), a.collapse(!1), h(r, a));
|
|
710
|
-
const l =
|
|
716
|
+
const l = O(r, a.cloneRange(), "after");
|
|
711
717
|
S(l, a) || (h(r, l), a = l), i.query = "";
|
|
712
718
|
const s = a.cloneRange();
|
|
713
|
-
return i.trigger = n.triggerChars[0],
|
|
719
|
+
return i.trigger = n.triggerChars[0], J(i, n, a, "", i.trigger, s), !0;
|
|
714
720
|
}
|
|
715
721
|
},
|
|
716
722
|
init: () => {
|
|
717
|
-
|
|
718
|
-
const r =
|
|
719
|
-
|
|
723
|
+
k += 1, ke(n), Array.from(document.querySelectorAll(g)).forEach((t) => {
|
|
724
|
+
const r = M(t);
|
|
725
|
+
D(t, r, n);
|
|
720
726
|
});
|
|
721
727
|
},
|
|
722
728
|
destroy: () => {
|
|
723
|
-
|
|
724
|
-
m(
|
|
725
|
-
}),
|
|
729
|
+
k = Math.max(0, k - 1), Array.from(document.querySelectorAll(g)).forEach((t) => {
|
|
730
|
+
m(M(t)), Te(t), we(t);
|
|
731
|
+
}), k === 0 && Le();
|
|
726
732
|
}
|
|
727
733
|
};
|
|
728
734
|
};
|
|
729
735
|
export {
|
|
730
|
-
|
|
736
|
+
Re as MentionPlugin
|
|
731
737
|
};
|