import { getAssetUrlsByMetaUrl } from '@tldraw/assets/urls' import { DefaultErrorFallback, ErrorBoundary, setDefaultEditorAssetUrls, setDefaultUiAssetUrls, } from '@tldraw/tldraw' import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import { RouterProvider, createBrowserRouter } from 'react-router-dom' import ExamplesTldrawLogo from './components/ExamplesTldrawLogo' import { ListLink } from './components/ListLink' import BasicExample from './BasicExample' import APIExample from './examples/APIExample' import AssetPropsExample from './examples/AssetOptionsExample' import CanvasEventsExample from './examples/CanvasEventsExample' import CustomComponentsExample from './examples/CustomComponentsExample' import CustomConfigExample from './examples/CustomConfigExample/CustomConfigExample' import CustomStylesExample from './examples/CustomStylesExample/CustomStylesExample' import CustomUiExample from './examples/CustomUiExample/CustomUiExample' import ErrorBoundaryExample from './examples/ErrorBoundaryExample/ErrorBoundaryExample' import ExplodedExample from './examples/ExplodedExample' import ExternalContentSourcesExample from './examples/ExternalContentSourcesExample' import ForceMobileExample from './examples/ForceBreakpointExample' import HideUiExample from './examples/HideUiExample' import MetaExample from './examples/MetaExample' import MultipleExample from './examples/MultipleExample' import OnTheCanvasExample from './examples/OnTheCanvas' import PersistenceExample from './examples/PersistenceExample' import ReadOnlyExample from './examples/ReadOnlyExample' import ScrollExample from './examples/ScrollExample' import ShapeMetaExample from './examples/ShapeMetaExample' import SnapshotExample from './examples/SnapshotExample/SnapshotExample' import StoreEventsExample from './examples/StoreEventsExample' import UiEventsExample from './examples/UiEventsExample' import UserPresenceExample from './examples/UserPresenceExample' import ZonesExample from './examples/ZonesExample' import EndToEnd from './examples/end-to-end/end-to-end' import OnlyEditorExample from './examples/only-editor/OnlyEditor' import YjsExample from './examples/yjs/YjsExample' // This example is only used for end to end tests // we use secret internal `setDefaultAssetUrls` functions to set these at the // top-level so assets don't need to be passed down in every single example. const assetUrls = getAssetUrlsByMetaUrl() setDefaultEditorAssetUrls(assetUrls) setDefaultUiAssetUrls(assetUrls) type Example = { path: string title?: string element: JSX.Element } export const allExamples: Example[] = [ { title: 'Basic (development)', path: 'develop', element: , }, { title: 'Collaboration (with Yjs)', path: 'yjs', element: , }, { title: 'Editor API', path: 'api', element: , }, { title: 'Multiple editors', path: 'multiple', element: , }, { title: 'Meta Example', path: 'meta', element: , }, { title: 'Readonly Example', path: 'readonly', element: , }, { title: 'Things on the canvas', path: 'things-on-the-canvas', element: , }, { title: 'Scroll example', path: 'scroll', element: , }, { title: 'Custom shapes / tools', path: 'custom-config', element: , }, { title: 'Sublibraries', path: 'exploded', element: , }, { title: 'Error boundary', path: 'error-boundary', element: , }, { title: 'Custom UI', path: 'custom-ui', element: , }, { title: 'Hide UI', path: 'hide-ui', element: , }, { title: 'UI components', path: 'custom-components', element: , }, { title: 'UI events', path: 'ui-events', element: , }, { title: 'Canvas events', path: 'canvas-events', element: , }, { title: 'Store events', path: 'store-events', element: , }, { title: 'User presence', path: 'user-presence', element: , }, { title: 'UI zones', path: 'zones', element: , }, { title: 'Persistence', path: 'persistence', element: , }, { title: 'Snapshots', path: 'snapshots', element: , }, { title: 'Force mobile breakpoint', path: 'force-mobile', element: , }, { title: 'Custom styles', path: 'custom-styles', element: , }, { title: 'Shape meta property', path: 'shape-meta', element: , }, { title: 'Only editor', path: 'only-editor', element: , }, { title: 'Asset props', path: 'asset-props', element: , }, { title: 'External content sources', path: 'external-content-sources', element: , }, // not listed { path: 'end-to-end', element: , }, ] function App() { return (

See docs at tldraw.dev

    {allExamples .filter((example) => example.title) .map((example) => ( ))}
) } const router = createBrowserRouter([ { path: '/', element: , }, ...allExamples, ]) const rootElement = document.getElementById('root') const root = createRoot(rootElement!) root.render( } onError={(error) => console.error(error)} > )