diff --git a/apps/web/src/routes/_app/notes.tsx b/apps/web/src/routes/_app/notes.tsx index f78d455..3310134 100644 --- a/apps/web/src/routes/_app/notes.tsx +++ b/apps/web/src/routes/_app/notes.tsx @@ -17,20 +17,20 @@ import { cn } from "@/lib/utils"; import type { Note, PaginatedResponse } from "@/lib/types"; // Simple TipTap-like editor using contentEditable -const NoteEditor = memo(function NoteEditor({ content, onChange, placeholder = "Start writing..." }: { content: string; onChange: (html: string) => void; placeholder?: string }) { +const NoteEditor = memo(function NoteEditor({ initialContent, onSave, placeholder = "Start writing..." }: { initialContent: string; onSave: (html: string) => void; placeholder?: string }) { const editorRef = useRef(null); - const [isPlaceholder, setIsPlaceholder] = useState(!content); + const [isPlaceholder, setIsPlaceholder] = useState(!initialContent); useEffect(() => { - if (editorRef.current && !editorRef.current.innerHTML) { - editorRef.current.innerHTML = content || ""; + if (editorRef.current) { + editorRef.current.innerHTML = initialContent || ""; } - }, [content]); + setIsPlaceholder(!initialContent); + }, [initialContent]); - const handleInput = () => { + const handleBlur = () => { const html = editorRef.current?.innerHTML || ""; - setIsPlaceholder(!html || html === "
"); - onChange(html); + onSave(html); }; return ( @@ -41,9 +41,9 @@ const NoteEditor = memo(function NoteEditor({ content, onChange, placeholder = "
); @@ -235,7 +235,7 @@ function NotesPage() {
- +
{/* Backlinks section */} {showBacklinks && selectedNote.backlinks && selectedNote.backlinks.length > 0 && (