Skip to content

Commit

Permalink
Verify that table cell is selected (#302)
Browse files Browse the repository at this point in the history
Fixes: #300

We were not verifying that the table cell is actually selected vs cursor being in the cell.
  • Loading branch information
chrischrischris authored Dec 17, 2024
1 parent 5b3ceb4 commit 5c10110
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions blocks/edit/prose/plugins/keyHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const isColumnSelected = (rect) => rect.top === 0 && rect.bottom === rect.map.he
const isTableSelected = (rect) => isRowSelected(rect) && isColumnSelected(rect);

export function handleTableBackspace(state, dispatch) {
if (!isInTable(state)) return false;
if (!isInTable(state) || !state.selection.$anchorCell) return false;

const rect = selectedRect(state);
if (!rect || rect.top === null) return false;
Expand All @@ -61,12 +61,10 @@ export function handleTableBackspace(state, dispatch) {
deleteTable(state, dispatch);
return true;
}

if (isRowSelected(rect)) {
deleteRow(state, dispatch);
return true;
}

if (isColumnSelected(rect)) {
deleteColumn(state, dispatch);
return true;
Expand Down

0 comments on commit 5c10110

Please sign in to comment.