Ticket #4851: 4851.patch
File 4851.patch, 2.0 KB (added by , 13 years ago) |
---|
-
_source/plugins/tabletools/plugin.js
123 123 { 124 124 if ( selectionOrRow instanceof CKEDITOR.dom.selection ) 125 125 { 126 var cells = getSelectedCells( selectionOrRow ); 127 var rowsToDelete = []; 126 var cells = getSelectedCells( selectionOrRow ), 127 cellsCount = cells.length, 128 rowsToDelete = [], 129 cursorPosition, 130 previousRowIndex, 131 nextRowIndex; 128 132 129 133 // Queue up the rows - it's possible and likely that we have duplicates. 130 for ( var i = 0 ; i < cells .length; i++ )134 for ( var i = 0 ; i < cellsCount ; i++ ) 131 135 { 132 var row = cells[ i ].getParent(); 133 rowsToDelete[ row.$.rowIndex ] = row; 136 var row = cells[ i ].getParent(), 137 rowIndex = row.$.rowIndex; 138 139 i == 0 && ( previousRowIndex = rowIndex - 1 ); 140 rowsToDelete[ rowIndex ] = row; 141 i == cellsCount - 1 && ( nextRowIndex = rowIndex + 1 ); 134 142 } 135 143 144 var table = row.getAscendant( 'table' ), 145 rows = table.$.rows, 146 rowCount = rows.length; 147 148 // Where to put the cursor after rows been deleted? 149 // 1. Into next sibling row if any; 150 // 2. Into previous sibling row if any; 151 // 3. Into table's parent element. 152 cursorPosition = new CKEDITOR.dom.element( 153 nextRowIndex < rowCount && table.$.rows[ nextRowIndex ] || 154 previousRowIndex > 0 && table.$.rows[ previousRowIndex ] || 155 table.$.parentNode ); 156 136 157 for ( i = rowsToDelete.length ; i >= 0 ; i-- ) 137 158 { 138 159 if ( rowsToDelete[ i ] ) 139 160 deleteRows( rowsToDelete[ i ] ); 140 161 } 162 163 return cursorPosition; 141 164 } 142 165 else if ( selectionOrRow instanceof CKEDITOR.dom.element ) 143 166 { … … 668 691 exec : function( editor ) 669 692 { 670 693 var selection = editor.getSelection(); 671 deleteRows( selection);694 placeCursorInCell( deleteRows( selection ) ); 672 695 } 673 696 } ); 674 697