27 lines
860 B
TypeScript
27 lines
860 B
TypeScript
import type { WorkspacePanel } from "@editor/state";
|
|
import type { Command } from "./command";
|
|
import { commandIds } from "./ids";
|
|
|
|
export type WorkspaceSetPanelPayload = { panel: WorkspacePanel };
|
|
|
|
export const workspaceSetPanelCommand: Command<WorkspaceSetPanelPayload> = {
|
|
id: commandIds.workspaceSetPanel,
|
|
name: "Set workspace panel",
|
|
history: { mode: "ignore" },
|
|
execute({ state }, payload) {
|
|
if (!workspacePanels.has(payload.panel)) return state;
|
|
if (state.editor.workspace.panel === payload.panel) return state;
|
|
return {
|
|
...state,
|
|
editor: {
|
|
...state.editor,
|
|
workspace: { panel: payload.panel },
|
|
},
|
|
};
|
|
},
|
|
};
|
|
|
|
const workspacePanels = new Set<WorkspacePanel>(["none", "generate", "chromaKey", "layers"]);
|
|
|
|
export const workspaceCommands = [workspaceSetPanelCommand] satisfies Command<unknown>[];
|