Have encountered a problem where text pasted from word into the TinyMCE editor contains a load of yucky header info as follows:
<!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Verdana; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1593833729 1073750107 16 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 72.0pt 72.0pt 72.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->
Anyone know how to remove this info or if using a different WYSIWYG would prevent this issue?
I’ve had this trouble using CKEditor before. That includes a Paste as Plain Text button which clears out all the formatting from Word but users often forget to use it or simply don’t know about it.
It turns out the function can be ‘forced’ by adding the appropriate setting to the config file. For example
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
config.forcePasteAsPlainText = true;
};
I tend to use that all the time now rather than giving people the extra flexibility as it saves a lot of confusion!
c2uk
June 30, 2010, 3:24pm
3
glad it works - you used to use a special button, but not any more.
Hey thanks c2uk - the paste plugin seems to do the trick as far as I can see from my initial tests.
Was really simple to enable too:
<!-- TinyMCE -->
<script type="text/javascript" src="../js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
theme : "simple",
mode : "textareas",
plugins : "paste",
theme_advanced_buttons3_add : "pastetext,pasteword,selectall",
paste_auto_cleanup_on_paste : true,
});
</script>
<!-- /TinyMCE -->
Thanks for all the help from everyone
Thanks for the replies.
Does the paste plugin require the client to click a special button to paste?
I have tried the following php code to remove this extra crap but strangely it is not removin it:
$article = strip_tags($_POST["content"], '<p><a>');
And my other attempt
$article = eregi_replace("<!--(.*?)-->","",$article);
c2uk
June 30, 2010, 2:51pm
6
some WYSIWYG editors can filter out all that crap on paste, TinyMCE seems to be doing a good job when you enable the “paste” plugin.
Will89
June 30, 2010, 2:44pm
7
I have this same problem with the rad editor for .NET.
You will have to paste the content from word into notepad or a similar simple text editor and then re-copy it and paste it into the editor.
This should drop all of the word formatting that is inserted.