Update + Delete articles

This commit is contained in:
cdricms
2025-02-25 17:49:37 +01:00
parent 793e3748f9
commit a3f716446c
16 changed files with 764 additions and 3357 deletions

View File

@@ -18,14 +18,14 @@ interface EditorProps {
content: string;
onChange?: (content: string) => void;
className?: string;
setTitle?: React.Dispatch<React.SetStateAction<string>>;
onTitleChange?: (t: string) => void;
}
export function LocalEditor({
content,
onChange,
className,
setTitle,
onTitleChange: setTitle,
}: EditorProps) {
const getTitle = (editor: Editor) => {
const firstNode = editor.state.doc.firstChild;
@@ -87,7 +87,7 @@ export function LocalEditor({
setTitle?.(title ?? "");
},
onUpdate: ({ editor }) => {
localStorage.setItem("blog_draft", editor.getHTML());
onChange?.(editor.getHTML());
const title = getTitle(editor);
setTitle?.(title ?? "");
},