Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deleting the last table being the last node of the document, places an empty node to avoid the editor to crash #951

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading