htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0 - Add-Ons:
Cleanup Code on paste event - dodgy fix!


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


MatRay
Novice

Nov 18, 2004, 6:55 AM

Post #1 of 7 (4607 views)
Shortcut
Cleanup Code on paste event - dodgy fix! Can't Post

Hi,

I just wondered if anyone had ever managed to solve the issue of the html cleanup functions not getting executed on paste events triggered from the contextmenu? I have found a way around it, but its frankly a bit of a nightmare. If anyone has a better method please let me know!

It was causing me a lot of grief, as my users were pasting in emails from Outlook which generates some lovely html - Crazy - especially if an email thread has been pasted in where an email has been bounced around several people (all with different settings on whether or not they accept html based emails and if so how) before being pasted into htmlArea. The result was that the dodgy code would (occaisionally) either cause my form to error on submission or it would go in OK but on subsequent viewing of the page generated large portions would be rendered by the browser invisibly - the code would appear if I selected the text on the screen and then disappear when de-selected!

First of all I removed the code that is triggered on CTRL+V and SHIFT+INS events and re-instated it but this time triggered on all onpaste events. This worked fine for CTRL+V and SHIFT+INS events but caused a stack overflow error followed by MSIE shutting down, when triggered from the oncontextmenu event. I suppose I should be grateful that it was at least triggered at all! After much scratching of my head I gave up on this approach. I noticed there was some dormant code in editor.js for creating a custom context menu so decided to give it a bash. This seems to have worked but required a lot of extra effort as I have select elements on my page which are no respecters of zIndex and punch right through the context menu div! Got around this though by floating an Iframe under the contextmenu.

All a bit of a mess really. Anyone have a better method?

Regards,

Mat


Luis
Veteran

Nov 18, 2004, 11:34 AM

Post #2 of 7 (4594 views)
Shortcut
Re: [MatRay] Cleanup Code on paste event - dodgy fix! [In reply to] Can't Post

Hi Mat Ray:

It's solved long time ago. Attach your editor and I'll gladly do it for you.

Indeed, you don't need to apply it oncontext menu. You need to apply it only onpaste. This way, the cleanup will be executed everytime some content is pasted in the editor regardless the method used to it.

My mod works with any method of pasting even the browser's bar button. If you are enabling the custom context menu in the original download you'll have a lot of problems besides the zindex issue.


Don't give up!!
http://webstationone.com/test/htmlarea


MatRay
Novice

Nov 18, 2004, 12:00 PM

Post #3 of 7 (4587 views)
Shortcut
Re: [Luis] Cleanup Code on paste event - dodgy fix! [In reply to] Can't Post

Thanks for the kind offer Luis, but whilst my contextmenu code is crude, it does actually work now, and I'm not sure I could face throwing it in the bin just yet - you are right though, I did face quite a few more issues in getting it to work than just the select element problem! What initially appeared to be a snowball sized issue quickly turned into an avalanche. Good learning experience I suppose! That said, I am curious as to how you got the onpaste event to work: I got it to trigger OK but the code caused IE to crash when triggered from the context menu but not when triggered from keyboard shortcuts. My code was essentially just the same as that originally in the script triggered solely by the keyboard shortcuts, so I was at a bit of a loss to explain the problem!

Mat


Luis
Veteran

Nov 18, 2004, 12:18 PM

Post #4 of 7 (4586 views)
Shortcut
Re: [MatRay] Cleanup Code on paste event - dodgy fix! [In reply to] Can't Post

Hi Mat Ray:

It is a very different method to what is used to be, therefore changes are many and difficult to explain. It could take me one hour writing an explanation on what to do and one more hour to you to understand it, while it takes me 5 minutes to integrate it myself.

If you are interested attach your editor and I'll do it for you.


Don't give up!!
http://webstationone.com/test/htmlarea


(This post was edited by Luis on Nov 18, 2004, 12:19 PM)


MatRay
Novice

Nov 18, 2004, 12:32 PM

Post #5 of 7 (4579 views)
Shortcut
Re: [Luis] Cleanup Code on paste event - dodgy fix! [In reply to] Can't Post

That's OK Luis - I appreciate the offer but there's no need - I'll figure it out for myself sooner or later and an explanation from you would spoil the fun even if you did have the time!! If you get a chance and have a copy of your modified script that you could post up that I could look at then that'd be nice but don't worry about it if this is troublesome for you.

Kind regards,

Mat


Luis
Veteran

Nov 19, 2004, 4:32 AM

Post #6 of 7 (4564 views)
Shortcut
Re: [MatRay] Cleanup Code on paste event - dodgy fix! [In reply to] Can't Post

Hi MatRay:

The zip in my test site includes that function.


Don't give up!!
http://webstationone.com/test/htmlarea


MatRay
Novice

Nov 19, 2004, 5:34 AM

Post #7 of 7 (4556 views)
Shortcut
Re: [Luis] Cleanup Code on paste event - dodgy fix! [In reply to] Can't Post

Thanks Luis - I'll take a look at that next week!

Have a good weekend,

Mat

 
 
 


Search for (options)