refactor(commands): centralize command ids
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { Vec2D } from "@core/geometry";
|
||||
import type { Command } from "./command";
|
||||
import { commandIds } from "./ids";
|
||||
|
||||
export type ViewportPanPayload = {
|
||||
delta: Vec2D;
|
||||
@@ -20,7 +21,7 @@ export type ViewportSetSizePayload = {
|
||||
};
|
||||
|
||||
export const viewportPanCommand: Command<ViewportPanPayload> = {
|
||||
id: "viewport.pan",
|
||||
id: commandIds.viewportPan,
|
||||
name: "Pan viewport",
|
||||
execute({ state }, payload) {
|
||||
return {
|
||||
@@ -40,7 +41,7 @@ export const viewportPanCommand: Command<ViewportPanPayload> = {
|
||||
};
|
||||
|
||||
export const viewportSetZoomCommand: Command<ViewportSetZoomPayload> = {
|
||||
id: "viewport.setZoom",
|
||||
id: commandIds.viewportSetZoom,
|
||||
name: "Set viewport zoom",
|
||||
execute({ state }, payload) {
|
||||
const zoom = Math.max(0.01, payload.zoom);
|
||||
@@ -59,7 +60,7 @@ export const viewportSetZoomCommand: Command<ViewportSetZoomPayload> = {
|
||||
};
|
||||
|
||||
export const viewportZoomAroundPointCommand: Command<ViewportZoomAroundPointPayload> = {
|
||||
id: "viewport.zoomAroundPoint",
|
||||
id: commandIds.viewportZoomAroundPoint,
|
||||
name: "Zoom viewport around point",
|
||||
execute({ state }, payload) {
|
||||
const viewport = state.editor.viewport;
|
||||
@@ -91,7 +92,7 @@ export const viewportZoomAroundPointCommand: Command<ViewportZoomAroundPointPayl
|
||||
};
|
||||
|
||||
export const viewportSetSizeCommand: Command<ViewportSetSizePayload> = {
|
||||
id: "viewport.setSize",
|
||||
id: commandIds.viewportSetSize,
|
||||
name: "Set viewport size",
|
||||
execute({ state }, payload) {
|
||||
return {
|
||||
@@ -111,7 +112,7 @@ export const viewportSetSizeCommand: Command<ViewportSetSizePayload> = {
|
||||
};
|
||||
|
||||
export const viewportResetCommand: Command = {
|
||||
id: "viewport.reset",
|
||||
id: commandIds.viewportReset,
|
||||
name: "Reset viewport",
|
||||
execute({ state }) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user