Ticket #5577: 5577.patch

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

     
    252252        {
    253253                if ( selectionOrCell instanceof CKEDITOR.dom.selection )
    254254                {
    255                         var colsToDelete = getSelectedCells( selectionOrCell );
    256                         for ( var i = colsToDelete.length ; i >= 0 ; i-- )
     255                        var colsToDelete = getSelectedCells( selectionOrCell ),
     256                                table = colsToDelete[ 0 ] && colsToDelete[ 0 ].getAscendant( 'table' ),
     257                                parent = table && table.$.parentNode,
     258                                cursorPosition = null;
     259
     260                        for ( var i = colsToDelete.length - 1 ; i >= 0 ; i-- )
    257261                        {
    258262                                if ( colsToDelete[ i ] )
    259263                                        deleteColumns( colsToDelete[ i ] );
    260264                        }
     265
     266                        if ( table && table.$.parentNode )
     267                                cursorPosition = new CKEDITOR.dom.element(
     268                                                                                table.$.getElementsByTagName( 'td' )[ 0 ]
     269                                                                                || parent
     270                                                                        );
     271                        else
     272                                cursorPosition = new CKEDITOR.dom.element( parent );
     273
     274                        return cursorPosition;
    261275                }
    262276                else if ( selectionOrCell instanceof CKEDITOR.dom.element )
    263277                {
    264278                        // Get the cell's table.
    265279                        var table = selectionOrCell.getAscendant( 'table' );
     280                        if ( !table )
     281                                return;
    266282
    267283                        // Get the cell index.
    268284                        var cellIndex = selectionOrCell.$.cellIndex;
     
    288304                                        row.$.removeChild( row.$.cells[ cellIndex ] );
    289305                        }
    290306                }
     307
     308                return null;
    291309        }
    292310
    293311        function insertCell( selection, insertBefore )
     
    767785                                        exec : function( editor )
    768786                                        {
    769787                                                var selection = editor.getSelection();
    770                                                 deleteColumns( selection );
     788                                                var cell = deleteColumns( selection );
     789                                                cell && placeCursorInCell( cell, true );
    771790                                        }
    772791                                } );
    773792
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy