mirror of
https://github.com/responsively-org/responsively-app
synced 2024-11-10 06:44:13 +00:00
feat: added hotkeys list
This commit is contained in:
parent
b38bad9f1c
commit
6a13dbdebd
2 changed files with 35 additions and 7 deletions
|
@ -1,7 +1,40 @@
|
|||
export const SHORTCUT_CHANNEL = {
|
||||
ZOOM_IN: 'ZOOM_IN',
|
||||
ZOOM_OUT: 'ZOOM_OUT',
|
||||
ROTATE_ALL: 'ROTATE_ALL',
|
||||
SCREENSHOT_ALL: 'SCREENSHOT_ALL',
|
||||
INSPECT_ELEMENTS: 'INSPECT_ELEMENTS',
|
||||
PREVIEW_LAYOUT: 'PREVIEW_LAYOUT',
|
||||
THEME: 'THEME',
|
||||
BACK: 'BACK',
|
||||
FORWARD: 'FORWARD',
|
||||
RELOAD: 'RELOAD',
|
||||
BOOKMARK: 'BOOKMARK',
|
||||
DELETE_CACHE: 'DELETE_CACHE',
|
||||
DELETE_STORAGE: 'DELETE_STORAGE',
|
||||
DELETE_COOKIES: 'DELETE_COOKIES',
|
||||
DELETE_ALL: 'DELETE_ALL',
|
||||
EDIT_URL: 'EDIT_URL',
|
||||
} as const;
|
||||
|
||||
export type ShortcutChannel =
|
||||
typeof SHORTCUT_CHANNEL[keyof typeof SHORTCUT_CHANNEL];
|
||||
|
||||
export const SHORTCUT_KEYS: { [key in ShortcutChannel]: string[] } = {
|
||||
[SHORTCUT_CHANNEL.ZOOM_IN]: ['mod+=', 'mod++', 'mod+shift+='],
|
||||
[SHORTCUT_CHANNEL.ZOOM_OUT]: ['mod+-'],
|
||||
[SHORTCUT_CHANNEL.ROTATE_ALL]: ['mod+alt+r'],
|
||||
[SHORTCUT_CHANNEL.SCREENSHOT_ALL]: ['mod+s'],
|
||||
[SHORTCUT_CHANNEL.INSPECT_ELEMENTS]: ['mod+i'],
|
||||
[SHORTCUT_CHANNEL.PREVIEW_LAYOUT]: ['mod+shift+l'],
|
||||
[SHORTCUT_CHANNEL.THEME]: ['mod+t'],
|
||||
[SHORTCUT_CHANNEL.BACK]: ['alt+left'],
|
||||
[SHORTCUT_CHANNEL.FORWARD]: ['alt+right'],
|
||||
[SHORTCUT_CHANNEL.RELOAD]: ['mod+r'],
|
||||
[SHORTCUT_CHANNEL.BOOKMARK]: ['mod+d'],
|
||||
[SHORTCUT_CHANNEL.DELETE_CACHE]: ['mod+alt+z'],
|
||||
[SHORTCUT_CHANNEL.DELETE_STORAGE]: ['mod+alt+q'],
|
||||
[SHORTCUT_CHANNEL.DELETE_COOKIES]: ['mod+alt+a'],
|
||||
[SHORTCUT_CHANNEL.DELETE_ALL]: ['mod+alt+del', 'mod+alt+backspace'],
|
||||
[SHORTCUT_CHANNEL.EDIT_URL]: ['mod+l'],
|
||||
};
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
import { SHORTCUT_CHANNEL, ShortcutChannel } from './constants';
|
||||
import { SHORTCUT_KEYS, ShortcutChannel } from './constants';
|
||||
import useMousetrapEmitter from './useMousetrapEmitter';
|
||||
|
||||
const shortcuts: { [key in ShortcutChannel]: string[] } = {
|
||||
[SHORTCUT_CHANNEL.ZOOM_IN]: ['mod+=', 'mod++', 'mod+shift+='],
|
||||
[SHORTCUT_CHANNEL.ZOOM_OUT]: ['mod+-'],
|
||||
};
|
||||
|
||||
const KeyboardShortcutsManager = () => {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const [channel, keys] of Object.entries(shortcuts)) {
|
||||
for (const [channel, keys] of Object.entries(SHORTCUT_KEYS)) {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
useMousetrapEmitter(keys, channel as ShortcutChannel);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue