fix: undo redo handler

This commit is contained in:
Vincent Chan 2022-08-09 13:33:54 +08:00
parent b9de45a110
commit 7c58654fe8
2 changed files with 17 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import 'package:flowy_editor/service/internal_key_event_handlers/enter_without_s
import 'package:flowy_editor/service/internal_key_event_handlers/slash_handler.dart';
import 'package:flowy_editor/service/internal_key_event_handlers/update_text_style_by_command_x_handler.dart';
import 'package:flowy_editor/service/internal_key_event_handlers/whitespace_handler.dart';
import 'package:flowy_editor/service/internal_key_event_handlers/redo_undo_handler.dart';
import 'package:flowy_editor/service/keyboard_service.dart';
import 'package:flowy_editor/service/render_plugin_service.dart';
import 'package:flowy_editor/service/scroll_service.dart';
@ -39,6 +40,7 @@ List<FlowyKeyEventHandler> defaultKeyEventHandler = [
flowyDeleteNodesHandler,
arrowKeysHandler,
copyPasteKeysHandler,
redoUndoKeysHandler,
enterWithoutShiftInTextNodesHandler,
updateTextStyleByCommandXHandler,
whiteSpaceHandler,

View File

@ -0,0 +1,15 @@
import 'package:flowy_editor/service/keyboard_service.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
FlowyKeyEventHandler redoUndoKeysHandler = (editorState, event) {
if (event.isMetaPressed && event.logicalKey == LogicalKeyboardKey.keyZ) {
if (event.isShiftPressed) {
editorState.undoManager.redo();
} else {
editorState.undoManager.undo();
}
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
};