This commit is contained in:
Timothy Jaeryang Baek
2026-03-01 14:38:10 -06:00
parent 201b93bfcc
commit 5645d5bccc
3 changed files with 123 additions and 33 deletions
+11
View File
@@ -477,6 +477,17 @@
</button>
</Tooltip>
{/if}
{#if filePdfData !== null}
<Tooltip content={$i18n.t('Reset view')}>
<button
class="shrink-0 p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 transition text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-400"
on:click={() => filePreviewRef?.resetPdfView()}
aria-label={$i18n.t('Reset view')}
>
<Reset className="size-3.5" />
</button>
</Tooltip>
{/if}
{#if (isMarkdown || isCsv) && fileContent !== null && !editing}
<Tooltip content={showRaw ? $i18n.t('Preview') : $i18n.t('Source')}>
<button
@@ -6,6 +6,8 @@
import Spinner from '../../common/Spinner.svelte';
import PDFViewer from '../../common/PDFViewer.svelte';
let pdfViewerRef: PDFViewer;
const i18n = getContext('i18n');
export let selectedFile: string | null = null;
@@ -135,13 +137,17 @@
}
};
export const resetPdfView = () => {
pdfViewerRef?.resetView();
};
onDestroy(() => {
disposePanzoom();
});
</script>
<div
class="flex-1 {fileImageUrl !== null || filePdfData !== null
class="flex-1 {fileImageUrl !== null
? 'overflow-hidden'
: 'overflow-y-auto'} min-h-0 relative h-full"
>
@@ -158,7 +164,7 @@
/>
</div>
{:else if filePdfData !== null}
<PDFViewer data={filePdfData} className="w-full h-full" />
<PDFViewer bind:this={pdfViewerRef} data={filePdfData} className="w-full h-full" />
{:else if fileContent !== null}
{#if isMarkdown && !showRaw}
<div class="prose dark:prose-invert max-w-full text-sm p-3">