Adding @irev-dev's solution to register all shortcuts
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
|
import { Menu } from '@headlessui/react'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
import Dialog from '@material-ui/core/Dialog'
|
import Dialog from '@material-ui/core/Dialog'
|
||||||
import { editorMenuConfig } from './menuConfig';
|
import { editorMenuConfig } from './menuConfig';
|
||||||
|
import { useIdeContext } from 'src/helpers/hooks/useIdeContext'
|
||||||
|
|
||||||
const SHORTCUT = 'ctrl+/, command+/'
|
const SHORTCUT = 'ctrl+/, command+/'
|
||||||
|
|
||||||
@@ -16,8 +18,22 @@ const AllShortcutsModal = () => {
|
|||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
useHotkeys(SHORTCUT, () => setOpen(!open), [open])
|
useHotkeys(SHORTCUT, () => setOpen(!open), [open])
|
||||||
|
const { state, thunkDispatch } = useIdeContext()
|
||||||
|
|
||||||
return (
|
return (<>
|
||||||
|
<div className="hidden">
|
||||||
|
<Menu>
|
||||||
|
{ editorMenuConfig.filter(menu => menu.items.length).map(menu =>
|
||||||
|
menu.items.map(item => (
|
||||||
|
<item.component
|
||||||
|
state={state}
|
||||||
|
thunkDispatch={thunkDispatch}
|
||||||
|
config={item}
|
||||||
|
key={menu.label +"-"+ item.label } />
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
<Dialog open={open} onClose={() => setOpen(false)} className={classes.root}>
|
<Dialog open={open} onClose={() => setOpen(false)} className={classes.root}>
|
||||||
<div className="bg-ch-gray-700 font-fira-sans max-w-7xl rounded shadow-lg text-ch-gray-300 p-4">
|
<div className="bg-ch-gray-700 font-fira-sans max-w-7xl rounded shadow-lg text-ch-gray-300 p-4">
|
||||||
<h2 className="text-2xl mb-4">All Shortcuts</h2>
|
<h2 className="text-2xl mb-4">All Shortcuts</h2>
|
||||||
@@ -35,7 +51,7 @@ const AllShortcutsModal = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
</>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const fileMenuConfig = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Cook Donut',
|
label: 'Cook Donut',
|
||||||
shortcut: 'ctrl+os+d',
|
shortcut: 'ctrl+d, command+d',
|
||||||
shortcutLabel: cmdOrCtrl() + ' D',
|
shortcutLabel: cmdOrCtrl() + ' D',
|
||||||
component: (props) => {
|
component: (props) => {
|
||||||
const { config } = props
|
const { config } = props
|
||||||
|
|||||||
Reference in New Issue
Block a user