Ticket #4611: 4611.patch

File 4611.patch, 1.3 KB (added by garry.yao, 2 years ago)
  • _source/plugins/selection/plugin.js

     
    486486                                                // IE report line break as CRLF with range.text but 
    487487                                                // only LF with textnode.nodeValue, normalize them to avoid 
    488488                                                // breaking character counting logic below. (#3949) 
    489                                                 var distance = testRange.text.replace( /(\r\n|\r)/g, '\n' ).length; 
     489                                                var textInRange = testRange.text, 
     490                                                                htmlInRange = testRange.htmlText, 
     491                                                                distance = textInRange.replace( /(\r\n|\r)/g, '\n' ).length; 
    490492 
     493                                                // Sometimes the above distance is incorrectly counting content within 
     494                                                // uneditable elements (e.g. [<select><option>text</option></select>] 
     495                                                // will be counted up to 4), counting again in with different approach. (#4611) 
     496                                                if( htmlInRange.length != textInRange.length ) 
     497                                                { 
     498                                                        for( var characters = 0; testRange.text.length 
     499                                                                                && testRange.compareEndPoints( 'EndToStart', range ); characters++ ) 
     500                                                                testRange.moveEnd( 'character', -1 ); 
     501 
     502                                                        distance = Math.min( distance, characters ); 
     503                                                } 
     504 
     505 
    491506                                                while ( distance > 0 ) 
    492507                                                        distance -= siblings[ --i ].nodeValue.length; 
    493508 
© 2003 – 2011 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy