feat(core): add raster layer type

This commit is contained in:
syntaxbullet
2026-07-03 17:34:02 +02:00
parent c946fb4c93
commit 665f4a5340
10 changed files with 66 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ import type { Rect } from "@core/geometry";
import type { ArtboardId, LayerId } from "@core/id";
import type { ImageLayer } from "@core/image-layer";
import type { Layer } from "@core/layer";
import type { RasterLayer } from "@core/raster-layer";
import type { LayerGroup } from "@core/layer-group";
import type { Command } from "./command";
import { commandIds } from "./ids";
@@ -48,6 +49,12 @@ export type DocumentAddImageLayerPayload = {
layer: ImageLayer;
};
export type DocumentAddRasterLayerPayload = {
artboardId: ArtboardId;
parentGroupId?: LayerId;
layer: RasterLayer;
};
export type DocumentAddGroupLayerPayload = {
artboardId: ArtboardId;
parentGroupId?: LayerId;
@@ -223,6 +230,17 @@ export const documentAddImageLayerCommand: Command<DocumentAddImageLayerPayload>
},
};
export const documentAddRasterLayerCommand: Command<DocumentAddRasterLayerPayload> = {
id: commandIds.documentAddRasterLayer,
name: "Add raster layer",
execute({ state }, payload) {
return {
...state,
document: insertLayer(state.document, payload.artboardId, payload.parentGroupId, payload.layer),
};
},
};
export const documentAddGroupLayerCommand: Command<DocumentAddGroupLayerPayload> = {
id: commandIds.documentAddGroupLayer,
name: "Add group layer",
@@ -389,6 +407,7 @@ export const documentCommands = [
documentRenameArtboardCommand,
documentAddAssetCommand,
documentAddImageLayerCommand,
documentAddRasterLayerCommand,
documentAddGroupLayerCommand,
documentMoveLayerCommand,
documentGroupLayersCommand,