nodebb-plugin-mentions 4.0.3 → 4.0.4
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/package.json +2 -2
- package/static/autofill.js +24 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-mentions",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "NodeBB Plugin that allows users to mention other users by prepending an '@' sign to their username",
|
|
5
5
|
"main": "library.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"mocha": "10.2.0",
|
|
35
|
-
"eslint": "8.
|
|
35
|
+
"eslint": "8.34.0",
|
|
36
36
|
"eslint-config-nodebb": "0.2.1",
|
|
37
37
|
"eslint-plugin-import": "2.27.5"
|
|
38
38
|
}
|
package/static/autofill.js
CHANGED
|
@@ -33,12 +33,18 @@ $(document).ready(function () {
|
|
|
33
33
|
if (err) {
|
|
34
34
|
return callback([]);
|
|
35
35
|
}
|
|
36
|
+
const termLowerCase = term.toLocaleLowerCase();
|
|
37
|
+
const localMatches = localUserList.filter(
|
|
38
|
+
u => u.username.startsWith(termLowerCase)
|
|
39
|
+
);
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
// remove local matches from search results
|
|
42
|
+
users = users.filter(u => !localMatches.find(lu => lu.uid === u.uid));
|
|
43
|
+
mentions = usersToMentions(sortUsers(localMatches).concat(sortUsers(users)), helpers);
|
|
38
44
|
|
|
39
45
|
// Add groups that start with the search term
|
|
40
46
|
const groupMentions = groupList.filter(function (groupName) {
|
|
41
|
-
return groupName.toLocaleLowerCase().startsWith(
|
|
47
|
+
return groupName.toLocaleLowerCase().startsWith(termLowerCase);
|
|
42
48
|
}).sort(function (a, b) {
|
|
43
49
|
return a.toLocaleLowerCase() > b.toLocaleLowerCase() ? 1 : -1;
|
|
44
50
|
});
|
|
@@ -93,21 +99,28 @@ $(document).ready(function () {
|
|
|
93
99
|
|
|
94
100
|
function loadTopicUsers(element) {
|
|
95
101
|
require(['composer', 'alerts'], function (composer, alerts) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
function findTid() {
|
|
103
|
+
const composerEl = element.parents('.composer').get(0);
|
|
104
|
+
if (composerEl) {
|
|
105
|
+
const uuid = composerEl.getAttribute('data-uuid');
|
|
106
|
+
const composerObj = composer.posts[uuid];
|
|
107
|
+
if (composerObj && composerObj.tid) {
|
|
108
|
+
return composerObj.tid;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (ajaxify.data.template.topic) {
|
|
112
|
+
return ajaxify.data.tid;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
99
115
|
}
|
|
100
116
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (!composerObj.tid) {
|
|
117
|
+
const tid = findTid();
|
|
118
|
+
if (!tid) {
|
|
105
119
|
localUserList = [];
|
|
106
120
|
return;
|
|
107
121
|
}
|
|
108
|
-
|
|
109
122
|
socket.emit('plugins.mentions.getTopicUsers', {
|
|
110
|
-
tid:
|
|
123
|
+
tid: tid,
|
|
111
124
|
}, function (err, users) {
|
|
112
125
|
if (err) {
|
|
113
126
|
return alerts.error(err);
|