Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: #832

Lucas.Xu1b5d71756049
diff --git a/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/delete_text_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/delete_text_handler.dart
index 5e96e75a99..92f5e9afb9 100644
--- a/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/delete_text_handler.dart
+++ b/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/delete_text_handler.dart
@@ -4,12 +4,13 @@ import 'package:flutter/services.dart';
import 'package:flowy_editor/flowy_editor.dart';
KeyEventResult _handleBackspace(EditorState editorState, RawKeyEvent event) {
- final selection = editorState.service.selectionService.currentSelection.value;
+ var selection = editorState.service.selectionService.currentSelection.value;
if (selection == null) {
return KeyEventResult.ignored;
}
-
- final nodes = editorState.service.selectionService.currentSelectedNodes;
+ var nodes = editorState.service.selectionService.currentSelectedNodes;
+ nodes = selection.isBackward ? nodes : nodes.reversed.toList(growable: false);
+ selection = selection.isBackward ? selection : selection.reversed;
// make sure all nodes is [TextNode].
final textNodes = nodes.whereType<TextNode>().toList();
if (textNodes.length != nodes.length) {
@@ -20,7 +21,7 @@ KeyEventResult _handleBackspace(EditorState editorState, RawKeyEvent event) {
if (textNodes.length == 1) {
final textNode = textNodes.first;
final index = textNode.delta.prevRunePosition(selection.start.offset);
- if (index < 0) {
+ if (index < 0 && selection.isCollapsed) {
// 1. style
if (textNode.subtype != null) {
transactionBuilder