mirror of
https://github.com/AppFlowy-IO/AppFlowy
synced 2026-05-23 09:08:24 +00:00
fix: #832
This commit is contained in:
parent
a71d9401d5
commit
1b5d717560
1 changed files with 5 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue