I need to trigger the macro editor to open when a macro is inserted in a page. Is it possible to programatically open the editor.
I can open a dialog when the macro is added, but the problem is that I can’t call AP.confluence.saveMacroData(x,y) unless I am in the editor.
It looks like other addons; e.g. gliffy and draw.io manage to achieve this, but I am completely stumped.
window.onload = () => {
AP.context.getContext((ctxt) => {
var isPreviewMode = ctxt.confluence.macro.outputType == 'preview';
if (isPreviewMode) {
AP.confluence.getMacroData((data) => {
if (!data["UNIQUE_ID"]) {
console.log(`we're in preview mode and HAVE NOT been edited`);
// HELP ME - I WANT TO OPEN THE EDITOR SO I CAN CREATE AN ID
}
else {
console.log(`we're in preview mode and HAVE been edited before so have an ID`, data["ws-diagram-id"]);
displayPreview = true;
}
});
}
});
}
Hi @GeoffBullen ,
I suspect the trick is to declare a general page and open it in a dialog. I created a rather ugly, but minimal demo of this which you can view at https://glitch.com/edit/#!/dx-full-page-macro-editor-app?path=connect.json%3A1%3A0 and install locally with https://dx-full-page-macro-editor-app.glitch.me/connect.json.
AP.dialog.create({
key: 'fullpage-editor',
width: '1000%',
height: '100%',
chrom: true
});
Regards,
Dugald
1 Like
Thanks a lot @dmorrow,
I still have the same issue that I can’t save macro data outside of the editor. I modified your example a little to illustrate the problem:
What I continue to see is in your example that data I set in edit
mode is persisted and that set in full-screen-edit
is not (i.e. from the general page).
Hi @GeoffBullen ,
I’m worried my first response might be taking us into anti-pattern territory so I’ve reached out to the Confluence Ecosystem team for their advice.
Regards,
Dugald
Ah @dmorrow
This helped me
If you add a mandatory parameter - the editor opens and I can call saveMacro
Thanks for your help and very quick responses…
1 Like
Hi @GeoffBullen
Thanks for the solution. I wasn’t aware that specifying a mandatory parameter results in the editor opening by default. I don’t see this documented so I’ve followed up by creating CONFCLOUD-72009 to address this and other gaps in our documentation.
Regards,
Dugald
Yes, some more doco around all the intricacies of saving and retrieving macro data and body would certainly have been a time saver.
It takes a lot of trial and error for a confluence addon noob 
Thanks again @dmorrow
1 Like