/
githubmirror
/
tldraw
Обзор
Документация
Войти
/
githubmirror
/
tldraw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/editor/src/lib/hooks/EditorComponentsContext.tsx
36 строк
2 KB
Jessica Claire Edwards
feat: commenting (#9471)
30 июл 2026, 14:08
Не верифицирован
30 июл 2026, 14:08
584d9b1
Код
Авторство
О чём код?
import { ComponentType, RefAttributes, createContext, useContext } from 'react' import type { TLCanvasComponentProps } from '../components/default-components/DefaultCanvas' 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 { TLShapeErrorFallbackComponent } from '../components/default-components/DefaultShapeErrorFallback' import type { TLShapeWrapperProps } from '../components/default-components/DefaultShapeWrapper' /** @public */ export interface TLEditorComponents { Background?: ComponentType | null Canvas?: ComponentType<TLCanvasComponentProps> | null CollaboratorCursor?: ComponentType<TLCursorProps> | null Grid?: ComponentType<TLGridProps> | null InFrontOfTheCanvas?: ComponentType | null LoadingScreen?: ComponentType | null OnTheCanvas?: ComponentType | null ShapeWrapper?: ComponentType<TLShapeWrapperProps & RefAttributes<HTMLDivElement>> | null Spinner?: ComponentType<React.SVGProps<SVGSVGElement>> | null SvgDefs?: ComponentType | null // These will always have defaults ErrorFallback?: TLErrorFallbackComponent ShapeErrorFallback?: TLShapeErrorFallbackComponent } export const EditorComponentsContext = createContext<null | Required<TLEditorComponents>>(null) /** @public */ export function useEditorComponents() { const components = useContext(EditorComponentsContext) if (!components) { throw new Error('useEditorComponents must be used inside of <EditorComponentsProvider />') } return components }