Ticket #8345: 8345.patch
File 8345.patch, 9.6 KB (added by , 13 years ago) |
---|
-
_source/plugins/menu/plugin.js
112 112 { 113 113 var selection = this.editor.getSelection(); 114 114 115 // Selection will be unavailable after menu shows up116 // in IE, lock it now.117 if ( CKEDITOR.env.ie )118 selection && selection.lock();119 120 115 var element = selection && selection.getStartElement(), 121 116 listeners = this._.listeners, 122 117 includedItems = []; … … 175 170 176 171 onHide : function() 177 172 { 178 if ( CKEDITOR.env.ie )179 {180 var selection = this.editor.getSelection();181 selection && selection.unlock();182 }183 184 173 this.onHide && this.onHide(); 185 174 }, 186 175 -
_source/plugins/dialog/plugin.js
974 974 975 975 var editor = this._.editor; 976 976 editor.focus(); 977 978 if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie ) 979 { 980 var selection = editor.getSelection(); 981 selection && selection.unlock( true ); 982 } 983 } 977 } 984 978 else 985 979 CKEDITOR.dialog._.currentZIndex -= 10; 986 980 … … 3096 3090 */ 3097 3091 openDialog : function( dialogName, callback ) 3098 3092 { 3099 if ( this.mode == 'wysiwyg' && CKEDITOR.env.ie )3100 {3101 var selection = this.getSelection();3102 selection && selection.lock();3103 }3104 3105 3093 var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ], 3106 3094 dialogSkin = this.skin.dialog; 3107 3095 -
_source/plugins/selection/plugin.js
241 241 { 242 242 var doc = editor.document, 243 243 body = doc.getBody(), 244 iframe = new CKEDITOR.dom.element( doc.getWindow().$.frameElement ), 244 245 html = doc.getDocumentElement(); 245 246 246 247 if ( CKEDITOR.env.ie ) … … 249 250 // editor document loose the focus. In IE, we don't 250 251 // have support for it, so we reproduce it here, other 251 252 // than firing the selection change event. 253 var restoreSel = 0; 252 254 253 var savedRange,254 saveEnabled,255 restoreEnabled = 1;256 257 255 // "onfocusin" is fired before "onfocus". It makes it 258 256 // possible to restore the selection before click 259 257 // events get executed. 260 258 body.on( 'focusin', function( evt ) 261 259 { 260 262 261 // If there are elements with layout they fire this event but 263 262 // it must be ignored to allow edit its contents #4682 264 263 if ( evt.data.$.srcElement.nodeName != 'BODY' ) 265 264 return; 266 265 267 // If we have saved a range, restore it at this 268 // point. 269 if ( savedRange ) 270 { 271 if ( restoreEnabled ) 272 { 273 // Well not break because of this. 274 try 275 { 276 savedRange.select(); 277 } 278 catch (e) 279 {} 266 var sel = editor.getSelection(); 280 267 281 // Update locked selection because of the normalized text nodes. (#6083, #6987) 282 var lockedSelection = doc.getCustomData( 'cke_locked_selection' ); 283 if ( lockedSelection ) 284 { 285 lockedSelection.unlock(); 286 lockedSelection.lock(); 287 } 288 } 289 290 savedRange = null; 291 } 268 // If we have a locked selection, restore it at this point. 269 if ( sel.isLocked ) 270 { 271 sel.unlock( restoreSel ); 272 restoreSel = 0; 273 } 292 274 }); 293 275 294 body.on( 'focus', function() 276 // Selection might lose at this point, or not (also triggered when clicking on scrollbar e.g.), 277 // but it's already the last chance for us to know the correct selection, so lock it up now. 278 iframe.on( 'beforedeactivate', function() 295 279 { 296 // Enable selections to be saved. 297 saveEnabled = 1; 280 var doc = editor.document, 281 sel = editor.getSelection(), 282 nativeSel = sel && sel.getNative(); 298 283 299 saveSelection(); 300 }); 284 // There is a very specific case, when clicking 285 // inside a text selection. In that case, the 286 // selection collapses at the clicking point, 287 // but the selection object remains in an 288 // unknown state, making createRange return a 289 // range at the very start of the document. In 290 // such situation we have to test the range, to 291 // be sure it's valid. 292 if ( nativeSel && nativeSel.type == 'None' ) 293 { 294 // The "InsertImage" command can be used to 295 // test whether the selection is good or not. 296 // If not, it's enough to give some time to 297 // IE to put things in order for us. 298 if ( !doc.$.queryCommandEnabled( 'InsertImage' ) ) 299 { 300 CKEDITOR.tools.setTimeout( arguments.callee, 50, this, true ); 301 return; 302 } 303 } 301 304 302 body.on( 'beforedeactivate', function( evt ) 303 { 304 // Ignore this event if it's caused by focus switch between 305 // internal editable control type elements, e.g. layouted paragraph. (#4682) 306 if ( evt.data.$.toElement ) 305 // Avoid saving selection from within text input. (#5747) 306 var parentTag; 307 if ( nativeSel && nativeSel.type && nativeSel.type != 'Control' 308 && ( parentTag = nativeSel.createRange() ) 309 && ( parentTag = parentTag.parentElement() ) 310 && ( parentTag = parentTag.nodeName ) 311 && parentTag.toLowerCase() in { input: 1, textarea : 1 } ) 312 { 307 313 return; 314 } 308 315 309 // Disable selections from being saved. 310 saveEnabled = 0; 311 restoreEnabled = 1; 316 sel.lock(); 312 317 }); 313 318 314 319 // IE before version 8 will leave cursor blinking inside the document after … … 326 331 }); 327 332 } 328 333 329 // Listening on document element ensures that 330 // scrollbar is included. (#5280) 331 html.on( 'mousedown', function() 332 { 333 // Lock restore selection now, as we have 334 // a followed 'click' event which introduce 335 // new selection. (#5735) 336 restoreEnabled = 0; 337 }); 334 // Now we're sure of the selection lost, mark it as to be restored. 335 editor.on( 'blur', function() { restoreSel = 1; } ); 338 336 339 html.on( 'mouseup', function()340 {341 restoreEnabled = 1;342 });343 344 337 // In IE6/7 the blinking cursor appears, but contents are 345 338 // not editable. (#5634) 346 339 if ( CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.version < 8 || CKEDITOR.env.quirks ) ) … … 369 362 if ( sel.type == 'None' ) 370 363 scroll = editor.window.getScrollPosition(); 371 364 } 372 disableSave();373 365 }); 374 366 375 367 body.on( 'mouseup', … … 382 374 editor.document.$.documentElement.scrollTop = scroll.y; 383 375 } 384 376 scroll = null; 385 386 saveEnabled = 1;387 setTimeout( function()388 {389 saveSelection( true );390 },391 0 );392 377 }); 393 378 394 body.on( 'keydown', disableSave );395 body.on( 'keyup',396 function()397 {398 saveEnabled = 1;399 saveSelection();400 });401 402 403 379 // IE is the only to provide the "selectionchange" 404 380 // event. 405 doc.on( 'selectionchange', saveSelection ); 406 407 function disableSave() 408 { 409 saveEnabled = 0; 410 } 411 412 function saveSelection( testIt ) 413 { 414 if ( saveEnabled ) 415 { 416 var doc = editor.document, 417 sel = editor.getSelection(), 418 nativeSel = sel && sel.getNative(); 419 420 // There is a very specific case, when clicking 421 // inside a text selection. In that case, the 422 // selection collapses at the clicking point, 423 // but the selection object remains in an 424 // unknown state, making createRange return a 425 // range at the very start of the document. In 426 // such situation we have to test the range, to 427 // be sure it's valid. 428 if ( testIt && nativeSel && nativeSel.type == 'None' ) 429 { 430 // The "InsertImage" command can be used to 431 // test whether the selection is good or not. 432 // If not, it's enough to give some time to 433 // IE to put things in order for us. 434 if ( !doc.$.queryCommandEnabled( 'InsertImage' ) ) 435 { 436 CKEDITOR.tools.setTimeout( saveSelection, 50, this, true ); 437 return; 438 } 439 } 440 441 // Avoid saving selection from within text input. (#5747) 442 var parentTag; 443 if ( nativeSel && nativeSel.type && nativeSel.type != 'Control' 444 && ( parentTag = nativeSel.createRange() ) 445 && ( parentTag = parentTag.parentElement() ) 446 && ( parentTag = parentTag.nodeName ) 447 && parentTag.toLowerCase() in { input: 1, textarea : 1 } ) 448 { 449 return; 450 } 451 452 savedRange = nativeSel && sel.getRanges()[ 0 ]; 453 454 checkSelectionChangeTimeout.call( editor ); 455 } 456 } 457 } 381 doc.on( 'selectionchange', checkSelectionChangeTimeout, editor ); 382 } 458 383 else 459 384 { 460 385 // In other browsers, we make the selection change