Files
image-studio/editor/tools.ts
2026-07-03 17:32:46 +02:00

22 lines
665 B
TypeScript

export const availableToolIds = ["select", "crop", "pan"] as const;
export type ToolId = (typeof availableToolIds)[number];
export type InteractionMode =
| { type: "tool"; tool: ToolId }
| { type: "temporary-pan"; previousTool: ToolId };
export type ToolState = {
activeTool: ToolId;
interactionMode: InteractionMode;
};
export const initialToolState: ToolState = {
activeTool: "select",
interactionMode: { type: "tool", tool: "select" },
};
export function isPanInteractionMode(interactionMode: InteractionMode): boolean {
return interactionMode.type === "temporary-pan" || (interactionMode.type === "tool" && interactionMode.tool === "pan");
}