Customizing the Sitecore Rich Text Editor

You have several options when customizing the Sitecore Rich Text Editor. It’s simple to setup custom sets of buttons and assign to different templates. If you are unsure on doing this I’d suggest googling ‘sitecore custom rich text editor’. This post details how to use the ‘Html Editor Configuration Type’ items.

Within the application there are various global settings which configure things like default tags to use for line breaks, which profile to use as default and a few more:

The problem we ran into was that for certain rich-text-editors we wanted the line breaks to be br tags, elsewhere p tags. This ruled out the setting above.

One hidden feature which is very useful is the ability to setup different configurations for each rte. If you look in the folder in core ‘/sitecore/system/Settings/Html Editor Profiles/Rich Text Default’ you will see an item of type ‘/sitecore/templates/System/Html Editor Profiles/Html Editor Configuration Type’. Here you can define a type, the default mapped to ‘Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration,Sitecore.Client’

If you need to setup specific RTE’s to use br tags instead of p tags:

  • Setup your custom RTE profile in core
  • Create an item of type ‘/sitecore/templates/System/Html Editor Profiles/Html Editor Configuration Type’ called ‘Configuration Type’
  • Create a new class which inherits from ‘Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration’
  • Update the ‘Configuration Type’ item to reference your new class
  • Override the methods you need – I found simply overriding SetupEditor was enough (see below).

An example of the code:

Leave a Reply

Your email address will not be published. Required fields are marked *