Ticket #5735: 5735_2.patch

File 5735_2.patch, 2.5 KB (added by Frederico Caldeira Knabben, 14 years ago)
  • _source/plugins/selection/plugin.js

     
    105105                        editor.on( 'contentDom', function()
    106106                                {
    107107                                        var doc = editor.document,
    108                                                 body = doc.getBody();
     108                                                body = doc.getBody(),
     109                                                html = doc.getDocumentElement();
    109110
    110111                                        if ( CKEDITOR.env.ie )
    111112                                        {
     
    115116                                                // than firing the selection change event.
    116117
    117118                                                var savedRange,
    118                                                         saveEnabled;
     119                                                        saveEnabled,
     120                                                        restoreEnabled = 1;
    119121
    120122                                                // "onfocusin" is fired before "onfocus". It makes it
    121123                                                // possible to restore the selection before click
     
    131133                                                                // point.
    132134                                                                if ( savedRange )
    133135                                                                {
    134                                                                         // Well not break because of this.
    135                                                                         try
     136                                                                        if ( restoreEnabled )
    136137                                                                        {
    137                                                                                 savedRange.select();
     138                                                                                // Well not break because of this.
     139                                                                                try
     140                                                                                {
     141                                                                                        savedRange.select();
     142                                                                                }
     143                                                                                catch (e)
     144                                                                                {}
    138145                                                                        }
    139                                                                         catch (e)
    140                                                                         {}
    141146
    142147                                                                        savedRange = null;
    143148                                                                }
     
    160165
    161166                                                                // Disable selections from being saved.
    162167                                                                saveEnabled = false;
     168                                                                restoreEnabled = 1;
    163169                                                        });
    164170
    165171                                                // IE before version 8 will leave cursor blinking inside the document after
    166172                                                // editor blurred unless we clean up the selection. (#4716)
    167173                                                if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 )
    168174                                                {
    169                                                         doc.getWindow().on( 'blur', function( evt )
     175                                                        editor.on( 'blur', function( evt )
    170176                                                        {
    171177                                                                editor.document.$.selection.empty();
    172178                                                        });
    173179                                                }
    174180
     181                                                // Listening on document element ensures that
     182                                                // scrollbar is included. (#5280)
     183                                                html.on( 'mousedown', function ()
     184                                                {
     185                                                        // Lock restore selection now, as we have
     186                                                        // a followed 'click' event which introduce
     187                                                        // new selection. (#5735)
     188                                                        restoreEnabled = 0;
     189                                                });
     190
     191                                                html.on( 'mouseup', function ()
     192                                                {
     193                                                        restoreEnabled = 1;
     194                                                });
     195
    175196                                                // IE fires the "selectionchange" event when clicking
    176197                                                // inside a selection. We don't want to capture that.
    177                                                 body.on( 'mousedown', disableSave );
     198                                                body.on( 'mousedown', function ()
     199                                                {
     200                                                        disableSave();
     201                                                });
     202
    178203                                                body.on( 'mouseup',
    179204                                                        function()
    180205                                                        {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy