X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fselection%2Fplugin.js;h=3a0a181d2954b6a2d96b8c64f326da8480b884fd;hp=aff5ba2b1ab44e4d070f720a45cea91539d14774;hb=6e682412d5cc0dfaedb376482e585bf2989c6863;hpb=2f22c0c38f17e75be5541089076885442aaa2377 diff --git a/_source/plugins/selection/plugin.js b/_source/plugins/selection/plugin.js index aff5ba2..3a0a181 100644 --- a/_source/plugins/selection/plugin.js +++ b/_source/plugins/selection/plugin.js @@ -414,10 +414,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) && doc.$.compatMode != 'BackCompat' ) { - html.on( 'mousedown', function( evt ) + function moveRangeToPoint( range, x, y ) { - evt = evt.data.$; + // Error prune in IE7. (#9034, #9110) + try { range.moveToPoint( x, y ); } catch ( e ) {} + } + html.on( 'mousedown', function( evt ) + { // Expand the text range along with mouse move. function onHover( evt ) { @@ -426,7 +430,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { // Read the current cursor. var rngEnd = body.$.createTextRange(); - rngEnd.moveToPoint( evt.x, evt.y ); + + moveRangeToPoint( rngEnd, evt.x, evt.y ); // Handle drag directions. textRng.setEndPoint( @@ -440,6 +445,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } } + evt = evt.data.$; + // We're sure that the click happens at the region // below body, but not on scrollbar. if ( evt.y < html.$.clientHeight @@ -448,8 +455,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { // Start to build the text range. var textRng = body.$.createTextRange(); - textRng.moveToPoint( evt.x, evt.y ); - textRng.select(); + moveRangeToPoint( textRng, evt.x, evt.y ); html.on( 'mousemove', onHover ); @@ -457,8 +463,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { html.removeListener( 'mousemove', onHover ); evt.removeListener(); + + // Make it in effect on mouse up. (#9022) textRng.select(); - textRng = null; } ); } }); @@ -585,7 +592,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license command : 'selectAll' }); - editor.selectionChange = checkSelectionChangeTimeout; + /** + * Check if to fire the {@link CKEDITOR.editor#selectionChange} event + * for the current editor instance. + * + * @param {Boolean} checkNow Check immediately without any delay. + */ + editor.selectionChange = function( checkNow ) + { + ( checkNow ? checkSelectionChange : checkSelectionChangeTimeout ).call( this ); + }; // IE9 might cease to work if there's an object selection inside the iframe (#7639). CKEDITOR.env.ie9Compat && editor.on( 'destroy', function() @@ -1435,8 +1451,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license this.isLocked = 0; this.reset(); - doc.getBody().focus(); - if ( selectedElement ) this.selectElement( selectedElement ); else