For all its greatness, one thing I’ve struggled with is that if you copy & paste stuff from another app into the YUI Editor, all of the original formatting is maintained. Most of the time for us, the “other app” is Microsoft Word, which does a particularly heinous job of generating HTML from a formatted document. This almost always wreaks havoc if the user subsequently tries to change text styles in the editor, as the underlying HTML is a total mess.

So, the solution for us was to try and strip out all of the formatting when somebody pastes stuff into the Editor, resulting in nice clean HTML that plays well with the YUI Editor formatting functions. Now, unfortunately no such feature exists in the YUI Editor, and Googling around just led to dead ends, so I was left to build my own.

Hello again,I have some problems with Firefox (cur. last stable version: 3.0.10), as it does not strip the first ugly block. The problem appear when pasting from Word Viewer 2003. A patch/workaround for this to work in Firefox (and other stuff like HTML comments) is to replace in your code the last part with this (notice the whitespace \s char, which include the NewLine character):

The only thing that I ran into was a timing issue in FF and IE when pasting.

No real testing, but, it seems when I pasted a large chunk of text, there was a chance that the timer would run before YUI had put the text into the container. This usually resulted in either a null container, or (strangely) an underscore (in FF).

Anyways, as a hack, I added a timer variable in the prototype, and wrapped the CleanPaste code in a try/catch. If an error was thrown, I incremented the timerCount, if it was less than 5 (an arbitrary value on my part), I reran the CleanPaste method. Seems to work fairly well.

Anthony, ran across this while working on my project. I was able to get it running, but had a question. I copied some paragraphs from Word into the editor and alerted the editors contents after the paste.

I still see some text like the following in some P tags:

P class=MsoNormal... text here etc

Are those Microsoft class names still supposed to show up in the filtered text?

Anthony, false alarm. I figured out the issue and it was on my end. What does your utility do that YUI doesn't do when setting the filterWord configuration attribute to true? I noticed your example also sets this attribute anyway, so I was just wondering.

Anthony, great job on the script! I have found an issue for me - the line to stop the context menu for mozilla browsers seem to be causing an issue in IE7 - it is clearing all the content when you right-click in the editor.

Thank you for the quick response. I copied a paragraph from MSWord, and posted, then I pasted in the editor, there is some format info left .. (You blog does not allow me to post those as it considers them as html code)

Also if I copy a paragraph like like:

MICHAEL HARTNETT: Yes, I think a little bit. Everything looks, technically, a little extended. But I’d still be a cyclical bull. I think the bottom line this year is, for me, the fundamental valuations are not so important. You just had an unprecedented bear market, an unprecedented macro meltdown, an unprecedented sort of policy response and I think you're in the midst of unprecedented rally in risk of the back of very oversold levels. And I think that we're not at the end of that risk rally and we won't be until the central banks end their quantitative easing policies.

It became:

MICHAEL HARTNETT: Yes, I think a little bit. Everythinglooks, technically, a little extended. But I’d still be a cyclical bull. Ithink the bottom line this year is, for me, the fundamental valuations are notso important. You just had an unprecedented bear market, an unprecedented macromeltdown, an unprecedented sort of policy response and I think you're in themidst of unprecedented rally in risk of the back of very oversold levels. And Ithink that we're not at the end of that risk rally and we won't be until thecentral banks end their quantitative easing policies.

If you bold some text in the editor and apply formatting to it (let's say, bold) and then copy and paste that, it is inserted into the rte as strong. At that point you can't unapply the formatting since it is expecting a bold tag. Of course it will save it as a strong tag when you submit anyway...

In any case, fixed this by adding html = this.Editor._cleanIncomingHTML(html) after your html = this.Editor.cleanHTML(html);

This code seems to invoke a problem if some text have been selected and the user left clicks to copy it.then it replaces the selected text with a underscore. which is far from ideal.Any suggestion how to avoid this behaivour?

Hi GuruFocus, sorry for the long delay. I tested the paragraph you sent me in Firefox (v3.0), however I did not experience the same problem. Perhaps you can attach a sample word document to the Issue Tracker in CodePlex and I'll try that.

Regarding your second problem about xml nodes etc still being there, it sounds like you have not correctly initialised the clean paste script. There is a sample HTML file included with the script, try pasting your text into that and see if the problem still occurs.

I'm getting similar behavior to Lars. I'm using IE 8.0.6 on WinXP with your unchanged example.htmSelect a word and right click it - the word is replaced with an underscore on a new line. Using the keyboard (Ctrl+X) works okay

FF 3.5.3 the right click is ignoredChrome 3.0.1 - When I right click, the word is deselected and the context menu is not displayedOpera 10.01 - Seems to work okay, although when I cut a word out using the context menu the text to the left of the cut word is shifted to the right effectively indenting the line?? weird??

Anthony. I'm not a js programmer. I'm trying to use your code in an app that has multiple YUI editors on a page. I can see the CleanPaste.js in the header, but when I paste into the editor the text is not getting cleaned.

Heya .. thanks a lot for this script!One issue i am facing is with IE8, wherein if i do a CTRL+V (it works on Context menu paste) and paste a text into an editor that already has some text, it is giing a JS error saying Object required (line 85). Also sometimes if there is text already and i paste some text, the whole text gets repeated, so each time i do a paste the text in the editor doubles.

For those with IE8 errors on line 85, switching to a setInterval method seemed to work for me. It looks like IE8 was taking too long to create the container div and didn't make it before the setTimeout occurred.

Hi Anthony, I am facing a issue with CleanPaste utility. I have modified the cleanPaste library for removal of most of the tags but whatever the contents i am copying from word document is not shown in same line which line it should be and breaked into multiple line.

And Word file which i am copying is having this content where the data is breaked into lines. In editor its showing in same line but when i am looking into alert box or in pdf its breaked into mulitple line.

So need your help..

Single sign on from Portal to Lotus is achieved through SAP Logon ticket, which is issued by SAP Portal and stored as browser cookie, which is accept by a lotus Domino(DSAPI Filter).

2. Implementation

The solution implements the approach which makes use of LtpaToken to SSO from EP to domino servers running on non-windows platform.

a) The DSAPI filter needs to be installed only on the Domino locator server and not on each and every domino server in the landscape.

b) A single lotus transport needs to be created in the portal corresponding to the Domino locator server, since locating the mail server of the user is handled internally.

Domino Side Configuration

1. The landscape can have multiple domino servers out of which one has to be the Domino Locator server.

Hi Anthony, I am facing one strange issue. I am pasting some text from word document to YUI Editor and i have used CleanPaste utility.In IE whatever the text i am pasting is replacing by the unformatted text but in firefox its duplicating the content which are inside the editor.

cleanpaste works fine without formatting,but once the cleaned content is inserted into rte (rich text editor) if u select the text and right click your mouse, the context is getting disappeard and is replaced by a character which is mentioned in execCommand(). It would be great if some one wil help me for the same. myid(charan.cse@gmail.com)