@joint/core 4.2.2 → 4.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/geometry.js +1 -1
- package/dist/geometry.min.js +1 -1
- package/dist/joint.d.ts +4 -3
- package/dist/joint.js +133 -89
- package/dist/joint.min.js +2 -2
- package/dist/joint.nowrap.js +133 -89
- package/dist/joint.nowrap.min.js +2 -2
- package/dist/vectorizer.js +26 -4
- package/dist/vectorizer.min.js +2 -2
- package/dist/version.mjs +1 -1
- package/package.json +6 -14
- package/src/V/transform.mjs +25 -3
- package/src/cellTools/Button.mjs +3 -1
- package/src/cellTools/Control.mjs +1 -1
- package/src/connectionPoints/index.mjs +1 -1
- package/src/connectors/curve.mjs +2 -4
- package/src/dia/Cell.mjs +5 -6
- package/src/dia/Graph.mjs +13 -13
- package/src/dia/GraphLayerCollection.mjs +2 -3
- package/src/dia/HighlighterView.mjs +5 -5
- package/src/dia/LayerView.mjs +1 -1
- package/src/dia/LinkView.mjs +1 -1
- package/src/dia/Paper.mjs +25 -15
- package/src/dia/attributes/eval.mjs +1 -1
- package/src/dia/ports.mjs +2 -2
- package/src/elementTools/HoverConnect.mjs +4 -3
- package/src/layout/ports/port.mjs +1 -1
- package/src/linkTools/RotateLabel.mjs +2 -1
- package/src/linkTools/Segments.mjs +1 -1
- package/src/mvc/Dom/Dom.mjs +2 -2
- package/src/mvc/Dom/animations.mjs +2 -6
- package/src/mvc/Dom/methods.mjs +3 -3
- package/src/mvc/Dom/props.mjs +1 -1
- package/src/mvc/Listener.mjs +1 -0
- package/src/mvc/Model.mjs +3 -1
- package/src/routers/rightAngle.mjs +9 -9
- package/src/util/calc.mjs +1 -1
- package/src/util/util.mjs +2 -4
- package/src/util/utilHelpers.mjs +5 -5
- package/types/joint.d.ts +5 -4
- package/types/vectorizer.d.ts +1 -1
package/src/V/transform.mjs
CHANGED
|
@@ -109,6 +109,25 @@ export function matrixToTransformString(matrixInit = {}) {
|
|
|
109
109
|
return `matrix(${a},${b},${c},${d},${e},${f})`;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* @param {SVGElement} node
|
|
114
|
+
* @returns {SVGSVGElement|null}
|
|
115
|
+
* @description Returns the root SVG element for the given node,
|
|
116
|
+
* walking up through nested SVG elements.
|
|
117
|
+
* Returns `null` if the node is not part of an SVG document.
|
|
118
|
+
*/
|
|
119
|
+
function getRootSVG(node) {
|
|
120
|
+
let svg = node.ownerSVGElement;
|
|
121
|
+
if (!svg) {
|
|
122
|
+
// The node itself may be an <svg> element
|
|
123
|
+
return node instanceof SVGSVGElement ? node : null;
|
|
124
|
+
}
|
|
125
|
+
while (svg.ownerSVGElement) {
|
|
126
|
+
svg = svg.ownerSVGElement;
|
|
127
|
+
}
|
|
128
|
+
return svg;
|
|
129
|
+
}
|
|
130
|
+
|
|
112
131
|
/**
|
|
113
132
|
*
|
|
114
133
|
* @param {SVGElement} a
|
|
@@ -119,9 +138,12 @@ export function matrixToTransformString(matrixInit = {}) {
|
|
|
119
138
|
* in order to calculate the correct transformation matrix.
|
|
120
139
|
*/
|
|
121
140
|
export function getRelativeTransformation(a, b) {
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
141
|
+
// Elements must be part of an SVG document
|
|
142
|
+
const rootA = getRootSVG(a);
|
|
143
|
+
const rootB = getRootSVG(b);
|
|
144
|
+
if (!rootA || !rootB) return null;
|
|
145
|
+
// Different SVG documents, no transformation possible
|
|
146
|
+
if (rootA !== rootB) return null;
|
|
125
147
|
// Get the transformation matrix from `a` to `b`.
|
|
126
148
|
const am = b.getScreenCTM();
|
|
127
149
|
if (!am) return null;
|
package/src/cellTools/Button.mjs
CHANGED
|
@@ -33,7 +33,9 @@ export const Button = ToolView.extend({
|
|
|
33
33
|
},
|
|
34
34
|
getElementMatrix() {
|
|
35
35
|
const { relatedView: view } = this;
|
|
36
|
-
|
|
36
|
+
const toolOptions = getToolOptions(this);
|
|
37
|
+
let { x = 0, y = 0 } = toolOptions;
|
|
38
|
+
const { useModelGeometry, offset = {}, rotate, scale, relative } = toolOptions;
|
|
37
39
|
let bbox = getViewBBox(view, { useModelGeometry, relative });
|
|
38
40
|
const angle = view.model.angle();
|
|
39
41
|
if (!rotate) bbox = bbox.bbox(angle);
|
|
@@ -76,7 +76,7 @@ export const Control = ToolView.extend({
|
|
|
76
76
|
const { options: { handleAttributes }} = this;
|
|
77
77
|
handleNode.setAttribute('transform', this.getHandleTransformString());
|
|
78
78
|
if (handleAttributes) {
|
|
79
|
-
for (
|
|
79
|
+
for (const attrName in handleAttributes) {
|
|
80
80
|
handleNode.setAttribute(attrName, handleAttributes[attrName]);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -71,7 +71,7 @@ function alignLine(line, type, offset = 0) {
|
|
|
71
71
|
// Connection Points
|
|
72
72
|
|
|
73
73
|
function anchorConnectionPoint(line, _view, _magnet, opt) {
|
|
74
|
-
|
|
74
|
+
const { offset, alignOffset, align } = opt;
|
|
75
75
|
if (align) alignLine(line, align, alignOffset);
|
|
76
76
|
return offsetPoint(line.end, line.start, offset);
|
|
77
77
|
}
|
package/src/connectors/curve.mjs
CHANGED
|
@@ -490,17 +490,15 @@ function createCatmullRomCurves(points, sourceTangent, targetTangent, options) {
|
|
|
490
490
|
const vAngle = angleBetweenVectors(v1, v2);
|
|
491
491
|
|
|
492
492
|
let rot = (Math.PI - vAngle) / 2;
|
|
493
|
-
let t;
|
|
494
493
|
const vectorDeterminant = determinant(v1, v2);
|
|
495
|
-
|
|
496
|
-
pointsDeterminant = determinant(points[i].difference(points[i + 1]), points[i].difference(points[i - 1]));
|
|
494
|
+
const pointsDeterminant = determinant(points[i].difference(points[i + 1]), points[i].difference(points[i - 1]));
|
|
497
495
|
if (vectorDeterminant < 0) {
|
|
498
496
|
rot = -rot;
|
|
499
497
|
}
|
|
500
498
|
if ((vAngle < Math.PI / 2) && ((rot < 0 && pointsDeterminant < 0) || (rot > 0 && pointsDeterminant > 0))) {
|
|
501
499
|
rot = rot - Math.PI;
|
|
502
500
|
}
|
|
503
|
-
t = v2.clone();
|
|
501
|
+
const t = v2.clone();
|
|
504
502
|
rotateVector(t, rot);
|
|
505
503
|
|
|
506
504
|
const t1 = t.clone();
|
package/src/dia/Cell.mjs
CHANGED
|
@@ -100,7 +100,7 @@ export const Cell = Model.extend({
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
let defaultAttributes = {};
|
|
103
|
-
|
|
103
|
+
const attributes = cloneDeep(this.attributes);
|
|
104
104
|
|
|
105
105
|
if (ignoreDefaults === true) {
|
|
106
106
|
// Compare all attributes with the defaults
|
|
@@ -747,9 +747,8 @@ export const Cell = Model.extend({
|
|
|
747
747
|
}.bind(this);
|
|
748
748
|
|
|
749
749
|
const { _scheduledTransitionIds } = this;
|
|
750
|
-
let initialId;
|
|
751
750
|
|
|
752
|
-
|
|
751
|
+
const initiator = (callback) => {
|
|
753
752
|
|
|
754
753
|
if (_scheduledTransitionIds[transitionKey]) {
|
|
755
754
|
_scheduledTransitionIds[transitionKey] = without(_scheduledTransitionIds[transitionKey], initialId);
|
|
@@ -768,7 +767,7 @@ export const Cell = Model.extend({
|
|
|
768
767
|
|
|
769
768
|
};
|
|
770
769
|
|
|
771
|
-
initialId = setTimeout(initiator, opt.delay, setter);
|
|
770
|
+
const initialId = setTimeout(initiator, opt.delay, setter);
|
|
772
771
|
|
|
773
772
|
_scheduledTransitionIds[transitionKey] || (_scheduledTransitionIds[transitionKey] = []);
|
|
774
773
|
_scheduledTransitionIds[transitionKey].push(initialId);
|
|
@@ -975,11 +974,11 @@ export const Cell = Model.extend({
|
|
|
975
974
|
|
|
976
975
|
var Cell = this.extend(protoProps, staticProps);
|
|
977
976
|
// es5 backward compatibility
|
|
978
|
-
|
|
977
|
+
// eslint-disable-next-line no-undef
|
|
979
978
|
if (typeof joint !== 'undefined' && has(joint, 'shapes')) {
|
|
979
|
+
// eslint-disable-next-line no-undef
|
|
980
980
|
setByPath(joint.shapes, type, Cell, '.');
|
|
981
981
|
}
|
|
982
|
-
/* eslint-enable no-undef */
|
|
983
982
|
return Cell;
|
|
984
983
|
}
|
|
985
984
|
});
|
package/src/dia/Graph.mjs
CHANGED
|
@@ -147,7 +147,7 @@ export const Graph = Model.extend({
|
|
|
147
147
|
|
|
148
148
|
} while (sortedCells.length > 0);
|
|
149
149
|
|
|
150
|
-
this.stopBatch('clear');
|
|
150
|
+
this.stopBatch('clear', opt);
|
|
151
151
|
|
|
152
152
|
return this;
|
|
153
153
|
},
|
|
@@ -329,7 +329,7 @@ export const Graph = Model.extend({
|
|
|
329
329
|
removeCells: function(cellRefs, options) {
|
|
330
330
|
if (!cellRefs.length) return this;
|
|
331
331
|
// Remove multiple cells in a single batch
|
|
332
|
-
this.startBatch('remove');
|
|
332
|
+
this.startBatch('remove', options);
|
|
333
333
|
for (const cellRef of cellRefs) {
|
|
334
334
|
if (!cellRef) continue;
|
|
335
335
|
let cell;
|
|
@@ -344,7 +344,7 @@ export const Graph = Model.extend({
|
|
|
344
344
|
}
|
|
345
345
|
this.layerCollection.removeCell(cell, options);
|
|
346
346
|
}
|
|
347
|
-
this.stopBatch('remove');
|
|
347
|
+
this.stopBatch('remove', options);
|
|
348
348
|
return this;
|
|
349
349
|
},
|
|
350
350
|
|
|
@@ -376,7 +376,7 @@ export const Graph = Model.extend({
|
|
|
376
376
|
|
|
377
377
|
// 3. Add the replacement cell
|
|
378
378
|
this.addCell(replacement, replaceOptions);
|
|
379
|
-
this.stopBatch(batchName);
|
|
379
|
+
this.stopBatch(batchName, opt);
|
|
380
380
|
},
|
|
381
381
|
|
|
382
382
|
/**
|
|
@@ -472,7 +472,7 @@ export const Graph = Model.extend({
|
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
-
this.stopBatch(batchName);
|
|
475
|
+
this.stopBatch(batchName, opt);
|
|
476
476
|
},
|
|
477
477
|
|
|
478
478
|
/**
|
|
@@ -499,27 +499,27 @@ export const Graph = Model.extend({
|
|
|
499
499
|
throw new Error('dia.Graph: cell to remove does not exist in the graph.');
|
|
500
500
|
}
|
|
501
501
|
if (cell.graph !== this) return;
|
|
502
|
-
this.startBatch('remove');
|
|
502
|
+
this.startBatch('remove', options);
|
|
503
503
|
cell.collection.remove(cell, options);
|
|
504
|
-
this.stopBatch('remove');
|
|
504
|
+
this.stopBatch('remove', options);
|
|
505
505
|
},
|
|
506
506
|
|
|
507
507
|
transferCellEmbeds: function(sourceCell, targetCell, opt = {}) {
|
|
508
508
|
|
|
509
509
|
const batchName = 'transfer-embeds';
|
|
510
|
-
this.startBatch(batchName);
|
|
510
|
+
this.startBatch(batchName, opt);
|
|
511
511
|
|
|
512
512
|
// Embed children of the source cell in the target cell.
|
|
513
513
|
const children = sourceCell.getEmbeddedCells();
|
|
514
514
|
targetCell.embed(children, { ...opt, reparent: true });
|
|
515
515
|
|
|
516
|
-
this.stopBatch(batchName);
|
|
516
|
+
this.stopBatch(batchName, opt);
|
|
517
517
|
},
|
|
518
518
|
|
|
519
519
|
transferCellConnectedLinks: function(sourceCell, targetCell, opt = {}) {
|
|
520
520
|
|
|
521
521
|
const batchName = 'transfer-connected-links';
|
|
522
|
-
this.startBatch(batchName);
|
|
522
|
+
this.startBatch(batchName, opt);
|
|
523
523
|
|
|
524
524
|
// Reconnect all the links connected to the old cell to the new cell.
|
|
525
525
|
const connectedLinks = this.getConnectedLinks(sourceCell, opt);
|
|
@@ -534,7 +534,7 @@ export const Graph = Model.extend({
|
|
|
534
534
|
}
|
|
535
535
|
});
|
|
536
536
|
|
|
537
|
-
this.stopBatch(batchName);
|
|
537
|
+
this.stopBatch(batchName, opt);
|
|
538
538
|
},
|
|
539
539
|
|
|
540
540
|
/**
|
|
@@ -542,8 +542,8 @@ export const Graph = Model.extend({
|
|
|
542
542
|
* Helper method for addLayer and moveLayer methods
|
|
543
543
|
*/
|
|
544
544
|
_getBeforeLayerIdFromOptions(options, layer = null) {
|
|
545
|
-
let {
|
|
546
|
-
|
|
545
|
+
let { index } = options;
|
|
546
|
+
const { before = null } = options;
|
|
547
547
|
if (before && index !== undefined) {
|
|
548
548
|
throw new Error('dia.Graph: Options "before" and "index" are mutually exclusive.');
|
|
549
549
|
}
|
|
@@ -28,9 +28,8 @@ export const GraphLayerCollection = Collection.extend({
|
|
|
28
28
|
if (cellNamespace) {
|
|
29
29
|
this.cellNamespace = cellNamespace;
|
|
30
30
|
} else {
|
|
31
|
-
|
|
32
|
-
this.cellNamespace = typeof joint !== 'undefined' && util.has(joint, 'shapes') ? joint.shapes : null;
|
|
33
|
-
/* eslint-enable no-undef */
|
|
31
|
+
// eslint-disable-next-line no-undef
|
|
32
|
+
this.cellNamespace = (((typeof joint !== 'undefined') && util.has(joint, 'shapes')) ? joint.shapes : null);
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
this.graph = graph;
|
|
@@ -244,7 +244,7 @@ export const HighlighterView = mvc.View.extend({
|
|
|
244
244
|
// all highlighters
|
|
245
245
|
const views = [];
|
|
246
246
|
if (!refs) return views;
|
|
247
|
-
for (
|
|
247
|
+
for (const hid in refs) {
|
|
248
248
|
const ref = refs[hid];
|
|
249
249
|
if (ref instanceof this) {
|
|
250
250
|
views.push(ref);
|
|
@@ -271,7 +271,7 @@ export const HighlighterView = mvc.View.extend({
|
|
|
271
271
|
if (!refs) return false;
|
|
272
272
|
if (id === null) {
|
|
273
273
|
// any highlighter
|
|
274
|
-
for (
|
|
274
|
+
for (const hid in refs) {
|
|
275
275
|
if (refs[hid] instanceof this) return true;
|
|
276
276
|
}
|
|
277
277
|
return false;
|
|
@@ -311,7 +311,7 @@ export const HighlighterView = mvc.View.extend({
|
|
|
311
311
|
const refs = _views[cid];
|
|
312
312
|
if (!refs) return;
|
|
313
313
|
if (id) delete refs[id];
|
|
314
|
-
for (
|
|
314
|
+
for (const _ in refs) return;
|
|
315
315
|
delete _views[cid];
|
|
316
316
|
},
|
|
317
317
|
|
|
@@ -324,8 +324,8 @@ export const HighlighterView = mvc.View.extend({
|
|
|
324
324
|
getAll(paper, id = null) {
|
|
325
325
|
const views = [];
|
|
326
326
|
const { _views } = this;
|
|
327
|
-
for (
|
|
328
|
-
for (
|
|
327
|
+
for (const cid in _views) {
|
|
328
|
+
for (const hid in _views[cid]) {
|
|
329
329
|
const view = _views[cid][hid];
|
|
330
330
|
if (view.cellView.paper === paper && view instanceof this && (id === null || hid === id)) {
|
|
331
331
|
views.push(view);
|
package/src/dia/LayerView.mjs
CHANGED
|
@@ -99,7 +99,7 @@ export const LayerView = View.extend({
|
|
|
99
99
|
|
|
100
100
|
removePivots: function() {
|
|
101
101
|
const { el, pivotNodes } = this;
|
|
102
|
-
for (
|
|
102
|
+
for (const z in pivotNodes) el.removeChild(pivotNodes[z]);
|
|
103
103
|
this.pivotNodes = {};
|
|
104
104
|
},
|
|
105
105
|
|
package/src/dia/LinkView.mjs
CHANGED
|
@@ -933,7 +933,7 @@ export const LinkView = CellView.extend({
|
|
|
933
933
|
const { metrics, _labelSelectors } = this;
|
|
934
934
|
const selectors = _labelSelectors[index];
|
|
935
935
|
if (!selectors) return;
|
|
936
|
-
for (
|
|
936
|
+
for (const selector in selectors) {
|
|
937
937
|
const { id } = selectors[selector];
|
|
938
938
|
if (id && (id in metrics)) delete metrics[id].magnetMatrix;
|
|
939
939
|
}
|
package/src/dia/Paper.mjs
CHANGED
|
@@ -637,9 +637,8 @@ export const Paper = View.extend({
|
|
|
637
637
|
|
|
638
638
|
const { options } = this;
|
|
639
639
|
if (!options.cellViewNamespace) {
|
|
640
|
-
|
|
641
|
-
options.cellViewNamespace = typeof joint !== 'undefined' && has(joint, 'shapes') ? joint.shapes : null;
|
|
642
|
-
/* eslint-enable no-undef */
|
|
640
|
+
// eslint-disable-next-line no-undef
|
|
641
|
+
options.cellViewNamespace = (((typeof joint !== 'undefined') && has(joint, 'shapes')) ? joint.shapes : null);
|
|
643
642
|
}
|
|
644
643
|
|
|
645
644
|
const defaultLayerViewNamespace = {
|
|
@@ -720,6 +719,9 @@ export const Paper = View.extend({
|
|
|
720
719
|
var position = opt.position;
|
|
721
720
|
if (this.isAsync() || !isNumber(position)) {
|
|
722
721
|
this.renderView(cell, opt);
|
|
722
|
+
// Wake up the paper in case it was idle
|
|
723
|
+
// When using initializeUnmounted: true the paper won't wake up by itself
|
|
724
|
+
this.wakeUp();
|
|
723
725
|
} else {
|
|
724
726
|
if (opt.maxPosition === position) this.freeze({ key: 'addCells' });
|
|
725
727
|
this.renderView(cell, opt);
|
|
@@ -867,11 +869,11 @@ export const Paper = View.extend({
|
|
|
867
869
|
} = options;
|
|
868
870
|
|
|
869
871
|
// Default cellView namespace for ES5
|
|
870
|
-
|
|
871
|
-
if (!cellViewNamespace && typeof joint !== 'undefined' && has(joint, 'shapes')) {
|
|
872
|
+
// eslint-disable-next-line no-undef
|
|
873
|
+
if (!cellViewNamespace && (typeof joint !== 'undefined') && has(joint, 'shapes')) {
|
|
874
|
+
// eslint-disable-next-line no-undef
|
|
872
875
|
options.cellViewNamespace = joint.shapes;
|
|
873
876
|
}
|
|
874
|
-
/* eslint-enable no-undef */
|
|
875
877
|
|
|
876
878
|
// Here if a function was provided, we can not clone it, as this would result in loosing the function.
|
|
877
879
|
// If the default is used, the cloning is necessary in order to prevent modifying the options on prototype.
|
|
@@ -1108,7 +1110,8 @@ export const Paper = View.extend({
|
|
|
1108
1110
|
* Helper method for addLayerView and moveLayerView methods
|
|
1109
1111
|
*/
|
|
1110
1112
|
_getBeforeLayerViewFromOptions(layerView, options) {
|
|
1111
|
-
|
|
1113
|
+
const { before = null } = options;
|
|
1114
|
+
let { index } = options;
|
|
1112
1115
|
|
|
1113
1116
|
if (before && index !== undefined) {
|
|
1114
1117
|
throw new Error('dia.Paper: Options "before" and "index" are mutually exclusive.');
|
|
@@ -1568,7 +1571,7 @@ export const Paper = View.extend({
|
|
|
1568
1571
|
delete prevPriorityUpdates[cid];
|
|
1569
1572
|
}
|
|
1570
1573
|
}
|
|
1571
|
-
|
|
1574
|
+
const currentType = priorityUpdates[cid] || 0;
|
|
1572
1575
|
// Prevent cycling
|
|
1573
1576
|
if ((currentType & type) === type) return;
|
|
1574
1577
|
if (!currentType) updates.count++;
|
|
@@ -1710,7 +1713,7 @@ export const Paper = View.extend({
|
|
|
1710
1713
|
let i = priorityIndexes.length;
|
|
1711
1714
|
while (i > 0 && i--) {
|
|
1712
1715
|
// a faster way how to check if an object is empty
|
|
1713
|
-
for (
|
|
1716
|
+
for (const _key in priorities[priorityIndexes[i]]) return true;
|
|
1714
1717
|
}
|
|
1715
1718
|
return false;
|
|
1716
1719
|
},
|
|
@@ -2030,8 +2033,12 @@ export const Paper = View.extend({
|
|
|
2030
2033
|
var updates = this._updates;
|
|
2031
2034
|
var unmountedList = updates.unmountedList;
|
|
2032
2035
|
for (var i = 0, n = Math.min(unmountedList.length, batchSize); i < n; i++) {
|
|
2036
|
+
// stop if there are no more unmounted views
|
|
2037
|
+
// this can happen when another view was mounted in the onViewUpdate() callback
|
|
2038
|
+
if (unmountedList.length === 0) break;
|
|
2039
|
+
|
|
2033
2040
|
const { key: cid } = unmountedList.peekHead();
|
|
2034
|
-
|
|
2041
|
+
const view = viewsRegistry[cid] || this._viewPlaceholders[cid];
|
|
2035
2042
|
if (!view) {
|
|
2036
2043
|
// This should not occur
|
|
2037
2044
|
// Prevent looping over this invalid cid
|
|
@@ -2267,8 +2274,8 @@ export const Paper = View.extend({
|
|
|
2267
2274
|
setDimensions: function(width, height, data = {}) {
|
|
2268
2275
|
const { options } = this;
|
|
2269
2276
|
const { width: currentWidth, height: currentHeight } = options;
|
|
2270
|
-
|
|
2271
|
-
|
|
2277
|
+
const w = (width === undefined) ? currentWidth : width;
|
|
2278
|
+
const h = (height === undefined) ? currentHeight : height;
|
|
2272
2279
|
if (currentWidth === w && currentHeight === h) return;
|
|
2273
2280
|
options.width = w;
|
|
2274
2281
|
options.height = h;
|
|
@@ -3243,7 +3250,8 @@ export const Paper = View.extend({
|
|
|
3243
3250
|
|
|
3244
3251
|
resolveHighlighter: function(opt = {}) {
|
|
3245
3252
|
|
|
3246
|
-
let { highlighter: highlighterDef
|
|
3253
|
+
let { highlighter: highlighterDef } = opt;
|
|
3254
|
+
const { type } = opt;
|
|
3247
3255
|
const { highlighting,highlighterNamespace } = this.options;
|
|
3248
3256
|
|
|
3249
3257
|
/*
|
|
@@ -3499,7 +3507,8 @@ export const Paper = View.extend({
|
|
|
3499
3507
|
if (view) {
|
|
3500
3508
|
// The view could have been disposed during dragging
|
|
3501
3509
|
// e.g. dragged outside of the viewport and hidden
|
|
3502
|
-
|
|
3510
|
+
// The model can be removed in previous mousemove event handlers
|
|
3511
|
+
view = this.findViewByModel(view.model) || view;
|
|
3503
3512
|
view.pointermove(evt, localPoint.x, localPoint.y);
|
|
3504
3513
|
} else {
|
|
3505
3514
|
this.trigger('blank:pointermove', evt, localPoint.x, localPoint.y);
|
|
@@ -3520,7 +3529,8 @@ export const Paper = View.extend({
|
|
|
3520
3529
|
if (view) {
|
|
3521
3530
|
// The view could have been disposed during dragging
|
|
3522
3531
|
// e.g. dragged outside of the viewport and hidden
|
|
3523
|
-
|
|
3532
|
+
// The model can be removed in previous mouseup event handlers (e.g. when deleting an element after dragging)
|
|
3533
|
+
view = this.findViewByModel(view.model) || view;
|
|
3524
3534
|
view.pointerup(normalizedEvt, localPoint.x, localPoint.y);
|
|
3525
3535
|
} else {
|
|
3526
3536
|
this.trigger('blank:pointerup', normalizedEvt, localPoint.x, localPoint.y);
|
|
@@ -45,7 +45,7 @@ const positiveValueAttributes = positiveValueList.reduce((acc, attrName) => {
|
|
|
45
45
|
|
|
46
46
|
export function evalAttributes(attrs, refBBox) {
|
|
47
47
|
const evalAttrs = {};
|
|
48
|
-
for (
|
|
48
|
+
for (const attrName in attrs) {
|
|
49
49
|
if (!attrs.hasOwnProperty(attrName)) continue;
|
|
50
50
|
evalAttrs[attrName] = evalAttribute(attrName, attrs[attrName], refBBox);
|
|
51
51
|
}
|
package/src/dia/ports.mjs
CHANGED
|
@@ -98,7 +98,7 @@ PortData.prototype = {
|
|
|
98
98
|
groupPortTransformations = this._getGroupPortTransformations(group, portsArgs, elBBox);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
const accumulator = {
|
|
102
102
|
ports: ports,
|
|
103
103
|
result: {}
|
|
104
104
|
};
|
|
@@ -264,7 +264,7 @@ PortData.prototype = {
|
|
|
264
264
|
evaluated.position = this._evaluatePortPositionProperty(group, evaluated);
|
|
265
265
|
evaluated.label = this._evaluatePortLabelProperty(group, evaluated);
|
|
266
266
|
evaluated.z = this._evaluatePortZProperty(group, evaluated);
|
|
267
|
-
evaluated.size = util.assign({}, group.size, evaluated.size);
|
|
267
|
+
evaluated.size = util.assign({ width: 0, height: 0 }, group.size, evaluated.size);
|
|
268
268
|
return evaluated;
|
|
269
269
|
},
|
|
270
270
|
|
|
@@ -8,11 +8,12 @@ export const HoverConnect = LinkHoverConnect.extend({
|
|
|
8
8
|
|
|
9
9
|
getTrackPath() {
|
|
10
10
|
const { relatedView: view } = this;
|
|
11
|
-
|
|
11
|
+
const {
|
|
12
12
|
useModelGeometry,
|
|
13
13
|
relative,
|
|
14
|
-
trackPath = 'M 0 0 H calc(w) V calc(h) H 0 Z'
|
|
14
|
+
trackPath: initialTrackPath = 'M 0 0 H calc(w) V calc(h) H 0 Z'
|
|
15
15
|
} = getToolOptions(this);
|
|
16
|
+
let trackPath = initialTrackPath;
|
|
16
17
|
if (typeof trackPath === 'function') {
|
|
17
18
|
trackPath = trackPath.call(this, view);
|
|
18
19
|
}
|
|
@@ -30,7 +31,7 @@ export const HoverConnect = LinkHoverConnect.extend({
|
|
|
30
31
|
|
|
31
32
|
getTrackMatrixAbsolute() {
|
|
32
33
|
const { relatedView: view } = this;
|
|
33
|
-
|
|
34
|
+
const { useModelGeometry, rotate } = getToolOptions(this);
|
|
34
35
|
let bbox = getViewBBox(view, { useModelGeometry });
|
|
35
36
|
const angle = view.model.angle();
|
|
36
37
|
if (!rotate) bbox = bbox.bbox(angle);
|
|
@@ -52,7 +52,8 @@ export const RotateLabel = Control.extend({
|
|
|
52
52
|
const label = this.getLabel();
|
|
53
53
|
const labelPosition = this.getLabelPosition(label);
|
|
54
54
|
const coords = view.getLabelCoordinates(labelPosition);
|
|
55
|
-
let { angle = 0
|
|
55
|
+
let { angle = 0 } = labelPosition;
|
|
56
|
+
const { args = {}} = labelPosition;
|
|
56
57
|
const keepGradient = args.keepGradient;
|
|
57
58
|
if (keepGradient) {
|
|
58
59
|
const tangent = view.getTangentAtRatio(
|
|
@@ -235,7 +235,7 @@ export const Segments = ToolView.extend({
|
|
|
235
235
|
const isSingleVertex = data.originalVertices.length === 1;
|
|
236
236
|
const origVIndex = isSingleVertex ? 0 : handleIndex;
|
|
237
237
|
const additionalOffset = data.firstHandleShifted && !isSingleVertex ? 1 : 0;
|
|
238
|
-
|
|
238
|
+
const nextVIndex = 1 + indexOffset;
|
|
239
239
|
vertices.splice(handleIndex + nextVIndex, 0, data.originalVertices[origVIndex - additionalOffset]);
|
|
240
240
|
}
|
|
241
241
|
}
|
package/src/mvc/Dom/Dom.mjs
CHANGED
|
@@ -44,7 +44,7 @@ $.guid = 1;
|
|
|
44
44
|
$.data = dataUser;
|
|
45
45
|
|
|
46
46
|
$.merge = function(first, second) {
|
|
47
|
-
|
|
47
|
+
const len = +second.length;
|
|
48
48
|
let i = first.length;
|
|
49
49
|
for (let j = 0; j < len; j++) {
|
|
50
50
|
first[i++] = second[j];
|
|
@@ -227,7 +227,7 @@ $.event.on = function(elem, types, selector, data, fn, one) {
|
|
|
227
227
|
data = data || selector;
|
|
228
228
|
selector = undefined;
|
|
229
229
|
}
|
|
230
|
-
for (
|
|
230
|
+
for (const type in types) {
|
|
231
231
|
$.event.on(elem, type, selector, data, types[type], one);
|
|
232
232
|
}
|
|
233
233
|
return elem;
|
|
@@ -23,12 +23,8 @@ export function animate(properties, opt = {}) {
|
|
|
23
23
|
|
|
24
24
|
function animateNode(el, properties, opt = {}) {
|
|
25
25
|
|
|
26
|
-
let {
|
|
27
|
-
|
|
28
|
-
easing = 'ease-in-out',
|
|
29
|
-
delay = 0,
|
|
30
|
-
complete
|
|
31
|
-
} = opt;
|
|
26
|
+
let { duration = 400, delay = 0 } = opt;
|
|
27
|
+
const { easing = 'ease-in-out', complete } = opt;
|
|
32
28
|
|
|
33
29
|
const delayId = setTimeout(function() {
|
|
34
30
|
|
package/src/mvc/Dom/methods.mjs
CHANGED
|
@@ -158,7 +158,7 @@ export function css(name, value) {
|
|
|
158
158
|
} else {
|
|
159
159
|
styles = name;
|
|
160
160
|
}
|
|
161
|
-
for (
|
|
161
|
+
for (const style in styles) {
|
|
162
162
|
if (styles.hasOwnProperty(style)) {
|
|
163
163
|
for (let i = 0; i < this.length; i++) {
|
|
164
164
|
setCSSProperty(this[i], style, styles[style]);
|
|
@@ -274,7 +274,7 @@ export function off(types, selector, fn) {
|
|
|
274
274
|
}
|
|
275
275
|
if (typeof types === 'object') {
|
|
276
276
|
// ( types-object [, selector] )
|
|
277
|
-
for (
|
|
277
|
+
for (const type in types) {
|
|
278
278
|
this.off(type, selector, types[type]);
|
|
279
279
|
}
|
|
280
280
|
return this;
|
|
@@ -321,7 +321,7 @@ export function height() {
|
|
|
321
321
|
export function position() {
|
|
322
322
|
const [el] = this;
|
|
323
323
|
if (!el) return;
|
|
324
|
-
|
|
324
|
+
const $el = $(el);
|
|
325
325
|
let offsetParent;
|
|
326
326
|
let offset;
|
|
327
327
|
let doc;
|
package/src/mvc/Dom/props.mjs
CHANGED
package/src/mvc/Listener.mjs
CHANGED
|
@@ -19,6 +19,7 @@ export class Listener {
|
|
|
19
19
|
}
|
|
20
20
|
// signature 2 - (object, event, callback, context)
|
|
21
21
|
else if (typeof evt === 'string' && typeof args[0] === 'function') {
|
|
22
|
+
// eslint-disable-next-line prefer-const
|
|
22
23
|
let [cb, context = null] = args;
|
|
23
24
|
// Invoke the callback with callbackArguments passed first
|
|
24
25
|
if (context || callbackArguments.length > 0) cb = cb.bind(context, ...callbackArguments);
|
package/src/mvc/Model.mjs
CHANGED
|
@@ -132,7 +132,9 @@ assign(Model.prototype, Events, {
|
|
|
132
132
|
if (this.idAttribute in attrs) {
|
|
133
133
|
var prevId = this.id;
|
|
134
134
|
this.id = this.get(this.idAttribute);
|
|
135
|
-
|
|
135
|
+
if (this.id !== prevId) {
|
|
136
|
+
this.trigger(this.eventPrefix + 'changeId', this, prevId, options);
|
|
137
|
+
}
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
// Trigger all relevant attribute changes.
|
|
@@ -776,8 +776,8 @@ function routeBetweenPoints(source, target, opt = {}) {
|
|
|
776
776
|
}
|
|
777
777
|
|
|
778
778
|
let x;
|
|
779
|
-
|
|
780
|
-
|
|
779
|
+
const y1 = Math.min((sy1 + ty0) / 2, toy);
|
|
780
|
+
const y2 = Math.min((sy0 + ty1) / 2, soy);
|
|
781
781
|
|
|
782
782
|
if (toy < soy) {
|
|
783
783
|
// Use the shortest path along the connections on horizontal sides
|
|
@@ -816,8 +816,8 @@ function routeBetweenPoints(source, target, opt = {}) {
|
|
|
816
816
|
}
|
|
817
817
|
|
|
818
818
|
let x;
|
|
819
|
-
|
|
820
|
-
|
|
819
|
+
const y1 = Math.max((sy0 + ty1) / 2, toy);
|
|
820
|
+
const y2 = Math.max((sy1 + ty0) / 2, soy);
|
|
821
821
|
|
|
822
822
|
if (toy > soy) {
|
|
823
823
|
// Use the shortest path along the connections on horizontal sides
|
|
@@ -856,8 +856,8 @@ function routeBetweenPoints(source, target, opt = {}) {
|
|
|
856
856
|
}
|
|
857
857
|
|
|
858
858
|
let y;
|
|
859
|
-
|
|
860
|
-
|
|
859
|
+
const x1 = Math.min((sx1 + tx0) / 2, tox);
|
|
860
|
+
const x2 = Math.min((sx0 + tx1) / 2, sox);
|
|
861
861
|
|
|
862
862
|
if (tox > sox) {
|
|
863
863
|
if (topD <= bottomD) {
|
|
@@ -895,8 +895,8 @@ function routeBetweenPoints(source, target, opt = {}) {
|
|
|
895
895
|
}
|
|
896
896
|
|
|
897
897
|
let y;
|
|
898
|
-
|
|
899
|
-
|
|
898
|
+
const x1 = Math.max((sx0 + tx1) / 2, tox);
|
|
899
|
+
const x2 = Math.max((sx1 + tx0) / 2, sox);
|
|
900
900
|
|
|
901
901
|
if (tox <= sox) {
|
|
902
902
|
if (topD <= bottomD) {
|
|
@@ -1518,7 +1518,7 @@ function rightAngleRouter(vertices, opt, linkView) {
|
|
|
1518
1518
|
const isTargetPort = !!linkView.model.target().port;
|
|
1519
1519
|
const targetPoint = pointDataFromAnchor(linkView.targetView, linkView.targetAnchor, linkView.targetBBox, targetDirection, isTargetPort, linkView.targetAnchor, margin);
|
|
1520
1520
|
|
|
1521
|
-
|
|
1521
|
+
const resultVertices = [];
|
|
1522
1522
|
|
|
1523
1523
|
if (!useVertices || vertices.length === 0) {
|
|
1524
1524
|
return simplifyPoints(routeBetweenPoints(sourcePoint, targetPoint));
|