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

New feature not working in firefox

7 Answers 264 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Eirik
Top achievements
Rank 1
Eirik asked on 29 Feb 2008, 07:15 AM
>Implemented a new option for Strip on Paste - AllExceptNewLines (strips all tags and keeps new lines and br tags)

This doesn't work in Firefox

7 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 29 Feb 2008, 01:57 PM
Hi Eldorsen,

The problem is related to the fact that the Mozilla based browsers do not allow unprivileged scripts to invoke the Cut, Copy and Paste commands in the Mozilla rich text editors. You can find more information on the topic in the following Mozilla article: Setting Prefs for the Mozilla Rich Text Editing Demo as well as on our site: Telerik RadEditor browser issues -> Cut / Copy / Paste do not work.

This restriction prevent the editor to capture the onpaste event in Firefox and to strip the pasted content when you paste the content with Ctrl+V. When you paste the content in Firefox, it is pasted as it is supplied by the browser in the editor.

What you can do is to strip the formatting when submitting the content as it is shown in the following help article:
Cleaning Word Formatting On Page Load And On Submit:

<script type="text/javascript">
function OnClientLoad(editor, args)
{
   editor.add_submit(function ()
   {
      editor.fire("SelectAll");
      editor.fire("StripAll");
      alert(editor.get_Html(true));
});
}
</script>

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Eirik
Top achievements
Rank 1
answered on 03 Mar 2008, 09:14 AM
Ok i understand. But couldn't you create a workaround. Maybe you could override ctrl+v to open a popup for pasting clean text if the useragent is firefox and AllExceptNewLines is activated. The same could be done for the standard paste button.
0
Rumen
Telerik team
answered on 03 Mar 2008, 11:38 AM
Hi Eirik,

Here is an example how to override the Paste command and launch the Paste as Plain text dialog when hitting Ctrl+V in Firefox:

<telerik:RadEditor ID="RadEditor1" runat="server" StripFormattingOptions="AllExceptNewLines"></telerik:RadEditor>
<script type="text/javascript">
var oldFunction = Telerik.Web.UI.Editor.CommandList["Paste"]; //save the original Paste function
Telerik.Web.UI.Editor.CommandList["Paste"] = function(commandName, editor, args)
{     
      if (!document.all)
      {
        editor.fire("PastePlainText");
      }
      else
      {
        oldFunction(commandName, editor, args);
      }
};
</script>

I hope this helps.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
cglubish
Top achievements
Rank 2
answered on 07 May 2008, 09:39 PM
Rumen,

I copied and pasted your solution posted for intercepting a control-v in firefox.  It doesn't work, and I get a js error saying "editor.Fire is not a function".

Any ideas?

Chris
0
Rumen
Telerik team
answered on 08 May 2008, 09:06 AM
Hi Chris,

From Q1 the compatibility layer which was used in the transition beta period is now removed. All client-side methods strictly follow the ASP.NET AJAX conventions and are lower case. For instance: set_mode() should always be used from now on, set_Mode() is no longer supported. This information is posted as a sticky note in the forums. You can see the following forum thread for more information: Important changes in the Client-Side API of RadEditor for ASP.NET AJAX.

To fix the problem rename the Fire() method to fire(), e.g.

<telerik:RadEditor ID="RadEditor1" runat="server" StripFormattingOptions="AllExceptNewLines"></telerik:RadEditor>
<script type="text/javascript">
var oldFunction = Telerik.Web.UI.Editor.CommandList["Paste"]; //save the original Paste function
Telerik.Web.UI.Editor.CommandList["Paste"] = function(commandName, editor, args)
{    
      if (!document.all)
      {
        editor.fire("PastePlainText");
      }
      else
      {
        oldFunction(commandName, editor, args);
      }
};
</script>

Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
cglubish
Top achievements
Rank 2
answered on 08 May 2008, 03:09 PM
Thanks Rumen,

That fixed it, much appreciated.  I did notice 2 things I was wondering if there is a way around:

1) My radeditor was inside an asp:UpdatePanel.  The code you gave me didn't intercept anything until I removed the updatePanel.  How can I keep the updatePanel and still have the code interecept things properly?

2)  I noticed the code properly intercepts control-v in firefox, but doesn't catch a browser context menu paste.  In IE, my custom context menu replaces the browser one, but in firefox if my editor is empty, the browser right/click paste inserts content bypassing the code and pastes uncleaned text.

Cheers
Chris
0
Rumen
Telerik team
answered on 13 May 2008, 04:28 PM
Hi Mr,

Up to the questions:
  1. You should not experience any problems with the provided code when the editor is placed in AJAX UpdatePanel. I made a test and I was not able to reproduce the problem. You can see the attached video as well as test the attached project for more information.
  2. This behavior is due to the fact that the Mozilla based browsers do not allow unprivileged scripts to invoke the Cut, Copy and Paste commands in the Mozilla rich text editors. You can find more information on the topic in the following Mozilla article:  Setting Prefs for the Mozilla Rich Text Editing Demo as well as on our site: Telerik RadEditor browser issues -> Cut / Copy / Paste do not work.

    If you would like we can tell you how to strip the HTML formatting on submit.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
Eirik
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Eirik
Top achievements
Rank 1
cglubish
Top achievements
Rank 2
Share this question
or