Save current image from the gallery view by pressing Ctrl-S
This commit is contained in:
@@ -161,7 +161,7 @@ export function Lightbox({
|
|||||||
}, [setVideoTime, videoElement]);
|
}, [setVideoTime, videoElement]);
|
||||||
|
|
||||||
const handleSave = (
|
const handleSave = (
|
||||||
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
event: KeyboardEvent | React.MouseEvent<HTMLButtonElement, MouseEvent>
|
||||||
) => {
|
) => {
|
||||||
if (isViewOnce) {
|
if (isViewOnce) {
|
||||||
return;
|
return;
|
||||||
@@ -193,6 +193,8 @@ export function Lightbox({
|
|||||||
|
|
||||||
const onKeyDown = useCallback(
|
const onKeyDown = useCallback(
|
||||||
(event: KeyboardEvent) => {
|
(event: KeyboardEvent) => {
|
||||||
|
const isMacOS = (window.platform === 'darwin');
|
||||||
|
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case 'Escape': {
|
case 'Escape': {
|
||||||
closeLightbox();
|
closeLightbox();
|
||||||
@@ -211,10 +213,16 @@ export function Lightbox({
|
|||||||
onNext(event);
|
onNext(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
if (isMacOS ? event.metaKey : event.ctrlKey) {
|
||||||
|
handleSave(event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[closeLightbox, onNext, onPrevious]
|
[closeLightbox, onNext, onPrevious, handleSave]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onClose = (event: React.MouseEvent<HTMLElement>) => {
|
const onClose = (event: React.MouseEvent<HTMLElement>) => {
|
||||||
|
Reference in New Issue
Block a user