// the command to execute.\r
body.on( command, onExec );\r
\r
- doc.$.execCommand( command );\r
+ // IE6/7: document.execCommand has problem to paste into positioned element.\r
+ ( CKEDITOR.env.version > 7 ? doc.$ : doc.$.selection.createRange() ) [ 'execCommand' ]( command );\r
\r
body.removeListener( command, onExec );\r
\r
if ( CKEDITOR.env.ie && doc.getById( 'cke_pastebin' ) )\r
return;\r
\r
+ // If the browser supports it, get the data directly\r
+ if (mode == 'text' && evt.data && evt.data.$.clipboardData)\r
+ {\r
+ // evt.data.$.clipboardData.types contains all the flavours in Mac's Safari, but not on windows.\r
+ var plain = evt.data.$.clipboardData.getData( 'text/plain' );\r
+ if (plain)\r
+ {\r
+ evt.data.preventDefault();\r
+ callback( plain );\r
+ return;\r
+ }\r
+ }\r
+\r
var sel = this.getSelection(),\r
range = new CKEDITOR.dom.range( doc );\r
\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
+ // by pulling it off the screen.\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
var bms = sel.createBookmarks();\r
\r
// Register the plugin.\r
CKEDITOR.plugins.add( 'clipboard',\r
{\r
- requires : [ 'htmldataprocessor' ],\r
+ requires : [ 'dialog', 'htmldataprocessor' ],\r
init : function( editor )\r
{\r
// Inserts processed data into the editor at the end of the\r
editor.on( 'contentDom', function()\r
{\r
var body = editor.document.getBody();\r
- body.on( ( mode == 'text' && CKEDITOR.env.ie ) ? 'paste' : 'beforepaste',\r
+ body.on( ( (mode == 'text' && CKEDITOR.env.ie) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste',\r
function( evt )\r
{\r
- if( depressBeforePasteEvent )\r
+ if ( depressBeforePasteEvent )\r
return;\r
\r
getClipboardData.call( editor, evt, mode, function ( data )\r
}\r
});\r
})();\r
+\r
+/**\r
+ * Fired when a clipboard operation is about to be taken into the editor.\r
+ * Listeners can manipulate the data to be pasted before having it effectively\r
+ * inserted into the document.\r
+ * @name CKEDITOR.editor#paste\r
+ * @since 3.1\r
+ * @event\r
+ * @param {String} [data.html] The HTML data to be pasted. If not available, e.data.text will be defined.\r
+ * @param {String} [data.text] The plain text data to be pasted, available when plain text operations are to used. If not available, e.data.html will be defined.\r
+ */\r