Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
25 lines
723 B
TypeScript
25 lines
723 B
TypeScript
'use client'
|
|
|
|
import { createContext, useContext } from 'react'
|
|
import type { Character, Variable } from '@/types/flowchart'
|
|
|
|
type EditorContextValue = {
|
|
characters: Character[]
|
|
onAddCharacter: (name: string, color: string) => string // returns new character id
|
|
variables: Variable[]
|
|
onAddVariable: (name: string, type: 'numeric' | 'string' | 'boolean', initialValue: number | string | boolean) => string // returns new variable id
|
|
}
|
|
|
|
const EditorContext = createContext<EditorContextValue>({
|
|
characters: [],
|
|
onAddCharacter: () => '',
|
|
variables: [],
|
|
onAddVariable: () => '',
|
|
})
|
|
|
|
export const EditorProvider = EditorContext.Provider
|
|
|
|
export function useEditorContext() {
|
|
return useContext(EditorContext)
|
|
}
|