Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
04a91152
Commit
04a91152
authored
May 06, 2024
by
Timothy J. Baek
Browse files
feat: esc image preview
parent
7874bea5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
src/lib/components/common/ImagePreview.svelte
src/lib/components/common/ImagePreview.svelte
+25
-0
No files found.
src/lib/components/common/ImagePreview.svelte
View file @
04a91152
<script lang="ts">
<script lang="ts">
import { onMount } from 'svelte';
export let show = false;
export let show = false;
export let src = '';
export let src = '';
export let alt = '';
export let alt = '';
let mounted = false;
const downloadImage = (url, filename) => {
const downloadImage = (url, filename) => {
fetch(url)
fetch(url)
.then((response) => response.blob())
.then((response) => response.blob())
...
@@ -18,6 +22,27 @@
...
@@ -18,6 +22,27 @@
})
})
.catch((error) => console.error('Error downloading image:', error));
.catch((error) => console.error('Error downloading image:', error));
};
};
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
console.log('Escape');
show = false;
}
};
onMount(() => {
mounted = true;
});
$: if (mounted) {
if (show) {
window.addEventListener('keydown', handleKeyDown);
document.body.style.overflow = 'hidden';
} else {
window.removeEventListener('keydown', handleKeyDown);
document.body.style.overflow = 'unset';
}
}
</script>
</script>
{#if show}
{#if show}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment