import { TLSelectTool } from '@tldraw/core' import { useApp } from '@tldraw/react' import { observer } from 'mobx-react-lite' import * as React from 'react' import { Button } from '~components/Button' import { LogseqIcon, TablerIcon } from '~components/icons' interface ToolButtonProps extends React.ButtonHTMLAttributes { id: string icon: string | React.ReactNode } const ToolButton = observer(({ id, icon, title, ...props }: ToolButtonProps) => { const app = useApp() const handleToolClick = React.useCallback( (e: React.MouseEvent) => { const tool = e.currentTarget.dataset.tool if (tool) app.selectTool(tool) }, [app] ) // Tool must exist const Tool = app.Tools?.find(T => T.id === id) ?? TLSelectTool const shortcut = ((Tool as any)['shortcut'] as string[])?.[0] const titleWithShortcut = shortcut ? `${title} (${shortcut})` : title return ( ) }) export const PrimaryTools = observer(function PrimaryTools() { const app = useApp() return (
} />
) })