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.

273 lines (272 loc) 12.9 kB
import { Canvas } from "../Canvas"; import { BaseViewer, ZoomParams } from "./BaseViewer"; import { Surface } from "@aurigma/design-atoms-model/Product/Surface"; import { Container } from "@aurigma/design-atoms-model/Product/Container"; import { Item } from "@aurigma/design-atoms-model/Product/Items/Item"; import { ItemHandler } from "../ItemHandlers/ItemHandler"; import { SafetyLinesHandler } from "./SafetyLinesHandler"; import { WatermarkConfig } from "@aurigma/design-atoms-model/Configuration/WatermarkConfig"; import { GridHandler } from "./GridHandler"; import { EventObject } from "@aurigma/design-atoms-model/EventObject"; import { RectangleF } from "@aurigma/design-atoms-model/Math/index"; import { BaseItem, PlainTextItem, ShapeItem, RectangleItem, BoundedTextItem, ImageItem, PlaceholderItem, AutoScaledTextItem, ArchedTextItem } from "@aurigma/design-atoms-model/Product/Items"; import { PlainTextItemHandler, ShapeItemHandler, RectangleItemHandler, PlaceholderItemHandler, BoundedTextItemHandler, ImageItemHandler, AutoScaledTextItemHandler, ArchedTextItemHandler } from "../ItemHandlers"; import { SurfaceContainer, PrintArea } from "@aurigma/design-atoms-model/Product"; import { LicenseHandler } from "../License"; import { VariableItemHelper } from "../Services/VariableItemHelper"; import { ProductThemeManager } from "../Services/ProductTheme/ProductThemeManager"; import { History } from "../History"; import { CommandManager } from "../Commands/CommandManager"; import { ProductHandler } from "../Services/ProductHandler"; import { IHitTestManager, IViewerConfiguration, TextEditorMode } from "./Interfaces"; import { IEventManager } from "../Services/IEventManager"; import { ItemsDataApplier } from "../Services/ItemsDataApplier"; import { SurfaceHandler } from "../Services/SurfaceHandler"; import { ViolationService } from "./../Services/ViolationService/ViolationService"; import * as TextWhizz from "@aurigma/text-whizz/TextWhizzJS"; import { IFontService } from "../InPlace/IFontService"; import { ViolationServiceFactory } from "../Services/ViolationService/ViolationServiceFactory"; import { Func } from "@aurigma/design-atoms-model/Utils/Types/Func"; import { InputHandlerManager } from "./../Input/InputHandler/InputHandlerManager"; import { InputHandlerType } from "./../Input/InputHandler/InputHandlerType"; import { ICreateInputHandlerArgs } from "./../Input/InputHandler/Create/CreateInputHandler"; import { ISetInputHandlerOptions } from "./../Input/InputHandler/ISetInputHandlerOptions"; import { IInputHandlerArgs } from "./../Input/InputHandler/IInputHandlerArgs"; import { IViewer } from "./Interfaces/IViewer"; import { IDesignAtomsApiClient } from "../Services/IDesignAtomsApiClient"; import { IListenableColorPreviewService } from "../Services/IColorPreviewService"; import { IColorParser, IRgbColorParser } from "../Serialization/Color"; import { IPreviewOptions } from "../Services/ProductPreview"; import { IInteractiveZonesHandler } from "./Interfaces/IInteractiveZonesHandler"; import { IRenderingConfigProvider } from "../IRenderingConfigProvider"; import { IRenderingConfig } from "@aurigma/design-atoms-model"; import { IQueryOptions } from "@aurigma/design-atoms-interfaces"; export interface IOptions { holderElement: HTMLDivElement; surface?: Surface; rulerEnabled?: boolean; canvasBackground?: CanvasBackground; backendUrl?: string; frontEndTextRenderingEnabled?: boolean; zone?: any; productViewerPartId?: string; ignorePermissionsMode?: boolean; keyInputElement?: HTMLDivElement; readonlyCanvasMode?: boolean; } export declare type CanvasBackground = "chess" | { color: string; }; export declare type ContainersChangeData = { added: Container[]; removed: Container[]; }; export declare class Viewer extends BaseViewer implements IViewer { static preventKeyHandleClass: string; static preventClickHandleClass: string; readonly frontEndTextRenderingEnabled: boolean; readonly containersFlatListChangedEvent: EventObject<ContainersChangeData>; private readonly _scrollbarStyleHandler; private readonly _renderingConfigProvider; private _containersFlatList; private _commandManager; private _onCanvasStatusChangedDelegate; private _resizeDelegate; private _modalBgClass; private _clearSelectionOnDocumentClick; private _clearSelectionOnViewerClick; private _devicePixelRatio; private _whitespaceDiv; private _viewportDiv; private _resizeCheckIntervalId; private _backendUrl; private _safetyLinesHandler; private _watermarkHandler; private _gridHandler; private _variableItemHelper; private _eventManager; private _productThemeManager; private _snapshotHandler; private _history; private _productHandler; private _itemsDataApplier; private _surfaceHandler; private _textFormattingEnabled; private _violationService; private _canvasViolationVisualizer; private _violationServiceFactory; private _inputHandlerManager; private _configuration; private _licenseHandler; private _ignorePermissionsModeEnabled; private _designAtomsApiClient; private _colorPreviewService; private _colorParser; private _rgbColorParser; private _service; private _userEditContainer; private _productPreviewService; private _interactiveZonesHandler; private _viewerInitializer; constructor({ holderElement, backendUrl, surface, canvasBackground, rulerEnabled, frontEndTextRenderingEnabled, zone, productViewerPartId, ignorePermissionsMode, keyInputElement, readonlyCanvasMode }: IOptions); /** * @param surfaceIndex Index of the surface to preview * @param options Preview rendering options * @returns Blob containing the preview image of given surface */ getSurfacePreview(surfaceIndex: number, options?: IPreviewOptions): Promise<Blob>; /** * @param options Preview rendering options * @returns Blob containing the preview image of the current surface */ getCurrentSurfacePreview(options?: IPreviewOptions): Promise<Blob>; ensureFocus(): void; get backendUrl(): string; set backendUrl(value: string); get designAtomsApiClient(): IDesignAtomsApiClient; get colorPreviewService(): IListenableColorPreviewService; get colorParser(): IColorParser; get rgbColorParser(): IRgbColorParser; get hitTestManager(): IHitTestManager; private get _serviceEndpoint(); get containersFlatList(): Container[]; get commandManager(): CommandManager; get configuration(): IViewerConfiguration; set configuration(conf: IViewerConfiguration); get renderingConfig(): IRenderingConfig | null; get renderingConfigProvider(): IRenderingConfigProvider; exitEditMode(): Promise<void>; setInputHandlerType(type: InputHandlerType.Create, args: ICreateInputHandlerArgs, options?: ISetInputHandlerOptions): any; setInputHandlerType(type: InputHandlerType.Default): any; setInputHandlerType(type: InputHandlerType.Locked): any; setInputHandlerType(type: InputHandlerType.SelectPixel, args: IInputHandlerArgs, options?: ISetInputHandlerOptions): any; get inputHandlerManager(): InputHandlerManager; queryItems(selectors: string, queryOptions?: IQueryOptions): Item[]; private _updateItem; private _initializeHistory; private _onHistoryChanged; private _normalizeHolderElement; private _createViewerElement; get licenseHandler(): LicenseHandler; private _createCanvas; private _setCanvasBackground; setTextWhizzModule(textWhizz: typeof TextWhizz): void; private _textEditorMode; private _fontService; private _useSimpleFontList; private _textInputIssueUserConfirmationDelegate; initTextEditor(fontService: IFontService, useSimpleFontList: boolean, textEditor?: TextEditorMode, textInputIssueUserConfirmationDelegate?: Func<Promise<boolean>, string>): void; get textEditorMode(): TextEditorMode; setTextEditorMode(value: number): void; set textEditorMode(value: TextEditorMode); get canvas(): Canvas; get whitespaceDiv(): HTMLDivElement; get viewportDiv(): HTMLDivElement; private _surface; get surface(): Surface; set surface(value: Surface); get safetyLinesHandler(): SafetyLinesHandler; get gridHandler(): GridHandler; get surfaceHandler(): SurfaceHandler; get violationService(): ViolationService; get violationServiceFactory(): ViolationServiceFactory; get interactiveZonesHandler(): IInteractiveZonesHandler; private _onCurrentSurfaceChange; private _onCurrentSurfaceContainerAdded; private _updateAlignMargin; private _getContainerCollections; get watermarkConfig(): WatermarkConfig; set watermarkConfig(value: WatermarkConfig); get selectedItems(): Item[]; set selectedItems(value: Item[]); get currentItem(): Item; private _onSurfacePropertyChanged; private _onPrintAreaPropertyChanged; private _updateCanvasByPrintAreaBounds; private _restoreSelectionAfterSnapshotLoaded; get zoomConfig(): import("./Interfaces").IRangeParams; get previewMode(): boolean; set previewMode(value: boolean); private _updateContainersFlatList; private _getDifference; /** * @returns {number} content width in css pixels */ get contentWidth(): number; /** * @returns {number} content height in css pixels */ get contentHeight(): number; _getContentDimension(workspaceDimension: any, screenDpi: any): number; get workspaceWidth(): number; get workspaceHeight(): number; get actualSizeHorizontalScale(): number; get actualSizeVerticalScale(): number; get modalBgClass(): any; set modalBgClass(value: any); get textFormattingEnabled(): boolean; set textFormattingEnabled(v: boolean); get clearSelectionOnDocumentClick(): boolean; set clearSelectionOnDocumentClick(value: boolean); get clearSelectionOnViewerClick(): boolean; set clearSelectionOnViewerClick(value: boolean); protected _renderContent(sb: string): string; protected _setZoomMode(v: any): void; zoomToRectangle(rect: RectangleF): void; setZoom(value: any, params?: ZoomParams, ignoreZoomConfigRestrictions?: boolean, withoutUpdate?: boolean): any; getMaxZoom(): number; _onDocumentClick(e: any): void; _ignoreSelectionClick(e: any): boolean; initialize({ ignore, intervalCheckLoop, readonlyCanvasMode }?: { ignore?: boolean; intervalCheckLoop?: any; readonlyCanvasMode?: boolean; }): void; private _createViewportDiv; _getCurrentScrollPosition(): { x: any; y: any; }; _updateWhitespace(): void; zoomToSelection(): void; protected _updateViewportNew(): void; protected _updateViewport(ignoreZoomConfigRestrictions?: boolean): void; protected _getElementForCursor(): any; _onResize(sender: any, updateButtonGroup: any): void; _onCanvasStatusChanged(sender: any): void; lockViewer(): void; unlockViewer(): void; get eventManager(): IEventManager; get history(): History; get userEditContainer(): SurfaceContainer; set userEditContainer(value: SurfaceContainer); /** {@inheritDoc ProductHandler.interactiveContainers} */ get interactiveContainers(): Container[]; set interactiveContainers(value: Container[]); getUserEditSurface(): Surface; getUserEditPrintArea(): PrintArea; get variableItemHelper(): VariableItemHelper; get productThemeManager(): ProductThemeManager; get productHandler(): ProductHandler; get itemsDataApplier(): ItemsDataApplier; getHandler(item: BaseItem): ItemHandler; getHandler(item: PlainTextItem): PlainTextItemHandler; getHandler(item: ShapeItem): ShapeItemHandler; getHandler(item: RectangleItem): RectangleItemHandler; getHandler(item: PlaceholderItem): PlaceholderItemHandler; getHandler(item: BoundedTextItem): BoundedTextItemHandler; getHandler(item: ImageItem): ImageItemHandler; getHandler(item: PlaceholderItem): PlaceholderItemHandler; getHandler(item: AutoScaledTextItem): AutoScaledTextItemHandler; getHandler(item: ArchedTextItem): ArchedTextItemHandler; getHandler<THandler extends ItemHandler>(item: Item): THandler; releaseHandler(itemHandler: ItemHandler): void; waitUpdate(): Promise<void>; getParentPosition(parentElement: HTMLElement): { top: number; left: number; }; private _onInput; dispose(): void; _refresh(): void; }