Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html (revision 5011)
+++ /CKEditor/trunk/CHANGES.html (revision 5012)
@@ -74,4 +74,5 @@
#4795 : [IE] Press 'Del' key on horizontal line or table result in error.
#4824 : [IE] <br/> at the very first table cell breaks the editor selection.
+ #4851 : [IE] Delete table rows with context-menu may cause error.
Updated the following language files:
- #5006 : Dutch;
Index: /CKEditor/trunk/_source/plugins/tabletools/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/tabletools/plugin.js (revision 5011)
+++ /CKEditor/trunk/_source/plugins/tabletools/plugin.js (revision 5012)
@@ -124,13 +124,34 @@
if ( selectionOrRow instanceof CKEDITOR.dom.selection )
{
- var cells = getSelectedCells( selectionOrRow );
- var rowsToDelete = [];
+ var cells = getSelectedCells( selectionOrRow ),
+ cellsCount = cells.length,
+ rowsToDelete = [],
+ cursorPosition,
+ previousRowIndex,
+ nextRowIndex;
// Queue up the rows - it's possible and likely that we have duplicates.
- for ( var i = 0 ; i < cells.length ; i++ )
- {
- var row = cells[ i ].getParent();
- rowsToDelete[ row.$.rowIndex ] = row;
- }
+ for ( var i = 0 ; i < cellsCount ; i++ )
+ {
+ var row = cells[ i ].getParent(),
+ rowIndex = row.$.rowIndex;
+
+ i == 0 && ( previousRowIndex = rowIndex - 1 );
+ rowsToDelete[ rowIndex ] = row;
+ i == cellsCount - 1 && ( nextRowIndex = rowIndex + 1 );
+ }
+
+ var table = row.getAscendant( 'table' ),
+ rows = table.$.rows,
+ rowCount = rows.length;
+
+ // Where to put the cursor after rows been deleted?
+ // 1. Into next sibling row if any;
+ // 2. Into previous sibling row if any;
+ // 3. Into table's parent element if it's the very last row.
+ cursorPosition = new CKEDITOR.dom.element(
+ nextRowIndex < rowCount && table.$.rows[ nextRowIndex ] ||
+ previousRowIndex > 0 && table.$.rows[ previousRowIndex ] ||
+ table.$.parentNode );
for ( i = rowsToDelete.length ; i >= 0 ; i-- )
@@ -139,4 +160,6 @@
deleteRows( rowsToDelete[ i ] );
}
+
+ return cursorPosition;
}
else if ( selectionOrRow instanceof CKEDITOR.dom.element )
@@ -669,5 +692,5 @@
{
var selection = editor.getSelection();
- deleteRows( selection );
+ placeCursorInCell( deleteRows( selection ) );
}
} );