- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/_source/classes/fckstyle.js
r1378 r1398 95 95 * Apply the style to a FCKDomRange. 96 96 */ 97 ApplyToRange : function( range, selectIt )97 ApplyToRange : function( range, selectIt, updateRange ) 98 98 { 99 99 // ApplyToRange is not valid for FCK_STYLE_OBJECT types. … … 112 112 } 113 113 114 this.ApplyToRange( range, selectIt ) ;114 this.ApplyToRange( range, selectIt, updateRange ) ; 115 115 }, 116 116 … … 142 142 * effect. 143 143 */ 144 RemoveFromRange : function( range, selectIt )144 RemoveFromRange : function( range, selectIt, updateRange ) 145 145 { 146 146 var bookmark ; … … 277 277 range.SelectBookmark( bookmark ) ; 278 278 279 return ; 279 if ( updateRange ) 280 range.MoveToBookmark( bookmark ) ; 280 281 } 281 282 … … 402 403 if ( selectIt ) 403 404 range.SelectBookmark( bookmark ) ; 405 406 if ( updateRange ) 407 range.MoveToBookmark( bookmark ) ; 404 408 }, 405 409 … … 750 754 * - Properly handle block containers like <div> and <blockquote>. 751 755 */ 752 _ApplyBlockStyle : function( range, selectIt )756 _ApplyBlockStyle : function( range, selectIt, updateRange ) 753 757 { 754 758 // Bookmark the range so we can re-select it after processing. … … 769 773 // Move everything from the current node to the new one. 770 774 FCKDomTools.MoveChildren( block, newBlock ) ; 775 776 // If we're in a non-IE browser, and the newBlock is <pre>, and the old block is not <pre>, 777 // then we need to clear linebreaks and compress ANSI whitespaces so that we don't get disrupted 778 // output in <pre> mode. (Bug #1355) 779 if ( !FCKBrowserInfo.IsIE && newBlock.nodeName.IEquals( 'pre' ) && !block.nodeName.IEquals( 'pre' ) ) 780 { 781 // If the newBlock's first child is a text node, left-trim it since any ANSI whitespace 782 // after a non-pre block is meaningless. 783 if ( newBlock.firstChild && newBlock.firstChild.nodeType == 3 ) 784 newBlock.firstChild.nodeValue = newBlock.firstChild.nodeValue.LTrim() ; 785 786 // Ditto for the last child. 787 if ( newBlock.lastChild && newBlock.lastChild.nodeType == 3 ) 788 newBlock.lastChild.nodeValue = newBlock.lastChild.nodeValue.RTrim() ; 789 790 // DFS walk the newBlock to compress ANSI whitespaces and delete excessive linebreaks. 791 var currentNode = newBlock ; 792 while ( currentNode ) 793 { 794 currentNode = FCKDomTools.GetNextSourceNode( currentNode, false, 3, newBlock.parentNode ) ; 795 if ( currentNode ) 796 { 797 // If the text node ends with a line break, and its next sibling is a <BR>, 798 // then right-trim the text node. 799 if ( currentNode.nodeValue.charAt( currentNode.nodeValue.length - 1 ) == '\n' 800 && currentNode.nextSibling 801 && currentNode.nextSibling.nodeName.IEquals( 'br' ) ) 802 currentNode.nodeValue = currentNode.nodeValue.RTrim() ; 803 // If the text node begins with a line break, and its next sibling is a <BR>, 804 // then left-trim the text node. 805 if ( currentNode.nodeValue.charAt( 0 ) == '\n' 806 && currentNode.previousSibling 807 && currentNode.previousSibling.nodeName.IEquals( 'br' ) ) 808 currentNode.nodeValue = currentNode.nodeValue.LTrim() ; 809 // Compress any ANSI whitespaces left. 810 currentNode.nodeValue = currentNode.nodeValue.replace( /[\r\n\t ]+/g, ' ' ) ; 811 } 812 } 813 } 771 814 772 815 // Delete the current node. … … 777 820 if ( selectIt ) 778 821 range.SelectBookmark( bookmark ) ; 822 823 if ( updateRange ) 824 range.MoveToBookmark( range ) ; 779 825 }, 780 826 … … 789 835 * <span style="color: #ff0000;"><span style="background-color: #ffffff">XYZ</span></span> 790 836 */ 791 _ApplyInlineStyle : function( range, selectIt )837 _ApplyInlineStyle : function( range, selectIt, updateRange ) 792 838 { 793 839 var doc = range.Window.document ; … … 970 1016 if ( selectIt ) 971 1017 range.SelectBookmark( bookmark ) ; 1018 1019 if ( updateRange ) 1020 range.MoveToBookmark( bookmark ) ; 972 1021 }, 973 1022
Note: See TracChangeset
for help on using the changeset viewer.
