JointJS+ changelog v3.7.0
Improve support for foreign objects in SVG​
This is the main change of this release. While previously HTML control elements had to be treated as a separate functional layer (HTML elements independent from the SVG diagram which had to be kept in sync behind the scenes), JointJS now supports embedding HTML directly in SVG via <foreignObject> elements.
To get started with foreign objects in JointJS, refer to our new Foreign Objects tutorial.
Details...
In order to enable this functionality, adjustments were made to every step along the way of working with JointJS diagrams - from parsing of JSON through diagram interaction to diagram export.
Most changes were done at the first step - parsing of SVG with <foreignObject> elements inside. Those include a fix to use lowercase for tagName of parsed HTML elements, fixes for textContent to contain HTML text nodes from all descendants and to keep those in correct order without creating empty textContent, and changes to JSON processing logic so that it can interpret string array items as HTML text nodes.
Changes done at the second step - interaction with <foreignObject> elements - include improved event handling of form control elements (which enables seamless user interaction), a new Paper option to enable default view actions, and the addition of a new special attribute props to support setting most common HTML form control properties programmatically.
Finally, changes to export logic enable <img> elements inside foreign objects, while a new option enables exporting HTML form control elements (<input>, <select>, <textarea>) with their current values.
Working with HTML form control foreign objects is illustrated in the new ROI demo.
Upgrade jQuery dependency (v3.6.4)​
Adds several minor fixes.
Rewrite AST Application using TypeScript​
Live Abstract Syntax Tree Demo
Improve zooming in Chatbot Application using pinch and pan Paper events​
In Chatbot Application, fix error occurring when using CommandManager in React​
Fixes an issue in the React versions of the app where triggering undo() immediately after using an Input component would throw an error.
Details...
This is because the onBlur() method of the Input component does not get triggered automatically in React when selecting a new element as it does in other environments. This causes CommandManager not to be notified that the undo/redo batch initiated by the Input component has ended, which leads to the undo() method throwing an error.
The issue was solved by defining a React useEffect on the Input component in order to call onBlur() when the component rerenders.
In KitchenSink Application, initiate Selection lasso also when user clicks on a cell while holding SHIFT key​
This change was enabled by the new preventDefaultInteraction() method of dia.CellView. By default, Selection lasso is only initiated when user clicks on a blank area of the Paper while holding SHIFT key.

Add DWDM (Dense Wavelength-Division Multiplexing) demo as an example of a network graphical view​

Add Flowchart demo​
Uses the new rightAngle router and the new straight connector. Also illustrates the new alignment options of the Paper transformToFitContent() method.
See CodePen.
Revamp FTA demo​
Uses a custom highlighter and the new straight connector. Also illustrates the new alignment options of the Paper transformToFitContent() method.
See CodePen.
Add ROI demo​
Illustrates working with foreign objects.
To get started with foreign objects in JointJS, refer to our new Foreign Objects tutorial.
Note: If you are viewing this page in Safari, you might notice some rendering bugs in this demo. Our Foreign Object tutorial has an overview of all caveats.
See CodePen.
dia.CommandManager - fix to prevent modifying provided undo/redo stack object in fromJSON()​
Addresses an issue where an undo/redo stack stack provided to CommandManager via the fromJSON() function was affected by subsequent changes in the undo/redo stack (caused by calling undo(), redo() or making a change in the diagram).
The input object is now independent. If you need the current state of the CommandManager undo/redo stack after some changes, you should export the diagram again via the toJSON() method.
const commandManager = new joint.dia.CommandManager({ graph: graph });
// ...
const backupUndoRedoStack = commandManager.toJSON(); // save current undo/redo stack
// ...
commandManager.fromJSON(backupUndoRedoStack); // apply saved undo/redo stack
commandManager.undo();
// Assert: `backupUndoRedoStack` did not change
format.Raster, format.SVG - add fillFormControls option to export HTML form control elements (<input>, <select>, <textarea>) with their current values​
This feature is related to the improved support for foreign objects - form control elements can be part of the export if they are inserted via an SVG <foreignObject> element. To get started with foreign objects in JointJS, refer to our new Foreign Objects tutorial.
A new option fillFormControls is added to allow exporting HTML form control elements within SVG (<input>, <select>, <textarea>) with their current values.
Details...
The function works as follows: For each form control element, the current value (i.e. the value of the property) is taken and set as the default value (i.e. the value of the attribute), and this SVG is then exported as a raster format (toPNG() / toJPEG() / toDataURL() / toCanvas() on Paper). The option is true by default. You can export to SVG analogously by using the toSVG() method on Paper.
Note: When exporting to SVG (toSVG() on Paper), keep in mind that the exported data is not entirely standalone. In order for the contained HTML foreign objects to be rendered as expected, the file must be opened in an environment which can understand the HTML namespace (for example, a web browser).
The option is illustrated in the following demo:
See CodePen.
format.Raster, format.SVG - fix to handle image URL conversion errors​
Previously, any image URL conversion errors encountered during export (toSVG() / toPNG() / toJPEG() / toDataURL() / toCanvas() on Paper) caused the export to fail completely without calling the provided callback function. For instance, an error would be thrown when an image's source attribute (xlink:href / href / src) links to an external resource which cannot be accessed.
This issue has now been fixed. If an error is encountered during export, the export proceeds without the affected image(s), and the encountered error is saved. The error object is passed to the export function callback as the second parameter, which allows you to introduce additional logic to resolve the encountered error.
Here is some example code taken from the handler of the "Export SVG" button in our KitchenSink application:
paper.hideTools().toSVG(
(svg, error) => {
if (error) {
console.error(error.message);
}
new joint.ui.Lightbox({
image: 'data:image/svg+xml,' + encodeURIComponent(svg),
downloadable: true,
fileName: 'JointJS',
}).open();
paper.showTools();
},
{
preserveDimensions: true,
convertImagesToDataUris: true,
useComputedStyles: false,
// ...
}
);