+ // Allow to peek clipboard content by redirecting the\r
+ // pasting content into a temporary bin and grab the content of it.\r
+ function getClipboardData( evt, mode, callback )\r
+ {\r
+ var doc = this.document;\r
+\r
+ // Avoid recursions on 'paste' event for IE.\r
+ if ( CKEDITOR.env.ie && doc.getById( 'cke_pastebin' ) )\r
+ return;\r
+\r
+ var sel = this.getSelection(),\r
+ range = new CKEDITOR.dom.range( doc );\r
+\r
+ // Create container to paste into\r
+ var pastebin = new CKEDITOR.dom.element( mode == 'text' ? 'textarea' : 'div', doc );\r
+ pastebin.setAttribute( 'id', 'cke_pastebin' );\r
+ // Safari requires a filler node inside the div to have the content pasted into it. (#4882)\r
+ CKEDITOR.env.webkit && pastebin.append( doc.createText( '\xa0' ) );\r
+ doc.getBody().append( pastebin );\r
+\r
+ // It's definitely a better user experience if we make the paste-bin pretty unnoticed\r
+ // by pulling it off the screen, while this hack will make the paste-bin a control type element\r
+ // and that become a selection plain later.\r
+ if ( !CKEDITOR.env.ie && mode != 'html' )\r
+ {\r
+ pastebin.setStyles(\r
+ {\r
+ position : 'absolute',\r
+ left : '-1000px',\r
+ // Position the bin exactly at the position of the selected element\r
+ // to avoid any subsequent document scroll.\r
+ top : sel.getStartElement().getDocumentPosition().y + 'px',\r
+ width : '1px',\r
+ height : '1px',\r
+ overflow : 'hidden'\r
+ });\r
+ }\r
+\r
+ var bms = sel.createBookmarks();\r
+\r
+ // Turn off design mode temporarily before give focus to the paste bin.\r
+ if ( mode == 'text' )\r
+ {\r
+ if ( CKEDITOR.env.ie )\r
+ {\r
+ var ieRange = doc.getBody().$.createTextRange();\r
+ ieRange.moveToElementText( pastebin.$ );\r
+ ieRange.execCommand( 'Paste' );\r
+ evt.data.preventDefault();\r
+ }\r
+ else\r
+ {\r
+ doc.$.designMode = 'off';\r
+ pastebin.$.focus();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ range.setStartAt( pastebin, CKEDITOR.POSITION_AFTER_START );\r
+ range.setEndAt( pastebin, CKEDITOR.POSITION_BEFORE_END );\r
+ range.select( true );\r
+ }\r
+\r
+ // Wait a while and grab the pasted contents\r
+ window.setTimeout( function()\r
+ {\r
+ mode == 'text' && !CKEDITOR.env.ie && ( doc.$.designMode = 'on' );\r
+ pastebin.remove();\r
+\r
+ // Grab the HTML contents.\r
+ // We need to look for a apple style wrapper on webkit it also adds\r
+ // a div wrapper if you copy/paste the body of the editor.\r
+ // Remove hidden div and restore selection.\r
+ var bogusSpan;\r
+ pastebin = ( CKEDITOR.env.webkit\r
+ && ( bogusSpan = pastebin.getFirst() )\r
+ && ( bogusSpan.is && bogusSpan.hasClass( 'Apple-style-span' ) ) ?\r
+ bogusSpan : pastebin );\r
+\r
+ sel.selectBookmarks( bms );\r
+ callback( pastebin[ 'get' + ( mode == 'text' ? 'Value' : 'Html' ) ]() );\r
+ }, 0 );\r
+ }\r
+\r