There are 2 comments.
 
 
XWiki Platform / cid:jira-generated-image-avatar-1bfdf207-72a2-4761-8039-4dd935f72e6e XWIKI-22738 Closed

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

 
View issue   ·   Add comment
 

2 comments

 
cid:jira-generated-image-avatar-015aa2e5-7738-4b3f-bac7-69cd2cabb80f Farcasi Alexandru-Vicentiu on 11/Aug/25 08:43
 

Anca Luca

Hello! A bit late, but if you still need a way to achieve the same thing and don’t want to wait until the next LTS, you can use the code below to detect when a macro is in edit mode or not
```

@Inject
private ScriptContextManager scriptContextManager;

private boolean inEditModeFallback()

{ String syntax = (String) scriptContextManager.getScriptContext().getAttribute("syntaxType"); return (syntax != null) && (syntax.equals("annotatedhtml") || syntax.equals("annotatedxhtml")); }

```

 
cid:jira-generated-image-avatar-015aa2e5-7738-4b3f-bac7-69cd2cabb80f Farcasi Alexandru-Vicentiu on 11/Aug/25 08:43
 
[~lucaa]

Hello! A bit late, but if you still need a way to achieve the same thing and don’t want to wait until the next LTS, you can use the code below to detect when a macro is in edit mode or not
```

{code:java}
   
    @Inject
    private ScriptContextManager scriptContextManager;

    private boolean inEditModeFallback()
    {
        String syntax = (String) scriptContextManager.getScriptContext().getAttribute("syntaxType");
        return (syntax != null) && (syntax.equals("annotatedhtml") || syntax.equals("annotatedxhtml"));
    }
{code}

```