Ticket #9175: 9175_2.patch

File 9175_2.patch, 4.0 KB (added by Garry Yao, 12 years ago)
  • _source/plugins/selection/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    263263                        editor.on( 'contentDom', function()
    264264                                {
    265265                                        var doc = editor.document,
     266                                                outerDoc = CKEDITOR.document,
    266267                                                body = doc.getBody(),
    267268                                                html = doc.getDocumentElement();
    268269
     
    430431
    431432                                                                                        // Handle drag directions.
    432433                                                                                        textRng.setEndPoint(
    433                                                                                                 textRng.compareEndPoints( 'StartToStart', rngEnd ) < 0 ?
     434                                                                                                startRng.compareEndPoints( 'StartToStart', rngEnd ) < 0 ?
    434435                                                                                                'EndToEnd' :
    435436                                                                                                'StartToStart',
    436437                                                                                                rngEnd );
     
    440441                                                                                }
    441442                                                                        }
    442443
     444                                                                        function removeListeners()
     445                                                                        {
     446                                                                                outerDoc.removeListener( 'mouseup', onSelectEnd );
     447                                                                                html.removeListener( 'mouseup', onSelectEnd );
     448                                                                        }
     449
     450                                                                        function onSelectEnd()
     451                                                                        {
     452
     453                                                                                html.removeListener( 'mousemove', onHover );
     454                                                                                removeListeners();
     455
     456                                                                                // Make it in effect on mouse up. (#9022)
     457                                                                                textRng.select();
     458                                                                        }
     459
    443460                                                                        evt = evt.data;
    444461
    445462                                                                        // We're sure that the click happens at the region
     
    449466                                                                                // Start to build the text range.
    450467                                                                                var textRng = body.$.createTextRange();
    451468                                                                                moveRangeToPoint( textRng, evt.$.x, evt.$.y );
     469                                                                                // Records the dragging start of the above text range.
     470                                                                                var startRng = textRng.duplicate();
    452471
    453472                                                                                html.on( 'mousemove', onHover );
    454 
    455                                                                                 html.on( 'mouseup', function( evt )
    456                                                                                 {
    457                                                                                         html.removeListener( 'mousemove', onHover );
    458                                                                                         evt.removeListener();
    459 
    460                                                                                         // Make it in effect on mouse up. (#9022)
    461                                                                                         textRng.select();
    462                                                                                 } );
     473                                                                                outerDoc.on( 'mouseup', onSelectEnd );
     474                                                                                html.on( 'mouseup', onSelectEnd );
    463475                                                                        }
    464476                                                                });
    465477                                                        }
     
    467479                                                        // It's much simpler for IE > 8, we just need to reselect the reported range.
    468480                                                        if ( CKEDITOR.env.ie8 )
    469481                                                        {
    470                                                                 html.on( 'mousedown', function( evt ) {
    471 
     482                                                                html.on( 'mousedown', function( evt )
     483                                                                {
    472484                                                                        if ( evt.data.getTarget().is( 'html' ) )
    473485                                                                        {
    474                                                                                 html.on( 'mouseup', function( evt )
    475                                                                                 {
    476                                                                                         evt.removeListener();
     486                                                                                // Limit the text selection mouse move inside of editable. (#9715)
     487                                                                                outerDoc.on( 'mouseup', onSelectEnd );
     488                                                                                html.on( 'mouseup', onSelectEnd )
     489                                                                        }
     490
     491                                                                });
     492
     493                                                                function removeListeners()
     494                                                                {
     495                                                                        outerDoc.removeListener( 'mouseup', onSelectEnd );
     496                                                                        html.removeListener( 'mouseup', onSelectEnd );
     497                                                                }
    477498
    478                                                                                         // The event is not fired when clicking on the scrollbars,
    479                                                                                         // so we can safely check the following to understand
    480                                                                                         // whether the empty space following <body> has been clicked.
    481                                                                                                 var sel = CKEDITOR.document.$.selection,
    482                                                                                                         range = sel.createRange();
    483                                                                                                 // The selection range is reported on host, but actually it should applies to the content doc.
    484                                                                                                 if ( sel.type != 'None' && range.parentElement().ownerDocument == doc.$ )
    485                                                                                                         range.select();
    486                                                                                 } );
    487                                                                         }
    488 
    489                                                                 });
     499                                                                function onSelectEnd()
     500                                                                {
     501                                                                        removeListeners();
     502
     503                                                                        // The event is not fired when clicking on the scrollbars,
     504                                                                        // so we can safely check the following to understand
     505                                                                        // whether the empty space following <body> has been clicked.
     506                                                                                var sel = CKEDITOR.document.$.selection,
     507                                                                                        range = sel.createRange();
     508                                                                                // The selection range is reported on host, but actually it should applies to the content doc.
     509                                                                                if ( sel.type != 'None' && range.parentElement().ownerDocument == doc.$ )
     510                                                                                        range.select();
     511                                                                }
    490512                                                        }
    491513
    492514                                                }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy