Ticket #6020: 6020_5.patch
File 6020_5.patch, 5.2 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 var pasteState = inReadOnly ? CKEDITOR.TRISTATE_DISABLED : 307 CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste', this ); 308 this.fire( 'pasteState', pasteState ); 309 } 310 284 311 // Register the plugin. 285 312 CKEDITOR.plugins.add( 'clipboard', 286 313 { … … 308 335 }, 0 ); 309 336 }); 310 337 338 editor.on( 'pasteState', function( evt ) 339 { 340 editor.getCommand( 'paste' ).setState( evt.data ); 341 }); 342 311 343 function addButtonCommand( buttonName, commandName, command, ctxMenuOrder ) 312 344 { 313 345 var lang = editor.lang[ commandName ]; … … 348 380 editor.on( 'contentDom', function() 349 381 { 350 382 var body = editor.document.getBody(); 351 body.on( ( ( mode == 'text' && CKEDITOR.env.ie ) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste',383 body.on( ( ( mode == 'text' && CKEDITOR.env.ie ) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste', 352 384 function( evt ) 353 385 { 354 386 if ( depressBeforeEvent ) … … 368 400 }); 369 401 370 402 body.on( 'beforecut', function() { !depressBeforeEvent && fixCut( editor ); } ); 403 404 body.on( 'mouseup', setToolbarStates, editor ); 405 body.on( 'keyup', setToolbarStates, editor ); 371 406 }); 372 407 408 // For improved performance, we're checking the readOnly state on selectionChange instead of hooking a key event for that. 409 editor.on( 'selectionChange', function( evt ) 410 { 411 inReadOnly = evt.data.selection.getCommonAncestor().isReadOnly(); 412 }); 413 373 414 // If the "contextmenu" plugin is loaded, register the listeners. 374 415 if ( editor.contextMenu ) 375 416 { 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 417 editor.contextMenu.addListener( function( element, selection ) 390 418 { 391 419 var readOnly = selection.getCommonAncestor().isReadOnly(); 392 420 return { 393 cut : !readOnly && stateFromNamedCommand( 'Cut' ),394 copy : stateFromNamedCommand( 'Copy' ),395 paste : !readOnly && ( CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste' ) )421 cut : !readOnly && stateFromNamedCommand( 'Cut', editor ), 422 copy : stateFromNamedCommand( 'Copy', editor ), 423 paste : !readOnly && ( CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste', editor ) ) 396 424 }; 397 425 }); 398 426 } -
_source/plugins/pastefromword/plugin.js
47 47 command : 'pastefromword' 48 48 }); 49 49 50 editor.on( 'pasteState', function( evt ) 51 { 52 editor.getCommand( 'pastefromword' ).setState( evt.data ); 53 }); 54 50 55 editor.on( 'paste', function( evt ) 51 56 { 52 57 var data = evt.data, … … 93 98 } 94 99 95 100 return !isLoaded; 96 } 101 }, 102 103 requires : [ 'clipboard' ] 97 104 }); 98 105 })(); 99 106 -
_source/plugins/pastetext/plugin.js
65 65 } 66 66 }, null, null, 0 ); 67 67 } 68 69 editor.on( 'pasteState', function( evt ) 70 { 71 editor.getCommand( 'pastetext' ).setState( evt.data ); 72 }); 68 73 }, 69 74 70 75 requires : [ 'clipboard' ]