Strange macro behavior

Hi all, I’m noticing a strange behavior when using my macro on a Confluence Server.

The macro browser of my macro is supposed to have a textarea that allows multiple lines of input, as such:

It behaves correctly only when there is another instance of the same macro already in the page.

However, whenever I insert the macro into a Confluence page where there is no instance of this macro, the textarea becomes an input , as such:

Macro browser override:

(function($) {
    var MermaidMacro = function(){
    var originalCode;

    MermaidMacro.prototype.fields = {
        "string" : function(param, options){
            if( == "Code"){

                var paramDiv = AJS.$(Confluence.Templates.MacroBrowser.macroParameter());
                var input = AJS.$("macro-param-div-Code", paramDiv);

                var textArea = document.createElement("textarea");
       = "none";
       = "scroll";
       = "nowrap";
                textArea.setAttribute("rows", "12");
                textArea.setAttribute("cols", "29");
                textArea.setAttribute("id", "macro-param-Code");
                textArea.setAttribute("class", "macro-param-input");

                var label = document.createElement("label");
                label.innerHTML = "Code";
                label.setAttribute("for", "macro-param-Code");


                return AJS.MacroBrowser.Field(paramDiv, input, options);

    MermaidMacro.prototype.beforeParamsSet = function(selectedParams, macroSelected){
        originalCode = selectedParams.code;
        console.log("Orignal Code : " + originalCode);
        return selectedParams;

    MermaidMacro.prototype.beforeParamsRetrieved = function(params){
        params.code = $("#macro-param-Code").val();
        console.log("params.code : " + params.code);
        return params;

        AJS.bind("init.rte", function(){
            AJS.MacroBrowser.setMacroJsOverride('mermaid-macro', new MermaidMacro());

What’s going on?

Solved: added <context>atl.general</context> and <context>atl.admin</context> to my atlassian-plugin.xml