Macro parameters: Dynamic parameters to build a custom table

Hello everyone looking for help on this

I’m aware that the macro parameters are defined in the atlassian-plugin.xml, like in the following example
https://developer.atlassian.com/server/framework/atlassian-sdk/create-a-confluence-hello-world-macro/#create-a-macro-element-in-confluence

However this is very limited and provides little to no flexibility.
On our scenario we need to build a table from the macro, so we need to add columns and headers, so if we need N columns, we can’t do it since the parameters are hardcoded in the atlassian-plugin.xml.

For example we can’t do add parameter Column1, Column2, Column3, and so on. For this reason we would need dynamic parameters

Really appreciate the help, thanks in advance

Update:
This is a quick mockup showing an example, a button that would add columns and fields, so we could have N columns and N fields, is this possible in a macro?

You can initialize your own macro editor instead using javascript.

AJS.MacroBrowser.setMacroJsOverride('macroName', {
    "opener": function () {
        
    }
})

The lifecycle of a custom UI element can be managed here. You may want to leverage Dialog2 component to make this easier: Dialog2 - AUI Documentation

A good community example is here: Custom macro dialog in confluence in editor context | Override MacroBrowser - #3 by aragot

1 Like

Hello @steve.behnke thanks for the reply!

I have added the JS code in the default js file under resources/js/file.js

(function ($) {
    console.log("Init")
    AJS.toInit(function() {
        console.log("Init-AJS")
        AJS.MacroBrowser.setMacroJsOverride('macro-name', {
            console.log("Override")
            "opener": function () {
                console.log("Debug")
            }
        });
    });

})(AJS.$ || jQuery);

Where

macro-name

Came from my name= property from atlassian-plugin.xml

<xhtml-macro name="macro-name" class="macro.macroname" key='macro-name-macro'>

But nothing really happens, the console.log never show up on my console

What am i doing wrong?