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:340

Properties

actions

actions: Actions

The actions

Source

editor.ts:230


canvas

canvas: Canvas

The canvas object

Source

editor.ts:255


canvasElement

canvasElement: HTMLCanvasElement

The canvas element

Source

editor.ts:250


clipboard

clipboard: Clipboard

The clipboard object

Source

editor.ts:215


factory

factory: ShapeFactory

The shape factory

Source

editor.ts:225


keymap

keymap: KeymapManager

The keymap manager

Source

editor.ts:235


onActiveHandlerChange

onActiveHandlerChange: TypedEvent<string>

The event emitter for active handler change

Source

editor.ts:135


onActiveHandlerLockChange

onActiveHandlerLockChange: TypedEvent<boolean>

The event emitter for active handler lock change

Source

editor.ts:140


onCurrentPageChange

onCurrentPageChange: TypedEvent<Page>

The event emitter for current page change

Source

editor.ts:130


onDblClick

onDblClick: TypedEvent<DblClickEvent>

The event emitter for double click

Source

editor.ts:170


onDrag

onDrag: TypedEvent<DragEvent>

The event emitter for drag

Source

editor.ts:185


onDragEnd

onDragEnd: TypedEvent<DragEvent>

The event emitter for drag end

Source

editor.ts:190


onDragStart

onDragStart: TypedEvent<DragEvent>

The event emitter for drag start

Source

editor.ts:180


onFileDrop

onFileDrop: TypedEvent<FileDropEvent>

The event emitter for file drop

Source

editor.ts:195


onKeyDown

onKeyDown: TypedEvent<KeyboardEvent>

The event emitter for key down

Source

editor.ts:175


onPointerDown

onPointerDown: TypedEvent<CanvasPointerEvent>

The event emitter for pointer down

Source

editor.ts:155


onPointerMove

onPointerMove: TypedEvent<CanvasPointerEvent>

The event emitter for pointer move

Source

editor.ts:160


onPointerUp

onPointerUp: TypedEvent<CanvasPointerEvent>

The event emitter for pointer up

Source

editor.ts:165


onRepaint

onRepaint: TypedEvent<void>

The event emitter for repaint

Source

editor.ts:200


onScroll

onScroll: TypedEvent<number[]>

The event emitter for scroll

Source

editor.ts:150


onZoom

onZoom: TypedEvent<number>

The event emitter for zoom

Source

editor.ts:145


options

options: EditorOptions

The editor options

Source

editor.ts:115


parent

parent: HTMLElement

The parent element

Source

editor.ts:245


platform

platform: string

The platform

Source

editor.ts:125


plugins

plugins: Record<string, Plugin>

The plugins

Source

editor.ts:120


selection

selection: SelectionManager

The selection manager

Source

editor.ts:220


store

store: Store

The store object

Source

editor.ts:205


transform

transform: Transform

The transform object

Source

editor.ts:210

Methods

activateDefaultHandler()

activateDefaultHandler(): void

Activate the default handler

Returns

void

Source

editor.ts:1090


activateHandler()

activateHandler(id): void

Activate a handler by id

Parameters

id: string

Returns

void

Source

editor.ts:1073


drawSelection()

drawSelection(): void

Draw selection

Returns

void

Source

editor.ts:1196


fit()

fit(): void

Fit the editor size to the holder element

Returns

void

Source

editor.ts:886


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:994


focus()

focus(): void

Set focus on this editor

Returns

void

Source

editor.ts:802


getActiveHandler()

getActiveHandler(): null | Handler

Get the active handler

Returns

null | Handler

Source

editor.ts:1066


getActiveHandlerLock()

getActiveHandlerLock(): boolean

Get active handler lock

Returns

boolean

Source

editor.ts:1109


getBoundingRect()

getBoundingRect(): number[][]

Get bounding rect in GCS

Returns

number[][]

Source

editor.ts:949


getCenter()

getCenter(): number[]

Get screen center point in GCS

Returns

number[]

Source

editor.ts:941


getCurrentPage()

getCurrentPage(): null | Page

Get current page

Returns

null | Page

Source

editor.ts:763


getCursor()

getCursor(): string

Get cursor

Returns

string

Source

editor.ts:1231


getDarkMode()

getDarkMode(): boolean

Get dark mode

Returns

boolean

Source

editor.ts:809


getDoc()

getDoc(): Doc

Get the document

Returns

Doc

Source

editor.ts:1246


getEnabled()

getEnabled(): boolean

Get enabled state

Returns

boolean

Source

editor.ts:748


getGridSize()

getGridSize(): number[]

Get grid size

Returns

number[]

Source

editor.ts:828


getOrigin()

getOrigin(): number[]

Get origin point in CCS

Returns

number[]

Source

editor.ts:894


getPages()

getPages(): Page[]

Get pages

Returns

Page[]

Source

editor.ts:792


getPlugin()

getPlugin(id): null | Plugin

Get a plugin by id

Parameters

id: string

Returns

null | Plugin

Source

editor.ts:741


getScale()

getScale(): number

Get scale

Returns

number

Source

editor.ts:957


getShowGrid()

getShowGrid(): boolean

Get show grid state

Returns

boolean

Source

editor.ts:843


getSize()

getSize(): number[]

Return the size of canvas element in CCS

Returns

number[]

Source

editor.ts:920


getSnapToGrid()

getSnapToGrid(): boolean

Get snap to grid

Returns

boolean

Source

editor.ts:858


getSnapToObject()

getSnapToObject(): boolean

Get snap to object

Returns

boolean

Source

editor.ts:872


loadFromJSON()

loadFromJSON(json): void

Load from JSON

Parameters

json: any

Returns

void

Source

editor.ts:1274


moveOrigin()

moveOrigin(dx, dy): void

Move origin point

Parameters

dx: number

dy: number

Returns

void

Source

editor.ts:913


newDoc()

newDoc(): Doc

Create a new document

Returns

Doc

Source

editor.ts:1260


repaint()

repaint(drawSelection): void

Repaint diagram

Parameters

drawSelection: boolean= true

Returns

void

Source

editor.ts:1216


saveToJSON()

saveToJSON(): any

Save to JSON

Returns

any

Source

editor.ts:1291


scroll()

scroll(dx, dy): void

Scroll screen

Parameters

dx: number

dy: number

Returns

void

Source

editor.ts:1017


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:1026


scrollToCenter()

scrollToCenter(): void

Scroll to center of the shapes

Returns

void

Source

editor.ts:1052


setActiveHandlerLock()

setActiveHandlerLock(lock): void

Set active handler lock

Parameters

lock: boolean

Returns

void

Source

editor.ts:1099


setCurrentPage()

setCurrentPage(page): void

Set current page

Parameters

page: Page

Returns

void

Source

editor.ts:770


setCursor()

setCursor(cursor, angle): void

Set cursor

Parameters

cursor: string

angle: number= 0

Returns

void

Source

editor.ts:1238


setDarkMode()

setDarkMode(dark): void

Set dark mode

Parameters

dark: boolean

Returns

void

Source

editor.ts:816


setDoc()

setDoc(doc): void

Set the document

Parameters

doc: Doc

Returns

void

Source

editor.ts:1253


setEnabled()

setEnabled(enabled): void

Set enabled state

Parameters

enabled: boolean

Returns

void

Source

editor.ts:755


setGridSize()

setGridSize(gridSize): void

Set grid size

Parameters

gridSize: number[]

Returns

void

Source

editor.ts:835


setOrigin()

setOrigin(x, y): void

Set origin point

Parameters

x: number

y: number

Returns

void

Source

editor.ts:901


setScale()

setScale(scale): void

Set scale

Parameters

scale: number

Returns

void

Source

editor.ts:964


setShowGrid()

setShowGrid(show): void

Set show grid or not

Parameters

show: boolean

Returns

void

Source

editor.ts:850


setSize()

setSize(width, height): void

Set canvas element size

Parameters

width: number

height: number

Returns

void

Source

editor.ts:927


setSnapToGrid()

setSnapToGrid(value): void

Set snap to grid

Parameters

value: boolean

Returns

void

Source

editor.ts:865


setSnapToObject()

setSnapToObject(value): void

Set snap to object

Parameters

value: boolean

Returns

void

Source

editor.ts:879


update()

update(): void

Update all shapes

Returns

void

Source

editor.ts:1205


zoom()

zoom(scale): void

Set zoom scale while keeping the screen center

Parameters

scale: number= 1

Returns

void

Source

editor.ts:984