Ticket #4881: 4881.patch
File 4881.patch, 2.7 KB (added by , 13 years ago) |
---|
-
_source/plugins/clipboard/plugin.js
68 68 { 69 69 exec : function( editor, data ) 70 70 { 71 this.type == 'cut' && fixCut( editor ); 72 71 73 var success = tryToCutCopy( editor, this.type ); 72 74 73 75 if ( !success ) … … 248 250 }, 0 ); 249 251 } 250 252 253 // Cutting off control type element in IE standards breaks the selection entirely. (#4881) 254 function fixCut( editor ) 255 { 256 if ( !CKEDITOR.env.ie || editor.document.$.compatMode == 'BackCompat' ) 257 return; 258 259 var sel = editor.getSelection(); 260 var control; 261 if( ( sel.getType() == CKEDITOR.SELECTION_ELEMENT ) && ( control = sel.getSelectedElement() ) ) 262 { 263 var range = sel.getRanges()[ 0 ]; 264 var dummy = editor.document.createText( '' ); 265 dummy.insertBefore( control ); 266 range.setStartBefore( dummy ); 267 range.setEndAfter( control ); 268 sel.selectRanges( [ range ] ); 269 270 // Clear up the fix if the paste wasn't succeeded. 271 setTimeout( function() 272 { 273 // Element still online? 274 if ( control.getParent() ) 275 { 276 dummy.remove(); 277 sel.selectElement( control ); 278 } 279 }, 0 ); 280 } 281 } 282 251 283 // Register the plugin. 252 284 CKEDITOR.plugins.add( 'clipboard', 253 285 { … … 318 350 body.on( ( (mode == 'text' && CKEDITOR.env.ie) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste', 319 351 function( evt ) 320 352 { 321 if ( depressBefore PasteEvent )353 if ( depressBeforeEvent ) 322 354 return; 323 355 324 356 getClipboardData.call( editor, evt, mode, function ( data ) … … 334 366 } ); 335 367 }); 336 368 369 body.on( 'beforecut', function() { !depressBeforeEvent && fixCut( editor ); } ); 337 370 }); 338 371 339 372 // If the "contextmenu" plugin is loaded, register the listeners. 340 373 if ( editor.contextMenu ) 341 374 { 342 var depressBefore PasteEvent;375 var depressBeforeEvent; 343 376 function stateFromNamedCommand( command ) 344 377 { 345 // IE Bug: queryCommandEnabled('paste') fires also 'beforepaste ',378 // IE Bug: queryCommandEnabled('paste') fires also 'beforepaste(copy/cut)', 346 379 // guard to distinguish from the ordinary sources( either 347 380 // keyboard paste or execCommand ) (#4874). 348 CKEDITOR.env.ie && command == 'Paste'&& ( depressBeforePasteEvent = 1 );381 CKEDITOR.env.ie && ( depressBeforeEvent = 1 ); 349 382 350 383 var retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; 351 depressBefore PasteEvent = 0;384 depressBeforeEvent = 0; 352 385 return retval; 353 386 } 354 387