Update + Delete articles
This commit is contained in:
@@ -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 ?? "");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user