orcasvn-react-diagrams 0.1.33 → 0.1.34
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/cjs/index.js +125 -99
- package/dist/cjs/types/utils/elementLinkUtil.d.ts +2 -0
- package/dist/cjs/types/utils/positionUtil.d.ts +1 -0
- package/dist/esm/index.js +125 -99
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/elementLinkUtil.d.ts +2 -0
- package/dist/esm/types/utils/positionUtil.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -7621,13 +7621,15 @@ var generateSubstitutePosition = function (intersectedPosition, targetPosition,
|
|
|
7621
7621
|
};
|
|
7622
7622
|
}
|
|
7623
7623
|
else {
|
|
7624
|
+
//Translate to the left of vertex 1
|
|
7624
7625
|
var leftPosition = {
|
|
7625
|
-
x:
|
|
7626
|
-
y:
|
|
7626
|
+
x: vertex1Position.x - translationOffset,
|
|
7627
|
+
y: vertex1Position.y,
|
|
7627
7628
|
};
|
|
7629
|
+
//Translate to the right of vertex 2
|
|
7628
7630
|
var rightPosition = {
|
|
7629
|
-
x:
|
|
7630
|
-
y:
|
|
7631
|
+
x: vertex2Position.x + translationOffset,
|
|
7632
|
+
y: vertex2Position.y,
|
|
7631
7633
|
};
|
|
7632
7634
|
replacementPosition = findNearestPosition([leftPosition, rightPosition], targetPosition);
|
|
7633
7635
|
}
|
|
@@ -7644,13 +7646,15 @@ var generateSubstitutePosition = function (intersectedPosition, targetPosition,
|
|
|
7644
7646
|
};
|
|
7645
7647
|
}
|
|
7646
7648
|
else {
|
|
7649
|
+
//Translate to the left of vertex 4
|
|
7647
7650
|
var leftPosition = {
|
|
7648
|
-
x:
|
|
7649
|
-
y:
|
|
7651
|
+
x: vertex4Position.x - translationOffset,
|
|
7652
|
+
y: vertex4Position.y,
|
|
7650
7653
|
};
|
|
7654
|
+
//Translate to the right of vertex 3
|
|
7651
7655
|
var rightPosition = {
|
|
7652
|
-
x:
|
|
7653
|
-
y:
|
|
7656
|
+
x: vertex3Position.x + translationOffset,
|
|
7657
|
+
y: vertex3Position.y,
|
|
7654
7658
|
};
|
|
7655
7659
|
replacementPosition = findNearestPosition([leftPosition, rightPosition], targetPosition);
|
|
7656
7660
|
}
|
|
@@ -7667,13 +7671,15 @@ var generateSubstitutePosition = function (intersectedPosition, targetPosition,
|
|
|
7667
7671
|
};
|
|
7668
7672
|
}
|
|
7669
7673
|
else {
|
|
7674
|
+
//Translate to the top of vertex 1
|
|
7670
7675
|
var topPosition = {
|
|
7671
|
-
x:
|
|
7672
|
-
y:
|
|
7676
|
+
x: vertex1Position.x,
|
|
7677
|
+
y: vertex1Position.y - translationOffset,
|
|
7673
7678
|
};
|
|
7679
|
+
//Translate to the bottom of vertex 4
|
|
7674
7680
|
var bottomPosition = {
|
|
7675
|
-
x:
|
|
7676
|
-
y:
|
|
7681
|
+
x: vertex4Position.x,
|
|
7682
|
+
y: vertex4Position.y + translationOffset,
|
|
7677
7683
|
};
|
|
7678
7684
|
replacementPosition = findNearestPosition([topPosition, bottomPosition], targetPosition);
|
|
7679
7685
|
}
|
|
@@ -7690,13 +7696,15 @@ var generateSubstitutePosition = function (intersectedPosition, targetPosition,
|
|
|
7690
7696
|
};
|
|
7691
7697
|
}
|
|
7692
7698
|
else {
|
|
7699
|
+
//Translate to the top of vertex 2
|
|
7693
7700
|
var topPosition = {
|
|
7694
|
-
x:
|
|
7695
|
-
y:
|
|
7701
|
+
x: vertex2Position.x,
|
|
7702
|
+
y: vertex2Position.y - translationOffset,
|
|
7696
7703
|
};
|
|
7704
|
+
//Translate to the bottom of vertex 3
|
|
7697
7705
|
var bottomPosition = {
|
|
7698
|
-
x:
|
|
7699
|
-
y:
|
|
7706
|
+
x: vertex3Position.x,
|
|
7707
|
+
y: vertex3Position.y + translationOffset,
|
|
7700
7708
|
};
|
|
7701
7709
|
replacementPosition = findNearestPosition([topPosition, bottomPosition], targetPosition);
|
|
7702
7710
|
}
|
|
@@ -7711,23 +7719,38 @@ var getRelativePosition = function (clientPosition, relativeElement) {
|
|
|
7711
7719
|
};
|
|
7712
7720
|
};
|
|
7713
7721
|
var getFourVertexesOfBBoxFromElement = function (element) {
|
|
7722
|
+
var absolutePosition = getAbsolutePosition(element);
|
|
7714
7723
|
var vertex1Position = {
|
|
7715
|
-
x:
|
|
7716
|
-
y:
|
|
7724
|
+
x: absolutePosition.x,
|
|
7725
|
+
y: absolutePosition.y
|
|
7717
7726
|
};
|
|
7718
7727
|
var vertex2Position = {
|
|
7719
|
-
x:
|
|
7720
|
-
y:
|
|
7728
|
+
x: absolutePosition.x + element.size.width,
|
|
7729
|
+
y: absolutePosition.y
|
|
7721
7730
|
};
|
|
7722
7731
|
var vertex3Position = {
|
|
7723
|
-
x:
|
|
7724
|
-
y:
|
|
7732
|
+
x: absolutePosition.x + element.size.width,
|
|
7733
|
+
y: absolutePosition.y + element.size.height
|
|
7725
7734
|
};
|
|
7726
7735
|
var vertex4Position = {
|
|
7727
|
-
x:
|
|
7728
|
-
y:
|
|
7736
|
+
x: absolutePosition.x,
|
|
7737
|
+
y: absolutePosition.y + element.size.height
|
|
7729
7738
|
};
|
|
7730
7739
|
return [vertex1Position, vertex2Position, vertex3Position, vertex4Position];
|
|
7740
|
+
};
|
|
7741
|
+
//get absolute position of element
|
|
7742
|
+
var getAbsolutePosition = function (element) {
|
|
7743
|
+
var parentElement = element.parentElement;
|
|
7744
|
+
if (!parentElement) {
|
|
7745
|
+
return __assign({}, element.position);
|
|
7746
|
+
}
|
|
7747
|
+
var absoluteParentElement = getAbsolutePosition(parentElement);
|
|
7748
|
+
var x = element.position.x + absoluteParentElement.x;
|
|
7749
|
+
var y = element.position.y + absoluteParentElement.y;
|
|
7750
|
+
return {
|
|
7751
|
+
x: x,
|
|
7752
|
+
y: y,
|
|
7753
|
+
};
|
|
7731
7754
|
};
|
|
7732
7755
|
|
|
7733
7756
|
var makerStart = React.createElement("circle", { cx: 10, cy: 10, r: 10, fill: "blue" });
|
|
@@ -8728,6 +8751,59 @@ function useKeyboardCommands(_a) {
|
|
|
8728
8751
|
}, [element]);
|
|
8729
8752
|
}
|
|
8730
8753
|
|
|
8754
|
+
//Automatically add points on the link so that the link does not cross elements, default maximum 10 points
|
|
8755
|
+
var automationAddPointsToLink = function (eleLink, elements, limitPoint) {
|
|
8756
|
+
if (!eleLink.targetElement || !eleLink.targetPort) {
|
|
8757
|
+
throw new Error("Target element is not found in element link");
|
|
8758
|
+
}
|
|
8759
|
+
var sourceElement = eleLink.sourceElement, sourcePort = eleLink.sourcePort, targetElement = eleLink.targetElement, targetPort = eleLink.targetPort;
|
|
8760
|
+
var absolutePositionOfSourceEle = getAbsolutePosition(sourceElement);
|
|
8761
|
+
var absolutePositionOfTargetEle = getAbsolutePosition(targetElement);
|
|
8762
|
+
var sourcePosition = {
|
|
8763
|
+
x: absolutePositionOfSourceEle.x + sourcePort.position.x,
|
|
8764
|
+
y: absolutePositionOfSourceEle.y + sourcePort.position.y
|
|
8765
|
+
};
|
|
8766
|
+
var targetPosition = {
|
|
8767
|
+
x: absolutePositionOfTargetEle.x + targetPort.position.x,
|
|
8768
|
+
y: absolutePositionOfTargetEle.y + targetPort.position.y
|
|
8769
|
+
};
|
|
8770
|
+
var fourVertexesOfSourceEleBBox = getFourVertexesOfBBoxFromElement(sourceElement);
|
|
8771
|
+
var fourVertexesOfTargetEleBBox = getFourVertexesOfBBoxFromElement(targetElement);
|
|
8772
|
+
var projectedSourcePositionOnBBox = findNearestProjectedPoint(sourcePosition, [
|
|
8773
|
+
[fourVertexesOfSourceEleBBox[0], fourVertexesOfSourceEleBBox[1]],
|
|
8774
|
+
[fourVertexesOfSourceEleBBox[1], fourVertexesOfSourceEleBBox[2]],
|
|
8775
|
+
[fourVertexesOfSourceEleBBox[2], fourVertexesOfSourceEleBBox[3]],
|
|
8776
|
+
[fourVertexesOfSourceEleBBox[3], fourVertexesOfSourceEleBBox[0]],
|
|
8777
|
+
]);
|
|
8778
|
+
var projectedTargetPositionOnBBox = findNearestProjectedPoint(targetPosition, [
|
|
8779
|
+
[fourVertexesOfTargetEleBBox[0], fourVertexesOfTargetEleBBox[1]],
|
|
8780
|
+
[fourVertexesOfTargetEleBBox[1], fourVertexesOfTargetEleBBox[2]],
|
|
8781
|
+
[fourVertexesOfTargetEleBBox[2], fourVertexesOfTargetEleBBox[3]],
|
|
8782
|
+
[fourVertexesOfTargetEleBBox[3], fourVertexesOfTargetEleBBox[0]],
|
|
8783
|
+
]);
|
|
8784
|
+
var numberOfPoints = 0;
|
|
8785
|
+
//create points between the start and end points, to create a line segment that passes through the points without intersecting the elements
|
|
8786
|
+
function generatePositions(sourcePosition, targetPosition, elements) {
|
|
8787
|
+
var firstIntersection = getFirstIntersection(sourcePosition, targetPosition, elements);
|
|
8788
|
+
//If there is no intersection point, then the line connecting the two points does not intersect any element.
|
|
8789
|
+
if (!firstIntersection || limitPoint === numberOfPoints)
|
|
8790
|
+
return [];
|
|
8791
|
+
var nearestIntersection = firstIntersection.nearestIntersection; firstIntersection.intersectionPointsList; var intersectedElement = firstIntersection.element;
|
|
8792
|
+
//Calculate to create a replacement point
|
|
8793
|
+
var replacementPosition = generateSubstitutePosition(nearestIntersection, targetPosition, intersectedElement);
|
|
8794
|
+
//Increases the number of points found by 1
|
|
8795
|
+
numberOfPoints += 1;
|
|
8796
|
+
//Create points with the starting point being the sourcePosition and the ending point being the newly created point
|
|
8797
|
+
var prependedPoints = generatePositions(sourcePosition, replacementPosition, elements);
|
|
8798
|
+
//Create points with the starting point being the new newly created point and the ending point being the targetPosition
|
|
8799
|
+
var appendedPoints = generatePositions(replacementPosition, targetPosition, elements);
|
|
8800
|
+
return __spreadArray(__spreadArray(__spreadArray([], prependedPoints, true), [replacementPosition], false), appendedPoints, true);
|
|
8801
|
+
}
|
|
8802
|
+
var points = generatePositions(projectedSourcePositionOnBBox, projectedTargetPositionOnBBox, elements);
|
|
8803
|
+
eleLink.points = points;
|
|
8804
|
+
return eleLink;
|
|
8805
|
+
};
|
|
8806
|
+
|
|
8731
8807
|
function convertElementsToTree(elements) {
|
|
8732
8808
|
//Find child elements in the child elements, that is possible child of element, then return element with child of it.
|
|
8733
8809
|
function findChildElementsOfNode(elementNodeInTree, possibleChildElements) {
|
|
@@ -8738,11 +8814,11 @@ function convertElementsToTree(elements) {
|
|
|
8738
8814
|
var foundChildElements = possibleChildElements.filter(function (ele) { var _a; return ((_a = ele.parentElement) === null || _a === void 0 ? void 0 : _a.id) === elementNodeInTree.id; });
|
|
8739
8815
|
var orphanedElements = possibleChildElements.filter(function (ele) { var _a; return ((_a = ele.parentElement) === null || _a === void 0 ? void 0 : _a.id) !== elementNodeInTree.id; });
|
|
8740
8816
|
var childElementsWithChild = foundChildElements.map(function (_elementNodeInTree) {
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
}
|
|
8745
|
-
_elementNodeInTree.relativePosition = relativePosition;
|
|
8817
|
+
// const relativePosition = {
|
|
8818
|
+
// x: _elementNodeInTree.position.x - elementNodeInTree.position.x,
|
|
8819
|
+
// y: _elementNodeInTree.position.y - elementNodeInTree.position.y,
|
|
8820
|
+
// }
|
|
8821
|
+
// _elementNodeInTree.relativePosition = relativePosition;
|
|
8746
8822
|
var newNode = findChildElementsOfNode(_elementNodeInTree, orphanedElements);
|
|
8747
8823
|
return newNode;
|
|
8748
8824
|
});
|
|
@@ -8752,7 +8828,7 @@ function convertElementsToTree(elements) {
|
|
|
8752
8828
|
var parentElms = elements.filter(function (e) { return !e.parentElement; });
|
|
8753
8829
|
var childElms = elements.filter(function (e) { return e.parentElement; });
|
|
8754
8830
|
var parsedElementsInTree = parentElms.map(function (ele) {
|
|
8755
|
-
ele.relativePosition = ele.position;
|
|
8831
|
+
// ele.relativePosition = ele.position;
|
|
8756
8832
|
var eleWithChild = findChildElementsOfNode(ele, childElms);
|
|
8757
8833
|
return eleWithChild;
|
|
8758
8834
|
});
|
|
@@ -8938,57 +9014,6 @@ var Paper = function (props) {
|
|
|
8938
9014
|
listener.off();
|
|
8939
9015
|
};
|
|
8940
9016
|
}, [selectedText]);
|
|
8941
|
-
//Automatically add points on the link so that the link does not cross elements, default maximum 10 points
|
|
8942
|
-
var automationAddPointsToLink = React.useCallback(function (eleLink, limitPoint) {
|
|
8943
|
-
if (limitPoint === void 0) { limitPoint = 10; }
|
|
8944
|
-
if (!eleLink.targetElement) {
|
|
8945
|
-
throw new Error("Target element is not found in element link");
|
|
8946
|
-
}
|
|
8947
|
-
var sourceElement = eleLink.sourceElement, sourcePort = eleLink.sourcePort, targetElement = eleLink.targetElement, targetPort = eleLink.targetPort;
|
|
8948
|
-
var sourcePosition = {
|
|
8949
|
-
x: sourceElement.position.x + sourcePort.position.x,
|
|
8950
|
-
y: sourceElement.position.y + sourcePort.position.y
|
|
8951
|
-
};
|
|
8952
|
-
var targetPosition = {
|
|
8953
|
-
x: targetElement.position.x + targetPort.position.x,
|
|
8954
|
-
y: targetElement.position.y + targetPort.position.y
|
|
8955
|
-
};
|
|
8956
|
-
var fourVertexesOfSourceEleBBox = getFourVertexesOfBBoxFromElement(sourceElement);
|
|
8957
|
-
var fourVertexesOfTargetEleBBox = getFourVertexesOfBBoxFromElement(targetElement);
|
|
8958
|
-
var projectedSourcePositionOnBBox = findNearestProjectedPoint(sourcePosition, [
|
|
8959
|
-
[fourVertexesOfSourceEleBBox[0], fourVertexesOfSourceEleBBox[1]],
|
|
8960
|
-
[fourVertexesOfSourceEleBBox[1], fourVertexesOfSourceEleBBox[2]],
|
|
8961
|
-
[fourVertexesOfSourceEleBBox[2], fourVertexesOfSourceEleBBox[3]],
|
|
8962
|
-
[fourVertexesOfSourceEleBBox[3], fourVertexesOfSourceEleBBox[0]],
|
|
8963
|
-
]);
|
|
8964
|
-
var projectedTargetPositionOnBBox = findNearestProjectedPoint(targetPosition, [
|
|
8965
|
-
[fourVertexesOfTargetEleBBox[0], fourVertexesOfTargetEleBBox[1]],
|
|
8966
|
-
[fourVertexesOfTargetEleBBox[1], fourVertexesOfTargetEleBBox[2]],
|
|
8967
|
-
[fourVertexesOfTargetEleBBox[2], fourVertexesOfTargetEleBBox[3]],
|
|
8968
|
-
[fourVertexesOfTargetEleBBox[3], fourVertexesOfTargetEleBBox[0]],
|
|
8969
|
-
]);
|
|
8970
|
-
var numberOfPoints = 0;
|
|
8971
|
-
//create points between the start and end points, to create a line segment that passes through the points without intersecting the elements
|
|
8972
|
-
function generatePositions(sourcePosition, targetPosition, elements) {
|
|
8973
|
-
var firstIntersection = getFirstIntersection(sourcePosition, targetPosition, elements);
|
|
8974
|
-
//If there is no intersection point, then the line connecting the two points does not intersect any element.
|
|
8975
|
-
if (!firstIntersection || limitPoint === numberOfPoints)
|
|
8976
|
-
return [];
|
|
8977
|
-
var nearestIntersection = firstIntersection.nearestIntersection; firstIntersection.intersectionPointsList; var intersectedElement = firstIntersection.element;
|
|
8978
|
-
//Calculate to create a replacement point
|
|
8979
|
-
var replacementPosition = generateSubstitutePosition(nearestIntersection, targetPosition, intersectedElement);
|
|
8980
|
-
//Increases the number of points found by 1
|
|
8981
|
-
numberOfPoints += 1;
|
|
8982
|
-
//Create points with the starting point being the sourcePosition and the ending point being the newly created point
|
|
8983
|
-
var prependedPoints = generatePositions(sourcePosition, replacementPosition, elements);
|
|
8984
|
-
//Create points with the starting point being the new newly created point and the ending point being the targetPosition
|
|
8985
|
-
var appendedPoints = generatePositions(replacementPosition, targetPosition, elements);
|
|
8986
|
-
return __spreadArray(__spreadArray(__spreadArray([], prependedPoints, true), [replacementPosition], false), appendedPoints, true);
|
|
8987
|
-
}
|
|
8988
|
-
var elements = elementsRef.current;
|
|
8989
|
-
var points = generatePositions(projectedSourcePositionOnBBox, projectedTargetPositionOnBBox, elements);
|
|
8990
|
-
return __assign(__assign({}, eleLink), { points: points });
|
|
8991
|
-
}, []);
|
|
8992
9017
|
var handlePaperMouseMove = function (ev) {
|
|
8993
9018
|
var _a;
|
|
8994
9019
|
//if there is a temp link, update the temp target point
|
|
@@ -9121,10 +9146,11 @@ var Paper = function (props) {
|
|
|
9121
9146
|
return null;
|
|
9122
9147
|
//Automatic bending, if is not defined points
|
|
9123
9148
|
if (!newElementLink.points || newElementLink.points.length === 0) {
|
|
9124
|
-
|
|
9149
|
+
var elements_1 = elementsRef.current;
|
|
9150
|
+
newElementLink = automationAddPointsToLink(newElementLink, elements_1, MAX_LINK_KNOT_COUNT);
|
|
9125
9151
|
}
|
|
9126
9152
|
return newElementLink;
|
|
9127
|
-
}, [props.onCreatingLink
|
|
9153
|
+
}, [props.onCreatingLink]);
|
|
9128
9154
|
var handlePortMouseUp = React.useCallback(function (ev, port, elementId) {
|
|
9129
9155
|
var _a;
|
|
9130
9156
|
ev.stopPropagation();
|
|
@@ -9253,9 +9279,9 @@ var Paper = function (props) {
|
|
|
9253
9279
|
var updateElementPosition = function (element, movementX, movementY) {
|
|
9254
9280
|
element.position.x += movementX;
|
|
9255
9281
|
element.position.y += movementY;
|
|
9256
|
-
if (element.childrenElementsInTree && element.childrenElementsInTree.length > 0) {
|
|
9257
|
-
|
|
9258
|
-
}
|
|
9282
|
+
// if (element.childrenElementsInTree && element.childrenElementsInTree.length > 0) {
|
|
9283
|
+
// element.childrenElementsInTree = element.childrenElementsInTree.map(child => updateElementPosition(child, movementX, movementY));
|
|
9284
|
+
// }
|
|
9259
9285
|
return element;
|
|
9260
9286
|
};
|
|
9261
9287
|
//use selection frame
|
|
@@ -9274,10 +9300,10 @@ var Paper = function (props) {
|
|
|
9274
9300
|
return;
|
|
9275
9301
|
var oldPosition = __assign({}, selectedElement.position);
|
|
9276
9302
|
var newElementPosition = updateElementPosition(selectedElement, offsetX, offsetY);
|
|
9277
|
-
newElementPosition.relativePosition = {
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
}
|
|
9303
|
+
// newElementPosition.relativePosition = {
|
|
9304
|
+
// x: newElementPosition.relativePosition!.x + offsetX,
|
|
9305
|
+
// y: newElementPosition.relativePosition!.y + offsetY
|
|
9306
|
+
// }
|
|
9281
9307
|
var indexSelectedElement = elements.findIndex(function (e) { return e.id === selectedElement.id; });
|
|
9282
9308
|
//Set state to re-render UI with new position
|
|
9283
9309
|
setElementsInTree(function (prev) { return __spreadArray([], prev, true); });
|
|
@@ -9428,11 +9454,10 @@ var Paper = function (props) {
|
|
|
9428
9454
|
}
|
|
9429
9455
|
}, [props.onElementMouseLeave]);
|
|
9430
9456
|
var renderElementInTree = React.useCallback(function (element) {
|
|
9431
|
-
var _a, _b;
|
|
9432
9457
|
//use the defined react element or the default Element component
|
|
9433
9458
|
var ReactElement = element.reactElement || Element$1;
|
|
9434
9459
|
return (React.createElement("g", { id: "group-of-element-".concat(element.id), key: element.id },
|
|
9435
|
-
React.createElement(ReactElement, { key: "element-".concat(element.id), id: element.id, height: element.size.height, width: element.size.width, x:
|
|
9460
|
+
React.createElement(ReactElement, { key: "element-".concat(element.id), id: element.id, height: element.size.height, width: element.size.width, x: element.position.x, y: element.position.y, onClick: handleElementClicked, onContextMenu: handleContextMenu, onMouseUp: handleMouseUp, onMouseMove: handleMouseMove, onMouseLeave: handleMouseLeave, container: paperContainerRef.current, renderShape: element.renderShape, cssClass: element.cssClass, texts: element.texts, ports: element.ports, portMoveableAreas: element.portMoveableAreas, portSlideRailSVGClassName: element.portSlideRailSVGClassName, portDirection: element.portDirection, defaultPortSize: element.defaultPortSize, onPortMoved: handlePortMoved, onPortMouseDown: handlePortMouseDown, onPortMouseUp: handlePortMouseUp,
|
|
9436
9461
|
// portPlaceholderShape={(<Circle x={0} y={0} width={10} height={10} fill='red' positioningAnchor={PositioningAnchor.Center} />)}
|
|
9437
9462
|
onMouseUpAtLinkedPortPlaceholder: handleMouseUpAtLinkedPortPlaceholder, onTextUpdated: handleElementTextChange, onManuallyTriggerRenderPort: props.onManuallyTriggerRenderPort, textsPlaceHolderClassName: element.textsPlaceHolderClassName, textsPlaceHolderFlexStyle: element.textsPlaceHolderFlexStyle, textsPlaceHolderFlexboxPosition: element.textsPlaceHolderFlexboxPosition }, element.childrenElementsInTree && element.childrenElementsInTree.map(renderElementInTree))));
|
|
9438
9463
|
}, [handleElementClicked, handleContextMenu, handlePortMoved, handlePortMouseDown, handlePortMouseUp, handleMouseUpAtLinkedPortPlaceholder, handleElementTextChange, handleMouseUp, handleMouseMove, handleMouseLeave]);
|
|
@@ -9452,18 +9477,19 @@ var Paper = function (props) {
|
|
|
9452
9477
|
React.createElement("svg", { tabIndex: 0, width: size.width, height: size.height, ref: paperContainerRef, id: "paper-container", onMouseMove: handlePaperMouseMove, onMouseDown: handleMouseDownOnPaper, onMouseUp: handleMouseUpOnPaper },
|
|
9453
9478
|
paperContainerRef.current ? ElementsInTree : "",
|
|
9454
9479
|
links && links.map(function (link, index) {
|
|
9455
|
-
|
|
9480
|
+
if (!link.targetElement || !link.targetPort)
|
|
9481
|
+
return null;
|
|
9456
9482
|
return (React.createElement(ElementLink, { key: link.id, id: link.id, path: link.path, sourcePosition: {
|
|
9457
|
-
x: link.sourceElement.
|
|
9458
|
-
y: link.sourceElement.
|
|
9483
|
+
x: getAbsolutePosition(link.sourceElement).x + link.sourcePort.position.x,
|
|
9484
|
+
y: getAbsolutePosition(link.sourceElement).y + link.sourcePort.position.y
|
|
9459
9485
|
}, targetPosition: {
|
|
9460
|
-
x: (
|
|
9461
|
-
y: (
|
|
9486
|
+
x: getAbsolutePosition(link.targetElement).x + link.targetPort.position.x,
|
|
9487
|
+
y: getAbsolutePosition(link.targetElement).y + link.targetPort.position.y
|
|
9462
9488
|
}, points: link.points, onPathChanged: handlePathChange, onClickDelete: handleClickLinkDelete(link, index), onSelected: function () { return handleSelectLink(link); }, onDeselected: function () { return handleDeselectLink(); }, container: paperContainerRef.current, markerStart: link.markerStart, markerEnd: link.markerEnd, markerDistanceFromPort: link.markerDistanceFromPort, markerSize: link.markerSize, label: link.label, sourceLabel: link.sourceLabel, targetLabel: link.targetLabel, onLabelMoved: onLabelMoved(index), onLabelResized: onLabelResized(index), onLabelContentChanged: onLabelContentChanged(index) }));
|
|
9463
9489
|
}),
|
|
9464
9490
|
(tempLink === null || tempLink === void 0 ? void 0 : tempLink.tempTargetPosition) && React.createElement(ElementLink, { id: tempLink.id, points: tempLink.points, sourcePosition: {
|
|
9465
|
-
x: tempLink.sourceElement.
|
|
9466
|
-
y: tempLink.sourceElement.
|
|
9491
|
+
x: getAbsolutePosition(tempLink.sourceElement).x + tempLink.sourcePort.position.x,
|
|
9492
|
+
y: getAbsolutePosition(tempLink.sourceElement).y + tempLink.sourcePort.position.y
|
|
9467
9493
|
}, targetPosition: tempLink.tempTargetPosition, container: paperContainerRef.current, markerStart: tempLink.markerStart, markerEnd: tempLink.markerEnd, markerDistanceFromPort: tempLink.markerDistanceFromPort, markerSize: tempLink.markerSize }),
|
|
9468
9494
|
texts.map(function (text, index) { return (React.createElement(Text$1, { key: text.id, id: text.id, x: text.position.x, y: text.position.y, width: text.size.width, height: text.size.height, editable: text.editable, fontSize: text.fontSize, border: text.border, container: paperContainerRef.current, content: text.content, align: text.align, onSelected: function () {
|
|
9469
9495
|
setSelectedText(text);
|
|
@@ -46,3 +46,4 @@ export declare const getFirstIntersection: (startPosition: IPosition, endPositio
|
|
|
46
46
|
export declare const generateSubstitutePosition: (intersectedPosition: IPosition, targetPosition: IPosition, ele: IElement) => IPosition;
|
|
47
47
|
export declare const getRelativePosition: (clientPosition: IPosition, relativeElement: Element) => IPosition;
|
|
48
48
|
export declare const getFourVertexesOfBBoxFromElement: (element: IElement) => IPosition[];
|
|
49
|
+
export declare const getAbsolutePosition: (element: IElement) => IPosition;
|