@gorpacrate/core-graphics
Version:
A core library for creating shape-based graphic editors
98 lines (97 loc) • 4.62 kB
TypeScript
import { IShapeDataWithoutId } from '../../declarations/shapes';
import { IEditorEvent } from '../editor-events';
export declare type EditorShapeEvent = IAddShapeEvent | IRemoveShapesEvent | IRemoveSelectedShapesEvent | IRemoveAllShapesEvent | IUpdateShapeCustomParamsEvent | IMoveSelectedShapeEvent | ISendShapesBackwardEvent | ISendShapesForwardEvent | ISendShapesToBackEvent | ISendShapesToFrontEvent;
export declare enum EditorShapeEventType {
AddShape = 0,
RemoveShapes = 1,
RemoveSelectedShapes = 2,
RemoveAllShapes = 3,
UpdateCustomParams = 4,
MoveSelectedShapes = 5,
SendShapesBackward = 6,
SendShapesForward = 7,
SendShapesToBack = 8,
SendShapesToFront = 9
}
export declare type EditorChangeShapesOrderEvent = ISendShapesBackwardEvent | ISendShapesForwardEvent | ISendShapesForwardEvent | ISendShapesToBackEvent;
export declare function isEditorShapeEvent(base: IEditorEvent): base is EditorShapeEvent;
export interface IAddShapeEvent extends IEditorEvent {
subType: EditorShapeEventType.AddShape;
payload: {
shapeData: IShapeDataWithoutId;
selectWhenAdded?: boolean;
};
}
export interface IRemoveShapesEvent extends IEditorEvent {
subType: EditorShapeEventType.RemoveShapes;
payload: {
ids: string[];
};
}
export interface IRemoveSelectedShapesEvent extends IEditorEvent {
subType: EditorShapeEventType.RemoveSelectedShapes;
}
export interface IRemoveAllShapesEvent extends IEditorEvent {
subType: EditorShapeEventType.RemoveAllShapes;
}
export interface IUpdateShapeCustomParamsEvent extends IEditorEvent {
subType: EditorShapeEventType.UpdateCustomParams;
payload: {
id: string;
value: any;
};
}
export interface IMoveSelectedShapeEvent extends IEditorEvent {
subType: EditorShapeEventType.MoveSelectedShapes;
payload: {
dx: number;
dy: number;
};
}
export interface ISendShapesBackwardEvent extends IEditorEvent {
subType: EditorShapeEventType.SendShapesBackward;
payload: {
ids: string[];
};
}
export interface ISendShapesForwardEvent extends IEditorEvent {
subType: EditorShapeEventType.SendShapesForward;
payload: {
ids: string[];
};
}
export interface ISendShapesToBackEvent extends IEditorEvent {
subType: EditorShapeEventType.SendShapesToBack;
payload: {
ids: string[];
};
}
export interface ISendShapesToFrontEvent extends IEditorEvent {
subType: EditorShapeEventType.SendShapesToFront;
payload: {
ids: string[];
};
}
export declare function isAddShapeEditorEvent(base: EditorShapeEvent): base is IAddShapeEvent;
export declare function isRemoveShapesEvent(base: EditorShapeEvent): base is IRemoveShapesEvent;
export declare function isRemoveSelectedShapesEvent(base: EditorShapeEvent): base is IRemoveSelectedShapesEvent;
export declare function isRemoveAllShapesEvent(base: EditorShapeEvent): base is IRemoveAllShapesEvent;
export declare function isUpdateShapeCustomParamsEvent(base: EditorShapeEvent): base is IUpdateShapeCustomParamsEvent;
export declare function isMoveSelectedShapesEvent(base: EditorShapeEvent): base is IMoveSelectedShapeEvent;
export declare function isSendShapesBackwardEvent(base: EditorShapeEvent): base is ISendShapesBackwardEvent;
export declare function isSendShapesForwardEvent(base: EditorShapeEvent): base is ISendShapesForwardEvent;
export declare function isSendShapesToBackEvent(base: EditorShapeEvent): base is ISendShapesToBackEvent;
export declare function isSendShapesToFrontEvent(base: EditorShapeEvent): base is ISendShapesToFrontEvent;
export declare function isChangeShapesOrderEvent(base: EditorShapeEvent): base is EditorChangeShapesOrderEvent;
export declare function addShape(shapeData: IShapeDataWithoutId, params?: {
selectWhenAdded?: boolean;
}): IAddShapeEvent;
export declare function removeShapes(ids: string[]): IRemoveShapesEvent;
export declare function removeSelectedShapes(): IRemoveSelectedShapesEvent;
export declare function removeAllShapes(): IRemoveAllShapesEvent;
export declare function updateShapeCustomParams(id: string, value: any): IUpdateShapeCustomParamsEvent;
export declare function moveSelectedShapes(dx: number, dy: number): IMoveSelectedShapeEvent;
export declare function sendShapesBackward(ids: string[]): ISendShapesBackwardEvent;
export declare function sendShapesForward(ids: string[]): ISendShapesForwardEvent;
export declare function sendShapesToBack(ids: string[]): ISendShapesToBackEvent;
export declare function sendShapesToFront(ids: string[]): ISendShapesToFrontEvent;