Ticket #5079: 5079.patch

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

     
    8282                // Creates the fake image used for this element.
    8383                breakObject = editor.createFakeElement( breakObject, 'cke_pagebreak', 'div' );
    8484
    85                 var ranges = editor.getSelection().getRanges();
     85                var selection = editor.getSelection(),
     86                                ranges = selection.getRanges(),
     87                                range;
    8688
    87                 for ( var range, i = 0 ; i < ranges.length ; i++ )
     89                for ( var i = 0; i < ranges.length; i++ )
    8890                {
    8991                        range = ranges[ i ];
     92                        range.deleteContents();
    9093
    91                         if ( i > 0 )
    92                                 breakObject = breakObject.clone( true );
     94                        // Split up all the blocks until to order to insert page-break inside 'BODY'. (#5079)
     95                        var current;
     96                        while ( !( current = range.getCommonAncestor( false, true ) ).is( 'body' ) )
     97                                range.splitBlock();
    9398
    94                         range.splitBlock( 'p' );
    9599                        range.insertNode( breakObject );
     100                        range.moveToElementEditStart( breakObject.getNext() ||breakObject.getPrevious() );
    96101                }
     102               
     103                selection.selectRanges( ranges );
    97104        }
    98105};
  • _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 };
    1313
    1414        // Check if an element contains any block element.
    1515        var checkHasBlock = function( element )
  • _source/core/dom/range.js

     
    14201420                        return fixedBlock;
    14211421                },
    14221422
     1423                /**
     1424                 * Split the occupied block into two, putting the new cursor position between them.
     1425                 * Note: If the range is not already inside a block, the result will
     1426                 *  depend on {@param blockTag }:
     1427                 *  1. Establish one new block element of the specified tag name before split;
     1428                 *  2. Split up the any surrounding blockLimit element besides 'BODY'.
     1429                 * @param {String} blockTag The tag name
     1430                 */
    14231431                splitBlock : function( blockTag )
    14241432                {
    14251433                        var startPath   = new CKEDITOR.dom.elementPath( this.startContainer ),
     
    14281436                        var startBlockLimit     = startPath.blockLimit,
    14291437                                endBlockLimit   = endPath.blockLimit;
    14301438
    1431                         var startBlock  = startPath.block,
    1432                                 endBlock        = endPath.block;
     1439                        var startBlock  = startPath.block || !blockTag && startBlockLimit,
     1440                                endBlock        = endPath.block || !blockTag && endBlockLimit;
    14331441
    14341442                        var elementPath = null;
     1443
    14351444                        // Do nothing if the boundaries are in different block limits.
    1436                         if ( !startBlockLimit.equals( endBlockLimit ) )
     1445                        if ( blockTag && !startBlockLimit.equals( endBlockLimit ) )
    14371446                                return null;
     1447                        // Don't split <body>.
     1448                        else if( !blockTag && ( startBlock.is( 'body' ) || endBlock.is( 'body' ) ) )
     1449                                return null;
    14381450
    14391451                        // Get or fix current blocks.
    14401452                        if ( blockTag != 'br' )
     
    14801492                                        // lists to be incorrectly rendered.
    14811493                                        if ( !CKEDITOR.env.ie && !startBlock.is( 'ul', 'ol') )
    14821494                                                startBlock.appendBogus() ;
    1483                                 }
    1484                         }
     1495                                        }
     1496                                }
    14851497
    14861498                        return {
    14871499                                previousBlock : startBlock,
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy