2023-05-09 16:08:38 +00:00
|
|
|
import { getAssetUrlsByMetaUrl } from '@tldraw/assets/urls'
|
2023-05-05 13:10:36 +00:00
|
|
|
import {
|
|
|
|
DefaultErrorFallback,
|
|
|
|
ErrorBoundary,
|
|
|
|
setDefaultEditorAssetUrls,
|
|
|
|
setDefaultUiAssetUrls,
|
|
|
|
} from '@tldraw/tldraw'
|
2023-04-25 11:01:25 +00:00
|
|
|
import { StrictMode } from 'react'
|
|
|
|
import { createRoot } from 'react-dom/client'
|
|
|
|
import { RouterProvider, createBrowserRouter } from 'react-router-dom'
|
|
|
|
import ExampleBasic from './1-basic/BasicExample'
|
|
|
|
import CustomComponentsExample from './10-custom-components/CustomComponentsExample'
|
2023-05-05 14:14:42 +00:00
|
|
|
import UserPresenceExample from './11-user-presence/UserPresenceExample'
|
2023-05-11 22:14:58 +00:00
|
|
|
import EventsExample from './12-events/EventsExample'
|
2023-04-25 11:01:25 +00:00
|
|
|
import ExampleApi from './2-api/APIExample'
|
|
|
|
import CustomConfigExample from './3-custom-config/CustomConfigExample'
|
|
|
|
import CustomUiExample from './4-custom-ui/CustomUiExample'
|
|
|
|
import ExplodedExample from './5-exploded/ExplodedExample'
|
|
|
|
import ExampleScroll from './6-scroll/ScrollExample'
|
|
|
|
import ExampleMultiple from './7-multiple/MultipleExample'
|
|
|
|
import ErrorBoundaryExample from './8-error-boundaries/ErrorBoundaryExample'
|
|
|
|
import HideUiExample from './9-hide-ui/HideUiExample'
|
|
|
|
|
2023-05-05 13:10:36 +00:00
|
|
|
// 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.
|
2023-05-09 16:08:38 +00:00
|
|
|
const assetUrls = getAssetUrlsByMetaUrl()
|
2023-05-05 13:10:36 +00:00
|
|
|
setDefaultEditorAssetUrls(assetUrls)
|
|
|
|
setDefaultUiAssetUrls(assetUrls)
|
|
|
|
|
|
|
|
type Example = {
|
|
|
|
path: string
|
|
|
|
element: JSX.Element
|
|
|
|
}
|
|
|
|
export const allExamples: Example[] = [
|
2023-04-25 11:01:25 +00:00
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
element: <ExampleBasic />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/scroll',
|
|
|
|
element: <ExampleScroll />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/multiple',
|
|
|
|
element: <ExampleMultiple />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/api',
|
|
|
|
element: <ExampleApi />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/custom',
|
|
|
|
element: <CustomConfigExample />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/custom-ui',
|
|
|
|
element: <CustomUiExample />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/exploded',
|
|
|
|
element: <ExplodedExample />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/hide-ui',
|
|
|
|
element: <HideUiExample />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/error-boundary',
|
|
|
|
element: <ErrorBoundaryExample />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/custom-components',
|
|
|
|
element: <CustomComponentsExample />,
|
|
|
|
},
|
2023-05-11 22:14:58 +00:00
|
|
|
{
|
|
|
|
path: '/events',
|
|
|
|
element: <EventsExample />,
|
|
|
|
},
|
2023-05-05 14:14:42 +00:00
|
|
|
{
|
|
|
|
path: '/user-presence',
|
|
|
|
element: <UserPresenceExample />,
|
|
|
|
},
|
2023-05-05 13:10:36 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
const router = createBrowserRouter(allExamples)
|
2023-04-25 11:01:25 +00:00
|
|
|
const rootElement = document.getElementById('root')
|
|
|
|
const root = createRoot(rootElement!)
|
|
|
|
|
|
|
|
root.render(
|
|
|
|
<StrictMode>
|
|
|
|
<ErrorBoundary
|
|
|
|
fallback={(error) => <DefaultErrorFallback error={error} />}
|
|
|
|
onError={(error) => console.error(error)}
|
|
|
|
>
|
|
|
|
<RouterProvider router={router} />
|
|
|
|
</ErrorBoundary>
|
|
|
|
</StrictMode>
|
|
|
|
)
|