@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
35 lines • 1.53 kB
JavaScript
import { BaseProductCommand } from "./BaseProductCommand";
import { NotImplementedException } from "@aurigma/design-atoms-model/Exception";
import { BaseTextItem } from "@aurigma/design-atoms-model/Product/Items/BaseTextItem";
import { InStringPlaceholderConverter } from "../../Services/InStringPlaceholderConverter";
import { ItemUtils } from "../../Utils/ItemUtils";
export class ReplaceInterpolationPlaceholdersCommand extends BaseProductCommand {
constructor(_productHandler, historyArgs, product, _canvas) {
super(product, historyArgs);
this._productHandler = _productHandler;
this._canvas = _canvas;
}
async _executeCommandBody() {
this.replaceInterpolationPlaceholders();
}
replaceInterpolationPlaceholders() {
const items = this._product.getAllItems({ ignoreMockups: false, flatGroupItems: true }).filter(item => item instanceof BaseTextItem);
const converter = new InStringPlaceholderConverter();
const replacedItems = [];
items.forEach(item => {
if (converter.convert(item))
replacedItems.push(item);
});
if (replacedItems.length > 0) {
ItemUtils.updateItems(replacedItems, this._productHandler, this._canvas);
}
return replacedItems;
}
redo() {
throw new NotImplementedException();
}
undo() {
throw new NotImplementedException();
}
}
//# sourceMappingURL=ReplaceInterpolationPlaceholders.js.map