Open History to see the last commit
1import { useRef } from "react";
2
3import type { Note } from "@/db/schema";
4import { formatEditorDate } from "@/lib/notes/dates";
5
6import { DeletedNoteBanner } from "../deleted-note-banner";
7import { NoteContent } from "../note-content";
8import { NoteEditor } from "../note-editor";
9import type { NoteEditorHandle } from "../note-editor";
10import { EditorToolbar } from "./editor-toolbar";
11
12export function MacEditor({ note }: { note: Note | undefined }) {
13 const editorRef = useRef<NoteEditorHandle>(null);
14 const deleted = note?.deletedAt != null;
15
16 return (
17 <section aria-label="Editor" className="flex min-w-0 flex-1 flex-col bg-mac-content">
18 <EditorToolbar
19 note={note}
20 onToggleChecklist={
21 note && !deleted ? () => editorRef.current?.toggleChecklist() : undefined
22 }
23 />
24 <div
25 data-page-scroll
26 className="notes-scroll min-h-0 flex-1 overflow-y-auto px-[22px] pb-10 text-mac-text"
27 >
28 {note ? (
29 <>
30 {deleted && <DeletedNoteBanner noteId={note.id} variant="mac" />}
31 <p className="pt-1 pb-3 text-center text-[12px] text-mac-text-secondary">
32 {formatEditorDate(new Date(note.updatedAt))}
33 </p>
34 {deleted ? (
35 <NoteContent note={note} variant="mac" />
36 ) : (
37 <NoteEditor key={note.id} note={note} variant="mac" handleRef={editorRef} />
38 )}
39 </>
40 ) : (
41 <p className="pt-32 text-center text-[13px] text-mac-text-secondary">No note selected</p>
42 )}
43 </div>
44 </section>
45 );
46}