Changeset 1079

Show
Ignore:
Timestamp:
2007-11-14 06:32:18 (2 years ago)
Author:
martinkou
Message:

Fixed the issue where the FCKDomRange.CreateBookmark2() algorithm would return wrong bookmark addresses in IE when the caret is placed just before a text node.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/_source/classes/fckdomrange.js

    r1078 r1079  
    461461                        curEnd = curEnd.previousSibling ; 
    462462                } 
     463 
     464                // If the object pointed to by the startOffset and endOffset are text nodes, we need 
     465                // to backtrack and add in the text offset to the bookmark addresses. 
     466                if ( addrStart.nodeType == 1 && addrStart.childNodes[bookmark.Start[0]].nodeType == 3 ) 
     467                { 
     468                        var curNode = addrStart.childNodes[bookmark.Start[0]] ; 
     469                        var offset = 0 ; 
     470                        while ( curNode.previousSibling && curNode.previousSibling.nodeType == 3 ) 
     471                        { 
     472                                curNode = curNode.previousSibling ; 
     473                                offset += curNode.length ; 
     474                        } 
     475                        addrStart = curNode ; 
     476                        bookmark.Start[0] = offset ; 
     477                } 
     478                if ( addrEnd.nodeType == 1 && addrEnd.childNodes[bookmark.End[0]].nodeType == 3 ) 
     479                { 
     480                        var curNode = addrEnd.childNodes[bookmark.End[0]] ; 
     481                        var offset = 0 ; 
     482                        while ( curNode.previousSibling && curNode.previousSibling.nodeType == 3 ) 
     483                        { 
     484                                curNode = curNode.previousSibling ; 
     485                                offset += curNode.length ; 
     486                        } 
     487                        addrEnd = curNode ; 
     488                        bookmark.End[0] = offset ; 
     489                } 
     490 
    463491                // Then, we record down the precise position of the container nodes 
    464492                // by walking up the DOM tree and counting their childNode index