Skip to content

Commit

Permalink
If deleting the last table of the document, define a blank Document
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-ellafi committed Oct 29, 2024
1 parent e7d9560 commit 76962b5
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 76962b5

Please sign in to comment.