Ticket #6020: 6020_4.patch
File 6020_4.patch, 3.8 KB (added by , 13 years ago) |
---|
-
_source/plugins/clipboard/plugin.js
61 61 var cutCopyCmd = function( type ) 62 62 { 63 63 this.type = type; 64 this.canUndo = ( this.type == 'cut' ); // We can't undo copy to clipboard. 64 this.canUndo = this.type == 'cut'; // We can't undo copy to clipboard. 65 this.startDisabled = true; 65 66 }; 66 67 67 68 cutCopyCmd.prototype = … … 281 282 } 282 283 } 283 284 285 var depressBeforeEvent; 286 function stateFromNamedCommand( command, editor ) 287 { 288 // IE Bug: queryCommandEnabled('paste') fires also 'beforepaste(copy/cut)', 289 // guard to distinguish from the ordinary sources( either 290 // keyboard paste or execCommand ) (#4874). 291 CKEDITOR.env.ie && ( depressBeforeEvent = 1 ); 292 293 var retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; 294 depressBeforeEvent = 0; 295 return retval; 296 } 297 298 var inReadOnly; 299 function setToolbarStates() 300 { 301 if ( this.mode != 'wysiwyg' ) 302 return; 303 304 this.getCommand( 'cut' ).setState( inReadOnly ? CKEDITOR.TRISTATE_DISABLED : stateFromNamedCommand( 'Cut', this ) ); 305 this.getCommand( 'copy' ).setState( stateFromNamedCommand( 'Copy', this ) ); 306 this.getCommand( 'paste' ).setState( inReadOnly ? CKEDITOR.TRISTATE_DISABLED : 307 CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste', this ) ); 308 } 309 284 310 // Register the plugin. 285 311 CKEDITOR.plugins.add( 'clipboard', 286 312 { … … 348 374 editor.on( 'contentDom', function() 349 375 { 350 376 var body = editor.document.getBody(); 351 body.on( ( ( mode == 'text' && CKEDITOR.env.ie ) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste',377 body.on( ( ( mode == 'text' && CKEDITOR.env.ie ) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste', 352 378 function( evt ) 353 379 { 354 380 if ( depressBeforeEvent ) … … 368 394 }); 369 395 370 396 body.on( 'beforecut', function() { !depressBeforeEvent && fixCut( editor ); } ); 397 398 body.on( 'mouseup', setToolbarStates, editor ); 399 editor.on( 'key', setToolbarStates, editor ); 371 400 }); 372 401 402 // For improved performance, we're checking the readOnly state on selectionChange instead of hooking a key event for that. 403 editor.on( 'selectionChange', function( evt ) 404 { 405 inReadOnly = evt.data.selection.getCommonAncestor().isReadOnly(); 406 }); 407 373 408 // If the "contextmenu" plugin is loaded, register the listeners. 374 409 if ( editor.contextMenu ) 375 410 { 376 var depressBeforeEvent;377 function stateFromNamedCommand( command )378 {379 // IE Bug: queryCommandEnabled('paste') fires also 'beforepaste(copy/cut)',380 // guard to distinguish from the ordinary sources( either381 // keyboard paste or execCommand ) (#4874).382 CKEDITOR.env.ie && ( depressBeforeEvent = 1 );383 384 var retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED;385 depressBeforeEvent = 0;386 return retval;387 }388 389 411 editor.contextMenu.addListener( function( element, selection ) 390 412 { 391 413 var readOnly = selection.getCommonAncestor().isReadOnly(); 392 414 return { 393 cut : !readOnly && stateFromNamedCommand( 'Cut' ),394 copy : stateFromNamedCommand( 'Copy' ),395 paste : !readOnly && ( CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste' ) )415 cut : !readOnly && stateFromNamedCommand( 'Cut', editor ), 416 copy : stateFromNamedCommand( 'Copy', editor ), 417 paste : !readOnly && ( CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste', editor ) ) 396 418 }; 397 419 }); 398 420 }