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.02 kB
import { NotImplementedException } from "@aurigma/design-atoms-model/Exception"; import { BaseItemsCommand } from "./BaseItemsCommand"; import { BaseTextItem, AutoScaledTextItem, ArchedTextItem, BoundedTextItem, PathBoundedTextItem, PlainTextItem } from "@aurigma/design-atoms-model/Product/Items"; import { StringUtils } from "../../Utils/StringUtils"; import { ItemsCommand, ItemType } from "@aurigma/design-atoms-interfaces"; export class FixUnsupportedTextCommand extends BaseItemsCommand { constructor(historyArgs, args, _commandManager) { super(null, historyArgs, args); this._commandManager = _commandManager; } async _executeCommandBody() { if (this._args.item == null) return; if (!(this._args.item instanceof BaseTextItem)) { console.warn(`FixUnsupportedTextCommand: item type ${this._args.item.type} is not supported`); return; } let item = this._args.item; if (item instanceof AutoScaledTextItem) { item = await this._commandManager.execute(ItemsCommand.convertTextItem, { item: item, to: ItemType.PlainTextItem }); } if (StringUtils.containsRtlChars(item.text)) { item.text = StringUtils.removeRtlChars(item.text); } item.shadow = null; item.overlapLinesEnabled = false; if (!(item instanceof ArchedTextItem)) item.maxLineCount = null; if (item instanceof PathBoundedTextItem) { item.isVertical = false; } if (item instanceof BoundedTextItem) { item.isVertical = false; item.scheduledFitMode = null; } if (item instanceof PlainTextItem) { item.isVertical = false; } return item; } redo() { throw new NotImplementedException(); } undo() { throw new NotImplementedException(); } } //# sourceMappingURL=FixUnsupportedTextCommand.js.map