This commit is contained in:
EGOIST 2022-05-08 14:00:22 +08:00
parent aa28d69dd6
commit e92a3662e6
1 changed files with 20 additions and 6 deletions

View File

@ -103,11 +103,11 @@ export default function SubdomainEditor() {
publishedAt: page?.publishedAt || null,
})
const [values, setValues] = useState({
title: page.title,
content: page.content,
publishedAt: page.publishedAt,
published: page.published,
slug: page.slug,
title: "",
content: "",
publishedAt: new Date(),
published: false,
slug: "",
})
const updateValue = (field: string, value: any) => {
setValues((values) => {
@ -127,6 +127,21 @@ export default function SubdomainEditor() {
}
}, [fetcher.type])
useEffect(() => {
if (!page) return
setValues((values) => {
return {
...values,
title: page.title,
content: page.content,
publishedAt: page.publishedAt,
published: page.published,
slug: page.slug,
}
})
}, [page])
const handleEditorContentChange = useCallback(
(value) => updateValue("content", value),
[]
@ -137,7 +152,6 @@ export default function SubdomainEditor() {
toast.error("You can only upload images")
return
}
const position = view.state.selection.main.head
const toastId = toast.loading("Uploading...")