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

Trying to avoid reinventing the wheel

3 Answers 65 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Stuart Hemming
Top achievements
Rank 2
Stuart Hemming asked on 23 Feb 2012, 01:15 PM
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)

3 Answers, 1 is accepted

Sort by
0
Stuart Hemming
Top achievements
Rank 2
answered on 27 Feb 2012, 03:53 PM
I guess I'm going to have to writwe this one for myself then.
0
Rumen
Telerik team
answered on 27 Feb 2012, 04:15 PM
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.
0
Stuart Hemming
Top achievements
Rank 2
answered on 27 Feb 2012, 06:22 PM
Hi Rumen,

Thanks for that.

--
Stuart
Tags
Editor
Asked by
Stuart Hemming
Top achievements
Rank 2
Answers by
Stuart Hemming
Top achievements
Rank 2
Rumen
Telerik team
Share this question
or