Ticket #8305: 8305.patch

File 8305.patch, 2.4 KB (added by Garry Yao, 11 years ago)
  • _source/plugins/list/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    483483                this.type = type;
    484484        }
    485485
    486         // Move direction attribute from root to list items.
    487         function dirToListItems( list )
     486        var elementType = CKEDITOR.dom.walker.nodeType( CKEDITOR.NODE_ELEMENT );
     487        // Merge list items with direction preserved. (#7448)
     488        function mergeListItems( from, into, toHead )
    488489        {
    489                 var dir = list.getDirection();
    490                 if ( dir )
     490                var child, itemDir;
     491                while ( child = from.getFirst( elementType ) )
    491492                {
    492                         for ( var i = 0, children = list.getChildren(), child; child = children.getItem( i ), i < children.count(); i++ )
    493                         {
    494                                 if ( child.type == CKEDITOR.NODE_ELEMENT && child.is( 'li' ) && !child.getDirection() )
    495                                         child.setAttribute( 'dir', dir );
    496                         }
    497 
    498                         list.removeAttribute( 'dir' );
    499                 }
    500         }
     493                        if ( ( itemDir = child.getDirection( 1 ) ) !== into.getDirection( 1 ) )
     494                                child.setAttribute( 'dir', itemDir );
     495                        into.append( child.remove(), toHead );
     496                }
     497        }
    501498
    502499        listCommand.prototype = {
    503500                exec : function( editor )
     
    640637                                        removeList.call( this, editor, groupObj, database );
    641638                        }
    642639
    643                         // For all new lists created, merge adjacent, same type lists.
     640                        // For all new lists created, merge into adjacent, same type lists.
    644641                        for ( i = 0 ; i < listsCreated.length ; i++ )
    645642                        {
    646643                                listNode = listsCreated[i];
    647644                                var mergeSibling, listCommand = this;
    648                                 ( mergeSibling = function( rtl ){
     645                                ( mergeSibling = function( rtl )
     646                                {
    649647
    650648                                        var sibling = listNode[ rtl ?
    651649                                                'getPrevious' : 'getNext' ]( CKEDITOR.dom.walker.whitespaces( true ) );
    652650                                        if ( sibling && sibling.getName &&
    653651                                                 sibling.getName() == listCommand.type )
    654652                                        {
    655 
    656                                                 // In case to be merged lists have difference directions. (#7448)
    657                                                 if ( sibling.getDirection( 1 ) != listNode.getDirection( 1 ) )
    658                                                         dirToListItems( listNode.getDirection() ? listNode : sibling );
    659 
    660                                                 sibling.remove();
    661653                                                // Move children order by merge direction.(#3820)
    662                                                 sibling.moveChildren( listNode, rtl );
     654                                                mergeListItems( listNode, sibling, !rtl );
     655
     656                                                listNode.remove();
     657                                                listNode = sibling;
    663658                                        }
    664659                                } )();
    665660                                mergeSibling( 1 );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy