Ticket #1015: fckplugin.js.patch

File fckplugin.js.patch, 3.0 KB (added by Justin McCormick, 16 years ago)

Possible patch to fix this issue

  • 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
     
    189190                                var basicElement = this._BasicElements[ sNodeName ] ;
    190191                                if ( basicElement )
    191192                                {
     193
    192194                                        if ( basicElement[0] )
    193                                                 stringBuilder.push( basicElement[0] ) ;
     195                                        {
     196                                                var pNode = htmlNode.previousSibling;
     197
     198                                                if ( pNode != null && pNode.nodeType == 3 && ( pNode.nodeValue == " " || pNode.nodeValue == "" ) )
     199                                                {
     200                                                        pNode = pNode.previousSibling;
     201                                                }
     202
     203                                                if ( pNode == null || !pNode.tagName || pNode.tagName.toLowerCase() != sNodeName || pNode.nodeValue != "" )
     204                                                {
     205                                                        stringBuilder.push( basicElement[0] );
     206                                                }
     207
     208                                        }
    194209
    195210                                        if ( !basicElement[2] )
    196211                                                this._AppendChildNodes( htmlNode, stringBuilder ) ;
    197212
    198213                                        if ( basicElement[1] )
    199                                                 stringBuilder.push( basicElement[1] ) ;
     214                                        {
     215                                                var nNode = htmlNode.nextSibling;
     216
     217                                                if ( nNode != null && nNode.nodeType == 3 && ( nNode.nodeValue == " " || nNode.nodeValue == "" ) )
     218                                                {
     219                                                        nNode = nNode.previousSibling;
     220                                                }
     221
     222                                                if ( nNode == null || !nNode.tagName || nNode.tagName.toLowerCase() != sNodeName || nNode.nodeValue != "" )
     223                                                {
     224                                                        stringBuilder.push( basicElement[1] );
     225                                                }
     226
     227                                        }
     228
     229                                        if ( this._appendSpace == true )
     230                                        {
     231                                                stringBuilder.push( " " );
     232                                                this._appendSpace = false;
     233                                        }
     234
    200235                                }
    201236                                else
    202237                                {
     238                                        this._appendSpace = false;
    203239                                        switch ( sNodeName )
    204240                                        {
    205241                                                case 'ol' :
     
    496532                                        textValue = FCKTools.HTMLEncode( textValue ) ;
    497533                                        textValue = textValue.replace( /\u00A0/g, ' ' ) ;
    498534
    499                                         if ( !htmlNode.previousSibling ||
    500                                         ( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) && !this._inLSpace )
     535                                        if ( textValue != "" && ( !htmlNode.previousSibling ||
     536                                        ( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) && !this._inLSpace ) )
    501537                                        {
    502                                                 textValue = textValue.LTrim() ;
     538                                                var newTextValue = textValue.LTrim() ;
     539                                                if ( newTextValue != textValue )
     540                                                {
     541                                                        var old = stringBuilder[ stringBuilder.length - 1 ];
     542                                                        stringBuilder[ stringBuilder.length - 1 ] = " ";
     543                                                        stringBuilder.push( old );
     544                                                }
     545
     546                                                textValue = newTextValue;
    503547                                        }
    504548
    505549                                        if ( !htmlNode.nextSibling && !this._inLSpace )
    506                                                 textValue = textValue.RTrim() ;
     550                                        {
     551                                                var newTextValue = textValue.RTrim() ;
     552                                                if ( newTextValue != textValue )
     553                                                {
     554                                                        this._appendSpace = true;
     555                                                }
     556
     557                                                textValue = newTextValue;
     558                                        }
    507559
    508560                                        textValue = textValue.replace( / {2,}/g, ' ' ) ;
    509561
     
    512564                                       
    513565                                        if ( this._IsInsideCell )
    514566                                                textValue = textValue.replace( /\|/g, '|' ) ;
    515        
     567
    516568                                }
    517569                                else
    518570                                {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy