cpitis
October 29, 2017, 10:19am
1
I am looking to develop a customized button in the macro panel, where to insert more than just a label and icon.
Is it any way of mentioning the html content of the button in atlassian-plugin.xml?
<xhtml-macro name="myMacro" class="com.learning.MyMacro" key="my-macro">
<category name="formatting"/>
<property-panel>
<button id="myMacro-custom-button"/>
</property-panel>
</xhtml-macro>
david
October 30, 2017, 9:31am
2
Take a look at this atlassian-plugin.xml …
…with the following xhtml-macro
:
<xhtml-macro name="box" class="com.example.plugin.confluence.BoxMacro"
key="box-xhtml"
icon="/download/resources/com.example.plugin.confluence.macromagic/images/64x64_package.png">
...
<!-- Additional option buttons in editor between 'edit' and 'remove' -->
<property-panel>
<spacer />
<button id="Small" label="S" />
<button id="Medium" label="M" />
<button id="Large" label="L" />
<spacer />
</property-panel>
</xhtml-macro>
Also this web-resource
which adds the functionality, using JavaScript:
<web-resource name="Resources - handle macros with JS"
key="macroeditor-resources">
<description>Macro related JS resources</description>
<context>editor</context>
<!-- JS to set properties S,M,L on box macro -->
<resource type="download" name="editor-box.js" location="js/editor-box.js" />
...
</web-resource>
And the corresponding JavaScript .
Set this all up, then you can use JavaScript to override the label on the button(s). If you need to reference the page content, try the relevant REST API.