This is a migrated thread and some comments may be shown as answers.

Editor - Limit Number of Options for the Users

5 Answers 40 Views
Editor
This is a migrated thread and some comments may be shown as answers.
-
Top achievements
Rank 1
- asked on 04 Aug 2010, 11:27 AM
I have seen somewhere that it is possible to limit of options available for the users of the editor by insert of some tags in the .aspx-file. Are a list with all option-tags available somewhere?

5 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 04 Aug 2010, 12:21 PM
Hello Kim,

The content area of RadEditor is a standard editable IFRAME element which uses the Rich Text Editing engine of the browser under which it operates. This engine supports all tags that the browser could work with.

If you would like you can reduce the tools available on the RadEditor toolbar (see this article) but the user will be still able to paste or insert in HTML mode the desired content. That is why you can also strip the unwanted tags when submitting the content or directly on the server using regular expressions.

Here is an example which demonstrates how to strip the unwanted tags by implementing a custom content filter:

<script type="text/javascript">
    function OnClientLoad(editor, args) {
        editor.get_filtersManager().add(new AllowedTagsFilter());
    }
    AllowedTagsFilter = function() {
        AllowedTagsFilter.initializeBase(this);
        this.set_isDom(false);
        this.set_enabled(true);
        this.set_name("AllowedTagsFilter");
        this.set_description("Strip the unwanted tags from RadEditor");
    }
    AllowedTagsFilter.prototype =
    {
    getHtmlContent: function(content) {
        return this._removeHtmlTags(content);
    },
 
    getDesignContent: function(content) {
        return this._removeHtmlTags(content);
    },
 
        _removeHtmlTags: function(initContent) {
            var cleanContent;
 
            //Perform necessary REGEX replacement to remove unsupported HTML tags
            //Supported Reporting HTML tags: FONT, STRONG, B, EM, I, U, A, OL, UL, LI, DIV, SPAN, P, BR, CENTER
            //HTML must be XHTML valid, too, but Editor already provides that filter
 
            //Following REGEX will remove all HTML tags EXCEPT those expliclitly listed
            cleanContent = initContent.replace(new RegExp("<(?!\/?(font|strong|b|em|(i(?!mg))|u|a|ol|ul|li|div|span|p|br|center)(?=>|\s?.*>))\/?.*?>", "ig"), "");
 
            return cleanContent;
        }
    }
    AllowedTagsFilter.registerClass('AllowedTagsFilter', Telerik.Web.UI.Editor.Filter);     
</script>
 
<telerik:RadEditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor1">
    <Content>sample content test <br/> test</Content>
</telerik:RadEditor>


Kind regards,
Rumen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
-
Top achievements
Rank 1
answered on 04 Aug 2010, 12:31 PM
Thank you for the answer!

Is there a way to hide all options and then allow the most common ones for the users?
0
Rumen
Telerik team
answered on 04 Aug 2010, 12:35 PM
Hi Kim,

All you need to do is to create an empty ToolsFile.xml file, which should contains only <root></root> tags and set the ToolsFile property of RadEditor to point to it. This will render RadEditor without toolbars.

You should also enable the provided in my earlier post AllowedTagsFilter content filter.

Kind regards,
Rumen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
-
Top achievements
Rank 1
answered on 04 Aug 2010, 02:23 PM
Thank you very much for your information!

Instead of an empty ToolsFile.xml, I tried to enter i.e. this content:

<root>
- <tools name="MainToolbar" dockable="false" enabled="true">
  <tool name="IncreaseSize" shortcut="F10" />
  <tool name="DecreaseSize" shortcut="F9" />
  <tool name="SpellCheck" />
  <tool name="Print" shortcut="CTRL+P" />
  <tool separator="true" />
  <tool name="Cut" shortcut="CTRL+X" />
  <tool name="Copy" shortcut="CTRL+C" />
  <tool name="Paste" shortcut="CTRL+V" />
  <tool separator="true" />
  <tool name="Undo" shortcut="CTRL+Z" />
  <tool name="Redo" shortcut="CTRL+Y" />
  </tools> 
</root>

and it seems that you in this way can control the number of tools - will this also be a correct way to do it?
0
Rumen
Telerik team
answered on 04 Aug 2010, 03:28 PM
Yes, Kim.

This is the proper way to declare toos via the toolsfile.xml file. You can find a list of all available tools in this help article: http://www.telerik.com/help/aspnet-ajax/toolbarintro.html.

Best regards,
Rumen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Editor
Asked by
-
Top achievements
Rank 1
Answers by
Rumen
Telerik team
-
Top achievements
Rank 1
Share this question
or