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.

33 lines 1.52 kB
import { BaseCommand } from "../BaseCommand"; import { EqualsOfFloatNumbers } from "@aurigma/design-atoms-model/Math"; import { ArgumentException } from "@aurigma/design-atoms-model/Exception"; import { SelectionCommand } from "@aurigma/design-atoms-interfaces"; export class SelectItemsByRectCommand extends BaseCommand { constructor(args, _canvas, _commandManager) { super(args); this._canvas = _canvas; this._commandManager = _commandManager; } async execute() { const { rect, multiSelectMode } = this._args; if (rect == null) throw new ArgumentException("SelectItemsByRectCommand: rect cannot be null"); if (EqualsOfFloatNumbers(rect.width, 0) || EqualsOfFloatNumbers(rect.height, 0)) return; const filterFunc = (i) => { return this._canvas.viewer.productHandler.userEditContainer == i.item.parentContainer && this._canvas.viewer.productHandler.isInteractive(i.item) && !i.isLocked() && rect.contains(i.rectangle.center); }; var items = this._canvas.getAllItemHandlers({ onlyVisible: true }) .filter(filterFunc) .map(i => i.item); const selectItemsArgs = { items: items, multiSelectMode: multiSelectMode }; await this._commandManager.execute(SelectionCommand.selectItems, selectItemsArgs); } } //# sourceMappingURL=SelectItemsByRect.js.map