Telerik
Home / Community / Forums / RadControls for ASP.NET: Editor / Pasting From Word in Firefox 3 Doesn't Remove Meta/Style Tags

Not answered Pasting From Word in Firefox 3 Doesn't Remove Meta/Style Tags

Feed from this thread
  • Addams avatar

    Posted on Sep 26, 2008 (permalink)

    I'm using Firefox 3 and whenever I paste from Word 2003 and attempt to do the special Paste From Word process it doesn't remove a lot of stuff.

    Below are my two examples.

    The first one is when I paste from Word without doing the "Paste From Word" process just to show what the original paste contained.

    The second one shows what I get when I do the "Paste From Word" process and everything that it leaves.

    Without "Paste From Word":
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CKPETER%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml
     <w:WordDocument> 
      <w:View>Normal</w:View> 
      <w:Zoom>0</w:Zoom> 
      <w:PunctuationKerning/> 
      <w:ValidateAgainstSchemas/> 
      <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> 
      <w:IgnoreMixedContent>false</w:IgnoreMixedContent> 
      <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> 
      <w:Compatibility> 
       <w:BreakWrappedTables/> 
       <w:SnapToGridInCell/> 
       <w:WrapTextWithPunct/> 
       <w:UseAsianBreakRules/> 
       <w:DontGrowAutofit/> 
      </w:Compatibility> 
      <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> 
     </w:WordDocument> 
    </xml><![endif]--><!--[if gte mso 9]><xml
     <w:LatentStyles DefLockedState="false" LatentStyleCount="156"
     </w:LatentStyles> 
    </xml><![endif]--><style
    <!-- 
     /* Style Definitions */ 
     p.MsoNormal, li.MsoNormal, div.MsoNormal 
        {mso-style-parent:""; 
        margin:0in; 
        margin-bottom:.0001pt; 
        mso-pagination:widow-orphan; 
        font-size:12.0pt; 
        font-family:"Times New Roman"; 
        mso-fareast-font-family:"Times New Roman";} 
    h1 
        {mso-style-next:Normal; 
        margin-top:12.0pt; 
        margin-right:0in; 
        margin-bottom:3.0pt; 
        margin-left:0in; 
        mso-pagination:widow-orphan; 
        page-break-after:avoid; 
        mso-outline-level:1; 
        font-size:16.0pt; 
        font-family:Arial; 
        mso-font-kerning:16.0pt;} 
    @page Section1 
        {size:8.5in 11.0in; 
        margin:1.0in 1.25in 1.0in 1.25in; 
        mso-header-margin:.5in; 
        mso-footer-margin:.5in; 
        mso-paper-source:0;} 
    div.Section1 
        {page:Section1;} 
    --> 
    </style><!--[if gte mso 10]> 
    <style> 
     /* Style Definitions */ 
     table.MsoNormalTable 
        {mso-style-name:"Table Normal"; 
        mso-tstyle-rowband-size:0; 
        mso-tstyle-colband-size:0; 
        mso-style-noshow:yes; 
        mso-style-parent:""; 
        mso-padding-alt:0in 5.4pt 0in 5.4pt; 
        mso-para-margin:0in; 
        mso-para-margin-bottom:.0001pt; 
        mso-pagination:widow-orphan; 
        font-size:10.0pt; 
        font-family:"Times New Roman"; 
        mso-ansi-language:#0400; 
        mso-fareast-language:#0400; 
        mso-bidi-language:#0400;} 
    </style> 
    <![endif]--> 
     
    <h1>Header</h1> 
     
    <class="MsoNormal"><o:p>&nbsp;</o:p></p
     
    <class="MsoNormal">This is a paragraph of text</p> 
     
    <class="MsoNormal"><o:p>&nbsp;</o:p></p
     
    <class="MsoNormal">This is a paragraph of text</p> 
     
     

    With "Paste From Word":
    <meta style="" http-equiv="Content-Type" content="text/html; charset=utf-8"><meta style="" name="ProgId" content="Word.Document"><meta style="" name="Generator" content="Microsoft Word 11"><meta style="" name="Originator" content="Microsoft Word 11"><link style="" rel="File-List"><!--[if gte mso 9]><xml> Normal 0 false false false MicrosoftInternetExplorer4 </xml><![endif]--><!--[if gte mso 9]><xml> </xml><![endif]--><style style=""> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} h1 {mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:1; font-size:16.0pt; font-family:Arial; mso-font-kerning:16.0pt;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <h1 style="">Header</h1> <style="">&nbsp;</p> <style="">This is a paragraph of text</p> <style="">&nbsp;</p> <style="">This is a paragraph of text</p> <br> 

    Reply

  • Telerik Admin admin's avatar

    Posted on Sep 30, 2008 (permalink)

    Hi Addams,

    Thank you for reporting this problem.

    We are aware of it and we are currently working on it. The problem is due to that Firefox 3.0 is presenting itself to MS Word as a XML client and the content pasted in the editor has new format different to this one pasted in Firefox 2.0. That is why the regular expressions used by the editor's Paste From Word filters are not stripping the new MS Word XML formatting.

    We will do our best to fix the problem until the official Q3 release of RadControls for ASP.NET AJAX.

    Kind regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

  • Mike Bridge avatar

    Posted on Oct 9, 2008 (permalink)

    Hi-

    For some reason, we're suddenly getting a huge number of support calls about problems with pasting from Word.  Until there's a fix, is there a good workaround for this which will somehow force something to be pasted as unformatted text?

    Thanks,

    -Mike

    Reply

  • Telerik Admin admin's avatar

    Posted on Oct 10, 2008 (permalink)

    Hi Mike,

    What you can do is to override the Paste command with this code and run your own script for example fire the PastePlainText dialog in Firefox

    <telerik:radeditor runat="server" ID="RadEditor1"></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>

    Greetings,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

  • Matt Murphy avatar

    Posted on Dec 4, 2008 (permalink)

    hi, has there been any update on this? i've been drowning in support calls and Q3 is out, but it doesn't appear that Editor is any different from the copy i have. "paste plain text" isn't actually an option for us, since the formatting from word needs to be held onto.

    a problem that is also appearing it the one mentioned here:
    http://www.telerik.com/community/forums/aspnet/editor/conditional-comments.aspx

    does this remain the best solution or is this something that can be taken care of by the Editor itself?

    thanks,

    matt



    Reply

  • Telerik Admin admin's avatar

    Posted on Dec 8, 2008 (permalink)

    Hello Matt Murphy,

    Please, note that Firefox 3 now offers an onpaste property and we were able to implement the StripFormattingOnPaste property to work under Firefox in the latest version of RadEditor.

    Firefox 3.0 is presenting itself to MS Word as a XML client and the paste content has new formatting different from this one pasted by Word to Firefox 2.0. In addition MS Word 2007 formatting is stored inside a single <style> tag which contains different mso attributes and classes. That is why if we strip the <style> tag then the content will be pasted as plain text which is the same as StripFormattingOnPaste="All".

    That is why we decided to not strip the <style> tag and keep the mso formatting when the
    StripFormattingOnPaste property is set to MSWordRemoveAll
    .

    Yes, the solution provided by Todd is the best option for the time being regarding the problem described in the forum thread http://www.telerik.com/community/forums/aspnet/editor/conditional-comments.aspx.

    Kind regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

  • Matt Murphy avatar

    Posted on Jun 1 (permalink)

    i wanted to put a solution out there for anyone who ran across the same problem. i got client-side filters from a couple different places and put them together into a solution that got rid of all the nasty word garbage by doing the following thing:

                            <script language="javascript">

                                        function StripWord()

                                        {

                                                    oTool = new Object();

                                                    var editor = <%= editor1.ClientID %>;

                                                    oTool.GetSelectedValue = function() { return "WORD_ALL"; }

                                                    editor.Fire("FormatStripper", oTool);

                                                   

                                                    // the internal word stripper was not nearly enough after the release of

                                                    // firefox 3.0. this stuff also needed to happen.

                                                    var html = editor.GetHtml();

     

                                                    // Remove meta/link tags

                                                    html = html.replace(/<(META|LINK)[^>]*>\s*/gi, '' ) ;


                                                    // Remove style tags

                                                    html = html.replace( /<STYLE[^>]*>([\s\S]*?)<\/STYLE[^>]*>/gi, '' ) ;

     

                                                    // get rid of <o:p></o:p> nonsense

                                                    html = html.replace(/<o:p>[\s\S]*?<\/o:p>/g, '&nbsp;') ;

     

                                                     // remove < ! - -[if gte mso 9]> stuff

                                                    html = html.replace(/<(!--)([\s\S]*?)(--)>/gi, '');


                                                    editor.SetHtml(html);

                                        }

     

                            </script>


    i attached that to my onsubmit and it appears to be taking care of the problem. i hope that helps anyone else in the same boat.

    matt

    Reply

  • Telerik Admin admin's avatar

    Posted on Jun 3 (permalink)

    Hi Matt,

    Thank you for sharing your solution with the community. Your Telerik points were updated.

    On a side note, I want to add that, as opposed to RadEditor Classic, the RadEditor for ASP.NET AJAX  features this functionality built-in - so my suggestion is for users who still use the old editor to consider moving to the new one.

    Sincerely yours,
    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.

    Reply

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2009 Telerik. All rights reserved.