Ticket #9080: 9080_2.patch

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

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    589589                                        command : 'selectAll'
    590590                                });
    591591
    592                         editor.selectionChange = checkSelectionChangeTimeout;
     592                        /**
     593                         * Check if to fire the {@link CKEDITOR.editor#selectionChange} event
     594                         * for the current editor instance.
     595                         *
     596                         * @param {Boolean} checkNow Check immediately without any delay.
     597                         */
     598                        editor.selectionChange = function( checkNow )
     599                        {
     600                                ( checkNow ? checkSelectionChange : checkSelectionChangeTimeout ).call( this );
     601                        };
    593602
    594603                        // IE9 might cease to work if there's an object selection inside the iframe (#7639).
    595604                        CKEDITOR.env.ie9Compat && editor.on( 'destroy', function()
  • _source/plugins/indent/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    428428                                        }
    429429                                }
    430430                        });
    431 
    432                         editor.on( 'key', function( evt )
    433                         {
    434                                 // Backspace at the beginning of  list item should outdent it.
    435                                 if ( editor.mode == 'wysiwyg' && evt.data.keyCode == 8 )
    436                                 {
    437                                         var sel = editor.getSelection(),
    438                                                 range = sel.getRanges()[ 0 ],
    439                                                 li;
    440 
    441                                         if ( range.collapsed &&
    442                                                  ( li = range.startContainer.getAscendant( 'li', 1 ) ) &&
    443                                                  range.checkBoundaryOfElement( li, CKEDITOR.START ) )
    444                                         {
    445                                                 editor.execCommand( 'outdent' );
    446                                                 evt.cancel();
    447                                         }
    448                                 }
    449                         });
    450431                },
    451432
    452433                requires : [ 'domiterator', 'list' ]
  • _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
     
    788790                var frag = nextCursor.extractContents();
    789791
    790792                cursor.trim( false, true );
     793                var bm = cursor.createBookmark();
    791794
    792795                // Kill original bogus;
    793796                var currentPath = new CKEDITOR.dom.elementPath( cursor.startContainer );
     
    836839                        var nextBlock = nextPath.block,
    837840                                parentBlock = nextBlock.getParent();
    838841
     842                        nextCursor.moveToPosition( nextBlock, CKEDITOR.POSITION_BEFORE_START );
    839843                        nextBlock.remove();
    840844
    841845                        // Remove if the path block container is now empty, e.g. li.
     
    843847                                 !parentBlock.getFirst( nonEmpty ) &&
    844848                                 !parentBlock.equals( nextPath.blockLimit ) )
    845849                        {
     850                                nextCursor.moveToPosition( parentBlock, CKEDITOR.POSITION_BEFORE_START );
    846851                                parentBlock.remove();
    847852                        }
    848853                }
    849854
     855                // Check if need to further merge with the list resides after the merged block. (#9080)
     856                var walkerRng = nextCursor.clone(), body = editor.document.getBody();
     857                walkerRng.setEndAt( body, CKEDITOR.POSITION_BEFORE_END );
     858                var walker = new CKEDITOR.dom.walker( walkerRng );
     859                walker.evaluator = function( node ) { return nonEmpty( node ) && !blockBogus( node ); };
     860                var next = walker.next();
     861                if ( next && next.type == CKEDITOR.NODE_ELEMENT && next.getName() in CKEDITOR.dtd.$list )
     862                        mergeListSiblings( next );
     863
     864                cursor.moveToBookmark( bm );
     865
    850866                // Make fresh selection.
    851867                cursor.select();
    852868
     869                editor.selectionChange( 1 );
    853870                editor.fire( 'saveSnapshot' );
    854871        }
    855872
     
    883900                        editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, numberedListCommand ) );
    884901                        editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, bulletedListCommand ) );
    885902
    886                         // [IE8] Fix "backspace" after list and "del" at the end of list item. (#8248)
    887                         if ( CKEDITOR.env.ie8Compat )
    888                         {
     903                                // [IE8] Fix "backspace" after list and "del" at the end of list item. (#8248)
    889904                                editor.on( 'key', function( evt )
    890905                                {
    891906                                        var key = evt.data.keyCode;
     
    911926                                                        walker.range.setStartAt( body, CKEDITOR.POSITION_AFTER_START );
    912927                                                        walker.range.setEnd( range.startContainer, range.startOffset );
    913928
    914                                                         var previous = walker.previous();
     929                                                        var previous, joinWith;
    915930
    916                                                         // Check if cursor collapsed right behind of a list.
    917                                                         if ( previous &&
    918                                                                  previous.type == CKEDITOR.NODE_ELEMENT &&
    919                                                                  previous.getName() in listNodeNames )
     931                                                        var path = new CKEDITOR.dom.elementPath( range.startContainer );
     932
     933                                                        // Join a sub list's first line, with the previous visual line in parent.
     934                                                        if ( ( previous = path.contains( listNodeNames ) ) &&
     935                                                             range.checkBoundaryOfElement( previous, CKEDITOR.START ) &&
     936                                                             ( previous = previous.getParent() ) && previous.is( 'li' ) &&
     937                                                             ( previous = getSubList( previous ) ) )
    920938                                                        {
    921                                                                 walker.range.selectNodeContents( previous );
    922                                                                 walker.reset();
    923                                                                 walker.evaluator = isTextBlock;
     939                                                                joinWith = previous;
     940                                                                // Place cursor before the nested list.
     941                                                                cursor.moveToPosition( joinWith, CKEDITOR.POSITION_BEFORE_START );
     942                                                        }
     943                                                        // Join any line following a list, with the last visual line of the list.
     944                                                        else
     945                                                        {
     946                                                                previous = walker.previous();
     947
     948                                                                if ( previous && previous.type == CKEDITOR.NODE_ELEMENT &&
     949                                                                   ( previous.getName() in listNodeNames || previous.is( 'li' ) ) )
     950                                                                {
     951                                                                        if ( !previous.is( 'li' ) )
     952                                                                        {
     953                                                                                walker.range.selectNodeContents( previous );
     954                                                                                walker.reset();
     955                                                                                walker.evaluator = isTextBlock;
     956                                                                                previous = walker.previous();
     957                                                                        }
    924958
    925                                                                 // Place cursor at the end of previous block.
    926                                                                 cursor.moveToElementEditEnd( walker.lastForward() );
     959                                                                        joinWith = previous;
     960                                                                        // Place cursor at the end of previous block.
     961                                                                        cursor.moveToElementEditEnd( joinWith );
     962                                                                }
     963                                                        }
     964
     965                                                        if ( joinWith )
     966                                                        {
    927967                                                                joinNextLineToCursor( editor, cursor, range );
    928968                                                                evt.cancel();
    929969                                                        }
     
    9711011                                                }
    9721012                                        }
    9731013                                } );
    974                         }
    9751014                },
    9761015
    9771016                afterInit : function ( editor )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy