How a Confluence customize macro image placeholder source generated?

AustinS January 7, 2018

Here is a customized macro image placeholder:

<p><img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e2NvbnRlbnRieWxhYmVsOmNxbD1sYWJlbCA9ICJkYWdkYS1ib2FyZCJ9&amp;locale=en_GB&amp;version=2" data-macro-name="contentbylabel" data-macro-parameters="ppr=rcs &quot;dagda-board&quot;" data-macro-schema-version="3"><br></p>

The "definition=" part of "src" seems generated automatically. And for each macro should has its unique "definition" value.   Just curious that how it created by what kind of rules? Any document mentioned these knowledge?

And any possible reason that may cause macro image placeholder

"src"  SAME?

 

Thanks in advance.

1 answer

1 vote
Minh Tran
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 8, 2018

Hi @AustinS,

I assume you are able to access to Confluence source code. The above image is generated via this servlet com.atlassian.confluence.tinymceplugin.placeholder.MacroPlaceholderServlet

You can check it out the logic and the rule from inside the doGet method of this class

That is true as you guessed. The "definition" part of the url contains the macro definition information

That you can refer to the class com.atlassian.confluence.xhtml.api.MacroDefinition

And the logic to render that url is placed in this class com.atlassian.confluence.content.render.xhtml.editor.macro.CustomImageEditorMacroMarshaller, see marshal method for further information

I hope this helps

Cheers,

Minh Tran

AustinS January 8, 2018

Thanks for these helpful information, Minh. 

One more question related to this, I'm developing a user macro that will be used multiple time on one page, and I found "Edit" button which under <div class="panel-buttons" > and belongs to <a href="#" class="aui-button macro-placeholder-property-panel-edit-button first"> element, is SHARED by any user macro of one Confluence page. That means for these user macros on same page, "Edit" feature don't know / can't identify which macro should be edited.  

Is there a workaround can be used to edit user macros on the same page and can get properties (parameters) of each macro correctly when re-open or re-edit it? Or any API can I use in user macro? How do I do it?  

I know in non user macro, which has preview, "Edit" button can identify which one is which one on a page, and can retrieve macro properties correctly.  I used "

AJS.MacroBrowser.setMacroJsOverride

" to override the "opener" to open my own custom "MacroBrowser".  But I'm not sure why "Edit" button doesn't work to retrieve the macro's parameters when we re-open and edit it.

Thank you.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events