Ticket #9129: 9129_3.patch

File 9129_3.patch, 8.1 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
     
    8181                function singletonBlock( node )
    8282                {
    8383                        var body = range.document.getBody();
    84                         return !node.is( 'body' ) && body.getChildCount() == 1;
     84
     85                        if ( node.isBlockBoundary() &&
     86                             range.checkBoundaryOfElement( body, CKEDITOR.START ) &&
     87                             range.checkBoundaryOfElement( body, CKEDITOR.END ) )
     88                        {
     89                                return true;
     90                        }
    8591                }
    8692
    8793                var start = range.startContainer,
  • _source/plugins/wysiwygarea/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    767767
    768768                                                domDocument.getDocumentElement().addClass( domDocument.$.compatMode );
    769769                                                // Override keystroke behaviors.
    770                                                 editable && domDocument.on( 'keydown', function( evt )
     770                                                editor.on( 'key', function( evt )
    771771                                                {
    772                                                         var keyCode = evt.data.getKeystroke();
     772                                                        var keyCode = evt.data.keyCode;
    773773
    774774                                                        // Backspace OR Delete.
    775775                                                        if ( keyCode in { 8 : 1, 46 : 1 } )
     
    799799
    800800                                                                        editor.fire( 'saveSnapshot' );
    801801
    802                                                                         evt.data.preventDefault();
     802                                                                        evt.cancel();
    803803                                                                }
    804                                                                 else
     804                                                                else if ( range.collapsed )
    805805                                                                {
    806806                                                                        // Handle the following special cases: (#6217)
    807807                                                                        // 1. Del/Backspace key before/after table;
     
    823823
    824824                                                                                editor.fire( 'saveSnapshot' );
    825825
    826                                                                                 evt.data.preventDefault();
     826                                                                                evt.cancel();
    827827                                                                        }
    828828                                                                        else if ( path.blockLimit.is( 'td' ) &&
    829829                                                                                          ( parent = path.blockLimit.getAscendant( 'table' ) ) &&
     
    843843
    844844                                                                                editor.fire( 'saveSnapshot' );
    845845
    846                                                                                 evt.data.preventDefault();
     846                                                                                evt.cancel();
    847847                                                                        }
    848848
    849849                                                                }
     
    865865                                                                                range = new CKEDITOR.dom.range( domDocument );
    866866                                                                                range[ keyCode == 33 ? 'moveToElementEditStart' : 'moveToElementEditEnd']( body );
    867867                                                                                range.select();
    868                                                                                 evt.data.preventDefault();
     868                                                                                evt.cancel();
    869869                                                                        }
    870870                                                                }
    871871
  • _source/plugins/list/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    784784                           CKEDITOR.dtd[ node.getName() ][ '#' ];
    785785        }
    786786
    787         // Merge the visual line content at the cursor range into the block.
     787        // Join visually two block lines.
    788788        function joinNextLineToCursor( editor, cursor, nextCursor )
    789789        {
    790790                editor.fire( 'saveSnapshot' );
     
    798798
    799799                // Kill original bogus;
    800800                var currentPath = new CKEDITOR.dom.elementPath( cursor.startContainer );
    801                 var currentLi = currentPath.lastElement.getAscendant( 'li', 1 );
     801                var currentBlock = currentPath.lastElement.getAscendant( 'li', 1 ) || currentPath.block;
    802802
    803803                var bogus = currentPath.block.getBogus();
    804804                bogus && bogus.remove();
     
    815815                else
    816816                        cursor.startContainer.append( frag );
    817817
    818                 var nextPath = new CKEDITOR.dom.elementPath( nextCursor.startContainer );
    819                 var nextLi = nextCursor.startContainer.getAscendant( 'li', 1 );
     818                var nextPath = new CKEDITOR.dom.elementPath( nextCursor.startContainer ),
     819                        nextLi = nextCursor.startContainer.getAscendant( 'li', 1 );
    820820
    821821                // Move the sub list nested in the next list item.
    822822                if ( nextLi )
     
    825825                        if ( sublist )
    826826                        {
    827827                                // If next line is in the sub list of the current list item.
    828                                 if ( currentLi.contains( nextLi ) )
     828                                if ( currentBlock.contains( nextLi ) )
    829829                                {
    830830                                        mergeChildren( sublist, nextLi.getParent(), nextLi );
    831831                                        sublist.remove();
    832832                                }
    833833                                // Migrate the sub list to current list item.
    834834                                else
    835                                         currentLi.append( sublist );
     835                                        currentBlock.append( sublist );
    836836                        }
    837837                }
    838838
     
    918918                                                if ( !range.collapsed )
    919919                                                        return;
    920920
     921                                                var path = new CKEDITOR.dom.elementPath( range.startContainer );
    921922                                                var isBackspace = key == 8;
    922923                                                var body = editor.document.getBody();
    923924                                                var walker = new CKEDITOR.dom.walker( range.clone() );
    924925                                                walker.evaluator = function( node ) { return nonEmpty( node ) && !blockBogus( node ); };
     926                                                walker.guard = function( node, isOut ) { return !( isOut && node.type == CKEDITOR.NODE_ELEMENT && node.is( 'table' ) ) };
    925927
    926928                                                var cursor = range.clone();
    927929
     
    929931                                                {
    930932                                                        var previous, joinWith;
    931933
    932                                                         var path = new CKEDITOR.dom.elementPath( range.startContainer );
    933 
    934934                                                        // Join a sub list's first line, with the previous visual line in parent.
    935935                                                        if ( ( previous = path.contains( listNodeNames ) ) &&
    936936                                                             range.checkBoundaryOfElement( previous, CKEDITOR.START ) &&
     
    973973                                                                joinNextLineToCursor( editor, cursor, range );
    974974                                                                evt.cancel();
    975975                                                        }
    976                                                 }
     976                                                        else
     977                                                        {
     978                                                                var list = path.contains( listNodeNames ), li;
     979                                                                // Backspace pressed at the start of list, in first list item. (#9129)
     980                                                                if ( list && range.checkBoundaryOfElement( list, CKEDITOR.START ) )
     981                                                                {
     982                                                                        li = list.getFirst( nonEmpty );
     983
     984                                                                        // Outdent the list item if:
     985                                                                        // 1. Inside of empty list item.
     986                                                                        // 2. No content to merge before.
     987                                                                        if ( range.checkBoundaryOfElement( li, CKEDITOR.START ) )
     988                                                                        {
     989                                                                                previous = list.getPrevious( nonEmpty );
     990
     991                                                                                // Simply move backward one character when:
     992                                                                                // 1. The list item contains a sub list;
     993                                                                                // 2. The previous one is a table;
     994                                                                                if ( getSubList( li ) ||
     995                                                                                     previous && previous.type == CKEDITOR.NODE_ELEMENT &&
     996                                                                                     previous.is( 'table' ) )
     997                                                                                {
     998                                                                                        if ( previous ) {
     999                                                                                                range.moveToElementEditEnd( previous );
     1000                                                                                                range.select();
     1001                                                                                        }
     1002
     1003                                                                                        evt.cancel();
     1004                                                                                }
     1005                                                                                // Outdent the list item when:
     1006                                                                                // 1. Empty list item that contains no sub list.
     1007                                                                                // 2. No previous content to merge.
     1008                                                                                else if ( range.checkBoundaryOfElement( li, CKEDITOR.END ) || !previous ) {
     1009                                                                                        editor.execCommand( 'outdent' );
     1010                                                                                        evt.cancel();
     1011                                                                                }
     1012                                                                        }
     1013                                                                }
     1014                                                        }
     1015                                                }
    9771016                                                else
    9781017                                                {
    979                                                         var li = range.startContainer.getAscendant( 'li', 1 );
     1018                                                        var next,
     1019                                                                nextLine,
     1020                                                                li = range.startContainer.getAscendant( 'li', 1 );
     1021
    9801022                                                        if ( li )
    9811023                                                        {
    9821024                                                                walker.range.setEndAt( body, CKEDITOR.POSITION_BEFORE_END );
     
    10071049                                                                if ( isAtEnd && next )
    10081050                                                                {
    10091051                                                                        // Put cursor range there.
    1010                                                                         var nextLine = range.clone();
     1052                                                                        nextLine = range.clone();
    10111053                                                                        nextLine.moveToElementEditStart( next );
    10121054
    10131055                                                                        joinNextLineToCursor( editor, cursor, nextLine );
    10141056                                                                        evt.cancel();
     1057                                                                }
     1058                                                        }
     1059                                                        else
     1060                                                        {
     1061                                                                // Handle Del key pressed before the list.
     1062                                                                walker.range.setEndAt( body, CKEDITOR.POSITION_BEFORE_END );
     1063                                                                next = walker.next();
     1064
     1065                                                                if ( next && next.type == CKEDITOR.NODE_ELEMENT &&
     1066                                                                     next.getName() in listNodeNames )
     1067                                                                {
     1068                                                                        // The start <li>
     1069                                                                        next = next.getFirst( nonEmpty );
     1070
     1071                                                                        // Move the cursor one character forward if
     1072                                                                        // the subsequent list item contains sub list.
     1073                                                                        if ( getSubList( next )  )
     1074                                                                        {
     1075                                                                                range.moveToElementEditStart( next );
     1076                                                                                range.select();
     1077                                                                                evt.cancel();
     1078                                                                        }
     1079                                                                        // Simply remove the current empty block, move cursor to the
     1080                                                                        // subsequent list.
     1081                                                                        else if ( path.block &&
     1082                                                                             range.checkStartOfBlock() &&
     1083                                                                             range.checkEndOfBlock() )
     1084                                                                        {
     1085                                                                                path.block.remove();
     1086                                                                                range.moveToElementEditStart( next );
     1087                                                                                range.select();
     1088                                                                                evt.cancel();
     1089                                                                        }
    10151090                                                                }
    10161091                                                        }
    10171092                                                }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy