diff --git a/web/src/lib/components/album-page/album-description.svelte b/web/src/lib/components/album-page/album-description.svelte
index 9e988ba75e..e860fbcd21 100644
--- a/web/src/lib/components/album-page/album-description.svelte
+++ b/web/src/lib/components/album-page/album-description.svelte
@@ -2,6 +2,7 @@
import { autoGrowHeight } from '$lib/utils/autogrow';
import { updateAlbumInfo } from '@immich/sdk';
import { handleError } from '$lib/utils/handle-error';
+ import { shortcut } from '$lib/utils/shortcut';
export let id: string;
export let description: string;
@@ -37,6 +38,10 @@
on:focusout={handleUpdateDescription}
use:autoGrowHeight
placeholder="Add description"
+ use:shortcut={{
+ shortcut: { key: 'Enter', ctrl: true },
+ onShortcut: (e) => e.currentTarget.blur(),
+ }}
/>
{:else if description}
diff --git a/web/src/lib/components/album-page/album-title.svelte b/web/src/lib/components/album-page/album-title.svelte
index 8a4af18eae..2725bb8921 100644
--- a/web/src/lib/components/album-page/album-title.svelte
+++ b/web/src/lib/components/album-page/album-title.svelte
@@ -1,6 +1,7 @@
e.key === 'Enter' && e.currentTarget.blur()}
+ use:shortcut={{ shortcut: { key: 'Enter' }, onShortcut: (e) => e.currentTarget.blur() }}
on:blur={handleUpdateName}
class="w-[99%] mb-2 border-b-2 border-transparent text-6xl text-immich-primary outline-none transition-all dark:text-immich-dark-primary {isOwned
? 'hover:border-gray-400'
diff --git a/web/src/lib/components/album-page/album-viewer.svelte b/web/src/lib/components/album-page/album-viewer.svelte
index ab5eb91d5e..591f90fff8 100644
--- a/web/src/lib/components/album-page/album-viewer.svelte
+++ b/web/src/lib/components/album-page/album-viewer.svelte
@@ -1,11 +1,9 @@
+ {
+ if (!$showAssetViewer && $isMultiSelectState) {
+ assetInteractionStore.clearMultiselect();
+ }
+ },
+ }}
+/>
+
{#if $isMultiSelectState}
{
- if (event.key === 'Enter') {
- event.preventDefault();
- await handleSendComment();
- return;
- }
- };
-
const timeOptions = {
year: 'numeric',
month: '2-digit',
@@ -295,7 +288,10 @@
use:autoGrowHeight={'5px'}
placeholder={disabled ? 'Comments are disabled' : 'Say something'}
on:input={() => autoGrowHeight(textArea, '5px')}
- on:keypress={handleEnter}
+ use:shortcut={{
+ shortcut: { key: 'Enter' },
+ onShortcut: () => handleSendComment(),
+ }}
class="h-[18px] {disabled
? 'cursor-not-allowed'
: ''} w-full max-h-56 pr-2 items-center overflow-y-auto leading-4 outline-none resize-none bg-gray-200"
diff --git a/web/src/lib/components/asset-viewer/asset-viewer.svelte b/web/src/lib/components/asset-viewer/asset-viewer.svelte
index 0af40b4d45..2ddd7ada4f 100644
--- a/web/src/lib/components/asset-viewer/asset-viewer.svelte
+++ b/web/src/lib/components/asset-viewer/asset-viewer.svelte
@@ -13,7 +13,7 @@
import { getAssetJobMessage, isSharedLink, handlePromiseError } from '$lib/utils';
import { addAssetsToAlbum, downloadFile } from '$lib/utils/asset-utils';
import { handleError } from '$lib/utils/handle-error';
- import { shouldIgnoreShortcut } from '$lib/utils/shortcut';
+ import { shortcuts } from '$lib/utils/shortcut';
import { SlideshowHistory } from '$lib/utils/slideshow-history';
import {
AssetJobName,
@@ -256,68 +256,9 @@
isShowActivity = !isShowActivity;
};
- const handleKeypress = async (event: KeyboardEvent) => {
- if (shouldIgnoreShortcut(event)) {
- return;
- }
-
- const key = event.key;
- const shiftKey = event.shiftKey;
- const ctrlKey = event.ctrlKey;
-
- if (ctrlKey) {
- return;
- }
-
- switch (key) {
- case 'a':
- case 'A': {
- if (shiftKey) {
- await toggleArchive();
- }
- return;
- }
- case 'ArrowLeft': {
- await navigateAsset('previous');
- return;
- }
- case 'ArrowRight': {
- await navigateAsset('next');
- return;
- }
- case 'd':
- case 'D': {
- if (shiftKey) {
- await downloadFile(asset);
- }
- return;
- }
- case 'Delete': {
- await trashOrDelete(shiftKey);
- return;
- }
- case 'Escape': {
- if (isShowDeleteConfirmation) {
- isShowDeleteConfirmation = false;
- return;
- }
- if (isShowShareModal) {
- isShowShareModal = false;
- return;
- }
- closeViewer();
- return;
- }
- case 'f': {
- await toggleFavorite();
- return;
- }
- case 'i': {
- isShowActivity = false;
- $isShowDetail = !$isShowDetail;
- return;
- }
- }
+ const toggleDetailPanel = () => {
+ isShowActivity = false;
+ $isShowDetail = !$isShowDetail;
};
const handleCloseViewer = () => {
@@ -557,7 +498,19 @@
};
-
+ navigateAsset('previous') },
+ { shortcut: { key: 'ArrowRight' }, onShortcut: () => navigateAsset('next') },
+ { shortcut: { key: 'd', shift: true }, onShortcut: () => downloadFile(asset) },
+ { shortcut: { key: 'Delete' }, onShortcut: () => trashOrDelete(false) },
+ { shortcut: { key: 'Delete', shift: true }, onShortcut: () => trashOrDelete(true) },
+ { shortcut: { key: 'Escape' }, onShortcut: closeViewer },
+ { shortcut: { key: 'f' }, onShortcut: toggleFavorite },
+ { shortcut: { key: 'i' }, onShortcut: toggleDetailPanel },
+ ]}
+/>
();
- const handleKeypress = async (event: KeyboardEvent) => {
- if (event.target !== textArea) {
- return;
- }
- const ctrl = event.ctrlKey;
- switch (event.key) {
- case 'Enter': {
- if (ctrl && event.target === textArea) {
- await handleFocusOut();
- }
- }
- }
- };
-
const getMegapixel = (width: number, height: number): number | undefined => {
const megapixel = Math.round((height * width) / 1_000_000);
@@ -180,8 +167,6 @@
}
-
-