Skip to content

Commit

Permalink
Release v3.4.1 (#1505)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumilingus authored Aug 18, 2021
1 parent 1c704bd commit 16c6ec8
Show file tree
Hide file tree
Showing 36 changed files with 249 additions and 125 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
18-08-2021 (v3.4.1)
* dia.ElementView - prevent unnecessary re-parenting after invalid un-embedding
* dia.CellView - support calc() in `transform` attribute
* dia.CellView - allow `presentationAttributes` and `initFlag` to be defined as a function
* Fix minor TS issues
* Fix minor Docs issues

13-07-2021 (v3.4.0)
* Add VueJS 3.0 Demo
* Add Tree-Shake Demo
Expand Down
2 changes: 1 addition & 1 deletion dist/geometry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JointJS v3.4.0 (2021-07-13) - JavaScript diagramming library
/*! JointJS v3.4.1 (2021-08-18) - JavaScript diagramming library
This Source Code Form is subject to the terms of the Mozilla Public
Expand Down
2 changes: 1 addition & 1 deletion dist/geometry.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/joint.core.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 67 additions & 29 deletions dist/joint.core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JointJS v3.4.0 (2021-07-13) - JavaScript diagramming library
/*! JointJS v3.4.1 (2021-08-18) - JavaScript diagramming library


This Source Code Form is subject to the terms of the Mozilla Public
Expand Down Expand Up @@ -12208,6 +12208,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Support `calc()` with the following SVG attributes
[
'transform', // g
'd', // path
'points', // polyline / polygon
'width', 'height', // rect / image
Expand Down Expand Up @@ -15523,7 +15524,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
var attributes = {};
var shift = 0;
var i, n, label;
var presentationAttributes = this.presentationAttributes;
var presentationAttributes = result(this, 'presentationAttributes');
for (var attribute in presentationAttributes) {
if (!presentationAttributes.hasOwnProperty(attribute)) { continue; }
var labels = presentationAttributes[attribute];
Expand All @@ -15537,7 +15538,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
attributes[attribute] |= flag;
}
}
var initFlag = this.initFlag;
var initFlag = result(this, 'initFlag');
if (!Array.isArray(initFlag)) { initFlag = [initFlag]; }
for (i = 0, n = initFlag.length; i < n; i++) {
label = initFlag[i];
Expand Down Expand Up @@ -16593,7 +16594,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
Highlighting: HighlightingTypes,

addPresentationAttributes: function(presentationAttributes) {
return merge({}, this.prototype.presentationAttributes, presentationAttributes, function(a, b) {
return merge({}, result(this.prototype, 'presentationAttributes'), presentationAttributes, function(a, b) {
if (!a || !b) { return; }
if (typeof a === 'string') { a = [a]; }
if (typeof b === 'string') { b = [b]; }
Expand Down Expand Up @@ -16934,39 +16935,49 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
// -----------------------

prepareEmbedding: function(data) {
if ( data === void 0 ) data = {};

data || (data = {});

var model = data.model || this.model;
var element = data.model || this.model;
var paper = data.paper || this.paper;
var graph = paper.model;

model.startBatch('to-front');
var initialZIndices = data.initialZIndices = {};
var embeddedCells = element.getEmbeddedCells({ deep: true });
var connectedLinks = graph.getConnectedLinks(element, { deep: true, includeEnclosed: true });

// Note: an embedded cell can be a connect link, but it's fine
// to iterate over the cell twice.
[
element ].concat( embeddedCells,
connectedLinks
).forEach(function (cell) { return initialZIndices[cell.id] = cell.attributes.z; });

element.startBatch('to-front');

// Bring the model to the front with all his embeds.
model.toFront({ deep: true, ui: true });
element.toFront({ deep: true, ui: true });

// Note that at this point cells in the collection are not sorted by z index (it's running in the batch, see
// the dia.Graph._sortOnChangeZ), so we can't assume that the last cell in the collection has the highest z.
var maxZ = graph.getElements().reduce(function(max, cell) {
return Math.max(max, cell.attributes.z || 0);
}, 0);
var maxZ = graph.getElements().reduce(function (max, cell) { return Math.max(max, cell.attributes.z || 0); }, 0);

// Move to front also all the inbound and outbound links that are connected
// to any of the element descendant. If we bring to front only embedded elements,
// links connected to them would stay in the background.
var connectedLinks = graph.getConnectedLinks(model, { deep: true, includeEnclosed: true });
connectedLinks.forEach(function(link) {
if (link.attributes.z <= maxZ) { link.set('z', maxZ + 1, { ui: true }); }
connectedLinks.forEach(function (link) {
if (link.attributes.z <= maxZ) {
link.set('z', maxZ + 1, { ui: true });
}
});

model.stopBatch('to-front');
element.stopBatch('to-front');

// Before we start looking for suitable parent we remove the current one.
var parentId = model.parent();
var parentId = element.parent();
if (parentId) {
var parent = graph.getCell(parentId);
parent.unembed(model, { ui: true });
parent.unembed(element, { ui: true });
data.initialParentId = parentId;
} else {
data.initialParentId = null;
Expand Down Expand Up @@ -17082,6 +17093,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
!validateUnembedding.call(paper, this)
) {
this._disallowUnembed(data);
return;
}
}

Expand All @@ -17095,6 +17107,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
var whenNotAllowed = data.whenNotAllowed; if ( whenNotAllowed === void 0 ) whenNotAllowed = 'revert';
var element = model || this.model;
var paper = data.paper || this.paper;
var graph = paper.model;
switch (whenNotAllowed) {
case 'remove': {
element.remove({ ui: true });
Expand All @@ -17103,12 +17116,24 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
case 'revert': {
var initialParentId = data.initialParentId;
var initialPosition = data.initialPosition;
var initialZIndices = data.initialZIndices;
// Revert the element's position (and the position of its embedded cells if any)
if (initialPosition) {
var x = initialPosition.x;
var y = initialPosition.y;
element.position(x, y, { ui: true });
element.position(x, y, { deep: true, ui: true });
}
// Revert all the z-indices changed during the embedding
if (initialZIndices) {
Object.keys(initialZIndices).forEach(function (id) {
var cell = graph.getCell(id);
if (cell) {
cell.set('z', initialZIndices[id], { ui: true });
}
});
}
var parent = paper.model.getCell(initialParentId);
// Revert the original parent
var parent = graph.getCell(initialParentId);
if (parent) {
parent.embed(element, { ui: true });
}
Expand Down Expand Up @@ -20874,6 +20899,11 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
};
},

// A function that determines whether a given point is an obstacle or not.
// If used, the `padding`, `excludeEnds`and `excludeTypes` options are ignored.
// (point: dia.Point) => boolean;
isPointObstacle: null,

// a router to use when the manhattan router fails
// (one of the partial routes returns null)
fallbackRouter: function(vertices, opt, linkView) {
Expand Down Expand Up @@ -21340,7 +21370,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.

// finds the route between two points/rectangles (`from`, `to`) implementing A* algorithm
// rectangles get rect points assigned by getRectPoints()
function findRoute(from, to, map, opt) {
function findRoute(from, to, isPointObstacle, opt) {

var precision = opt.precision;

Expand Down Expand Up @@ -21388,8 +21418,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
}

// take into account only accessible rect points (those not under obstacles)
startPoints = startPoints.filter(map.isPointAccessible, map);
endPoints = endPoints.filter(map.isPointAccessible, map);
startPoints = startPoints.filter(function (p) { return !isPointObstacle(p); });
endPoints = endPoints.filter(function (p) { return !isPointObstacle(p); });

// Check that there is an accessible route point on both sides.
// Otherwise, use fallbackRoute().
Expand Down Expand Up @@ -21456,8 +21486,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
// check if we reached any endpoint
var samePoints = startPoints.length === endPoints.length;
if (samePoints) {
for (var i = 0; i < startPoints.length; i++) {
if (!startPoints[i].equals(endPoints[i])) {
for (var j = 0; j < startPoints.length; j++) {
if (!startPoints[j].equals(endPoints[j])) {
samePoints = false;
break;
}
Expand All @@ -21484,7 +21514,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
var neighborKey = getKey(neighborPoint);

// Closed points from the openSet were already evaluated.
if (openSet.isClose(neighborKey) || !map.isPointAccessible(neighborPoint)) { continue; }
if (openSet.isClose(neighborKey) || isPointObstacle(neighborPoint)) { continue; }

// We can only enter end points at an acceptable angle.
if (endPointsKeys.indexOf(neighborKey) >= 0) { // neighbor is an end point
Expand Down Expand Up @@ -21568,7 +21598,15 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
//var targetAnchor = getTargetAnchor(linkView, opt);

// pathfinding
var map = (new ObstacleMap(opt)).build(linkView.paper.model, linkView.model);
var isPointObstacle;
if (typeof opt.isPointObstacle === 'function') {
isPointObstacle = opt.isPointObstacle;
} else {
var map = new ObstacleMap(opt);
map.build(linkView.paper.model, linkView.model);
isPointObstacle = function (point) { return !map.isPointAccessible(point); };
}

var oldVertices = toArray(vertices).map(Point);
var newVertices = [];
var tailPoint = sourceAnchor; // the origin of first route's grid, does not need snapping
Expand Down Expand Up @@ -21605,7 +21643,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
}

// if partial route has not been calculated yet use the main routing method to find one
partialRoute = partialRoute || findRoute.call(linkView, from, to, map, opt);
partialRoute = partialRoute || findRoute.call(linkView, from, to, isPointObstacle, opt);

if (partialRoute === null) { // the partial route cannot be found
return opt.fallbackRouter(vertices, opt, linkView);
Expand Down Expand Up @@ -26944,7 +26982,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
} else {
view = views[cell.id] = this.createViewForModel(cell);
view.paper = this;
flag = this.registerUnmountedView(view) | view.getFlag(view.initFlag);
flag = this.registerUnmountedView(view) | view.getFlag(result(view, 'initFlag'));
}
this.requestViewUpdate(view, flag, view.UPDATE_PRIORITY, opt);
return view;
Expand Down Expand Up @@ -29728,7 +29766,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
Boundary: Boundary
});

var version = "3.4.0";
var version = "3.4.1";

var Vectorizer = V;
var layout = { PortLabel: PortLabel, Port: Port };
Expand Down
2 changes: 1 addition & 1 deletion dist/joint.core.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/joint.core.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/joint.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions dist/joint.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JointJS v3.4.0 (2021-07-13) - JavaScript diagramming library
/*! JointJS v3.4.1 (2021-08-18) - JavaScript diagramming library
This Source Code Form is subject to the terms of the Mozilla Public
Expand Down Expand Up @@ -1100,7 +1100,7 @@ export namespace dia {
tagName: string;
selector?: string;
groupSelector?: string;
namespaceUri?: string;
namespaceURI?: string;
className?: string;
attributes?: attributes.NativeSVGAttributes;
style?: { [key: string]: any };
Expand Down Expand Up @@ -1884,6 +1884,8 @@ export namespace dia {
class LinkView extends CellViewGeneric<Link> {

options: LinkView.Options;
sourceAnchor: g.Point;
targetAnchor: g.Point;

sendToken(token: SVGElement, duration?: number, callback?: () => void): void;
sendToken(token: SVGElement, opt?: { duration?: number, direction?: string; connection?: string }, callback?: () => void): void;
Expand Down Expand Up @@ -2541,9 +2543,9 @@ export namespace dia {

type NodeSelector = string | SVGElement | NodeSelectorJSON;

type Options = {
interface Options extends mvc.ViewOptions<undefined> {
layer?: dia.Paper.Layers | string | null;
};
}
}

class HighlighterView<Options = HighlighterView.Options> extends mvc.View<undefined> {
Expand Down Expand Up @@ -4009,6 +4011,7 @@ export namespace routers {
excludeTypes?: string[];
startDirections?: dia.OrthogonalDirection[];
endDirections?: dia.OrthogonalDirection[];
isPointObstacle?: (point: dia.Point) => boolean;
}

interface OrthogonalRouterArguments {
Expand Down
Loading

0 comments on commit 16c6ec8

Please sign in to comment.