tldraw/apps/www/components/Editor.tsx
Steve Ruiz f0f545806a
[improvement] Quality and UI cleanup (#846)
* remove sponsors, ui cleanup

* fix radius

* improve panel

* remove cursor spline animations

* migrate options

* Switch hrs to divider

* fix text color on menu dark mode

* Remove option for clone handles

* fix wheel

* remove unused translations
2022-07-23 15:05:48 +01:00

46 lines
1.1 KiB
TypeScript

import { Tldraw, TldrawApp, TldrawProps, useFileSystem } from '@tldraw/tldraw'
import { useUploadAssets } from 'hooks/useUploadAssets'
import * as React from 'react'
import * as gtag from 'utils/gtag'
declare const window: Window & { app: TldrawApp }
interface EditorProps {
id?: string
}
const Editor = ({ id = 'home', ...rest }: EditorProps & Partial<TldrawProps>) => {
const handleMount = React.useCallback((app: TldrawApp) => {
window.app = app
}, [])
// Send events to gtag as actions.
const handlePersist = React.useCallback((_app: TldrawApp, reason?: string) => {
gtag.event({
action: reason ?? '',
category: 'editor',
label: reason ?? 'persist',
value: 0,
})
}, [])
const fileSystemEvents = useFileSystem()
const { onAssetUpload } = useUploadAssets()
return (
<div className="tldraw">
<Tldraw
id={id}
autofocus
onMount={handleMount}
onPersist={handlePersist}
onAssetUpload={onAssetUpload}
{...fileSystemEvents}
{...rest}
/>
</div>
)
}
export default Editor