Changeset 807
- Timestamp:
- 2007-09-13 10:11:42 (15 months ago)
- Location:
- FCKeditor/trunk/editor/_source
- Files:
-
- 5 modified
-
classes/fckdomrange.js (modified) (1 diff)
-
classes/fckw3crange.js (modified) (1 diff)
-
commandclasses/fckjustifycommands.js (modified) (3 diffs)
-
internals/fckdomtools.js (modified) (1 diff)
-
internals/fckselection.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/_source/classes/fckdomrange.js
r803 r807 841 841 842 842 return retval ; 843 }, 844 845 GetText : function() 846 { 847 if ( ! this._Range ) 848 return '' ; 849 return this._Range.toString() ; 843 850 } 844 851 } ; -
FCKeditor/trunk/editor/_source/classes/fckw3crange.js
r806 r807 451 451 var startNode = this.startContainer ; 452 452 var endNode = this.endContainer ; 453 if ( startNode.firstChild && this.startOffset ) 454 startNode = startNode.childNodes[this.startOffset] ; 455 if ( endNode.firstChild && this.endOffset ) 456 endNode = endNode.childNodes[this.endOffset] ; 453 454 // note that it often occurs that startOffset/endOffset goes beyond the end of a container. 455 if ( startNode.firstChild ) 456 { 457 if ( startNode.childNodes[this.startOffset] == null ) 458 startNode = startNode.lastChild ; 459 else 460 startNode = startNode.childNodes[this.startOffset] ; 461 } 462 if ( endNode.firstChild ) 463 { 464 if ( endNode.childNodes[this.endOffset] == null ) 465 endNode = endNode.lastChild ; 466 else 467 endNode = endNode.childNodes[this.endOffset] ; 468 } 457 469 458 470 // Use an array for joining strings for performance. -
FCKeditor/trunk/editor/_source/commandclasses/fckjustifycommands.js
r805 r807 19 19 * == END LICENSE == 20 20 * 21 * FCKJustifyCommand Class: controls textjustification.21 * FCKJustifyCommand Class: controls block justification. 22 22 */ 23 23 … … 35 35 range.MoveToSelection() ; 36 36 var bookmark = range.CreateBookmark() ; 37 range.Expand( 'block_contents' ) ; 38 if ( range.StartContainer == range.Window.document.body ) 39 range.FixBlock( true ) ; 40 range.StartContainer.removeAttribute( 'align' ) ; 37 var paragraphs = range.GetParagraphs() ; 41 38 42 if ( this.CurrentState == FCK_TRISTATE_OFF) 43 range.StartContainer.style.textAlign = this.AlignVaue ; 44 else if ( this.CurrentState == FCK_TRISTATE_ON ) 45 range.StartContainer.style.textAlign = '' ; 39 while ( paragraphs.length > 0 ) 40 { 41 range = paragraphs.shift() ; 42 if ( range.GetText().search( /^[\r\n\t ]*$/ ) == 0 ) 43 continue ; 44 45 if ( range.StartContainer == range.Window.document.body ) 46 range.FixBlock( true ) ; 47 range.StartContainer.removeAttribute( 'align' ) ; 48 49 if ( this.CurrentState == FCK_TRISTATE_OFF) 50 range.StartContainer.style.textAlign = this.AlignVaue ; 51 else if ( this.CurrentState == FCK_TRISTATE_ON ) 52 range.StartContainer.style.textAlign = '' ; 53 54 var nextNode = range.EndNode ; 55 while ( nextNode.lastChild ) 56 nextNode = nextNode.lastChild ; 57 currentNode = nextNode = FCKDomTools.GetNextSourceNode( nextNode ) ; 58 } 46 59 47 60 range.MoveToBookmark( bookmark ) ; … … 58 71 } 59 72 60 var parentEl = FCKSelection.GetParentElement() ; 61 var nearestBlock = parentEl ; 62 while ( nearestBlock ) 63 { 64 if ( FCKListsLib.BlockBoundaries[nearestBlock.nodeName.toLowerCase()] ) 65 break ; 66 nearestBlock = nearestBlock.parentNode ; 67 } 73 var nearestBlock = FCKSelection.GetParentBlock() ; 68 74 69 75 if ( ! nearestBlock ) -
FCKeditor/trunk/editor/_source/internals/fckdomtools.js
r799 r807 316 316 while ( node ) 317 317 { 318 parents. splice( 0, 0,node ) ;318 parents.unshift( node ) ; 319 319 node = node.parentNode ; 320 320 } 321 321 322 322 return parents ; 323 }, 324 325 GetCommonParents : function( node1, node2 ) 326 { 327 var p1 = this.GetParents( node1 ) ; 328 var p2 = this.GetParents( node2 ) ; 329 var retval = [] ; 330 for ( var i = 0 ; i < p1.length ; i++ ) 331 { 332 if ( p1[i] == p2[i] ) 333 retval.push( p1[i] ) ; 334 } 335 return retval ; 336 }, 337 338 GetCommonParentNode : function( node1, node2, tagList ) 339 { 340 var tagMap = {} ; 341 if ( ! tagList.pop ) 342 tagList = [ tagList ] ; 343 while ( tagList.length > 0 ) 344 tagMap[tagList.pop().toLowerCase()] = 1 ; 345 346 var commonParents = this.GetCommonParents( node1, node2 ) ; 347 var currentParent = null ; 348 while ( ( currentParent = commonParents.pop() ) ) 349 { 350 if ( tagMap[currentParent.nodeName.toLowerCase()] ) 351 return currentParent ; 352 } 353 return null ; 323 354 }, 324 355 -
FCKeditor/trunk/editor/_source/internals/fckselection.js
r480 r807 22 22 */ 23 23 24 var FCKSelection = FCK.Selection = new Object() ; 25 24 var FCKSelection = FCK.Selection = 25 { 26 GetParentBlock : function() 27 { 28 var retval = this.GetParentElement() ; 29 while ( retval ) 30 { 31 if ( FCKListsLib.BlockBoundaries[retval.nodeName.toLowerCase()] ) 32 break ; 33 retval = retval.parentNode ; 34 } 35 return retval ; 36 } 37 } ;