JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.1
[ckeditor.git] / _source / plugins / clipboard / plugin.js
index 51f53e9..3c53ab1 100644 (file)
@@ -214,17 +214,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \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
-                               pastebin.$.focus();\r
-               }\r
+                       pastebin.$.focus();\r
                else\r
                {\r
                        range.setStartAt( pastebin, CKEDITOR.POSITION_AFTER_START );\r
@@ -293,7 +283,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                // keyboard paste or execCommand ) (#4874).\r
                CKEDITOR.env.ie && ( depressBeforeEvent = 1 );\r
 \r
-               var retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED;\r
+               var retval = CKEDITOR.TRISTATE_OFF;\r
+               try { retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; }catch( er ){}\r
+\r
                depressBeforeEvent = 0;\r
                return retval;\r
        }\r
@@ -377,33 +369,42 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                editor.on( 'key', onKey, editor );\r
 \r
-                               var mode = editor.config.forcePasteAsPlainText ? 'text' : 'html';\r
-\r
                                // We'll be catching all pasted content in one line, regardless of whether the\r
                                // it's introduced by a document command execution (e.g. toolbar buttons) or\r
                                // user paste behaviors. (e.g. Ctrl-V)\r
                                editor.on( 'contentDom', function()\r
                                {\r
                                        var body = editor.document.getBody();\r
-                                       body.on( ( ( mode == 'text' && CKEDITOR.env.ie ) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste',\r
-                                               function( evt )\r
+                                       body.on( CKEDITOR.env.webkit ? 'paste' : 'beforepaste', function( evt )\r
                                                {\r
                                                        if ( depressBeforeEvent )\r
                                                                return;\r
 \r
-                                                       getClipboardData.call( editor, evt, mode, function ( data )\r
+                                                       // Fire 'beforePaste' event so clipboard flavor get customized\r
+                                                       // by other plugins.\r
+                                                       var eventData =  { mode : 'html' };\r
+                                                       editor.fire( 'beforePaste', eventData );\r
+\r
+                                                       getClipboardData.call( editor, evt, eventData.mode, function ( data )\r
                                                        {\r
                                                                // The very last guard to make sure the\r
                                                                // paste has successfully happened.\r
-                                                               if ( !CKEDITOR.tools.trim( data.toLowerCase().replace( /<span[^>]+data-cke-bookmark[^<]*?<\/span>/g,'' ) ) )\r
+                                                               if ( !( data = CKEDITOR.tools.trim( data.replace( /<span[^>]+data-cke-bookmark[^<]*?<\/span>/ig,'' ) ) ) )\r
                                                                        return;\r
 \r
                                                                var dataTransfer = {};\r
-                                                               dataTransfer[ mode ] = data;\r
+                                                               dataTransfer[ eventData.mode ] = data;\r
                                                                editor.fire( 'paste', dataTransfer );\r
                                                        } );\r
                                                });\r
 \r
+                                       // Dismiss the (wrong) 'beforepaste' event fired on context menu open. (#7953)\r
+                                       body.on( 'contextmenu', function()\r
+                                       {\r
+                                               depressBeforeEvent = 1;\r
+                                               setTimeout( function() { depressBeforeEvent = 0; }, 10 );\r
+                                       });\r
+\r
                                        body.on( 'beforecut', function() { !depressBeforeEvent && fixCut( editor ); } );\r
 \r
                                        body.on( 'mouseup', function(){ setTimeout( function(){ setToolbarStates.call( editor ); }, 0 ); }, editor );\r