Release v0.4.0: dev -> main #251
+11
-13
@@ -307,21 +307,19 @@ function setAttachedFile(file) {
|
|||||||
attachedFile = file;
|
attachedFile = file;
|
||||||
renderFileChip();
|
renderFileChip();
|
||||||
setHidden('file-text-note', false);
|
setHidden('file-text-note', false);
|
||||||
// #171/#184: title auto-fill — images take the file name; text files
|
// #233: title auto-fill — the file's own name always wins when the
|
||||||
// use the language-placeholder convention (e.g. Python.py, fallback
|
// title is still blank; fallback is date.fileextension (e.g.
|
||||||
// Text.txt). Only when the title is still blank; never overwrite a
|
// 2026-09-10.txt) when the name is missing or unusable. Never
|
||||||
// typed title.
|
// overwrite a typed title.
|
||||||
if (!$('title').value.trim()) {
|
if (!$('title').value.trim()) {
|
||||||
if (IMAGE_RE.test(file.type)) {
|
const raw = (file.name || '').trim();
|
||||||
$('title').value = file.name;
|
if (raw) {
|
||||||
|
$('title').value = raw;
|
||||||
} else {
|
} else {
|
||||||
const lang = LANG_BY_EXT[extOf(file.name)];
|
const d = new Date();
|
||||||
if (lang) {
|
const iso = d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
|
||||||
const fn = defaultFilename(lang);
|
const ext = extOf(raw || file.name);
|
||||||
if (fn) $('title').value = fn;
|
$('title').value = ext ? iso + '.' + ext : iso;
|
||||||
} else if (TEXT_EXTS.has(extOf(file.name))) {
|
|
||||||
$('title').value = defaultFilename('text') || 'Text.txt';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showFileInEditor(file);
|
showFileInEditor(file);
|
||||||
|
|||||||
Reference in New Issue
Block a user