Can I use Javascript to control the UI within my ACE macro?

Hi there,

I have built a static-content-macro (to present UI tabs) using the Atlassian Connect Express framework.

The presentation works, but the UI controls do not (i.e. I cannot activate any of the tabs when I click on them).
I am trying to use Javascript/jQuery (within a element at the bottom of my ‘tabGroup.hbs’ macro template), but that doesn’t seem to work.

I then tried to reduce the complexity of my script right down to something as simple as ‘alert(“Hello!”)’ when the page loads or even in the onclick="*" attribute of each tab.

That didn’t work either - this leads me to believe that Javascript is completely suppressed/unavailable within Confluence Cloud add-ons. Is that correct?

The only reason that I still have hope, that I can get this to work, is that I was able to execute some client-side Javascript in the *.hbs template of my macro-editor. If that works, then surly it should work within the *.hbs template for the macro-display?

Hope someone can help.

Regards,
Paul

JS will not work for static content macros. You would need to use a dynamic content macro instead, but then you are constrained to doing everything within an iframe.

1 Like

Great, thanks Bob - that was very useful!

It feels like I am a step or two closer to the solution I need, now - but not quite over the line.

If it’s not already clear, I am trying to create a nested rich-text macro experience, here.
I know that this has been decommissioned in the latest Confluence editor, but I have been led to believe (from online Atlassian docs) that this is still possible, if I create my own macro editor.

I can’t quite seem to join the dots, though.

I’ve set the ‘bodyType’ attribute, of my outer (‘tab-group’) macro to be ‘rich-text’ (as I need to be able to edit the contents, to create child ‘tabs’).

When I try to do the same for my inner (‘tab’) macro (as in, set the ‘bodyType’ attribute to ‘rich-text’), the macro won’t save at all when I submit my custom macro-editor.

I did get the inner tabs to save, and present well, when I changed the ‘bodyType’ attribute, of my inner (‘tab’) macro to ‘none’. See the attached images for how that renders.
The only remaining problem with this is that I obviously cannot edit the contents of my inner (‘tab’) macro.

Is there any advice you can lend for getting around this problem?

Regards,
Paul

For what it’s worth, the published content looks good - it lays out well.
I just cannot put anything within the tabs.

Unfortunately, nested macros are more or less deprecated (or rather impossible) in the new editor experience. The way to go here would be to provide a sophisticated “macro editor” experience instead and only use a single macro.

Hi Sven,

Yes, I was thinking that would be the right approach. The problem I am facing, though, is how to accept Confluence markup, for the tab content, within the customer macro editor?

Can you help with that?

Regards,
Paul