@html-graph/html-graph 8.17.0 → 8.18.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/README.md +3 -3
- package/dist/html-graph.d.ts +25 -12
- package/dist/html-graph.js +216 -140
- package/dist/html-graph.min.js +552 -496
- package/dist/html-graph.min.umd.cjs +1 -1
- package/dist/html-graph.umd.cjs +216 -140
- package/package.json +1 -1
package/dist/html-graph.umd.cjs
CHANGED
|
@@ -3309,7 +3309,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3309
3309
|
}
|
|
3310
3310
|
const target = event.currentTarget;
|
|
3311
3311
|
const portId = this.canvas.graph.findPortIdsByElement(target)[0];
|
|
3312
|
-
const dragAllowed = this.params.
|
|
3312
|
+
const dragAllowed = this.params.onPointerDownVerifier(portId, {
|
|
3313
3313
|
x: mouseEvent.clientX,
|
|
3314
3314
|
y: mouseEvent.clientY
|
|
3315
3315
|
});
|
|
@@ -3351,7 +3351,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3351
3351
|
const touch = touchEvent.touches[0];
|
|
3352
3352
|
const target = event.currentTarget;
|
|
3353
3353
|
const portId = this.canvas.graph.findPortIdsByElement(target)[0];
|
|
3354
|
-
const dragAllowed = this.params.
|
|
3354
|
+
const dragAllowed = this.params.onPointerDownVerifier(portId, {
|
|
3355
3355
|
x: touch.clientX,
|
|
3356
3356
|
y: touch.clientY
|
|
3357
3357
|
});
|
|
@@ -3589,6 +3589,52 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3589
3589
|
}
|
|
3590
3590
|
}
|
|
3591
3591
|
}
|
|
3592
|
+
const resolveCreateEdgeRequest = (params, targetPortId) => {
|
|
3593
|
+
return {
|
|
3594
|
+
from: params.isDirect ? params.staticPortId : targetPortId,
|
|
3595
|
+
to: params.isDirect ? targetPortId : params.staticPortId
|
|
3596
|
+
};
|
|
3597
|
+
};
|
|
3598
|
+
class ClosestConnectablePortDraggingPortDirectionResolver {
|
|
3599
|
+
constructor(graph, connectionAllowedVerifier) {
|
|
3600
|
+
this.graph = graph;
|
|
3601
|
+
this.connectionAllowedVerifier = connectionAllowedVerifier;
|
|
3602
|
+
}
|
|
3603
|
+
resolve(params) {
|
|
3604
|
+
let closestDirection = void 0;
|
|
3605
|
+
let closestDistance = Infinity;
|
|
3606
|
+
const { cursor } = params;
|
|
3607
|
+
this.graph.getAllPortIds().forEach((portId) => {
|
|
3608
|
+
const { element, direction, nodeId } = this.graph.getPort(portId);
|
|
3609
|
+
const { x, y } = this.graph.getNode(nodeId);
|
|
3610
|
+
if (x === null || y === null) {
|
|
3611
|
+
return;
|
|
3612
|
+
}
|
|
3613
|
+
const request = resolveCreateEdgeRequest(params, portId);
|
|
3614
|
+
if (!this.connectionAllowedVerifier(request)) {
|
|
3615
|
+
return;
|
|
3616
|
+
}
|
|
3617
|
+
const { top, left, width, height } = element.getBoundingClientRect();
|
|
3618
|
+
const center = { x: left + width / 2, y: top + height / 2 };
|
|
3619
|
+
const dx = cursor.x - center.x;
|
|
3620
|
+
const dy = cursor.y - center.y;
|
|
3621
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
3622
|
+
if (distance < closestDistance) {
|
|
3623
|
+
closestDistance = distance;
|
|
3624
|
+
closestDirection = direction;
|
|
3625
|
+
}
|
|
3626
|
+
});
|
|
3627
|
+
return closestDirection;
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
class ConstantDraggingPortDirectionResolver {
|
|
3631
|
+
constructor(direction) {
|
|
3632
|
+
this.direction = direction;
|
|
3633
|
+
}
|
|
3634
|
+
resolve() {
|
|
3635
|
+
return this.direction;
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3592
3638
|
class UserDraggableNodesConfigurator {
|
|
3593
3639
|
constructor(canvas, element, window2, pointInsideVerifier, params) {
|
|
3594
3640
|
__publicField(this, "grabbedNode", null);
|
|
@@ -4310,8 +4356,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4310
4356
|
class UserConnectablePortsConfigurator {
|
|
4311
4357
|
constructor(canvas, overlayLayer, viewportStore, window2, pointInsideVerifier, params) {
|
|
4312
4358
|
__publicField(this, "overlayCanvas");
|
|
4313
|
-
__publicField(this, "
|
|
4314
|
-
__publicField(this, "isTargetDragging", true);
|
|
4359
|
+
__publicField(this, "edgeInProgress", null);
|
|
4315
4360
|
__publicField(this, "onEdgeCreated", (edgeId) => {
|
|
4316
4361
|
this.params.onAfterEdgeCreated(edgeId);
|
|
4317
4362
|
});
|
|
@@ -4329,7 +4374,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4329
4374
|
const draggablePortsParams = {
|
|
4330
4375
|
mouseDownEventVerifier: this.params.mouseDownEventVerifier,
|
|
4331
4376
|
mouseUpEventVerifier: this.params.mouseUpEventVerifier,
|
|
4332
|
-
|
|
4377
|
+
onPointerDownVerifier: (portId, cursor) => {
|
|
4333
4378
|
const connectionType = this.params.connectionTypeResolver(portId);
|
|
4334
4379
|
if (connectionType === null) {
|
|
4335
4380
|
return false;
|
|
@@ -4345,13 +4390,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4345
4390
|
this.resetDragState();
|
|
4346
4391
|
},
|
|
4347
4392
|
onPointerOutside: () => {
|
|
4348
|
-
const
|
|
4349
|
-
const isTargetDragging = this.isTargetDragging;
|
|
4393
|
+
const params2 = this.edgeInProgress;
|
|
4350
4394
|
this.resetDragState();
|
|
4351
|
-
this.params.onEdgeCreationInterrupted(
|
|
4352
|
-
staticPortId,
|
|
4353
|
-
isDirect: isTargetDragging
|
|
4354
|
-
});
|
|
4395
|
+
this.params.onEdgeCreationInterrupted(params2);
|
|
4355
4396
|
}
|
|
4356
4397
|
};
|
|
4357
4398
|
DraggablePortsConfigurator.configure(
|
|
@@ -4371,9 +4412,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4371
4412
|
params
|
|
4372
4413
|
);
|
|
4373
4414
|
}
|
|
4374
|
-
grabPort(
|
|
4375
|
-
const port = this.canvas.graph.getPort(
|
|
4376
|
-
this.staticPortId = portId;
|
|
4415
|
+
grabPort(staticPortId, cursor, connectionType) {
|
|
4416
|
+
const port = this.canvas.graph.getPort(staticPortId);
|
|
4377
4417
|
const portRect = port.element.getBoundingClientRect();
|
|
4378
4418
|
const portX = portRect.x + portRect.width / 2;
|
|
4379
4419
|
const portY = portRect.y + portRect.height / 2;
|
|
@@ -4391,13 +4431,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4391
4431
|
portCoords: portPoint,
|
|
4392
4432
|
portDirection: port.direction
|
|
4393
4433
|
};
|
|
4434
|
+
const isDirect = connectionType === "direct";
|
|
4435
|
+
this.edgeInProgress = {
|
|
4436
|
+
staticPortId,
|
|
4437
|
+
isDirect
|
|
4438
|
+
};
|
|
4394
4439
|
const draggingParams = {
|
|
4395
4440
|
overlayNodeId: OverlayId.DraggingNodeId,
|
|
4396
4441
|
portCoords: cursorPoint,
|
|
4397
|
-
portDirection: this.params.
|
|
4442
|
+
portDirection: this.params.draggingPortDirectionResolver.resolve({
|
|
4443
|
+
cursor,
|
|
4444
|
+
...this.edgeInProgress
|
|
4445
|
+
}) ?? port.direction
|
|
4398
4446
|
};
|
|
4399
|
-
|
|
4400
|
-
const [sourceParams, targetParams] = this.isTargetDragging ? [staticParams, draggingParams] : [draggingParams, staticParams];
|
|
4447
|
+
const [sourceParams, targetParams] = isDirect ? [staticParams, draggingParams] : [draggingParams, staticParams];
|
|
4401
4448
|
this.overlayCanvas.addNode(createAddNodeOverlayRequest(sourceParams));
|
|
4402
4449
|
this.overlayCanvas.addNode(createAddNodeOverlayRequest(targetParams));
|
|
4403
4450
|
this.overlayCanvas.addEdge({
|
|
@@ -4407,25 +4454,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4407
4454
|
});
|
|
4408
4455
|
}
|
|
4409
4456
|
resetDragState() {
|
|
4410
|
-
this.
|
|
4411
|
-
this.isTargetDragging = true;
|
|
4457
|
+
this.edgeInProgress = null;
|
|
4412
4458
|
this.overlayCanvas.clear();
|
|
4413
4459
|
}
|
|
4414
4460
|
tryCreateConnection(cursor) {
|
|
4415
|
-
const
|
|
4416
|
-
if (
|
|
4417
|
-
this.params.onEdgeCreationInterrupted(
|
|
4418
|
-
staticPortId: this.staticPortId,
|
|
4419
|
-
isDirect: this.isTargetDragging
|
|
4420
|
-
});
|
|
4461
|
+
const targetPortId = findPortAtPoint(this.canvas.graph, cursor);
|
|
4462
|
+
if (targetPortId === null) {
|
|
4463
|
+
this.params.onEdgeCreationInterrupted(this.edgeInProgress);
|
|
4421
4464
|
return;
|
|
4422
4465
|
}
|
|
4423
|
-
const
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4466
|
+
const request = resolveCreateEdgeRequest(
|
|
4467
|
+
this.edgeInProgress,
|
|
4468
|
+
targetPortId
|
|
4469
|
+
);
|
|
4427
4470
|
const connectionAllowed = this.params.connectionAllowedVerifier(request);
|
|
4428
|
-
const processedRequest = this.params.connectionPreprocessor(
|
|
4471
|
+
const processedRequest = this.params.connectionPreprocessor({
|
|
4472
|
+
from: request.from,
|
|
4473
|
+
to: request.to
|
|
4474
|
+
});
|
|
4429
4475
|
if (connectionAllowed && processedRequest !== null) {
|
|
4430
4476
|
this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated);
|
|
4431
4477
|
this.canvas.addEdge(processedRequest);
|
|
@@ -4434,23 +4480,26 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4434
4480
|
this.params.onEdgeCreationPrevented(request);
|
|
4435
4481
|
}
|
|
4436
4482
|
}
|
|
4437
|
-
moveDraggingPort(
|
|
4483
|
+
moveDraggingPort(cursor) {
|
|
4438
4484
|
const canvasRect = this.overlayLayer.getBoundingClientRect();
|
|
4439
4485
|
const nodeContentCoords = this.canvas.viewport.createContentCoords({
|
|
4440
|
-
x:
|
|
4441
|
-
y:
|
|
4486
|
+
x: cursor.x - canvasRect.x,
|
|
4487
|
+
y: cursor.y - canvasRect.y
|
|
4488
|
+
});
|
|
4489
|
+
const direction = this.params.draggingPortDirectionResolver.resolve({
|
|
4490
|
+
cursor,
|
|
4491
|
+
...this.edgeInProgress
|
|
4442
4492
|
});
|
|
4443
4493
|
this.overlayCanvas.updateNode(OverlayId.DraggingNodeId, {
|
|
4444
4494
|
x: nodeContentCoords.x,
|
|
4445
4495
|
y: nodeContentCoords.y
|
|
4446
|
-
});
|
|
4496
|
+
}).updatePort(OverlayId.DraggingNodeId, { direction });
|
|
4447
4497
|
}
|
|
4448
4498
|
}
|
|
4449
4499
|
class UserDraggableEdgesConfigurator {
|
|
4450
4500
|
constructor(canvas, overlayLayer, viewportStore, window2, pointInsideVerifier, params) {
|
|
4451
4501
|
__publicField(this, "overlayCanvas");
|
|
4452
|
-
__publicField(this, "
|
|
4453
|
-
__publicField(this, "isTargetDragging", true);
|
|
4502
|
+
__publicField(this, "edgeInProgress", null);
|
|
4454
4503
|
__publicField(this, "draggingEdgePayload", null);
|
|
4455
4504
|
__publicField(this, "onEdgeReattached", (edgeId) => {
|
|
4456
4505
|
this.params.onAfterEdgeReattached(edgeId);
|
|
@@ -4469,7 +4518,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4469
4518
|
const draggablePortsParams = {
|
|
4470
4519
|
mouseDownEventVerifier: this.params.mouseDownEventVerifier,
|
|
4471
4520
|
mouseUpEventVerifier: this.params.mouseUpEventVerifier,
|
|
4472
|
-
|
|
4521
|
+
onPointerDownVerifier: (portId, cursor) => {
|
|
4473
4522
|
return this.tryStartEdgeDragging(portId, cursor);
|
|
4474
4523
|
},
|
|
4475
4524
|
onPointerMove: (cursor) => {
|
|
@@ -4515,10 +4564,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4515
4564
|
}
|
|
4516
4565
|
const edge = this.canvas.graph.getEdge(edgeId);
|
|
4517
4566
|
const isSourceDragging = portId === edge.from;
|
|
4518
|
-
const
|
|
4567
|
+
const isDirect = portId === edge.to;
|
|
4519
4568
|
const staticPortId = isSourceDragging ? edge.to : edge.from;
|
|
4520
|
-
this.
|
|
4521
|
-
this.isTargetDragging = isTargetDragging;
|
|
4569
|
+
this.edgeInProgress = { staticPortId, isDirect };
|
|
4522
4570
|
const draggingPort = this.canvas.graph.getPort(portId);
|
|
4523
4571
|
const staticPort = this.canvas.graph.getPort(staticPortId);
|
|
4524
4572
|
const staticRect = staticPort.element.getBoundingClientRect();
|
|
@@ -4548,12 +4596,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4548
4596
|
portCoords: staticPoint,
|
|
4549
4597
|
portDirection: staticPort.direction
|
|
4550
4598
|
};
|
|
4599
|
+
const direction = this.params.draggingPortDirectionResolver.resolve({
|
|
4600
|
+
cursor,
|
|
4601
|
+
...this.edgeInProgress
|
|
4602
|
+
});
|
|
4551
4603
|
const draggingParams = {
|
|
4552
4604
|
overlayNodeId: OverlayId.DraggingNodeId,
|
|
4553
4605
|
portCoords: draggingPoint,
|
|
4554
|
-
portDirection: draggingPort.direction
|
|
4606
|
+
portDirection: direction ?? draggingPort.direction
|
|
4555
4607
|
};
|
|
4556
|
-
const [sourceParams, targetParams] =
|
|
4608
|
+
const [sourceParams, targetParams] = isDirect ? [staticParams, draggingParams] : [draggingParams, staticParams];
|
|
4557
4609
|
this.overlayCanvas.addNode(createAddNodeOverlayRequest(sourceParams));
|
|
4558
4610
|
this.overlayCanvas.addNode(createAddNodeOverlayRequest(targetParams));
|
|
4559
4611
|
const overlayEdgeShape = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(OverlayId.EdgeId) : edge.shape;
|
|
@@ -4567,30 +4619,43 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4567
4619
|
}
|
|
4568
4620
|
resetDragState() {
|
|
4569
4621
|
this.draggingEdgePayload = null;
|
|
4570
|
-
this.
|
|
4571
|
-
this.isTargetDragging = true;
|
|
4622
|
+
this.edgeInProgress = null;
|
|
4572
4623
|
this.overlayCanvas.clear();
|
|
4573
4624
|
}
|
|
4574
|
-
moveDraggingPort(
|
|
4625
|
+
moveDraggingPort(cursor) {
|
|
4575
4626
|
const canvasRect = this.overlayLayer.getBoundingClientRect();
|
|
4576
4627
|
const nodeViewCoords = {
|
|
4577
|
-
x:
|
|
4578
|
-
y:
|
|
4628
|
+
x: cursor.x - canvasRect.x,
|
|
4629
|
+
y: cursor.y - canvasRect.y
|
|
4579
4630
|
};
|
|
4580
4631
|
const nodeContentCoords = this.canvas.viewport.createContentCoords(nodeViewCoords);
|
|
4632
|
+
const direction = this.params.draggingPortDirectionResolver.resolve({
|
|
4633
|
+
cursor,
|
|
4634
|
+
...this.edgeInProgress
|
|
4635
|
+
});
|
|
4581
4636
|
this.overlayCanvas.updateNode(OverlayId.DraggingNodeId, {
|
|
4582
4637
|
x: nodeContentCoords.x,
|
|
4583
4638
|
y: nodeContentCoords.y
|
|
4584
|
-
});
|
|
4639
|
+
}).updatePort(OverlayId.DraggingNodeId, { direction });
|
|
4585
4640
|
}
|
|
4586
4641
|
tryCreateConnection(cursor) {
|
|
4587
4642
|
const draggingPortId = findPortAtPoint(this.canvas.graph, cursor);
|
|
4588
4643
|
this.overlayCanvas.removeEdge(OverlayId.EdgeId);
|
|
4589
4644
|
if (draggingPortId === null) {
|
|
4590
|
-
this.
|
|
4645
|
+
const edge2 = this.draggingEdgePayload;
|
|
4646
|
+
this.params.onEdgeReattachInterrupted({
|
|
4647
|
+
id: edge2.id,
|
|
4648
|
+
from: edge2.from,
|
|
4649
|
+
to: edge2.to,
|
|
4650
|
+
shape: edge2.shape,
|
|
4651
|
+
priority: edge2.priority
|
|
4652
|
+
});
|
|
4591
4653
|
return;
|
|
4592
4654
|
}
|
|
4593
|
-
const
|
|
4655
|
+
const { from, to } = resolveCreateEdgeRequest(
|
|
4656
|
+
this.edgeInProgress,
|
|
4657
|
+
draggingPortId
|
|
4658
|
+
);
|
|
4594
4659
|
const edge = this.draggingEdgePayload;
|
|
4595
4660
|
const request = {
|
|
4596
4661
|
id: edge.id,
|
|
@@ -4619,16 +4684,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4619
4684
|
});
|
|
4620
4685
|
}
|
|
4621
4686
|
}
|
|
4622
|
-
handleEdgeReattachInterrupted() {
|
|
4623
|
-
const edge = this.draggingEdgePayload;
|
|
4624
|
-
this.params.onEdgeReattachInterrupted({
|
|
4625
|
-
id: edge.id,
|
|
4626
|
-
from: edge.from,
|
|
4627
|
-
to: edge.to,
|
|
4628
|
-
shape: edge.shape,
|
|
4629
|
-
priority: edge.priority
|
|
4630
|
-
});
|
|
4631
|
-
}
|
|
4632
4687
|
}
|
|
4633
4688
|
class ManualLayoutApplicationStrategyConfigurator {
|
|
4634
4689
|
constructor(applier, trigger) {
|
|
@@ -4993,6 +5048,87 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4993
5048
|
});
|
|
4994
5049
|
const noopFn = () => {
|
|
4995
5050
|
};
|
|
5051
|
+
const resolveDraggingPortDirectionResolver = (config, graph, connectionAllowedVerifier) => {
|
|
5052
|
+
if (config === "closest-connectable-port") {
|
|
5053
|
+
return new ClosestConnectablePortDraggingPortDirectionResolver(
|
|
5054
|
+
graph,
|
|
5055
|
+
connectionAllowedVerifier
|
|
5056
|
+
);
|
|
5057
|
+
}
|
|
5058
|
+
return new ConstantDraggingPortDirectionResolver(config);
|
|
5059
|
+
};
|
|
5060
|
+
const resolveEdgeShapeFactory = (config) => {
|
|
5061
|
+
if (typeof config === "function") {
|
|
5062
|
+
return config;
|
|
5063
|
+
}
|
|
5064
|
+
switch (config.type) {
|
|
5065
|
+
case "straight":
|
|
5066
|
+
return () => new StraightEdgeShape({
|
|
5067
|
+
color: config.color,
|
|
5068
|
+
width: config.width,
|
|
5069
|
+
arrowLength: config.arrowLength,
|
|
5070
|
+
arrowOffset: config.arrowOffset,
|
|
5071
|
+
arrowRenderer: config.arrowRenderer,
|
|
5072
|
+
hasSourceArrow: config.hasSourceArrow,
|
|
5073
|
+
hasTargetArrow: config.hasTargetArrow,
|
|
5074
|
+
cycleSquareSide: config.cycleSquareSide,
|
|
5075
|
+
roundness: config.roundness,
|
|
5076
|
+
detourDistance: config.detourDistance,
|
|
5077
|
+
detourDirection: config.detourDirection
|
|
5078
|
+
});
|
|
5079
|
+
case "horizontal":
|
|
5080
|
+
return () => new HorizontalEdgeShape({
|
|
5081
|
+
color: config.color,
|
|
5082
|
+
width: config.width,
|
|
5083
|
+
arrowLength: config.arrowLength,
|
|
5084
|
+
arrowOffset: config.arrowOffset,
|
|
5085
|
+
arrowRenderer: config.arrowRenderer,
|
|
5086
|
+
hasSourceArrow: config.hasSourceArrow,
|
|
5087
|
+
hasTargetArrow: config.hasTargetArrow,
|
|
5088
|
+
cycleSquareSide: config.cycleSquareSide,
|
|
5089
|
+
roundness: config.roundness,
|
|
5090
|
+
detourDistance: config.detourDistance
|
|
5091
|
+
});
|
|
5092
|
+
case "vertical":
|
|
5093
|
+
return () => new VerticalEdgeShape({
|
|
5094
|
+
color: config.color,
|
|
5095
|
+
width: config.width,
|
|
5096
|
+
arrowLength: config.arrowLength,
|
|
5097
|
+
arrowOffset: config.arrowOffset,
|
|
5098
|
+
arrowRenderer: config.arrowRenderer,
|
|
5099
|
+
hasSourceArrow: config.hasSourceArrow,
|
|
5100
|
+
hasTargetArrow: config.hasTargetArrow,
|
|
5101
|
+
cycleSquareSide: config.cycleSquareSide,
|
|
5102
|
+
roundness: config.roundness,
|
|
5103
|
+
detourDistance: config.detourDistance
|
|
5104
|
+
});
|
|
5105
|
+
case "direct":
|
|
5106
|
+
return () => new DirectEdgeShape({
|
|
5107
|
+
color: config.color,
|
|
5108
|
+
width: config.width,
|
|
5109
|
+
arrowLength: config.arrowLength,
|
|
5110
|
+
arrowRenderer: config.arrowRenderer,
|
|
5111
|
+
hasSourceArrow: config.hasSourceArrow,
|
|
5112
|
+
hasTargetArrow: config.hasTargetArrow,
|
|
5113
|
+
sourceOffset: config.sourceOffset,
|
|
5114
|
+
targetOffset: config.targetOffset
|
|
5115
|
+
});
|
|
5116
|
+
default:
|
|
5117
|
+
return () => new BezierEdgeShape({
|
|
5118
|
+
color: config.color,
|
|
5119
|
+
width: config.width,
|
|
5120
|
+
arrowLength: config.arrowLength,
|
|
5121
|
+
arrowRenderer: config.arrowRenderer,
|
|
5122
|
+
hasSourceArrow: config.hasSourceArrow,
|
|
5123
|
+
hasTargetArrow: config.hasTargetArrow,
|
|
5124
|
+
cycleRadius: config.cycleRadius,
|
|
5125
|
+
smallCycleRadius: config.smallCycleRadius,
|
|
5126
|
+
curvature: config.curvature,
|
|
5127
|
+
detourDistance: config.detourDistance,
|
|
5128
|
+
detourDirection: config.detourDirection
|
|
5129
|
+
});
|
|
5130
|
+
}
|
|
5131
|
+
};
|
|
4996
5132
|
const createDraggableNodesParams = (config) => {
|
|
4997
5133
|
var _a, _b, _c, _d, _e, _f;
|
|
4998
5134
|
const nodeDragVerifier = config.nodeDragVerifier ?? (() => true);
|
|
@@ -5187,102 +5323,36 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5187
5323
|
maxViewportScale: backgroundConfig.maxViewportScale ?? 10
|
|
5188
5324
|
};
|
|
5189
5325
|
};
|
|
5190
|
-
const resolveEdgeShapeFactory = (config) => {
|
|
5191
|
-
if (typeof config === "function") {
|
|
5192
|
-
return config;
|
|
5193
|
-
}
|
|
5194
|
-
switch (config.type) {
|
|
5195
|
-
case "straight":
|
|
5196
|
-
return () => new StraightEdgeShape({
|
|
5197
|
-
color: config.color,
|
|
5198
|
-
width: config.width,
|
|
5199
|
-
arrowLength: config.arrowLength,
|
|
5200
|
-
arrowOffset: config.arrowOffset,
|
|
5201
|
-
arrowRenderer: config.arrowRenderer,
|
|
5202
|
-
hasSourceArrow: config.hasSourceArrow,
|
|
5203
|
-
hasTargetArrow: config.hasTargetArrow,
|
|
5204
|
-
cycleSquareSide: config.cycleSquareSide,
|
|
5205
|
-
roundness: config.roundness,
|
|
5206
|
-
detourDistance: config.detourDistance,
|
|
5207
|
-
detourDirection: config.detourDirection
|
|
5208
|
-
});
|
|
5209
|
-
case "horizontal":
|
|
5210
|
-
return () => new HorizontalEdgeShape({
|
|
5211
|
-
color: config.color,
|
|
5212
|
-
width: config.width,
|
|
5213
|
-
arrowLength: config.arrowLength,
|
|
5214
|
-
arrowOffset: config.arrowOffset,
|
|
5215
|
-
arrowRenderer: config.arrowRenderer,
|
|
5216
|
-
hasSourceArrow: config.hasSourceArrow,
|
|
5217
|
-
hasTargetArrow: config.hasTargetArrow,
|
|
5218
|
-
cycleSquareSide: config.cycleSquareSide,
|
|
5219
|
-
roundness: config.roundness,
|
|
5220
|
-
detourDistance: config.detourDistance
|
|
5221
|
-
});
|
|
5222
|
-
case "vertical":
|
|
5223
|
-
return () => new VerticalEdgeShape({
|
|
5224
|
-
color: config.color,
|
|
5225
|
-
width: config.width,
|
|
5226
|
-
arrowLength: config.arrowLength,
|
|
5227
|
-
arrowOffset: config.arrowOffset,
|
|
5228
|
-
arrowRenderer: config.arrowRenderer,
|
|
5229
|
-
hasSourceArrow: config.hasSourceArrow,
|
|
5230
|
-
hasTargetArrow: config.hasTargetArrow,
|
|
5231
|
-
cycleSquareSide: config.cycleSquareSide,
|
|
5232
|
-
roundness: config.roundness,
|
|
5233
|
-
detourDistance: config.detourDistance
|
|
5234
|
-
});
|
|
5235
|
-
case "direct":
|
|
5236
|
-
return () => new DirectEdgeShape({
|
|
5237
|
-
color: config.color,
|
|
5238
|
-
width: config.width,
|
|
5239
|
-
arrowLength: config.arrowLength,
|
|
5240
|
-
arrowRenderer: config.arrowRenderer,
|
|
5241
|
-
hasSourceArrow: config.hasSourceArrow,
|
|
5242
|
-
hasTargetArrow: config.hasTargetArrow,
|
|
5243
|
-
sourceOffset: config.sourceOffset,
|
|
5244
|
-
targetOffset: config.targetOffset
|
|
5245
|
-
});
|
|
5246
|
-
default:
|
|
5247
|
-
return () => new BezierEdgeShape({
|
|
5248
|
-
color: config.color,
|
|
5249
|
-
width: config.width,
|
|
5250
|
-
arrowLength: config.arrowLength,
|
|
5251
|
-
arrowRenderer: config.arrowRenderer,
|
|
5252
|
-
hasSourceArrow: config.hasSourceArrow,
|
|
5253
|
-
hasTargetArrow: config.hasTargetArrow,
|
|
5254
|
-
cycleRadius: config.cycleRadius,
|
|
5255
|
-
smallCycleRadius: config.smallCycleRadius,
|
|
5256
|
-
curvature: config.curvature,
|
|
5257
|
-
detourDistance: config.detourDistance,
|
|
5258
|
-
detourDirection: config.detourDirection
|
|
5259
|
-
});
|
|
5260
|
-
}
|
|
5261
|
-
};
|
|
5262
5326
|
const defaults$3 = Object.freeze({
|
|
5263
5327
|
connectionTypeResolver: () => "direct",
|
|
5264
5328
|
connectionPreprocessor: (request) => request,
|
|
5265
5329
|
connectionAllowedVerifier: () => true,
|
|
5266
5330
|
mouseEventVerifier: (event) => event.button === 0
|
|
5267
5331
|
});
|
|
5268
|
-
const createConnectablePortsParams = (config, defaultEdgeShapeFactory,
|
|
5332
|
+
const createConnectablePortsParams = (config, defaultEdgeShapeFactory, graph) => {
|
|
5269
5333
|
var _a, _b, _c;
|
|
5334
|
+
const connectionAllowedVerifier = config.connectionAllowedVerifier ?? defaults$3.connectionAllowedVerifier;
|
|
5270
5335
|
return {
|
|
5271
5336
|
connectionTypeResolver: config.connectionTypeResolver ?? defaults$3.connectionTypeResolver,
|
|
5337
|
+
connectionAllowedVerifier,
|
|
5338
|
+
draggingPortDirectionResolver: resolveDraggingPortDirectionResolver(
|
|
5339
|
+
config.dragPortDirection,
|
|
5340
|
+
graph,
|
|
5341
|
+
connectionAllowedVerifier
|
|
5342
|
+
),
|
|
5343
|
+
edgeShapeFactory: config.edgeShape !== void 0 ? resolveEdgeShapeFactory(config.edgeShape) : defaultEdgeShapeFactory,
|
|
5272
5344
|
connectionPreprocessor: config.connectionPreprocessor ?? defaults$3.connectionPreprocessor,
|
|
5273
|
-
connectionAllowedVerifier: config.connectionAllowedVerifier ?? defaults$3.connectionAllowedVerifier,
|
|
5274
5345
|
mouseDownEventVerifier: config.mouseDownEventVerifier ?? defaults$3.mouseEventVerifier,
|
|
5275
5346
|
mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaults$3.mouseEventVerifier,
|
|
5276
5347
|
onAfterEdgeCreated: ((_a = config.events) == null ? void 0 : _a.onAfterEdgeCreated) ?? noopFn,
|
|
5277
5348
|
onEdgeCreationInterrupted: ((_b = config.events) == null ? void 0 : _b.onEdgeCreationInterrupted) ?? noopFn,
|
|
5278
|
-
onEdgeCreationPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeCreationPrevented) ?? noopFn
|
|
5279
|
-
dragPortDirection: config.dragPortDirection ?? defaultDragPortDirection,
|
|
5280
|
-
edgeShapeFactory: config.edgeShape !== void 0 ? resolveEdgeShapeFactory(config.edgeShape) : defaultEdgeShapeFactory
|
|
5349
|
+
onEdgeCreationPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeCreationPrevented) ?? noopFn
|
|
5281
5350
|
};
|
|
5282
5351
|
};
|
|
5283
5352
|
const defaults$2 = Object.freeze({
|
|
5284
5353
|
connectionAllowedVerifier: () => true,
|
|
5285
5354
|
connectionPreprocessor: (request) => request,
|
|
5355
|
+
// TODO: remove ctrl key
|
|
5286
5356
|
mouseDownEventVerifier: (event) => event.button === 0 && event.ctrlKey,
|
|
5287
5357
|
mouseUpEventVerifier: (event) => event.button === 0
|
|
5288
5358
|
});
|
|
@@ -5296,16 +5366,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5296
5366
|
return null;
|
|
5297
5367
|
}
|
|
5298
5368
|
};
|
|
5369
|
+
const connectionAllowedVerifier = config.connectionAllowedVerifier ?? defaults$2.connectionAllowedVerifier;
|
|
5299
5370
|
return {
|
|
5300
5371
|
connectionPreprocessor: config.connectionPreprocessor ?? defaults$2.connectionPreprocessor,
|
|
5301
|
-
connectionAllowedVerifier
|
|
5372
|
+
connectionAllowedVerifier,
|
|
5302
5373
|
mouseDownEventVerifier: config.mouseDownEventVerifier ?? defaults$2.mouseDownEventVerifier,
|
|
5303
5374
|
mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaults$2.mouseUpEventVerifier,
|
|
5304
5375
|
draggingEdgeResolver: config.draggingEdgeResolver ?? defaultDraggingEdgeResolver,
|
|
5305
5376
|
draggingEdgeShapeFactory: config.draggingEdgeShape !== void 0 ? resolveEdgeShapeFactory(config.draggingEdgeShape) : null,
|
|
5306
5377
|
onAfterEdgeReattached: ((_a = config.events) == null ? void 0 : _a.onAfterEdgeReattached) ?? noopFn,
|
|
5307
5378
|
onEdgeReattachInterrupted: ((_b = config.events) == null ? void 0 : _b.onEdgeReattachInterrupted) ?? noopFn,
|
|
5308
|
-
onEdgeReattachPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeReattachPrevented) ?? noopFn
|
|
5379
|
+
onEdgeReattachPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeReattachPrevented) ?? noopFn,
|
|
5380
|
+
draggingPortDirectionResolver: resolveDraggingPortDirectionResolver(
|
|
5381
|
+
config.dragPortDirection,
|
|
5382
|
+
graph,
|
|
5383
|
+
connectionAllowedVerifier
|
|
5384
|
+
)
|
|
5309
5385
|
};
|
|
5310
5386
|
};
|
|
5311
5387
|
const createVirtualScrollParams = (config) => {
|
|
@@ -6927,7 +7003,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6927
7003
|
const params = createConnectablePortsParams(
|
|
6928
7004
|
this.connectablePortsConfig,
|
|
6929
7005
|
graphControllerParams.edges.shapeFactory,
|
|
6930
|
-
|
|
7006
|
+
canvas.graph
|
|
6931
7007
|
);
|
|
6932
7008
|
UserConnectablePortsConfigurator.configure(
|
|
6933
7009
|
canvas,
|