Filters in RadEditor are small code snippets, which are called in a sequence to process the editor content, when the mode (Design,HTML and Preview) is switched.
Implementing a Custom Filter
There are two steps that you should take to implement a custom filter:
- Create a javascript function/class that implements one or more of these filter methods:
-
getDesignContent - Called when the editor is moving from some other mode to Design mode
-
getHtmlContent - Called when the editor is moving from some other state to HTML mode. Also, it is respected when submitting the content, i.e., filters the submitted content.
-
Register the filter with the editor. The best way to achieve this is to register an OnClientLoad function that instantiates the filter and adds it to the filters manager.
Custom Filter Example
The filter modifies the editor content so that in HTML mode it is presented with capital letters while in Design mode, it is shown in lower-case letters. This is a fairly simplistic and unrealistic scenario that is only used to demonstrate what is necessary to create and "hook" a filter into Telerik RadEditor. In a real life scenario, the filter would likely employ a number of regular expressions of varying complexity that will make the necessary changes to the content.