mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
4843288b50
Remove keyShortCut from compile function options GitOrigin-RevId: 31b13be5fd6742419d4147b89ef281b1b30227fb
39 lines
958 B
JavaScript
39 lines
958 B
JavaScript
import { useCallback } from 'react'
|
|
import { useDetachCompileContext } from '../../../shared/context/detach-compile-context'
|
|
import PropTypes from 'prop-types'
|
|
|
|
export const Shortcuts = ({ children }) => {
|
|
const { startCompile } = useDetachCompileContext()
|
|
|
|
const handleKeyDown = useCallback(
|
|
event => {
|
|
if (event.metaKey) {
|
|
switch (event.key) {
|
|
case 's':
|
|
case 'Enter':
|
|
event.preventDefault()
|
|
startCompile()
|
|
break
|
|
}
|
|
} else if (event.ctrlKey) {
|
|
switch (event.key) {
|
|
case '.':
|
|
event.preventDefault()
|
|
startCompile()
|
|
break
|
|
}
|
|
}
|
|
},
|
|
[startCompile]
|
|
)
|
|
|
|
return (
|
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
<div onKeyDown={handleKeyDown} role="tabpanel" tabIndex="0">
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|
|
Shortcuts.propTypes = {
|
|
children: PropTypes.node,
|
|
}
|