Changes for page MentionsMacro

Last modified by Drunk Monkey on 2023-11-02 09:50

From version 9.1
edited by Drunk Monkey
on 2021-12-29 11:08
Change comment: Install extension [org.xwiki.platform:xwiki-platform-mentions-ui/13.10.2]
To version 10.1
edited by Drunk Monkey
on 2022-03-20 10:03
Change comment: Install extension [org.xwiki.platform:xwiki-platform-mentions-ui/14.1]

Summary

Details

XWiki.JavaScriptExtension[0]
Code
... ... @@ -4,12 +4,12 @@
4 4   }
5 5  });
6 6  require(['deferred!ckeditor', 'xwiki-suggestUsers', 'jquery', 'xwiki-meta'], function (ckeditorPromise, suggestUsers, $, xm) {
7 -
7 +
8 8   /**
9 9   * Get the current wiki scope for displaying global, local or global and local users
10 10   */
11 11   const userScope = "$!services.wiki.user.userScope";
12 -
12 +
13 13   // see https://stackoverflow.com/a/6248722/657524
14 14   function random6chars() {
15 15   // I generate the UID from two parts here
... ... @@ -20,7 +20,7 @@
20 20   secondPart = ("000" + secondPart.toString(36)).slice(-3);
21 21   return firstPart + secondPart;
22 22   }
23 -
23 +
24 24   /**
25 25   * Compute a new unique anchor for the given reference.
26 26   * The unique anchor is based on the mentionned user id, concatenaed with a random string of 6 alphanumeric
... ... @@ -39,8 +39,8 @@
39 39   'input': text,
40 40   'limit': 6,
41 41   };
42 - $.when(suggestUsers.loadUsers(userScope, params)).then(function (user) {
43 - const cct = user.map(function (x) {
42 + suggestUsers.loadUsers(userScope, params).then(users => {
43 + const cct = users.map(function (x) {
44 44   // insert an id because that's required by the mentions plugins.
45 45   x.id = x.value;
46 46   // Make sure to display the icon avatar or the image one.
... ... @@ -56,10 +56,10 @@
56 56   return x;
57 57   });
58 58   callback(cct);
59 - })
59 + });
60 60   }
61 61  
62 - ckeditorPromise.done(function (ckeditor) {
62 + ckeditorPromise.then(ckeditor => {
63 63   function confMentions(name) {
64 64   return {
65 65   feed: function (opts, callback) {