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
  • Loading branch information
saif-ellafi committed Oct 29, 2024
1 parent e7d9560 commit 1bf000c
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 1bf000c

Please sign in to comment.