"use client"; import React, { useState, useEffect } from 'react'; import { Save } from 'lucide-react'; import dynamic from 'next/dynamic'; // Dynamically import the editor to avoid SSR issues const ReactQuill = dynamic(() => import('react-quill'), { ssr: false }); import 'react-quill/dist/quill.snow.css'; interface Note { id: string; title: string; lastModified: string; size: number; type: string; mime: string; etag: string; content?: string; } interface EditorProps { note: Note | null; onSave: (note: Note) => void; currentFolder: string; } export function Editor({ note, onSave, currentFolder }: EditorProps) { const [content, setContent] = useState(''); const [isSaving, setIsSaving] = useState(false); const [isLoading, setIsLoading] = useState(false); useEffect(() => { if (note?.content) { setIsLoading(true); setContent(note.content); setIsLoading(false); } else { setContent(''); } }, [note]); const handleSave = async () => { if (!note) return; setIsSaving(true); try { const updatedNote = { ...note, content, lastModified: new Date().toISOString(), size: content.length }; onSave(updatedNote); } catch (error) { console.error('Failed to save note:', error); } finally { setIsSaving(false); } }; if (isLoading) { return (
); } if (!note) { return (

Select a note to edit

); } return (

{note.title}

); }