Changeset 1868

Show
Ignore:
Timestamp:
2008-04-02 07:58:55 (5 months ago)
Author:
wwalc
Message:

Fix for #1785: whitespaces removed inside a pre tag

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • MediaWiki/trunk/plugins/mediawiki/fckplugin.js

    r1866 r1868  
    9797                var stringBuilder = new Array() ; 
    9898                this._AppendNode( rootNode, stringBuilder, '' ) ; 
    99                 return stringBuilder.join( '' ).Trim() ; 
     99                return stringBuilder.join( '' ).RTrim() ; 
    100100        }, 
    101101 
     
    509509                                                                this._AppendChildNodes( htmlNode, stringBuilder, prefix ) ; 
    510510                                                                this._inLSpace = false ; 
    511                                                                 if ( stringBuilder[stringBuilder.length-2] == "\n" && stringBuilder[stringBuilder.length-1] == " " ) 
    512                                                                         stringBuilder.pop() ; 
    513                                                                 else 
     511                                                                if ( !stringBuilder[stringBuilder.length-1].EndsWith("\n") ) 
    514512                                                                        stringBuilder.push( "\n" ) ; 
    515513                                                        } 
     
    526524                                                                this._AppendChildNodes( htmlNode, stringBuilder, prefix ) ; 
    527525                                                                this._inPre = false ; 
     526 
    528527                                                                stringBuilder.push( '<\/' ) ; 
    529528                                                                stringBuilder.push( sNodeName ) ; 
    530                                                                 stringBuilder.push( '>' ) ;                                                              
     529                                                                stringBuilder.push( '>' ) ; 
    531530                                                        } 
    532531                                                 
     
    561560                                if ( !parentIsSpecialTag )  
    562561                                { 
     562                                        if ( FCKBrowserInfo.IsIE && this._inLSpace ) { 
     563                                                textValue = textValue.replace(/\r/, "\r ") ; 
     564                                        } 
     565                                         
    563566                                        textValue = textValue.replace( /[\n\t]/g, ' ' ) ;  
    564567         
     
    566569                                        textValue = textValue.replace( /\u00A0/g, '&nbsp;' ) ; 
    567570 
    568                                         if ( !htmlNode.previousSibling || 
    569                                         ( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) && !this._inLSpace ) 
     571                                        if ( ( !htmlNode.previousSibling || 
     572                                        ( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) ) && !this._inLSpace && !this._inPre ) 
    570573                                        { 
    571574                                                textValue = textValue.LTrim() ; 
    572575                                        } 
    573576 
    574                                         if ( !htmlNode.nextSibling && !this._inLSpace && (!htmlNode.parentNode || !htmlNode.parentNode.nextSibling)) 
     577                                        if ( !htmlNode.nextSibling && !this._inLSpace && !this._inPre && (!htmlNode.parentNode || !htmlNode.parentNode.nextSibling)) 
    575578                                                textValue = textValue.RTrim() ; 
    576579 
    577                                         textValue = textValue.replace( / {2,}/g, ' ' ) ; 
     580                                        if (!this._inLSpace && !this._inPre) 
     581                                                textValue = textValue.replace( / {2,}/g, ' ' ) ; 
    578582 
    579583                                        if ( this._inLSpace && textValue.length == 1 && textValue.charCodeAt(0) == 13 ) 
     
    583587                                } 
    584588                                else  
    585                                 {                                        
     589                                { 
    586590                                        textValue = FCKTools.HTMLDecode(textValue).replace(/fckLR/g,'\r\n'); 
    587591                                }