Hi there, I have an issue with word and my WYSIWYG editor on web. When I copy something from word and paste it to my editor on web, it keeps formating but also insert lot of word tags which are not valid in html, sometimes change font on whole site, or link colors, etc... Is there any way in js how to clean text before paste to editor? Ty
Depends on what you mean with "your"editor (you developed it or you mean just a usage of 3rd party editor). Most of the available editors support pasting from word, maybe you could try another HTML editor then. The option is called "Paste from Word" and requires special handling for Word contents, you can see an example here: http://tinymce.moxiecode.com/tryit/full.php Another example: http://www.asp.net/ajax/ajaxcontroltoolkit/samples/htmleditor/htmleditor.aspx or http://www.obout.com/editor_new/sample_full.aspx Eventually you could see what word tag cleaning logic is being used by those editors and only integrate that specific functionality into your editor.
Maybe you dont understand me. When I copy something from word, paste it into editor(mostly nicedit) and then I show source I see tags like <meta name="Title" content="" /><meta name="Keywords" content="" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="ProgId" content="Word.Document" /><meta name="Generator" content="Microsoft Word 14" /><meta name="Originator" content="Microsoft Word 14" /><link rel="File-List" href="... <!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings></xml><![endif]--><link rel="themeData" .... Code (markup): It also copy styles, another xml, etc etc and I dont want them paste to my editor... I tried it in that asp.net editor you posted, its same as in nicedit, but tinymce cleaned it. How can I do this in any editor? EDIT: In obout.com editor I see that tags too.
Are you using the "Paste from MS Word (with cleanup)" Button or are you just pasting text directly into editor? Because the button function *should* clean all those extra ms word tags. Anyways, you can't do this in "any editor" just like that. The editor itself must provide this functionality or you gotta mod it by yourself. If the obout editor isn't working that way (it should actually, if it says "cleanup" it should mean removing unnecessary tags) or nicedit, then i would go with tinymce. The workaround i use sometimes is to always paste whole content into notepad first to remove all formatting, and then C&P it into editors, but that could be too much work
Just pasting text directly(as most of users do it). This is not about me, I know how to paste it there correctly, this is about users who dont understand this (and I think they never will) and then call me "What happend? I pasted text from word and..." no matter how many times you tell them how to do it... I found fix for nicedit minute ago - http://www.billyswebdesign.com/blog...-wysiwyg-that-can-clean-a-paste-from-ms-word/ I havent tested it yet, hope itll work. P.S.: I do it same way sometimes