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

Controling Paste content

3 Answers 53 Views
Editor
This is a migrated thread and some comments may be shown as answers.
François MAESEELE
Top achievements
Rank 1
François MAESEELE asked on 09 Jun 2010, 05:35 PM
Hi,
I have a few problems with the RadEditor.
  1. I need to restrict the text lenght to 100cars for example. But if the user use the Paste button, he can paste text that has a greater size. How can I control that ?
  2. I need to restrict the number of cars per line. How can I do that ?
  3. I need to prevent any user to paste html code as I wan pure text content. How can I do that ?
Thanks a lot.

François

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 10 Jun 2010, 09:21 AM
Hi François,

You can use the OnClientPasteHtml event of RadEditor to modify the pasted content. The OnClientPasteHtml event is also fired when the Paste (Ctrl+V) command is executed. It is useful in scenarios when the pasted content should be modified and inserted in the content area.

<script type="text/javascript">
function OnClientPasteHtml(sender, args)
{
    var commandName = args.get_commandName();
    var value = args.get_value();
    
    if (commandName == "Paste")
    {
        modify the content in the value variable and paste it using the set_value method
        args.set_value(newElement.outerHTML);
    }
}
</script>

You can configure RadEditor to paste plain text by setting the StripFormattingOnPaste property to "All" or "AllExceptNewLines".


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.
0
François MAESEELE
Top achievements
Rank 1
answered on 10 Jun 2010, 10:32 AM
Hi,
Thanks for your answer.
Regarding the option StripFormatingOnPaste, you are right. I was using the other StripFormattingOptions instead.
Also, it seems to me that if a limit of 100cars is set to the control, the paste operation shouldn't allow a user to paste more than these 100cars, isn't it ?
Regards,

François
0
Rumen
Telerik team
answered on 14 Jun 2010, 03:40 PM
Hi François,

RadEditor does not offer a built-in feature which will restrict the amount of pasted characters / words. RadEditor offers the ability to restrict the characters only when submitting the content as it is shown in this live demo: Max Content Length.

If you want to restrict the characters while pasting content see the solution provided in this forum thread: Charector limit in Rad:Editor.

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.
Tags
Editor
Asked by
François MAESEELE
Top achievements
Rank 1
Answers by
Rumen
Telerik team
François MAESEELE
Top achievements
Rank 1
Share this question
or