File tree 3 files changed +19
-2
lines changed
layer/renderer/src/modules/command/hooks 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -6,18 +6,26 @@ import { getCommand } from "./use-command"
6
6
import type { BindingCommandId } from "./use-command-shortcut"
7
7
import { useCommandShortcut } from "./use-command-shortcut"
8
8
9
+ export interface HotkeyOptions {
10
+ forceInputElement ?: true
11
+ }
9
12
interface RegisterHotkeyOptions < T extends FollowCommandId > {
10
13
shortcut : string
11
14
commandId : T
12
15
args ?: Parameters < Extract < FollowCommand , { id : T } > [ "run" ] >
13
16
when ?: boolean
17
+
18
+ options ?: HotkeyOptions
14
19
}
15
20
21
+ const IGNORE_INPUT_ELEMENT = [ HTMLInputElement , HTMLTextAreaElement ]
22
+
16
23
export const useCommandHotkey = < T extends FollowCommandId > ( {
17
24
shortcut,
18
25
commandId,
19
26
when,
20
27
args,
28
+ options,
21
29
} : RegisterHotkeyOptions < T > ) => {
22
30
useEffect ( ( ) => {
23
31
if ( ! when ) {
@@ -35,6 +43,15 @@ export const useCommandHotkey = <T extends FollowCommandId>({
35
43
// Create a handler for each shortcut
36
44
shortcuts . forEach ( ( key ) => {
37
45
keyMap [ key ] = ( event ) => {
46
+ const { target } = event
47
+ if (
48
+ ! options ?. forceInputElement &&
49
+ ( IGNORE_INPUT_ELEMENT . some ( ( el ) => target instanceof el ) ||
50
+ ( target as HTMLElement ) . getAttribute ( "contenteditable" ) === "true" )
51
+ ) {
52
+ return
53
+ }
54
+
38
55
event . preventDefault ( )
39
56
event . stopPropagation ( )
40
57
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " Folo" ,
3
3
"type" : " module" ,
4
- "version" : " 0.4.6 " ,
4
+ "version" : " 0.4.7 " ,
5
5
"private" : true ,
6
6
"description" : " Follow everything in one place" ,
7
7
"author" : " Folo Team" ,
28
28
"dev:electron" : " electron-vite dev" ,
29
29
"dev:server" : " pnpm run --filter=ssr dev" ,
30
30
"dev:web" : " cross-env WEB_BUILD=1 vite" ,
31
+ "hotfix" : " vv -c bump.hotfix.config.js" ,
31
32
"publish" : " electron-vite build && electron-forge publish" ,
32
33
"start" : " electron-vite preview" ,
33
34
"update:main-hash" : " tsx plugins/vite/generate-main-hash.ts"
Original file line number Diff line number Diff line change 19
19
"format" : " prettier --write ." ,
20
20
"format:check" : " prettier --check ." ,
21
21
"generator:i18n-template" : " tsx scripts/generate-i18n-locale.ts" ,
22
- "hotfix" : " vv -c bump.hotfix.config.js" ,
23
22
"icons:sync" : " tsx scripts/svg-to-rn.ts && prettier --write apps/mobile/src/icons/**/*.tsx && eslint --fix apps/mobile/src/icons/**/*.tsx" ,
24
23
"icons:update" : " tsx scripts/update-icon.ts" ,
25
24
"lint" : " pnpm run lint:tsl && eslint" ,
You can’t perform that action at this time.
0 commit comments