tldraw
Version:
A tiny little drawing editor.
39 lines (38 loc) • 1.08 kB
JavaScript
import { StateNode } from "@tldraw/editor";
import { updateHoveredShapeId } from "../../../tools/selection-logic/updateHoveredShapeId.mjs";
import { startEditingShapeWithRichText } from "../../../tools/SelectTool/selectHelpers.mjs";
class Idle extends StateNode {
static id = "idle";
onPointerMove(info) {
switch (info.target) {
case "shape":
case "canvas": {
updateHoveredShapeId(this.editor);
}
}
}
onPointerDown(info) {
this.parent.transition("pointing", info);
}
onEnter() {
this.editor.setCursor({ type: "cross", rotation: 0 });
}
onExit() {
updateHoveredShapeId.cancel();
}
onKeyDown(info) {
if (info.key === "Enter") {
const onlySelectedShape = this.editor.getOnlySelectedShape();
if (!this.editor.canEditShape(onlySelectedShape)) return;
this.editor.setCurrentTool("select");
startEditingShapeWithRichText(this.editor, onlySelectedShape.id, { info });
}
}
onCancel() {
this.editor.setCurrentTool("select");
}
}
export {
Idle
};
//# sourceMappingURL=Idle.mjs.map