Macro Parameters go a long way when it comes to macro configuration, but there are cases when a macro add-on needs more control over the UI.
Defining a Macro Editor allows you to implement a custom UI for the macro, by specifying a URL to a page in your add-on which will be shown in the dialog iFrame.
In order to persist custom data in your macro editor, use the Javascript Confluence API and the Dialog API. For example:
AP.require(["confluence", "dialog"], function (confluence, dialog) { function onSubmit() { var macroParams = { myParameter: value }; confluence.saveMacro(macroParams); confluence.closeMacroEditor(); return true; }
dialog.getButton("submit").bind(onSubmit); });
In order to retrieve the custom data again when the editor is opened, use confluence.getMacroData
(see
Confluence API):
AP.require("confluence", function (confluence) { var macroData = confluence.getMacroData(function(macroParams) { doSomethingWith(macroParams.myParameter); }); });
Example
1 2 3 4 5 6 7 8 9 10 11 12
{
"editor": {
"url": "/map-editor",
"editTitle": {
"value": "Edit Map"
},
"insertTitle": {
"value": "Insert Map"
}
}
}
url
Type | |
Format | uri-template |
Required | Yes |
Description | The URL to the macro configuration page in the add-on. |
cacheable
Type | |
Defaults to | false |
Description | Returns whether the URL should be cacheable. Cacheable URLs are taken directly from the add-on descriptor, and lack all additional query parameters:
|
editTitle
Type | |
Description | An optional title that will be shown in the edit dialog header for an existing macro. Represents a string that can be resolved via a localization properties file. You can use the same Example1 2 3 4
|
value |
| ||||||||
i18n |
|
height
Type | |
Max length | 10 |
Description | The preferred height of the edit dialog, e.g. |
insertTitle
Type | |
Description | An optional title that will be shown in the edit dialog header for a new macro. Represents a string that can be resolved via a localization properties file. You can use the same Example1 2 3 4
|
value |
| ||||||||
i18n |
|
width
Type | |
Max length | 10 |
Description | The preferred width of the edit dialog, e.g. |
Rate this page: