tldraw/apps/www/components/Editor.tsx
Judicael d919bd273e
feat: add translation (#704)
* feat: add translation

* modal, left menu translation

* primary tools translation

* render with intl provider for testing

restore file

* french translation done

* context menu translation and test

* added italian

* Add menu to select language

* translation for the word language

* bump dev deps

Bump react on www

* Fix types

* update dependencies

* pre-release

* Delete lask.config.json

Co-authored-by: Enrico <franciscono.enry@gmail.com>
Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-06-09 15:33:35 +01:00

59 lines
1.4 KiB
TypeScript

import { Tldraw, TldrawApp, TldrawProps, useFileSystem } from '@tldraw/tldraw'
import { useAccountHandlers } from 'hooks/useAccountHandlers'
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
isUser?: boolean
isSponsor?: boolean
}
const Editor: React.FC<EditorProps & Partial<TldrawProps>> = ({
id = 'home',
isUser = false,
isSponsor = false,
...rest
}) => {
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 { onSignIn, onSignOut } = useAccountHandlers()
const { onAssetUpload } = useUploadAssets()
return (
<div className="tldraw">
<Tldraw
id={id}
autofocus
onMount={handleMount}
onPersist={handlePersist}
showSponsorLink={!isSponsor}
onSignIn={isSponsor ? undefined : onSignIn}
onSignOut={isUser ? onSignOut : undefined}
onAssetUpload={onAssetUpload}
{...fileSystemEvents}
{...rest}
/>
</div>
)
}
export default Editor