There is 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-00818e41-c0c9-4050-b518-d0505f0ee2be XWIKI-22738 Closed

Target syntax is not set on the transformation context when the document content is executed

 
View issue   ·   Add comment
 

1 comment

 
cid:jira-generated-image-avatar-e7f1144e-1d57-436f-beb0-0ed1e3e89fa5 Josué Tille on 19/Nov/25 09:40
 

I use this velocity code to support XWiki <17.0.0.

#macro(isEdit $return)
  #set ($macro.targetSyntax = $wikimacro.context.transformationContext.targetSyntax)
  #if ($macro.targetSyntax != $NULL)
    #set ($macro.targetSyntaxId = $macro.targetSyntax.type.id)
    #set ($isEdit = $macro.targetSyntaxId == 'annotatedhtml' || $macro.targetSyntaxId == 'annotatedxhtml')
  #else
    ## If target syntax ID is null need to fallback with the script context manager
    ## Solve issue https://jira.xwiki.org/browse/XWIKI-22738 (fixed with XWiki >= 17.0.0)
    #set ($macro.scriptContextManager = $services.component.getInstance('org.xwiki.script.ScriptContextManager'))
    #set ($macro.targetSyntaxId = $macro.scriptContextManager.getScriptContext().getAttribute("syntaxType"))
    #set ($isEdit = $macro.targetSyntaxId == 'annotatedhtml' || $macro.targetSyntaxId == 'annotatedxhtml')
  #end
  #set ($return = $NULL)
  #setVariable("$return" $isEdit)
#end