fix: accept multi-key combination for customizing shortcuts & removes duplicates (#5414)

This commit is contained in:
Mayur Mahajan
2024-05-27 06:27:51 +05:30
committed by GitHub
parent a8f136eda2
commit 8b6575d1ee
3 changed files with 57 additions and 29 deletions

View File

@ -56,7 +56,18 @@ final List<CommandShortcutEvent> commandShortcutEvents = [
customPasteCommand,
customCutCommand,
...customTextAlignCommands,
...standardCommandShortcutEvents,
// remove standard shortcuts for copy, cut, paste, todo
...standardCommandShortcutEvents
..removeWhere(
(shortcut) => [
copyCommand,
cutCommand,
pasteCommand,
toggleTodoListCommand,
].contains(shortcut),
),
emojiShortcutEvent,
];
@ -90,7 +101,6 @@ class AppFlowyEditorPage extends StatefulWidget {
final String Function(Node)? placeholderText;
/// Used to provide an initial selection on Page-load
///
final Selection? initialSelection;
final bool useViewInfoBloc;
@ -111,15 +121,8 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
],
);
late final List<CommandShortcutEvent> commandShortcutEvents = [
toggleToggleListCommand,
...localizedCodeBlockCommands,
customCopyCommand,
customPasteCommand,
customCutCommand,
...customTextAlignCommands,
...standardCommandShortcutEvents,
emojiShortcutEvent,
late final List<CommandShortcutEvent> cmdShortcutEvents = [
...commandShortcutEvents,
..._buildFindAndReplaceCommands(),
];
@ -309,7 +312,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
),
// customize the shortcuts
characterShortcutEvents: characterShortcutEvents,
commandShortcutEvents: commandShortcutEvents,
commandShortcutEvents: cmdShortcutEvents,
// customize the context menu items
contextMenuItems: customContextMenuItems,
// customize the header and footer.
@ -401,7 +404,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
final customizeShortcuts =
await settingsShortcutService.getCustomizeShortcuts();
await settingsShortcutService.updateCommandShortcuts(
commandShortcutEvents,
cmdShortcutEvents,
customizeShortcuts,
);
}