From 6c1bfaf15efc5e021d7bdd79fe1d90089378d97e Mon Sep 17 00:00:00 2001 From: fen Date: Thu, 10 Sep 2026 11:49:52 -0500 Subject: [PATCH] Fix #184: file upload replaces the main editing area on /new Image files render fitted into the editor area (editor and gutter hidden); the title auto-fills with the file name. Text files always load their content into the editor, replacing any text already there, instead of only filling an empty editor. Title auto-fill still only applies when the title is blank; a typed title is never overwritten. Drawing and cropping tools are noted in the issue as possible future work and are intentionally not implemented here. --- internal/web/static/new.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/web/static/new.js b/internal/web/static/new.js index 1ce5147..816f089 100644 --- a/internal/web/static/new.js +++ b/internal/web/static/new.js @@ -280,11 +280,12 @@ async function showFileInEditor(file) { if (!TEXT_EXTS.has(extOf(file.name))) return; // unknown binary: leave editor alone try { const text = await file.text(); - if (!content.value.trim()) { - content.value = text; - updateGutter(); - guessLang(); - } + // #184: the file replaces the main editing area, so the text always + // loads over whatever was in the editor (same rule as images, which + // hide the editor entirely). + content.value = text; + updateGutter(); + guessLang(); } catch (e) {} } @@ -306,9 +307,10 @@ function setAttachedFile(file) { attachedFile = file; renderFileChip(); setHidden('file-text-note', false); - // #171: title auto-fill — images take the file name; text files use the - // language-placeholder convention (e.g. Python.py, fallback Text.txt). - // Only when the title is still blank; never overwrite a typed title. + // #171/#184: title auto-fill — images take the file name; text files + // use the language-placeholder convention (e.g. Python.py, fallback + // Text.txt). Only when the title is still blank; never overwrite a + // typed title. if (!$('title').value.trim()) { if (IMAGE_RE.test(file.type)) { $('title').value = file.name; -- 2.54.0