Merge pull request #1390 from LucasXu0/fix_enter_key_handler

fix: remove the unnecessary operation in enter key handler
This commit is contained in:
Lucas.Xu 2022-10-29 16:56:07 +08:00 committed by GitHub
commit 95fdfd7da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View File

@ -153,11 +153,13 @@ ShortcutEventHandler enterWithoutShiftInTextNodesHandler =
delta: textNode.delta.slice(selection.end.offset),
),
);
transaction.deleteText(
textNode,
selection.start.offset,
textNode.toPlainText().length - selection.start.offset,
);
if (selection.end.offset != textNode.toPlainText().length) {
transaction.deleteText(
textNode,
selection.start.offset,
textNode.toPlainText().length - selection.start.offset,
);
}
if (textNode.children.isNotEmpty) {
final children = textNode.children.toList(growable: false);
transaction.deleteNodes(children);

View File

@ -78,10 +78,10 @@ class AppFlowyRenderPlugin extends AppFlowyRenderPluginService {
node.key = key;
return _autoUpdateNodeWidget(builder, context);
} else {
assert(false,
'Could not query the builder with this $name, or nodeValidator return false.');
// TODO: return a placeholder widget with tips.
return Container();
// Returns a SizeBox with 0 height if no builder found.
return const SizedBox(
height: 0,
);
}
}