|
|
@@ -293,35 +293,29 @@ export default class TableSelection extends Plugin {
|
|
|
*/
|
|
|
_handleDeleteContent( event, args ) {
|
|
|
const [ selection, options ] = args;
|
|
|
+ const model = this.editor.model;
|
|
|
+ const isBackward = !options || options.direction == 'backward';
|
|
|
+ const selectedTableCells = getTableCellsInSelection( selection );
|
|
|
|
|
|
- // This Model#deleteContent() hook supports multiple-cell selections only.
|
|
|
- // **Note**: It executes Model#deleteContent() itself for each individual cell within
|
|
|
- // the selection, so this also avoids infinite loops.
|
|
|
- if ( selection.rangeCount > 1 ) {
|
|
|
- const model = this.editor.model;
|
|
|
- const isBackward = !options || options.direction == 'backward';
|
|
|
- const selectedTableCells = getTableCellsInSelection( selection );
|
|
|
-
|
|
|
- // There are possible multiple-range selection that have nothing to do with tables.
|
|
|
- // Let's filter them out and focus on table cells only.
|
|
|
- if ( selectedTableCells.length ) {
|
|
|
- event.stop();
|
|
|
-
|
|
|
- model.change( writer => {
|
|
|
- const tableCellToSelect = selectedTableCells[ isBackward ? selectedTableCells.length - 1 : 0 ];
|
|
|
-
|
|
|
- clearTableCellsContents( model, selectedTableCells );
|
|
|
-
|
|
|
- // The insertContent() helper passes the actual DocumentSelection,
|
|
|
- // while the deleteContent() helper always operates on the abstract clones.
|
|
|
- if ( selection.is( 'documentSelection' ) ) {
|
|
|
- writer.setSelection( tableCellToSelect, 'in' );
|
|
|
- } else {
|
|
|
- selection.setTo( tableCellToSelect, 'in' );
|
|
|
- }
|
|
|
- } );
|
|
|
- }
|
|
|
+ if ( !selectedTableCells.length ) {
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ event.stop();
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ const tableCellToSelect = selectedTableCells[ isBackward ? selectedTableCells.length - 1 : 0 ];
|
|
|
+
|
|
|
+ clearTableCellsContents( model, selectedTableCells );
|
|
|
+
|
|
|
+ // The insertContent() helper passes the actual DocumentSelection,
|
|
|
+ // while the deleteContent() helper always operates on the abstract clones.
|
|
|
+ if ( selection.is( 'documentSelection' ) ) {
|
|
|
+ writer.setSelection( tableCellToSelect, 'in' );
|
|
|
+ } else {
|
|
|
+ selection.setTo( tableCellToSelect, 'in' );
|
|
|
+ }
|
|
|
+ } );
|
|
|
}
|
|
|
}
|
|
|
|