diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 15975aa..c275a4b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -78,10 +78,25 @@ function App() { } } - const handleNewFile = () => { - setCurrentFile(null) - setContent('# New File\n\nStart writing here...') - setIsEditing(true) + const handleNewFile = async () => { + const filename = prompt('Enter filename:', 'untitled.md') + if (!filename) return + + try { + const response = await fetch('/api/files', { + method: 'POST', + headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({filename, content: '# New File\n\nStart writing here...', title: filename.replace('.md', '')}) + }) + if (response.ok) { + const newFile = await response.json() + setCurrentFile(newFile) + setContent(newFile.content) + setIsEditing(true) + } + } catch (error) { + console.error('Failed to create new file:', error) + } } const handleSave = async () => {