You are not logged in.

#1 2008-07-18 11:01:08

Zooey
Member
Registered: 2008-07-11
Posts: 17

Paste as Word: 'extra' code in Firefox

Sorry if this has been covered before: I did have a look through but didn't find anything.

I've just enabled the Paste as Word plugin in my editor, and it seems to be working okay. However, when I use it in Firefox, it seems to add a bunch of plugin-related code into the actual text field. The code doesn't affect anything - it's only visible when the editor is toggled off - but it's a bit annoying. This is the kind of output it gives me:

Code:

<p><a name="Plugin_options"></a></p>
<p>&nbsp;</p>
<!--[if gte mso 9]><xml> Normal   0         false   false   false                             MicrosoftInternetExplorer4 </xml><![endif]--><!--[if gte mso 9]><xml> </xml><![endif]--><!--[if !mso]>
<object  classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui>
</object>
<mce:style><!  st1\:*{behavior:url(#ieooui) } -->
<p>&nbsp;</p>
<!--[endif]-->
<p><!--  --></p>
<!--[if gte mso 10]> <mce: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:0cm 5.4pt 0cm 5.4pt;     mso-para-margin:0cm;     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;} -->
<p>&nbsp;</p>

All that shows up before my actual pasted text starts. This does not happen if I use the editor in IE.

Is this a known bug / feature, or is there something in my configuration I need to change to avoid this happening? If it's just the way the editor works in FF, I can live with it, since the editor otherwise functions as it needs to (it just might be a bit confusing for some users if they switch into html mode). But I wanted to be sure this wasn't caused by my error, which is entirely possible.

Thanks in advance!

Offline

 

#2 2008-07-23 11:04:38

Zooey
Member
Registered: 2008-07-11
Posts: 17

Re: Paste as Word: 'extra' code in Firefox

Update to this issue: on further experimentation, it seems that the rogue code does show up in the posted content. It is a Firefox-specific problem - if I paste in the same content in another browser I don't get this - so I presume it is related to the restrictions on copy / paste in Firefox. Obviously it is a much bigger problem than I had previously thought, since this affects what the end user will see.

Has anyone else experienced this? Any workarounds?

Offline

 

#3 2008-07-23 12:33:24

krzyko
Member
Registered: 2007-09-27
Posts: 10

Re: Paste as Word: 'extra' code in Firefox

I've also noticed this problem. My solution is to use: paste_insert_word_content_callback : "convertWord" in the init options, and the callback function is:

Code:

function convertWord (type, content) {
    switch (type) {
        // Gets executed before the built in logic performs it's cleanups
        case "before":
            //content = content.toLowerCase(); // Some dummy logic
            //alert(content);
            break;
        // Gets executed after the built in logic performs it's cleanups
        case "after":
            //alert(content);
            content = content.replace(/<!(?:--[\s\S]*?--\s*)?>\s*/g,'');
            //content = content.toLowerCase(); // Some dummy logic
            //alert(content);
            break;
    }
    return content;
}

It will remove all html comments <!-- --> form the pasted content. This works for me very well (I'm using Word 2003), You can also try to experiment with this callback function (more about the paste plugin is here: http://wiki.moxiecode.com/index.php/Tin … gins/paste).

Offline

 

#4 2008-07-31 13:58:08

Zooey
Member
Registered: 2008-07-11
Posts: 17

Re: Paste as Word: 'extra' code in Firefox

Kryko, sorry it's taken me so long to reply - I've only just had a chance to put this into action. It worked great for me - thanks very much indeed for your help!

Offline

 

#5 2008-08-21 07:56:13

rayleigh
Member
Registered: 2008-08-09
Posts: 2

Re: Paste as Word: 'extra' code in Firefox

How about using html_entity_decode() and htmlspecialchars_decode()? Can this be a reliable solution?

Offline

 

#6 2009-05-19 06:11:45

ug4jee
Member
Registered: 2008-11-26
Posts: 33

Re: Paste as Word: 'extra' code in Firefox

how to and where i need to add this code(convertWord) in my tinyMCE to get worked out.
give me few steps where and how to implement this in my application.

Thanks,
-Jee

Offline

 

#7 2009-05-19 09:03:19

lkeijmel
Member
From: The Netherlands
Registered: 2008-03-13
Posts: 104
Website

Re: Paste as Word: 'extra' code in Firefox

this code shouldn't be needed because there is new past logic build within tinymce


Grtz, Laurence

Offline

 

#8 2009-05-19 15:15:06

ug4jee
Member
Registered: 2008-11-26
Posts: 33

Re: Paste as Word: 'extra' code in Firefox

I am already using the old build for my production environment, i may not be able to migrate to newer build, please point me where i can add these lines in paste plugin.

Thanks,
-Jee

Offline

 

#9 2009-05-19 18:31:13

Zooey
Member
Registered: 2008-07-11
Posts: 17

Re: Paste as Word: 'extra' code in Firefox

Jee,

You need to add the lines into your tiny_mce init file. So you'll have something like this (depending on what other options you're using):

Code:

tinyMCE.init({
        theme:"advanced",
        mode:"none",
        editor_selector:"mce-editor",
        plugins : "paste",
        paste_insert_word_content_callback : "convertWord",
        paste_auto_cleanup_on_paste : true,
              





function convertWord (type, content) {
    switch (type) {
        // Gets executed before the built in logic performs it's cleanups
        case "before":
            //content = content.toLowerCase(); // Some dummy logic
            //alert(content);
            break;
        // Gets executed after the built in logic performs it's cleanups
        case "after":
            //alert(content);
            content = content.replace(/<!(?:--[\s\S]*?--\s*)?>\s*/g,'');
            //content = content.toLowerCase(); // Some dummy logic
            //alert(content);
            break;
    }
    return content;
}

Good luck!

Zooey

Offline

 

#10 2009-05-19 20:47:01

spocke
Administrator
From: Sweden, Skellefteċ
Registered: 2004-11-25
Posts: 11471
Website

Re: Paste as Word: 'extra' code in Firefox

Or you could update to the latest version.


Best regards,
Spocke - Main developer of TinyMCE

Offline

 

#11 2009-05-20 09:11:36

ug4jee
Member
Registered: 2008-11-26
Posts: 33

Re: Paste as Word: 'extra' code in Firefox

Zooey,

It looks different for me,
actually I want this to work at paste(Ctrl+V) operation for word content, I tried adding these code snippets to my script and it has never called the function.
at file location \tiny_mce\plugins\paste\editor_plugin_src.js

Could please let me know what I am missing here.

Thanks
-Jee

Offline

 

#12 2009-05-20 09:35:28

Felix Riesterer
Administrator
From: Germany
Registered: 2005-12-30
Posts: 4690
Website

Re: Paste as Word: 'extra' code in Firefox

ug4jee wrote:

and it has never called the function.
at file location \tiny_mce\plugins\paste\editor_plugin_src.js

Usually the editor doesn't load the "*_src.js" files. Copy your code into the file "editor_plugin.js" and you should get your intended results (don't forget to empty your browser cache!).


Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)

Offline

 

#13 2009-05-20 09:58:50

ug4jee
Member
Registered: 2008-11-26
Posts: 33

Re: Paste as Word: 'extra' code in Firefox

Hmm,

I have pointed the tiny_mce_src.js file in my application, then it shoud take the modifications from editor_plugin_src.js .

The below mentioned comments are adding while page refresh on browser...

<!-- /* 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";} @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;} -->

-Jee

Offline

 

#14 2009-05-20 12:26:50

bcx
Member
Registered: 2007-12-28
Posts: 3

Re: Paste as Word: 'extra' code in Firefox

I'm seeing similar behaviour in 3.2.3.1.

On pasting from Microsoft Word 2002 into TinyMCE 3.2.3.1 in firefox 3.0.10 on Windows Vista i'm getting this in the editor (source):

<p><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:HyphenationZone>21</w:HyphenationZone> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:ApplyBreakingRules /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:UseFELayout /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--> &lt;!--  /* Font Definitions */  @font-face  {font-family:SimSun;  panose-1:2 1 6 0 3 1 1 1 1 1;  mso-font-alt:宋体;  mso-font-charset:134;  mso-generic-font-family:auto;  mso-font-pitch:variable;  mso-font-signature:3 680460288 22 0 262145 0;} @font-face  {font-family:"\@SimSun";  panose-1:2 1 6 0 3 1 1 1 1 1;  mso-font-charset:134;  mso-generic-font-family:auto;  mso-font-pitch:variable;  mso-font-signature:3 680460288 22 0 262145 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal  {mso-style-parent:"";  margin:0cm;  margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:10.0pt;  font-family:Arial;  mso-fareast-font-family:SimSun;} @page Section1  {size:595.3pt 841.9pt;  margin:70.85pt 70.85pt 70.85pt 70.85pt;  mso-header-margin:35.4pt;  mso-footer-margin:35.4pt;  mso-paper-source:0;} div.Section1  {page:Section1;} --&gt; <!--[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:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
</style>
<![endif]-->
<p class="MsoNormal">test</p>
</p>

Offline

 

#15 2009-05-20 16:34:00

ug4jee
Member
Registered: 2008-11-26
Posts: 33

Re: Paste as Word: 'extra' code in Firefox

When I try with new version of paste plugin(I have replaced all *paste* folder with ) in my dev environment, It was not pasting the content using Ctrl+V option.

What i need to change in new version of paste plugin code.

Thanks,
-Jee

Offline

 

#16 2009-05-20 16:44:44

spocke
Administrator
From: Sweden, Skellefteċ
Registered: 2004-11-25
Posts: 11471
Website

Re: Paste as Word: 'extra' code in Firefox

You need the latest TinyMCE version for that plugin to work.


Best regards,
Spocke - Main developer of TinyMCE

Offline

 

#17 2009-05-20 17:27:32

ug4jee
Member
Registered: 2008-11-26
Posts: 33

Re: Paste as Word: 'extra' code in Firefox

I have downloaded tinymce_3_2_3_1_dev.zip file from http://tinymce.moxiecode.com/download.php site, is it not the latest version, if so please give me the link to download the latest verion.

Please let me know the modifications which need to be done.

Thanks.
Shivaji

Offline

 

#18 2009-05-20 19:20:23

Felix Riesterer
Administrator
From: Germany
Registered: 2005-12-30
Posts: 4690
Website

Re: Paste as Word: 'extra' code in Firefox

ug4jee wrote:

please give me the link to download the latest verion.

TinyMCE repository


Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)

Offline

 

#19 2009-05-20 19:27:03

spocke
Administrator
From: Sweden, Skellefteċ
Registered: 2004-11-25
Posts: 11471
Website

Re: Paste as Word: 'extra' code in Firefox

The latest official version has the new paste plugin as well. And I can't reproduce your issue with the comment. If I paste from Word 2k7, 2k4, XP they all work in FF, IE, Safari, Chrome and none of them produce the conditional comments.


Best regards,
Spocke - Main developer of TinyMCE

Offline

 

#20 2009-05-21 13:12:51

ug4jee
Member
Registered: 2008-11-26
Posts: 33

Re: Paste as Word: 'extra' code in Firefox

I have downloaded the latest plugin from TinyMCE repository location provided by Felix,
Now iam not able to paste the content which was copied from word document using Ctrl+V option. It pastes only an empty space.

Apparently iam receiving an error message in error console for my FF browser.

Error: dom.split is not a function
Source File: http://localhost:8090/paws/javascript/tiny_mce/plugins/paste/editor_plugin_src.js
Line: 433


suggestion please?

Thanks,
-Jee

Offline

 

#21 2009-07-27 17:42:52

forwheeler
Member
Registered: 2009-04-14
Posts: 14

Re: Paste as Word: 'extra' code in Firefox

I am using 3.2.4.1 and when I paste into IE from word it always works fine. When I paste from FF using control V it brings up the paste window which works fine. When I right click using FF and paste I get the comments. The convertWord function doesn't get called when right click paste from FF. Is that expected?

Last edited by forwheeler (2009-07-27 17:48:18)

Offline

 

#22 2009-07-27 17:51:45

spocke
Administrator
From: Sweden, Skellefteċ
Registered: 2004-11-25
Posts: 11471
Website

Re: Paste as Word: 'extra' code in Firefox

Upgrade = problem solved.


Best regards,
Spocke - Main developer of TinyMCE

Offline

 

#23 2009-07-27 18:16:48

forwheeler
Member
Registered: 2009-04-14
Posts: 14

Re: Paste as Word: 'extra' code in Firefox

Yes, I upgraded to 3.2.5.1 and it works great. I removed the paste_auto_cleanup_on_paste in the init since I didn't seem to need it anymore.

Thanks!

Offline

 

#24 2009-07-27 18:52:13

forwheeler
Member
Registered: 2009-04-14
Posts: 14

Re: Paste as Word: 'extra' code in Firefox

I guess I spoke too soon. When I paste with this new version, my font colors and font family revert back to default.

Offline

 

#25 2009-07-27 19:03:26

spocke
Administrator
From: Sweden, Skellefteċ
Registered: 2004-11-25
Posts: 11471
Website

Re: Paste as Word: 'extra' code in Firefox

Yes, consult manuals for details on how to retain styles.


Best regards,
Spocke - Main developer of TinyMCE

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB