/** * Layer operations that integrate with history system * Use these instead of calling store methods directly */ import { useHistoryStore } from '@/store/history-store'; import { CreateLayerCommand, DeleteLayerCommand, UpdateLayerCommand, DuplicateLayerCommand, ReorderLayerCommand, MergeLayerDownCommand, } from '@/core/commands'; import type { CreateLayerParams, LayerUpdate } from '@/types'; /** * Create a new layer (with undo support) */ export function createLayerWithHistory(params: CreateLayerParams): void { const command = new CreateLayerCommand(params); useHistoryStore.getState().executeCommand(command); } /** * Delete a layer (with undo support) */ export function deleteLayerWithHistory(layerId: string): void { const command = new DeleteLayerCommand(layerId); useHistoryStore.getState().executeCommand(command); } /** * Update layer properties (with undo support) */ export function updateLayerWithHistory( layerId: string, updates: LayerUpdate, commandName?: string ): void { const command = new UpdateLayerCommand(layerId, updates, commandName); useHistoryStore.getState().executeCommand(command); } /** * Duplicate a layer (with undo support) */ export function duplicateLayerWithHistory(layerId: string): void { const command = new DuplicateLayerCommand(layerId); useHistoryStore.getState().executeCommand(command); } /** * Reorder a layer (with undo support) */ export function reorderLayerWithHistory(layerId: string, newOrder: number): void { const command = new ReorderLayerCommand(layerId, newOrder); useHistoryStore.getState().executeCommand(command); } /** * Merge layer down (with undo support) */ export function mergeLayerDownWithHistory(layerId: string): void { const command = new MergeLayerDownCommand(layerId); useHistoryStore.getState().executeCommand(command); }