General API

This article contains a list of all methods available on main pixie object. For description and method list of various available tools see individual articles for tools:

Methods

init

Create a new editor instance.

init(config: PixieConfig): Promise<Pixie>

open

Open editor.

open(config?: Partial<PixieConfig>): void

close

Close editor.

close(): void

setConfig

Override editor configuration.

setConfig(config: Partial<PixieConfig>): void

uploadAndAddImage

Open file upload window and add selected image to canvas.

uploadAndAddImage(): Promise<void>

uploadAndReplaceMainImage

Open file upload window and replace canvas contents with selected image.

uploadAndReplaceMainImage(): Promise<void>

uploadAndOpenStateFile

Open file upload window and replace canvas contents with selected state file.

uploadAndOpenStateFile(): Promise<void>

newCanvas

Clear current canvas and open a new one at specified size.

newCanvas(width: number, height: number, bgColor?: string): Promise<{ width: number; height: number }>

getState

Get current canvas state as json string.

getState(customProps?: string[]): string

setState

Replace current canvas contents with specified pixie state.

setState(data: string | SerializedPixieState): Promise<void>

setStateFromUrl

Replace current canvas contents with pixie state file loaded from specified url.

setStateFromUrl(url: string): Promise<void>

openTool

Open specified tool (crop, draw, text etc.)

openTool(name: ToolName): void

applyChanges

Apply any pending changes from currently open tool. This is identical to clicking "apply" button in the editor.

applyChanges(): void

cancelChanges

Cancel any pending changes from currently open tool. This is identical to clicking "cancel" button in the editor.

cancelChanges(): void

resetEditor

Fully reset editor state and optionally override specified configuration.

resetEditor(config?: PixieConfig): Promise<void>

togglePanel

Toggle specified floating panel.

togglePanel(name: "newImage" | "history" | "objects" | "export", isOpen?: boolean): void

on

Listen to specified canvas event. (List of all available events can be found in the documentation)

on(event: "object:modified", handler: (e: ObjectModifiedEvent) => void): void

isDirty

isDirty(): boolean

Check if any modifications made to canvas have not been applied yet.

notify

Display specified notification message in the editor.

notify(message: string): string