Änderungen von Dokument MentionsMacro

Zuletzt geändert von xwikiadmin am 2024/06/24 14:17

Von Version 7.1
bearbeitet von xwikiadmin
am 2023/10/26 09:31
Änderungskommentar: Install extension [org.xwiki.platform:xwiki-platform-mentions-ui/15.8]
Auf Version 4.1
bearbeitet von xwikiadmin
am 2022/08/11 16:40
Änderungskommentar: Install extension [org.xwiki.platform:xwiki-platform-mentions-ui/14.6]

Zusammenfassung

Details

XWiki.JavaScriptExtension[0]
Code
... ... @@ -97,35 +97,19 @@
97 97   };
98 98   }
99 99  
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 - });
100 + function updateConfig(editor) {
101 + editor.config.mentions = editor.config.mentions || [];
102 + editor.config.mentions.push(getUserMentionsConfig(editor));
117 117   }
118 118  
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 - }
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);
128 128   });
129 - }
113 + });
130 130   });
131 131  });
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)## Do not remove this comment as it ensures that the spacing after mention is not broken.
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)
16 16  </a>
17 17  {{/html}}
18 18  {{/velocity}}