@flowgram.ai/free-layout-core 0.4.16 → 0.4.17
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 +47 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +47 -183
- package/dist/index.d.ts +47 -183
- package/dist/index.js +47 -12
- package/dist/index.js.map +1 -1
- package/dist/typings/index.d.mts +4 -5
- package/dist/typings/index.d.ts +4 -5
- package/dist/typings/workflow-drag.d.mts +1 -2
- package/dist/typings/workflow-drag.d.ts +1 -2
- package/dist/typings/workflow-json.d.mts +3 -4
- package/dist/typings/workflow-json.d.ts +3 -4
- package/dist/typings/workflow-line.d.mts +3 -4
- package/dist/typings/workflow-line.d.ts +3 -4
- package/dist/typings/workflow-node.d.mts +2 -3
- package/dist/typings/workflow-node.d.ts +2 -3
- package/dist/typings/workflow-registry.d.mts +3 -4
- package/dist/typings/workflow-registry.d.ts +3 -4
- package/dist/typings/workflow-sub-canvas.d.mts +6 -1
- package/dist/typings/workflow-sub-canvas.d.ts +6 -1
- package/dist/{workflow-line-entity-IbhMSbBs.d.mts → workflow-node-entity-DtPEYn6-.d.mts} +377 -212
- package/dist/{workflow-line-entity-DcecHiNc.d.ts → workflow-node-entity-GyY_PHY6.d.ts} +377 -212
- package/package.json +9 -9
- package/dist/workflow-sub-canvas-IQzlYvPD.d.mts +0 -25
- package/dist/workflow-sub-canvas-IQzlYvPD.d.ts +0 -25
package/dist/esm/index.js
CHANGED
|
@@ -776,11 +776,11 @@ var WorkflowLineRenderData = class extends EntityData3 {
|
|
|
776
776
|
* WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
|
|
777
777
|
*/
|
|
778
778
|
updatePosition() {
|
|
779
|
-
this.data.position.from = this.entity.from.
|
|
779
|
+
this.data.position.from = this.entity.from.ports.getOutputPoint(this.entity.info.fromPort);
|
|
780
780
|
if (this.entity.info.drawingTo) {
|
|
781
781
|
this.data.position.to = this.entity.info.drawingTo;
|
|
782
782
|
} else {
|
|
783
|
-
this.data.position.to = this.entity.to?.
|
|
783
|
+
this.data.position.to = this.entity.to?.ports?.getInputPoint(this.entity.info.toPort) ?? {
|
|
784
784
|
x: this.data.position.from.x,
|
|
785
785
|
y: this.data.position.from.y,
|
|
786
786
|
location: this.data.position.from.location === "right" ? "left" : "top"
|
|
@@ -1042,13 +1042,13 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
1042
1042
|
return this.getData(WorkflowLineRenderData).calcDistance(pos);
|
|
1043
1043
|
}
|
|
1044
1044
|
get fromPort() {
|
|
1045
|
-
return this.from.
|
|
1045
|
+
return this.from.ports.getPortEntityByKey("output", this.info.fromPort);
|
|
1046
1046
|
}
|
|
1047
1047
|
get toPort() {
|
|
1048
1048
|
if (!this.to) {
|
|
1049
1049
|
return void 0;
|
|
1050
1050
|
}
|
|
1051
|
-
return this.to.
|
|
1051
|
+
return this.to.ports.getPortEntityByKey("input", this.info.toPort);
|
|
1052
1052
|
}
|
|
1053
1053
|
/**
|
|
1054
1054
|
* 获取线条真实的输入输出节点坐标
|
|
@@ -1726,7 +1726,7 @@ var WorkflowLinesManager = class {
|
|
|
1726
1726
|
*/
|
|
1727
1727
|
getPortFromMousePos(pos) {
|
|
1728
1728
|
const allNodes = this.getSortedNodes().reverse();
|
|
1729
|
-
const allPorts = allNodes.map((node) => node.
|
|
1729
|
+
const allPorts = allNodes.map((node) => node.ports.allPorts).flat();
|
|
1730
1730
|
const targetPort = allPorts.find((port) => port.isHovered(pos.x, pos.y));
|
|
1731
1731
|
if (targetPort) {
|
|
1732
1732
|
const containNodes = this.getContainNodesFromMousePos(pos);
|
|
@@ -2183,6 +2183,8 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
2183
2183
|
});
|
|
2184
2184
|
const datas = dataRegistries ? this.nodeDataRegistries.concat(...dataRegistries) : this.nodeDataRegistries;
|
|
2185
2185
|
node.addInitializeData(datas);
|
|
2186
|
+
node.ports = node.getData(WorkflowNodePortsData);
|
|
2187
|
+
node.lines = node.getData(WorkflowNodeLinesData);
|
|
2186
2188
|
node.onDispose(() => this.onNodeDisposeEmitter.fire({ node }));
|
|
2187
2189
|
this.options.fromNodeJSON?.(node, data, true);
|
|
2188
2190
|
isNew = true;
|
|
@@ -2633,10 +2635,6 @@ var WorkflowDragService = class {
|
|
|
2633
2635
|
return Promise.resolve(false);
|
|
2634
2636
|
}
|
|
2635
2637
|
this.isDragging = true;
|
|
2636
|
-
const sameParent = this.childrenOfContainer(selectedNodes);
|
|
2637
|
-
if (sameParent && sameParent.flowNodeType !== FlowNodeBaseType3.ROOT) {
|
|
2638
|
-
selectedNodes = [sameParent];
|
|
2639
|
-
}
|
|
2640
2638
|
let startPosition = this.getNodesPosition(selectedNodes);
|
|
2641
2639
|
let startPositions = selectedNodes.map((node) => {
|
|
2642
2640
|
const transform = node.getData(TransformData8);
|
|
@@ -2698,6 +2696,7 @@ var WorkflowDragService = class {
|
|
|
2698
2696
|
triggerEvent,
|
|
2699
2697
|
dragger
|
|
2700
2698
|
});
|
|
2699
|
+
this.resetContainerInternalPosition(selectedNodes);
|
|
2701
2700
|
}
|
|
2702
2701
|
});
|
|
2703
2702
|
const { clientX, clientY } = MouseTouchEvent.getEventCoord(triggerEvent);
|
|
@@ -2968,12 +2967,48 @@ var WorkflowDragService = class {
|
|
|
2968
2967
|
};
|
|
2969
2968
|
}
|
|
2970
2969
|
}
|
|
2970
|
+
/**
|
|
2971
|
+
* 容器内子节点总体位置重置为0
|
|
2972
|
+
*/
|
|
2973
|
+
resetContainerInternalPosition(nodes) {
|
|
2974
|
+
const container = this.childrenOfContainer(nodes);
|
|
2975
|
+
if (!container) {
|
|
2976
|
+
return;
|
|
2977
|
+
}
|
|
2978
|
+
const bounds = Rectangle8.enlarge(
|
|
2979
|
+
container.blocks.map((node) => {
|
|
2980
|
+
const x = node.transform.position.x - node.transform.bounds.width / 2;
|
|
2981
|
+
const y = node.transform.position.y;
|
|
2982
|
+
const width = node.transform.bounds.width;
|
|
2983
|
+
const height = node.transform.bounds.height;
|
|
2984
|
+
return new Rectangle8(x, y, width, height);
|
|
2985
|
+
})
|
|
2986
|
+
);
|
|
2987
|
+
const containerTransform = container.getData(TransformData8);
|
|
2988
|
+
containerTransform.update({
|
|
2989
|
+
position: {
|
|
2990
|
+
x: containerTransform.position.x + bounds.x,
|
|
2991
|
+
y: containerTransform.position.y + bounds.y
|
|
2992
|
+
}
|
|
2993
|
+
});
|
|
2994
|
+
this.document.layout.updateAffectedTransform(container);
|
|
2995
|
+
container.blocks.forEach((node) => {
|
|
2996
|
+
const transform = node.getData(TransformData8);
|
|
2997
|
+
transform.update({
|
|
2998
|
+
position: {
|
|
2999
|
+
x: transform.position.x - bounds.x,
|
|
3000
|
+
y: transform.position.y - bounds.y
|
|
3001
|
+
}
|
|
3002
|
+
});
|
|
3003
|
+
this.document.layout.updateAffectedTransform(node);
|
|
3004
|
+
});
|
|
3005
|
+
}
|
|
2971
3006
|
childrenOfContainer(nodes) {
|
|
2972
3007
|
if (nodes.length === 0) {
|
|
2973
3008
|
return;
|
|
2974
3009
|
}
|
|
2975
3010
|
const sourceContainer = nodes[0]?.parent;
|
|
2976
|
-
if (!sourceContainer
|
|
3011
|
+
if (!sourceContainer) {
|
|
2977
3012
|
return;
|
|
2978
3013
|
}
|
|
2979
3014
|
const valid = nodes.every((node) => node?.parent === sourceContainer);
|
|
@@ -3174,7 +3209,7 @@ var WorkflowDragService = class {
|
|
|
3174
3209
|
}
|
|
3175
3210
|
/** 获取最近的 port */
|
|
3176
3211
|
getNearestPort(node, mousePos) {
|
|
3177
|
-
const portsData = node.
|
|
3212
|
+
const portsData = node.ports;
|
|
3178
3213
|
const distanceSortedPorts = portsData.inputPorts.sort((a, b) => {
|
|
3179
3214
|
const aDistance = Math.abs(mousePos.y - a.point.y);
|
|
3180
3215
|
const bDistance = Math.abs(mousePos.y - b.point.y);
|
|
@@ -3379,7 +3414,7 @@ var isFirefox = navigator?.userAgent?.includes?.("Firefox");
|
|
|
3379
3414
|
function useNodeRender(nodeFromProps) {
|
|
3380
3415
|
const node = nodeFromProps || useContext(PlaygroundEntityContext);
|
|
3381
3416
|
const renderData = node.getData(FlowNodeRenderData3);
|
|
3382
|
-
const portsData = node.
|
|
3417
|
+
const portsData = node.ports;
|
|
3383
3418
|
const readonly = usePlaygroundReadonlyState();
|
|
3384
3419
|
const dragService = useService(WorkflowDragService);
|
|
3385
3420
|
const selectionService = useService(WorkflowSelectService);
|