Ticket #1015: 1015.patch

File 1015.patch, 3.1 kB (added by justinm, 8 months ago)

Pro

  • fckplugin.js

     
    5656{ 
    5757        _inPre : false, 
    5858        _inLSpace : false,       
     59        _appendSpace : false, 
    5960 
    6061        /* 
    6162         * Returns a string representing the HTML format of "data". The returned 
     
    190191                                var basicElement = this._BasicElements[ sNodeName ] ; 
    191192                                if ( basicElement ) 
    192193                                { 
     194 
    193195                                        if ( basicElement[0] ) 
    194                                                 stringBuilder.push( basicElement[0] ) ; 
     196                                        { 
     197                                                var pNode = htmlNode.previousSibling; 
    195198 
     199                                                if ( pNode != null && pNode.nodeType == 3 && ( pNode.nodeValue == " " || pNode.nodeValue == "" ) ) 
     200                                                { 
     201                                                        pNode = pNode.previousSibling; 
     202                                                } 
     203 
     204                                                if ( pNode == null || !pNode.tagName || pNode.tagName.toLowerCase() != sNodeName || pNode.nodeValue == "" ) 
     205                                                { 
     206                                                        stringBuilder.push( basicElement[0] ); 
     207                                                } 
     208 
     209                                        } 
     210 
    196211                                        if ( !basicElement[2] ) 
    197212                                                this._AppendChildNodes( htmlNode, stringBuilder ) ; 
    198213 
    199214                                        if ( basicElement[1] ) 
    200                                                 stringBuilder.push( basicElement[1] ) ; 
     215                                        { 
     216                                                var nNode = htmlNode.nextSibling; 
     217 
     218                                                if ( nNode != null && nNode.nodeType == 3 && ( nNode.nodeValue == " " || nNode.nodeValue == "" ) ) 
     219                                                { 
     220                                                        nNode = nNode.previousSibling; 
     221                                                } 
     222 
     223                                                if ( nNode == null || !nNode.tagName || nNode.tagName.toLowerCase() != sNodeName || nNode.nodeValue == "" ) 
     224                                                { 
     225                                                        stringBuilder.push( basicElement[1] ); 
     226                                                } 
     227 
     228                                        } 
     229 
     230                                        if ( this._appendSpace == true ) 
     231                                        { 
     232                                                stringBuilder.push( " " ); 
     233                                                this._appendSpace = false; 
     234                                        } 
     235 
    201236                                } 
    202237                                else 
    203238                                { 
     239                                        this._appendSpace = false; 
    204240                                        switch ( sNodeName ) 
    205241                                        { 
    206242                                                case 'ol' : 
     
    498534                                        textValue = FCKTools.HTMLEncode( textValue ) ; 
    499535                                        textValue = textValue.replace( /\u00A0/g, ' ' ) ; 
    500536 
    501                                         if ( !htmlNode.previousSibling || 
    502                                         ( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) && !this._inLSpace ) 
     537                                        if ( textValue != "" && ( !htmlNode.previousSibling || 
     538                                        ( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) && !this._inLSpace ) ) 
    503539                                        { 
    504                                                 textValue = textValue.LTrim() ; 
     540                                                var newTextValue = textValue.LTrim() ; 
     541                                                if ( newTextValue != textValue )  
     542                                                { 
     543                                                        var old = stringBuilder[ stringBuilder.length - 1 ]; 
     544                                                        stringBuilder[ stringBuilder.length - 1 ] = " "; 
     545                                                        stringBuilder.push( old ); 
     546                                                } 
     547 
     548                                                textValue = newTextValue; 
    505549                                        } 
    506550 
    507551                                        if ( !htmlNode.nextSibling && !this._inLSpace ) 
    508                                                 textValue = textValue.RTrim() ; 
     552                                        { 
     553                                                var newTextValue = textValue.RTrim() ; 
     554                                                if ( newTextValue != textValue ) 
     555                                                { 
     556                                                        this._appendSpace = true; 
     557                                                } 
    509558 
     559                                                textValue = newTextValue; 
     560                                        } 
     561 
    510562                                        textValue = textValue.replace( / {2,}/g, ' ' ) ; 
    511563 
    512564                                        if ( this._inLSpace && textValue.length == 1 && textValue.charCodeAt(0) == 13 ) 
     
    514566                                         
    515567                                        if ( this._IsInsideCell ) 
    516568                                                textValue = textValue.replace( /\|/g, '|' ) ; 
    517          
     569 
    518570                                } 
    519571                                else  
    520572                                { 
     
    692744                        } 
    693745                } 
    694746        } 
    695 }) ; 
    696  No newline at end of file 
     747}) ;