Wijzigen voor document MentionsMacro
Laatst gewijzigd door admin op 10-04-2026
Samenvatting
-
Objecten (2 gewijzigd, 0 toegevoegd, 0 verwijderd)
Details
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -62,10 +62,8 @@ 62 62 ckeditorPromise.then(ckeditor => { 63 63 function getUserMentionsConfig(editor) { 64 64 return { 65 - dataCallback: function (options, callback) { 66 - // Remove the marker prefix and replace non-breaking space. 67 - const text = options.query.substring(1).replaceAll('\u00A0', ' '); 68 - search(text, callback); 65 + feed: function (opts, callback) { 66 + search(opts.query, callback); 69 69 }, 70 70 marker: '@', 71 71 minChars: 0, ... ... @@ -99,30 +99,19 @@ 99 99 }; 100 100 } 101 101 102 - // Enable the user mentions for the CKEditor instances that have been already created. 103 - Object.values(ckeditor.instances).forEach(maybeEnableUserMentions); 104 - // Enable the user mentions for the CKEditor instances that are going to be created from now on. 105 - ckeditor.on('instanceCreated', (event) => { 106 - maybeEnableUserMentions(event.editor); 107 - }); 108 - 109 - function maybeEnableUserMentions(editor) { 110 - return waitForEditorReady(editor).then(editor => { 111 - new CKEDITOR.plugins.AdvancedAutoComplete(editor, getUserMentionsConfig(editor)); 112 - return editor; 113 - }); 100 + function updateConfig(editor) { 101 + editor.config.mentions = editor.config.mentions || []; 102 + editor.config.mentions.push(getUserMentionsConfig(editor)); 114 114 } 115 115 116 - function waitForEditorReady(editor) { 117 - return new Promise((resolve, reject) => { 118 - if (editor.status === 'ready') { 119 - resolve(editor); 120 - } else { 121 - editor.once('instanceReady', (event) => { 122 - resolve(event.editor); 123 - }); 124 - } 105 + ckeditor.on('instanceCreated', function(event) { 106 + // The editor instance was created but it not yet initialized. Unfortunately the configuration object passed when 107 + // the instance was created has not been merged with the global configuration yet. 108 + event.editor.once('configLoaded', function(event) { 109 + // The editor configuration has been loaded (the instance configuration has been merged with the global 110 + // configuration) but the editor has not been fully initialized yet so we can modify the configuration. 111 + updateConfig(event.editor); 125 125 }); 126 - } 113 + }); 127 127 }); 128 128 });
- XWiki.StyleSheetExtension[0]
-
- Code
-
... ... @@ -1,17 +1,11 @@ 1 1 .xwiki-mention { 2 - --mentions-color: $services.mentions.mentionsColor; 3 - --mentions-self-color: $services.mentions.selfMentionsForeground; 4 - --mentions-self-bg: $services.mentions.selfMentionsColor; 5 - background-color: var(--mentions-color); 6 - border-radius: 10px; 7 - padding: 1px 5px 1px 5px; 8 - border: 1px solid var(--dropdown-divider-bg); 2 + background-color: $services.mentions.mentionsColor; 3 + border-radius: 8px; 4 + padding: 2px 5px 2px 5px; 9 9 } 10 10 11 11 .xwiki-mention.user.self { 12 - background-color: var(--mentions-self-bg); 13 - color: var(--mentions-self-color); 14 - border: 0; 8 + background-color: $services.mentions.selfMentionsColor; 15 15 } 16 16 17 17 .xwiki-mention.removed {