Skip to content

Editor

The editor

Constructors

new Editor()

new Editor(editorHolder, options, plugins): Editor

constructor

Parameters

editorHolder: HTMLElement

options: Partial<EditorOptions>

plugins: Plugin[]= []

Returns

Editor

Source

editor.ts:363

Properties

actions

actions: Actions

The actions

Source

editor.ts:240


canvas

canvas: Canvas

The canvas object

Source

editor.ts:265


canvasElement

canvasElement: HTMLCanvasElement

The canvas element

Source

editor.ts:260


clipboard

clipboard: Clipboard

The clipboard object

Source

editor.ts:225


factory

factory: ShapeFactory

The shape factory

Source

editor.ts:235


keymap

keymap: KeymapManager

The keymap manager

Source

editor.ts:245


onActiveHandlerChange

onActiveHandlerChange: TypedEvent<string>

The event emitter for active handler change

Source

editor.ts:140


onActiveHandlerLockChange

onActiveHandlerLockChange: TypedEvent<boolean>

The event emitter for active handler lock change

Source

editor.ts:145


onCurrentPageChange

onCurrentPageChange: TypedEvent<Page>

The event emitter for current page change

Source

editor.ts:135


onDblClick

onDblClick: TypedEvent<DblClickEvent>

The event emitter for double click

Source

editor.ts:175


onDrag

onDrag: TypedEvent<DragEvent>

The event emitter for drag

Source

editor.ts:195


onDragEnd

onDragEnd: TypedEvent<DragEvent>

The event emitter for drag end

Source

editor.ts:200


onDragStart

onDragStart: TypedEvent<DragEvent>

The event emitter for drag start

Source

editor.ts:190


onFileDrop

onFileDrop: TypedEvent<FileDropEvent>

The event emitter for file drop

Source

editor.ts:205


onKeyDown

onKeyDown: TypedEvent<KeyboardEvent>

The event emitter for key down

Source

editor.ts:180


onKeyUp

onKeyUp: TypedEvent<KeyboardEvent>

The event emitter for key up

Source

editor.ts:185


onPointerDown

onPointerDown: TypedEvent<CanvasPointerEvent>

The event emitter for pointer down

Source

editor.ts:160


onPointerMove

onPointerMove: TypedEvent<CanvasPointerEvent>

The event emitter for pointer move

Source

editor.ts:165


onPointerUp

onPointerUp: TypedEvent<CanvasPointerEvent>

The event emitter for pointer up

Source

editor.ts:170


onRepaint

onRepaint: TypedEvent<void>

The event emitter for repaint

Source

editor.ts:210


onScroll

onScroll: TypedEvent<number[]>

The event emitter for scroll

Source

editor.ts:155


onZoom

onZoom: TypedEvent<number>

The event emitter for zoom

Source

editor.ts:150


options

options: EditorOptions

The editor options

Source

editor.ts:120


parent

parent: HTMLElement

The parent element

Source

editor.ts:255


platform

platform: string

The platform

Source

editor.ts:130


plugins

plugins: Record<string, Plugin>

The plugins

Source

editor.ts:125


selection

selection: SelectionManager

The selection manager

Source

editor.ts:230


store

store: Store

The store object

Source

editor.ts:215


transform

transform: Transform

The transform object

Source

editor.ts:220

Methods

activateDefaultHandler()

activateDefaultHandler(): void

Activate the default handler

Returns

void

Source

editor.ts:1163


activateHandler()

activateHandler(id): void

Activate a handler by id

Parameters

id: string

Returns

void

Source

editor.ts:1146


drawSelection()

drawSelection(): void

Draw selection

Returns

void

Source

editor.ts:1275


fit()

fit(): void

Fit the editor size to the holder element

Returns

void

Source

editor.ts:959


fitToScreen()

fitToScreen(scaleAdjust, maxScale): void

Fit doc to screen and move to center

Parameters

scaleAdjust: number= 1

maxScale: number= 1

Returns

void

Source

editor.ts:1067


focus()

focus(): void

Set focus on this editor

Returns

void

Source

editor.ts:875


getActiveHandler()

getActiveHandler(): null | Handler

Get the active handler

Returns

null | Handler

Source

editor.ts:1139


getActiveHandlerLock()

getActiveHandlerLock(): boolean

Get active handler lock

Returns

boolean

Source

editor.ts:1182


getBoundingRect()

getBoundingRect(): number[][]

Get bounding rect in GCS

Returns

number[][]

Source

editor.ts:1022


getCenter()

getCenter(): number[]

Get screen center point in GCS

Returns

number[]

Source

editor.ts:1014


getCurrentPage()

getCurrentPage(): null | Page

Get current page

Returns

null | Page

Source

editor.ts:836


getCursor()

getCursor(): string

Get cursor

Returns

string

Source

editor.ts:1310


getDarkMode()

getDarkMode(): boolean

Get dark mode

Returns

boolean

Source

editor.ts:882


getDoc()

getDoc(): Doc

Get the document

Returns

Doc

Source

editor.ts:1325


getEnabled()

getEnabled(): boolean

Get enabled state

Returns

boolean

Source

editor.ts:821


getGridSize()

getGridSize(): number[]

Get grid size

Returns

number[]

Source

editor.ts:901


getOrigin()

getOrigin(): number[]

Get origin point in CCS

Returns

number[]

Source

editor.ts:967


getPages()

getPages(): Page[]

Get pages

Returns

Page[]

Source

editor.ts:865


getPlugin()

getPlugin(id): null | Plugin

Get a plugin by id

Parameters

id: string

Returns

null | Plugin

Source

editor.ts:814


getScale()

getScale(): number

Get scale

Returns

number

Source

editor.ts:1030


getShowGrid()

getShowGrid(): boolean

Get show grid state

Returns

boolean

Source

editor.ts:916


getSize()

getSize(): number[]

Return the size of canvas element in CCS

Returns

number[]

Source

editor.ts:993


getSnapToGrid()

getSnapToGrid(): boolean

Get snap to grid

Returns

boolean

Source

editor.ts:931


getSnapToObjects()

getSnapToObjects(): boolean

Get snap to object

Returns

boolean

Source

editor.ts:945


loadFromJSON()

loadFromJSON(json): void

Load from JSON

Parameters

json: any

Returns

void

Source

editor.ts:1353


moveOrigin()

moveOrigin(dx, dy): void

Move origin point

Parameters

dx: number

dy: number

Returns

void

Source

editor.ts:986


newDoc()

newDoc(): Doc

Create a new document

Returns

Doc

Source

editor.ts:1339


repaint()

repaint(drawSelection): void

Repaint diagram

Parameters

drawSelection: boolean= true

Returns

void

Source

editor.ts:1295


saveToJSON()

saveToJSON(): any

Save to JSON

Returns

any

Source

editor.ts:1370


scroll()

scroll(dx, dy): void

Scroll screen

Parameters

dx: number

dy: number

Returns

void

Source

editor.ts:1090


scrollCenterTo()

scrollCenterTo(center?): void

Scroll screen center to a point in GCS

Parameters

center?: number[]

center point in GCS. If not provided, scroll to the center of the page size or the center of the shapes

Returns

void

Source

editor.ts:1099


scrollToCenter()

scrollToCenter(): void

Scroll to center of the shapes

Returns

void

Source

editor.ts:1125


setActiveHandlerLock()

setActiveHandlerLock(lock): void

Set active handler lock

Parameters

lock: boolean

Returns

void

Source

editor.ts:1172


setCurrentPage()

setCurrentPage(page): void

Set current page

Parameters

page: Page

Returns

void

Source

editor.ts:843


setCursor()

setCursor(cursor, angle): void

Set cursor

Parameters

cursor: string

angle: number= 0

Returns

void

Source

editor.ts:1317


setDarkMode()

setDarkMode(dark): void

Set dark mode

Parameters

dark: boolean

Returns

void

Source

editor.ts:889


setDoc()

setDoc(doc): void

Set the document

Parameters

doc: Doc

Returns

void

Source

editor.ts:1332


setEnabled()

setEnabled(enabled): void

Set enabled state

Parameters

enabled: boolean

Returns

void

Source

editor.ts:828


setGridSize()

setGridSize(gridSize): void

Set grid size

Parameters

gridSize: number[]

Returns

void

Source

editor.ts:908


setOrigin()

setOrigin(x, y): void

Set origin point

Parameters

x: number

y: number

Returns

void

Source

editor.ts:974


setScale()

setScale(scale): void

Set scale

Parameters

scale: number

Returns

void

Source

editor.ts:1037


setShowGrid()

setShowGrid(show): void

Set show grid or not

Parameters

show: boolean

Returns

void

Source

editor.ts:923


setSize()

setSize(width, height): void

Set canvas element size

Parameters

width: number

height: number

Returns

void

Source

editor.ts:1000


setSnapToGrid()

setSnapToGrid(value): void

Set snap to grid

Parameters

value: boolean

Returns

void

Source

editor.ts:938


setSnapToObjects()

setSnapToObjects(value): void

Set snap to object

Parameters

value: boolean

Returns

void

Source

editor.ts:952


update()

update(): void

Update all shapes

Returns

void

Source

editor.ts:1284


zoom()

zoom(scale): void

Set zoom scale while keeping the screen center

Parameters

scale: number= 1

Returns

void

Source

editor.ts:1057