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.

feat: refresh number list when delete multiple lines

Vincent Chan27757372607d
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/backspace_handler.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/backspace_handler.dart
index a8337543e7..1e252d9114 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/backspace_handler.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/backspace_handler.dart
@@ -93,9 +93,19 @@ KeyEventResult _handleBackspace(EditorState editorState, RawKeyEvent event) {
}
}
} else {
- if (textNodes.isNotEmpty) {
- _deleteTextNodes(transactionBuilder, textNodes, selection);
+ if (textNodes.isEmpty) {
+ return KeyEventResult.handled;
}
+ final startPosition = selection.start;
+ final nodeAtStart = editorState.document.nodeAtPath(startPosition.path)!;
+ _deleteTextNodes(transactionBuilder, textNodes, selection);
+ transactionBuilder.commit();
+
+ if (nodeAtStart is TextNode && nodeAtStart.subtype == StyleKey.numberList) {
+ makeFollowingNodesIncremental(
+ editorState, startPosition.path, transactionBuilder.afterSelection!);
+ }
+ return KeyEventResult.handled;
}
if (transactionBuilder.operations.isNotEmpty) {
@@ -156,11 +166,18 @@ KeyEventResult _handleDelete(EditorState editorState, RawKeyEvent event) {
);
}
}
+ transactionBuilder.commit();
} else {
+ final startPosition = selection.start;
+ final nodeAtStart = editorState.document.nodeAtPath(startPosition.path)!;
_deleteTextNodes(transactionBuilder, textNodes, selection);
- }
+ transactionBuilder.commit();
- transactionBuilder.commit();
+ if (nodeAtStart is TextNode && nodeAtStart.subtype == StyleKey.numberList) {
+ makeFollowingNodesIncremental(
+ editorState, startPosition.path, transactionBuilder.afterSelection!);
+ }
+ }
return KeyEventResult.handled;
}
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart
index 0a8ee552cb..e6cb91d318 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart
@@ -37,6 +37,7 @@ ShortcutEventHandler enterWithoutShiftInTextNodesHandler =
// Multiple selection
if (!selection.isSingle) {
+ final startNode = editorState.document.nodeAtPath(selection.start.path)!;
final length = textNodes.length;
final List<TextNode> subTextNodes =
length >= 3 ? textNodes.sublist(1, textNodes.length - 1) : [];
@@ -57,6 +58,12 @@ ShortcutEventHandler enterWithoutShiftInTextNodesHandler =
)
..afterSelection = afterSelection
..commit();
+
+ if (startNode is TextNode && startNode.subtype == StyleKey.numberList) {
+ makeFollowingNodesIncremental(
+ editorState, selection.start.path, afterSelection);
+ }
+
return KeyEventResult.handled;
}