import { ComponentType, RefAttributes, createContext, useContext } from 'react' import type { TLBrushProps } from '../components/default-components/DefaultBrush' import type { TLCanvasComponentProps } from '../components/default-components/DefaultCanvas' import type { TLCollaboratorHintProps } from '../components/default-components/DefaultCollaboratorHint' import type { TLCursorProps } from '../components/default-components/DefaultCursor' import type { TLErrorFallbackComponent } from '../components/default-components/DefaultErrorFallback' import type { TLGridProps } from '../components/default-components/DefaultGrid' import type { TLHandleProps } from '../components/default-components/DefaultHandle' import type { TLHandlesProps } from '../components/default-components/DefaultHandles' import type { TLScribbleProps } from '../components/default-components/DefaultScribble' import type { TLSelectionBackgroundProps } from '../components/default-components/DefaultSelectionBackground' import type { TLSelectionForegroundProps } from '../components/default-components/DefaultSelectionForeground' import type { TLShapeErrorFallbackComponent } from '../components/default-components/DefaultShapeErrorFallback' import type { TLShapeIndicatorProps } from '../components/default-components/DefaultShapeIndicator' import type { TLShapeIndicatorErrorFallbackComponent } from '../components/default-components/DefaultShapeIndicatorErrorFallback' import type { TLShapeWrapperProps } from '../components/default-components/DefaultShapeWrapper' import type { TLSnapIndicatorProps } from '../components/default-components/DefaultSnapIndictor' /** @public */ export interface TLEditorComponents { Background?: ComponentType | null Brush?: ComponentType | null Canvas?: ComponentType | null CollaboratorBrush?: ComponentType | null CollaboratorCursor?: ComponentType | null CollaboratorHint?: ComponentType | null CollaboratorScribble?: ComponentType | null CollaboratorShapeIndicator?: ComponentType | null Cursor?: ComponentType | null Grid?: ComponentType | null Handle?: ComponentType | null Handles?: ComponentType | null InFrontOfTheCanvas?: ComponentType | null LoadingScreen?: ComponentType | null OnTheCanvas?: ComponentType | null Overlays?: ComponentType | null Scribble?: ComponentType | null SelectionBackground?: ComponentType | null SelectionForeground?: ComponentType | null ShapeIndicator?: ComponentType | null ShapeIndicators?: ComponentType | null ShapeWrapper?: ComponentType> | null SnapIndicator?: ComponentType | null Spinner?: ComponentType> | null SvgDefs?: ComponentType | null ZoomBrush?: ComponentType | null // These will always have defaults ErrorFallback?: TLErrorFallbackComponent ShapeErrorFallback?: TLShapeErrorFallbackComponent ShapeIndicatorErrorFallback?: TLShapeIndicatorErrorFallbackComponent } export const EditorComponentsContext = createContext>(null) /** @public */ export function useEditorComponents() { const components = useContext(EditorComponentsContext) if (!components) { throw new Error('useEditorComponents must be used inside of ') } return components }