Changeset 969
- Timestamp:
- 2007-10-04 06:12:46 (2 years ago)
- Location:
- FCKeditor/trunk/editor/_source
- Files:
-
- 4 modified
-
classes/fckdomrange.js (modified) (2 diffs)
-
commandclasses/fckjustifycommands.js (modified) (1 diff)
-
internals/fckdomtools.js (modified) (2 diffs)
-
internals/fckundo.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/_source/classes/fckdomrange.js
r906 r969 369 369 "End" : [ this._Range.endOffset ] 370 370 } ; 371 var curStart = this._Range.startContainer.previousSibling ; 372 var curEnd = this._Range.endContainer.previousSibling ; 373 while ( curStart && curStart.nodeType == 3 ) 374 { 375 bookmark.Start[0] += curStart.length ; 376 curStart = curStart.previousSibling ; 377 } 378 while ( curEnd && curEnd.nodeType == 3 ) 379 { 380 bookmark.End[0] += curEnd.length ; 381 curEnd = curEnd.previousSibling ; 382 } 371 383 // Then, we record down the precise position of the container nodes 372 384 // by walking up the DOM tree and counting their childNode index 373 bookmark.Start = FCKDomTools.GetNodeAddress( this._Range.startContainer ).concat( bookmark.Start ) ;374 bookmark.End = FCKDomTools.GetNodeAddress( this._Range.endContainer ).concat( bookmark.End ) ;385 bookmark.Start = FCKDomTools.GetNodeAddress( this._Range.startContainer, true ).concat( bookmark.Start ) ; 386 bookmark.End = FCKDomTools.GetNodeAddress( this._Range.endContainer, true ).concat( bookmark.End ) ; 375 387 return bookmark; 376 388 }, … … 379 391 { 380 392 // Reverse the childNode counting algorithm in CreateBookmark2() 381 var curStart = FCKDomTools.GetNodeFromAddress( this.Window.document, bookmark.Start.slice( 0, -1 ) ) ;382 var curEnd = FCKDomTools.GetNodeFromAddress( this.Window.document, bookmark.End.slice( 0, -1 ) ) ;393 var curStart = FCKDomTools.GetNodeFromAddress( this.Window.document, bookmark.Start.slice( 0, -1 ), true ) ; 394 var curEnd = FCKDomTools.GetNodeFromAddress( this.Window.document, bookmark.End.slice( 0, -1 ), true ) ; 383 395 384 396 // Generate the W3C Range object and update relevant data 385 397 this.Release( true ) ; 386 398 this._Range = new FCKW3CRange( this.Window.document ) ; 387 this._Range.setStart( curStart, bookmark.Start[ bookmark.Start.length - 1 ] ) ; 388 this._Range.setEnd( curEnd, bookmark.End[ bookmark.End.length - 1 ] ) ; 399 var startOffset = bookmark.Start[ bookmark.Start.length - 1 ] ; 400 var endOffset = bookmark.End[ bookmark.End.length - 1 ] ; 401 while ( curStart.nodeType == 3 && startOffset > curStart.length ) 402 { 403 if ( ! curStart.nextSibling || curStart.nextSibling.nodeType != 3 ) 404 break ; 405 startOffset -= curStart.length ; 406 curStart = curStart.nextSibling ; 407 } 408 while ( curEnd.nodeType == 3 && endOffset > curEnd.length ) 409 { 410 if ( ! curEnd.nextSibling || curEnd.nextSibling.nodeType != 3 ) 411 break ; 412 endOffset -= curEnd.length ; 413 curEnd = curEnd.nextSibling ; 414 } 415 this._Range.setStart( curStart, startOffset ) ; 416 this._Range.setEnd( curEnd, endOffset ) ; 389 417 this._UpdateElementInfo() ; 390 418 }, -
FCKeditor/trunk/editor/_source/commandclasses/fckjustifycommands.js
r968 r969 30 30 this.IsDefaultAlign = ( alignValue == 'left' && contentDir == 'ltr' ) || 31 31 ( alignValue == 'right' && contentDir == 'rtl' ) ; 32 33 34 32 35 33 // Get the class name to be used by this instance. -
FCKeditor/trunk/editor/_source/internals/fckdomtools.js
r922 r969 550 550 * The tree address cannot be used for finding back the DOM tree node once the DOM tree structure has been modified. 551 551 */ 552 GetNodeAddress : function( node )552 GetNodeAddress : function( node, normalized ) 553 553 { 554 554 var retval = [] ; 555 555 while ( node && node != node.ownerDocument.documentElement ) 556 556 { 557 retval.unshift( this.GetIndexOf( node ) ) ; 557 var parentNode = node.parentNode ; 558 var currentIndex = -1 ; 559 for( var i = 0 ; i < parentNode.childNodes.length ; i++ ) 560 { 561 var candidate = parentNode.childNodes[i] ; 562 if ( normalized === true && 563 candidate.nodeType == 3 && 564 candidate.previousSibling && 565 candidate.previousSibling.nodeType == 3 ) 566 continue; 567 currentIndex++ ; 568 if ( parentNode.childNodes[i] == node ) 569 break ; 570 } 571 retval.unshift( currentIndex ) ; 558 572 node = node.parentNode ; 559 573 } … … 565 579 * index address. 566 580 */ 567 GetNodeFromAddress : function( doc, addr )581 GetNodeFromAddress : function( doc, addr, normalized ) 568 582 { 569 583 var cursor = doc.documentElement ; 570 584 for ( var i = 0 ; i < addr.length ; i++ ) 571 cursor = cursor.childNodes[ addr[i] ] ; 585 { 586 var target = addr[i] ; 587 if ( ! normalized ) 588 { 589 cursor = cursor.childNodes[target] ; 590 continue ; 591 } 592 593 var currentIndex = -1 ; 594 for (var j = 0 ; j < cursor.childNodes.length ; j++ ) 595 { 596 var candidate = cursor.childNodes[j] ; 597 if ( normalized === true && 598 candidate.nodeType == 3 && 599 candidate.previousSibling && 600 candidate.previousSibling.nodeType == 3 ) 601 continue ; 602 currentIndex++ ; 603 if ( currentIndex == target ) 604 { 605 cursor = candidate ; 606 break ; 607 } 608 } 609 } 572 610 return cursor ; 573 611 }, -
FCKeditor/trunk/editor/_source/internals/fckundo.js
r936 r969 31 31 FCKUndo._GetBookmark = function() 32 32 { 33 if ( ! FCKBrowserInfo.IsIE )34 FCK.EditorDocument.body.normalize() ;35 33 var range = new FCKDomRange( FCK.EditorWindow ) ; 36 34 try