- Implemented command palette with keyboard shortcut (⌘K) for opening. - Added commands for opening, closing, setting query, and selecting items in the command palette. - Created tests for command palette commands and input handling. - Enhanced layer actions with functions for adding, grouping, and deleting layers. - Updated UI components to integrate command palette and shortcuts.
123 lines
2.7 KiB
TypeScript
123 lines
2.7 KiB
TypeScript
import type { ImageDocument } from "@core/document";
|
|
import type { Angle, Rect, Size, Transform, Vec2D } from "@core/geometry";
|
|
import type { ArtboardId, AssetId, LayerId } from "@core/id";
|
|
import type { GenerateSettings, ToolState } from "./tools";
|
|
import type { TransformSession } from "./transform";
|
|
|
|
export type ViewportState = {
|
|
center: Vec2D;
|
|
zoom: number;
|
|
rotation: Angle;
|
|
size: Size;
|
|
};
|
|
|
|
export type SelectionState = {
|
|
artboardId?: ArtboardId;
|
|
layerIds: LayerId[];
|
|
};
|
|
|
|
export type MaskViewMode = "composite" | "blackWhite" | "alpha" | "overlay";
|
|
|
|
export type MaskEditState = {
|
|
targetLayerId: LayerId;
|
|
maskLayerId: LayerId;
|
|
viewMode?: MaskViewMode;
|
|
};
|
|
|
|
export type BrushPreviewState = {
|
|
position: Vec2D;
|
|
};
|
|
|
|
export type BrushStrokePreviewState = {
|
|
layerId: LayerId;
|
|
assetId: AssetId;
|
|
source: string;
|
|
};
|
|
|
|
export type GenerationCandidate = {
|
|
id: string;
|
|
source: string;
|
|
mimeType: string;
|
|
intrinsicSize: Size;
|
|
mode: GenerateSettings["mode"];
|
|
settings: GenerateSettings;
|
|
seed: number;
|
|
width: number;
|
|
height: number;
|
|
inputImage?: string;
|
|
maskImage?: string;
|
|
placement: {
|
|
artboardId: ArtboardId;
|
|
layerName: string;
|
|
transform: Transform;
|
|
};
|
|
inpaint?: {
|
|
targetLayerId: LayerId;
|
|
maskLayerId: LayerId;
|
|
sourceAssetId: AssetId;
|
|
maskAssetId: AssetId;
|
|
inputImage: string;
|
|
maskImage: string;
|
|
crop: {
|
|
assetBounds: Rect;
|
|
documentBounds: Rect;
|
|
padding: number;
|
|
maskedAreaOnly: boolean;
|
|
};
|
|
mask: {
|
|
polarity: GenerateSettings["inpaint"]["maskPolarity"];
|
|
activeBounds: Rect;
|
|
};
|
|
backend: {
|
|
growMaskBy: number;
|
|
maskedContent: GenerateSettings["inpaint"]["maskedContent"];
|
|
maskBlur: number;
|
|
maskFeather: number;
|
|
maskExpand: number;
|
|
cropPadding: number;
|
|
};
|
|
};
|
|
};
|
|
|
|
export type GenerationCompareMode = "result" | "before" | "split";
|
|
|
|
export type GenerationState = {
|
|
candidates: GenerationCandidate[];
|
|
selectedCandidateId?: string;
|
|
compareMode: GenerationCompareMode;
|
|
};
|
|
|
|
export type CommandPaletteState = {
|
|
open: boolean;
|
|
query: string;
|
|
selectedIndex: number;
|
|
};
|
|
|
|
export type EditorState = {
|
|
viewport: ViewportState;
|
|
selection: SelectionState;
|
|
tools: ToolState;
|
|
generation: GenerationState;
|
|
commandPalette: CommandPaletteState;
|
|
transformSession?: TransformSession;
|
|
maskEdit?: MaskEditState;
|
|
brushPreview?: BrushPreviewState;
|
|
brushStrokePreview?: BrushStrokePreviewState;
|
|
};
|
|
|
|
export type HistorySnapshot = {
|
|
document: ImageDocument;
|
|
editor: EditorState;
|
|
};
|
|
|
|
export type HistoryState = {
|
|
past: HistorySnapshot[];
|
|
future: HistorySnapshot[];
|
|
};
|
|
|
|
export type AppState = {
|
|
document: ImageDocument;
|
|
editor: EditorState;
|
|
history: HistoryState;
|
|
};
|