+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Disabling links in RadEditor

Disabling links in RadEditor

5 posts, 0 answered
  1. Kevin
    Kevin avatar
    42 posts
    Registered:
    15 Mar 2005
    16 May 2010
    Link to this post
    Due to a security issue, I need to completely remove the ability to add links in forum posts.  I can remove the LinkManager from the radeditor toolbar easily enough, but whenever a user enters something like www.mysite.com in the text editor it will automatically create a link, and you can right-click on the link and see the inappropriate link properties popup window.  Is there a way to either disable the automatic conversion of www.mysite.com to a url, or better yet force the non-admin LinkManager to show up (I'm using Sitefinity 3.7)?  I've noticed that here the right link manager shows up, not the one used in the admin which allows you to see every page, public or not.
  2. Kevin
    Kevin avatar
    42 posts
    Registered:
    15 Mar 2005
    16 May 2010
    Link to this post
    This will at least remove the popup window ...

    <ContextMenus>
      <telerik:EditorContextMenu Enabled="false" /> 
      <telerik:EditorContextMenu TagName="IMG"  Enabled="false" /> 
      <telerik:EditorContextMenu TagName="A"  Enabled="false" /> 
      <telerik:EditorContextMenu TagName="TABLE"  Enabled="false" />
    </ContextMenus>
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 May 2010
    Link to this post
    Hello Kevin,

    The RadEditor automatically adds <a href= "" ...>. You could disable the links by subscribing for OnClientSubmit event of the RadEditor, then use js Regular Expression and look for <a> tag. If you find it remove these tags and set only the href value.

    You should modifySitefinity\ControlTemplates\Forums\EditPost.ascx template which is loaded when you post a  reply. You could use editor.get_html() to get the content of the RadEditor and pass it to your RegEx validator. Finally you should call editor.set_html to set the new content where <a> are escaped

    function OnClientSubmit(editor, args) {
     
            var cnt = editor.get_html();
            var newContent = ""; // here you need to escape the <a>
            editor.set_html(newContent);
        }


    Best wishes,
    Ivan Dimitrov
    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.
  4. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    06 Oct 2010
    Link to this post
    I assume that if I put this code below into the GenericContentDesigner.ascx file and map to it, that when you right click on a table in the RadEditor, the context menu should be disabled?  It is not working.  Am I missing something?
    I am using the RadEditor from within editing a page.
    But also, can i just disable a few options such as "Delete Cell" or "Delete Column" ?
    Thank you as always.
    <telerik:RadEditor
        runat="server"
        ID="textEditor"
    ...
         <ContextMenus>
            <telerik:EditorContextMenu  Enabled="false" />
            <telerik:EditorContextMenu TagName="TABLE"  Enabled="false" />
        </ContextMenus>
    ...
    </telerik:RadEditor>
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    07 Oct 2010
    Link to this post
    Hi Laura,

    Clear the context menu collection inside OnPreRender of GenericContentControlDesigner.ascx and then add the tools you want to see

    sample

    <script type="text/C#" runat="server">
     
        protected override void OnPreRender(EventArgs e)
        {
            
            textEditor.EnsureToolsFileLoaded();
            textEditor.ContextMenus.Clear();
            EditorContextMenu forBody = new EditorContextMenu();
            forBody.TagName = "BODY";
            //add specific tools to the context menu
            forBody.Tools.Add(new EditorTool("Cut"));
            forBody.Tools.Add(new EditorTool("Copy"));
            forBody.Tools.Add(new EditorTool("Paste"));
            forBody.Tools.Add(new EditorTool("PasteFromWord"));
            forBody.Tools.Add(new EditorTool("PastePlainText"));
            forBody.Tools.Add(new EditorTool("PasteAsHtml"));
            textEditor.ContextMenus.Add(forBody);
             
        }
    </script>


    All the best,
    Ivan Dimitrov
    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
Register for webinar
5 posts, 0 answered