Ticket #8812: 8812_2.patch

File 8812_2.patch, 1.3 KB (added by Frederico Caldeira Knabben, 12 years ago)
  • _source/plugins/selection/plugin.js

     
    896896                                                        {
    897897                                                                child = siblings[ siblings.length - 1 ];
    898898
    899                                                                 if ( child.nodeType == CKEDITOR.NODE_ELEMENT )
     899                                                                if ( child.nodeType != CKEDITOR.NODE_TEXT )
    900900                                                                        return { container : parent, offset : siblings.length };
    901901                                                                else
    902902                                                                        return { container : child, offset : child.nodeValue.length };
     
    904904
    905905                                                        // Start the measuring until distance overflows, meanwhile count the text nodes.
    906906                                                        var i = siblings.length;
    907                                                         while ( distance > 0 )
    908                                                                 distance -= siblings[ --i ].nodeValue.length;
     907                                                        while ( distance > 0 && i > 0 )
     908                                                        {
     909                                                                sibling = siblings[ --i ];
     910                                                                if ( sibling.nodeType == CKEDITOR.NODE_TEXT )
     911                                                                {
     912                                                                        child = sibling;
     913                                                                        distance -= sibling.nodeValue.length;
     914                                                                }
     915                                                        }
    909916
    910                                                         return  { container : siblings[ i ], offset : -distance };
     917                                                        return  { container : child, offset : -distance };
    911918                                                }
    912919                                                // Test range was one offset beyond OR behind the anchored text node.
    913920                                                else
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy