UNPKG

tldraw

Version:

A tiny little drawing editor.

56 lines (55 loc) 2.03 kB
import { updateHoveredShapeId } from "./tools/selection-logic/updateHoveredShapeId.mjs"; function registerDefaultSideEffects(editor) { return editor.sideEffects.register({ instance: { afterChange: (prev, next) => { if (prev.cameraState !== next.cameraState && next.cameraState === "idle") { updateHoveredShapeId(editor); } } }, instance_page_state: { afterChange: (prev, next) => { if (prev.croppingShapeId !== next.croppingShapeId) { const isInCroppingState = editor.isIn("select.crop"); if (!prev.croppingShapeId && next.croppingShapeId) { if (!isInCroppingState) { editor.setCurrentTool("select.crop.idle"); } } else if (prev.croppingShapeId && !next.croppingShapeId) { if (isInCroppingState) { editor.setCurrentTool("select.idle"); } } } if (prev.editingShapeId !== next.editingShapeId) { if (!prev.editingShapeId && next.editingShapeId) { if (!editor.isIn("select.editing_shape")) { const shape = editor.getEditingShape(); if (shape && shape.type === "text" && editor.isInAny("text.pointing", "select.resizing") && editor.getInstanceState().isToolLocked) { editor.setCurrentTool("select.editing_shape", { target: "shape", shape, isCreatingTextWhileToolLocked: true }); } else { editor.setCurrentTool("select.editing_shape", { target: "shape", shape }); } } } else if (prev.editingShapeId && !next.editingShapeId) { if (editor.isIn("select.editing_shape")) { editor.setCurrentTool("select.idle"); } } } } } }); } export { registerDefaultSideEffects }; //# sourceMappingURL=defaultSideEffects.mjs.map