Changeset 1078
- Timestamp:
- 2007-11-14 05:23:44 (2 years ago)
- Location:
- FCKeditor/trunk/editor
- Files:
-
- 2 modified
-
dialog/fck_replace.html (modified) (2 diffs)
-
_source/classes/fckdomrange.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/dialog/fck_replace.html
r1077 r1078 104 104 function GetData( bookmark ) 105 105 { 106 var cur rentNode = oEditor.FCK.EditorDocument.documentElement;107 for ( var i = 0 ; i < bookmark.length ; i++ )108 { 109 if ( currentNode.childNodes.length > bookmark[i] )110 currentNode = currentNode.childNodes.item( bookmark[i] );111 else if ( currentNode.nodeType == 3 ) // text node106 var cursor = oEditor.FCK.EditorDocument.documentElement ; 107 for ( var i = 0 ; i < bookmark.length ; i++ ) 108 { 109 var target = bookmark[i] ; 110 var currentIndex = -1 ; 111 if ( cursor.nodeType != 3 ) 112 112 { 113 var c = currentNode.nodeValue.charAt( bookmark[i] ) ; 114 if ( i == bookmark.length - 1 ) 115 return c != "" ? c : null ; 116 else 113 for (var j = 0 ; j < cursor.childNodes.length ; j++ ) 114 { 115 var candidate = cursor.childNodes[j] ; 116 if ( candidate.nodeType == 3 && 117 candidate.previousSibling && 118 candidate.previousSibling.nodeType == 3 ) 119 continue ; 120 currentIndex++ ; 121 if ( currentIndex == target ) 122 { 123 cursor = candidate ; 124 break ; 125 } 126 } 127 if ( currentIndex < target ) 117 128 return null ; 118 129 } 119 130 else 120 return null; 121 } 122 return currentNode ; 131 { 132 if ( i != bookmark.length - 1 ) 133 return null ; 134 while ( target >= cursor.length && cursor.nextSibling && cursor.nextSibling.nodeType == 3 ) 135 { 136 target -= cursor.length ; 137 cursor = cursor.nextSibling ; 138 } 139 cursor = cursor.nodeValue.charAt( target ) ; 140 if ( cursor == "" ) 141 cursor = null ; 142 } 143 } 144 return cursor ; 123 145 } 124 146 … … 128 150 // See if there's anything further down the tree. 129 151 var next = bookmark.concat( [0] ) ; 130 131 152 if ( GetData( next ) != null ) 132 153 return next ; -
FCKeditor/trunk/editor/_source/classes/fckdomrange.js
r1048 r1078 441 441 "End" : [ this._Range.endOffset ] 442 442 } ; 443 // Since we're treating the document tree as normalized, we need to backtrack the text lengths 444 // of previous text nodes into the offset value. 443 445 var curStart = this._Range.startContainer.previousSibling ; 444 446 var curEnd = this._Range.endContainer.previousSibling ; 447 448 // Also note that the node that we use for "address base" would change during backtracking. 449 var addrStart = this._Range.startContainer ; 450 var addrEnd = this._Range.endContainer ; 445 451 while ( curStart && curStart.nodeType == 3 ) 446 452 { 447 453 bookmark.Start[0] += curStart.length ; 454 addrStart = curStart ; 448 455 curStart = curStart.previousSibling ; 449 456 } … … 451 458 { 452 459 bookmark.End[0] += curEnd.length ; 460 addrEnd = curEnd ; 453 461 curEnd = curEnd.previousSibling ; 454 462 } 455 463 // Then, we record down the precise position of the container nodes 456 464 // by walking up the DOM tree and counting their childNode index 457 bookmark.Start = FCKDomTools.GetNodeAddress( this._Range.startContainer, true ).concat( bookmark.Start ) ;458 bookmark.End = FCKDomTools.GetNodeAddress( this._Range.endContainer, true ).concat( bookmark.End ) ;465 bookmark.Start = FCKDomTools.GetNodeAddress( addrStart, true ).concat( bookmark.Start ) ; 466 bookmark.End = FCKDomTools.GetNodeAddress( addrEnd, true ).concat( bookmark.End ) ; 459 467 return bookmark; 460 468 },