Ticket #3457: 3457_3.patch

File 3457_3.patch, 1.9 KB (added by Alfonso Martínez de Lizarrondo, 13 years ago)

patch for fragment.js

  • _source/core/htmlparser/fragment.js

     
    6767                        pendingInline = [],
    6868                        pendingBRs = [],
    6969                        currentNode = fragment,
     70                    // Indicate we're inside a <textarea> element, spaces should be touched differently.
     71                        inTextarea = false,
    7072                    // Indicate we're inside a <pre> element, spaces should be touched differently.
    7173                        inPre = false;
    7274
     
    161163
    162164                        // Rtrim empty spaces on block end boundary. (#3585)
    163165                        if ( element._.isBlockLike
    164                                  && element.name != 'pre' )
     166                                 && element.name != 'pre' && element.name != 'textarea' )
    165167                        {
    166168
    167169                                var length = element.children.length,
     
    212214                                currentNode.add( new CKEDITOR.htmlParser.text( '\n' ) );
    213215                                return;
    214216                        }
     217                        else if ( tagName == 'textarea' )
     218                                inTextarea = true;
    215219
    216220                        if ( tagName == 'br' )
    217221                        {
     
    345349                                if ( currentNode.name == 'pre' )
    346350                                        inPre = false;
    347351
     352                                if ( currentNode.name == 'textarea' )
     353                                        inTextarea = false;
     354
    348355                                if ( candidate._.isBlockLike )
    349356                                        sendPendingBRs();
    350357
     
    364371
    365372                parser.onText = function( text )
    366373                {
    367                         // Trim empty spaces at beginning of text contents except <pre>.
    368                         if ( ( !currentNode._.hasInlineStarted || pendingBRs.length ) && !inPre )
     374                        // Trim empty spaces at beginning of text contents except <pre> and <textarea>.
     375                        if ( ( !currentNode._.hasInlineStarted || pendingBRs.length ) && !inPre && !inTextarea )
    369376                        {
    370377                                text = CKEDITOR.tools.ltrim( text );
    371378
     
    385392
    386393                        // Shrinking consequential spaces into one single for all elements
    387394                        // text contents.
    388                         if ( !inPre )
     395                        if ( !inPre && !inTextarea )
    389396                                text = text.replace( /[\t\r\n ]{2,}|[\t\r\n]/g, ' ' );
    390397
    391398                        currentNode.add( new CKEDITOR.htmlParser.text( text ) );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy