feat(comments): support comment deletion and video player shortcuts

This commit is contained in:
yiling
2026-07-16 09:55:05 +08:00
parent fa6bf73452
commit 62b1fc1d37
16 changed files with 463 additions and 50 deletions
@@ -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],