UNPKG

tldraw

Version:

A tiny little drawing editor.

8 lines (7 loc) 1.91 kB
{ "version": 3, "sources": ["../../../../../src/lib/shapes/arrow/toolStates/Idle.ts"], "sourcesContent": ["import { StateNode, TLKeyboardEventInfo, TLPointerEventInfo } from '@tldraw/editor'\n\nexport class Idle extends StateNode {\n\tstatic override id = 'idle'\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tthis.parent.transition('pointing', info)\n\t}\n\n\toverride onEnter() {\n\t\tthis.editor.setCursor({ type: 'cross', rotation: 0 })\n\t}\n\n\toverride onCancel() {\n\t\tthis.editor.setCurrentTool('select')\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tif (info.key === 'Enter') {\n\t\t\tif (this.editor.getIsReadonly()) return null\n\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t// If the only selected shape is editable, start editing it\n\t\t\tif (\n\t\t\t\tonlySelectedShape &&\n\t\t\t\tthis.editor.getShapeUtil(onlySelectedShape).canEdit(onlySelectedShape)\n\t\t\t) {\n\t\t\t\tthis.editor.setCurrentTool('select')\n\t\t\t\tthis.editor.setEditingShape(onlySelectedShape.id)\n\t\t\t\tthis.editor.root.getCurrent()?.transition('editing_shape', {\n\t\t\t\t\t...info,\n\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\tshape: onlySelectedShape,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n"], "mappings": "AAAA,SAAS,iBAA0D;AAE5D,MAAM,aAAa,UAAU;AAAA,EACnC,OAAgB,KAAK;AAAA,EAEZ,cAAc,MAA0B;AAChD,SAAK,OAAO,WAAW,YAAY,IAAI;AAAA,EACxC;AAAA,EAES,UAAU;AAClB,SAAK,OAAO,UAAU,EAAE,MAAM,SAAS,UAAU,EAAE,CAAC;AAAA,EACrD;AAAA,EAES,WAAW;AACnB,SAAK,OAAO,eAAe,QAAQ;AAAA,EACpC;AAAA,EAES,QAAQ,MAA2B;AAC3C,QAAI,KAAK,QAAQ,SAAS;AACzB,UAAI,KAAK,OAAO,cAAc,EAAG,QAAO;AACxC,YAAM,oBAAoB,KAAK,OAAO,qBAAqB;AAE3D,UACC,qBACA,KAAK,OAAO,aAAa,iBAAiB,EAAE,QAAQ,iBAAiB,GACpE;AACD,aAAK,OAAO,eAAe,QAAQ;AACnC,aAAK,OAAO,gBAAgB,kBAAkB,EAAE;AAChD,aAAK,OAAO,KAAK,WAAW,GAAG,WAAW,iBAAiB;AAAA,UAC1D,GAAG;AAAA,UACH,QAAQ;AAAA,UACR,OAAO;AAAA,QACR,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD;AACD;", "names": [] }