Question

I am creating a Sitecore module which includes a new button within the Rich Text Editor.

In order to register the command for the button I had to append some code to the RichText Commands.js file.

I had hoped that I could create the installation package in such a way that it would be simple, without any additional manual intervention required.

So I have 2 questions:

  1. Is there any way I can the add the javascript command registration code without amending an existing file?

  2. Is there somewhere in the Sitecore tree I can put the button so it appears for all RTE profiles? - a sort of "global profile".

Was it helpful?

Solution

You can add your own client scripts by adding an entry into the config. Patch the following:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">  
  <sitecore>  
    <clientscripts>  
      <htmleditor>  
        <script src="/sitecore modules/shell/Controls/Rich Text Editor/Custom RichText Commands.js" language="JavaScript"/>  
      </htmleditor>  
    </clientscripts>  
  </sitecore>  
</configuration>

Here is a detailed blog post about it.

There is no setting that I know of so that all profiles display the button. You have to add it to the profiles you wish the button to show on. Either:

  • add it to the default profile
  • make a copy of an existing profile, rename it to Rich Text Default and add/remove whatever you want
  • Change <setting name="HtmlEditor.DefaultProfile" value="/sitecore/system/Settings/Html Editor Profiles/Rich Text Default"/> in web.config to your custom profile

If you set the DataSource of a rich text field to a different one then obviously the default settings will not take effect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top