File
Blob: src/client/components/editor/editor-runtime-context.ts
| 1 | import { createContext, use } from "react"; |
| 2 | |
| 3 | export interface EditorRuntimeSnapshot { |
| 4 | workspaceId: string | undefined; |
| 5 | pageId: string; |
| 6 | shareToken: string | undefined; |
| 7 | } |
| 8 | |
| 9 | export type EditorRuntimeContextValue = EditorRuntimeSnapshot; |
| 10 | |
| 11 | const EMPTY_RUNTIME: EditorRuntimeSnapshot = { |
| 12 | workspaceId: undefined, |
| 13 | pageId: "", |
| 14 | shareToken: undefined, |
| 15 | }; |
| 16 | |
| 17 | export const EditorRuntimeContext = createContext<EditorRuntimeContextValue>({ |
| 18 | ...EMPTY_RUNTIME, |
| 19 | }); |
| 20 | |
| 21 | export function useEditorRuntime(): EditorRuntimeContextValue { |
| 22 | return use(EditorRuntimeContext); |
| 23 | } |