Ticket #4696: 4696.patch

File 4696.patch, 4.9 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/pagebreak/plugin.js

     
    8080                // Creates the fake image used for this element.
    8181                breakObject = editor.createFakeElement( breakObject, 'cke_pagebreak', 'div' );
    8282
    83                 var ranges = editor.getSelection().getRanges();
     83                var ranges = editor.getSelection().getRanges(),
     84                        lastRangeIndex = ranges.length - 1,
     85                        range;
    8486
    85                 for ( var range, i = 0 ; i < ranges.length ; i++ )
     87                for ( var i = lastRangeIndex ; i >= 0 ; i-- )
    8688                {
    8789                        range = ranges[ i ];
    8890
    89                         if ( i > 0 )
     91                        if ( i < lastRangeIndex )
    9092                                breakObject = breakObject.clone( true );
    9193
    92                         range.splitBlock( 'p' );
     94                        // Make sure it's inserted under body, split elements
     95                        // when necessary. (#4696)
     96                        var current;
     97                        while ( ( current = range.getCommonAncestor( false, true ) ) && !current.is( 'body' ) )
     98                                range.splitBlock();
    9399                        range.insertNode( breakObject );
    94                 }
    95         }
     100
     101                        // Place cursor at the next editable position.
     102                        if( i == lastRangeIndex )
     103                        {
     104                                var next = breakObject.getNextSourceNode( true );
     105                                if ( next && next.type == CKEDITOR.NODE_ELEMENT )
     106                                        range.moveToElementEditStart( next );
     107                                else
     108                                        range.collapse();
     109
     110                                range.select( true );
     111                        }
     112                }
     113        }
    96114};
  • _source/core/dom/elementpath.js

     
    99        var pathBlockElements = { address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,de:1 };
    1010
    1111        // Elements that may be considered the "Block limit" in an element path.
    12         var pathBlockLimitElements = { body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1 };
     12        var pathBlockLimitElements = { body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1,ul:1,ol:1,dl:1 };
    1313
    1414        // Check if an element contains any block element.
    1515        var checkHasBlock = function( element )
  • _source/core/dom/range.js

     
    14051405                        return fixedBlock;
    14061406                },
    14071407
     1408                /**
     1409                 * Remove the contents of the range, and split the then occupied
     1410                 * block into two, while setup the new position between them.
     1411                 * Note: If the range is not currently within a block, the result will
     1412                 *  depend on the {@param blockTag }
     1413                 *  1. Establish one new block element of the specified tag name before split;
     1414                 *  2. Just split up the surrounding blockLimit element unless it's already inside <body>.
     1415                 * @param {String} blockTag The tag name
     1416                 */
    14081417                splitBlock : function( blockTag )
    14091418                {
    14101419                        var startPath   = new CKEDITOR.dom.elementPath( this.startContainer ),
     
    14131422                        var startBlockLimit     = startPath.blockLimit,
    14141423                                endBlockLimit   = endPath.blockLimit;
    14151424
    1416                         var startBlock  = startPath.block,
    1417                                 endBlock        = endPath.block;
     1425                        var startBlock  = startPath.block || !blockTag && startBlockLimit,
     1426                                endBlock        = endPath.block || !blockTag && endBlockLimit;
    14181427
    14191428                        var elementPath = null;
     1429
    14201430                        // Do nothing if the boundaries are in different block limits.
    1421                         if ( !startBlockLimit.equals( endBlockLimit ) )
     1431                        if ( blockTag && !startBlockLimit.equals( endBlockLimit ) )
    14221432                                return null;
     1433                        // Don't split <body>.
     1434                        else if( !blockTag && ( startBlock.is( 'body' ) || endBlock.is( 'body' ) ) )
     1435                                return null;
    14231436
    14241437                        // Get or fix current blocks.
    14251438                        if ( blockTag != 'br' )
     
    14731486
    14741487                                        // In Gecko, the last child node must be a bogus <br>.
    14751488                                        // Note: bogus <br> added under <ul> or <ol> would cause
    1476                                         // lists to be incorrectly rendered.
    1477                                         if ( !CKEDITOR.env.ie && !startBlock.is( 'ul', 'ol') )
    1478                                                 startBlock.appendBogus() ;
    1479                                 }
    1480                         }
     1489                                        // lists to be incorrectly rendered, and <br> under <tr>
     1490                                        // or <tbody> will bring inconsistency output among browsers.
     1491                                        if ( !CKEDITOR.env.ie )
     1492                                        {
     1493                                                var dtd = CKEDITOR.dtd[ startBlock.getName() ];
     1494                                                dtd[ 'br' ] && startBlock.appendBogus() ;
     1495                                        }
     1496                                }
     1497                        }
    14811498
    14821499                        return {
    14831500                                previousBlock : startBlock,
  • _source/core/htmlparser/fragment.js

     
    345345
    346346                        checkPending();
    347347
    348                         if ( fixForBody && !currentNode.type )
     348                        if ( fixForBody && CKEDITOR.tools.trim( text ) && !currentNode.type )
    349349                                this.onTagOpen( fixForBody, {} );
    350350
    351351                        // Shrinking consequential spaces into one single for all elements
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy