Files
windmill/frontend/src/lib/components/graph/graphContext.ts
T
2025-11-19 12:36:39 +00:00

20 lines
777 B
TypeScript

import { getContext, setContext } from 'svelte'
import type { SelectionManager } from './selectionUtils.svelte'
import type { NoteManager } from './noteManager.svelte'
import type { Writable } from 'svelte/store'
export type GraphContext = {
selectionManager: SelectionManager
useDataflow: Writable<boolean | undefined>
showAssets: Writable<boolean | undefined>
noteManager?: NoteManager
clearFlowSelection?: () => void
yOffset?: number
}
const graphContextKey = 'FlowGraphContext'
//TODO: use https://svelte.dev/docs/svelte/context#Type-safe-context after migrating svelte 5 to latest version
export const getGraphContext = () => getContext<GraphContext>(graphContextKey)
export const setGraphContext = (context: GraphContext) => setContext(graphContextKey, context)