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

Paste plain text in FF

12 Answers 273 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Yaniv
Top achievements
Rank 1
Yaniv asked on 07 Sep 2008, 03:50 PM

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

Sort by
0
Rumen
Telerik team
answered on 08 Sep 2008, 08:52 AM
Hi Yaniv,

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.
0
arnaud
Top achievements
Rank 1
answered on 05 Nov 2008, 12:29 AM
Hi,

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 ?



0
Rumen
Telerik team
answered on 05 Nov 2008, 03:49 PM
Hi Arnaud,

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.
0
arnaud
Top achievements
Rank 1
answered on 05 Nov 2008, 04:23 PM
The result is the same using OnClientCommandExecuting, it does not work.
Safari 3.1.2
Thank you



0
Rumen
Telerik team
answered on 10 Nov 2008, 09:08 AM
Hi Arnaud,

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.
0
Edward
Top achievements
Rank 1
answered on 16 Feb 2009, 11:51 AM
Is there any way i can call PastePlainText when ever user paste the content in rad editor using ctl + v in IE, FF as well as Safari.     
0
Rumen
Telerik team
answered on 16 Feb 2009, 01:25 PM
Hello JOY ,

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.
0
Yaniv
Top achievements
Rank 1
answered on 01 Mar 2009, 11:18 AM
Hi,

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
0
Tervel
Telerik team
answered on 03 Mar 2009, 09:08 AM
Hello 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.
0
Chase Florell
Top achievements
Rank 1
answered on 01 Apr 2010, 12:01 AM
Hi there.  I tried this exact solution and when I paste I get the following error.  (does this have something to do with my URL Rewriting, and if so, how can I fix it?)

I also am getting a javascript error saying I need to add an HttpHandler
Controls>RadEditor>Dialogs>Introduction.

Error Details
Error URL: http://infinitas.local/App_Controls.aspx?Page=Telerik.Web.UI.DialogHandler&checkHandler=true
Error Source: System.Web
Exception: System.Web.HttpException: The file '/App_Controls.aspx' does not exist. at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Stack Trace: at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Additional Notes:
User Details
User Name: rockinthesixstring
User IP Address: 192.168.0.108
User Browser: Firefox
User Operating System: Windows 7
 

0
Rumen
Telerik team
answered on 02 Apr 2010, 12:10 PM
Hi Chase,

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.
0
Chase Florell
Top achievements
Rank 1
answered on 09 Apr 2010, 08:34 PM
The problem WAS with URLRewriting the Dialog Handler.  I fixed it by tweaking the dialog rewrites.
Tags
Editor
Asked by
Yaniv
Top achievements
Rank 1
Answers by
Rumen
Telerik team
arnaud
Top achievements
Rank 1
Edward
Top achievements
Rank 1
Yaniv
Top achievements
Rank 1
Tervel
Telerik team
Chase Florell
Top achievements
Rank 1
Share this question
or