Ticket #7432: 7432_2.patch

File 7432_2.patch, 1.5 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/list/plugin.js

     
    457457        listCommand.prototype = {
    458458                exec : function( editor )
    459459                {
    460                         editor.focus();
    461 
    462460                        var doc = editor.document,
     461                                config = editor.config,
    463462                                selection = editor.getSelection(),
    464463                                ranges = selection && selection.getRanges( true );
    465464
     
    473472                        if ( this.state == CKEDITOR.TRISTATE_OFF )
    474473                        {
    475474                                var body = doc.getBody();
    476                                 body.trim();
    477                                 if ( !body.getFirst() )
     475                                if ( !body.getFirst( nonEmpty ) )
    478476                                {
    479                                         var paragraph = doc.createElement( editor.config.enterMode == CKEDITOR.ENTER_P ? 'p' :
    480                                                         ( editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'br' ) );
    481                                         paragraph.appendTo( body );
    482                                         ranges = new CKEDITOR.dom.rangeList( [ new CKEDITOR.dom.range( doc ) ] );
    483                                         // IE exception on inserting anything when anchor inside <br>.
    484                                         if ( paragraph.is( 'br' ) )
    485                                         {
    486                                                 ranges[ 0 ].setStartBefore( paragraph );
    487                                                 ranges[ 0 ].setEndAfter( paragraph );
    488                                         }
    489                                         else
    490                                                 ranges[ 0 ].selectNodeContents( paragraph );
     477                                        config.enterMode == CKEDITOR.ENTER_BR ?
     478                                                body.appendBogus() :
     479                                                ranges[ 0 ].fixBlock( 1, config.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' );
     480
    491481                                        selection.selectRanges( ranges );
    492482                                }
    493483                                // Maybe a single range there enclosing the whole list,
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy