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


activateHandler()

activateHandler(id): void

Activate a handler by id

Parameters

id: string

Returns

void

Source

editor.ts:1137


drawSelection()

drawSelection(): void

Draw selection

Returns

void

Source

editor.ts:1266


fit()

fit(): void

Fit the editor size to the holder element

Returns

void

Source

editor.ts:950


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


focus()

focus(): void

Set focus on this editor

Returns

void

Source

editor.ts:866


getActiveHandler()

getActiveHandler(): null | Handler

Get the active handler

Returns

null | Handler

Source

editor.ts:1130


getActiveHandlerLock()

getActiveHandlerLock(): boolean

Get active handler lock

Returns

boolean

Source

editor.ts:1173


getBoundingRect()

getBoundingRect(): number[][]

Get bounding rect in GCS

Returns

number[][]

Source

editor.ts:1013


getCenter()

getCenter(): number[]

Get screen center point in GCS

Returns

number[]

Source

editor.ts:1005


getCurrentPage()

getCurrentPage(): null | Page

Get current page

Returns

null | Page

Source

editor.ts:827


getCursor()

getCursor(): string

Get cursor

Returns

string

Source

editor.ts:1301


getDarkMode()

getDarkMode(): boolean

Get dark mode

Returns

boolean

Source

editor.ts:873


getDoc()

getDoc(): Doc

Get the document

Returns

Doc

Source

editor.ts:1316


getEnabled()

getEnabled(): boolean

Get enabled state

Returns

boolean

Source

editor.ts:812


getGridSize()

getGridSize(): number[]

Get grid size

Returns

number[]

Source

editor.ts:892


getOrigin()

getOrigin(): number[]

Get origin point in CCS

Returns

number[]

Source

editor.ts:958


getPages()

getPages(): Page[]

Get pages

Returns

Page[]

Source

editor.ts:856


getPlugin()

getPlugin(id): null | Plugin

Get a plugin by id

Parameters

id: string

Returns

null | Plugin

Source

editor.ts:805


getScale()

getScale(): number

Get scale

Returns

number

Source

editor.ts:1021


getShowGrid()

getShowGrid(): boolean

Get show grid state

Returns

boolean

Source

editor.ts:907


getSize()

getSize(): number[]

Return the size of canvas element in CCS

Returns

number[]

Source

editor.ts:984


getSnapToGrid()

getSnapToGrid(): boolean

Get snap to grid

Returns

boolean

Source

editor.ts:922


getSnapToObject()

getSnapToObject(): boolean

Get snap to object

Returns

boolean

Source

editor.ts:936


loadFromJSON()

loadFromJSON(json): void

Load from JSON

Parameters

json: any

Returns

void

Source

editor.ts:1344


moveOrigin()

moveOrigin(dx, dy): void

Move origin point

Parameters

dx: number

dy: number

Returns

void

Source

editor.ts:977


newDoc()

newDoc(): Doc

Create a new document

Returns

Doc

Source

editor.ts:1330


repaint()

repaint(drawSelection): void

Repaint diagram

Parameters

drawSelection: boolean= true

Returns

void

Source

editor.ts:1286


saveToJSON()

saveToJSON(): any

Save to JSON

Returns

any

Source

editor.ts:1361


scroll()

scroll(dx, dy): void

Scroll screen

Parameters

dx: number

dy: number

Returns

void

Source

editor.ts:1081


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


scrollToCenter()

scrollToCenter(): void

Scroll to center of the shapes

Returns

void

Source

editor.ts:1116


setActiveHandlerLock()

setActiveHandlerLock(lock): void

Set active handler lock

Parameters

lock: boolean

Returns

void

Source

editor.ts:1163


setCurrentPage()

setCurrentPage(page): void

Set current page

Parameters

page: Page

Returns

void

Source

editor.ts:834


setCursor()

setCursor(cursor, angle): void

Set cursor

Parameters

cursor: string

angle: number= 0

Returns

void

Source

editor.ts:1308


setDarkMode()

setDarkMode(dark): void

Set dark mode

Parameters

dark: boolean

Returns

void

Source

editor.ts:880


setDoc()

setDoc(doc): void

Set the document

Parameters

doc: Doc

Returns

void

Source

editor.ts:1323


setEnabled()

setEnabled(enabled): void

Set enabled state

Parameters

enabled: boolean

Returns

void

Source

editor.ts:819


setGridSize()

setGridSize(gridSize): void

Set grid size

Parameters

gridSize: number[]

Returns

void

Source

editor.ts:899


setOrigin()

setOrigin(x, y): void

Set origin point

Parameters

x: number

y: number

Returns

void

Source

editor.ts:965


setScale()

setScale(scale): void

Set scale

Parameters

scale: number

Returns

void

Source

editor.ts:1028


setShowGrid()

setShowGrid(show): void

Set show grid or not

Parameters

show: boolean

Returns

void

Source

editor.ts:914


setSize()

setSize(width, height): void

Set canvas element size

Parameters

width: number

height: number

Returns

void

Source

editor.ts:991


setSnapToGrid()

setSnapToGrid(value): void

Set snap to grid

Parameters

value: boolean

Returns

void

Source

editor.ts:929


setSnapToObject()

setSnapToObject(value): void

Set snap to object

Parameters

value: boolean

Returns

void

Source

editor.ts:943


update()

update(): void

Update all shapes

Returns

void

Source

editor.ts:1275


zoom()

zoom(scale): void

Set zoom scale while keeping the screen center

Parameters

scale: number= 1

Returns

void

Source

editor.ts:1048