mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 09:46:30 -05:00
fixed shortcuts for macs
This commit is contained in:
parent
9439855b08
commit
36af0dc841
2 changed files with 8 additions and 10 deletions
|
@ -4,13 +4,14 @@ import { Trans } from 'react-i18next'
|
|||
import { isMac } from '../../utils'
|
||||
|
||||
export const Shortcut: React.FC = () => {
|
||||
const modifierKey = isMac ? <kbd>Cmd</kbd> : <kbd>Ctrl</kbd>
|
||||
const modifierKey = isMac ? <kbd>⌘</kbd> : <kbd>Ctrl</kbd>
|
||||
const altKey = isMac ? <kbd>⌥</kbd> : <kbd>Alt</kbd>
|
||||
|
||||
const shortcutMap: {[category: string]: { [functionName: string]: JSX.Element[] }} = {
|
||||
'View Mode': {
|
||||
'editor.help.shortcuts.view': [modifierKey, <> + </>, <kbd>Alt</kbd>, <> + </>, <kbd>V</kbd>],
|
||||
'editor.help.shortcuts.both': [modifierKey, <> + </>, <kbd>Alt</kbd>, <> + </>, <kbd>B</kbd>],
|
||||
'editor.help.shortcuts.edit': [modifierKey, <> + </>, <kbd>Alt</kbd>, <> + </>, <kbd>E</kbd>]
|
||||
'editor.help.shortcuts.view': [<kbd>Ctrl</kbd>, <> + </>, altKey, <> + </>, <kbd>V</kbd>],
|
||||
'editor.help.shortcuts.both': [<kbd>Ctrl</kbd>, <> + </>, altKey, <> + </>, <kbd>B</kbd>],
|
||||
'editor.help.shortcuts.edit': [<kbd>Ctrl</kbd>, <> + </>, altKey, <> + </>, <kbd>E</kbd>]
|
||||
},
|
||||
Editor: {
|
||||
'editor.help.shortcuts.bold': [modifierKey, <> + </>, <kbd>B</kbd>],
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
import { setEditorMode } from '../../../redux/editor/methods'
|
||||
import { EditorMode } from '../app-bar/editor-view-mode'
|
||||
import { isMac } from '../utils'
|
||||
|
||||
export const shortcutHandler = (event: KeyboardEvent): void => {
|
||||
const modifierKey = isMac ? event.metaKey : event.ctrlKey
|
||||
|
||||
if (modifierKey && event.altKey && event.key === 'b') {
|
||||
if (event.ctrlKey && event.altKey && event.key === 'b') {
|
||||
setEditorMode(EditorMode.BOTH)
|
||||
}
|
||||
|
||||
if (modifierKey && event.altKey && event.key === 'v') {
|
||||
if (event.ctrlKey && event.altKey && event.key === 'v') {
|
||||
setEditorMode(EditorMode.PREVIEW)
|
||||
}
|
||||
|
||||
if (modifierKey && event.altKey && event.key === 'e') {
|
||||
if (event.ctrlKey && event.altKey && event.key === 'e') {
|
||||
setEditorMode(EditorMode.EDITOR)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue