import { useEffect } from 'react' import { onHostMessage, tellHost } from './bridge' import { Canvas } from './components/Canvas' import { SidePanel } from './components/SidePanel' import { ToolRail } from './components/ToolRail' import { Button, Icon, IconButton, Select } from './components/controls' import { useStore } from './store' import type { Source, Tool } from './types' const SOURCES: { value: Source; label: string }[] = [ { value: 'generation', label: 'From generation' }, { value: 'own', label: 'Own image' }, ] /** The keys that pick a tool, by their place on the keyboard: they work in any layout. */ const TOOL_KEYS: Record = { KeyV: 'off', KeyB: 'bubble', KeyP: 'brush', KeyE: 'eraser' } // Text entry keeps Escape for itself: the first Esc leaves the field (its onBlur applies the text), the next one closes the editor. const TEXT_INPUT_TYPES = new Set(['text', 'number', 'search', '']) function isTextEntry(target: EventTarget | null): target is HTMLElement { if (!(target instanceof HTMLElement)) return false if (target.isContentEditable || target instanceof HTMLTextAreaElement) return true return target instanceof HTMLInputElement && TEXT_INPUT_TYPES.has(target.type) } /** Says whether new images are lettered by themselves, and leads to the setting. */ function AutoChip() { const auto = useStore((state) => state.auto) return ( ) } function TopBar() { const embedded = useStore((state) => state.embedded) const comfy = useStore((state) => state.comfy) const source = useStore((state) => state.source) const slot = useStore((state) => state.slots[state.source]) const showOriginal = useStore((state) => state.showOriginal) const showFrames = useStore((state) => state.showFrames) const canUndo = useStore((state) => state.canUndo) const canRedo = useStore((state) => state.canRedo) const { setSource, setShowOriginal, setShowFrames, save, undo, redo } = useStore.getState() const sourceLabel = SOURCES.find((entry) => entry.value === source)?.label ?? '' return (
Comic Lettering {embedded && (