How to write Macro code for the edit mode?
Version 1.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
#if ($xcontext.action == 'get' || $xcontext.action == 'edit' || $request.outputSyntax == 'annotatedxhtml') ... do something specific here ... #end
- When writing a Java macro
public class MyMacro extends AbstractMacro<MyMacroParameters> { ... public List<Block> execute(MyMacroParameters parameters, String content, MacroTransformationContext context) { ... if (Syntax.ANNOTATED_XHTML.getId().equals(context.getTransformationContext().getTargetSyntax())) { ... do something specific here ... } ... } }