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