Skip to content

Commit

Permalink
fix: deleting the last table being the last node of the document, pla…
Browse files Browse the repository at this point in the history
…ces an empty node to avoid the editor to crash (#951)
  • Loading branch information
saif-ellafi authored Nov 20, 2024
1 parent a1081a9 commit 16a7287
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ void _deleteCol(Node tableNode, int col, EditorState editorState) {
colsLen = tableNode.attributes[TableBlockKeys.colsLen];

if (colsLen == 1) {
if (editorState.document.root.children.length == 1) {
final emptyParagraph = paragraphNode();
transaction.insertNode(tableNode.path, emptyParagraph);
}
transaction.deleteNode(tableNode);
tableNode.dispose();
} else {
Expand All @@ -238,6 +242,10 @@ void _deleteRow(Node tableNode, int row, EditorState editorState) {
colsLen = tableNode.attributes[TableBlockKeys.colsLen];

if (rowsLen == 1) {
if (editorState.document.root.children.length == 1) {
final emptyParagraph = paragraphNode();
transaction.insertNode(tableNode.path, emptyParagraph);
}
transaction.deleteNode(tableNode);
tableNode.dispose();
} else {
Expand Down

0 comments on commit 16a7287

Please sign in to comment.