Skip to content

Commit ed1b959

Browse files
committed
refac
1 parent d2b3812 commit ed1b959

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/lib/components/chat/FileNav/FilePreview.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { getContext, onDestroy } from 'svelte';
2+
import { getContext, onDestroy, tick } from 'svelte';
33
import panzoom, { type PanZoom } from 'panzoom';
44
import { marked } from 'marked';
55
import DOMPurify from 'dompurify';
@@ -19,6 +19,7 @@
1919
export let editing = false;
2020
let editContent = '';
2121
export let saving = false;
22+
let editTextarea: HTMLTextAreaElement;
2223
2324
// Reset edit state when switching files
2425
$: selectedFile, resetEdit();
@@ -29,10 +30,12 @@
2930
saving = false;
3031
};
3132
32-
export const startEdit = () => {
33+
export const startEdit = async () => {
3334
editContent = fileContent ?? '';
3435
editing = true;
3536
showRaw = true;
37+
await tick();
38+
editTextarea?.focus();
3639
};
3740
3841
export const saveEdit = async () => {
@@ -191,6 +194,7 @@
191194
{:else}
192195
{#if editing}
193196
<textarea
197+
bind:this={editTextarea}
194198
bind:value={editContent}
195199
class="w-full h-full text-xs font-mono text-gray-800 dark:text-gray-200 whitespace-pre break-all leading-relaxed p-3 bg-transparent border-none outline-none resize-none"
196200
spellcheck="false"

0 commit comments

Comments
 (0)