nodebb-plugin-mentions 4.8.12 → 4.8.14
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/library.js +1 -1
- package/package.json +1 -1
- package/static/autofill.js +18 -3
package/library.js
CHANGED
|
@@ -487,7 +487,7 @@ Mentions.parseRaw = async (content, type = 'default') => {
|
|
|
487
487
|
|
|
488
488
|
replacements = Array.from(replacements)
|
|
489
489
|
.sort((a, b) => {
|
|
490
|
-
return b.user.userslug.length - a.user.userslug.length;
|
|
490
|
+
return b.user && a.user ? b.user.userslug.length - a.user.userslug.length : 0;
|
|
491
491
|
})
|
|
492
492
|
.forEach(({ match, url, user, mentionType }) => {
|
|
493
493
|
const regex = isLatinMention.test(match) ?
|
package/package.json
CHANGED
package/static/autofill.js
CHANGED
|
@@ -7,6 +7,7 @@ $(document).ready(function () {
|
|
|
7
7
|
const categorySlugMap = new Map();
|
|
8
8
|
let localUserList = [];
|
|
9
9
|
let helpers;
|
|
10
|
+
let groupTranslation = '';
|
|
10
11
|
|
|
11
12
|
function showAlert(type, message) {
|
|
12
13
|
require(['alerts'], function (alerts) {
|
|
@@ -24,6 +25,15 @@ $(document).ready(function () {
|
|
|
24
25
|
if (!categoryList) {
|
|
25
26
|
loadCategoryList();
|
|
26
27
|
}
|
|
28
|
+
|
|
29
|
+
if (!groupTranslation) {
|
|
30
|
+
require(['translator'], function (translator) {
|
|
31
|
+
translator.translate('[[groups:group]]', function (translation) {
|
|
32
|
+
groupTranslation = translation;
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
27
37
|
let slugify;
|
|
28
38
|
const strategy = {
|
|
29
39
|
match: /\B@([^\s\n]*)?$/,
|
|
@@ -62,8 +72,7 @@ $(document).ready(function () {
|
|
|
62
72
|
const groupMentions = groupList.filter(
|
|
63
73
|
group => group.name.toLocaleLowerCase().startsWith(termLowerCase) ||
|
|
64
74
|
group.slug.startsWith(termLowerCase)
|
|
65
|
-
).sort((a, b) =>a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase() ? 1 : -1)
|
|
66
|
-
.map(group => group.name);
|
|
75
|
+
).sort((a, b) => a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase() ? 1 : -1);
|
|
67
76
|
|
|
68
77
|
// Add group mentions at the bottom of dropdown
|
|
69
78
|
callback([...users, ...groupMentions]);
|
|
@@ -77,6 +86,8 @@ $(document).ready(function () {
|
|
|
77
86
|
return `@${mention.userslug} `;
|
|
78
87
|
} else if (mention.cid) {
|
|
79
88
|
return `@${utils.isNumber(mention.cid) ? mention.handle : mention.slug} `;
|
|
89
|
+
} else if (mention.isGroup) {
|
|
90
|
+
return `@${slugify(mention.name, true)} `;
|
|
80
91
|
} else if (mention) {
|
|
81
92
|
return `@${slugify(mention, true)} `;
|
|
82
93
|
}
|
|
@@ -119,6 +130,10 @@ $(document).ready(function () {
|
|
|
119
130
|
const avatar = helpers.buildCategoryIcon(entry, '24px', 'rounded-circle');
|
|
120
131
|
return `${avatar} ${entry.name}${!utils.isNumber(entry.cid) ? ` (${entry.slug})` : ''}`;
|
|
121
132
|
}
|
|
133
|
+
case entry.isGroup: {
|
|
134
|
+
const icon = '<i class="fa-fw fa-solid fa-users text-secondary" style="width: 24px;"></i>';
|
|
135
|
+
return `${icon} ${entry.name} (${groupTranslation})`;
|
|
136
|
+
}
|
|
122
137
|
|
|
123
138
|
default:
|
|
124
139
|
return entry.hasOwnProperty('name') ? entry.name : entry;
|
|
@@ -164,7 +179,7 @@ $(document).ready(function () {
|
|
|
164
179
|
return showAlert('error', err.message);
|
|
165
180
|
}
|
|
166
181
|
const s = await app.require('slugify');
|
|
167
|
-
groupList = groupNames.map(name => ({ name, slug: s(name) }));
|
|
182
|
+
groupList = groupNames.map(name => ({ name, slug: s(name), isGroup: true }));
|
|
168
183
|
});
|
|
169
184
|
}
|
|
170
185
|
|