mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 09:15:35 +03:00
fix: Change shortcut listeners from window to document (#18416)
* fix: Change shortcut listeners to document * fix: split into window and document * chore: upgrade ui package
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
use:shortcut={{
|
||||
shortcut: { key: 'Escape' },
|
||||
onShortcut: () => {
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
use:shortcut={{ shortcut: { key: 'l', shift: shared }, onShortcut: () => (showSelectionModal = true) }}
|
||||
/>
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:window use:shortcut={{ shortcut: { key: 'a', shift: true }, onShortcut: onArchive }} />
|
||||
<svelte:document use:shortcut={{ shortcut: { key: 'a', shift: true }, onShortcut: onArchive }} />
|
||||
|
||||
<MenuOption
|
||||
icon={asset.isArchived ? mdiArchiveArrowUpOutline : mdiArchiveArrowDownOutline}
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
let { onClose }: Props = $props();
|
||||
</script>
|
||||
|
||||
<svelte:window use:shortcut={{ shortcut: { key: 'Escape' }, onShortcut: onClose }} />
|
||||
<svelte:document use:shortcut={{ shortcut: { key: 'Escape' }, onShortcut: onClose }} />
|
||||
|
||||
<CircleIconButton color="opaque" icon={mdiArrowLeft} title={$t('go_back')} onclick={onClose} />
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
use:shortcuts={[
|
||||
{ shortcut: { key: 'Delete' }, onShortcut: () => trashOrDelete(asset.isTrashed) },
|
||||
{ shortcut: { key: 'Delete', shift: true }, onShortcut: () => trashOrDelete(true) },
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
const onDownloadFile = async () => downloadFile(await getAssetInfo({ id: asset.id, key: authManager.key }));
|
||||
</script>
|
||||
|
||||
<svelte:window use:shortcut={{ shortcut: { key: 'd', shift: true }, onShortcut: onDownloadFile }} />
|
||||
<svelte:document use:shortcut={{ shortcut: { key: 'd', shift: true }, onShortcut: onDownloadFile }} />
|
||||
|
||||
{#if !menuItem}
|
||||
<CircleIconButton color="opaque" icon={mdiFolderDownloadOutline} title={$t('download')} onclick={onDownloadFile} />
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:window use:shortcut={{ shortcut: { key: 'f' }, onShortcut: toggleFavorite }} />
|
||||
<svelte:document use:shortcut={{ shortcut: { key: 'f' }, onShortcut: toggleFavorite }} />
|
||||
|
||||
<CircleIconButton
|
||||
color="opaque"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
let { onNextAsset }: Props = $props();
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
use:shortcuts={[
|
||||
{ shortcut: { key: 'ArrowRight' }, onShortcut: onNextAsset },
|
||||
{ shortcut: { key: 'd' }, onShortcut: onNextAsset },
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
let { onPreviousAsset }: Props = $props();
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
use:shortcuts={[
|
||||
{ shortcut: { key: 'ArrowLeft' }, onShortcut: onPreviousAsset },
|
||||
{ shortcut: { key: 'a' }, onShortcut: onPreviousAsset },
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
let { onShowDetail }: Props = $props();
|
||||
</script>
|
||||
|
||||
<svelte:window use:shortcut={{ shortcut: { key: 'i' }, onShortcut: onShowDetail }} />
|
||||
<svelte:document use:shortcut={{ shortcut: { key: 'i' }, onShortcut: onShowDetail }} />
|
||||
|
||||
<CircleIconButton color="opaque" icon={mdiInformationOutline} onclick={onShowDetail} title={$t('info')} />
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
const onConfirm = () => (typeof $showCancelConfirmDialog === 'boolean' ? null : $showCancelConfirmDialog());
|
||||
</script>
|
||||
|
||||
<svelte:window use:shortcut={{ shortcut: { key: 'Escape' }, onShortcut: onClose }} />
|
||||
<svelte:document use:shortcut={{ shortcut: { key: 'Escape' }, onShortcut: onClose }} />
|
||||
|
||||
<section class="relative p-2 dark:bg-immich-dark-bg dark:text-immich-dark-fg">
|
||||
<div class="flex place-items-center gap-2">
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
let containerHeight = $state(0);
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
use:shortcuts={[
|
||||
{ shortcut: { key: 'c', ctrl: true }, onShortcut: onCopyShortcut, preventDefault: false },
|
||||
{ shortcut: { key: 'c', meta: true }, onShortcut: onCopyShortcut, preventDefault: false },
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
onmousemove={showControlBar}
|
||||
use:shortcuts={[
|
||||
{ shortcut: { key: 'Escape' }, onShortcut: onClose },
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
let toggleButton = $derived(toggleButtonOptions[getNextVisibility(toggleVisibility)]);
|
||||
</script>
|
||||
|
||||
<svelte:window use:shortcut={{ shortcut: { key: 'Escape' }, onShortcut: onClose }} />
|
||||
<svelte:document use:shortcut={{ shortcut: { key: 'Escape' }, onShortcut: onClose }} />
|
||||
|
||||
<div
|
||||
class="fixed top-0 flex h-16 w-full items-center justify-between border-b bg-white p-1 dark:border-immich-dark-gray dark:bg-black dark:text-immich-dark-fg md:p-8"
|
||||
|
||||
@@ -301,7 +301,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
use:shortcuts={$isViewing
|
||||
? []
|
||||
: [
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
let menuItemIcon = $derived(getAssets().length === 1 ? mdiFileDownloadOutline : mdiFolderDownloadOutline);
|
||||
</script>
|
||||
|
||||
<svelte:window use:shortcut={{ shortcut: { key: 'd', shift: true }, onShortcut: handleDownloadFiles }} />
|
||||
<svelte:document use:shortcut={{ shortcut: { key: 'd', shift: true }, onShortcut: handleDownloadFiles }} />
|
||||
|
||||
{#if menuItem}
|
||||
<MenuOption text={$t('download')} icon={menuItemIcon} onClick={handleDownloadFiles} />
|
||||
|
||||
@@ -712,7 +712,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeyDown} onkeyup={onKeyUp} onselectstart={onSelectStart} use:shortcuts={shortcutList} />
|
||||
<svelte:document onkeydown={onKeyDown} onkeyup={onKeyUp} onselectstart={onSelectStart} use:shortcuts={shortcutList} />
|
||||
|
||||
{#if isShowDeleteConfirmation}
|
||||
<DeleteAssetDialog
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script lang="ts">
|
||||
import Icon from '$lib/components/elements/icon.svelte';
|
||||
import { generateId } from '$lib/utils/generate-id';
|
||||
import { optionClickCallbackStore, selectedIdStore } from '$lib/stores/context-menu.store';
|
||||
import type { Shortcut } from '$lib/actions/shortcut';
|
||||
import { shortcutLabel as computeShortcutLabel, shortcut as bindShortcut } from '$lib/actions/shortcut';
|
||||
import { shortcut as bindShortcut, shortcutLabel as computeShortcutLabel } from '$lib/actions/shortcut';
|
||||
import Icon from '$lib/components/elements/icon.svelte';
|
||||
import { optionClickCallbackStore, selectedIdStore } from '$lib/stores/context-menu.store';
|
||||
import { generateId } from '$lib/utils/generate-id';
|
||||
|
||||
interface Props {
|
||||
text: string;
|
||||
@@ -44,7 +44,7 @@
|
||||
: () => {};
|
||||
</script>
|
||||
|
||||
<svelte:window use:bindShortcutIfSet />
|
||||
<svelte:document use:bindShortcutIfSet />
|
||||
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<!-- svelte-ignore a11y_mouse_events_have_key_events -->
|
||||
|
||||
@@ -446,7 +446,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
onkeydown={onKeyDown}
|
||||
onkeyup={onKeyUp}
|
||||
onselectstart={onSelectStart}
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
use:shortcuts={[
|
||||
{ shortcut: { key: 'Escape' }, onShortcut: onEscape },
|
||||
{ shortcut: { ctrl: true, key: 'k' }, onShortcut: () => input?.select() },
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
use:shortcuts={[
|
||||
{ shortcut: { key: 'a' }, onShortcut: onSelectAll },
|
||||
{
|
||||
|
||||
@@ -248,7 +248,8 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window use:shortcut={{ shortcut: { key: 'Escape' }, onShortcut: onEscape }} bind:scrollY />
|
||||
<svelte:window bind:scrollY />
|
||||
<svelte:document use:shortcut={{ shortcut: { key: 'Escape' }, onShortcut: onEscape }} />
|
||||
|
||||
<section>
|
||||
{#if assetInteraction.selectionActive}
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
{/if}
|
||||
</svelte:head>
|
||||
|
||||
<svelte:window
|
||||
<svelte:document
|
||||
use:shortcut={{
|
||||
shortcut: { ctrl: true, shift: true, key: 'm' },
|
||||
onShortcut: () => copyToClipboard(getMyImmichLink().toString()),
|
||||
|
||||
Reference in New Issue
Block a user