0c5f8dda48
* remove sponsorwall for main route * Adds sponsorship link * Remove all sponsorwall * Fix sponsorship link appearance on dark mode * Add heart icon * Fix text bug * Fix toolbar, hide resize handles on sticky * Add eraser * Update Kbd.tsx * cleanup * base zoom delta on event deltaMode * Fix image in example * Fix eraser icon * eraser tool resets to previous tool * Update EraseTool.spec.ts * Improves support for locked shapes * Update _document.tsx * Update CHANGELOG.md * Adds multiplayer menu, fix develop route in example * Tighten up top panel padding * Update top bar, bump packages * refactor TLDrawState -> TLDrawApp, mutables, new tests * Fix scaling bug, delete groups bug * fix snapping * add pressure to points * Remove mutables, rename to tldraw (or Tldraw) * Clean up types, add darkmode prop * more renaming * rename getShapeUtils to getShapeUtil * Fix file names * Fix last bugs related to renaming * Update state to app in tests * rename types to TD * remove unused styles / rename styles * slight update to panel * Fix rogue radix perf issue * Update ZoomMenu.tsx * Consolidate style panel * Fix text wrapping in text shape, improve action menu * Fix props * add indicators for tool lock * fix calloits * Add click to erase shapes * Slightly improve loading screen * Update PrimaryTools.tsx * remove force consistent filenames from tsconfig * Update useTldrawApp.tsx * fix capitalization * Update main.yml
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { Tldraw, TldrawApp, useFileSystem } from '@tldraw/tldraw'
|
|
import * as gtag from '-utils/gtag'
|
|
import React from 'react'
|
|
import { useAccountHandlers } from '-hooks/useAccountHandlers'
|
|
|
|
declare const window: Window & { app: TldrawApp }
|
|
|
|
interface EditorProps {
|
|
id?: string
|
|
isUser?: boolean
|
|
isSponsor?: boolean
|
|
}
|
|
|
|
export default function Editor({ id = 'home', isSponsor = false }: EditorProps) {
|
|
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()
|
|
|
|
return (
|
|
<div className="tldraw">
|
|
<Tldraw
|
|
id={id}
|
|
autofocus
|
|
onMount={handleMount}
|
|
onPersist={handlePersist}
|
|
showSponsorLink={!isSponsor}
|
|
onSignIn={isSponsor ? undefined : onSignIn}
|
|
onSignOut={onSignOut}
|
|
{...fileSystemEvents}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|