Ticket #9175: 9175.patch

File 9175.patch, 3.8 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
     
    430430
    431431                                                                                        // Handle drag directions.
    432432                                                                                        textRng.setEndPoint(
    433                                                                                                 textRng.compareEndPoints( 'StartToStart', rngEnd ) < 0 ?
     433                                                                                                startRng.compareEndPoints( 'StartToStart', rngEnd ) < 0 ?
    434434                                                                                                'EndToEnd' :
    435435                                                                                                'StartToStart',
    436436                                                                                                rngEnd );
     
    440440                                                                                }
    441441                                                                        }
    442442
     443                                                                        function removeListeners()
     444                                                                        {
     445                                                                                html.removeListener( 'mouseleave', onSelectEnd );
     446                                                                                html.removeListener( 'mouseup', onSelectEnd );
     447                                                                        }
     448
     449                                                                        function onSelectEnd()
     450                                                                        {
     451
     452                                                                                html.removeListener( 'mousemove', onHover );
     453                                                                                removeListeners();
     454
     455                                                                                // Make it in effect on mouse up. (#9022)
     456                                                                                textRng.select();
     457                                                                        }
     458
    443459                                                                        evt = evt.data;
    444460
    445461                                                                        // We're sure that the click happens at the region
     
    449465                                                                                // Start to build the text range.
    450466                                                                                var textRng = body.$.createTextRange();
    451467                                                                                moveRangeToPoint( textRng, evt.$.x, evt.$.y );
     468                                                                                // Records the dragging start of the above text range.
     469                                                                                var startRng = textRng.duplicate();
    452470
    453471                                                                                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                                                                                 } );
     472                                                                                html.on( 'mouseleave', onSelectEnd );
     473                                                                                html.on( 'mouseup', onSelectEnd );
    463474                                                                        }
    464475                                                                });
    465476                                                        }
     
    467478                                                        // It's much simpler for IE > 8, we just need to reselect the reported range.
    468479                                                        if ( CKEDITOR.env.ie8 )
    469480                                                        {
    470                                                                 html.on( 'mousedown', function( evt ) {
    471 
     481                                                                html.on( 'mousedown', function( evt )
     482                                                                {
    472483                                                                        if ( evt.data.getTarget().is( 'html' ) )
    473484                                                                        {
    474                                                                                 html.on( 'mouseup', function( evt )
    475                                                                                 {
    476                                                                                         evt.removeListener();
     485                                                                                // Limit the text selection mouse move inside of editable. (#9715)
     486                                                                                html.on( 'mouseleave', onSelectEnd );
     487                                                                                html.on( 'mouseup', onSelectEnd )
     488                                                                        }
     489
     490                                                                });
     491
     492                                                                function removeListeners()
     493                                                                {
     494                                                                        html.removeListener( 'mouseleave', onSelectEnd );
     495                                                                        html.removeListener( 'mouseup', onSelectEnd );
     496                                                                }
    477497
    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                                                                 });
     498                                                                function onSelectEnd()
     499                                                                {
     500                                                                        removeListeners();
     501
     502                                                                        // The event is not fired when clicking on the scrollbars,
     503                                                                        // so we can safely check the following to understand
     504                                                                        // whether the empty space following <body> has been clicked.
     505                                                                                var sel = CKEDITOR.document.$.selection,
     506                                                                                        range = sel.createRange();
     507                                                                                // The selection range is reported on host, but actually it should applies to the content doc.
     508                                                                                if ( sel.type != 'None' && range.parentElement().ownerDocument == doc.$ )
     509                                                                                        range.select();
     510                                                                }
    490511                                                        }
    491512
    492513                                                }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy