Ticket #6925: 6925.patch

File 6925.patch, 2.9 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/htmldataprocessor/plugin.js

     
    527527                toDataFormat : function( html, fixForBody )
    528528                {
    529529                        var writer = this.writer,
    530                                 fragment = CKEDITOR.htmlParser.fragment.fromHtml( html, fixForBody );
     530                                fragment = CKEDITOR.htmlParser.fragment.fromHtml( html, fixForBody, 1 );
    531531
    532532                        writer.reset();
    533533
  • _source/core/htmlparser/fragment.js

     
    5858         * alert( fragment.children[0].name );  "b"
    5959         * alert( fragment.children[1].value );  " Text"
    6060         */
    61         CKEDITOR.htmlParser.fragment.fromHtml = function( fragmentHtml, fixForBody )
     61        CKEDITOR.htmlParser.fragment.fromHtml = function( fragmentHtml, fixForBody, noSpacesFix )
    6262        {
    6363                var parser = new CKEDITOR.htmlParser(),
    6464                        html = [],
     
    156156                                        text;
    157157                                if ( lastChild && lastChild.type == CKEDITOR.NODE_TEXT )
    158158                                {
    159                                         if ( !( text = CKEDITOR.tools.rtrim( lastChild.value ) ) )
     159                                        if ( !( text = noSpacesFix ? lastChild.value : CKEDITOR.tools.rtrim( lastChild.value ) ) )
    160160                                                element.children.length = length -1;
    161161                                        else
    162162                                                lastChild.value = text;
     
    176176                {
    177177                        var element = new CKEDITOR.htmlParser.element( tagName, attributes );
    178178
     179                        element._.spacesFix = !noSpacesFix;
     180
    179181                        // "isEmpty" will be always "false" for unknown elements, so we
    180182                        // must force it if the parser has identified it as a selfClosing tag.
    181183                        if ( element.isUnknown && selfClosing )
     
    358360                parser.onText = function( text )
    359361                {
    360362                        // Trim empty spaces at beginning of element contents except <pre>.
    361                         if ( !currentNode._.hasInlineStarted && !inPre )
     363                        if ( !( noSpacesFix  || currentNode._.hasInlineStarted ) && !inPre )
    362364                        {
    363365                                text = CKEDITOR.tools.ltrim( text );
    364366
     
    371373
    372374                        if ( fixForBody
    373375                                 && ( !currentNode.type || currentNode.name == 'body' )
    374                                  && CKEDITOR.tools.trim( text ) )
     376                                 && ( noSpacesFix || CKEDITOR.tools.trim( text ) ) )
    375377                        {
    376378                                this.onTagOpen( fixForBody, {} );
    377379                        }
     
    439441                        var len = this.children.length,
    440442                                previous = len > 0 && this.children[ len - 1 ] || null;
    441443
    442                         if ( previous )
     444                        if ( this._.spacesFix && previous )
    443445                        {
    444446                                // If the block to be appended is following text, trim spaces at
    445447                                // the right of it.
    446448                                if ( node._.isBlockLike && previous.type == CKEDITOR.NODE_TEXT )
    447449                                {
    448                                         previous.value = CKEDITOR.tools.rtrim( previous.value );
     450                                        previous.value = previous.value;
    449451
    450452                                        // If we have completely cleared the previous node.
    451453                                        if ( previous.value.length === 0 )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy