Release 7.0.0
We are pleased to announce the release of version 7.0.0 of JsPlumb Toolkit, in which we have introduced three major new capabilities:
-
Vertex avoidance JsPlumb can now automatically route edges around nodes and groups. Various options for the routing strategy are supported, and groups are handled seamlessly.
-
Magnetizer trackback A new mode for the magnetizer in which elements that have been moved out of the way of some element that is being dragged will attempt to snap back to their original positions - like a crowd parting for you on your way back from the bar.
-
Edge snapping When dragging edges, you can instruct JsPlumb to snap to nearby drag targets.
We've also made a host of small updates to improve the usability of JsPlumb's API, documentation and starter apps. This is a big release, so get comfortable!
New Functionality
Vertex avoidance
In JsPlumb 7.0.0 you can configure edges to avoid vertices - try dragging node 1 or 2 around in this canvas and see how the connector avoids node 3.
It isn't always possible for an edge to avoid vertices - if some element is overlapping some other element, the vertex avoidance will switch off for the element that is being overlapped.
Groups
Vertex avoidance works seamlessly with groups:
Further reading
-
Vertex avoidance is covered in detail in our documentation at https://docs.jsplumbtoolkit.com/toolkit/7.x/lib/edges/vertex-avoidance.
-
See vertex avoidance in action in our Flowchart Builder starter app or Active Filtering demonstration.
Magnetizer Trackback
When running the magnetizer in constant mode, elements are pushed out of the way of the element that is being dragged. This is very useful and cool, but once an element has been pushed from its original location it doesn't go back, and so its easy to accidentally scatter your elements all over the canvas. Enter trackback mode: when this is switched on, the magnetizer attempts to revert any moved elements back to their location at the start of an element drag. This is super slick and we're pretty pleased with it.
Try dragging node 1 through the gap between nodes 2 and 3 in this canvas - they'll move out of the way as node 1 moves through, and then spring back:
Further reading
-
Find our more about magnetizer trackback in our documentation at https://docs.jsplumbtoolkit.com/toolkit/7.x/lib/magnetizer#trackback
-
See magnetizer trackback in action in our Flowchart Builder starter app
Edge Snapping
You can instruct JsPlumb to snap edges to the nearest drag target that lies within some threshold - try dragging from the blue circles in this canvas:
This is the simplest example, in which we've switched on edge snap in the render options:
{
edgeSnap:{
enabled:true
}
}
There are a number of ways you can configure edge snapping for more advanced usage, including setting the snap threshold and specifying whether to snap to the edge of some element or its center, as well as only enabling snap to particular targets. See the link below for details.
Further reading
- Edge snapping is discussed at length in our documentation at https://docs.jsplumbtoolkit.com/toolkit/7.x/lib/edges/dragging-edges#snapping-to-drag-targets
Simplified dataGenerator
When using the SurfaceDropManager (or one of its library wrappers) two updates have been made to simplify matters:
-
It is no longer necessary to provide a
dataGeneratorto create a payload for items a user is dragging. By default, JsPlumb will prepare a payload derived from anydata-jtk-***attribute found on the element. For instance, if you writedata-jtk-typeanddata-jtk-labelattributes on the elements your users can drag, the initial payload will be a JS object with matchingtypeandlabelvalues. -
JsPlumb will use a default
selectorofdata-jtk-type, meaning you do not need to provide one.
These changes have been applied also to the Angular, React, Svelte and Vue integrations.
Connector updates
We've made a number of changes to our connectors, the most notable being that the Straight and Segmented connectors were folded into one
Refactoring/renames
- The
Segmentedconnector was renamed toStraight(this is also listed in the breaking changes section below). We made this change because aSegmentedconnector that had a single segment behaved identically to aStraightconnector; we have in fact really just enhanced ourStraightconnector to support multiple segments.
Path constraint
- The
Straightconnector now supports an optionalconstrainconfiguration option, with possible values "orthogonal", "diagonal" and "none", with "none" being the default. Whenconstrain:"orthogonal"is set, theStraightconnector behaves the same as anOrthogonalconnector. Whenconstrain:diagonalis set the connector chooses horizontal/vertical or diagonal paths.
Orthogonal connector
- Internally, the
Orthogonalconnector is now just an alias toStraightwithconstrain:orthogonalset. But you do not need to worry about that - if your app uses anOrthogonalconnector you don't need to make any changes.
Bezier connector
- Support for
gapwas added toCubicBezierConnector
Default edge outlines
You can now instruct JsPlumb to paint an outline of some specific size by default on all of your edges, using two new default keys:
paintConnectorOutline(default valuefalse)connectorOutlineWidth(default value10)
When paintConnectorOutline is set to true, a 10 pixel transparent path will be drawn behind each edge, which makes it much easier for your users to interact with your edges.
Angular updates
-
Added
ExportControlsComponentto the Angular integration. This component can export an SVG based UI to SVG, PNG or JPG. -
Added support for
onVertexAdded,dragSize,canvasDropFilterandcanvasSelectorinput to thejsplumb-surface-dropcomponent in the Angular integration.
DrawingTools plugin
- The
DrawingToolsplugin was updated to support resizing elements by dragging their border. Borders can be visible or transparent.
React updates
- Added support for
onVertexAdded,dragSize,canvasDropFilterandcanvasSelectorinput to thePaletteComponentin the React integration.
Inspectors
- Added support for
showCloseButtonoption on Inspectors. When clicked, the inspector is made inactive and JsPlumb's selection is cleared
Updates/Fixes
Miscellaneous
-
Fix applied to orthogonal connector to fix occasional paint issue when removing short segments.
-
An improvement was made to the continuous anchor location selection algorithm to reduce flicker.
-
The drop manager was updated to fix an issue whereby drop on edge would not occur if the element to drop was hovering over some vertex, even if dropping on the vertex was not permitted.
-
The
SurfaceRenderOptionsinterface was updated to useBrowserJsPlumbDefaultsinstead ofJsPlumbDefaultsfor the optionaldefaultsvalue. -
Internal refactoring of
OrthogonalandStraightconnectors to improve reuse between the two. -
AngularViewOptionsinterface updated to fix missing group inheritance. When defining groups in your Angular view it was previously necessary to cast the view toanyto use group flags. -
Internally, the controls component uses the
BrowserElementinterface instead ofHTMLElement. This makes it easier to integrate when using methods likequerySelectorand Typescript. -
Updated
SVGExporter/ImageExporterto fix error thrown when there is noShapeLibraryregistered and the default SVG renderer would be used. -
Fixed an issue with Angular overlay components - our previous way of instantiating them no longer works with Angular 18. We've updated the code to support a different way of instantiating them (which is backwards compatible with Angular 17 and 16).
-
Updated the
DrawingToolsplugin to automatically register appropriate drag filters on the underlying surface. Previously it was the user's responsibility to do this via thedragOptionsof the surface, and failure to set this up would result in a transaction error at the start of a resize. -
The drop manager was updated to provide a nicer user experience when dragging a node/group from the palette - the element being dragged is centered around the mouse/touch event location now.
CSS Updates
-
We now ship the source
scssfiles that we use to createjsplumbtoolkit.cssin the/scssdirectory of the@jsplumbtoolkit/browser-uipackage. -
A few useful updates were made to the
jsplumbtoolkit.cssdefault stylesheet:- When an edge is dragging, the canvas cursor is set to
default, where previously it would bedrag. This makes for a nicer visual cue for users. - Nodes and groups are assigned the
movecursor by default - When
elementsDraggable:falseis set on a surface, nodes and groups are assigned thedefaultcursor. - When an individual node/group is marked as not draggable, it is assigned the
defaultcursor.
- When an edge is dragging, the canvas cursor is set to
Demo updates
- Updated various demonstrations to give them a more fresh look and feel
- Added an Inspector to our Angular Gantt chart
- Updated Flowchart Builder to use vertex avoidance for edges instead of editable edge paths, and magnetizer trackback.
API docs updates
We spent some time going through the Typedoc documentation prior to releasing version 7.0.0, and we've updated our API docs with categories and groups, to gather together related concepts and generally make it easier to get around. Finding what you're looking for is now more straightforward, but with this new structure it's also possible just to browse around a little and discover things you may not have known about.
Breaking Changes
-
Support for the
ORTHOGONAL_CONNECTOR_RECALC_STRATEGY_LEGACYrecalculation strategy was removed, having been previously deprecated.ORTHOGONAL_CONNECTOR_RECALC_STRATEGY_MODERNandOrthogonalRecalcStrategywere also both removed, being no longer necessary. -
The
SegmentedConnectorhas been renamed toStraightConnector. Wherever your app usesSegmentedConnector.typeyou'll need to update the code. Note, though, that this newStraightConnectoris the default connector, so if you currently useSegmentedConnectorwithout any config options you can simply remove that code.
We do not expect any change in functionality for apps that either currently use the default connector or that specify Straight as the connector type, as the new Straight connector is a drop-in replacement for the original Straight connector, when it has only a single segment.
-
The original
StraightConnectorhas been renamed toLegacyStraightConnector. -
marginwas removed fromStateMachineandBezierconnectors. Use the pre-existinggapoption instead. -
The CSS classes added to groups that are a drag target or the current hover target for other groups or nodes being dragged have changed from
jtk-drag-activeandjtk-drag-hovertojtk-vertex-drag-activeandjtk-vertex-drag-hover. This is to distinguish them from the active/hover classes used when dragging edges. -
The
initializeSegmentedConnectorEditorsmethod was renamed toinitializeStraightConnectorEditors -
The CSS classes related to the previous segmented connector editor have been renamed, eg. where we'd have
.jtk-segmented-segment-delete, for example, we now have.jtk-straight-segment-delete. -
The contents of the
jsplumbtoolkit-connector-editors.cssstylesheet was folded in tojsplumbtoolkit.cssandjsplumbtoolkit-connector-editors.csswas removed. -
The contents of the
jsplumbtoolkit-edge-type-picker.cssstylesheet was folded in tojsplumbtoolkit.cssandjsplumbtoolkit-edge-type-picker.csswas removed. -
The contents of the
jsplumbtoolkit-dialogs.cssstylesheet was folded in tojsplumbtoolkit.cssandjsplumbtoolkit-dialogs.csswas removed. -
The contents of the
jsplumbtoolkit-browser-ui-plugin-background.cssstylesheet was folded in tojsplumbtoolkit.cssandjsplumbtoolkit-browser-ui-plugin-background.csswas removed. -
The contents of the
jsplumbtoolkit-controls.cssstylesheet was folded in tojsplumbtoolkit.cssandjsplumbtoolkit-controls.csswas removed. -
The
ExportControlsComponentconstructor has changed - the third argument is now options instead of a ShapeLibrary. if you need to pass in a shape library you can do it inside the options, but it should not be necessary as the component gets the shape library from the surface you pass in.
Changelog
You can find the full changelog here - https://docs.jsplumbtoolkit.com/toolkit/7.x/lib/changelog
Start a free trial
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 hello@jsplumbtoolkit.com.