add copy event handler
This commit is contained in:
parent
35f3a14787
commit
48008ea040
|
@ -104,17 +104,15 @@ function PhotoViewer(props: Iprops) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!photoSwipe) return;
|
if (!photoSwipe) return;
|
||||||
|
function handleCopyEvent() {
|
||||||
|
copyToClipboardHelper(photoSwipe.currItem as EnteFile);
|
||||||
|
}
|
||||||
|
|
||||||
function handleKeyUp(event: KeyboardEvent) {
|
function handleKeyUp(event: KeyboardEvent) {
|
||||||
if (!isOpen || showInfo) {
|
if (!isOpen || showInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addLocalLog(
|
addLocalLog(() => 'Event: ' + event.key);
|
||||||
() =>
|
|
||||||
'Event: ' +
|
|
||||||
event.key +
|
|
||||||
' isShiftPressedx: ' +
|
|
||||||
event.shiftKey
|
|
||||||
);
|
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'I':
|
case 'I':
|
||||||
|
@ -140,19 +138,17 @@ function PhotoViewer(props: Iprops) {
|
||||||
case 'L':
|
case 'L':
|
||||||
onFavClick(photoSwipe?.currItem as EnteFile);
|
onFavClick(photoSwipe?.currItem as EnteFile);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
|
||||||
case 'C':
|
|
||||||
copyFileToClipboard(photoSwipe.currItem.src);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('keyup', handleKeyUp);
|
window.addEventListener('keyup', handleKeyUp);
|
||||||
|
window.addEventListener('copy', handleCopyEvent);
|
||||||
return () => {
|
return () => {
|
||||||
addLocalLog(() => 'Removing listener');
|
addLocalLog(() => 'Removing listener');
|
||||||
window.removeEventListener('keyup', handleKeyUp);
|
window.removeEventListener('keyup', handleKeyUp);
|
||||||
|
window.removeEventListener('copy', handleCopyEvent);
|
||||||
};
|
};
|
||||||
}, [isOpen, photoSwipe, showInfo]);
|
}, [isOpen, photoSwipe, showInfo]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue