Editor
The editor
Constructors
new Editor()
new Editor(
editorHolder
,options
,plugins
):Editor
constructor
Parameters
• editorHolder: HTMLElement
• options: Partial
<EditorOptions
>
• plugins: Plugin
[]= []
Returns
Source
Properties
actions
actions:
Actions
The actions
Source
canvas
canvas:
Canvas
The canvas object
Source
canvasElement
canvasElement:
HTMLCanvasElement
The canvas element
Source
clipboard
clipboard:
Clipboard
The clipboard object
Source
factory
factory:
ShapeFactory
The shape factory
Source
keymap
keymap:
KeymapManager
The keymap manager
Source
onActiveHandlerChange
onActiveHandlerChange:
TypedEvent
<string
>
The event emitter for active handler change
Source
onActiveHandlerLockChange
onActiveHandlerLockChange:
TypedEvent
<boolean
>
The event emitter for active handler lock change
Source
onCurrentPageChange
onCurrentPageChange:
TypedEvent
<Page
>
The event emitter for current page change
Source
onDblClick
onDblClick:
TypedEvent
<DblClickEvent
>
The event emitter for double click
Source
onDrag
onDrag:
TypedEvent
<DragEvent
>
The event emitter for drag
Source
onDragEnd
onDragEnd:
TypedEvent
<DragEvent
>
The event emitter for drag end
Source
onDragStart
onDragStart:
TypedEvent
<DragEvent
>
The event emitter for drag start
Source
onFileDrop
onFileDrop:
TypedEvent
<FileDropEvent
>
The event emitter for file drop
Source
onKeyDown
onKeyDown:
TypedEvent
<KeyboardEvent
>
The event emitter for key down
Source
onKeyUp
onKeyUp:
TypedEvent
<KeyboardEvent
>
The event emitter for key up
Source
onPointerDown
onPointerDown:
TypedEvent
<CanvasPointerEvent
>
The event emitter for pointer down
Source
onPointerMove
onPointerMove:
TypedEvent
<CanvasPointerEvent
>
The event emitter for pointer move
Source
onPointerUp
onPointerUp:
TypedEvent
<CanvasPointerEvent
>
The event emitter for pointer up
Source
onRepaint
onRepaint:
TypedEvent
<void
>
The event emitter for repaint
Source
onScroll
onScroll:
TypedEvent
<number
[]>
The event emitter for scroll
Source
onZoom
onZoom:
TypedEvent
<number
>
The event emitter for zoom
Source
options
options:
EditorOptions
The editor options
Source
parent
parent:
HTMLElement
The parent element
Source
platform
platform:
string
The platform
Source
plugins
plugins:
Record
<string
,Plugin
>
The plugins
Source
selection
selection:
SelectionManager
The selection manager
Source
store
store:
Store
The store object
Source
transform
transform:
Transform
The transform object
Source
Methods
activateDefaultHandler()
activateDefaultHandler():
void
Activate the default handler
Returns
void
Source
activateHandler()
activateHandler(
id
):void
Activate a handler by id
Parameters
• id: string
Returns
void
Source
drawSelection()
drawSelection():
void
Draw selection
Returns
void
Source
fit()
fit():
void
Fit the editor size to the holder element
Returns
void
Source
fitToScreen()
fitToScreen(
scaleAdjust
,maxScale
):void
Fit doc to screen and move to center
Parameters
• scaleAdjust: number
= 1
• maxScale: number
= 1
Returns
void
Source
focus()
focus():
void
Set focus on this editor
Returns
void
Source
getActiveHandler()
getActiveHandler():
null
|Handler
Get the active handler
Returns
null
| Handler
Source
getActiveHandlerLock()
getActiveHandlerLock():
boolean
Get active handler lock
Returns
boolean
Source
getBoundingRect()
getBoundingRect():
number
[][]
Get bounding rect in GCS
Returns
number
[][]
Source
getCenter()
getCenter():
number
[]
Get screen center point in GCS
Returns
number
[]
Source
getCurrentPage()
getCurrentPage():
null
|Page
Get current page
Returns
null
| Page
Source
getCursor()
getCursor():
string
Get cursor
Returns
string
Source
getDarkMode()
getDarkMode():
boolean
Get dark mode
Returns
boolean
Source
getDoc()
getDoc():
Doc
Get the document
Returns
Source
getEnabled()
getEnabled():
boolean
Get enabled state
Returns
boolean
Source
getGridSize()
getGridSize():
number
[]
Get grid size
Returns
number
[]
Source
getOrigin()
getOrigin():
number
[]
Get origin point in CCS
Returns
number
[]
Source
getPages()
getPages():
Page
[]
Get pages
Returns
Page
[]
Source
getPlugin()
getPlugin(
id
):null
|Plugin
Get a plugin by id
Parameters
• id: string
Returns
null
| Plugin
Source
getScale()
getScale():
number
Get scale
Returns
number
Source
getShowGrid()
getShowGrid():
boolean
Get show grid state
Returns
boolean
Source
getSize()
getSize():
number
[]
Return the size of canvas element in CCS
Returns
number
[]
Source
getSnapToGrid()
getSnapToGrid():
boolean
Get snap to grid
Returns
boolean
Source
getSnapToObjects()
getSnapToObjects():
boolean
Get snap to object
Returns
boolean
Source
loadFromJSON()
loadFromJSON(
json
):void
Load from JSON
Parameters
• json: any
Returns
void
Source
moveOrigin()
moveOrigin(
dx
,dy
):void
Move origin point
Parameters
• dx: number
• dy: number
Returns
void
Source
newDoc()
newDoc():
Doc
Create a new document
Returns
Source
repaint()
repaint(
drawSelection
):void
Repaint diagram
Parameters
• drawSelection: boolean
= true
Returns
void
Source
saveToJSON()
saveToJSON():
any
Save to JSON
Returns
any
Source
scroll()
scroll(
dx
,dy
):void
Scroll screen
Parameters
• dx: number
• dy: number
Returns
void
Source
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
scrollToCenter()
scrollToCenter():
void
Scroll to center of the shapes
Returns
void
Source
setActiveHandlerLock()
setActiveHandlerLock(
lock
):void
Set active handler lock
Parameters
• lock: boolean
Returns
void
Source
setCurrentPage()
setCurrentPage(
page
):void
Set current page
Parameters
• page: Page
Returns
void
Source
setCursor()
setCursor(
cursor
,angle
):void
Set cursor
Parameters
• cursor: string
• angle: number
= 0
Returns
void
Source
setDarkMode()
setDarkMode(
dark
):void
Set dark mode
Parameters
• dark: boolean
Returns
void
Source
setDoc()
setDoc(
doc
):void
Set the document
Parameters
• doc: Doc
Returns
void
Source
setEnabled()
setEnabled(
enabled
):void
Set enabled state
Parameters
• enabled: boolean
Returns
void
Source
setGridSize()
setGridSize(
gridSize
):void
Set grid size
Parameters
• gridSize: number
[]
Returns
void
Source
setOrigin()
setOrigin(
x
,y
):void
Set origin point
Parameters
• x: number
• y: number
Returns
void
Source
setScale()
setScale(
scale
):void
Set scale
Parameters
• scale: number
Returns
void
Source
setShowGrid()
setShowGrid(
show
):void
Set show grid or not
Parameters
• show: boolean
Returns
void
Source
setSize()
setSize(
width
,height
):void
Set canvas element size
Parameters
• width: number
• height: number
Returns
void
Source
setSnapToGrid()
setSnapToGrid(
value
):void
Set snap to grid
Parameters
• value: boolean
Returns
void
Source
setSnapToObjects()
setSnapToObjects(
value
):void
Set snap to object
Parameters
• value: boolean
Returns
void
Source
update()
update():
void
Update all shapes
Returns
void
Source
zoom()
zoom(
scale
):void
Set zoom scale while keeping the screen center
Parameters
• scale: number
= 1
Returns
void