diff --git a/packages/editor/src/lib/TldrawEditor.tsx b/packages/editor/src/lib/TldrawEditor.tsx index b9be45ef2..383562642 100644 --- a/packages/editor/src/lib/TldrawEditor.tsx +++ b/packages/editor/src/lib/TldrawEditor.tsx @@ -14,6 +14,7 @@ import classNames from 'classnames' import { Canvas } from './components/Canvas' import { OptionalErrorBoundary } from './components/ErrorBoundary' import { DefaultErrorFallback } from './components/default-components/DefaultErrorFallback' +import { DefaultLoadingScreen } from './components/default-components/DefaultLoadingScreen' import { TLUser, createTLUser } from './config/createTLUser' import { TLAnyShapeUtilConstructor } from './config/defaultShapes' import { Editor } from './editor/Editor' @@ -156,6 +157,7 @@ export const TldrawEditor = memo(function TldrawEditor({ ...rest, shapeUtils: rest.shapeUtils ?? EMPTY_SHAPE_UTILS_ARRAY, tools: rest.tools ?? EMPTY_TOOLS_ARRAY, + components, } return ( @@ -235,7 +237,8 @@ const TldrawEditorWithLoadingStore = memo(function TldrawEditorBeforeLoading({ throw store.error } case 'loading': { - return Connecting... + const LoadingScreen = rest.components?.LoadingScreen ?? DefaultLoadingScreen + return } case 'not-synced': { break diff --git a/packages/editor/src/lib/components/default-components/DefaultLoadingScreen.tsx b/packages/editor/src/lib/components/default-components/DefaultLoadingScreen.tsx new file mode 100644 index 000000000..141a67ee9 --- /dev/null +++ b/packages/editor/src/lib/components/default-components/DefaultLoadingScreen.tsx @@ -0,0 +1,10 @@ +import { ComponentType } from 'react' +import { LoadingScreen } from '../../TldrawEditor' + +/** @public */ +export type TLLoadingScreenComponent = ComponentType + +/** @public */ +export const DefaultLoadingScreen: TLLoadingScreenComponent = () => { + return Connecting... +} diff --git a/packages/editor/src/lib/hooks/useEditorComponents.tsx b/packages/editor/src/lib/hooks/useEditorComponents.tsx index 77ebfe39c..0978e23f6 100644 --- a/packages/editor/src/lib/hooks/useEditorComponents.tsx +++ b/packages/editor/src/lib/hooks/useEditorComponents.tsx @@ -22,6 +22,7 @@ import { TLHoveredShapeIndicatorComponent, } from '../components/default-components/DefaultHoveredShapeIndicator' import { TLInFrontOfTheCanvas } from '../components/default-components/DefaultInFrontOfTheCanvas' +import { TLLoadingScreenComponent } from '../components/default-components/DefaultLoadingScreen' import { TLOnTheCanvas } from '../components/default-components/DefaultOnTheCanvas' import { DefaultScribble, @@ -72,6 +73,7 @@ export interface BaseEditorComponents { HoveredShapeIndicator: TLHoveredShapeIndicatorComponent OnTheCanvas: TLOnTheCanvas InFrontOfTheCanvas: TLInFrontOfTheCanvas + LoadingScreen: TLLoadingScreenComponent } // These will always have defaults