@flowgram.ai/free-layout-core 0.2.17 → 0.2.18
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 +37 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +21 -15
- package/dist/index.js.map +1 -1
- package/dist/typings/index.d.mts +1 -1
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/workflow-drag.d.mts +1 -1
- package/dist/typings/workflow-drag.d.ts +1 -1
- package/dist/typings/workflow-json.d.mts +1 -1
- package/dist/typings/workflow-json.d.ts +1 -1
- package/dist/typings/workflow-line.d.mts +1 -1
- package/dist/typings/workflow-line.d.ts +1 -1
- package/dist/typings/workflow-node.d.mts +1 -1
- package/dist/typings/workflow-node.d.ts +1 -1
- package/dist/typings/workflow-registry.d.mts +1 -1
- package/dist/typings/workflow-registry.d.ts +1 -1
- package/dist/{workflow-line-entity-D4-erSyq.d.ts → workflow-line-entity-BUokXoMi.d.ts} +3 -0
- package/dist/{workflow-line-entity-BpFc2Mu3.d.mts → workflow-line-entity-BuRLWUuf.d.mts} +3 -0
- package/package.json +9 -9
package/dist/esm/index.js
CHANGED
|
@@ -694,6 +694,7 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
694
694
|
super(opts);
|
|
695
695
|
this._processing = false;
|
|
696
696
|
this._hasError = false;
|
|
697
|
+
this.stackIndex = 0;
|
|
697
698
|
/**
|
|
698
699
|
* 线条数据
|
|
699
700
|
*/
|
|
@@ -1134,7 +1135,7 @@ import {
|
|
|
1134
1135
|
MouseTouchEvent,
|
|
1135
1136
|
PlaygroundConfigEntity as PlaygroundConfigEntity5,
|
|
1136
1137
|
PlaygroundDrag,
|
|
1137
|
-
TransformData as
|
|
1138
|
+
TransformData as TransformData8
|
|
1138
1139
|
} from "@flowgram.ai/core";
|
|
1139
1140
|
|
|
1140
1141
|
// src/workflow-lines-manager.ts
|
|
@@ -1142,7 +1143,7 @@ import { last } from "lodash-es";
|
|
|
1142
1143
|
import { inject as inject3, injectable as injectable3 } from "inversify";
|
|
1143
1144
|
import { DisposableCollection, Emitter as Emitter3 } from "@flowgram.ai/utils";
|
|
1144
1145
|
import { FlowNodeRenderData as FlowNodeRenderData2, FlowNodeTransformData as FlowNodeTransformData3 } from "@flowgram.ai/document";
|
|
1145
|
-
import { EntityManager as EntityManager2, PlaygroundConfigEntity as PlaygroundConfigEntity2
|
|
1146
|
+
import { EntityManager as EntityManager2, PlaygroundConfigEntity as PlaygroundConfigEntity2 } from "@flowgram.ai/core";
|
|
1146
1147
|
|
|
1147
1148
|
// src/workflow-document-option.ts
|
|
1148
1149
|
import { FlowNodeErrorData } from "@flowgram.ai/form-core";
|
|
@@ -1489,7 +1490,8 @@ var WorkflowLinesManager = class {
|
|
|
1489
1490
|
const allPorts = this.entityManager.getEntities(WorkflowPortEntity).filter((port) => port.node.flowNodeType !== "root");
|
|
1490
1491
|
const targetPort = allPorts.find((port) => port.isHovered(pos.x, pos.y));
|
|
1491
1492
|
if (targetPort) {
|
|
1492
|
-
const
|
|
1493
|
+
const containNodes = this.getContainNodesFromMousePos(pos);
|
|
1494
|
+
const targetNode = last(containNodes);
|
|
1493
1495
|
if (targetNode && targetNode !== targetPort.node) {
|
|
1494
1496
|
return;
|
|
1495
1497
|
}
|
|
@@ -1501,16 +1503,8 @@ var WorkflowLinesManager = class {
|
|
|
1501
1503
|
* @param pos - 鼠标位置
|
|
1502
1504
|
*/
|
|
1503
1505
|
getNodeFromMousePos(pos) {
|
|
1504
|
-
const allNodes = this.document.getAllNodes().sort((a, b) => this.getNodeIndex(a) - this.getNodeIndex(b));
|
|
1505
|
-
const containNodes = [];
|
|
1506
1506
|
const { selection } = this.selectService;
|
|
1507
|
-
const
|
|
1508
|
-
allNodes.forEach((node) => {
|
|
1509
|
-
const { bounds } = node.getData(FlowNodeTransformData3);
|
|
1510
|
-
if (bounds.clone().pad(4 / zoom).contains(pos.x, pos.y)) {
|
|
1511
|
-
containNodes.push(node);
|
|
1512
|
-
}
|
|
1513
|
-
});
|
|
1507
|
+
const containNodes = this.getContainNodesFromMousePos(pos);
|
|
1514
1508
|
if (selection?.length) {
|
|
1515
1509
|
const filteredNodes = containNodes.filter(
|
|
1516
1510
|
(node) => selection.some((_node) => node.id === _node.id)
|
|
@@ -1528,6 +1522,18 @@ var WorkflowLinesManager = class {
|
|
|
1528
1522
|
registerData(line) {
|
|
1529
1523
|
line.addData(WorkflowLineRenderData);
|
|
1530
1524
|
}
|
|
1525
|
+
/** 获取鼠标坐标位置的所有节点(stackIndex 从小到大排序) */
|
|
1526
|
+
getContainNodesFromMousePos(pos) {
|
|
1527
|
+
const allNodes = this.document.getAllNodes().sort((a, b) => this.getNodeIndex(a) - this.getNodeIndex(b));
|
|
1528
|
+
const zoom = this.entityManager.getEntity(PlaygroundConfigEntity2)?.config?.zoom || 1;
|
|
1529
|
+
const containNodes = allNodes.map((node) => {
|
|
1530
|
+
const { bounds } = node.getData(FlowNodeTransformData3);
|
|
1531
|
+
if (bounds.clone().pad(4 / zoom).contains(pos.x, pos.y)) {
|
|
1532
|
+
return node;
|
|
1533
|
+
}
|
|
1534
|
+
}).filter(Boolean);
|
|
1535
|
+
return containNodes;
|
|
1536
|
+
}
|
|
1531
1537
|
getNodeIndex(node) {
|
|
1532
1538
|
const nodeRenderData = node.getData(FlowNodeRenderData2);
|
|
1533
1539
|
return nodeRenderData.stackIndex;
|
|
@@ -1563,7 +1569,7 @@ import {
|
|
|
1563
1569
|
injectPlaygroundContext,
|
|
1564
1570
|
PlaygroundConfigEntity as PlaygroundConfigEntity4,
|
|
1565
1571
|
PositionData,
|
|
1566
|
-
TransformData as
|
|
1572
|
+
TransformData as TransformData7
|
|
1567
1573
|
} from "@flowgram.ai/core";
|
|
1568
1574
|
|
|
1569
1575
|
// src/layout/free-layout.ts
|
|
@@ -1577,7 +1583,7 @@ import {
|
|
|
1577
1583
|
FlowDocumentProvider,
|
|
1578
1584
|
FlowNodeTransformData as FlowNodeTransformData4
|
|
1579
1585
|
} from "@flowgram.ai/document";
|
|
1580
|
-
import { PlaygroundConfigEntity as PlaygroundConfigEntity3, TransformData as
|
|
1586
|
+
import { PlaygroundConfigEntity as PlaygroundConfigEntity3, TransformData as TransformData6 } from "@flowgram.ai/core";
|
|
1581
1587
|
var FREE_LAYOUT_KEY = "free-layout";
|
|
1582
1588
|
var FreeLayout = class {
|
|
1583
1589
|
constructor() {
|
|
@@ -1645,7 +1651,7 @@ var FreeLayout = class {
|
|
|
1645
1651
|
*/
|
|
1646
1652
|
getInitScroll(contentSize) {
|
|
1647
1653
|
const bounds = Rectangle7.enlarge(
|
|
1648
|
-
this.document.getAllNodes().map((node) => node.getData(
|
|
1654
|
+
this.document.getAllNodes().map((node) => node.getData(TransformData6).bounds)
|
|
1649
1655
|
).pad(30, 30);
|
|
1650
1656
|
const viewport = this.playgroundConfig.getViewport(false);
|
|
1651
1657
|
const zoom = SizeSchema2.fixSize(bounds, viewport);
|
|
@@ -1658,13 +1664,13 @@ var FreeLayout = class {
|
|
|
1658
1664
|
* 获取默认输入点
|
|
1659
1665
|
*/
|
|
1660
1666
|
getDefaultInputPoint(node) {
|
|
1661
|
-
return node.getData(
|
|
1667
|
+
return node.getData(TransformData6).bounds.leftCenter;
|
|
1662
1668
|
}
|
|
1663
1669
|
/**
|
|
1664
1670
|
* 获取默认输出点
|
|
1665
1671
|
*/
|
|
1666
1672
|
getDefaultOutputPoint(node) {
|
|
1667
|
-
return node.getData(
|
|
1673
|
+
return node.getData(TransformData6).bounds.rightCenter;
|
|
1668
1674
|
}
|
|
1669
1675
|
/**
|
|
1670
1676
|
* 水平中心点
|
|
@@ -1818,7 +1824,7 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1818
1824
|
if (!position) {
|
|
1819
1825
|
position = this.getNodeDefaultPosition(json.type);
|
|
1820
1826
|
}
|
|
1821
|
-
node.getData(
|
|
1827
|
+
node.getData(TransformData7).update({
|
|
1822
1828
|
position
|
|
1823
1829
|
});
|
|
1824
1830
|
if (formMeta && formData && !formData.formModel.initialized) {
|
|
@@ -1877,7 +1883,7 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1877
1883
|
);
|
|
1878
1884
|
}
|
|
1879
1885
|
if (subCanvas) {
|
|
1880
|
-
const canvasTransform = subCanvas.canvasNode.getData(
|
|
1886
|
+
const canvasTransform = subCanvas.canvasNode.getData(TransformData7);
|
|
1881
1887
|
canvasTransform.update({
|
|
1882
1888
|
position: subCanvas.parentNode.getNodeMeta()?.canvasPosition
|
|
1883
1889
|
});
|
|
@@ -2346,7 +2352,7 @@ var WorkflowDragService = class {
|
|
|
2346
2352
|
}
|
|
2347
2353
|
let startPosition = this.getNodesPosition(selectedNodes);
|
|
2348
2354
|
let startPositions = selectedNodes.map((node) => {
|
|
2349
|
-
const transform = node.getData(
|
|
2355
|
+
const transform = node.getData(TransformData8);
|
|
2350
2356
|
return { x: transform.position.x, y: transform.position.y };
|
|
2351
2357
|
});
|
|
2352
2358
|
let dragSuccess = false;
|
|
@@ -2373,7 +2379,7 @@ var WorkflowDragService = class {
|
|
|
2373
2379
|
});
|
|
2374
2380
|
const positions = [];
|
|
2375
2381
|
selectedNodes.forEach((node, index) => {
|
|
2376
|
-
const transform = node.getData(
|
|
2382
|
+
const transform = node.getData(TransformData8);
|
|
2377
2383
|
const nodeStartPosition = startPositions[index];
|
|
2378
2384
|
const newPosition = {
|
|
2379
2385
|
x: nodeStartPosition.x + offset.x,
|
|
@@ -2507,7 +2513,7 @@ var WorkflowDragService = class {
|
|
|
2507
2513
|
/**
|
|
2508
2514
|
* 如果存在容器节点,且传入鼠标坐标,需要用容器的坐标减去传入的鼠标坐标
|
|
2509
2515
|
*/
|
|
2510
|
-
adjustSubNodePosition(subNodeType, containerNode, mousePos
|
|
2516
|
+
adjustSubNodePosition(subNodeType, containerNode, mousePos) {
|
|
2511
2517
|
if (!mousePos) {
|
|
2512
2518
|
return { x: 0, y: 0 };
|
|
2513
2519
|
}
|
|
@@ -2516,16 +2522,16 @@ var WorkflowDragService = class {
|
|
|
2516
2522
|
}
|
|
2517
2523
|
const isParentEmpty = !containerNode.children || containerNode.children.length === 0;
|
|
2518
2524
|
const parentPadding = this.document.layout.getPadding(containerNode);
|
|
2519
|
-
const
|
|
2520
|
-
if (isParentEmpty
|
|
2525
|
+
const containerWorldTransform = containerNode.transform.transform.worldTransform;
|
|
2526
|
+
if (isParentEmpty) {
|
|
2521
2527
|
return {
|
|
2522
2528
|
x: 0,
|
|
2523
2529
|
y: parentPadding.top
|
|
2524
2530
|
};
|
|
2525
2531
|
} else {
|
|
2526
2532
|
return {
|
|
2527
|
-
x: mousePos.x -
|
|
2528
|
-
y: mousePos.y -
|
|
2533
|
+
x: mousePos.x - containerWorldTransform.tx,
|
|
2534
|
+
y: mousePos.y - containerWorldTransform.ty
|
|
2529
2535
|
};
|
|
2530
2536
|
}
|
|
2531
2537
|
}
|
|
@@ -2898,11 +2904,11 @@ import { DisposableCollection as DisposableCollection3, Emitter as Emitter6 } fr
|
|
|
2898
2904
|
|
|
2899
2905
|
// src/utils/layout-to-positions.ts
|
|
2900
2906
|
import { FlowNodeTransformData as FlowNodeTransformData7 } from "@flowgram.ai/document";
|
|
2901
|
-
import { TransformData as
|
|
2907
|
+
import { TransformData as TransformData9, startTween } from "@flowgram.ai/core";
|
|
2902
2908
|
var layoutToPositions = async (nodes, nodePositionMap) => {
|
|
2903
2909
|
const newNodePositionMap = {};
|
|
2904
2910
|
nodes.forEach((node) => {
|
|
2905
|
-
const transform = node.getData(
|
|
2911
|
+
const transform = node.getData(TransformData9);
|
|
2906
2912
|
const nodeTransform = node.getData(FlowNodeTransformData7);
|
|
2907
2913
|
newNodePositionMap[node.id] = {
|
|
2908
2914
|
x: transform.position.x,
|
|
@@ -2916,7 +2922,7 @@ var layoutToPositions = async (nodes, nodePositionMap) => {
|
|
|
2916
2922
|
duration: 300,
|
|
2917
2923
|
onUpdate: (v) => {
|
|
2918
2924
|
nodes.forEach((node) => {
|
|
2919
|
-
const transform = node.getData(
|
|
2925
|
+
const transform = node.getData(TransformData9);
|
|
2920
2926
|
const deltaX = (nodePositionMap[node.id].x - transform.position.x) * v.d / 100;
|
|
2921
2927
|
const deltaY = (nodePositionMap[node.id].y - transform.bounds.height / 2 - transform.position.y) * v.d / 100;
|
|
2922
2928
|
transform.update({
|
|
@@ -3000,7 +3006,7 @@ WorkflowResetLayoutService = __decorateClass([
|
|
|
3000
3006
|
import { inject as inject8 } from "inversify";
|
|
3001
3007
|
import { Emitter as Emitter7 } from "@flowgram.ai/utils";
|
|
3002
3008
|
import { FlowOperationBaseServiceImpl } from "@flowgram.ai/document";
|
|
3003
|
-
import { TransformData as
|
|
3009
|
+
import { TransformData as TransformData10 } from "@flowgram.ai/core";
|
|
3004
3010
|
var WorkflowOperationBaseServiceImpl = class extends FlowOperationBaseServiceImpl {
|
|
3005
3011
|
constructor() {
|
|
3006
3012
|
super(...arguments);
|
|
@@ -3012,7 +3018,7 @@ var WorkflowOperationBaseServiceImpl = class extends FlowOperationBaseServiceImp
|
|
|
3012
3018
|
if (!node) {
|
|
3013
3019
|
return;
|
|
3014
3020
|
}
|
|
3015
|
-
const transformData = node.getData(
|
|
3021
|
+
const transformData = node.getData(TransformData10);
|
|
3016
3022
|
const oldPosition = {
|
|
3017
3023
|
x: transformData.position.x,
|
|
3018
3024
|
y: transformData.position.y
|