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

Automatically Replace Content Being Pasted In

3 Answers 80 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ayaz
Top achievements
Rank 1
Ayaz asked on 24 Jun 2010, 05:08 PM
Hi,

After searching through the forums I couldn't find this particular question posed or answered anywhere.
What I'd like to do is on a paste (preferred) or save event in the RadEditor, search the html content for deprecated tags like <b> and <i> and replace them with <strong> and <em> (respectively).

I believe this would be some kind of javascript code I need to add. I just need to know where to add it and what event listener to make it part of. Not looking for the entire code to be written for me, just would like to find out if it's possible and be pointed in the right direction.

Thank you.

3 Answers, 1 is accepted

Sort by
0
Accepted
Rumen Jekov
Top achievements
Rank 1
answered on 24 Jun 2010, 08:14 PM
Hi,

The event that you are looking for is named OnClientPasteHtml. You can find information and example about it at

http://demos.telerik.com/aspnet-ajax/editor/examples/onclientpastehtml/defaultcs.aspx

Greetings,
Rumen



0
Ayaz
Top achievements
Rank 1
answered on 24 Jun 2010, 10:16 PM
Thank you! exactly what I was looking for. My custom regex cleanup is working perfectly.

Another question .. what are various values of: args.get_commandName() ? Aside from "Paste" of course.

Also, I noticed that the OnClientPasteHtml doesn't seem to trigger in Source Code view (only Design view). Is this by design or am I missing something?

Thanks.



0
Rumen Jekov
Top achievements
Rank 1
answered on 26 Jun 2010, 10:04 PM
Hi,

You can find a list of command names in this help article: http://www.telerik.com/help/aspnet-ajax/toolbarintro.html
Use the tool name as command name value.

The source and design modes are two different HTML elements and for this reason the OnClientPasteHtml works only in design mode. You can get a reference to the textarea in source mode using editor.get_textArea() method and attach your own event handler using the browser's attachEvent and addEventListener methods. See this help article for more information: http://www.telerik.com/community/forums/aspnet-ajax/chart/charector-limit-in-rad-editor.aspx

Greetings,
Rumen
Tags
Editor
Asked by
Ayaz
Top achievements
Rank 1
Answers by
Rumen Jekov
Top achievements
Rank 1
Ayaz
Top achievements
Rank 1
Share this question
or