How to write Macro code for the edit mode?
Version 2.1 by Vincent Massol on 2024/10/29
If you're writing a Macro, and you need to do something specific when the macro is rendered in edit mode, write the following:
- When writing a wiki macro using Velocity#set ($targetSyntaxId = $wikimacro.context.transformationContext.targetSyntax.getId())
#if ($targetSyntaxId == 'annotatedhtml' || $targetSyntaxId == 'annotatedxhtml')
... do something specific here ...
#end - When writing a Java macropublic class MyMacro extends AbstractMacro<MyMacroParameters>
{
...
public List<Block> execute(MyMacroParameters parameters, String content, MacroTransformationContext context)
{
...
if (Syntax.ANNOTATED_XHTML.getId().equals(context.getTransformationContext().getTargetSyntax().getId())) {
... do something specific here ...
}
...
}
}