Release 6.2.5 of the Toolkit is now available. This release contains a bunch of useful new things, and sees an update to our most popular demonstrations to turn them into fully-fledged starter applications from which you can build your own apps quicker than ever.
Many things. The full changelog is available here. In this post we're going to discuss all of the changes from 6.2.0 through to 6.2.5.
A shape library is an object that can assist in rendering SVG shapes into your nodes. One of our most popular demonstrations for a long time has been the Flowchart Builder, in which nodes are drawn using SVG as various shapes. Prior to release 6.2.0, though, these shapes were "hand-drawn" in the node templates and adding a new shape involved creating the SVG template and mapping it explicitly inside your app.
The Flowchart Builder starter app now uses a shape library to render the SVG in its nodes:
The Toolkit ships a default set of shapes that you can use -
FLOWCHART_SHAPES, but it is straightforward to create your own shape sets. It would be easy, for example, to convert the Flowchart Builder into an Entity Relationship Diagram builder simply by swapping out the shapes used by the shape library. We may even make that the topic of a future blog post.
Shape Library Palettes
We've created a component called
ShapeLibraryPalette that integrates tightly with a shape library to provide a palette of shapes that a user can drag on to your canvas. You can see this in action in the Flowchart Builder starter app linked above. The shape library palette takes the contents of some shape library (in the screenshot below, that's the
FLOWCHART_SHAPES that ship with the Toolkit) and renders each shape, then instantiates a drop manager to allow users to drag new shapes onto a surface.
Our Angular, React, Vue2 and Vue3 integrations all contain support for shape libraries and shape library palettes. Because of the way Svelte operates we haven't added any specific support for these concepts to the Svelte integration - it's straightforward to hook into these things the way you would in a 'vanilla' app. But if you're a user of our Svelte integration and you've got any suggestions we'd be happy to hear from you.
Read the documentation about shape libraries and shape library palettes here
An inspector is an object that can assist you in implementing implementing form-based editors for objects in your dataset. For example, this is a node inspector from the Flowchart Builder starter app:
Inspectors integrate tightly with a
Surface component, and have been written in a layered way that makes them agnostic of the specifics of the form they are managing: it is the user's responsibility to render the HTML they wish to use for a given inspector, so you are free to use anything you like, and the inspector will hook into your UI via a custom attribute you write in your code.
Inspectors can manage single objects, as shown above, and they can also manage multiple objects:
Support for inspectors was added to the Angular, Vue2, Vue and React integrations.
In the FlowchartBuilder's edge inspector a user can select an edge type by clicking on it:
We make use of an EdgeTypePicker to do this. This is a component that we created for the starter apps but which seemed like something that could be useful for licensees of the Toolkit, so we've pulled it into the
@jsplumbtoolkit/browser-ui package now. There's a wrapper available for Angular, React, Vue2 and Vue3.
Read the documentation about inspectors and edge type pickers here.
The concept of 'mode' was added to selections: you can specify that a given selection may only contain one type of object (eg nodes, groups or edges), or that it can contain a mix. For more information see the documentation.
We use this concept in the Flowchart Builder starter app: a user can edit one or more nodes in an inspector, or one or more edges, but not a mixture of nodes or edges. Setting
SelectionModes.isolated on the underlying Toolkit's selection means that the Toolkit will not support a selection of objects of different types.
Drag and drop updates
Several improvements were made to the
SurfaceDropManager. The parent class
DropManageralready supported this but it was not exposed on the
SurfaceDropManagerprior to 6.2.0.
dragSizeparameter can be supplied to the drop manager, to set the size of nodes/groups that are being dragged.
An object being dragged onto a canvas will be automatically scaled so that it matches the current zoom of the canvas. This makes a big difference to the usability of the drag/drop, as users can see while dragging an element how it will fit into the canvas once it is dropped. This behaviour can be switched off if desired.
When dragging a new edge, the Surface element will now honour a
typespecifier returned from a
beforeStartConnectinterceptor. In previous versions the
typewould only be honoured once a new connection had been established. For more information see here.
Support for a
modelEventsobject has been added to the Surface's constructor. Instead of having to register model events after the fact you can now supply them with your render parameters.
You may have seen this component in our various starter app/feature demonstrations:
We now ship this as a component that you can include in your apps. Wrappers for Angular, React, Vue2 and Vue3 are available.
Edge editors now snap anchor placeholders to the closest anchor when the user is relocating an anchor. Previously the placeholder would not be snapped until the use released the mouse button. The previous behaviour can be reinstated by setting
snapToAnchors:falsein the options you pass to the
Support for 'fragments' was added to custom tags in the default template engine. This is more of an internal feature, but could be leveraged by advanced users of the Toolkit. See documentation on templating for further information.
Label overlays now have a
jtk-label-overlayclass added to their element.
The default CSS stylesheet was updated with a
.jtk-label-overlay:empty. For label overlays on which the label's value is currently an empty string, this will hide the overlay.
The CSS for the "controls" component that we ship along with each of the library integrations was copied out from
jsplumbtoolkit-controls.css, and the various selectors were updated to be more specific.
Several enhancements were made to the drawing tools plugin, specifically with regard to honouring a grid that is applied to the associated surface.
- Fixed issue with anchor placeholder not being centered correctly when editing an edge.
- Fixed issue with
Hierarchylayout where certain combinations of unattached roots and multiple parents could cause the layout to fail, due to a cache not being cleared.
- Updates to the default template engine to ensure that elements written by custom tags are correctly updated when their vertex is updated.
- Fixed issue in connector editor package where re-editing an edge that it was already editing would cause any extra overlays to be removed.
- Fixed issue in bezier connector editor where control points were being dragged at twice the rate the mouse was moving.
Get in touch!
If you'd like to discuss any of the ideas/concepts in this article we'd love to hear from you - drop us a line at firstname.lastname@example.org.
Not a user of the jsPlumb Toolkit but thinking of checking it out? Head over to https://jsplumbtoolkit.com/trial. It's a good time to get started with jsPlumb.