New feature not working in firefox

8 posts, 0 answers
  1. Eirik
    Eirik avatar
    46 posts
    Member since:
    Apr 2007

    Posted 29 Feb 2008 Link to this post

    >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
  2. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 29 Feb 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eirik
    Eirik avatar
    46 posts
    Member since:
    Apr 2007

    Posted 03 Mar 2008 Link to this post

    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.
  5. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 03 Mar 2008 Link to this post

    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
  6. cglubish
    cglubish avatar
    11 posts
    Member since:
    Aug 2012

    Posted 07 May 2008 Link to this post

    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
  7. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 08 May 2008 Link to this post

    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
  8. cglubish
    cglubish avatar
    11 posts
    Member since:
    Aug 2012

    Posted 08 May 2008 Link to this post

    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
  9. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 13 May 2008 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017