| 68 | } |
| 69 | |
| 70 | async function handleCreateFile() { |
| 71 | let name = newFileName.trim(); |
| 72 | if (!name) return; |
| 73 | if (!name.endsWith('.md')) name += '.md'; |
| 74 | try { |
| 75 | await api(`/api/bootstrap/${encodeURIComponent(name)}`, { |
| 76 | method: 'POST', |
| 77 | body: JSON.stringify({ content: `# ${name.replace('.md', '')}\n\n` }), |
| 78 | }); |
| 79 | setNewFileName(''); |
| 80 | setShowNewFile(false); |
| 81 | await loadFiles(); |
| 82 | setActiveFile(name); |
| 83 | } catch { /* ignore */ } |
| 84 | } |
| 85 | |
| 86 | const currentFile = files.find(f => f.name === activeFile); |
| 87 | const isDirty = currentFile ? editContent !== currentFile.content : false; |