Creates the new instance of the editor.
Protected
_manipulationProtected
_manipulationReadonly
languageEnables multi-language support.
Readonly
settingsEditor settings.
Control available colors, font families, etc. through this property.
Steps zoom in/out buttons go through.
Returns true if redo operation can be performed (redo stack is not empty).
Returns true if undo operation can be performed (undo stack is not empty).
Returns the current stencil editor set.
Sets the current stencil editor set.
Note that all the current edits are lost when new stencil set is set.
Returns the current zoom level.
Sets the current zoom level.
Optional
options: boolean | AddEventListenerOptionsOptional
options: boolean | AddEventListenerOptionsCreates a new stencil of the specified type
stencil type as either type or its string representation
Removes the supplied stencil editor from selection. If no stencil editor is supplied, all selected stencils are unselected.
Optional
stencilEditor: StencilBaseEditorstencil editor to select.
Returns the diagram configration state object. Use it to store the state in databases, files, etc.
diagram configuration as a serializable object.
Hides toolbar buttons for provided commands.
Available buttons/commands:
select
, delete
, save
, undo
, redo
, add
, connect
, document-setup
,
zoomout
, zoomin
, zoomreset
, properties
.
This method can be used to both remove buttons to preserve space and simplify
user experience by removing unnecessary functions and to remove access to
certain functions. For example, you may constantly auto-save the diagram in your
code so the save
button isn't necessary and misleading.
The code below hides zoomreset
and redo
buttons.
editor.hideToolbarButtons('zoomreset', 'redo');
1.1.0
Rest
...commands: string[]list of commands
Optional
options: boolean | EventListenerOptionsOptional
options: boolean | EventListenerOptionsUse this method to reneder the current diagram as a static raster image.
Optional
width: numbertarget width
Optional
height: numbertarget height
image type (image/png, image/jpeg, etc.)
Optional
quality: numberrender quality for lossy codecs (1=100% for jpeg).
rendered image as a data URL.
Restores (loads) previous saved (or manually created) diagram.
diagram configuration object.
Selects a stencil. If there already is a selected stencil then the supplied stencil is added to the selection.
stencil editor to select.
Sets the currently active stencil editor. If multiple stencils are selected then there's no "current" stencil. Passing nothing/undefined unsets the current stencil.
Optional
stencilEditor: StencilBaseEditorstencil editor to make active.
Generated using TypeDoc
DiagramEditor is the main diagram editing web component of the MJS Diagram library.
You add an instance of DiagramEditor to your page to enable diagram editing.
You can add it in your HTML markup as a custom element with something like this:
Or you can add it in code.
One important thing to set when the component loads is the StencilEditorSet you want to use.
Here we add a Flowchart stencil set:
You may want to add a previously saved state via the restoreState.
Finally, you most probably want to handle the saveclick event to store the editing results:
See
Check out MJS Diagram docs and demos for more details.