forked from nhn/tui.image-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support typescript * fix: incorrect jsdoc * chore: apply feedback * chore: fix any type * chore: add script for tslint * chore: remove unnecessary comment
- Loading branch information
1 parent
72a1699
commit 23ae046
Showing
9 changed files
with
853 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,292 @@ | ||
// Type definitions for TOAST UI Image Editor v3.3.0 | ||
// TypeScript Version: 3.2.2 | ||
|
||
/// <reference types="jquery" /> | ||
|
||
type AngleType = number; | ||
|
||
interface IThemeConfig { | ||
'common.bi.image'?: string; | ||
'common.bisize.width'?: string; | ||
'common.bisize.height'?: string; | ||
'common.backgroundImage'?: string; | ||
'common.backgroundColor'?: string; | ||
'common.border'?: string; | ||
'header.backgroundImage'?: string; | ||
'header.backgroundColor'?: string; | ||
'header.border'?: string; | ||
'loadButton.backgroundColor'?: string; | ||
'loadButton.border'?: string; | ||
'loadButton.color'?: string; | ||
'loadButton.fontFamily'?: string; | ||
'loadButton.fontSize'?: string; | ||
'downloadButton.backgroundColor'?: string; | ||
'downloadButton.border'?: string; | ||
'downloadButton.color'?: string; | ||
'downloadButton.fontFamily'?: string; | ||
'downloadButton.fontSize'?: string; | ||
'menu.normalIcon.path'?: string; | ||
'menu.normalIcon.name'?: string; | ||
'menu.activeIcon.path'?: string; | ||
'menu.activeIcon.name'?: string; | ||
'menu.iconSize.width'?: string; | ||
'menu.iconSize.height'?: string; | ||
'submenu.backgroundColor'?: string; | ||
'submenu.partition.color'?: string; | ||
'submenu.normalIcon.path'?: string; | ||
'submenu.normalIcon.name'?: string; | ||
'submenu.activeIcon.path'?: string; | ||
'submenu.activeIcon.name'?: string; | ||
'submenu.iconSize.width'?: string; | ||
'submenu.iconSize.height'?: string; | ||
'submenu.normalLabel.color'?: string; | ||
'submenu.normalLabel.fontWeight'?: string; | ||
'submenu.activeLabel.color'?: string; | ||
'submenu.activeLabel.fontWeight'?: string; | ||
'checkbox.border'?: string; | ||
'checkbox.backgroundColor'?: string; | ||
'range.pointer.color'?: string; | ||
'range.bar.color'?: string; | ||
'range.subbar.color'?: string; | ||
'range.value.color'?: string; | ||
'range.value.fontWeight'?: string; | ||
'range.value.fontSize'?: string; | ||
'range.value.border'?: string; | ||
'range.value.backgroundColor'?: string; | ||
'range.title.color'?: string; | ||
'range.title.fontWeight'?: string; | ||
'colorpicker.button.border'?: string; | ||
'colorpicker.title.color'?: string; | ||
} | ||
|
||
interface IIconInfo { | ||
[propName: string]: string; | ||
} | ||
|
||
interface IIconOptions { | ||
fill?: string; | ||
left?: number; | ||
top?: number; | ||
} | ||
|
||
interface IShapeOptions { | ||
fill?: string; | ||
stroke?: string; | ||
strokeWidth?: number; | ||
width?: number; | ||
height?: number; | ||
rx?: number; | ||
ry?: number; | ||
left?: number; | ||
top?: number; | ||
isRegular?: boolean; | ||
} | ||
|
||
interface IGenerateTextOptions { | ||
styles?: ITextStyleConfig; | ||
position?: { | ||
x: number; | ||
y: number; | ||
}; | ||
} | ||
|
||
interface ITextStyleConfig { | ||
fill?: string; | ||
fontFamily?: string; | ||
fontSize?: number; | ||
fontStyle?: string; | ||
fontWeight?: string; | ||
textAlign?: string; | ||
textDecoration?: string; | ||
} | ||
|
||
interface IRectConfig { | ||
left: number; | ||
top: number; | ||
width: number; | ||
height: number; | ||
} | ||
|
||
interface ICanvasSize { | ||
width: number; | ||
height: number; | ||
} | ||
|
||
interface IBrushOptions { | ||
width: number; | ||
color: string; | ||
} | ||
|
||
interface IPositionConfig { | ||
x: number; | ||
y: number; | ||
originX: string; | ||
originY: string; | ||
} | ||
|
||
interface IToDataURLOptions { | ||
format?: string; | ||
quality?: number; | ||
multiplier?: number; | ||
left?: number; | ||
top?: number; | ||
width?: number; | ||
height?: number; | ||
} | ||
|
||
interface IGraphicObjectProps { | ||
id?: number; | ||
type?: string; | ||
text?: string; | ||
left?: string | number; | ||
top?: string | number; | ||
width?: string | number; | ||
height?: string | number; | ||
fill?: string; | ||
stroke?: string; | ||
strokeWidth?: string | number; | ||
fontFamily?: string; | ||
fontSize?: number; | ||
fontStyle?: string; | ||
fontWeight?: string; | ||
textAlign?: string; | ||
textDecoration?: string; | ||
opacity?: number; | ||
[propName: string]: number | string | boolean; | ||
} | ||
|
||
interface IIncludeUIOptions { | ||
loadImage?: { | ||
path: string; | ||
name: string; | ||
}; | ||
theme?: IThemeConfig; | ||
menu?: string[]; | ||
initMenu?: string; | ||
uiSize?: { | ||
width: string; | ||
height: string; | ||
}; | ||
menuBarPosition?: string; | ||
} | ||
|
||
interface ISelectionStyleConfig { | ||
cornerStyle?: string; | ||
cornerSize?: number; | ||
cornerColor?: string; | ||
cornerStrokeColor?: string; | ||
transparentCorners?: boolean; | ||
lineWidth?: number; | ||
borderColor?: string; | ||
rotatingPointOffset?: number; | ||
} | ||
|
||
interface IObjectProps { // icon, shape | ||
fill: string; | ||
height: number; | ||
id: number; | ||
left: number; | ||
opacity: number; | ||
stroke: string | null; | ||
strokeWidth: number | null; | ||
top: number; | ||
type: string; | ||
width: number; | ||
} | ||
|
||
interface ITextObjectProps extends IObjectProps { | ||
fontFamily: string; | ||
fontSize: string; | ||
fontStyle: string; | ||
text: string; | ||
textAlign: string; | ||
textDecoration: string; | ||
} | ||
|
||
interface IFilterResolveObject { | ||
type: string; | ||
action: string; | ||
} | ||
|
||
interface ICropResolveObject { | ||
oldWidth: number; | ||
oldHeight: number; | ||
newWidth: number; | ||
newHeight: number; | ||
} | ||
|
||
interface IFlipXYResolveObject { | ||
flipX: boolean; | ||
flipY: boolean; | ||
angle: AngleType; | ||
} | ||
|
||
interface IOptions { | ||
includeUI?: IIncludeUIOptions; | ||
cssMaxWidth?: number; | ||
cssMaxHeight?: number; | ||
usageStatistics?: boolean; | ||
selectionStyle?: ISelectionStyleConfig; | ||
} | ||
|
||
declare class ImageEditor { | ||
constructor(wrapper: string | JQuery | Element, options: IOptions); | ||
|
||
public addIcon(type: string, options?: IIconOptions): Promise<IObjectProps>; | ||
public addImageObject(imgUrl: string): Promise<void>; | ||
public addShape(type: string, options?: IShapeOptions): Promise<IObjectProps>; | ||
public addText(text: string, options?: IGenerateTextOptions): Promise<ITextObjectProps>; | ||
public applyFilter(type: string, options?: { | ||
maskObjId: number | ||
}): Promise<IFilterResolveObject>; | ||
public changeCursor(cursorType: string): void; | ||
public changeIconColor(id: number, color: string): Promise<void>; | ||
public changeSelectableAll(selectable: boolean): void; | ||
public changeShape(id: number, options?: IShapeOptions): Promise<void>; | ||
public changeText(id: number, text?: string): Promise<void>; | ||
public changeTextStyle(id: number, styleObj: ITextStyleConfig): Promise<void>; | ||
public clearObjects(): Promise<void>; | ||
public clearRedoStack(): void; | ||
public clearUndoStack(): void; | ||
public crop(rect: IRectConfig): Promise<ICropResolveObject>; | ||
public deactivateAll(): void; | ||
public destroy(): void; | ||
public discardSelection(): void; | ||
public flipX(): Promise<IFlipXYResolveObject>; | ||
public flipY(): Promise<IFlipXYResolveObject>; | ||
public getCanvasSize(): ICanvasSize; | ||
public getCropzoneRect(): IRectConfig; | ||
public getDrawingMode(): string; | ||
public getImageName(): string; | ||
public getObjectPosition(id: number, originX: string, originY: string): ICanvasSize; | ||
public getObjectProperties(id: number, keys: string | string[] | IGraphicObjectProps): IGraphicObjectProps; | ||
public hasFilter(type: string): boolean; | ||
public isEmptyRedoStack(): boolean; | ||
public isEmptyUndoStack(): boolean; | ||
public loadImageFromFile(imgFile: File, imageName?: string): Promise<ICropResolveObject>; | ||
public loadImageFromURL(url: string, imageName?: string): Promise<ICropResolveObject>; | ||
public redo(): Promise<any>; | ||
public registerIcons(infos: IIconInfo): void; | ||
public removeActiveObject(): void; | ||
public removeFilter(type?: string): Promise<IFilterResolveObject>; | ||
public removeObject(id: number): Promise<void>; | ||
public resetFlip(): Promise<IFlipXYResolveObject>; | ||
public resizeCanvasDemension(dimension: ICanvasSize): Promise<void>; | ||
public rotate(angle: AngleType): Promise<AngleType>; | ||
public setAngle(angle: AngleType): Promise<AngleType>; | ||
public setBrush(option: IBrushOptions): void; | ||
public setCropzoneRect(mode?: number): void; | ||
public setDrawingShape(type: string, options?: IShapeOptions): void; | ||
public setObjectPosition(id: number, posInfo?: IPositionConfig): Promise<void>; | ||
public setObjectProperties(id: number, keyValue?: IGraphicObjectProps): Promise<void>; | ||
public setObjectPropertiesQuietly(id: number, keyValue?: IGraphicObjectProps): Promise<void>; | ||
public startDrawingMode(mode: string, option?: {width?: number, color?: string}): boolean; | ||
public stopDrawingMode(): void; | ||
public toDataURL(options?: IToDataURLOptions): string; | ||
public undo(): Promise<any>; | ||
public on(eventName: string, handler: (...args: any[]) => void): void; | ||
} | ||
|
||
declare module 'tui-image-editor' { | ||
export = ImageEditor; | ||
} |
Oops, something went wrong.