Ticket #1229: 1229.patch
File 1229.patch, 3.9 KB (added by , 16 years ago) |
---|
-
_whatsnew.html
177 177 settings.</li> 178 178 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1868">#1868</a>] Links 179 179 to file browser has been changed to avoid requests containing double dots.</li> 180 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1229">#1229</a>] Converting 181 multiple contiguous paragraphs to Formatted will now be merged into a single 182 <PRE> block.</li> 180 183 </ul> 181 184 <p> 182 185 <a href="_whatsnew_history.html">See previous versions history</a> -
editor/_source/classes/fckstyle.js
817 817 value = '\n' ; 818 818 results.push( value ) ; 819 819 } ) ; 820 820 821 821 // Assigning innerHTML to <PRE> in IE causes all linebreaks to be reduced to spaces. 822 822 // Assigning outerHTML to <PRE> in IE doesn't work if the <PRE> isn't contained in another node 823 823 // since the node reference is changed after outerHTML assignment. … … 855 855 var block ; 856 856 var doc = range.Window.document ; 857 857 858 var preBlocks = [] ; 859 var convertedPreBlocks = [] ; 860 858 861 while( ( block = iterator.GetNextParagraph() ) ) // Only one = 859 862 { 860 863 // Create the new node right before the current one. … … 864 867 var newBlockIsPre = newBlock.nodeName.IEquals( 'pre' ) ; 865 868 var blockIsPre = block.nodeName.IEquals( 'pre' ) ; 866 869 if ( newBlockIsPre && !blockIsPre ) 870 { 867 871 newBlock = this._ToPre( doc, block, newBlock ) ; 872 preBlocks.push( newBlock ) ; 873 } 868 874 else if ( !newBlockIsPre && blockIsPre ) 875 { 869 876 newBlock = this._FromPre( doc, block, newBlock ) ; 877 convertedPreBlocks.push( newBlock ) ; 878 } 870 879 else // Convering from a regular block to another regular block. 871 880 FCKDomTools.MoveChildren( block, newBlock ) ; 872 881 … … 875 884 FCKDomTools.RemoveNode( block ) ; 876 885 } 877 886 887 // Merge adjacent <PRE> blocks for #1229. 888 for ( var i = 0 ; i < preBlocks.length - 1 ; i++ ) 889 { 890 // Check if the next block in HTML equals the next <PRE> block generated. 891 if ( FCKDomTools.GetNextSourceElement( preBlocks[i], true, [], [], true ) != preBlocks[i+1] ) 892 continue ; 893 894 // Merge the upper <PRE> block's content into the lower <PRE> block. 895 // Remove the upper <PRE> block. 896 preBlocks[i+1].innerHTML = preBlocks[i].innerHTML + '\n\n' + preBlocks[i+1].innerHTML ; 897 FCKDomTools.RemoveNode( preBlocks[i] ) ; 898 } 899 900 // Split converted <PRE> blocks for #1229. 901 for ( var i = 0 ; i < convertedPreBlocks.length ; i++ ) 902 { 903 var currentBlock = convertedPreBlocks[i] ; 904 var lastNewBlock = null ; 905 for ( var j = 0 ; j < currentBlock.childNodes.length ; j++ ) 906 { 907 var cursor = currentBlock.childNodes[j] ; 908 909 // If we have two <BR>s, and they're not at the beginning or the end, 910 // then we'll split up the contents following them into another block. 911 if ( cursor.nodeName.IEquals( 'br' ) && j != 0 && j != currentBlock.childNodes.length - 2 912 && cursor.nextSibling && cursor.nextSibling.nodeName.IEquals( 'br' ) ) 913 { 914 FCKDomTools.RemoveNode( cursor.nextSibling ) ; 915 FCKDomTools.RemoveNode( cursor ) ; 916 j-- ; // restart at current index at next iteration 917 lastNewBlock = FCKDomTools.InsertAfterNode( lastNewBlock || currentBlock, doc.createElement( currentBlock.nodeName ) ) ; 918 continue ; 919 } 920 921 if ( lastNewBlock ) 922 { 923 FCKDomTools.MoveNode( cursor, lastNewBlock ) ; 924 j-- ; // restart at current index at next iteration 925 } 926 } 927 } 928 878 929 // Re-select the original range. 879 930 if ( selectIt ) 880 931 range.SelectBookmark( bookmark ) ;