Ticket #3836: 3836.patch

File 3836.patch, 3.2 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/list/plugin.js

     
    335335                }
    336336
    337337                var newList = CKEDITOR.plugins.list.arrayToList( listArray, database, null, editor.config.enterMode );
     338
     339                // Compensate a <br> before the first node if the previous node of list is a non-blocks.(#3836)
     340                var docFragment = newList.listNode, firstNode, previousNode;
     341                if ( ( firstNode = docFragment.getFirst() )
     342                         && !( firstNode.is && firstNode.isBlockBoundary() )
     343                         && ( previousNode = groupObj.root.getPrevious( true ) )
     344                         && !( previousNode.is && previousNode.isBlockBoundary( { br : 1 } ) ) )
     345                        editor.document.createElement( 'br' ).insertBefore( firstNode );
     346
    338347                // If groupObj.root is the last element in its parent, or its nextSibling is a <br>, then we should
    339348                // not add a <br> after the final item. So, check for the cases and trim the <br>.
    340349                if ( !groupObj.root.getNext() || groupObj.root.getNext().$.nodeName.toLowerCase() == 'br' )
     
    342351                        if ( newList.listNode.getLast().$.nodeName.toLowerCase() == 'br' )
    343352                                newList.listNode.getLast().remove();
    344353                }
    345                 newList.listNode.replace( groupObj.root );
     354                docFragment.replace( groupObj.root );
    346355        }
    347356
    348357        function listCommand( name, type )
  • _source/tests/plugins/list/list.html

     
    161161                                        this.wait();
    162162                        },
    163163
     164                        /**
     165                         *  Test remove list first list item not merging with previous text node.
     166                         */
     167                        test_ticket_3836 : function()
     168                        {
     169                                prepareEditor( 'test_ticket_3836_editor', null,
     170                                        { enterMode : CKEDITOR.ENTER_BR },
     171                                        function( editor )
     172                                        {
     173                                                this.resume( function()
     174                                                {
     175                                                        editor.focus();
     176
     177                                                        var doc = editor.document,
     178                                                                range = new CKEDITOR.dom.range( doc );
     179                                                        setRange( range, [ 1, 1, 0, 0 ], [ 1, 1, 1, 1 ] );
     180                                                        debugger;
     181                                                        var sel = editor.getSelection();
     182                                                        sel.selectRanges( [ range ] );
     183
     184                                                        // Waiting for 'comand state' effected.
     185                                                        this.wait( function(){
     186                                                                // Remove list.
     187                                                                editor.execCommand( 'bulletedlist' );
     188                                                                assert.areSame( getTextAreaValue( 'test_ticket_3836_result' ),
     189                                                                        editor.getData(),
     190                                                                        'Remove list result not correct.' );
     191                                                        }, 1000 );
     192
     193                                                } );
     194                                        }, this );
     195                                        this.wait();
     196                        },
     197
    164198                        name :document.title
    165199                };
    166200        } )() );
     
    174208<textarea id="test_ticket_3820_result"><ul><li>bullet line 1</li><li>bullet line 2</li><li>Second line</li></ul></textarea>
    175209<textarea id="test_ticket_3773_editor"><ol><li>line1</li><li>line2</li></ol></textarea>
    176210<textarea id="test_ticket_3773_result">line1<br />line2</textarea>
     211<textarea id="test_ticket_3836_editor">line1<ul><li>item1</li><li>item2</li></ul>line2</textarea>
     212<textarea id="test_ticket_3836_result">line1<br />item1<br />item2<br />line2</textarea>
    177213</body>
    178214</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy