From d5ff55e23ed0ade6979e2d87bb48be9349e1ef98 Mon Sep 17 00:00:00 2001
From: Ajay Bura <32841439+ajbura@users.noreply.github.com>
Date: Sat, 21 Oct 2023 18:14:33 +1100
Subject: [PATCH] Fix hotkeys (#1468)
* use hotkey using key instead of which (default)
* remove shift from block formatting hotkeys
* smartly exit formatting with backspace
* set markdown to off by default
* exit formatting with escape
---
src/app/components/editor/Toolbar.tsx | 23 +++------
.../editor/autocomplete/AutocompleteMenu.tsx | 6 +--
src/app/components/editor/keyboard.ts | 47 +++++++++++++++----
src/app/components/emoji-board/EmojiBoard.tsx | 6 +--
src/app/organisms/room/RoomInput.tsx | 8 ++--
src/app/organisms/room/RoomTimeline.tsx | 4 +-
.../organisms/room/message/MessageEditor.tsx | 8 ++--
src/app/state/settings.ts | 2 +-
src/app/utils/keyboard.ts | 6 +--
9 files changed, 65 insertions(+), 45 deletions(-)
diff --git a/src/app/components/editor/Toolbar.tsx b/src/app/components/editor/Toolbar.tsx
index 342dd1060..766a1d839 100644
--- a/src/app/components/editor/Toolbar.tsx
+++ b/src/app/components/editor/Toolbar.tsx
@@ -261,33 +261,22 @@ export function Toolbar() {
- }
+ tooltip={}
/>
- }
+ tooltip={}
/>
- }
+ tooltip={}
/>
- }
+ tooltip={}
/>
@@ -296,7 +285,9 @@ export function Toolbar() {
}
+ tooltip={
+
+ }
/>
>
diff --git a/src/app/components/editor/autocomplete/AutocompleteMenu.tsx b/src/app/components/editor/autocomplete/AutocompleteMenu.tsx
index e7c8df388..fc4327daf 100644
--- a/src/app/components/editor/autocomplete/AutocompleteMenu.tsx
+++ b/src/app/components/editor/autocomplete/AutocompleteMenu.tsx
@@ -1,6 +1,6 @@
import React, { ReactNode } from 'react';
import FocusTrap from 'focus-trap-react';
-import isHotkey from 'is-hotkey';
+import { isKeyHotkey } from 'is-hotkey';
import { Header, Menu, Scroll, config } from 'folds';
import * as css from './AutocompleteMenu.css';
@@ -22,8 +22,8 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto
returnFocusOnDeactivate: false,
clickOutsideDeactivates: true,
allowOutsideClick: true,
- isKeyForward: (evt: KeyboardEvent) => isHotkey('arrowdown', evt),
- isKeyBackward: (evt: KeyboardEvent) => isHotkey('arrowup', evt),
+ isKeyForward: (evt: KeyboardEvent) => isKeyHotkey('arrowdown', evt),
+ isKeyBackward: (evt: KeyboardEvent) => isKeyHotkey('arrowup', evt),
}}
>