}\r
};\r
\r
+ function cancel( evt ) { evt.cancel(); }\r
+\r
// 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 bms = sel.createBookmarks();\r
\r
+ this.on( 'selectionChange', cancel, null, null, 0 );\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
- pastebin.$.focus();\r
- }\r
+ pastebin.$.focus();\r
else\r
{\r
range.setStartAt( pastebin, CKEDITOR.POSITION_AFTER_START );\r
{\r
mode == 'text' && CKEDITOR.env.gecko && editor.focusGrabber.focus();\r
pastebin.remove();\r
+ editor.removeListener( 'selectionChange', cancel );\r
\r
// Grab the HTML contents.\r
// We need to look for a apple style wrapper on webkit it also adds\r
// 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
else if ( data[ 'text' ] )\r
editor.insertText( data[ 'text' ] );\r
\r
+ setTimeout( function () { editor.fire( 'afterPaste' ); }, 0 );\r
+\r
}, null, null, 1000 );\r
\r
editor.on( 'pasteDialog', function( evt )\r
\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 ( !data )\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