I'm in the process of implementing a custom tab, group and button for the SharePoint 2010 ribbon. The button is to behave almost identically to the standard Editing Tools>Insert>Link button, except instead of allowing freetext entry of a link, the dialog will launch an ActiveX DMS browser allowing a document to be selected, and a link generated.

I've attempted to pull apart the implementation of the standard Link button but I've been unable to satisfactorily determine how it works. I'd have expected there to be a CommandUIHandler for the standard button in CMDUI.XML, with possibly an EnabledScript (so I could see how it's enabled/disabled and copy this) and a CommandAction (so I could determine how to correctly launch the RTEDialog.aspx page and have it insert a link). Neither of those are present in CMDUI.XML (as far as I can tell).

With the background information out of the way, I guess my actual question can be broken down into two parts:

  • How can I mimic the standard Insert Link button enabled/disabled states?

  • How can I launch a slightly tweaked version of RteDialog.aspx correctly, so that my generated link is inserted successfully?

  • Hi Omlin Thanks for shareing your knowledge. I am trying to develop AnchorButton in CFINSERT tab, I want to open the dialog window with one text box and submit button, and once they submit it suppose to be insert anchor links (<a name=" + text value + "></a> ) at current cursor. i finished to add the new group in CFINSERT and open the dialog, but don't know how to take the RTE existing cursor and insert the href tag? Can you please help me if you done similar things before please. Thanks Veeru
    – user3492
    Commented May 24, 2011 at 7:17

2 Answers 2


Code for OOTB ribbon button handlers is provided with PageComponents. For RTE, you can find this code in file C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SP.UI.Rte.debug.js

You will need to start your explorations from RTE.RichTextEditor.insertLink function.

About Insert button, best way here will be simply to replace Insert Link button with your own ribbon button. To achieve this, you will need to set Location attribute for your CommandUIDefinition to "Ribbon.EditingTools.CPInsert.Links.Link":

<CommandUIDefinition Location="Ribbon.EditingTools.CPInsert.Links.Link">
    <!-- your Button definition here -->

In your button definition, you should provide your custom js, and call some standard functions from RTE.RichTextEditor object, which will help you to operate with SharePoint Rich Text Editor.

  • Thanks for the pointers to the RTE.RichTextEditor.insertLink function, looks promising in terms of providing enough of an example for me to build a solution. Unfortunately I can't simply replace the existing Insert Link button, it still needs to be present. The button I'm building is the first of several in my own tab.
    – ss81
    Commented May 20, 2011 at 12:13
  • Feel free to ask any futher concrete questions here on SPSE, tweaking the RTE functionality is a very interesting task for me :) Commented May 20, 2011 at 12:27

We use jquery.aop to extend OOTB SharePoint JS functions, it works like a charm. it allows for adding other function calls before or after the regular sharepoint js method calls.

  • Hmm thanks for this, sounds like it could be really useful.
    – ss81
    Commented May 24, 2011 at 13:30
  • An example would be nice. The post is about custom ribbon buttons you just link to jQuery.AOP without any reference. How does it help you? code.google.com/p/jquery-aop
    – Dennis G
    Commented Apr 17, 2012 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.