2
0
Files
bot/apps/builder/contexts/EditorContext.tsx

41 lines
974 B
TypeScript
Raw Normal View History

import {
createContext,
Dispatch,
ReactNode,
SetStateAction,
useContext,
useState,
} from 'react'
export enum RightPanel {
PREVIEW,
}
const editorContext = createContext<{
rightPanel?: RightPanel
setRightPanel: Dispatch<SetStateAction<RightPanel | undefined>>
2022-06-11 07:27:38 +02:00
startPreviewAtGroup: string | undefined
setStartPreviewAtGroup: Dispatch<SetStateAction<string | undefined>>
2022-01-15 17:30:20 +01:00
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
}>({})
export const EditorContext = ({ children }: { children: ReactNode }) => {
const [rightPanel, setRightPanel] = useState<RightPanel>()
2022-06-11 07:27:38 +02:00
const [startPreviewAtGroup, setStartPreviewAtGroup] = useState<string>()
return (
<editorContext.Provider
value={{
rightPanel,
setRightPanel,
2022-06-11 07:27:38 +02:00
startPreviewAtGroup,
setStartPreviewAtGroup,
}}
>
{children}
</editorContext.Provider>
)
}
export const useEditor = () => useContext(editorContext)