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

Macro is inserted directly

Newbie July 29, 2015

Hello,

I have an not wanted behavior. If I use the Macro-Shortcut expression ('{' sign) and select my macro via enter or a mouse click. My macro is directly inserted in my page. But what I want is, that my macro dialog is open first, before my macro is inserted.

Here is an example of my JavaScript file.

AJS.bind("init.rte", function() {
...
});

All I needed that my macro is inserted directly is this "simplest" callback function.

I don't even need to call this method

var macroRenderRequest = {
	contentId: Confluence.Editor.getContentId(),
	macro: {
		name: "myMacro",
		params: currentParams,
		defaultParameterValue: "",
		body : ""
	}
};
tinymce.confluence.MacroUtils.insertMacro(macroRenderRequest);

How can I avoid this situation?


Greetings

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Newbie August 6, 2015

I have solve my issue. After debugging the JS-Code.

Internally this method would be called:

var dropdownSelectionMade = function(autoCompleteControl, options) {
        var macroMetadata = options.presetMacroMetadata;
        autoCompleteControl.replaceWithSelectedSearchText();
        if (!macroMetadata) {
            tinymce.confluence.macrobrowser.macroBrowserToolbarButtonClicked(options);
        } else {
            // only open the macro browser if there are required parameters
            if (AJS.MacroBrowser.hasRequiredParameters(macroMetadata) || !!macroMetadata.alwaysShowConfig) {
                tinymce.confluence.macrobrowser.macroBrowserToolbarButtonClicked(options);
            } else {
                AJS.Rte.BookmarkManager.storeBookmark();
                tinymce.confluence.MacroUtils.insertMacro({
                    contentId: AJS.Meta.get('content-id') || "0",
                    macro: {
                        name: macroMetadata.macroName,
                        body : ""
                    }
                });
            }
        }
    };

There is a commentar, which is very useful.

The macro will be inserted directly if there are no required parameter in the atlassian-plugin.xml defined.

So, you have to do this in your xhtml-macro parameter node.

0 votes
Anton Kronseder _smartics_ November 29, 2015

Hi,

thanks for your question and the answer. Helped me alot.

TAGS
AUG Leaders

Atlassian Community Events