I created a test for this and can get the macro data and macro body saved, but I do note one issue. My scenario is as follows:
Visit a page with the dynamic content macro in it.
Edit the page.
Open the macro edit dialog.
Make changes and click save.
View the previewed version of the macro.
Save the page.
View the updated macro.
Step 5 observations:
New editor behaviour: At step 5, my macro does not reflect the updated data (neither macro data nor macro body). The macro view looks like it is refreshed, but it displays the old macro data. I’m using AP.confluence.getMacroData and AP.confluence.getMacroBody to retrieve the data in the macro view.
Old editor behaviour: At step 5, the macro reflects the updated data.
Step 7 observations: The macro reflects the updated data in both new and old editors.
My code for submitting the macro data is as follows:
AP.dialog.getButton("submit").bind(this.onDialogSubmit);
onDialogSubmit = (event) => {
const dateTimeText = new Date().toString();
const macroParams = {
foo: `Bar - ${dateTimeText}`
};
const macroBody = `${dateTimeText}: Macro body`;
AP.confluence.saveMacro(macroParams, macroBody);
// No need to call AP.confluence.closeMacroEditor() if we return true.
return true;
}
How and when are you retrieving the macro data and concluding it’s not being updated?
After saving the macro and closing the dialog, I can see in the editor that the macro body stays the same (I’m using a rich-text body type).
Viewing the page in preview mode, I retrieve the macro data and body using AP.confluence.getMacroData and AP.confluence.getMacroBody. Using getMacroData returns the updated macro data, but getMacroBody returns the old macro body.
Saving/publishing the page also does not give me an updated macro body.
I copied your example to setup a simple test and can confirm that I am still having the same issue. Interestingly, using return true; does not work for me (wonder if that’s because we are using different versions of the JS API?). This is because I had AP.dialog.disableCloseOnSubmit();
For reference, below is how I setup a simple test:
DEPRECATED API - AP.dialog.getDialogButton().bind() has been deprecated since ACJS 5.0 and will be removed in a future release. Use AP.events.on("dialog.message", callback) instead.
Could there be a version mismatch between my setup and yours that’s causing the saveMacro to not behave as expected for me?
I had declared my macro body type as plain-text. When I change it to rich-text, I see the same behaviour as you - namely that the body appears empty, but the console shows it is<p />. Do you see any change of behaviour if you change your macro type to plain-text?
I’ve changed my body type to plain-text and tested it.
I am seeing the same behaviour as you did including this:
So it looks like the problem is saveMacro does not update the body for rich-text body type. Is that the expected behaviour?
Changing the body type to plain-text also stops the macro body from being editable manually from the editor. What is the difference between plain-text and rich-text?
Is there any progress on this blocker? Basically what happens is - you cannot save macro body from custom macro editor. It simply gets removed when calling to