Confluence Insert Link dialog extension

sm shamim August 22, 2012

We have created an extension of the 'Insert Link' dialog. It shows a list of videos from a video site. When a user select a video and click insert, the video url is inserter onto the editor. Is it possible to change this behaviour so that the inserted link is wrapped with an iframe embedding object? So that the video the url points to gets embedded.

1 answer

1 accepted

0 votes
Answer accepted
sm shamim September 4, 2012

What the 'Insert Link' dialog does is that it creates a anchor node with the given link and insert this node to the linkBrowser.

We wrote the following fragment of code inside the preSubmit handler of our 'Insert Link' extension.

preSubmit: function () {
      	var widgetMacroText = "<p><img class=\"editor-inline-macro\" src=\"/confluence/plugins/servlet/confluence/placeholder/macro?definition=e3dpZGdldDp1cmw9aHR0cHM6Ly9zZW5kdmlldy50by93LzM2MTYwYmZiOH0&locale=en_GB&version=2\" data-macro-name=\"widget\" data-macro-parameters=\"url="+url+"\""+" ></p>";
            	tinymce.confluence.NodeUtils.replaceSelection(widgetMacroText);
            },

The above code made sure that our video url got connected with the Widget Connector extension we created.

sm shamim October 9, 2012

The above code was changed to

var node = "<p><img class=\"editor-inline-macro\" src=\"/download/resources/com.dreambroker.confluence.plugins.dreambroker-confluence-plugin:image-resource/macro.png\" data-macro-name=\"widget\" data-macro-parameters=\"url="+url+"\""+" ></p>";
var ed = tinymce.activeEditor;	
var node = AJS.$(newNode).clone(true,false)[0];
ed.execCommand('mceInsertContent', false, node.outerHTML);

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events