tldraw
Version:
A tiny little drawing editor.
43 lines (42 loc) • 1.59 kB
JavaScript
function registerDefaultSideEffects(editor) {
return editor.sideEffects.register({
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", {
isCreatingTextWhileToolLocked: true
});
} else {
editor.setCurrentTool("select.editing_shape");
}
}
} else if (prev.editingShapeId && !next.editingShapeId) {
if (editor.isIn("select.editing_shape")) {
editor.setCurrentTool("select.idle");
}
}
}
}
}
});
}
export {
registerDefaultSideEffects
};
//# sourceMappingURL=defaultSideEffects.mjs.map