Ticket #4886: 4886_3.patch

File 4886_3.patch, 2.3 KB (added by fredck, 2 years ago)
  • _source/core/htmlparser/fragment.js

     
    6464                        html = [], 
    6565                        fragment = new CKEDITOR.htmlParser.fragment(), 
    6666                        pendingInline = [], 
     67                        pendingBRs = [], 
    6768                        currentNode = fragment, 
    6869                    // Indicate we're inside a <pre> element, spaces should be touched differently. 
    6970                        inPre = false, 
     
    7172 
    7273                function checkPending( newTagName ) 
    7374                { 
     75                        var pendingBRsSent; 
     76 
    7477                        if ( pendingInline.length > 0 ) 
    7578                        { 
    7679                                for ( var i = 0 ; i < pendingInline.length ; i++ ) 
     
    8285 
    8386                                        if ( ( !currentDtd || currentDtd[ pendingName ] ) && ( !newTagName || !pendingDtd || pendingDtd[ newTagName ] || !CKEDITOR.dtd[ newTagName ] ) ) 
    8487                                        { 
     88                                                if ( !pendingBRsSent ) 
     89                                                { 
     90                                                        sendPendingBRs(); 
     91                                                        pendingBRsSent = 1; 
     92                                                } 
     93 
    8594                                                // Get a clone for the pending element. 
    8695                                                pendingElement = pendingElement.clone(); 
    8796 
     
    99108                        } 
    100109                } 
    101110 
     111                function sendPendingBRs() 
     112                { 
     113                        while ( pendingBRs.length ) 
     114                                currentNode.add( pendingBRs.shift() ); 
     115                } 
     116 
    102117                function addElement( element, target, enforceCurrent ) 
    103118                { 
    104119                        target = target || currentNode || fragment; 
     
    181196                                return; 
    182197                        } 
    183198 
     199                        if ( tagName == 'br' ) 
     200                        { 
     201                                pendingBRs.push( element ); 
     202                                return; 
     203                        } 
     204 
    184205                        var currentName = currentNode.name; 
    185206 
    186207                        var currentDtd = currentName 
     
    308329 
    309330                                currentNode = candidate; 
    310331 
    311                                 if( currentNode.name == 'pre' ) 
     332                                if ( currentNode.name == 'pre' ) 
    312333                                        inPre = false; 
    313334 
     335                                if ( candidate._.isBlockLike ) 
     336                                        sendPendingBRs(); 
     337 
    314338                                addElement( candidate, candidate.parent ); 
    315339 
    316340                                // The parent should start receiving new nodes now, except if 
     
    321345                                pendingInline = pendingInline.concat( newPendingInline ); 
    322346                        } 
    323347 
    324                         if( tagName == 'body' ) 
     348                        if ( tagName == 'body' ) 
    325349                                fixForBody = false; 
    326350                }; 
    327351 
     
    336360                                        return; 
    337361                        } 
    338362 
     363                        sendPendingBRs(); 
    339364                        checkPending(); 
    340365 
    341366                        if ( fixForBody 
     
    366391                // Parse it. 
    367392                parser.parse( fragmentHtml ); 
    368393 
     394                sendPendingBRs(); 
     395 
    369396                // Close all pending nodes. 
    370397                while ( currentNode.type ) 
    371398                { 
© 2003 – 2011 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy