mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Added keyboard shortcuts for zoom (#5334)
GitOrigin-RevId: b284f923e9b4aba7837430239b09e05bb0308d09
This commit is contained in:
parent
a4799c29b6
commit
07ca18cdbb
1 changed files with 26 additions and 1 deletions
|
@ -228,10 +228,35 @@ function PdfJsViewer({ url }) {
|
|||
}
|
||||
}, [pdfJsWrapper])
|
||||
|
||||
const handleKeyDown = useCallback(
|
||||
event => {
|
||||
if (!initialised) {
|
||||
return
|
||||
}
|
||||
if ((event.metaKey || event.ctrlKey) && event.key === '=') {
|
||||
event.preventDefault()
|
||||
setZoom('zoom-in')
|
||||
} else if ((event.metaKey || event.ctrlKey) && event.key === '-') {
|
||||
event.preventDefault()
|
||||
setZoom('zoom-out')
|
||||
} else if ((event.metaKey || event.ctrlKey) && event.key === '0') {
|
||||
event.preventDefault()
|
||||
setZoom('fit-width')
|
||||
}
|
||||
},
|
||||
[initialised, setZoom]
|
||||
)
|
||||
|
||||
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */
|
||||
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
||||
return (
|
||||
<div className="pdfjs-viewer" ref={handleContainer}>
|
||||
<div className="pdfjs-viewer-inner" tabIndex="0">
|
||||
<div
|
||||
className="pdfjs-viewer-inner"
|
||||
role="tabpanel"
|
||||
tabIndex="0"
|
||||
onKeyDown={handleKeyDown}
|
||||
>
|
||||
<div className="pdfViewer" />
|
||||
</div>
|
||||
<div className="pdfjs-controls">
|
||||
|
|
Loading…
Reference in a new issue