mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 15:14:10 +00:00
feat(comments): support comment deletion and video player shortcuts
This commit is contained in:
@@ -149,6 +149,31 @@ export function CompareViewer({
|
||||
applyBoth((h) => (shouldPlay ? h.play() : h.pause()))
|
||||
}, [activeState?.video?.isPlaying, applyBoth])
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
const activeEl = document.activeElement
|
||||
if (
|
||||
activeEl &&
|
||||
(activeEl.tagName === 'INPUT' ||
|
||||
activeEl.tagName === 'TEXTAREA' ||
|
||||
activeEl.hasAttribute('contenteditable') ||
|
||||
activeEl.getAttribute('contenteditable') === 'true')
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
if (e.key === ' ' || e.key.toLowerCase() === 'k') {
|
||||
e.preventDefault()
|
||||
handleTogglePlay()
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', handleKeyDown)
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKeyDown)
|
||||
}
|
||||
}, [handleTogglePlay])
|
||||
|
||||
const handleSeek = useCallback(
|
||||
(frame: number) => applyBoth((h) => h.seekToFrame(frame)),
|
||||
[applyBoth],
|
||||
|
||||
Reference in New Issue
Block a user