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.

56 lines 2.93 kB
import { NotImplementedException } from "@aurigma/design-atoms-model/Exception"; import { BaseItemsCommand } from "./BaseItemsCommand"; import { ShapeItem, PlaceholderItem, ContentItem, ImageItem } from "@aurigma/design-atoms-model/Product/Items"; import { ItemsCommand, SelectionCommand } from "@aurigma/design-atoms-interfaces"; export class ConvertItemToPlaceholderCommand extends BaseItemsCommand { constructor(productHandler, historyArgs, args, _commandManager) { super(productHandler, historyArgs, args); this._commandManager = _commandManager; } async _executeCommandBody() { var _a, _b; const { item } = this._args; if (item == null) return; if (!(item instanceof ShapeItem) || item instanceof PlaceholderItem) { console.warn(`ConvertItemToPlaceholderCommand: item type ${item.type} is not supported`); return; } const placeholder = new PlaceholderItem(item.sourceRectangle.clone()); placeholder.sourcePath = item.sourcePath.clone(); placeholder.sourcePathId = item.sourcePathId; placeholder.transform = item.transform.clone(); placeholder.name = item.name; const selected = this._productHandler.isItemSelected(item); await this._commandManager.execute(ItemsCommand.replaceItemCommand, { item: placeholder, oldItem: item }); if (selected) await this._commandManager.execute(SelectionCommand.selectItems, { items: [placeholder] }); if (item instanceof ContentItem) { placeholder.content = item; placeholder.isStubContent = item instanceof ImageItem ? true : false; placeholder.barcodeFormat = (_a = item === null || item === void 0 ? void 0 : item.barcodeFormat) !== null && _a !== void 0 ? _a : null; if (item instanceof ImageItem) { placeholder.allowedSubfolder = item.allowedSubfolder; placeholder.allowedTabs = (_b = item.allowedTabs) === null || _b === void 0 ? void 0 : _b.slice(); } } else { placeholder.fillColor = item.fillColor; placeholder.borderColor = item.borderColor; placeholder.borderWidth = item.borderWidth; } placeholder.manipulationPermissions = item.manipulationPermissions.clone(); placeholder.manipulationPermissions.resizeGrips.edge = true; placeholder.visualizationPermissions = item.visualizationPermissions.clone(); placeholder.itemPermissions = item.itemPermissions.clone(); placeholder.shapePermissions = item.shapePermissions.clone(); return placeholder; } redo() { throw new NotImplementedException(); } undo() { throw new NotImplementedException(); } } //# sourceMappingURL=ConvertItemToPlaceholderCommand.js.map