add setting
This commit is contained in:
@@ -22,17 +22,19 @@ const Editor: FC = () => {
|
||||
}
|
||||
}, [])
|
||||
const [isLayersPanelOpen, setIsLayersPanelOpen] = useState(false)
|
||||
const { loadPages, pages } = useEditorStore()
|
||||
const { loadPages, pages, documentSettings } = useEditorStore()
|
||||
const { data } = useGetCatalogById(id!)
|
||||
const { scheduleUpdate, isSaving } = useUpdateCatalog()
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.data && data?.data?.content) {
|
||||
const json = JSON.parse(data?.data?.content)
|
||||
console.log(json);
|
||||
if (!json) return
|
||||
|
||||
if (json) {
|
||||
if (Array.isArray(json)) {
|
||||
loadPages(json)
|
||||
} else if (json.pages) {
|
||||
loadPages(json.pages, json.documentSettings)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +47,11 @@ const Editor: FC = () => {
|
||||
|
||||
scheduleUpdate({
|
||||
id,
|
||||
content: JSON.stringify(pages),
|
||||
content: JSON.stringify({ pages, documentSettings }),
|
||||
})
|
||||
// عمداً scheduleUpdate را در وابستگیها نیاوردیم تا از لوپ ذخیرهسازی جلوگیری شود
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [id, pages])
|
||||
}, [id, pages, documentSettings])
|
||||
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user