-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement readonly view for pdf files (#1849)
Signed-off-by: Ryan Hopper-Lowe <[email protected]>
- Loading branch information
1 parent
ab4593a
commit aa8a0e3
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script lang="ts"> | ||
import type { EditorItem } from '$lib/stores/editor.svelte'; | ||
type Props = { | ||
file: EditorItem; | ||
height?: number | string; | ||
}; | ||
const { file, height = '100%' }: Props = $props(); | ||
let blobUrl = $state<string>(); | ||
$effect(() => { | ||
if (!file.blob) return; | ||
const url = URL.createObjectURL(new Blob([file.blob], { type: 'application/pdf' })); | ||
blobUrl = url; | ||
return () => URL.revokeObjectURL(url); | ||
}); | ||
</script> | ||
|
||
<div> | ||
{#if blobUrl} | ||
<embed src={blobUrl} width="100%" {height} /> | ||
{/if} | ||
</div> |