2026-05-21 00:02:12 +07:00
|
|
|
import type { EditorToolId } from "@pien-studio/editor-core";
|
2026-05-10 03:06:54 +07:00
|
|
|
|
|
|
|
|
export type ToolModeController = {
|
|
|
|
|
kind: "mode";
|
|
|
|
|
id: EditorToolId;
|
|
|
|
|
label: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type ToolActionController = {
|
|
|
|
|
kind: "action";
|
|
|
|
|
id: string;
|
|
|
|
|
label: string;
|
|
|
|
|
run: () => void;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type EditorToolController = ToolModeController | ToolActionController;
|
|
|
|
|
|
|
|
|
|
type CreateEditorToolControllersOptions = {
|
|
|
|
|
onAddTextLayer: () => void;
|
|
|
|
|
onImportImage: () => void;
|
|
|
|
|
labels: {
|
|
|
|
|
pointer: string;
|
|
|
|
|
pan: string;
|
|
|
|
|
face: string;
|
2026-05-21 00:02:12 +07:00
|
|
|
fill: string;
|
|
|
|
|
brush: string;
|
2026-05-10 03:06:54 +07:00
|
|
|
text: string;
|
|
|
|
|
image: string;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function createEditorToolControllers(options: CreateEditorToolControllersOptions): EditorToolController[] {
|
|
|
|
|
return [
|
|
|
|
|
{ kind: "mode", id: "pointer", label: options.labels.pointer },
|
|
|
|
|
{ kind: "mode", id: "hand", label: options.labels.pan },
|
|
|
|
|
{ kind: "mode", id: "face", label: options.labels.face },
|
2026-05-21 00:02:12 +07:00
|
|
|
{ kind: "mode", id: "fill", label: options.labels.fill },
|
|
|
|
|
{ kind: "mode", id: "brush", label: options.labels.brush },
|
2026-05-10 03:06:54 +07:00
|
|
|
{ kind: "action", id: "add-text", label: options.labels.text, run: options.onAddTextLayer },
|
|
|
|
|
{ kind: "action", id: "import-image", label: options.labels.image, run: options.onImportImage },
|
|
|
|
|
];
|
|
|
|
|
}
|