Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Create custom macro dialog in confluence

EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 1, 2013

I followed this doc, https://developer.atlassian.com/display/CONFDEV/Adding+an+Option+to+the+Editor+Insert+Menu to add my plugin to the "insert" menu. UNfortunately it is coming up with the same error as https://answers.atlassian.com/questions/27554/no-macro-metadata-when-editing-a-macro-in-editor (and I tried all resolutions there)

But more importantly I actually want to completely customize the content that shows there, and then link to a specific xwork action of mine, rather then just showing some plugin parameters.

What I really want is something like Gliffy's insert macro dialog.

It seems that I could use AJS to bind to the rich editor's init mode, and that's where the maze of JS in the confluence code loses me.

Anyone have experience with a custom dialog for macro?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Matthew Erickson
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2013

Hi Eddie,

I think this presentation has the information you are looking for: http://www.slideshare.net/GoAtlassian/pimp-my-confluence-plugin-atlascamp-2011. Specifically you probably want to use AJS.MacroBrowser.setMacroJsOverride to create your own dialog.

EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2013

Thanks for the link, lots of good stuff there!

Question though, I don't technically have my own macro, but instead and hijacking that menu as a result of the "Add" menu disappearing in Confluence 5.

So it seems the AJS.MacroBrowser.setMacroJsOverride requires my macro name, and not necessary the id of the web-item. (at least it doesn't seem to be triggering for me)

<web-item key="editor-featured-macro-scribbles"
              name="Insert Scribbles"
              section="system.editor.featured.macros.default"
              weight="12">
        <description>Adds a new scribbles to the current page</description>
      	<label key="scribbles.action.add" />
		<link linkId="scribble-macro"/><!-- name of macro to associate with -->
		
</web-item>

OverridingTheMacroBrowser11AJS.MacroBrowser.setMacroJsOverride('scribble-macro',{opener:
	function(macro){
	console.log(">>MacroJsOverride()")
	}
});


EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2013

THanks for the great link. Slide 135 is exactly what I want, but it seems to be misbehaving for me, perhaps just a fluke with my running SDK instance.

<!--  confluence 5  nix's the add menu, use insert instead.. -->
	<!--  https://developer.atlassian.com/display/CONFDEV/Adding+an+Option+to+the+Editor+Insert+Menu -->
	<!--  the link must be present, but contents are ignored. instead use a macro to bind to it -->
    <web-item key="editor-featured-macro-scribbles"
              name="Insert Scribbles"
              section="system.editor.featured.macros.default"
              weight="12">
        <description>Adds a new scribbles to the current page</description>
      	<label key="scribbles.action.add" />
		<link linkId="scribble-macro"/><!-- name of macro to associate with -->
		
    </web-item>

	<xhtml-macro key="scribble-macro"
                 name="scribble-macro"
                 class="com.edwardawebb.confluence.scribbles.ScribbleMacro"
                 >
        <!-- description is used in the macro browser -->
        <description key="scribbles.action.add">Insert Scribbles into the current page</description>
        <category name="visuals"/>

    </xhtml-macro>

function createScribbleMacro(){
	console.log(">>createScribblesMacroDialog");

	var dialog = new AJS.Dialog({
	    width:200, 
	    height:200, 
	    id:"dialog-name", 
	    closeOnOutsideClick: true
	});
	dialog.show();
	return dialog;
}


AJS.MacroBrowser.setMacroJsOverride('scribble-macro',{opener: createScribbleMacro});

EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 6, 2013

Seems my issue was with the macro module, apparently <parameters /> is required if you do not have any parameters, otherwise the macro is invalid and ignored.

After adding that and a clean/run cycle my custom dialog is appearing, Thanks again Matthew for the great resource !

0 votes
Shanth February 10, 2014

Hi All,

If any one knows how to include the "preview" and "parameters" to custom dialog please let me know.

Thanks

0 votes
EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2013

OK, so I found that i can get a handle to the dialog using

AJS.bind("show.dialog", function(e, data) {
  //manipulate dialog here
  }
});

But there is no way to determine if it is the dialog for my macro, or any other macro.

0 votes
EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 4, 2013

Been poking around a few more days with no luck. I am actually unsure now if blueprints are the way to make these dialigs or not. Still invesitgating a javascript route to hijack the dialog and add my own content.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events