#233: file attachment title takes the file name, fallback date.ext
This commit is contained in:
+11
-13
@@ -307,21 +307,19 @@ function setAttachedFile(file) {
|
||||
attachedFile = file;
|
||||
renderFileChip();
|
||||
setHidden('file-text-note', false);
|
||||
// #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.
|
||||
// #233: title auto-fill — the file's own name always wins when the
|
||||
// title is still blank; fallback is date.fileextension (e.g.
|
||||
// 2026-09-10.txt) when the name is missing or unusable. Never
|
||||
// overwrite a typed title.
|
||||
if (!$('title').value.trim()) {
|
||||
if (IMAGE_RE.test(file.type)) {
|
||||
$('title').value = file.name;
|
||||
const raw = (file.name || '').trim();
|
||||
if (raw) {
|
||||
$('title').value = raw;
|
||||
} else {
|
||||
const lang = LANG_BY_EXT[extOf(file.name)];
|
||||
if (lang) {
|
||||
const fn = defaultFilename(lang);
|
||||
if (fn) $('title').value = fn;
|
||||
} else if (TEXT_EXTS.has(extOf(file.name))) {
|
||||
$('title').value = defaultFilename('text') || 'Text.txt';
|
||||
}
|
||||
const d = new Date();
|
||||
const iso = d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
|
||||
const ext = extOf(raw || file.name);
|
||||
$('title').value = ext ? iso + '.' + ext : iso;
|
||||
}
|
||||
}
|
||||
showFileInEditor(file);
|
||||
|
||||
Reference in New Issue
Block a user