refac
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user