Ticket #5335: 5335_3.patch

File 5335_3.patch, 3.3 KB (added by Sa'ar Zac Elias, 14 years ago)

Same patch, updated to the current revision

  • _source/plugins/domiterator/plugin.js

     
    4444                        // Indicats that the current element in the loop is the last one.
    4545                        var isLast;
    4646
     47                        // Indicate at least one of the range boundaries is inside a preformat block.
     48                        var touchPre;
     49
    4750                        // Instructs to cleanup remaining BRs.
    4851                        var removePreviousBr, removeLastBr;
    4952
     
    5558                                // Shrink the range to exclude harmful "noises" (#4087, #4450, #5435).
    5659                                range.shrink( CKEDITOR.NODE_ELEMENT, true );
    5760
    58                                 range.enlarge( this.forceBrBreak || !this.enlargeBr ?
     61                                touchPre = range.endContainer.hasAscendant( 'pre', true )
     62                                        || range.startContainer.hasAscendant( 'pre', true );
     63
     64                                range.enlarge( this.forceBrBreak && !touchPre || !this.enlargeBr ?
    5965                                                           CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS : CKEDITOR.ENLARGE_BLOCK_CONTENTS );
    6066
    6167                                var walker = new CKEDITOR.dom.walker( range ),
     
    106112                        {
    107113                                // closeRange indicates that a paragraph boundary has been found,
    108114                                // so the range can be closed.
    109                                 var closeRange = false;
     115                                var closeRange = false,
     116                                                parentPre = currentNode.hasAscendant( 'pre' );
    110117
    111118                                // includeNode indicates that the current node is good to be part
    112119                                // of the range. By default, any non-element node is ok for it.
     
    119126                                {
    120127                                        var nodeName = currentNode.getName();
    121128
    122                                         if ( currentNode.isBlockBoundary( this.forceBrBreak && { br : 1 } ) )
     129                                        if ( currentNode.isBlockBoundary( this.forceBrBreak &&
     130                                                        !parentPre && { br : 1 } ) )
    123131                                        {
    124132                                                // <br> boundaries must be part of the range. It will
    125133                                                // happen only if ForceBrBreak.
     
    193201                                        {
    194202                                                var parentNode = currentNode.getParent();
    195203
    196                                                 if ( parentNode.isBlockBoundary( this.forceBrBreak && { br : 1 } ) )
     204                                                if ( parentNode.isBlockBoundary( this.forceBrBreak
     205                                                                && !parentPre && { br : 1 } ) )
    197206                                                {
    198207                                                        closeRange = true;
    199208                                                        isLast = isLast || ( parentNode.equals( lastNode) );
  • _source/plugins/list/plugin.js

     
    299299                        var contentBlock = listContents.shift(),
    300300                                listItem = doc.createElement( 'li' );
    301301
    302                         // Preserve heading structure when converting to list item. (#5271)
    303                         if ( headerTagRegex.test( contentBlock.getName() ) )
     302                        // Preserve preformat block and heading structure when converting to list item. (#5335) (#5271)
     303                        if ( contentBlock.is( 'pre' ) || headerTagRegex.test( contentBlock.getName() ) )
    304304                                contentBlock.appendTo( listItem );
    305305                        else
    306306                        {
     
    312312                                contentBlock.copyAttributes( listItem );
    313313                                contentBlock.moveChildren( listItem );
    314314                                contentBlock.remove();
     315
     316                                // Append a bogus BR to force the LI to render at full height
     317                                if ( !CKEDITOR.env.ie )
     318                                        listItem.appendBogus();
    315319                        }
    316320
    317321                        listItem.appendTo( listNode );
    318 
    319                         // Append a bogus BR to force the LI to render at full height
    320                         if ( !CKEDITOR.env.ie )
    321                                 listItem.appendBogus();
    322322                }
    323323
    324324                if ( dir )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy