Ticket #4784: 4784.patch

File 4784.patch, 1.7 KB (added by brooks, 14 years ago)
  • _source/plugins/tabletools/plugin.js

     
    8686                return retval;
    8787        }
    8888
     89        function getToFocusedCell( cellsToDelete ) {
     90                var len = cellsToDelete.length,
     91                        firstCell = cellsToDelete[ 0 ],
     92                        lastCell  = cellsToDelete[ len - 1 ],
     93                        td, tr;
     94               
     95                // Where to put the cursor after cells been deleted?
     96                // 1. Into next cell  if any;
     97                // 2. Into previous cell if any;
     98                // 3. Into next row first cell if any;
     99                // 4. Into previous row last cell if any;
     100               
     101                return ( lastCell.getNext()
     102                                || firstCell.getPrevious()           
     103                                || ( tr = lastCell.getParent().getNext() ) && tr.getChild( 0 )
     104                            || ( tr = firstCell.getParent().getPrevious() ) && tr.getLast()
     105                           );
     106
     107        }
     108
    89109        function clearRow( $tr )
    90110        {
    91111                // Get the array of row's cells.
     
    277297                if ( selectionOrCell instanceof CKEDITOR.dom.selection )
    278298                {
    279299                        var cellsToDelete = getSelectedCells( selectionOrCell );
     300                        var cellToFocus   = getToFocusedCell( cellsToDelete );
     301
    280302                        for ( var i = cellsToDelete.length - 1 ; i >= 0 ; i-- )
    281303                                deleteCells( cellsToDelete[ i ] );
     304                       
     305                        if ( cellToFocus )
     306                        {
     307                                placeCursorInCell( cellToFocus, true );
     308                        }
     309                       
    282310                }
    283311                else if ( selectionOrCell instanceof CKEDITOR.dom.element )
    284312                {
    285                         if ( selectionOrCell.getParent().getChildCount() == 1 )
    286                                 selectionOrCell.getParent().remove();
     313                        var tr = selectionOrCell.getParent();
     314                        if ( tr.getChildCount() == 1 )
     315                                tr.remove();
    287316                        else
    288317                                selectionOrCell.remove();
    289318                }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy