Trying to avoid reinventing the wheel

4 posts, 0 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 23 Feb 2012 Link to this post

    I am about to add RadEditor to a page we use for creating a mail message.

    The user wants to be able to generate HTML mail but also wants the Outlook-like ability to choose to send plain text mail.

    My plan is to add a custom dropdown to the Editor toolbar to allow the user to choose the format and then modify the tools available in toolbar to an appropriate set dependent on the option chosen.

    What I then need to do, if the user has selected Plain Text, is remove any formating that is inappropriate.

    Looking at the functinality available in the radEditor demos, I can make a few calls to the Format Stripper to remove CSS, Font, Span and Word formating but I still need to remove any <a> tags.

    I guess I need to leave any <p> and <br> tags 'til after the user has finished composing the message or else it's going to be just one big block of text.

    Whilst I know that I could remove the <a> tags at the same time that I do the post-processing to convert the <p> and <br> tags the LFCR in the sent message, I'd prefer to do it in the editor so the user can see that tghere are no links in their message.

    So, to my point. is there an example somewhere of code I can use to process the message to remove a set of tags? Or should I just discover a method of sucking out the editor's content, throw it at the HTML Agility Pack to process it and then put it back?

    Or, better yet, is there an example of switching from full HTML editing to plan text already someplace?

    --
    Stuart (Founder member of LazyProgrammersRUs)
  2. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 27 Feb 2012 Link to this post

    I guess I'm going to have to writwe this one for myself then.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rumen
    Admin
    Rumen avatar
    12848 posts

    Posted 27 Feb 2012 Link to this post

    Hi Stuart,

    You can strip the whole HTML formatting (except <br/>) on submit using the FormatStripper command

    <script type="text/javascript">
    function OnClientSubmit(editor)
    {
         editor.fire("FormatStripper", {value : "ALL"});
    }
    </script>
    <telerik:RadEditor runat="server" OnClientSubmit="OnClientSubmit" />

    Another approach is to strip the unwanted tags using a custom content filter as shown in the following forum thread: Restrict to table editing only.

    Kind regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 27 Feb 2012 Link to this post

    Hi Rumen,

    Thanks for that.

    --
    Stuart
Back to Top