Ticket #9080: 9080.patch

File 9080.patch, 3.7 KB (added by Garry Yao, 12 years ago)
  • _source/plugins/list/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    681681
    682682                        // For all new lists created, merge into adjacent, same type lists.
    683683                        for ( i = 0 ; i < listsCreated.length ; i++ )
    684                         {
    685                                 listNode = listsCreated[i];
    686                                 var mergeSibling, listCommand = this;
    687                                 ( mergeSibling = function( rtl )
    688                                 {
    689                                         var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ]( nonEmpty );
    690                                         if ( sibling && sibling.getName &&
    691                                                  sibling.getName() == listCommand.type )
    692                                         {
    693                                                 // Move children order by merge direction.(#3820)
    694                                                 mergeChildren( listNode, sibling, null, !rtl );
     684                                mergeListSiblings( listsCreated[ i ] );
     685
     686                        // Clean up, restore selection and update toolbar button states.
     687                        CKEDITOR.dom.element.clearAllMarkers( database );
     688                        selection.selectBookmarks( bookmarks );
     689                        editor.focus();
     690                }
     691        };
     692
     693        // Merge list adjacent, of same type lists.
     694        function mergeListSiblings( listNode )
     695        {
     696                var mergeSibling;
     697                ( mergeSibling = function( rtl )
     698                {
     699                        var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ]( nonEmpty );
     700                        if ( sibling && sibling.is( listNode.getName() ) )
     701                        {
     702                                // Move children order by merge direction.(#3820)
     703                                mergeChildren( listNode, sibling, null, !rtl );
    695704
    696                                                 listNode.remove();
    697                                                 listNode = sibling;
    698                                         }
    699                                 } )();
    700                                 mergeSibling( 1 );
    701                         }
     705                                listNode.remove();
     706                                listNode = sibling;
     707                        }
     708                } )();
     709                mergeSibling( 1 );
     710        }
    702711
    703                         // Clean up, restore selection and update toolbar button states.
    704                         CKEDITOR.dom.element.clearAllMarkers( database );
    705                         selection.selectBookmarks( bookmarks );
    706                         editor.focus();
    707                 }
    708         };
    709 
    710712        var dtd = CKEDITOR.dtd;
    711713        var tailNbspRegex = /[\t\r\n ]*(?:&nbsp;|\xa0)$/;
    712714
     
    836838                        var nextBlock = nextPath.block,
    837839                                parentBlock = nextBlock.getParent();
    838840
     841                        nextCursor.moveToPosition( nextBlock, CKEDITOR.POSITION_BEFORE_START );
    839842                        nextBlock.remove();
    840843
    841844                        // Remove if the path block container is now empty, e.g. li.
     
    843846                                 !parentBlock.getFirst( nonEmpty ) &&
    844847                                 !parentBlock.equals( nextPath.blockLimit ) )
    845848                        {
     849                                nextCursor.moveToPosition( parentBlock, CKEDITOR.POSITION_BEFORE_START );
    846850                                parentBlock.remove();
    847851                        }
    848852                }
    849853
     854                // Check if need to further merge with the list resides after the merged block. (#9080)
     855                var walkerRng = nextCursor.clone(), body = editor.document.getBody();
     856                walkerRng.setEndAt( body, CKEDITOR.POSITION_BEFORE_END );
     857                var walker = new CKEDITOR.dom.walker( walkerRng );
     858                walker.evaluator = function( node ) { return nonEmpty( node ) && !blockBogus( node ); };
     859                var next = walker.next();
     860                if ( next && next.type == CKEDITOR.NODE_ELEMENT && next.getName() in CKEDITOR.dtd.$list )
     861                        mergeListSiblings( next );
     862
    850863                // Make fresh selection.
    851864                cursor.select();
    852865
     
    883896                        editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, numberedListCommand ) );
    884897                        editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, bulletedListCommand ) );
    885898
    886                         // [IE8] Fix "backspace" after list and "del" at the end of list item. (#8248)
    887                         if ( CKEDITOR.env.ie8Compat )
    888                         {
     899                                // [IE8] Fix "backspace" after list and "del" at the end of list item. (#8248)
    889900                                editor.on( 'key', function( evt )
    890901                                {
    891902                                        var key = evt.data.keyCode;
     
    971982                                                }
    972983                                        }
    973984                                } );
    974                         }
    975985                },
    976986
    977987                afterInit : function ( editor )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy