@flowgram.ai/free-layout-core 0.2.19 → 0.2.21
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/esm/index.js +12 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -137,6 +137,8 @@ declare class WorkflowDragService {
|
|
|
137
137
|
resetLine(line: WorkflowLineEntity, e: MouseEvent): Promise<void>;
|
|
138
138
|
/** 线条拖拽结束 */
|
|
139
139
|
onDragLineEnd(callback: OnDragLineEnd): Disposable;
|
|
140
|
+
/** 获取最近的 port */
|
|
141
|
+
private getNearestPort;
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
type PositionMap = Record<string, IPoint>;
|
package/dist/index.d.ts
CHANGED
|
@@ -137,6 +137,8 @@ declare class WorkflowDragService {
|
|
|
137
137
|
resetLine(line: WorkflowLineEntity, e: MouseEvent): Promise<void>;
|
|
138
138
|
/** 线条拖拽结束 */
|
|
139
139
|
onDragLineEnd(callback: OnDragLineEnd): Disposable;
|
|
140
|
+
/** 获取最近的 port */
|
|
141
|
+
private getNearestPort;
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
type PositionMap = Record<string, IPoint>;
|
package/dist/index.js
CHANGED
|
@@ -2797,12 +2797,8 @@ var WorkflowDragService = class {
|
|
|
2797
2797
|
type: "onDrag"
|
|
2798
2798
|
});
|
|
2799
2799
|
this.setLineColor(line, this.linesManager.lineColor.drawing);
|
|
2800
|
-
if (toNode
|
|
2801
|
-
|
|
2802
|
-
const { inputPorts } = portsData;
|
|
2803
|
-
if (inputPorts.length === 1) {
|
|
2804
|
-
toPort = inputPorts[0];
|
|
2805
|
-
}
|
|
2800
|
+
if (toNode) {
|
|
2801
|
+
toPort = this.getNearestPort(toNode, dragPos);
|
|
2806
2802
|
const { hasError } = this.handleDragOnNode(toNode, fromPort, line, toPort, originLine);
|
|
2807
2803
|
lineErrorReset = hasError;
|
|
2808
2804
|
}
|
|
@@ -2910,6 +2906,16 @@ var WorkflowDragService = class {
|
|
|
2910
2906
|
}
|
|
2911
2907
|
};
|
|
2912
2908
|
}
|
|
2909
|
+
/** 获取最近的 port */
|
|
2910
|
+
getNearestPort(node, mousePos) {
|
|
2911
|
+
const portsData = node.getData(WorkflowNodePortsData);
|
|
2912
|
+
const distanceSortedPorts = portsData.inputPorts.sort((a, b) => {
|
|
2913
|
+
const aDistance = Math.abs(mousePos.y - a.point.y);
|
|
2914
|
+
const bDistance = Math.abs(mousePos.y - b.point.y);
|
|
2915
|
+
return aDistance - bDistance;
|
|
2916
|
+
});
|
|
2917
|
+
return distanceSortedPorts[0];
|
|
2918
|
+
}
|
|
2913
2919
|
};
|
|
2914
2920
|
__decorateClass([
|
|
2915
2921
|
(0, import_inversify6.inject)(import_core15.PlaygroundConfigEntity)
|