@html-graph/html-graph 8.22.0 → 8.24.0
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/dist/html-graph.d.ts +77 -1
- package/dist/html-graph.js +438 -128
- package/dist/html-graph.min.js +722 -504
- package/dist/html-graph.min.umd.cjs +1 -1
- package/dist/html-graph.umd.cjs +438 -127
- package/package.json +1 -1
package/dist/html-graph.umd.cjs
CHANGED
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
this.attachedNodeIds.delete(nodeId);
|
|
86
86
|
}
|
|
87
87
|
attachEdge(edgeId) {
|
|
88
|
-
const svg = this.graphStore.getEdge(edgeId).payload.shape.
|
|
88
|
+
const svg = this.graphStore.getEdge(edgeId).payload.shape.element;
|
|
89
89
|
this.edgeIdToElementMap.set(edgeId, svg);
|
|
90
90
|
this.container.appendChild(svg);
|
|
91
91
|
this.renderEdge(edgeId);
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
updateEdgeShape(edgeId) {
|
|
128
128
|
const element = this.edgeIdToElementMap.get(edgeId);
|
|
129
129
|
this.container.removeChild(element);
|
|
130
|
-
const svg = this.graphStore.getEdge(edgeId).payload.shape.
|
|
130
|
+
const svg = this.graphStore.getEdge(edgeId).payload.shape.element;
|
|
131
131
|
this.edgeIdToElementMap.set(edgeId, svg);
|
|
132
132
|
this.container.appendChild(svg);
|
|
133
133
|
}
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
}
|
|
153
153
|
updateEdgePriority(edgeId) {
|
|
154
154
|
const edge = this.graphStore.getEdge(edgeId);
|
|
155
|
-
edge.payload.shape.
|
|
155
|
+
edge.payload.shape.element.style.zIndex = `${edge.payload.priority}`;
|
|
156
156
|
}
|
|
157
157
|
createEdgeRenderPort(port, rectPort, rectCanvas, scale) {
|
|
158
158
|
const contentPoint = this.viewportStore.createContentCoords({
|
|
@@ -761,7 +761,7 @@
|
|
|
761
761
|
if (this.hasEdge(request.id)) throw new CanvasError(canvasErrorText.addEdgeWithExistingId(request.id));
|
|
762
762
|
if (!this.hasPort(request.from)) throw new CanvasError(canvasErrorText.addEdgeFromNonexistentPort(request.id, request.from));
|
|
763
763
|
if (!this.hasPort(request.to)) throw new CanvasError(canvasErrorText.addEdgeToNonexistentPort(request.id, request.to));
|
|
764
|
-
const useEdgeId = this.findEdgeIdByElement(request.shape.
|
|
764
|
+
const useEdgeId = this.findEdgeIdByElement(request.shape.element);
|
|
765
765
|
if (useEdgeId !== void 0) throw new CanvasError(canvasErrorText.addEdgeWithElementInUse(request.id, useEdgeId));
|
|
766
766
|
this.addEdgeInternal(request);
|
|
767
767
|
this.afterEdgeAddedEmitter.emit(request.id);
|
|
@@ -902,7 +902,7 @@
|
|
|
902
902
|
priority: request.priority
|
|
903
903
|
}
|
|
904
904
|
});
|
|
905
|
-
this.edgesElementsMap.set(request.shape.
|
|
905
|
+
this.edgesElementsMap.set(request.shape.element, request.id);
|
|
906
906
|
if (request.from !== request.to) {
|
|
907
907
|
this.portOutgoingEdges.get(request.from).add(request.id);
|
|
908
908
|
this.portIncomingEdges.get(request.to).add(request.id);
|
|
@@ -917,7 +917,7 @@
|
|
|
917
917
|
this.portOutgoingEdges.get(from).delete(edgeId);
|
|
918
918
|
this.portOutgoingEdges.get(to).delete(edgeId);
|
|
919
919
|
this.edges.delete(edgeId);
|
|
920
|
-
this.edgesElementsMap.delete(payload.shape.
|
|
920
|
+
this.edgesElementsMap.delete(payload.shape.element);
|
|
921
921
|
}
|
|
922
922
|
};
|
|
923
923
|
//#endregion
|
|
@@ -1392,13 +1392,13 @@
|
|
|
1392
1392
|
return parts.join(" ");
|
|
1393
1393
|
};
|
|
1394
1394
|
//#endregion
|
|
1395
|
-
//#region src/edges/paths/
|
|
1396
|
-
var
|
|
1395
|
+
//#region src/edges/paths/shared/create-horizontal-line/create-horizontal-line.ts
|
|
1396
|
+
var createHorizontalLine = (from, to) => {
|
|
1397
1397
|
const fromLine = from.linePoint;
|
|
1398
1398
|
const toLine = to.linePoint;
|
|
1399
1399
|
const horizontalLineDir = toLine.x - fromLine.x >= 0;
|
|
1400
|
-
const fromPortDir = from.
|
|
1401
|
-
if (fromPortDir === to.
|
|
1400
|
+
const fromPortDir = from.dir.x >= 0;
|
|
1401
|
+
if (fromPortDir === to.dir.x >= 0) {
|
|
1402
1402
|
const isSameDirLine = fromPortDir === horizontalLineDir;
|
|
1403
1403
|
const midpoint = {
|
|
1404
1404
|
x: (fromLine.x + toLine.x) / 2,
|
|
@@ -1475,6 +1475,198 @@
|
|
|
1475
1475
|
};
|
|
1476
1476
|
};
|
|
1477
1477
|
//#endregion
|
|
1478
|
+
//#region src/edges/paths/shared/shared/transpose-point/transpose-point.ts
|
|
1479
|
+
var transposePoint = (point) => {
|
|
1480
|
+
return {
|
|
1481
|
+
x: point.y,
|
|
1482
|
+
y: point.x
|
|
1483
|
+
};
|
|
1484
|
+
};
|
|
1485
|
+
//#endregion
|
|
1486
|
+
//#region src/edges/paths/shared/create-vertical-line/create-vertical-line.ts
|
|
1487
|
+
var createVerticalLine = (from, to) => {
|
|
1488
|
+
const transposedLine = createHorizontalLine({
|
|
1489
|
+
arrowPoint: transposePoint(from.arrowPoint),
|
|
1490
|
+
linePoint: transposePoint(from.linePoint),
|
|
1491
|
+
dir: transposePoint(from.dir)
|
|
1492
|
+
}, {
|
|
1493
|
+
arrowPoint: transposePoint(to.arrowPoint),
|
|
1494
|
+
linePoint: transposePoint(to.linePoint),
|
|
1495
|
+
dir: transposePoint(to.dir)
|
|
1496
|
+
});
|
|
1497
|
+
return {
|
|
1498
|
+
points: transposedLine.points.map((p) => transposePoint(p)),
|
|
1499
|
+
midpoint: transposePoint(transposedLine.midpoint)
|
|
1500
|
+
};
|
|
1501
|
+
};
|
|
1502
|
+
//#endregion
|
|
1503
|
+
//#region src/edges/paths/shared/create-horizontal-source-orthogonal-line/calculate-midpoint/calculate-midpoint.ts
|
|
1504
|
+
var calculateMidpoint = (points) => {
|
|
1505
|
+
const parts = [];
|
|
1506
|
+
for (let i = 1; i < points.length; i++) {
|
|
1507
|
+
const start = points[i - 1];
|
|
1508
|
+
const end = points[i];
|
|
1509
|
+
const dx = end.x - start.x;
|
|
1510
|
+
const dy = end.y - start.y;
|
|
1511
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
1512
|
+
parts.push({
|
|
1513
|
+
start,
|
|
1514
|
+
end,
|
|
1515
|
+
distance
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
const halfLength = parts.reduce((acc, cur) => acc + cur.distance, 0) / 2;
|
|
1519
|
+
let accLength = 0;
|
|
1520
|
+
for (const part of parts) {
|
|
1521
|
+
const nextAccLength = accLength + part.distance;
|
|
1522
|
+
if (nextAccLength >= halfLength) {
|
|
1523
|
+
const residue = halfLength - accLength;
|
|
1524
|
+
const { start, end, distance } = part;
|
|
1525
|
+
if (distance === 0) continue;
|
|
1526
|
+
const ratio = residue / distance;
|
|
1527
|
+
const dx = end.x - start.x;
|
|
1528
|
+
const dy = end.y - start.y;
|
|
1529
|
+
return {
|
|
1530
|
+
x: start.x + dx * ratio,
|
|
1531
|
+
y: start.y + dy * ratio
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
accLength = nextAccLength;
|
|
1535
|
+
}
|
|
1536
|
+
if (accLength === 0 && points.length > 0) return points[0];
|
|
1537
|
+
throw new Error("Failed to calculate midpoint");
|
|
1538
|
+
};
|
|
1539
|
+
//#endregion
|
|
1540
|
+
//#region src/edges/paths/shared/create-horizontal-source-orthogonal-line/create-horizontal-source-orthogonal-line.ts
|
|
1541
|
+
var createHorizontalSourceOrthogonalLine = (from, to) => {
|
|
1542
|
+
const fromLine = from.linePoint;
|
|
1543
|
+
const fromArrow = from.arrowPoint;
|
|
1544
|
+
const toLine = to.linePoint;
|
|
1545
|
+
const toArrow = to.arrowPoint;
|
|
1546
|
+
const targetPortDir = to.dir.y >= 0;
|
|
1547
|
+
const sourcePortDir = from.dir.x >= 0;
|
|
1548
|
+
const verticalLineDir = toLine.y - fromLine.y >= 0;
|
|
1549
|
+
const isSameSourceHorizontal = sourcePortDir === toLine.x - fromLine.x >= 0;
|
|
1550
|
+
const isSameTargetVertical = targetPortDir === verticalLineDir;
|
|
1551
|
+
if (isSameSourceHorizontal) {
|
|
1552
|
+
if (isSameTargetVertical) {
|
|
1553
|
+
const joint = {
|
|
1554
|
+
x: toArrow.x,
|
|
1555
|
+
y: fromArrow.y
|
|
1556
|
+
};
|
|
1557
|
+
return {
|
|
1558
|
+
points: [
|
|
1559
|
+
fromArrow,
|
|
1560
|
+
joint,
|
|
1561
|
+
toArrow
|
|
1562
|
+
],
|
|
1563
|
+
midpoint: calculateMidpoint([
|
|
1564
|
+
fromLine,
|
|
1565
|
+
joint,
|
|
1566
|
+
toLine
|
|
1567
|
+
])
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
const middleX = (fromLine.x + toLine.x) / 2;
|
|
1571
|
+
const jointStart = {
|
|
1572
|
+
x: middleX,
|
|
1573
|
+
y: fromLine.y
|
|
1574
|
+
};
|
|
1575
|
+
const jointEnd = {
|
|
1576
|
+
x: middleX,
|
|
1577
|
+
y: toLine.y
|
|
1578
|
+
};
|
|
1579
|
+
return {
|
|
1580
|
+
points: [
|
|
1581
|
+
fromArrow,
|
|
1582
|
+
jointStart,
|
|
1583
|
+
jointEnd,
|
|
1584
|
+
toLine,
|
|
1585
|
+
toArrow
|
|
1586
|
+
],
|
|
1587
|
+
midpoint: calculateMidpoint([
|
|
1588
|
+
fromLine,
|
|
1589
|
+
jointStart,
|
|
1590
|
+
jointEnd,
|
|
1591
|
+
toLine
|
|
1592
|
+
])
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
if (isSameTargetVertical) {
|
|
1596
|
+
const middleY = (fromLine.y + toLine.y) / 2;
|
|
1597
|
+
const jointStart = {
|
|
1598
|
+
x: fromLine.x,
|
|
1599
|
+
y: middleY
|
|
1600
|
+
};
|
|
1601
|
+
const jointEnd = {
|
|
1602
|
+
x: toLine.x,
|
|
1603
|
+
y: middleY
|
|
1604
|
+
};
|
|
1605
|
+
return {
|
|
1606
|
+
points: [
|
|
1607
|
+
fromArrow,
|
|
1608
|
+
fromLine,
|
|
1609
|
+
jointStart,
|
|
1610
|
+
jointEnd,
|
|
1611
|
+
toArrow
|
|
1612
|
+
],
|
|
1613
|
+
midpoint: calculateMidpoint([
|
|
1614
|
+
fromLine,
|
|
1615
|
+
jointStart,
|
|
1616
|
+
jointEnd,
|
|
1617
|
+
toLine
|
|
1618
|
+
])
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
const joint = {
|
|
1622
|
+
x: fromLine.x,
|
|
1623
|
+
y: toLine.y
|
|
1624
|
+
};
|
|
1625
|
+
return {
|
|
1626
|
+
points: [
|
|
1627
|
+
fromArrow,
|
|
1628
|
+
fromLine,
|
|
1629
|
+
joint,
|
|
1630
|
+
toLine,
|
|
1631
|
+
toArrow
|
|
1632
|
+
],
|
|
1633
|
+
midpoint: calculateMidpoint([
|
|
1634
|
+
fromLine,
|
|
1635
|
+
joint,
|
|
1636
|
+
toLine
|
|
1637
|
+
])
|
|
1638
|
+
};
|
|
1639
|
+
};
|
|
1640
|
+
//#endregion
|
|
1641
|
+
//#region src/edges/paths/shared/create-vertical-source-orthogonal-line/create-vertical-source-orthogonal-line.ts
|
|
1642
|
+
var createVerticalSourceOrthogonalLine = (from, to) => {
|
|
1643
|
+
const transposedLine = createHorizontalSourceOrthogonalLine({
|
|
1644
|
+
arrowPoint: transposePoint(from.arrowPoint),
|
|
1645
|
+
linePoint: transposePoint(from.linePoint),
|
|
1646
|
+
dir: transposePoint(from.dir)
|
|
1647
|
+
}, {
|
|
1648
|
+
arrowPoint: transposePoint(to.arrowPoint),
|
|
1649
|
+
linePoint: transposePoint(to.linePoint),
|
|
1650
|
+
dir: transposePoint(to.dir)
|
|
1651
|
+
});
|
|
1652
|
+
return {
|
|
1653
|
+
points: transposedLine.points.map((p) => transposePoint(p)),
|
|
1654
|
+
midpoint: transposePoint(transposedLine.midpoint)
|
|
1655
|
+
};
|
|
1656
|
+
};
|
|
1657
|
+
//#endregion
|
|
1658
|
+
//#region src/edges/paths/shared/create-orthogonal-line/create-orthogonal-line.ts
|
|
1659
|
+
var createOrthogonalLine = (from, to) => {
|
|
1660
|
+
const isSourceHor = Math.abs(from.dir.y) < 1e-10;
|
|
1661
|
+
const isTargetHor = Math.abs(to.dir.y) < 1e-10;
|
|
1662
|
+
if (isSourceHor) {
|
|
1663
|
+
if (isTargetHor) return createHorizontalLine(from, to);
|
|
1664
|
+
return createHorizontalSourceOrthogonalLine(from, to);
|
|
1665
|
+
}
|
|
1666
|
+
if (!isTargetHor) return createVerticalLine(from, to);
|
|
1667
|
+
return createVerticalSourceOrthogonalLine(from, to);
|
|
1668
|
+
};
|
|
1669
|
+
//#endregion
|
|
1478
1670
|
//#region src/edges/paths/horizontal-edge-path/horizontal-edge-path.ts
|
|
1479
1671
|
var HorizontalEdgePath = class {
|
|
1480
1672
|
path;
|
|
@@ -1498,14 +1690,14 @@
|
|
|
1498
1690
|
x: to.x - gap,
|
|
1499
1691
|
y: to.y
|
|
1500
1692
|
}, toDir, to);
|
|
1501
|
-
const line =
|
|
1693
|
+
const line = createHorizontalLine({
|
|
1502
1694
|
arrowPoint: beginArrow,
|
|
1503
1695
|
linePoint: beginLine,
|
|
1504
|
-
|
|
1696
|
+
dir: fromDir
|
|
1505
1697
|
}, {
|
|
1506
1698
|
arrowPoint: endArrow,
|
|
1507
1699
|
linePoint: endLine,
|
|
1508
|
-
|
|
1700
|
+
dir: toDir
|
|
1509
1701
|
});
|
|
1510
1702
|
this.path = createRoundedPath(line.points, roundness);
|
|
1511
1703
|
this.midpoint = line.midpoint;
|
|
@@ -1599,89 +1791,6 @@
|
|
|
1599
1791
|
}
|
|
1600
1792
|
};
|
|
1601
1793
|
//#endregion
|
|
1602
|
-
//#region src/edges/paths/vertical-edge-path/create-line/create-line.ts
|
|
1603
|
-
var createLine = (from, to) => {
|
|
1604
|
-
const fromLine = from.linePoint;
|
|
1605
|
-
const toLine = to.linePoint;
|
|
1606
|
-
const verticalLineDir = toLine.y - fromLine.y >= 0;
|
|
1607
|
-
const fromPortDir = from.dirY >= 0;
|
|
1608
|
-
if (fromPortDir === to.dirY >= 0) {
|
|
1609
|
-
const isSameDirLine = fromPortDir === verticalLineDir;
|
|
1610
|
-
const midpoint = {
|
|
1611
|
-
x: (fromLine.x + toLine.x) / 2,
|
|
1612
|
-
y: (fromLine.y + toLine.y) / 2
|
|
1613
|
-
};
|
|
1614
|
-
if (isSameDirLine) return {
|
|
1615
|
-
points: [
|
|
1616
|
-
from.arrowPoint,
|
|
1617
|
-
{
|
|
1618
|
-
x: fromLine.x,
|
|
1619
|
-
y: midpoint.y
|
|
1620
|
-
},
|
|
1621
|
-
{
|
|
1622
|
-
x: toLine.x,
|
|
1623
|
-
y: midpoint.y
|
|
1624
|
-
},
|
|
1625
|
-
to.arrowPoint
|
|
1626
|
-
],
|
|
1627
|
-
midpoint
|
|
1628
|
-
};
|
|
1629
|
-
return {
|
|
1630
|
-
points: [
|
|
1631
|
-
from.arrowPoint,
|
|
1632
|
-
fromLine,
|
|
1633
|
-
{
|
|
1634
|
-
x: midpoint.x,
|
|
1635
|
-
y: fromLine.y
|
|
1636
|
-
},
|
|
1637
|
-
{
|
|
1638
|
-
x: midpoint.x,
|
|
1639
|
-
y: toLine.y
|
|
1640
|
-
},
|
|
1641
|
-
toLine,
|
|
1642
|
-
to.arrowPoint
|
|
1643
|
-
],
|
|
1644
|
-
midpoint
|
|
1645
|
-
};
|
|
1646
|
-
}
|
|
1647
|
-
const isSameSourceDir = fromPortDir === verticalLineDir;
|
|
1648
|
-
const centerX = (fromLine.x + toLine.x) / 2;
|
|
1649
|
-
if (isSameSourceDir) {
|
|
1650
|
-
const joint = {
|
|
1651
|
-
x: fromLine.x,
|
|
1652
|
-
y: toLine.y
|
|
1653
|
-
};
|
|
1654
|
-
return {
|
|
1655
|
-
points: [
|
|
1656
|
-
from.arrowPoint,
|
|
1657
|
-
joint,
|
|
1658
|
-
toLine,
|
|
1659
|
-
to.arrowPoint
|
|
1660
|
-
],
|
|
1661
|
-
midpoint: {
|
|
1662
|
-
x: centerX,
|
|
1663
|
-
y: joint.y
|
|
1664
|
-
}
|
|
1665
|
-
};
|
|
1666
|
-
}
|
|
1667
|
-
const joint = {
|
|
1668
|
-
x: toLine.x,
|
|
1669
|
-
y: fromLine.y
|
|
1670
|
-
};
|
|
1671
|
-
return {
|
|
1672
|
-
points: [
|
|
1673
|
-
from.arrowPoint,
|
|
1674
|
-
fromLine,
|
|
1675
|
-
joint,
|
|
1676
|
-
to.arrowPoint
|
|
1677
|
-
],
|
|
1678
|
-
midpoint: {
|
|
1679
|
-
x: centerX,
|
|
1680
|
-
y: joint.y
|
|
1681
|
-
}
|
|
1682
|
-
};
|
|
1683
|
-
};
|
|
1684
|
-
//#endregion
|
|
1685
1794
|
//#region src/edges/paths/vertical-edge-path/vertical-edge-path.ts
|
|
1686
1795
|
var VerticalEdgePath = class {
|
|
1687
1796
|
path;
|
|
@@ -1705,14 +1814,51 @@
|
|
|
1705
1814
|
x: to.x - gap,
|
|
1706
1815
|
y: to.y
|
|
1707
1816
|
}, toDir, to);
|
|
1708
|
-
const line =
|
|
1817
|
+
const line = createVerticalLine({
|
|
1818
|
+
arrowPoint: beginArrow,
|
|
1819
|
+
linePoint: beginLine,
|
|
1820
|
+
dir: fromDir
|
|
1821
|
+
}, {
|
|
1822
|
+
arrowPoint: endArrow,
|
|
1823
|
+
linePoint: endLine,
|
|
1824
|
+
dir: toDir
|
|
1825
|
+
});
|
|
1826
|
+
this.path = createRoundedPath(line.points, roundness);
|
|
1827
|
+
this.midpoint = line.midpoint;
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
//#endregion
|
|
1831
|
+
//#region src/edges/paths/orthogonal-edge-path/orthogonal-edge-path.ts
|
|
1832
|
+
var OrthogonalEdgePath = class {
|
|
1833
|
+
path;
|
|
1834
|
+
midpoint;
|
|
1835
|
+
constructor(params) {
|
|
1836
|
+
const { from, to, fromDir, toDir, arrowLength, arrowOffset, roundness, hasSourceArrow, hasTargetArrow } = params;
|
|
1837
|
+
const beginArrow = hasSourceArrow ? createRotatedPoint({
|
|
1838
|
+
x: from.x + arrowLength,
|
|
1839
|
+
y: from.y
|
|
1840
|
+
}, fromDir, from) : from;
|
|
1841
|
+
const endArrow = hasTargetArrow ? createRotatedPoint({
|
|
1842
|
+
x: to.x - arrowLength,
|
|
1843
|
+
y: to.y
|
|
1844
|
+
}, toDir, to) : to;
|
|
1845
|
+
const gap = arrowLength + arrowOffset;
|
|
1846
|
+
const beginLine = createRotatedPoint({
|
|
1847
|
+
x: from.x + gap,
|
|
1848
|
+
y: from.y
|
|
1849
|
+
}, fromDir, from);
|
|
1850
|
+
const endLine = createRotatedPoint({
|
|
1851
|
+
x: to.x - gap,
|
|
1852
|
+
y: to.y
|
|
1853
|
+
}, toDir, to);
|
|
1854
|
+
const line = createOrthogonalLine({
|
|
1709
1855
|
arrowPoint: beginArrow,
|
|
1710
1856
|
linePoint: beginLine,
|
|
1711
|
-
|
|
1857
|
+
dir: fromDir
|
|
1712
1858
|
}, {
|
|
1713
1859
|
arrowPoint: endArrow,
|
|
1714
1860
|
linePoint: endLine,
|
|
1715
|
-
|
|
1861
|
+
dir: toDir
|
|
1716
1862
|
});
|
|
1717
1863
|
this.path = createRoundedPath(line.points, roundness);
|
|
1718
1864
|
this.midpoint = line.midpoint;
|
|
@@ -1928,6 +2074,31 @@
|
|
|
1928
2074
|
}
|
|
1929
2075
|
};
|
|
1930
2076
|
//#endregion
|
|
2077
|
+
//#region src/edges/paths/detour-orthogonal-edge-path/detour-orthogonal-edge-shape.ts
|
|
2078
|
+
var DetourOrthogonalEdgePath = class {
|
|
2079
|
+
path;
|
|
2080
|
+
midpoint;
|
|
2081
|
+
constructor(params) {
|
|
2082
|
+
const isSourceHor = Math.abs(params.fromDir.y) < 1e-10;
|
|
2083
|
+
const isTargetHor = Math.abs(params.toDir.y) < 1e-10;
|
|
2084
|
+
if (isSourceHor && isTargetHor) {
|
|
2085
|
+
const path = new DetourHorizontalEdgePath(params);
|
|
2086
|
+
this.path = path.path;
|
|
2087
|
+
this.midpoint = path.midpoint;
|
|
2088
|
+
return;
|
|
2089
|
+
}
|
|
2090
|
+
if (!isSourceHor && !isTargetHor) {
|
|
2091
|
+
const path = new DetourVerticalEdgePath(params);
|
|
2092
|
+
this.path = path.path;
|
|
2093
|
+
this.midpoint = path.midpoint;
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
const path = new OrthogonalEdgePath(params);
|
|
2097
|
+
this.path = path.path;
|
|
2098
|
+
this.midpoint = path.midpoint;
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
//#endregion
|
|
1931
2102
|
//#region src/edges/edge-constants.ts
|
|
1932
2103
|
var edgeConstants = Object.freeze({
|
|
1933
2104
|
color: "#777777",
|
|
@@ -1964,6 +2135,7 @@
|
|
|
1964
2135
|
//#region src/edges/shapes/path-edge-shape/path-edge-shape.ts
|
|
1965
2136
|
var PathEdgeShape = class {
|
|
1966
2137
|
params;
|
|
2138
|
+
element;
|
|
1967
2139
|
svg;
|
|
1968
2140
|
group = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
1969
2141
|
line;
|
|
@@ -1976,8 +2148,9 @@
|
|
|
1976
2148
|
this.params = params;
|
|
1977
2149
|
[this.afterRenderEmitter, this.onAfterRender] = createPair();
|
|
1978
2150
|
this.arrowRenderer = this.params.arrowRenderer;
|
|
1979
|
-
this.
|
|
1980
|
-
this.svg
|
|
2151
|
+
this.element = createEdgeSvg(params.color);
|
|
2152
|
+
this.svg = this.element;
|
|
2153
|
+
this.element.appendChild(this.group);
|
|
1981
2154
|
this.line = createEdgePath(params.width);
|
|
1982
2155
|
this.group.appendChild(this.line);
|
|
1983
2156
|
if (params.hasSourceArrow) {
|
|
@@ -1991,7 +2164,7 @@
|
|
|
1991
2164
|
}
|
|
1992
2165
|
render(params) {
|
|
1993
2166
|
const { x, y, width, height, from, to } = createEdgeRectangle(params.from, params.to, this.params.padding);
|
|
1994
|
-
setSvgRectangle(this.
|
|
2167
|
+
setSvgRectangle(this.element, {
|
|
1995
2168
|
x,
|
|
1996
2169
|
y,
|
|
1997
2170
|
width,
|
|
@@ -2149,6 +2322,7 @@
|
|
|
2149
2322
|
//#endregion
|
|
2150
2323
|
//#region src/edges/shapes/bezier-edge-shape/bezier-edge-shape.ts
|
|
2151
2324
|
var BezierEdgeShape = class {
|
|
2325
|
+
element;
|
|
2152
2326
|
svg;
|
|
2153
2327
|
group;
|
|
2154
2328
|
line;
|
|
@@ -2215,7 +2389,8 @@
|
|
|
2215
2389
|
createLinePath: this.createLinePath,
|
|
2216
2390
|
padding: 50
|
|
2217
2391
|
});
|
|
2218
|
-
this.
|
|
2392
|
+
this.element = this.pathShape.element;
|
|
2393
|
+
this.svg = this.element;
|
|
2219
2394
|
this.group = this.pathShape.group;
|
|
2220
2395
|
this.line = this.pathShape.line;
|
|
2221
2396
|
this.sourceArrow = this.pathShape.sourceArrow;
|
|
@@ -2233,7 +2408,12 @@
|
|
|
2233
2408
|
};
|
|
2234
2409
|
//#endregion
|
|
2235
2410
|
//#region src/edges/shapes/horizontal-edge-shape/horizontal-edge-shape.ts
|
|
2411
|
+
/**
|
|
2412
|
+
* @deprecated
|
|
2413
|
+
* use OrthogonalEdgeShape instead
|
|
2414
|
+
*/
|
|
2236
2415
|
var HorizontalEdgeShape = class {
|
|
2416
|
+
element;
|
|
2237
2417
|
svg;
|
|
2238
2418
|
group;
|
|
2239
2419
|
line;
|
|
@@ -2301,7 +2481,8 @@
|
|
|
2301
2481
|
createLinePath: this.createLinePath,
|
|
2302
2482
|
padding: 50
|
|
2303
2483
|
});
|
|
2304
|
-
this.
|
|
2484
|
+
this.element = this.pathShape.element;
|
|
2485
|
+
this.svg = this.element;
|
|
2305
2486
|
this.group = this.pathShape.group;
|
|
2306
2487
|
this.line = this.pathShape.line;
|
|
2307
2488
|
this.sourceArrow = this.pathShape.sourceArrow;
|
|
@@ -2326,6 +2507,7 @@
|
|
|
2326
2507
|
//#endregion
|
|
2327
2508
|
//#region src/edges/shapes/straight-edge-shape/straight-edge-shape.ts
|
|
2328
2509
|
var StraightEdgeShape = class {
|
|
2510
|
+
element;
|
|
2329
2511
|
svg;
|
|
2330
2512
|
group;
|
|
2331
2513
|
line;
|
|
@@ -2396,7 +2578,8 @@
|
|
|
2396
2578
|
createLinePath: this.createLinePath,
|
|
2397
2579
|
padding: 50
|
|
2398
2580
|
});
|
|
2399
|
-
this.
|
|
2581
|
+
this.element = this.pathShape.element;
|
|
2582
|
+
this.svg = this.element;
|
|
2400
2583
|
this.group = this.pathShape.group;
|
|
2401
2584
|
this.line = this.pathShape.line;
|
|
2402
2585
|
this.sourceArrow = this.pathShape.sourceArrow;
|
|
@@ -2415,7 +2598,12 @@
|
|
|
2415
2598
|
};
|
|
2416
2599
|
//#endregion
|
|
2417
2600
|
//#region src/edges/shapes/vertical-edge-shape/vertical-edge-shape.ts
|
|
2601
|
+
/**
|
|
2602
|
+
* @deprecated
|
|
2603
|
+
* use OrthogonalEdgeShape instead
|
|
2604
|
+
*/
|
|
2418
2605
|
var VerticalEdgeShape = class {
|
|
2606
|
+
element;
|
|
2419
2607
|
svg;
|
|
2420
2608
|
group;
|
|
2421
2609
|
line;
|
|
@@ -2483,7 +2671,8 @@
|
|
|
2483
2671
|
createLinePath: this.createLinePath,
|
|
2484
2672
|
padding: 50
|
|
2485
2673
|
});
|
|
2486
|
-
this.
|
|
2674
|
+
this.element = this.pathShape.element;
|
|
2675
|
+
this.svg = this.element;
|
|
2487
2676
|
this.group = this.pathShape.group;
|
|
2488
2677
|
this.line = this.pathShape.line;
|
|
2489
2678
|
this.sourceArrow = this.pathShape.sourceArrow;
|
|
@@ -2506,6 +2695,113 @@
|
|
|
2506
2695
|
}
|
|
2507
2696
|
};
|
|
2508
2697
|
//#endregion
|
|
2698
|
+
//#region src/edges/shapes/orthogonal-edge-shape/orthogonalize-direction/orthogonalize-direction.ts
|
|
2699
|
+
var orthogonalizeDirection = (direction) => {
|
|
2700
|
+
const adjDir = direction + Math.PI / 4;
|
|
2701
|
+
const adjCos = Math.cos(adjDir);
|
|
2702
|
+
const adjSin = Math.sin(adjDir);
|
|
2703
|
+
if (adjCos > 0) {
|
|
2704
|
+
if (adjSin > 0) return 0;
|
|
2705
|
+
return -Math.PI / 2;
|
|
2706
|
+
}
|
|
2707
|
+
if (adjSin > 0) return Math.PI / 2;
|
|
2708
|
+
return Math.PI;
|
|
2709
|
+
};
|
|
2710
|
+
//#endregion
|
|
2711
|
+
//#region src/edges/shapes/orthogonal-edge-shape/orthogonal-edge-shape.ts
|
|
2712
|
+
var OrthogonalEdgeShape = class {
|
|
2713
|
+
element;
|
|
2714
|
+
svg;
|
|
2715
|
+
group;
|
|
2716
|
+
line;
|
|
2717
|
+
sourceArrow;
|
|
2718
|
+
targetArrow;
|
|
2719
|
+
onAfterRender;
|
|
2720
|
+
arrowLength;
|
|
2721
|
+
arrowOffset;
|
|
2722
|
+
roundness;
|
|
2723
|
+
cycleSquareSide;
|
|
2724
|
+
detourDistance;
|
|
2725
|
+
hasSourceArrow;
|
|
2726
|
+
hasTargetArrow;
|
|
2727
|
+
pathShape;
|
|
2728
|
+
createCyclePath = (from, _to, fromDir) => new CycleSquareEdgePath({
|
|
2729
|
+
origin: from,
|
|
2730
|
+
dir: fromDir,
|
|
2731
|
+
arrowLength: this.arrowLength,
|
|
2732
|
+
side: this.cycleSquareSide,
|
|
2733
|
+
arrowOffset: this.arrowOffset,
|
|
2734
|
+
roundness: this.roundness,
|
|
2735
|
+
hasArrow: this.hasSourceArrow || this.hasTargetArrow
|
|
2736
|
+
});
|
|
2737
|
+
createDetourPath = (from, to, fromDir, toDir) => new DetourOrthogonalEdgePath({
|
|
2738
|
+
from,
|
|
2739
|
+
to,
|
|
2740
|
+
fromDir,
|
|
2741
|
+
toDir,
|
|
2742
|
+
arrowLength: this.arrowLength,
|
|
2743
|
+
arrowOffset: this.arrowOffset,
|
|
2744
|
+
roundness: this.roundness,
|
|
2745
|
+
detourDistance: this.detourDistance,
|
|
2746
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2747
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2748
|
+
});
|
|
2749
|
+
createLinePath = (from, to, fromDir, toDir) => new OrthogonalEdgePath({
|
|
2750
|
+
from,
|
|
2751
|
+
to,
|
|
2752
|
+
fromDir,
|
|
2753
|
+
toDir,
|
|
2754
|
+
arrowLength: this.arrowLength,
|
|
2755
|
+
arrowOffset: this.arrowOffset,
|
|
2756
|
+
roundness: this.roundness,
|
|
2757
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2758
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2759
|
+
});
|
|
2760
|
+
constructor(params) {
|
|
2761
|
+
this.arrowLength = params?.arrowLength ?? edgeConstants.arrowLength;
|
|
2762
|
+
this.arrowOffset = params?.arrowOffset ?? edgeConstants.arrowOffset;
|
|
2763
|
+
this.cycleSquareSide = params?.cycleSquareSide ?? edgeConstants.cycleSquareSide;
|
|
2764
|
+
const roundness = params?.roundness ?? edgeConstants.roundness;
|
|
2765
|
+
this.roundness = Math.min(roundness, this.arrowOffset, this.cycleSquareSide / 2);
|
|
2766
|
+
this.detourDistance = params?.detourDistance ?? edgeConstants.detourDistance;
|
|
2767
|
+
this.hasSourceArrow = params?.hasSourceArrow ?? edgeConstants.hasSourceArrow;
|
|
2768
|
+
this.hasTargetArrow = params?.hasTargetArrow ?? edgeConstants.hasTargetArrow;
|
|
2769
|
+
this.pathShape = new PathEdgeShape({
|
|
2770
|
+
color: params?.color ?? edgeConstants.color,
|
|
2771
|
+
width: params?.width ?? edgeConstants.width,
|
|
2772
|
+
arrowRenderer: resolveArrowRenderer(params?.arrowRenderer ?? {}),
|
|
2773
|
+
arrowLength: this.arrowLength,
|
|
2774
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2775
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
2776
|
+
createCyclePath: this.createCyclePath,
|
|
2777
|
+
createDetourPath: this.createDetourPath,
|
|
2778
|
+
createLinePath: this.createLinePath,
|
|
2779
|
+
padding: 50
|
|
2780
|
+
});
|
|
2781
|
+
this.element = this.pathShape.element;
|
|
2782
|
+
this.svg = this.element;
|
|
2783
|
+
this.group = this.pathShape.group;
|
|
2784
|
+
this.line = this.pathShape.line;
|
|
2785
|
+
this.sourceArrow = this.pathShape.sourceArrow;
|
|
2786
|
+
this.targetArrow = this.pathShape.targetArrow;
|
|
2787
|
+
this.onAfterRender = this.pathShape.onAfterRender;
|
|
2788
|
+
}
|
|
2789
|
+
render(params) {
|
|
2790
|
+
const { from, to, category } = params;
|
|
2791
|
+
this.pathShape.render({
|
|
2792
|
+
category,
|
|
2793
|
+
from: {
|
|
2794
|
+
...from,
|
|
2795
|
+
direction: orthogonalizeDirection(from.direction)
|
|
2796
|
+
},
|
|
2797
|
+
to: {
|
|
2798
|
+
...to,
|
|
2799
|
+
direction: orthogonalizeDirection(to.direction)
|
|
2800
|
+
}
|
|
2801
|
+
});
|
|
2802
|
+
}
|
|
2803
|
+
};
|
|
2804
|
+
//#endregion
|
|
2509
2805
|
//#region src/edges/shapes/direct-edge-shape/resolve-port-offset-fn/box-port-offset-fn/box-port-offset-fn.ts
|
|
2510
2806
|
var boxPortOffsetFn = (params) => {
|
|
2511
2807
|
const { direction, radius } = params;
|
|
@@ -2529,6 +2825,7 @@
|
|
|
2529
2825
|
//#region src/edges/shapes/direct-edge-shape/direct-edge-shape.ts
|
|
2530
2826
|
var defaultPortOffset = edgeConstants.portOffset;
|
|
2531
2827
|
var DirectEdgeShape = class {
|
|
2828
|
+
element;
|
|
2532
2829
|
svg;
|
|
2533
2830
|
group = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
2534
2831
|
line;
|
|
@@ -2550,8 +2847,9 @@
|
|
|
2550
2847
|
this.arrowRenderer = resolveArrowRenderer(params?.arrowRenderer ?? {});
|
|
2551
2848
|
this.sourceOffsetFn = resolvePortOffsetFn(params?.sourceOffset ?? defaultPortOffset);
|
|
2552
2849
|
this.targetOffsetFn = resolvePortOffsetFn(params?.targetOffset ?? defaultPortOffset);
|
|
2553
|
-
this.
|
|
2554
|
-
this.svg
|
|
2850
|
+
this.element = createEdgeSvg(this.color);
|
|
2851
|
+
this.svg = this.element;
|
|
2852
|
+
this.element.appendChild(this.group);
|
|
2555
2853
|
this.line = createEdgePath(this.width);
|
|
2556
2854
|
this.group.appendChild(this.line);
|
|
2557
2855
|
if (params?.hasSourceArrow) {
|
|
@@ -2565,7 +2863,7 @@
|
|
|
2565
2863
|
}
|
|
2566
2864
|
render(params) {
|
|
2567
2865
|
const { x, y, width, height, from, to } = createEdgeRectangle(params.from, params.to, 50);
|
|
2568
|
-
setSvgRectangle(this.
|
|
2866
|
+
setSvgRectangle(this.element, {
|
|
2569
2867
|
x,
|
|
2570
2868
|
y,
|
|
2571
2869
|
width,
|
|
@@ -2730,6 +3028,7 @@
|
|
|
2730
3028
|
//#region src/edges/shapes/interactive-edge-shape/interactive-edge-shape.ts
|
|
2731
3029
|
var InteractiveEdgeShape = class InteractiveEdgeShape {
|
|
2732
3030
|
baseEdge;
|
|
3031
|
+
element;
|
|
2733
3032
|
svg;
|
|
2734
3033
|
group;
|
|
2735
3034
|
line;
|
|
@@ -2747,7 +3046,8 @@
|
|
|
2747
3046
|
constructor(baseEdge, params) {
|
|
2748
3047
|
this.baseEdge = baseEdge;
|
|
2749
3048
|
if (baseEdge instanceof InteractiveEdgeShape) throw new InteractiveEdgeError("interactive edge can be configured only once");
|
|
2750
|
-
this.
|
|
3049
|
+
this.element = this.baseEdge.element;
|
|
3050
|
+
this.svg = this.element;
|
|
2751
3051
|
this.group = this.baseEdge.group;
|
|
2752
3052
|
this.line = this.baseEdge.line;
|
|
2753
3053
|
this.sourceArrow = this.baseEdge.sourceArrow;
|
|
@@ -2785,17 +3085,19 @@
|
|
|
2785
3085
|
sourceArrow;
|
|
2786
3086
|
targetArrow;
|
|
2787
3087
|
onAfterRender;
|
|
3088
|
+
element;
|
|
2788
3089
|
svg;
|
|
2789
3090
|
constructor(baseShape, midpointElement) {
|
|
2790
3091
|
this.baseShape = baseShape;
|
|
2791
3092
|
this.midpointElement = midpointElement;
|
|
2792
|
-
this.
|
|
3093
|
+
this.element = this.baseShape.element;
|
|
3094
|
+
this.svg = this.element;
|
|
2793
3095
|
this.group = this.baseShape.group;
|
|
2794
3096
|
this.line = this.baseShape.line;
|
|
2795
3097
|
this.sourceArrow = this.baseShape.sourceArrow;
|
|
2796
3098
|
this.targetArrow = this.baseShape.targetArrow;
|
|
2797
3099
|
this.onAfterRender = this.baseShape.onAfterRender;
|
|
2798
|
-
this.
|
|
3100
|
+
this.element.append(this.midpointElement);
|
|
2799
3101
|
this.baseShape.onAfterRender.subscribe((model) => {
|
|
2800
3102
|
const midpoint = model.edgePath.midpoint;
|
|
2801
3103
|
const transform = `translate(${midpoint.x}px, ${midpoint.y}px)`;
|
|
@@ -4801,16 +5103,16 @@
|
|
|
4801
5103
|
onEdgeSelected;
|
|
4802
5104
|
onAfterEdgeAdded = (edgeId) => {
|
|
4803
5105
|
const { shape } = this.canvas.graph.getEdge(edgeId);
|
|
4804
|
-
this.configurator.enable(shape.
|
|
5106
|
+
this.configurator.enable(shape.element);
|
|
4805
5107
|
};
|
|
4806
5108
|
onBeforeEdgeRemoved = (edgeId) => {
|
|
4807
5109
|
const { shape } = this.canvas.graph.getEdge(edgeId);
|
|
4808
|
-
this.configurator.disable(shape.
|
|
5110
|
+
this.configurator.disable(shape.element);
|
|
4809
5111
|
};
|
|
4810
5112
|
reset = () => {
|
|
4811
5113
|
this.canvas.graph.getAllEdgeIds().forEach((edgeId) => {
|
|
4812
5114
|
const { shape } = this.canvas.graph.getEdge(edgeId);
|
|
4813
|
-
this.configurator.disable(shape.
|
|
5115
|
+
this.configurator.disable(shape.element);
|
|
4814
5116
|
});
|
|
4815
5117
|
};
|
|
4816
5118
|
constructor(canvas, window, pointInsideVerifier, eventTagger, params) {
|
|
@@ -4998,6 +5300,18 @@
|
|
|
4998
5300
|
roundness: config.roundness,
|
|
4999
5301
|
detourDistance: config.detourDistance
|
|
5000
5302
|
});
|
|
5303
|
+
case "orthogonal": return () => new OrthogonalEdgeShape({
|
|
5304
|
+
color: config.color,
|
|
5305
|
+
width: config.width,
|
|
5306
|
+
arrowLength: config.arrowLength,
|
|
5307
|
+
arrowOffset: config.arrowOffset,
|
|
5308
|
+
arrowRenderer: config.arrowRenderer,
|
|
5309
|
+
hasSourceArrow: config.hasSourceArrow,
|
|
5310
|
+
hasTargetArrow: config.hasTargetArrow,
|
|
5311
|
+
cycleSquareSide: config.cycleSquareSide,
|
|
5312
|
+
roundness: config.roundness,
|
|
5313
|
+
detourDistance: config.detourDistance
|
|
5314
|
+
});
|
|
5001
5315
|
case "direct": return () => new DirectEdgeShape({
|
|
5002
5316
|
color: config.color,
|
|
5003
5317
|
width: config.width,
|
|
@@ -5082,28 +5396,24 @@
|
|
|
5082
5396
|
const prev = params.prevTransform;
|
|
5083
5397
|
const next = params.nextTransform;
|
|
5084
5398
|
let nextScale = next.scale;
|
|
5085
|
-
let
|
|
5086
|
-
let
|
|
5399
|
+
let nextX = next.x;
|
|
5400
|
+
let nextY = next.y;
|
|
5087
5401
|
if (next.scale > maxViewScale && next.scale > prev.scale) {
|
|
5088
5402
|
nextScale = Math.max(prev.scale, maxViewScale);
|
|
5089
|
-
nextDx = prev.x;
|
|
5090
|
-
nextDy = prev.y;
|
|
5091
5403
|
const ratio = (nextScale - prev.scale) / (next.scale - prev.scale);
|
|
5092
|
-
|
|
5093
|
-
|
|
5404
|
+
nextX = prev.x + (next.x - prev.x) * ratio;
|
|
5405
|
+
nextY = prev.y + (next.y - prev.y) * ratio;
|
|
5094
5406
|
}
|
|
5095
5407
|
if (next.scale < minViewScale && next.scale < prev.scale) {
|
|
5096
5408
|
nextScale = Math.min(prev.scale, minViewScale);
|
|
5097
|
-
nextDx = prev.x;
|
|
5098
|
-
nextDy = prev.y;
|
|
5099
5409
|
const ratio = (nextScale - prev.scale) / (next.scale - prev.scale);
|
|
5100
|
-
|
|
5101
|
-
|
|
5410
|
+
nextX = prev.x + (next.x - prev.x) * ratio;
|
|
5411
|
+
nextY = prev.y + (next.y - prev.y) * ratio;
|
|
5102
5412
|
}
|
|
5103
5413
|
return {
|
|
5104
5414
|
scale: nextScale,
|
|
5105
|
-
x:
|
|
5106
|
-
y:
|
|
5415
|
+
x: nextX,
|
|
5416
|
+
y: nextY
|
|
5107
5417
|
};
|
|
5108
5418
|
};
|
|
5109
5419
|
};
|
|
@@ -6827,6 +7137,7 @@
|
|
|
6827
7137
|
exports.InteractiveEdgeError = InteractiveEdgeError;
|
|
6828
7138
|
exports.InteractiveEdgeShape = InteractiveEdgeShape;
|
|
6829
7139
|
exports.MidpointEdgeShape = MidpointEdgeShape;
|
|
7140
|
+
exports.OrthogonalEdgeShape = OrthogonalEdgeShape;
|
|
6830
7141
|
exports.StraightEdgeShape = StraightEdgeShape;
|
|
6831
7142
|
exports.VerticalEdgeShape = VerticalEdgeShape;
|
|
6832
7143
|
exports.boxPortOffsetFn = boxPortOffsetFn;
|