@richhtmleditor/mentions 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/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +257 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { EditorPlugin } from "@richhtmleditor/core";
|
|
2
|
+
export type MentionUser = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
avatar?: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
};
|
|
8
|
+
export type MentionsPluginOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* Fetch users matching the typed query after `@`.
|
|
11
|
+
* May return a plain array or a Promise.
|
|
12
|
+
*/
|
|
13
|
+
fetchUsers: (query: string) => MentionUser[] | Promise<MentionUser[]>;
|
|
14
|
+
/** Called after a user is inserted into the document. */
|
|
15
|
+
onMention?: (user: MentionUser) => void;
|
|
16
|
+
/** Maximum number of dropdown results. Default: 8 */
|
|
17
|
+
maxResults?: number;
|
|
18
|
+
/** CSS class for mention spans in the output HTML. Default: 'de-mention' */
|
|
19
|
+
mentionClass?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* @mention autocomplete plugin.
|
|
23
|
+
*
|
|
24
|
+
* Watches for `@` in the editor, shows a dropdown of users from `fetchUsers`,
|
|
25
|
+
* and inserts `<span class="de-mention" data-user-id="..." data-user-name="...">@name</span>`.
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { createMentionsPlugin } from "@richhtmleditor/mentions";
|
|
29
|
+
* createEditor({
|
|
30
|
+
* plugins: [createMentionsPlugin({
|
|
31
|
+
* fetchUsers: async (q) => myApi.searchUsers(q)
|
|
32
|
+
* })]
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function createMentionsPlugin(options: MentionsPluginOptions): EditorPlugin;
|
|
37
|
+
/** Parse all mention spans from an HTML string and return the mentioned users. */
|
|
38
|
+
export declare function extractMentions(html: string): Array<{
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
}>;
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzE,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACtE,yDAAyD;IACzD,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAgBF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,YAAY,CA4NjF;AAED,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAOjF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
function escapeHtml(s) {
|
|
2
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
3
|
+
}
|
|
4
|
+
function getCaretCoords(container) {
|
|
5
|
+
const sel = window.getSelection();
|
|
6
|
+
if (!sel || sel.rangeCount === 0)
|
|
7
|
+
return { x: 0, y: 0 };
|
|
8
|
+
const range = sel.getRangeAt(0).cloneRange();
|
|
9
|
+
range.collapse(true);
|
|
10
|
+
const rect = range.getBoundingClientRect();
|
|
11
|
+
const hostRect = container.getBoundingClientRect();
|
|
12
|
+
return { x: rect.left - hostRect.left, y: rect.bottom - hostRect.top + 4 };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @mention autocomplete plugin.
|
|
16
|
+
*
|
|
17
|
+
* Watches for `@` in the editor, shows a dropdown of users from `fetchUsers`,
|
|
18
|
+
* and inserts `<span class="de-mention" data-user-id="..." data-user-name="...">@name</span>`.
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { createMentionsPlugin } from "@richhtmleditor/mentions";
|
|
22
|
+
* createEditor({
|
|
23
|
+
* plugins: [createMentionsPlugin({
|
|
24
|
+
* fetchUsers: async (q) => myApi.searchUsers(q)
|
|
25
|
+
* })]
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function createMentionsPlugin(options) {
|
|
30
|
+
const maxResults = options.maxResults ?? 8;
|
|
31
|
+
const mentionClass = options.mentionClass ?? "de-mention";
|
|
32
|
+
return {
|
|
33
|
+
id: "richhtmleditor-mentions",
|
|
34
|
+
attach: (editor) => {
|
|
35
|
+
const host = editor.element;
|
|
36
|
+
const contentEl = host.querySelector(".de-content");
|
|
37
|
+
if (!contentEl)
|
|
38
|
+
return () => { };
|
|
39
|
+
let dropdown = null;
|
|
40
|
+
let currentQuery = null;
|
|
41
|
+
let activeIndex = 0;
|
|
42
|
+
let currentUsers = [];
|
|
43
|
+
const closeDropdown = () => {
|
|
44
|
+
dropdown?.remove();
|
|
45
|
+
dropdown = null;
|
|
46
|
+
currentQuery = null;
|
|
47
|
+
currentUsers = [];
|
|
48
|
+
activeIndex = 0;
|
|
49
|
+
};
|
|
50
|
+
const getAtRange = () => {
|
|
51
|
+
const sel = window.getSelection();
|
|
52
|
+
if (!sel || sel.rangeCount === 0)
|
|
53
|
+
return null;
|
|
54
|
+
const range = sel.getRangeAt(0);
|
|
55
|
+
if (!range.collapsed)
|
|
56
|
+
return null;
|
|
57
|
+
const node = range.startContainer;
|
|
58
|
+
if (node.nodeType !== Node.TEXT_NODE)
|
|
59
|
+
return null;
|
|
60
|
+
const text = node.textContent ?? "";
|
|
61
|
+
const caretOffset = range.startOffset;
|
|
62
|
+
const before = text.slice(0, caretOffset);
|
|
63
|
+
const match = before.match(/@([\w.-]*)$/);
|
|
64
|
+
if (!match)
|
|
65
|
+
return null;
|
|
66
|
+
const atOffset = caretOffset - match[0].length;
|
|
67
|
+
return { node: node, atOffset };
|
|
68
|
+
};
|
|
69
|
+
const insertMention = (user) => {
|
|
70
|
+
const atRange = getAtRange();
|
|
71
|
+
if (!atRange) {
|
|
72
|
+
closeDropdown();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const sel = window.getSelection();
|
|
76
|
+
if (!sel) {
|
|
77
|
+
closeDropdown();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Build the replacement range: from '@' to current caret
|
|
81
|
+
const range = document.createRange();
|
|
82
|
+
range.setStart(atRange.node, atRange.atOffset);
|
|
83
|
+
range.setEnd(atRange.node, sel.getRangeAt(0).startOffset);
|
|
84
|
+
range.deleteContents();
|
|
85
|
+
const span = document.createElement("span");
|
|
86
|
+
span.className = mentionClass;
|
|
87
|
+
span.dataset.userId = user.id;
|
|
88
|
+
span.dataset.userName = user.name;
|
|
89
|
+
span.contentEditable = "false";
|
|
90
|
+
span.textContent = `@${user.name}`;
|
|
91
|
+
range.insertNode(span);
|
|
92
|
+
// Place caret after the span
|
|
93
|
+
const after = document.createTextNode("\u00A0");
|
|
94
|
+
span.after(after);
|
|
95
|
+
const newRange = document.createRange();
|
|
96
|
+
newRange.setStart(after, 1);
|
|
97
|
+
newRange.collapse(true);
|
|
98
|
+
sel.removeAllRanges();
|
|
99
|
+
sel.addRange(newRange);
|
|
100
|
+
options.onMention?.(user);
|
|
101
|
+
closeDropdown();
|
|
102
|
+
};
|
|
103
|
+
const renderDropdown = (users, coords) => {
|
|
104
|
+
closeDropdown();
|
|
105
|
+
if (!users.length)
|
|
106
|
+
return;
|
|
107
|
+
currentUsers = users;
|
|
108
|
+
activeIndex = 0;
|
|
109
|
+
dropdown = document.createElement("div");
|
|
110
|
+
dropdown.className = "de-mentions-dropdown";
|
|
111
|
+
dropdown.setAttribute("role", "listbox");
|
|
112
|
+
dropdown.setAttribute("aria-label", "Mention user");
|
|
113
|
+
dropdown.style.cssText = `position:absolute;z-index:600;top:${coords.y}px;left:${coords.x}px;`;
|
|
114
|
+
users.forEach((user, i) => {
|
|
115
|
+
const item = document.createElement("div");
|
|
116
|
+
item.className = "de-mentions-dropdown__item";
|
|
117
|
+
item.setAttribute("role", "option");
|
|
118
|
+
item.setAttribute("aria-selected", i === 0 ? "true" : "false");
|
|
119
|
+
item.dataset.index = String(i);
|
|
120
|
+
if (user.avatar) {
|
|
121
|
+
const img = document.createElement("img");
|
|
122
|
+
img.src = user.avatar;
|
|
123
|
+
img.className = "de-mentions-dropdown__avatar";
|
|
124
|
+
img.alt = "";
|
|
125
|
+
item.appendChild(img);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const initials = document.createElement("span");
|
|
129
|
+
initials.className = "de-mentions-dropdown__initials";
|
|
130
|
+
initials.textContent = user.name.slice(0, 2).toUpperCase();
|
|
131
|
+
item.appendChild(initials);
|
|
132
|
+
}
|
|
133
|
+
const info = document.createElement("div");
|
|
134
|
+
info.className = "de-mentions-dropdown__info";
|
|
135
|
+
const nameEl = document.createElement("span");
|
|
136
|
+
nameEl.className = "de-mentions-dropdown__name";
|
|
137
|
+
nameEl.textContent = user.name;
|
|
138
|
+
info.appendChild(nameEl);
|
|
139
|
+
if (user.role) {
|
|
140
|
+
const roleEl = document.createElement("span");
|
|
141
|
+
roleEl.className = "de-mentions-dropdown__role";
|
|
142
|
+
roleEl.textContent = user.role;
|
|
143
|
+
info.appendChild(roleEl);
|
|
144
|
+
}
|
|
145
|
+
item.appendChild(info);
|
|
146
|
+
item.addEventListener("mousedown", (e) => {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
insertMention(user);
|
|
149
|
+
});
|
|
150
|
+
dropdown.appendChild(item);
|
|
151
|
+
});
|
|
152
|
+
host.appendChild(dropdown);
|
|
153
|
+
highlightItem(0);
|
|
154
|
+
};
|
|
155
|
+
const highlightItem = (index) => {
|
|
156
|
+
if (!dropdown)
|
|
157
|
+
return;
|
|
158
|
+
const items = dropdown.querySelectorAll(".de-mentions-dropdown__item");
|
|
159
|
+
items.forEach((item, i) => {
|
|
160
|
+
item.classList.toggle("de-mentions-dropdown__item--active", i === index);
|
|
161
|
+
item.setAttribute("aria-selected", i === index ? "true" : "false");
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
const onKeydown = (e) => {
|
|
165
|
+
if (!dropdown)
|
|
166
|
+
return;
|
|
167
|
+
if (e.key === "ArrowDown") {
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
activeIndex = Math.min(activeIndex + 1, currentUsers.length - 1);
|
|
170
|
+
highlightItem(activeIndex);
|
|
171
|
+
}
|
|
172
|
+
else if (e.key === "ArrowUp") {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
activeIndex = Math.max(activeIndex - 1, 0);
|
|
175
|
+
highlightItem(activeIndex);
|
|
176
|
+
}
|
|
177
|
+
else if (e.key === "Enter" || e.key === "Tab") {
|
|
178
|
+
if (currentUsers[activeIndex]) {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
insertMention(currentUsers[activeIndex]);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else if (e.key === "Escape") {
|
|
184
|
+
closeDropdown();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
let fetchTimer = null;
|
|
188
|
+
const onInput = () => {
|
|
189
|
+
const atRange = getAtRange();
|
|
190
|
+
if (!atRange) {
|
|
191
|
+
closeDropdown();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const sel = window.getSelection();
|
|
195
|
+
if (!sel || sel.rangeCount === 0)
|
|
196
|
+
return;
|
|
197
|
+
const text = atRange.node.textContent ?? "";
|
|
198
|
+
const query = text.slice(atRange.atOffset + 1, sel.getRangeAt(0).startOffset);
|
|
199
|
+
if (currentQuery === query)
|
|
200
|
+
return;
|
|
201
|
+
currentQuery = query;
|
|
202
|
+
if (fetchTimer)
|
|
203
|
+
clearTimeout(fetchTimer);
|
|
204
|
+
fetchTimer = setTimeout(async () => {
|
|
205
|
+
const coords = getCaretCoords(host);
|
|
206
|
+
const users = (await Promise.resolve(options.fetchUsers(query))).slice(0, maxResults);
|
|
207
|
+
if (currentQuery === query)
|
|
208
|
+
renderDropdown(users, coords);
|
|
209
|
+
}, 120);
|
|
210
|
+
};
|
|
211
|
+
const onDocClick = (e) => {
|
|
212
|
+
if (dropdown && !dropdown.contains(e.target))
|
|
213
|
+
closeDropdown();
|
|
214
|
+
};
|
|
215
|
+
// Inject CSS
|
|
216
|
+
const styleId = "de-mentions-styles";
|
|
217
|
+
if (!document.getElementById(styleId)) {
|
|
218
|
+
const style = document.createElement("style");
|
|
219
|
+
style.id = styleId;
|
|
220
|
+
style.textContent = `
|
|
221
|
+
.${mentionClass}{display:inline;background:color-mix(in srgb,var(--de-primary,#2563eb) 12%,transparent);color:var(--de-primary,#2563eb);border-radius:4px;padding:0 2px;font-weight:500;cursor:default;}
|
|
222
|
+
.de-mentions-dropdown{background:var(--de-toolbar-bg,#fff);border:1px solid var(--de-border,#e2e8f0);border-radius:10px;box-shadow:0 8px 24px rgba(0,0,0,.12);min-width:200px;max-width:280px;overflow:hidden;}
|
|
223
|
+
.de-mentions-dropdown__item{display:flex;align-items:center;gap:10px;padding:8px 12px;cursor:pointer;}
|
|
224
|
+
.de-mentions-dropdown__item--active,.de-mentions-dropdown__item:hover{background:var(--de-primary-hover,#eff6ff);}
|
|
225
|
+
.de-mentions-dropdown__avatar{width:28px;height:28px;border-radius:50%;object-fit:cover;}
|
|
226
|
+
.de-mentions-dropdown__initials{width:28px;height:28px;border-radius:50%;background:var(--de-primary,#2563eb);color:#fff;font-size:.75rem;font-weight:600;display:flex;align-items:center;justify-content:center;flex-shrink:0;}
|
|
227
|
+
.de-mentions-dropdown__info{display:flex;flex-direction:column;min-width:0;}
|
|
228
|
+
.de-mentions-dropdown__name{font-size:.875rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
|
229
|
+
.de-mentions-dropdown__role{font-size:.75rem;color:var(--de-text-muted,#64748b);}
|
|
230
|
+
`.trim();
|
|
231
|
+
document.head.appendChild(style);
|
|
232
|
+
}
|
|
233
|
+
contentEl.addEventListener("input", onInput);
|
|
234
|
+
contentEl.addEventListener("keydown", onKeydown, true);
|
|
235
|
+
document.addEventListener("click", onDocClick);
|
|
236
|
+
void escapeHtml; // suppress unused
|
|
237
|
+
return () => {
|
|
238
|
+
contentEl.removeEventListener("input", onInput);
|
|
239
|
+
contentEl.removeEventListener("keydown", onKeydown, true);
|
|
240
|
+
document.removeEventListener("click", onDocClick);
|
|
241
|
+
if (fetchTimer)
|
|
242
|
+
clearTimeout(fetchTimer);
|
|
243
|
+
closeDropdown();
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/** Parse all mention spans from an HTML string and return the mentioned users. */
|
|
249
|
+
export function extractMentions(html) {
|
|
250
|
+
const template = document.createElement("template");
|
|
251
|
+
template.innerHTML = html;
|
|
252
|
+
return Array.from(template.content.querySelectorAll(".de-mention")).map((span) => ({
|
|
253
|
+
id: span.dataset.userId ?? "",
|
|
254
|
+
name: span.dataset.userName ?? span.textContent?.slice(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,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;KAChE,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@richhtmleditor/mentions",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "@mention users with autocomplete dropdown plugin for Rich HTML Editor.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": ["dist", "README.md"],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.json",
|
|
18
|
+
"prepack": "node ../../scripts/assert-pack-ready.mjs"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@richhtmleditor/core": "^1.1.0"
|
|
22
|
+
},
|
|
23
|
+
"keywords": ["richhtmleditor", "mentions", "autocomplete", "collaboration"],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"publishConfig": { "access": "public" },
|
|
26
|
+
"engines": { "node": ">=18" }
|
|
27
|
+
}
|