Merge pull request 'Fix #184: file upload replaces the main editing area on /new' (#189) from fix-184 into dev
This commit was merged in pull request #189.
This commit is contained in:
@@ -280,11 +280,12 @@ async function showFileInEditor(file) {
|
|||||||
if (!TEXT_EXTS.has(extOf(file.name))) return; // unknown binary: leave editor alone
|
if (!TEXT_EXTS.has(extOf(file.name))) return; // unknown binary: leave editor alone
|
||||||
try {
|
try {
|
||||||
const text = await file.text();
|
const text = await file.text();
|
||||||
if (!content.value.trim()) {
|
// #184: the file replaces the main editing area, so the text always
|
||||||
content.value = text;
|
// loads over whatever was in the editor (same rule as images, which
|
||||||
updateGutter();
|
// hide the editor entirely).
|
||||||
guessLang();
|
content.value = text;
|
||||||
}
|
updateGutter();
|
||||||
|
guessLang();
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,9 +307,10 @@ function setAttachedFile(file) {
|
|||||||
attachedFile = file;
|
attachedFile = file;
|
||||||
renderFileChip();
|
renderFileChip();
|
||||||
setHidden('file-text-note', false);
|
setHidden('file-text-note', false);
|
||||||
// #171: title auto-fill — images take the file name; text files use the
|
// #171/#184: title auto-fill — images take the file name; text files
|
||||||
// language-placeholder convention (e.g. Python.py, fallback Text.txt).
|
// use the language-placeholder convention (e.g. Python.py, fallback
|
||||||
// Only when the title is still blank; never overwrite a typed title.
|
// Text.txt). Only when the title is still blank; never overwrite a
|
||||||
|
// typed title.
|
||||||
if (!$('title').value.trim()) {
|
if (!$('title').value.trim()) {
|
||||||
if (IMAGE_RE.test(file.type)) {
|
if (IMAGE_RE.test(file.type)) {
|
||||||
$('title').value = file.name;
|
$('title').value = file.name;
|
||||||
|
|||||||
Reference in New Issue
Block a user