Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Other: Moved some code around.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed May 6, 2019
1 parent 6ea9495 commit e6cc3bc
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/tableediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,22 @@ export default class TableEditing extends Plugin {
}

const isLastCellInRow = currentCellIndex === tableRow.childCount - 1;
let isLastRow = currentRowIndex === table.childCount - 1;
const isLastRow = currentRowIndex === table.childCount - 1;

if ( isForward && isLastRow && isLastCellInRow ) {
editor.execute( 'insertTableRowBelow' );

// Re-evaluate `isLastRow`. If `insertTableRowBelow` execution didn't add any row (because it was disabled or it got
// overwritten in some way) this will still be `true`. But if the row was added it will change to `false`.
isLastRow = currentRowIndex === table.childCount - 1;
// Check if the command actually added a row. If `insertTableRowBelow` execution didn't add a row (because it was disabled
// or it got overwritten) do not change the selection.
if ( currentRowIndex === table.childCount - 1 ) {
return;
}
}

let cellToFocus;

// Move to first cell in next row.
if ( isForward && isLastCellInRow ) {
if ( isLastRow ) {
// It's the last cell of a table - don't do anything (stay in current position).
return;
}

const nextRow = table.getChild( currentRowIndex + 1 );

cellToFocus = nextRow.getChild( 0 );
Expand Down

0 comments on commit e6cc3bc

Please sign in to comment.