Update the name of custom macro in confluence

Hi Team ,

I’m trying to change the name of ‘helloworld’ macro . I’ve changed name field for this xml tag from "<xhtml-macro name=“helloworld” to "<xhtml-macro name=“ABCmacro” in atlassian-plugin.xml file. On confluence , I’m able to search macro using ABCmacro name but on selecting it , it is giving error saying "unknown macro: ‘abcmacro’ ".

I’ve customized macro editor window using below code snippet. So i have tried by changing the name in below script as well from helloworld to ‘abcmacro’.

AJS.MacroBrowser.setMacroJsOverride(“helloworld”, {
fields: {
string: {

Could you please help to tell me is there any other file also in which i need to update the name ?

Thanks

The name attribute of the <xhtml-macro /> is case-sensitive and only supports lowercase. If you change the value of <xhtml-macro name=“ABCmacro in atlassian-plugin.xml to <xhtml-macro name=“abcmacro it will work.

If you want the label of the macro to have uppercase or a more descriptive value, you can do this using a properties file. Add the following to your atlassian-plugin.xml:

<resource key="i18n" name="i18n" type="i18n" location="i18n"/>

Now also add a i18n.properties file in the root of your resources folder with the following content:

<APPKEY>.<MACRONAME>.label=<LABEL>
<APPKEY>.<MACRONAME>.desc=<DESCRIPTION>

If you have parameters defined in your <xhtml-maco />, you can also set their labels and descriptions:

<APPKEY>.<MACRONAME>.param.<PARAMNAME>.label=<LABEL>
<APPKEY>.<MACRONAME>.param.<PARAMNAME>.desc=<DESCRIPTION>
1 Like

@remie
Thanks for the answer.
What is the value of Appkey ? Do you mean appkey is the value of key tag in below xhtml macro config i.e. helloworld-macro?

<xhtml-macro name=“Abcmacro” class=“com.atlassian.tutorial.macro.helloworld” key=‘helloworld-macro’

Thanks

That is the value that is in the key attribute of the root element of the atlassian-plugin.xml:

<atlassian-plugin key="<APPKEY>" />

Hi @remie

I tried to configure the name of macro but while installing the macro on confluence I’m getting error as “Invalid anti-XSRF token provided. The valid token should be retrieved transparently, but you may want to perform a hard refresh in your browser and try again before creating a support issue.” .

atlassian.xml file data :

<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version=“2”
<xhtml-macro name=“abcmacro” class=“com.atlassian.tutorial.macro.helloworld” key=‘helloworld-macro’

I added the properties as below.
myconfluenceMacro.properties::
com.atlassian.tutorial.macro.helloworld-macro.abcmacro.label=Add File link

I have also attached my project directory structure.

Can anyone help me on this issue ?