feat(commands): add artboard bounds command
This commit is contained in:
@@ -9,6 +9,11 @@ export type DocumentAddArtboardPayload = {
|
||||
bounds: Rect;
|
||||
};
|
||||
|
||||
export type DocumentSetArtboardBoundsPayload = {
|
||||
id: ArtboardId;
|
||||
bounds: Rect;
|
||||
};
|
||||
|
||||
export const documentAddArtboardCommand: Command<DocumentAddArtboardPayload> = {
|
||||
id: commandIds.documentAddArtboard,
|
||||
name: "Add artboard",
|
||||
@@ -32,4 +37,20 @@ export const documentAddArtboardCommand: Command<DocumentAddArtboardPayload> = {
|
||||
},
|
||||
};
|
||||
|
||||
export const documentCommands = [documentAddArtboardCommand] satisfies Command<unknown>[];
|
||||
export const documentSetArtboardBoundsCommand: Command<DocumentSetArtboardBoundsPayload> = {
|
||||
id: commandIds.documentSetArtboardBounds,
|
||||
name: "Set artboard bounds",
|
||||
execute({ state }, payload) {
|
||||
return {
|
||||
...state,
|
||||
document: {
|
||||
...state.document,
|
||||
artboards: state.document.artboards.map((artboard) =>
|
||||
artboard.id === payload.id ? { ...artboard, bounds: { ...payload.bounds } } : artboard,
|
||||
),
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export const documentCommands = [documentAddArtboardCommand, documentSetArtboardBoundsCommand] satisfies Command<unknown>[];
|
||||
|
||||
Reference in New Issue
Block a user