getState
returns the reactive state object of Diagram Editor
object getState();
Example
// returns the current state of the editor
const state = $$("editor").getState();
Related samples
Details
The returned state object contains the following properties and methods:
{
gridStep: 20,
zoom: 20,
selected: {
id: 100
}
}
If the selected element is a link, the selected object stores the following data:
{
selected: {
id: 25,
link: true
},
//...
}
Properties
- gridStep (number) - defines a moving step for shapes being dragged (in pixels). 10 by default
- zoom (number) - defines the current zoom level. 1 by default
- selected (object) - stores object with ID and additional info (in case of a link) of the element being selected currently (either a block/shape or link).
Methods
- $observe (function) - a handler to listen to changes in the current state of the editor. It takes 2 parameters:
- prop (string) - a reactive property whose changes you want to listen to;
- handler (function) - a function to execute when changes are made. It takes a single argument:
- value (any) - the current value of the reactive property. The type of the value (string, array, etc.) depends on the reactive property being observed.
- $batch (function) - allows setting several properties at once. It takes a single parameter:
- props (object) - an object containing pairs of property names and values to set.
Back to top
Join Our Forum
We've retired comments here. Visit our forum for faster technical support,
connect with other developers, and share your feedback there.