Skip to content
File

Blob: src/client/components/editor/editor-runtime-context.ts

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