Skip to content

Commit

Permalink
fix: unable to delete node on the mobile platform
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 committed Jun 1, 2023
1 parent c573b9a commit a7d2d32
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
3 changes: 1 addition & 2 deletions example/lib/pages/simple_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ class SimpleEditor extends StatelessWidget {
EditorState editorState,
ScrollController? scrollController,
) {
return AppFlowyEditor.custom(
return AppFlowyEditor.standard(
editorStyle: const EditorStyle.mobile(),
editorState: editorState,
scrollController: scrollController,
blockComponentBuilders: standardBlockComponentBuilderMap,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,6 @@ Future<void> onDelete(
return;
}

// single line
if (selection.isSingle) {
final node = editorState.getNodeAtPath(selection.end.path);
final delta = node?.delta;
if (node == null || delta == null) {
return;
}

final transaction = editorState.transaction
..deleteText(
node,
deletion.deletedRange.start,
deletion.textDeleted.length,
);
return editorState.apply(transaction);
} else {
throw UnimplementedError();
}
// use backspace command instead.
backspaceCommand.execute(editorState);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
/// - support
/// - desktop
/// - web
/// - mobile
///
final CommandShortcutEvent backspaceCommand = CommandShortcutEvent(
key: 'backspace',
Expand Down Expand Up @@ -111,10 +112,6 @@ CommandShortcutEventHandler _deleteLeftSentenceCommandHandler = (editorState) {
};

CommandShortcutEventHandler _backspaceCommandHandler = (editorState) {
if (PlatformExtension.isMobile) {
assert(false, 'backspaceCommand is not supported on mobile platform.');
return KeyEventResult.ignored;
}
final selection = editorState.selection;
if (selection == null) {
return KeyEventResult.ignored;
Expand Down

0 comments on commit a7d2d32

Please sign in to comment.