UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

48 lines 2.27 kB
import { NotImplementedException } from "@aurigma/design-atoms-model/Exception"; import { BaseSurfaceCommand } from "./BaseSurfaceCommand"; import { ItemUtils } from "../../Utils/ItemUtils"; import { PlaceholderItem } from "@aurigma/design-atoms-model/Product/Items"; import { SetImageItemCommand } from "../ItemsCommands/SetImageItemCommand"; import { ProductCommand } from "@aurigma/design-atoms-interfaces"; export class SetBleedCommand extends BaseSurfaceCommand { constructor(_productHandler, historyArgs, args, _commandManager) { super(args.surface, historyArgs, args); this._productHandler = _productHandler; this._commandManager = _commandManager; } async _executeCommandBody() { const normalizedArgs = Object.assign({ surface: this._productHandler.currentSurface }, this._args); const printArea = normalizedArgs.surface.printAreas.firstOrDefault(); if (printArea != null) printArea.bleed = normalizedArgs.bleed; await this._updateBackground(normalizedArgs); } async _updateBackground(args) { var _a; const bgItem = args.surface.getBackgroundItem(); if (bgItem == null) return; const bgImage = ItemUtils.getImageItem(bgItem); let imageData = null; if (bgImage != null) { imageData = ((((_a = bgImage === null || bgImage === void 0 ? void 0 : bgImage.source) === null || _a === void 0 ? void 0 : _a.id) != null) || ((bgImage === null || bgImage === void 0 ? void 0 : bgImage.name) != null)) ? SetImageItemCommand.getImageData(bgImage) : null; if ((imageData === null || imageData === void 0 ? void 0 : imageData.storageId) == null) { imageData = bgItem.fillColor; } } else if (bgItem instanceof PlaceholderItem) { imageData = bgItem.fillColor; } await this._commandManager.execute(ProductCommand.changeBackground, { surfaces: [args.surface], data: imageData }); } redo() { throw new NotImplementedException(); } undo() { throw new NotImplementedException(); } } //# sourceMappingURL=SetBleedCommand.js.map