| Page 1 of 4 | [ 32 posts ] | Go to page 1, 2, 3, 4 Next |
|
We were able to do this in YUI2. I had a plug-in I downloaded that attached to different events. For IE, it would attach to onbeforepaste for instance. It then inserted a fake node and focused to make sure the text ended up in that fake node.
I'm actually trying to get it to work again but can only successfully do it on FF for all markup. In Safari and IE, when the markup gets crazy, it only strips the first few images and whatnot. I basically now run a line like this: Code: TE.yeditor.execCommand( 'insertandfocus', str ); The pasted text then goes into that container. I get the reference to it and then do a lot of regex replacing. Some is pasted from YUI2's function, some from the plug-in, and some additional stuff I added in. Dav, do you have any idea why it would work flawlessly in FF but then cut out halfway for "harder" markup in the other browsers? I tried with text from Facebook and CNN. It appears to really hate if an input field is pasted in. |
|
Without seeing it run, I can't give you a definite answer. But I would guess you have a race condition going on. The content getting pasted hasn't finished yet when it's being processed.
|
|
Okay this is interesting. If I paste the "simple" text in, Cleaner's HTML console.logs perfectly. When I paste two tweets in, it console logs as blank and I can see the full HTML in the editor. You can clearly see I've had quirky issues in past with what is in cleaner so I'm going to play with that some. Let me know if this jogs your memory some. I'll keep you posted on any solution I find so other users can take advantage too
Code: CleanPaste.prototype.InsertContainer = function( e ) { // quirk var str = ( ( $.browser.msie && parseInt($.browser.version) >= 8.0 ) ) ? "<span id='Cleaner'> </span>" : '<div id="Cleaner">_</div>'; TE.yeditor.execCommand( 'insertandfocus', str ); console.log('inserted'); }; Code: CleanPaste.prototype.CleanPaste = function() { console.log('html test: ', this.doc.getElementById("Cleaner").innerHTML ); }; Code: CleanPaste.prototype.handleKeyDown = function(e) { // in my code this is actual logic if ( copy_pasted ) { console.log( 'insert container'); this.InsertContainer( e ); setTimeout(function() { console.log('clean paste' ); _this.CleanPaste(); }, 10); } }; |
|
Increasing timeout to 150 didn't help btw
|
|
Oh boy. It looks like Firefox fixes invalid HTML on paste. If I paste the same thing everytime into Chrome, I get a small amount of markup. If I then do this bad string for cleaner:
<div id="Cleaner"><div>_</div> It actually console logs the whole block. |
|
Looks like I have to give up. My last post seems to be wrong. It really dependso n the markup but I can't pinpoint it. With another copy-paste sample I had it so everytime I hit ctrl+a ctrl+v it would alternate removing the markup or not removing it, even though clearly ctrl+a selects everything to overwite.
I'm at an insane loss |
|
Working with Copy Paste is a nightmare. Just working with Ctrl+A/C is not enough. What about Macs? What about right clicking? What about Edit > Copy menu interactions?
There are tons of things there. The other issue, is that some OSes clipboards are limited or special. They tend to change the content on the fly depending on where it's being pasted. For example. Copy some rich markup, then paste that into a textarea. The markup will go away and you will get plain text. But pasting that into something like Word, you will get rich markup. The clipboard is intentionally hard to work with due to the massive security implications that it exposes. For example, what if you went to your banking site and copied your current bank info to your clipboard. Then visited my site and i read your clipboard. I now have access to that data. So they limited it and added a DOMPaste event (which Editor tries to fix a little). You should be able to listen to the "dom:paste" event on the Editor instance to be notified when a paste occurred. When, and if, I decide to write a clipboard module for Editor, it will likely be a toolbar button that loads another iframe into a modal dialog. They paste into that, then I clean and inject the content where the cursor was positioned. That's about the most reliable way to deal with it. |
|
I know ctrl+a is not the only way. I'm just using that as the simplest example. I'm currently catching it in a number of ways, but I'm gonna try out the dom:paste event and see if that will work properly.
It's just super frustrating since my node is clearly inserted before paste, and at least some of the pasted content is getting in there. I've tried removing setTimeout and increasing it with no luck. Going to keep my fingers crossed on the dom event you mentioned. |
|
dom:paste works in FF but not Chrome still. I tried dom:beforepaste for kicks, not knowing if you did that or not, and I'm guessing you didn't. You are so correct about nightmares
|
|
What exactly goes on during insertandfocus? Are there any setTimeouts in there?
|
| Page 1 of 4 | [ 32 posts ] | Go to page 1, 2, 3, 4 Next |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group