mirror of
https://github.com/ente-io/ente.git
synced 2025-08-14 02:07:33 +00:00
help
This commit is contained in:
@@ -662,12 +662,16 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
case "toggle-fullscreen":
|
case "toggle-fullscreen":
|
||||||
handleToggleFullscreen();
|
handleToggleFullscreen();
|
||||||
break;
|
break;
|
||||||
|
case "help":
|
||||||
|
handleShortcuts();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
handleConfirmDelete,
|
handleConfirmDelete,
|
||||||
handleCopyImage,
|
handleCopyImage,
|
||||||
handleToggleFullscreen,
|
handleToggleFullscreen,
|
||||||
|
handleShortcuts,
|
||||||
activeAnnotatedFile,
|
activeAnnotatedFile,
|
||||||
canCopyImage,
|
canCopyImage,
|
||||||
],
|
],
|
||||||
@@ -942,6 +946,7 @@ const Shortcuts: React.FC<ModalVisibilityProps> = ({ open, onClose }) => (
|
|||||||
<Shortcut action="Delete" shortcut="Delete, Backspace" />
|
<Shortcut action="Delete" shortcut="Delete, Backspace" />
|
||||||
<Shortcut action="Copy as PNG" shortcut="^C / ⌘C" />
|
<Shortcut action="Copy as PNG" shortcut="^C / ⌘C" />
|
||||||
<Shortcut action="Toggle fullscreen" shortcut="F" />
|
<Shortcut action="Toggle fullscreen" shortcut="F" />
|
||||||
|
<Shortcut action="Show shortcuts" shortcut="?" />
|
||||||
</ShortcutsContent>
|
</ShortcutsContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
@@ -87,7 +87,9 @@ export interface FileViewerPhotoSwipeDelegate {
|
|||||||
* so the delegate must validate and only then perform the action if it is
|
* so the delegate must validate and only then perform the action if it is
|
||||||
* appropriate.
|
* appropriate.
|
||||||
*/
|
*/
|
||||||
performKeyAction: (action: "delete" | "copy" | "toggle-fullscreen") => void;
|
performKeyAction: (
|
||||||
|
action: "delete" | "copy" | "toggle-fullscreen" | "help",
|
||||||
|
) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileViewerPhotoSwipeOptions = Pick<
|
type FileViewerPhotoSwipeOptions = Pick<
|
||||||
@@ -724,6 +726,8 @@ export class FileViewerPhotoSwipe {
|
|||||||
const handleToggleFullscreen = () =>
|
const handleToggleFullscreen = () =>
|
||||||
delegate.performKeyAction("toggle-fullscreen");
|
delegate.performKeyAction("toggle-fullscreen");
|
||||||
|
|
||||||
|
const handleHelp = () => delegate.performKeyAction("help");
|
||||||
|
|
||||||
pswp.on("keydown", (pswpEvent) => {
|
pswp.on("keydown", (pswpEvent) => {
|
||||||
// Ignore keyboard events when we do not have "focus".
|
// Ignore keyboard events when we do not have "focus".
|
||||||
if (delegate.shouldIgnoreKeyboardEvent()) {
|
if (delegate.shouldIgnoreKeyboardEvent()) {
|
||||||
@@ -747,17 +751,25 @@ export class FileViewerPhotoSwipe {
|
|||||||
// since that should match the user's expectation.
|
// since that should match the user's expectation.
|
||||||
|
|
||||||
let cb: (() => void) | undefined;
|
let cb: (() => void) | undefined;
|
||||||
if (e.shiftKey || e.altKey || e.metaKey || e.ctrlKey) {
|
if (e.shiftKey) {
|
||||||
// Ignore except using Ctrl/Cmd-C for copy.
|
// Ignore except "?" for help.
|
||||||
if ((e.metaKey || e.ctrlKey) && lkey == "c") {
|
if (key == "?") cb = handleHelp;
|
||||||
cb = handleCopy;
|
} else if (e.altKey) {
|
||||||
}
|
// Ignore.
|
||||||
|
} else if (e.metaKey || e.ctrlKey) {
|
||||||
|
// Ignore except Ctrl/Cmd-C for copy
|
||||||
|
if (lkey == "c") cb = handleCopy;
|
||||||
} else {
|
} else {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "Backspace":
|
case "Backspace":
|
||||||
case "Delete":
|
case "Delete":
|
||||||
cb = handleDelete;
|
cb = handleDelete;
|
||||||
break;
|
break;
|
||||||
|
// We check for "?"" both with an without shift, since some
|
||||||
|
// keyboards might have it emittable without shift.
|
||||||
|
case "?":
|
||||||
|
cb = handleHelp;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
switch (lkey) {
|
switch (lkey) {
|
||||||
case "w":
|
case "w":
|
||||||
|
Reference in New Issue
Block a user