views:

251

answers:

3

We are using the jQuery lwRTE plugin (http://plugins.jquery.com/project/lwRTE) to collect user input, and we have been quite pleased with its flexibility. We are only interested in allowing basic formatting, and the ability to customize the toolbar has been nice.

One problem we have run into, though, is dealing with the additional (garbage) html formatting that accompanies the text when it is copied from Word (or other applications that offer a html version to the clipboard). We do a pretty good job of cleaning it up on the server, but we would prefer to not have to deal with it at all. It would be nice if we could just get plain text from the clipboard.

The extent of extra formatting we get depends on the browser, but we are seeing at least some on all of them. Is there an execCommand() that I need to enable?

Thanks. Any help would be appreciated.

+2  A: 

This is a pretty common "problem" with many WYSIWYG editors. In worst case, the Word formatting will mess up your page layout as well.

Take a look atthis javascripot: http://www.1stclassmedia.co.uk/developers/clean-ms-word-formatting.php

Call it when you paste the text.

Steven
I ended up abandoning my client-side ambitions and just taking care of it on the server side. I was hoping for a browser-command switch that would cause it to grab the text-only version from the clipboard. Thanks for the answer anyway.
Jason Francis
+2  A: 

Whenever I come across this kind of situation, I usually paste the text into Notepad first (as it will paste just the plain text portions of the text) - then re-cut the text from there, to the target location. If I remember correctly, this is possible because a 'clip' can have its data stored in several formats, and an application can say something like 'paste as text', 'paste as html' etc. I suppose that the trick would be to get the jquery plugin to do the paste in the right format.

I can't check right now - because of the security policies in place in my office - but try running C:WINDOWS\system32\clipbrd.exe to see what's actually in the clipboard.

I will update this post when I have chance to locate more info.

Quick edit: Check this link for more info - http://msdn.microsoft.com/en-us/library/ms649013%28VS.85%29.aspx

belugabob
A: 

Did you fix this? Could you find the way to use CleanWordHTML() function or lwRTE object to clean word html? I cant find the paste event...

kike314