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

Properties

actions

actions: Actions

The actions

Source

editor.ts:225


canvas

canvas: Canvas

The canvas object

Source

editor.ts:250


canvasElement

canvasElement: HTMLCanvasElement

The canvas element

Source

editor.ts:245


clipboard

clipboard: Clipboard

The clipboard object

Source

editor.ts:210


factory

factory: ShapeFactory

The shape factory

Source

editor.ts:220


keymap

keymap: KeymapManager

The keymap manager

Source

editor.ts:230


onActiveHandlerChange

onActiveHandlerChange: TypedEvent<string>

The event emitter for active handler change

Source

editor.ts:130


onActiveHandlerLockChange

onActiveHandlerLockChange: TypedEvent<boolean>

The event emitter for active handler lock change

Source

editor.ts:135


onCurrentPageChange

onCurrentPageChange: TypedEvent<Page>

The event emitter for current page change

Source

editor.ts:125


onDblClick

onDblClick: TypedEvent<DblClickEvent>

The event emitter for double click

Source

editor.ts:165


onDrag

onDrag: TypedEvent<DragEvent>

The event emitter for drag

Source

editor.ts:180


onDragEnd

onDragEnd: TypedEvent<DragEvent>

The event emitter for drag end

Source

editor.ts:185


onDragStart

onDragStart: TypedEvent<DragEvent>

The event emitter for drag start

Source

editor.ts:175


onFileDrop

onFileDrop: TypedEvent<FileDropEvent>

The event emitter for file drop

Source

editor.ts:190


onKeyDown

onKeyDown: TypedEvent<KeyboardEvent>

The event emitter for key down

Source

editor.ts:170


onPointerDown

onPointerDown: TypedEvent<CanvasPointerEvent>

The event emitter for pointer down

Source

editor.ts:150


onPointerMove

onPointerMove: TypedEvent<CanvasPointerEvent>

The event emitter for pointer move

Source

editor.ts:155


onPointerUp

onPointerUp: TypedEvent<CanvasPointerEvent>

The event emitter for pointer up

Source

editor.ts:160


onRepaint

onRepaint: TypedEvent<void>

The event emitter for repaint

Source

editor.ts:195


onScroll

onScroll: TypedEvent<number[]>

The event emitter for scroll

Source

editor.ts:145


onZoom

onZoom: TypedEvent<number>

The event emitter for zoom

Source

editor.ts:140


options

options: EditorOptions

The editor options

Source

editor.ts:110


parent

parent: HTMLElement

The parent element

Source

editor.ts:240


platform

platform: string

The platform

Source

editor.ts:120


plugins

plugins: Record<string, Plugin>

The plugins

Source

editor.ts:115


selection

selection: SelectionManager

The selection manager

Source

editor.ts:215


store

store: Store

The store object

Source

editor.ts:200


transform

transform: Transform

The transform object

Source

editor.ts:205

Methods

activateDefaultHandler()

activateDefaultHandler(): void

Activate the default handler

Returns

void

Source

editor.ts:1066


activateHandler()

activateHandler(id): void

Activate a handler by id

Parameters

id: string

Returns

void

Source

editor.ts:1049


drawSelection()

drawSelection(): void

Draw selection

Returns

void

Source

editor.ts:1172


fit()

fit(): void

Fit the editor size to the holder element

Returns

void

Source

editor.ts:862


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


focus()

focus(): void

Set focus on this editor

Returns

void

Source

editor.ts:778


getActiveHandler()

getActiveHandler(): null | Handler

Get the active handler

Returns

null | Handler

Source

editor.ts:1042


getActiveHandlerLock()

getActiveHandlerLock(): boolean

Get active handler lock

Returns

boolean

Source

editor.ts:1085


getBoundingRect()

getBoundingRect(): number[][]

Get bounding rect in GCS

Returns

number[][]

Source

editor.ts:925


getCenter()

getCenter(): number[]

Get screen center point in GCS

Returns

number[]

Source

editor.ts:917


getCurrentPage()

getCurrentPage(): null | Page

Get current page

Returns

null | Page

Source

editor.ts:739


getDarkMode()

getDarkMode(): boolean

Get dark mode

Returns

boolean

Source

editor.ts:785


getDoc()

getDoc(): Doc

Get the document

Returns

Doc

Source

editor.ts:1217


getEnabled()

getEnabled(): boolean

Get enabled state

Returns

boolean

Source

editor.ts:724


getGridSize()

getGridSize(): number[]

Get grid size

Returns

number[]

Source

editor.ts:804


getOrigin()

getOrigin(): number[]

Get origin point in CCS

Returns

number[]

Source

editor.ts:870


getPages()

getPages(): Page[]

Get pages

Returns

Page[]

Source

editor.ts:768


getPlugin()

getPlugin(id): null | Plugin

Get a plugin by id

Parameters

id: string

Returns

null | Plugin

Source

editor.ts:717


getScale()

getScale(): number

Get scale

Returns

number

Source

editor.ts:933


getShowGrid()

getShowGrid(): boolean

Get show grid state

Returns

boolean

Source

editor.ts:819


getSize()

getSize(): number[]

Return the size of canvas element in CCS

Returns

number[]

Source

editor.ts:896


getSnapToGrid()

getSnapToGrid(): boolean

Get snap to grid

Returns

boolean

Source

editor.ts:834


getSnapToObject()

getSnapToObject(): boolean

Get snap to object

Returns

boolean

Source

editor.ts:848


loadFromJSON()

loadFromJSON(json): void

Load from JSON

Parameters

json: any

Returns

void

Source

editor.ts:1244


moveOrigin()

moveOrigin(dx, dy): void

Move origin point

Parameters

dx: number

dy: number

Returns

void

Source

editor.ts:889


newDoc()

newDoc(): Doc

Create a new document

Returns

Doc

Source

editor.ts:1231


repaint()

repaint(drawSelection): void

Repaint diagram

Parameters

drawSelection: boolean= true

Returns

void

Source

editor.ts:1194


saveToJSON()

saveToJSON(): any

Save to JSON

Returns

any

Source

editor.ts:1261


scroll()

scroll(dx, dy): void

Scroll screen

Parameters

dx: number

dy: number

Returns

void

Source

editor.ts:993


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


scrollToCenter()

scrollToCenter(): void

Scroll to center of the shapes

Returns

void

Source

editor.ts:1028


setActiveHandlerLock()

setActiveHandlerLock(lock): void

Set active handler lock

Parameters

lock: boolean

Returns

void

Source

editor.ts:1075


setCurrentPage()

setCurrentPage(page): void

Set current page

Parameters

page: Page

Returns

void

Source

editor.ts:746


setCursor()

setCursor(cursor, angle): void

Set cursor

Parameters

cursor: string

angle: number= 0

Returns

void

Source

editor.ts:1209


setDarkMode()

setDarkMode(dark): void

Set dark mode

Parameters

dark: boolean

Returns

void

Source

editor.ts:792


setDoc()

setDoc(doc): void

Set the document

Parameters

doc: Doc

Returns

void

Source

editor.ts:1224


setEnabled()

setEnabled(enabled): void

Set enabled state

Parameters

enabled: boolean

Returns

void

Source

editor.ts:731


setGridSize()

setGridSize(gridSize): void

Set grid size

Parameters

gridSize: number[]

Returns

void

Source

editor.ts:811


setOrigin()

setOrigin(x, y): void

Set origin point

Parameters

x: number

y: number

Returns

void

Source

editor.ts:877


setScale()

setScale(scale): void

Set scale

Parameters

scale: number

Returns

void

Source

editor.ts:940


setShowGrid()

setShowGrid(show): void

Set show grid or not

Parameters

show: boolean

Returns

void

Source

editor.ts:826


setSize()

setSize(width, height): void

Set canvas element size

Parameters

width: number

height: number

Returns

void

Source

editor.ts:903


setSnapToGrid()

setSnapToGrid(value): void

Set snap to grid

Parameters

value: boolean

Returns

void

Source

editor.ts:841


setSnapToObject()

setSnapToObject(value): void

Set snap to object

Parameters

value: boolean

Returns

void

Source

editor.ts:855


update()

update(): void

Update all shapes

Returns

void

Source

editor.ts:1181


zoom()

zoom(scale): void

Set zoom scale while keeping the screen center

Parameters

scale: number= 1

Returns

void

Source

editor.ts:960