@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
281 lines • 17.7 kB
JavaScript
import { SurfaceManager, SurfaceSwitchCommand } from "../Services/SurfaceManager";
import { ArgumentException } from "@aurigma/design-atoms-model/Exception";
import { RotateProductCommand } from "./ProductCommand/RotateProductCommand";
import { ChangeBackgroundCommand } from "./ProductCommand/ChangeBackgroundCommand";
import { AddItemsCommand } from "./SurfaceCommands/AddItemsCommand";
import { DeleteItemsCommand } from "./ItemsCommands/DeleteItemsCommand";
import { SelectItemsCommand } from "./SelectionCommand/SelectItemsCommand";
import { SelectFirstItemCommand } from "./SelectionCommand/SelectFirstItemCommand";
import { ClearSelectionCommand } from "./SelectionCommand/ClearSelectionCommand";
import { CloneItemsCommand } from "./ItemsCommands/CloneItemsCommand";
import { ReplaceInterpolationPlaceholdersCommand } from "./ProductCommand/ReplaceInterpolationPlaceholders";
import { Surface } from "@aurigma/design-atoms-model/Product";
import { ApplyProductThemeCommand } from "./ProductCommand/ApplyProductThemeCommand";
import { AddContentCommand } from "./ItemsCommands/AddContentCommand";
import { AlignItemsCommand } from "./ItemsCommands/AlignItemsCommand";
import { GroupAlignCommand } from "./ItemsCommands/GroupAlignCommand";
import { BringItemsCommand } from "./ItemsCommands/BringItemsCommand";
import { MoveItemCommand } from "./ItemsCommands/MoveItemCommand";
import { DistributeItemsCommand } from "./ItemsCommands/DistributeItemsCommand";
import { CreateItemCommand } from "./ItemsCommands/CreateItemCommand";
import { EditItemsCommand } from "./ItemsCommands/EditItemsCommand";
import { SetImageMetadataCommand } from "./ItemsCommands/SetImageMetadataCommand";
import { PlaceholderContentScaleCommand } from "./ItemsCommands/PlaceholderContentScaleCommand";
import { PlaceholderContentResetCommand } from "./ItemsCommands/PlaceholderContentResetCommand";
import { ChangeBarcodeFormatCommand } from "./ItemsCommands/ChangeBarcodeFormatCommand";
import { ChangeColumnCountCommand } from "./ItemsCommands/ChangeColumnCountCommand";
import { PlaceholderContentRotateCommand } from "./ItemsCommands/PlaceholderContentRotateCommand";
import { InsertItemsIntoAreaCommand } from "./ItemsCommands/InsertItemsIntoAreaCommand";
import { ChangeLayoutCommand } from "./ItemsCommands/ChangeLayoutCommand";
import { GroupItemsCommand } from "./ItemsCommands/GroupItemsCommand";
import { UngroupItemsCommand } from "./ItemsCommands/UngroupItemsCommand";
import { ReplaceGroupItemContentCommand } from "./ItemsCommands/ReplaceGroupItemContentCommand";
import { ChangeClipartItemColorCommand } from "./ItemsCommands/ChangeClipartItemColor";
import { FillPlaceholdersCommand } from "./ProductCommand/FillPlaceholdersCommand";
import { ResizeCommand } from "./ProductCommand/ResizeCommand";
import { TranslateItemsCommand } from "./ItemsCommands/TranslateItemsCommand";
import { ConvertGroupIntoLayoutCommand } from "./ItemsCommands/ConvertGroupIntoLayoutCommand";
import { ConvertLayoutIntoGroupCommand } from "./ItemsCommands/ConvertLayoutIntoGroupCommand";
import { SetImageItemCommand } from "./ItemsCommands/SetImageItemCommand";
import { ConvertItemToPlaceholderCommand } from "./ItemsCommands/ConvertItemToPlaceholderCommand";
import { ConvertPlaceholderToItemCommand } from "./ItemsCommands/ConvertPlaceholderToItemCommand";
import { SetBleedCommand } from "./SurfaceCommands/SetBleedCommand";
import { ZoomToItemsCommand } from "./ZoomCommands/ZoomToItemsCommand";
import { ZoomToSafetyLineCommand } from "./ZoomCommands/ZoomToSafetyLineCommand";
import { ZoomToSelectionCommand } from "./ZoomCommands/ZoomToSelectionCommand";
import { PlaceItemsToAreaCommand } from "./ItemsCommands/PlaceItemsToAreaCommand";
import { FixUnsupportedTextCommand } from "./ItemsCommands/FixUnsupportedTextCommand";
import { ConvertTextItemCommand } from "./ItemsCommands/ConvertTextItemCommand";
import { SelectItemsByRectCommand } from "./SelectionCommand/SelectItemsByRect";
import { TransformItemsCommand } from "./ItemsCommands/TransformCommands/TransformItemsCommand";
import { ReplaceItemCommand } from "./ItemsCommands/ReplaceItemsCommand";
import { SetSlugCommand } from "./SurfaceCommands/SetSlugCommand";
import { EditPlaceholderCommand } from "./ItemsCommands/EditPlaceholderCommand";
import { RotateItemsCommand } from "./ItemsCommands/TransformCommands/RotateItemsCommand";
import { NewTranslateItemsCommand } from "./ItemsCommands/TransformCommands/NewTranslateItemsCommand";
import { ResizeItemsCommand } from "./ItemsCommands/TransformCommands/ResizeItemsCommand";
import { MoveViewportCommand } from "./ViewerCommands/MoveViewportCommand";
import { SetZoomCommand } from "./ZoomCommands/SetZoomCommand";
import { FrontEndLogger, LogSource } from "./../Services/FrontEndLogger";
import { SelectAllItemsCommand } from "./SelectionCommand/SelectAllCommand";
import { ItemsCommand, ProductCommand, SelectionCommand, SurfaceCommand, ViewerCommand, ZoomCommand, ColorCommand } from "@aurigma/design-atoms-interfaces";
import { ParseColorCommand } from "./ColorCommands/ParseColorCommand";
var CommandManager = /** @class */ (function () {
function CommandManager(_history, _productHandler, _productThemeManager, _variableItemHelper, _eventManager, _canvas, _itemsDataApplier) {
this._history = _history;
this._productHandler = _productHandler;
this._productThemeManager = _productThemeManager;
this._variableItemHelper = _variableItemHelper;
this._eventManager = _eventManager;
this._canvas = _canvas;
this._itemsDataApplier = _itemsDataApplier;
this._surfaceManager = new SurfaceManager(_productHandler);
}
Object.defineProperty(CommandManager.prototype, "_product", {
get: function () {
return this._productHandler.product;
},
enumerable: true,
configurable: true
});
CommandManager.prototype.execute = function (name, args, historyUpdateMode) {
var _a, _b, _c;
this._log(name, args);
var historyArgs = { history: this._history, historyUpdateMode: historyUpdateMode };
var command;
switch (name) {
// TODO: Rewrite to usual commands with SurfaceManager dependency.
case SurfaceSwitchCommand.switchToSurface:
this._surfaceManager.switchToSurface(args.value instanceof Surface ? args.value : this._product.surfaces.get(args.value));
break;
case SurfaceSwitchCommand.getNextSurface:
this._surfaceManager.getNextSurface(args.spinIndex);
break;
case SurfaceSwitchCommand.switchSurfaceForward:
this._surfaceManager.switchSurfaceForward();
break;
case SurfaceSwitchCommand.switchSurfaceBackward:
this._surfaceManager.switchSurfaceBackward();
break;
case ProductCommand.rotateProduct:
command = new RotateProductCommand(this._productHandler, historyArgs, this._product, args);
break;
case ProductCommand.replaceInterpolationPlaceholders:
command = new ReplaceInterpolationPlaceholdersCommand(this._productHandler, historyArgs, this._product, this._canvas);
break;
case ProductCommand.changeBackground:
command = new ChangeBackgroundCommand(this._productHandler, historyArgs, this._product, args, this, this._productThemeManager, this._canvas, this._eventManager);
break;
case ProductCommand.applyProductTheme:
command = new ApplyProductThemeCommand(historyArgs, this._product, args, this._productThemeManager, this);
break;
case ProductCommand.fillPlaceholders:
command = new FillPlaceholdersCommand(historyArgs, this._product, args, this);
break;
case ProductCommand.resize:
command = new ResizeCommand(historyArgs, this._product, args, this._productHandler, this, this._canvas);
break;
case SurfaceCommand.addItems:
command = new AddItemsCommand(this._productHandler, historyArgs, args, this._productThemeManager, this._canvas, this._variableItemHelper, this, this._eventManager);
break;
case SurfaceCommand.setBleed:
command = new SetBleedCommand(this._productHandler, historyArgs, args, this);
break;
case SurfaceCommand.setSlug:
command = new SetSlugCommand(this._productHandler, historyArgs, args);
break;
case ItemsCommand.deleteItems:
command = new DeleteItemsCommand(this._productHandler, historyArgs, args, this._canvas, this.configuration, this);
break;
case ItemsCommand.cloneItems:
command = new CloneItemsCommand(this._productHandler, historyArgs, args, this, this._variableItemHelper);
break;
case ItemsCommand.addContent:
command = new AddContentCommand(this._productHandler, historyArgs, args, this._productThemeManager, this._eventManager);
break;
case ItemsCommand.alignItems:
command = new AlignItemsCommand(this._productHandler, historyArgs, args, this._canvas);
break;
case ItemsCommand.groupAlign:
command = new GroupAlignCommand(this._productHandler, historyArgs, args, this._canvas);
break;
case ItemsCommand.bringItems:
command = new BringItemsCommand(this._productHandler, historyArgs, args, this, this._canvas);
break;
case ItemsCommand.moveItem:
command = new MoveItemCommand(this._productHandler, historyArgs, args);
break;
case ItemsCommand.createItem:
command = new CreateItemCommand(this._productHandler, this._itemsDataApplier, historyArgs, args);
break;
case ItemsCommand.editItems:
command = new EditItemsCommand(this._itemsDataApplier, this._productHandler, historyArgs, args);
break;
case ItemsCommand.setImageMetadata:
command = new SetImageMetadataCommand(this._productHandler, historyArgs, args, this._variableItemHelper, this, this._eventManager);
break;
case ItemsCommand.setImageItem:
command = new SetImageItemCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.placeholderContentScale:
command = new PlaceholderContentScaleCommand(this._productHandler, args, historyArgs);
break;
case ItemsCommand.placeholderContentReset:
command = new PlaceholderContentResetCommand(this._productHandler, args, historyArgs);
break;
case ItemsCommand.changeBarcodeFormat:
command = new ChangeBarcodeFormatCommand(this._productHandler, args, historyArgs);
break;
case ItemsCommand.changeColumnCount:
command = new ChangeColumnCountCommand(this._productHandler, args, historyArgs);
break;
case ItemsCommand.placeholderContentRotate:
command = new PlaceholderContentRotateCommand(this._productHandler, args, historyArgs);
break;
case ItemsCommand.insertItemsIntoArea:
command = new InsertItemsIntoAreaCommand(this._productHandler, args, historyArgs, this);
break;
case ItemsCommand.changeLayout:
command = new ChangeLayoutCommand(this._productHandler, args, historyArgs, this);
break;
case ItemsCommand.groupItems:
command = new GroupItemsCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.ungroupItems:
command = new UngroupItemsCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.replaceGroupItemContent:
command = new ReplaceGroupItemContentCommand(this._productHandler, historyArgs, args, this, this._productThemeManager, this._canvas);
break;
case ItemsCommand.changeClipartItemColor:
command = new ChangeClipartItemColorCommand(historyArgs, args);
break;
case ItemsCommand.translateItems:
command = new TranslateItemsCommand(this._productHandler, historyArgs, args);
break;
case ItemsCommand.convertGroupIntoLayout:
command = new ConvertGroupIntoLayoutCommand(this._productHandler, historyArgs, args, this, this._canvas);
break;
case ItemsCommand.convertLayoutIntoGroup:
command = new ConvertLayoutIntoGroupCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.convertItemToPlaceholder:
command = new ConvertItemToPlaceholderCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.convertPlaceholderToItem:
command = new ConvertPlaceholderToItemCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.placeItemsToArea:
command = new PlaceItemsToAreaCommand(this._productHandler, historyArgs, args, this._canvas);
break;
case ItemsCommand.convertTextItem:
command = new ConvertTextItemCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.transformItems:
command = new TransformItemsCommand(this._productHandler, historyArgs, args);
break;
case ItemsCommand.rotateItems:
command = new RotateItemsCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.newTranslateItems:
command = new NewTranslateItemsCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.resizeItems:
command = new ResizeItemsCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.replaceItemCommand:
command = new ReplaceItemCommand(this._productHandler, historyArgs, args, this);
break;
case ItemsCommand.fixUnsupportedText:
command = new FixUnsupportedTextCommand(historyArgs, args, this);
break;
case ItemsCommand.editPlaceholder:
command = new EditPlaceholderCommand(this._productHandler, args, historyArgs, this);
break;
case ItemsCommand.distributeItems:
return new DistributeItemsCommand(this._canvas, this._productHandler, historyArgs, args).execute();
case SelectionCommand.selectItems:
command = new SelectItemsCommand(this._productHandler, args, this._canvas);
break;
case SelectionCommand.selectItemsByRect:
command = new SelectItemsByRectCommand(args, this._canvas, this);
break;
case SelectionCommand.selectAll:
command = new SelectAllItemsCommand((_a = this._canvas) === null || _a === void 0 ? void 0 : _a.viewer, this);
break;
case SelectionCommand.selectFirst:
command = new SelectFirstItemCommand(this._productHandler, this, this._canvas);
break;
case SelectionCommand.clearSelection:
command = new ClearSelectionCommand(this._canvas);
break;
case ZoomCommand.zoomToItems:
command = new ZoomToItemsCommand(this._productHandler, args, this._canvas);
break;
case ZoomCommand.zoomToSafetyLine:
command = new ZoomToSafetyLineCommand(args, this._canvas);
break;
case ZoomCommand.zoomToSelection:
command = new ZoomToSelectionCommand(this._canvas);
break;
case ZoomCommand.setZoom:
command = new SetZoomCommand(args, this._canvas);
break;
case ViewerCommand.moveViewPort:
command = new MoveViewportCommand(args, (_b = this._canvas) === null || _b === void 0 ? void 0 : _b.viewer);
break;
case ColorCommand.parseColor:
command = new ParseColorCommand(args, (_c = this._canvas) === null || _c === void 0 ? void 0 : _c.viewer);
break;
default:
throw new ArgumentException();
}
return command === null || command === void 0 ? void 0 : command.execute();
};
CommandManager.prototype._log = function (name, args) {
FrontEndLogger.debugLog("Command " + name + " is executing!", LogSource.CommandManager);
};
return CommandManager;
}());
export { CommandManager };
//# sourceMappingURL=CommandManager.js.map