This commit is contained in:
Timothy Jaeryang Baek
2026-03-15 16:54:54 -05:00
parent f9d38a073f
commit 47e47e42af
2 changed files with 43 additions and 0 deletions
@@ -244,6 +244,12 @@
export let showRaw = false;
$: selectedFile, (showRaw = false); // reset to preview mode when switching files
// Auto-switch to raw/editor mode for empty previewable files so the user
// can start editing immediately instead of seeing a blank preview.
$: if (fileContent !== null && fileContent.trim() === '' && (isMarkdown || isCsv || isJson)) {
showRaw = true;
}
let pzInstance: PanZoom | null = null;
const initImagePanzoom = (node: HTMLElement) => {
@@ -424,6 +430,15 @@
<div bind:this={markdownEl} class="prose dark:prose-invert max-w-full text-sm p-3">
{@html renderedHtml}
</div>
{:else if isMarkdown && showRaw}
<div class="h-full">
<FileCodeEditor
bind:this={fileCodeEditorRef}
value={fileContent ?? ''}
filePath={selectedFile}
{onSave}
/>
</div>
{:else if isCsv && !showRaw && csvRows.length > 0}
<div class="absolute inset-0 overflow-auto px-3 pb-3">
<table class="csv-table text-xs font-mono border-collapse">