tldraw
Version:
A tiny little drawing editor.
22 lines (18 loc) • 601 B
text/typescript
import { StateNode, TLStateNodeConstructor } from '@tldraw/editor'
import { Drawing } from './toolStates/Drawing'
import { Idle } from './toolStates/Idle'
/** @public */
export class DrawShapeTool extends StateNode {
static override id = 'draw'
static override initial = 'idle'
static override isLockable = false
static override useCoalescedEvents = true
static override children(): TLStateNodeConstructor[] {
return [Idle, Drawing]
}
override shapeType = 'draw'
override onExit() {
const drawingState = this.children!['drawing'] as Drawing
drawingState.initialShape = undefined
}
}