@mescius/dsimageviewer
Version:
Document Solutions Image Viewer
152 lines (151 loc) • 7.14 kB
TypeScript
//@ts-ignore
import { Color, Dropdown } from "@grapecity/core-ui";
//@ts-ignore
import { PluginModel } from "@grapecity/viewer-core";
//@ts-ignore
import { PanelHandle } from "@grapecity/viewer-core/types/api/PluginModel";
//@ts-ignore
import { DocumentViewer } from "@grapecity/viewer-core/types/components";
/// <reference path="../../vendor/i18next.d.ts" />
//@ts-ignore
import { i18n } from "i18next";
/// <reference path="../../vendor/react/react.d.ts" />
//@ts-ignore
import { Component, LegacyRef } from "react";
import { EventBusAttachOptions, EventBusEventName } from "../Core/EventBus";
import { ConfirmButton } from "../Dialogs/Types";
import { IImageLayer } from "../Layers/types";
import { ImageToolbarLayout } from "../Toolbar/ImageToolbarLayout";
import { ColorEditorLocalization } from "../Tools/ColorEditor/types";
import { UndoCommandSupport } from "../Undo/Commands";
import { ViewerOptions } from "../ViewerOptions";
import { IViewerPlugin } from "./IViewerPlugin";
import { IViewerTransactionSupport } from "./IViewerTransactionSupport";
import { IGcSelectionBox, PointLocation, Size } from "./SelectionBoxTypes";
import { ImageFormatCode, SaveOptions } from "./Types";
export interface IImageViewer {
pluginPanels: {
[key: string]: {
handle: PluginModel.PanelHandle;
panel: Component<any> | null;
};
};
closePanel(panelHandleOrId?: PanelHandle | string): any;
get leftSidebar(): any;
createPanel<TState>(component: any, binder: PluginModel.IStateBinder<TState>, key: string, { icon, description, visible, enabled, label, location }: Partial<PluginModel.PanelSettings>): PluginModel.PanelHandle;
showPanel(panelKey: PluginModel.PanelHandle, visible?: boolean): void;
updatePanel(panelKey: PluginModel.PanelHandle, settings: Partial<PluginModel.PanelSettings>): void;
getPanelState(panelKey: PluginModel.PanelHandle): PluginModel.PanelSettings | null;
layoutPanels(layout: string[]): void;
save(options?: string | SaveOptions, original?: boolean): void;
get isFullscreen(): boolean;
toggleFullscreen(fullscreen?: boolean): void;
get isToolbarHidden(): boolean;
toggleToolbar(show?: boolean): void;
toggleSidebar: (show?: boolean | undefined) => void;
get imageFormatSupportsTransparency(): boolean;
maxImageSize: Size;
panSupport: IPanSupport | undefined;
plugin: any;
toolbar: any;
toolbarLayout: ImageToolbarLayout;
altPressed: boolean;
ctrlPressed: boolean;
shiftPressed: boolean;
spacePressed: boolean;
applyToolbarLayout(): any;
addKeyboardListener(uniqueKey: string, handler: WindowKeyboardListener): any;
removeKeyboardListener(uniqueKey: string): any;
canvasToDataURL(canvas: HTMLCanvasElement): string;
configurePluginMainToolbar(pos: number | boolean | undefined, buttonsToInsert: string[]): any;
performTransparencyConversionCheck(message: string): Promise<boolean>;
dataUrlToImageData(dataUrl: string, destinationSize?: {
width: number;
height: number;
}): Promise<ImageData>;
ensurePaintLayer(): IImageLayer;
findPlugin(pluginId: string): IViewerPlugin | null;
getEventCanvasPoint(event: PointerEvent | MouseEvent): PointLocation;
getImageDataUrl(): string;
renderColorDropdown(colorValue: Color | null | undefined, onSelect: (color: Color) => void, localization: ColorEditorLocalization, refCallback: LegacyRef<Dropdown>, settings?: {
size?: 'small' | 'default' | 'large';
includeOpacity?: boolean;
disabled?: boolean;
}): JSX.Element;
setImageDataUrl(dataUrl: any): Promise<void>;
showActivitySpinner(container?: HTMLElement): any;
hideActivitySpinner(): any;
setTransaction(transaction: IViewerTransactionSupport): any;
confirmChanges(): Promise<void>;
cancelChanges(): Promise<void | boolean>;
clearTransaction(transaction: IViewerTransactionSupport): any;
confirm(confirmationText?: string | JSX.Element, level?: "info" | "warning" | "error", title?: string, buttons?: ConfirmButton[]): Promise<boolean | ConfirmButton>;
getOriginalImageDataUrl(): string;
getType(typeName: string): any;
hideSecondToolbar(toolbarKey?: SecondToolbarType): Promise<void>;
invalidate(): any;
raiseStateChanged(): any;
removeLayer(layerOrIndex: IImageLayer | number): any;
removeLayers(): any;
showSecondToolbar(toolbarKey: SecondToolbarType): Promise<void>;
get eventBus(): IEventBus;
get hasImage(): boolean;
get imageFormat(): ImageFormatCode;
set imageFormat(format: ImageFormatCode);
readonly in17n: i18n;
get instanceId(): string;
get layers(): IImageLayer[];
get naturalSize(): {
width: number;
height: number;
};
get secondToolbar(): any;
get selectionBox(): IGcSelectionBox;
get undoStorage(): IUndoStorage;
get hostElement(): Element;
get viewerState(): DocumentViewer.Model;
}
export interface IUndoStorage {
applyOptions(options: ViewerOptions): any;
dispose(): any;
clear(): any;
isCommandSupported(command: UndoCommandSupport): boolean;
execute(command: UndoCommandSupport): Promise<void>;
onCommandExecuted(command: UndoCommandSupport): any;
undo(): Promise<void>;
redo(): Promise<void>;
get hasUndo(): boolean;
get hasRedo(): boolean;
get undoIndex(): number;
get undoCount(): number;
get undoInProgress(): boolean;
get commands(): UndoCommandSupport[];
}
export interface IEventBus {
dispatch(eventName: EventBusEventName, data: any): any;
on(eventName: EventBusEventName, listener: any, options?: EventBusAttachOptions): any;
_on(eventName: EventBusEventName, listener: any, options?: EventBusAttachOptions): any;
off(eventName: EventBusEventName, listener: any): any;
_off(eventName: EventBusEventName, listener: Function | false): any;
}
export declare type PaintToolType = "Selection" | "Pencil" | "Brush" | "Eraser" | "CloneStamp" | "Text" | "None";
export declare type ToolbarItemType = "Selection" | "Pencil" | "Brush" | "Eraser" | "CloneStamp" | "Text" | "Pixelate" | "Blur" | "Brightness" | "Contrast" | "BrightnessContrast" | "Vibrance" | "Splitter" | "Size" | "Color" | "UseOriginalImage" | "Undo" | "Redo" | "Apply" | "Cancel" | "FontSize" | "FontName" | "FontBold" | "FontItalic" | "FontColor";
export declare type SecondToolbarType = "page-tools" | "crop-image" | "resize-image" | "text-tools" | "paint-tools" | "effects" | "image-filter-tools" | "image-filter-settings" | "none";
export interface WindowKeyboardListener {
onKeyDown: (e: KeyboardEvent, params: {
alt: boolean;
ctrl: boolean;
shift: boolean;
space: boolean;
}) => any;
onKeyUp: (e: KeyboardEvent, params: {
alt: boolean;
ctrl: boolean;
shift: boolean;
space: boolean;
}) => any;
}
export interface IPanSupport {
suspend(): void;
resume(): void;
}