Ticket #4784: 4784_3.patch
File 4784_3.patch, 2.3 KB (added by , 14 years ago) |
---|
-
_source/plugins/tabletools/plugin.js
85 85 86 86 return retval; 87 87 } 88 89 function getFocusedCell( cellsToDelete ) { 90 var i = 0, 91 last = cellsToDelete.length - 1, 92 database = {}, 93 cell,focusedCell, 94 tr; 95 96 while ( cell = cellsToDelete[ i++ ] ) 97 CKEDITOR.dom.element.setMarker( database, cell, 'delete_cell', true ); 98 99 // 1.first we check left or right side focusable cell row by row; 100 i = 0; 101 while ( cell = cellsToDelete[ i++ ] ) 102 { 103 if ( ( focusedCell = cell.getPrevious() ) && !focusedCell.getCustomData( 'delete_cell' ) 104 || ( focusedCell = cell.getNext() ) && !focusedCell.getCustomData( 'delete_cell' ) ) 105 { 106 CKEDITOR.dom.element.clearAllMarkers( database ); 107 return focusedCell; 108 } 109 } 88 110 111 CKEDITOR.dom.element.clearAllMarkers( database ); 112 113 // 2. then we check the toppest row (outside the selection area square) focusable cell 114 tr = cellsToDelete[ 0 ].getParent(); 115 if ( tr = tr.getPrevious() ) 116 return tr.getLast(); 117 118 // 3. last we check the lowerest row focusable cell 119 tr = cellsToDelete[ last ].getParent(); 120 if ( tr = tr.getNext() ) 121 return tr.getChild( 0 ); 122 123 return null; 124 } 125 89 126 function clearRow( $tr ) 90 127 { 91 128 // Get the array of row's cells. … … 277 314 if ( selectionOrCell instanceof CKEDITOR.dom.selection ) 278 315 { 279 316 var cellsToDelete = getSelectedCells( selectionOrCell ); 317 var table = cellsToDelete[ 0 ] && cellsToDelete[ 0 ].getAscendant( 'table' ); 318 var cellToFocus = getFocusedCell( cellsToDelete ); 319 280 320 for ( var i = cellsToDelete.length - 1 ; i >= 0 ; i-- ) 281 321 deleteCells( cellsToDelete[ i ] ); 322 323 if ( cellToFocus ) 324 placeCursorInCell( cellToFocus, true ); 325 else if ( table ) 326 table.remove(); 282 327 } 283 328 else if ( selectionOrCell instanceof CKEDITOR.dom.element ) 284 329 { 285 if ( selectionOrCell.getParent().getChildCount() == 1 ) 286 selectionOrCell.getParent().remove(); 330 var tr = selectionOrCell.getParent(); 331 if ( tr.getChildCount() == 1 ) 332 tr.remove(); 287 333 else 288 334 selectionOrCell.remove(); 289 335 }