fix(code-editor): improve template handling and default value logic

This commit is contained in:
cfngc4594 2025-03-09 11:22:40 +08:00
parent 556fde6546
commit a691992404

View File

@ -66,8 +66,8 @@ export default function CodeEditor({
if (storedValue !== null) { if (storedValue !== null) {
setValue(storedValue); setValue(storedValue);
} else { } else {
const template = templates.find((t) => t.language === language); const currentTemplate = templates.find((t) => t.language === language)?.template ?? "";
if (template) setValue(template.template); setValue(currentTemplate);
} }
}, [valueStorageKey, setValue, templates, language]) }, [valueStorageKey, setValue, templates, language])