import { Icon, useBreakpoint, useEditor, useValue } from '@tldraw/tldraw' import { ChangeEvent, useCallback, useState } from 'react' import { setTimeout } from 'timers' export function APIKeyInput() { const breakpoint = useBreakpoint() const [cool, setCool] = useState(false) const editor = useEditor() const isFocusMode = useValue('is focus mode', () => editor.getInstanceState().isFocusMode, [ editor, ]) // Store the API key locally const handleChange = useCallback((e: ChangeEvent) => { localStorage.setItem('makeitreal_key', e.target.value) }, []) const handleKeyDown = useCallback((e: React.KeyboardEvent) => { if (e.key === 'Enter') { e.preventDefault() e.stopPropagation() e.currentTarget.blur() setCool(true) // its cool setTimeout(() => setCool(false), 1200) } }, []) if (isFocusMode) return null return (
) }