JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1.1
[ckeditor.git] / _source / plugins / clipboard / plugin.js
index d215221..8dbacc6 100644 (file)
@@ -164,6 +164,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                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
@@ -241,7 +254,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        // 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
@@ -305,10 +318,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                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
@@ -356,3 +369,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        }\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