diff --git a/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/index.tsx b/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/index.tsx index fc1b52d..3c4f144 100644 --- a/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/index.tsx +++ b/packages/editor-sample/src/App/InspectorDrawer/ConfigurationPanel/index.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { Box, Typography } from '@mui/material'; import { TEditorBlock } from '../../../documents/editor/core'; -import { setEditorState, useDocument, useSelectedBlockId } from '../../../documents/editor/EditorContext'; +import { setDocument, useDocument, useSelectedBlockId } from '../../../documents/editor/EditorContext'; import AvatarSidebarPanel from './input-panels/AvatarSidebarPanel'; import ButtonSidebarPanel from './input-panels/ButtonSidebarPanel'; @@ -37,10 +37,7 @@ export default function ConfigurationPanel() { return renderMessage(`Block with id ${selectedBlockId} was not found. Click on a block to reset.`); } - const setBlock = (conf: TEditorBlock) => - setEditorState({ - document: { ...document, [selectedBlockId]: conf }, - }); + const setBlock = (conf: TEditorBlock) => setDocument({ [selectedBlockId]: conf }); const { data, type } = block; switch (type) { case 'Avatar': diff --git a/packages/editor-sample/src/App/InspectorDrawer/StylesPanel.tsx b/packages/editor-sample/src/App/InspectorDrawer/StylesPanel.tsx index 42ba2eb..ff31c6a 100644 --- a/packages/editor-sample/src/App/InspectorDrawer/StylesPanel.tsx +++ b/packages/editor-sample/src/App/InspectorDrawer/StylesPanel.tsx @@ -1,12 +1,11 @@ import React from 'react'; -import { setEditorState, useDocument } from '../../documents/editor/EditorContext'; +import { setDocument, useDocument } from '../../documents/editor/EditorContext'; import EmailLayoutSidebarPanel from './ConfigurationPanel/input-panels/EmailLayoutSidebarPanel'; export default function StylesPanel() { const block = useDocument().root; - const document = useDocument(); if (!block) { return

Block not found

; } @@ -15,11 +14,6 @@ export default function StylesPanel() { if (type !== 'EmailLayout') { throw new Error('Expected "root" element to be of type EmailLayout'); } - return ( - setEditorState({ document: { ...document, root: { type, data } } })} - /> - ); + + return setDocument({ root: { type, data } })} />; } diff --git a/packages/editor-sample/src/App/InspectorDrawer/ToggleInspectorPanelButton.tsx b/packages/editor-sample/src/App/InspectorDrawer/ToggleInspectorPanelButton.tsx index a07b39b..2dc41b9 100644 --- a/packages/editor-sample/src/App/InspectorDrawer/ToggleInspectorPanelButton.tsx +++ b/packages/editor-sample/src/App/InspectorDrawer/ToggleInspectorPanelButton.tsx @@ -3,13 +3,13 @@ import React from 'react'; import { AppRegistrationOutlined, LastPageOutlined } from '@mui/icons-material'; import { IconButton } from '@mui/material'; -import { setEditorState, useInspectorDrawerOpen } from '../../documents/editor/EditorContext'; +import { toggleInspectorDrawerOpen, useInspectorDrawerOpen } from '../../documents/editor/EditorContext'; export default function ToggleInspectorPanelButton() { const inspectorDrawerOpen = useInspectorDrawerOpen(); const handleClick = () => { - setEditorState({ inspectorDrawerOpen: !inspectorDrawerOpen }); + toggleInspectorDrawerOpen(); }; if (inspectorDrawerOpen) { return ( diff --git a/packages/editor-sample/src/App/InspectorDrawer/index.tsx b/packages/editor-sample/src/App/InspectorDrawer/index.tsx index 144b93f..3b2c2cc 100644 --- a/packages/editor-sample/src/App/InspectorDrawer/index.tsx +++ b/packages/editor-sample/src/App/InspectorDrawer/index.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Box, Drawer, Tab, Tabs } from '@mui/material'; -import { setEditorState, useInspectorDrawerOpen, useSelectedSidebarTab } from '../../documents/editor/EditorContext'; +import { setSidebarTab, useInspectorDrawerOpen, useSelectedSidebarTab } from '../../documents/editor/EditorContext'; import ConfigurationPanel from './ConfigurationPanel'; import StylesPanel from './StylesPanel'; @@ -33,7 +33,7 @@ export default function InspectorDrawer() { > - setEditorState({ selectedSidebarTab: v })}> + setSidebarTab(v)}> diff --git a/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsx b/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsx index 2d020d6..d551abe 100644 --- a/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsx +++ b/packages/editor-sample/src/App/SamplesDrawer/SidebarButton.tsx @@ -2,13 +2,12 @@ import React from 'react'; import { Button } from '@mui/material'; -import { setEditorState } from '../../documents/editor/EditorContext'; +import { resetDocument } from '../../documents/editor/EditorContext'; import getConfiguration from '../../getConfiguration'; export default function SidebarButton({ href, children }: { href: string; children: JSX.Element | string }) { const handleClick = () => { - const document = getConfiguration(href); - setEditorState({ document }); + resetDocument(getConfiguration(href)); }; return (