@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
47 lines • 2.18 kB
JavaScript
import { NotImplementedException, ArgumentException } from "@aurigma/design-atoms-model/Exception";
import { ImageMetaData } from "@aurigma/design-atoms-model/Product/Items";
import { BaseItemsCommand } from "./BaseItemsCommand";
import { HistoryUpdateMode } from "../ModelUpdateCommand";
import { ItemsCommand } from "@aurigma/design-atoms-interfaces";
export class SetImageItemCommand extends BaseItemsCommand {
constructor(productHandler, historyArgs, args, _commandManager) {
super(productHandler, historyArgs, args);
this._commandManager = _commandManager;
}
async _executeCommandBody() {
if (this._args.item == null || this._args.targetItem == null)
throw new ArgumentException("SetImageItemCommand: item and target item cannot be null");
const args = {
dataList: [{
imageData: SetImageItemCommand.getImageData(this._args.item),
item: this._args.targetItem,
tags: this._args.item.tags
}],
dpi: this._args.dpi,
keepLocation: this._args.keepLocation
};
this._commandManager.execute(ItemsCommand.setImageMetadata, args, HistoryUpdateMode.NotUpdate);
}
redo() {
throw new NotImplementedException();
}
undo() {
throw new NotImplementedException();
}
static getImageData(imageItem) {
var _a, _b;
if (imageItem.source == null)
return null;
const result = new ImageMetaData();
result.isUserImage = imageItem.isUserImage;
result.storageId = imageItem.source.id;
result.pageIndex = imageItem.source.pageIndex;
result.isVector = imageItem.source.isVector;
result.name = (_a = imageItem.displayName) !== null && _a !== void 0 ? _a : imageItem.name;
result.origin = (_b = imageItem.source.origin) === null || _b === void 0 ? void 0 : _b.clone();
result.size.width = imageItem.source.width;
result.size.height = imageItem.source.height;
return result;
}
}
//# sourceMappingURL=SetImageItemCommand.js.map