Hello,
Our online version of RadEditor is 7.3.2 – RadEditor for ASP .NET
While attempting to migrate to the RadEditor for ASP .NET AJAX we’ve came across these problems:
1. We’re interested in having the editor strip HTML tags (except for BR tags) when the user pastes content into it. Since the stripping is problematic in FF, we’ve written some client code to bring the “paste plain text page” up when the user tries to paste. This is the code we have online:
function OnClientCommandExecuting(editor, commandName, oTool)
{
var browserName=navigator.appName;
if (commandName == "Paste" && browserName!="Microsoft Internet Explorer")
{
editor.Fire("PastePlainText");
return false;
}
}
We’ve changed it to fit the new version thus:
function OnClientCommandExecuting(editor, commandName, oTool)
{
var browserName=navigator.appName;
if (commandName._commandName == 'Paste' && browserName!="Microsoft Internet Explorer")
{
editor.fire("PastePlainText");
return false;
}
}
Which works, but the behavior is different! Instead of bringing up the “paste plain text page”, the editor first puts the clipboard’s content in the content-area of the editor, and only then brings the page up, thereby rendering our efforts useless.
Please advise as to what we can do to solve this problem ?
2. Another problem is, when the user clicks the “paste” button, the “Please use Ctrl+V to Paste” msgbox appears before the “paste plain text page” appears.
How do we suppress this in the new (AJAX) version ?
12 Answers, 1 is accepted
Here is the code for RadEditor for ASP.NET AJAX that will work as expected:
<script type="text/javascript">
function OnClientCommandExecuted(editor, args)
{
var browserName=navigator.appName;
var commandName = args.get_commandName();
if (commandName == "Paste" && browserName!="Microsoft Internet Explorer")
{
editor.fire("PastePlainText");
args.set_cancel(true); //cancel the command execution
}
}
</script>
<telerik:radeditor runat="server" ID="RadEditor1"
OnClientCommandExecuted="OnClientCommandExecuted">
</telerik:radeditor>
Best wishes,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
args.set_cancel(true); works in FF, not in Safari (the text is still paste before the radwindow opens and not canceled).
Any way to make this works on all browsers ?
Please, replace the OnClientCommandExecuted event with OnClientCommandExecuting and test again the args.set_cancel(true); in Safari. When the args.set_cancel(true); is fired in the OnClientCommandExecuted event the command is already executed - that is why you should fire the set_cancel(true) method in the OnClientCommandExecuting event.
Best regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Safari 3.1.2
Thank you
Yes, you are correct that the paste event is not canceled in Safari event by attaching to the OnClientCommandExecuting event.
Nevertheless, please, try the following solution that works in Safari too on my side:
<script type="text/javascript">
function OnClientLoad(editor, args)
{
var element = document.all ? editor.get_document().body : editor.get_document();
$telerik.addExternalHandler(element, "paste", function(e)
{
if (!document.all)
{
editor.fire("PastePlainText");
//cancel the browser's paste event
if (e.preventDefault) e.preventDefault();
if (e.stopPropagation)e.stopPropagation();
return false;
}
});
}
</script>
<telerik:RadEditor runat="server"
OnClientLoad="OnClientLoad"
ID="RadEditor1">
</telerik:RadEditor>
Kind regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please, set StripFormattingOptions="NoneSupressCleanMessage" and remove the browser check, e.g.
<script type="text/javascript">
function OnClientLoad(editor, args)
{
var element = document.all ? editor.get_document().body : editor.get_document();
$telerik.addExternalHandler(element, "paste", function(e)
{
editor.fire("PastePlainText");
//cancel the browser's paste event
if (e.preventDefault) e.preventDefault();
if (e.stopPropagation)e.stopPropagation();
return false;
});
}
</script>
<telerik:RadEditor runat="server"
OnClientLoad="OnClientLoad"
StripFormattingOptions="NoneSupressCleanMessage"
ID="RadEditor1">
</telerik:RadEditor>
This code fires the PastePlainText command when hitting Ctrl+V in IE, FF and Safari.
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I have implement your last post solution and it works fine in IE,FF and safari.
But, in Chrome it seems to work from time to time and not always. To reproduce it you can try copying some HTML into the editor for the fist time after the page is loaded and see that it works fine.
Then, try editing the content of the editor with backspace and delete buttons and try pasting HTML again.
After repeating this for several times I cannot get the "Paste Plain text" window anymore and the HTML is pasted as is into the editor.
Do you have any solution to this behavior ?
thanks,
yaniv
It seems that there would be some bug in the Chrome browser that is causing the code to eventually stop working.
Chrome is essentially a Safari in disguise, albeit with a few modifications on its own - unfortunately these two browsers (Chrome and Safari) are very difficult to debug in a meaningful manner.
We are not sure what could be causing the issue and will log it for further investigation.
Best wishes,
Tervel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I also am getting a javascript error saying I need to add an HttpHandler
Controls>RadEditor>Dialogs>Introduction.
I tried to reproduce the problem with the latest Q1 2010 (version 2010.1.309) of RadEditor, but without success.
Could you please test the attached project and if you are able to reproduce the problem send sample content and steps to reproduce the issue?
If your scenario is other modify the project so that the issue is reproducible and send it for examination along with reproduction steps.
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.