Ticket #8463: 8463.patch
File 8463.patch, 2.9 KB (added by , 12 years ago) |
---|
-
_source/plugins/clipboard/plugin.js
275 275 } 276 276 } 277 277 278 var depressBeforeEvent; 278 var depressBeforeEvent, 279 inReadOnly; 279 280 function stateFromNamedCommand( command, editor ) 280 281 { 281 // IE Bug: queryCommandEnabled('paste') fires also 'beforepaste(copy/cut)', 282 // guard to distinguish from the ordinary sources( either 283 // keyboard paste or execCommand ) (#4874). 284 CKEDITOR.env.ie && ( depressBeforeEvent = 1 ); 282 var retval; 285 283 286 var retval = CKEDITOR.TRISTATE_OFF;287 try { retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; }catch( er ){}284 if ( inReadOnly && command in { Paste : 1, Cut : 1 } ) 285 return CKEDITOR.TRISTATE_DISABLED; 288 286 289 depressBeforeEvent = 0; 290 return retval; 287 if ( command == 'Paste' ) 288 { 289 // IE Bug: queryCommandEnabled('paste') fires also 'beforepaste(copy/cut)', 290 // guard to distinguish from the ordinary sources (either 291 // keyboard paste or execCommand) (#4874). 292 CKEDITOR.env.ie && ( depressBeforeEvent = 1 ); 293 try 294 { 295 // Always return true for Webkit (which always returns false). 296 retval = editor.document.$.queryCommandEnabled( command ) || CKEDITOR.env.webkit; 297 } 298 catch( er ) {} 299 depressBeforeEvent = 0; 300 } 301 // Cut, Copy - check if the selection is not empty 302 else 303 { 304 var ranges = editor.getSelection().getRanges(); 305 retval = !( ranges.length == 1 && ranges[ 0 ].collapsed ); 306 } 307 308 return retval ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; 291 309 } 292 310 293 var inReadOnly;294 311 function setToolbarStates() 295 312 { 296 313 if ( this.mode != 'wysiwyg' ) 297 314 return; 298 315 299 this.getCommand( 'cut' ).setState( inReadOnly ? CKEDITOR.TRISTATE_DISABLED : stateFromNamedCommand( 'Cut', this ) ); 316 var pasteState = stateFromNamedCommand( 'Paste', this ); 317 318 this.getCommand( 'cut' ).setState( stateFromNamedCommand( 'Cut', this ) ); 300 319 this.getCommand( 'copy' ).setState( stateFromNamedCommand( 'Copy', this ) ); 301 var pasteState = inReadOnly ? CKEDITOR.TRISTATE_DISABLED : 302 CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste', this ); 320 this.getCommand( 'paste' ).setState( pasteState ); 303 321 this.fire( 'pasteState', pasteState ); 304 322 } 305 323 … … 451 469 { 452 470 var readOnly = selection.getRanges()[ 0 ].checkReadOnly(); 453 471 return { 454 cut : !readOnly &&stateFromNamedCommand( 'Cut', editor ),472 cut : stateFromNamedCommand( 'Cut', editor ), 455 473 copy : stateFromNamedCommand( 'Copy', editor ), 456 paste : !readOnly && ( CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste', editor ))474 paste : stateFromNamedCommand( 'Paste', editor ) 457 475 }; 458 476 }); 459 477 }