Änderungen von Dokument MentionsMacro
Zuletzt geändert von xwikiadmin am 2024/06/24 14:17
Von Version 4.1
bearbeitet von xwikiadmin
am 2022/08/11 16:40
am 2022/08/11 16:40
Änderungskommentar:
Install extension [org.xwiki.platform:xwiki-platform-mentions-ui/14.6]
Auf Version 8.1
bearbeitet von xwikiadmin
am 2024/06/24 14:17
am 2024/06/24 14:17
Änderungskommentar:
Install extension [org.xwiki.platform:xwiki-platform-mentions-ui/16.4.0]
Zusammenfassung
-
Objekte (3 geändert, 0 hinzugefügt, 0 gelöscht)
Details
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -97,19 +97,35 @@ 97 97 }; 98 98 } 99 99 100 - function updateConfig(editor) { 101 - editor.config.mentions = editor.config.mentions || []; 102 - editor.config.mentions.push(getUserMentionsConfig(editor)); 100 + // Enable the user mentions for the CKEditor instances that have been already created. 101 + Object.values(ckeditor.instances).forEach(maybeEnableUserMentions); 102 + // Enable the user mentions for the CKEditor instances that are going to be created from now on. 103 + ckeditor.on('instanceCreated', (event) => { 104 + maybeEnableUserMentions(event.editor); 105 + }); 106 + 107 + function maybeEnableUserMentions(editor) { 108 + return waitForEditorReady(editor).then((editor) => { 109 + // Check if the Mentions plugin is enabled for the given editor instance. 110 + // TODO: Add support for disabling the user mentions for a particular editor instance (without disabling all 111 + // types of mentions). 112 + if (editor.plugins.mentions) { 113 + editor.plugins.mentions.instances.push(new ckeditor.plugins.mentions(editor, getUserMentionsConfig(editor))); 114 + } 115 + return editor; 116 + }); 103 103 } 104 104 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); 119 + function waitForEditorReady(editor) { 120 + return new Promise((resolve, reject) => { 121 + if (editor.status === 'ready') { 122 + resolve(editor); 123 + } else { 124 + editor.once('instanceReady', (event) => { 125 + resolve(event.editor); 126 + }); 127 + } 112 112 }); 113 - } );129 + } 114 114 }); 115 115 });
- XWiki.StyleSheetExtension[0]
-
- Code
-
... ... @@ -1,6 +1,6 @@ 1 1 .xwiki-mention { 2 2 background-color: $services.mentions.mentionsColor; 3 - border-radius: 8px;3 + border-radius: 10px; 4 4 padding: 2px 5px 2px 5px; 5 5 } 6 6
- XWiki.WikiMacroClass[0]
-
- Makro-Code
-
... ... @@ -11,8 +11,8 @@ 11 11 #end 12 12 #set ($link = $xwiki.getURL($reference.reference, 'view')) 13 13 {{html}} 14 -<a id="$escapetool.xml($anchor)" class="$stringtool.join($cssClasses, ' ')" data-reference="$escapetool.xml($services.model.serialize($reference.reference, 'default'))" href="$escapetool.xml($link)"> 15 - $escapetool.xml($content) 14 +<a id="$escapetool.xml($anchor)" class="$stringtool.join($cssClasses, ' ')" data-reference="$escapetool.xml($services.model.serialize($reference.reference, 'default'))" href="$escapetool.xml($link)">## 15 + $escapetool.xml($content)## Do not remove this comment as it ensures that the spacing after mention is not broken. 16 16 </a> 17 17 {{/html}} 18 18 {{/velocity}}