There are 2 comments.
 
 
XWiki Platform / cid:jira-generated-image-avatar-733dcbf2-12d7-4397-b452-643b345f598e XWIKI-21973 Open

User Mention inside macro content is removed when inserted in empty lines

 
View issue   ยท   Add comment
 

2 comments

 
cid:jira-generated-image-avatar-9042c121-8492-48f5-8777-d4e32499c553 Manuel Leduc on 12/Dec/24 15:49
 

The issue is caused by a bad conversion from html to html when CKEditor.HTMLConverter is called after the mention macro is inserted.

 

http://localhost:8080/xwiki/bin/get/Main/?sheet=CKEditor.HTMLConverter&outputSyntax=plain&language=&formToken=NhdUQBhyMLkr9qOzoclazg 
{
	"netfluxChannel": "f8969d8e94161214b33979e65807a329600ada2f4d3e479f",
	"sourceSyntax": "xwiki/2.1",
	"wysiwygRestricted": "false",
	"stripHTMLEnvelope": "true",
	"fromHTML": "true",
	"toHTML": "true",
	"text": "<!--startmacro:info|-|--><div+data-xwiki-non-generated-content=\"java.util.List&lt;org.xwiki.rendering.block.Block&gt;\"+class=\"xwiki-metadata-container\"+data-lt-tmp-id=\"lt-515618\"+spellcheck=\"false\"+data-gramm=\"false\"><p><!--startmacro:mention|-|reference=\"XWiki.Admin\"+style=\"FULL_NAME\"+anchor=\"XWiki-Admin-7qcxlk\"--><!--stopmacro--><span+id=\"xwiki-macro-inline-enforcer\">&nbsp;</span></p></div><!--stopmacro-->"
}

returns

<!--startmacro:info|-||-|\{\{mention reference="XWiki.Admin" style="FULL_NAME" anchor="XWiki-Admin-7qcxlk"/}}(% id="xwiki-macro-inline-enforcer" %) --><div class="box infomessage"><span class="icon-block"><span class="fa fa-info-circle" aria-hidden="true"></span></span><span class="sr-only">Information</span><div data-xwiki-non-generated-content="java.util.List&lt;org.xwiki.rendering.block.Block&gt;" class="xwiki-metadata-container"><p><span id="xwiki-macro-inline-enforcer"><!--startmacro:mention|-|reference="XWiki.Admin" style="FULL_NAME" anchor="XWiki-Admin-7qcxlk"--><!--startmacro:velocity|-||-|#set ($reference = $wikimacro.parameters.reference)
#set ($style = $wikimacro.parameters.style)
#set ($type = "$!wikimacro.parameters.type")
#set ($content = $services.mentions.format($reference.reference, $style, $type))
#set ($anchor = $wikimacro.parameters.anchor)
#set ($isCurrentUser = $xcontext.userReference == $reference.reference && ($type == '' || $type  == 'user'))
#set ($cssClasses = ['xwiki-mention', 'user'])
#if ($isCurrentUser)
  #set ($discard = $cssClasses.add('self'))
#end
#set ($link = $xwiki.getURL($reference.reference, 'view'))
\{\{html}}
<\a id="$escapetool.xml($anchor)" class="$stringtool.join($cssClasses, ' ')" data-reference="$escapetool.xml($services.model.serialize($reference.reference, 'default'))" href="$escapetool.xml($link)">##
  $escapetool.xml($content)## Do not remove this comment as it ensures that the spacing after mention is not broken.
<\/a>
\{\{/html}}--><!--startmacro:html|-||-|<\a id="XWiki-Admin-7qcxlk" class="xwiki-mention user self" data-reference="xwiki:XWiki.Admin" href="/xwiki/bin/view/XWiki/Admin">@Administrator<\/a>--><a class="xwiki-mention user self" data-reference="xwiki:XWiki.Admin" href="/xwiki/bin/view/XWiki/Admin" id="XWiki-Admin-7qcxlk">@Administrator</a><!--stopmacro--><!--stopmacro--><!--stopmacro-->&nbsp;</span></p></div></div><!--stopmacro-->

where a xwiki-macro-inline-enforcer span wraps the mention macro, which is then removed by https://github.com/xwiki/xwiki-platform/blob/909da80c5e50a8de85d9b02881a1b9e73c4fdd15/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/plugin.js#L771
Making the wrapped mention macro disapear.

 
cid:jira-generated-image-avatar-9042c121-8492-48f5-8777-d4e32499c553 Manuel Leduc on 12/Dec/24 15:49
 
The issue is caused by a bad conversion from html to html when {{CKEditor.HTMLConverter}} is called after the mention macro is inserted.

 
{noformat}
http://localhost:8080/xwiki/bin/get/Main/?sheet=CKEditor.HTMLConverter&outputSyntax=plain&language=&formToken=NhdUQBhyMLkr9qOzoclazg {noformat}

{noformat}
{
"netfluxChannel": "f8969d8e94161214b33979e65807a329600ada2f4d3e479f",
"sourceSyntax": "xwiki/2.1",
"wysiwygRestricted": "false",
"stripHTMLEnvelope": "true",
"fromHTML": "true",
"toHTML": "true",
"text": "<!--startmacro:info|-|--><div+data-xwiki-non-generated-content=\"java.util.List&lt;org.xwiki.rendering.block.Block&gt;\"+class=\"xwiki-metadata-container\"+data-lt-tmp-id=\"lt-515618\"+spellcheck=\"false\"+data-gramm=\"false\"><p><!--startmacro:mention|-|reference=\"XWiki.Admin\"+style=\"FULL_NAME\"+anchor=\"XWiki-Admin-7qcxlk\"--><!--stopmacro--><span+id=\"xwiki-macro-inline-enforcer\">&nbsp;</span></p></div><!--stopmacro-->"
}
{noformat}

returns

{noformat}
<!--startmacro:info|-||-|\{\{mention reference="XWiki.Admin" style="FULL_NAME" anchor="XWiki-Admin-7qcxlk"/}}(% id="xwiki-macro-inline-enforcer" %) --><div class="box infomessage"><span class="icon-block"><span class="fa fa-info-circle" aria-hidden="true"></span></span><span class="sr-only">Information</span><div data-xwiki-non-generated-content="java.util.List&lt;org.xwiki.rendering.block.Block&gt;" class="xwiki-metadata-container"><p><span id="xwiki-macro-inline-enforcer"><!--startmacro:mention|-|reference="XWiki.Admin" style="FULL_NAME" anchor="XWiki-Admin-7qcxlk"--><!--startmacro:velocity|-||-|#set ($reference = $wikimacro.parameters.reference)
#set ($style = $wikimacro.parameters.style)
#set ($type = "$!wikimacro.parameters.type")
#set ($content = $services.mentions.format($reference.reference, $style, $type))
#set ($anchor = $wikimacro.parameters.anchor)
#set ($isCurrentUser = $xcontext.userReference == $reference.reference && ($type == '' || $type  == 'user'))
#set ($cssClasses = ['xwiki-mention', 'user'])
#if ($isCurrentUser)
  #set ($discard = $cssClasses.add('self'))
#end
#set ($link = $xwiki.getURL($reference.reference, 'view'))
\{\{html}}
<\a id="$escapetool.xml($anchor)" class="$stringtool.join($cssClasses, ' ')" data-reference="$escapetool.xml($services.model.serialize($reference.reference, 'default'))" href="$escapetool.xml($link)">##
  $escapetool.xml($content)## Do not remove this comment as it ensures that the spacing after mention is not broken.
<\/a>
\{\{/html}}--><!--startmacro:html|-||-|<\a id="XWiki-Admin-7qcxlk" class="xwiki-mention user self" data-reference="xwiki:XWiki.Admin" href="/xwiki/bin/view/XWiki/Admin">@Administrator<\/a>--><a class="xwiki-mention user self" data-reference="xwiki:XWiki.Admin" href="/xwiki/bin/view/XWiki/Admin" id="XWiki-Admin-7qcxlk">@Administrator</a><!--stopmacro--><!--stopmacro--><!--stopmacro-->&nbsp;</span></p></div></div><!--stopmacro-->
{noformat}

where a {{xwiki-macro-inline-enforcer}} span wraps the mention macro, which is then removed by https://github.com/xwiki/xwiki-platform/blob/909da80c5e50a8de85d9b02881a1b9e73c4fdd15/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-macro/plugin.js#L771
Making the wrapped mention macro disapear.


Matrix conversation about the issue: https://matrix.to/#/!ikPtGZaGWtyblizzlR:matrix.xwiki.com/$17340145961017epfnO:matrix.xwiki.com?via=matrix.org&via=matrix.xwiki.com&via=mtrx.nz