@flowgram.ai/free-layout-core 0.5.1 → 0.5.2
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/{chunk-O4WKIIW2.js → chunk-3UW6BHP2.js} +1 -1
- package/dist/esm/chunk-3UW6BHP2.js.map +1 -0
- package/dist/esm/index.js +102 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/typings/index.js +1 -1
- package/dist/esm/typings/workflow-operation.js +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +101 -30
- 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/index.js.map +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-operation.d.mts +9 -0
- package/dist/typings/workflow-operation.d.ts +9 -0
- package/dist/typings/workflow-operation.js.map +1 -1
- package/dist/typings/workflow-registry.d.mts +1 -1
- package/dist/typings/workflow-registry.d.ts +1 -1
- package/dist/typings/workflow-sub-canvas.d.mts +1 -1
- package/dist/typings/workflow-sub-canvas.d.ts +1 -1
- package/dist/{workflow-node-entity-lKu00Aj4.d.mts → workflow-node-entity-DgQT-wl9.d.mts} +16 -3
- package/dist/{workflow-node-entity-Cnte2phX.d.ts → workflow-node-entity-kGsp2Roz.d.ts} +16 -3
- package/package.json +9 -9
- package/dist/esm/chunk-O4WKIIW2.js.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import { PlaygroundConfigEntity, CommandService, PlaygroundDragEvent, EntityData
|
|
|
2
2
|
export { bindConfigEntity, useConfigEntity, useEntities, useEntityDataFromContext, useEntityFromContext, useListenEvents, usePlayground, usePlaygroundContainer, usePlaygroundContext, useRefresh, useService } from '@flowgram.ai/core';
|
|
3
3
|
import { NodeFormProps } from '@flowgram.ai/node';
|
|
4
4
|
import { FlowOperationBaseService, FlowNodeType, FlowOperationBaseServiceImpl, FlowNodeEntityOrId, FlowNodeEntity } from '@flowgram.ai/document';
|
|
5
|
-
import { W as WorkflowJSON, L as LineCenterPoint, a as WorkflowDocument, b as WorkflowNodeEntity, c as WorkflowHoverService, d as WorkflowLinesManager, e as WorkflowSelectService, f as WorkflowDocumentOptions, g as LineEventProps, N as NodesDragEvent, h as WorkflowNodeJSON, i as WorkflowPortEntity, j as WorkflowLineEntity, O as OnDragLineEnd, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-node-entity-
|
|
6
|
-
export { X as HoverPosition, F as LINE_HOVER_DISTANCE, x as LineColor, y as LineColors, w as LinePoint, v as LinePointLocation, u as LineType, C as NodesDragEndEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, P as POINT_RADIUS, K as PORT_SIZE, p as WORKFLOW_LINE_ENTITY, Y as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, _ as WorkflowDocumentOptionsDefault, Z as WorkflowDocumentProvider, V as WorkflowEntityHoverable, H as WorkflowLineEntityOpts, I as WorkflowLineInfo, G as WorkflowLinePortInfo, z as WorkflowLineRenderContributionFactory, J as WorkflowLineUIState, T as WorkflowNodeLines, U as WorkflowNodeLinesData, t as WorkflowNodeMeta, S as WorkflowNodePortsData, M as WorkflowPort, R as WorkflowPortEntityOpts, n as WorkflowPortType, Q as WorkflowPorts, A as WorkflowSubCanvas, q as domReactToBounds, o as getPortEntityId, E as onDragLineEndParams } from './workflow-node-entity-
|
|
5
|
+
import { W as WorkflowJSON, L as LineCenterPoint, a as WorkflowDocument, b as WorkflowNodeEntity, c as WorkflowHoverService, d as WorkflowLinesManager, e as WorkflowSelectService, f as WorkflowDocumentOptions, g as LineEventProps, N as NodesDragEvent, h as WorkflowNodeJSON, i as WorkflowPortEntity, j as WorkflowLineEntity, O as OnDragLineEnd, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-node-entity-DgQT-wl9.mjs';
|
|
6
|
+
export { X as HoverPosition, F as LINE_HOVER_DISTANCE, x as LineColor, y as LineColors, w as LinePoint, v as LinePointLocation, u as LineType, C as NodesDragEndEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, P as POINT_RADIUS, K as PORT_SIZE, p as WORKFLOW_LINE_ENTITY, Y as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, _ as WorkflowDocumentOptionsDefault, Z as WorkflowDocumentProvider, V as WorkflowEntityHoverable, H as WorkflowLineEntityOpts, I as WorkflowLineInfo, G as WorkflowLinePortInfo, z as WorkflowLineRenderContributionFactory, J as WorkflowLineUIState, T as WorkflowNodeLines, U as WorkflowNodeLinesData, t as WorkflowNodeMeta, S as WorkflowNodePortsData, M as WorkflowPort, R as WorkflowPortEntityOpts, n as WorkflowPortType, Q as WorkflowPorts, A as WorkflowSubCanvas, q as domReactToBounds, o as getPortEntityId, E as onDragLineEndParams } from './workflow-node-entity-DgQT-wl9.mjs';
|
|
7
7
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
8
8
|
import { IPoint, Rectangle, DisposableCollection, Disposable } from '@flowgram.ai/utils';
|
|
9
9
|
export { compose, composeAsync, delay } from '@flowgram.ai/utils';
|
|
@@ -228,9 +228,11 @@ declare class WorkflowResetLayoutService {
|
|
|
228
228
|
|
|
229
229
|
declare class WorkflowOperationBaseServiceImpl extends FlowOperationBaseServiceImpl implements WorkflowOperationBaseService {
|
|
230
230
|
protected document: WorkflowDocument;
|
|
231
|
+
linesManager: WorkflowLinesManager;
|
|
231
232
|
private onNodePostionUpdateEmitter;
|
|
232
233
|
readonly onNodePostionUpdate: _flowgram_ai_utils.Event<NodePostionUpdateEvent>;
|
|
233
234
|
updateNodePosition(nodeOrId: FlowNodeEntityOrId, position: IPoint): void;
|
|
235
|
+
fromJSON(json: WorkflowJSON): void;
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { PlaygroundConfigEntity, CommandService, PlaygroundDragEvent, EntityData
|
|
|
2
2
|
export { bindConfigEntity, useConfigEntity, useEntities, useEntityDataFromContext, useEntityFromContext, useListenEvents, usePlayground, usePlaygroundContainer, usePlaygroundContext, useRefresh, useService } from '@flowgram.ai/core';
|
|
3
3
|
import { NodeFormProps } from '@flowgram.ai/node';
|
|
4
4
|
import { FlowOperationBaseService, FlowNodeType, FlowOperationBaseServiceImpl, FlowNodeEntityOrId, FlowNodeEntity } from '@flowgram.ai/document';
|
|
5
|
-
import { W as WorkflowJSON, L as LineCenterPoint, a as WorkflowDocument, b as WorkflowNodeEntity, c as WorkflowHoverService, d as WorkflowLinesManager, e as WorkflowSelectService, f as WorkflowDocumentOptions, g as LineEventProps, N as NodesDragEvent, h as WorkflowNodeJSON, i as WorkflowPortEntity, j as WorkflowLineEntity, O as OnDragLineEnd, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-node-entity-
|
|
6
|
-
export { X as HoverPosition, F as LINE_HOVER_DISTANCE, x as LineColor, y as LineColors, w as LinePoint, v as LinePointLocation, u as LineType, C as NodesDragEndEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, P as POINT_RADIUS, K as PORT_SIZE, p as WORKFLOW_LINE_ENTITY, Y as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, _ as WorkflowDocumentOptionsDefault, Z as WorkflowDocumentProvider, V as WorkflowEntityHoverable, H as WorkflowLineEntityOpts, I as WorkflowLineInfo, G as WorkflowLinePortInfo, z as WorkflowLineRenderContributionFactory, J as WorkflowLineUIState, T as WorkflowNodeLines, U as WorkflowNodeLinesData, t as WorkflowNodeMeta, S as WorkflowNodePortsData, M as WorkflowPort, R as WorkflowPortEntityOpts, n as WorkflowPortType, Q as WorkflowPorts, A as WorkflowSubCanvas, q as domReactToBounds, o as getPortEntityId, E as onDragLineEndParams } from './workflow-node-entity-
|
|
5
|
+
import { W as WorkflowJSON, L as LineCenterPoint, a as WorkflowDocument, b as WorkflowNodeEntity, c as WorkflowHoverService, d as WorkflowLinesManager, e as WorkflowSelectService, f as WorkflowDocumentOptions, g as LineEventProps, N as NodesDragEvent, h as WorkflowNodeJSON, i as WorkflowPortEntity, j as WorkflowLineEntity, O as OnDragLineEnd, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-node-entity-kGsp2Roz.js';
|
|
6
|
+
export { X as HoverPosition, F as LINE_HOVER_DISTANCE, x as LineColor, y as LineColors, w as LinePoint, v as LinePointLocation, u as LineType, C as NodesDragEndEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, P as POINT_RADIUS, K as PORT_SIZE, p as WORKFLOW_LINE_ENTITY, Y as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, _ as WorkflowDocumentOptionsDefault, Z as WorkflowDocumentProvider, V as WorkflowEntityHoverable, H as WorkflowLineEntityOpts, I as WorkflowLineInfo, G as WorkflowLinePortInfo, z as WorkflowLineRenderContributionFactory, J as WorkflowLineUIState, T as WorkflowNodeLines, U as WorkflowNodeLinesData, t as WorkflowNodeMeta, S as WorkflowNodePortsData, M as WorkflowPort, R as WorkflowPortEntityOpts, n as WorkflowPortType, Q as WorkflowPorts, A as WorkflowSubCanvas, q as domReactToBounds, o as getPortEntityId, E as onDragLineEndParams } from './workflow-node-entity-kGsp2Roz.js';
|
|
7
7
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
8
8
|
import { IPoint, Rectangle, DisposableCollection, Disposable } from '@flowgram.ai/utils';
|
|
9
9
|
export { compose, composeAsync, delay } from '@flowgram.ai/utils';
|
|
@@ -228,9 +228,11 @@ declare class WorkflowResetLayoutService {
|
|
|
228
228
|
|
|
229
229
|
declare class WorkflowOperationBaseServiceImpl extends FlowOperationBaseServiceImpl implements WorkflowOperationBaseService {
|
|
230
230
|
protected document: WorkflowDocument;
|
|
231
|
+
linesManager: WorkflowLinesManager;
|
|
231
232
|
private onNodePostionUpdateEmitter;
|
|
232
233
|
readonly onNodePostionUpdate: _flowgram_ai_utils.Event<NodePostionUpdateEvent>;
|
|
233
234
|
updateNodePosition(nodeOrId: FlowNodeEntityOrId, position: IPoint): void;
|
|
235
|
+
fromJSON(json: WorkflowJSON): void;
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2105,6 +2105,9 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2105
2105
|
this._loading = false;
|
|
2106
2106
|
this.onLoadedEmitter.fire();
|
|
2107
2107
|
}
|
|
2108
|
+
/**
|
|
2109
|
+
* @deprecated use `ctx.operation.fromJSON` instead
|
|
2110
|
+
*/
|
|
2108
2111
|
async reload(json, delayTime = 0) {
|
|
2109
2112
|
if (this.disposed) return;
|
|
2110
2113
|
this._loading = true;
|
|
@@ -2125,7 +2128,7 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2125
2128
|
edges: json.edges ?? []
|
|
2126
2129
|
};
|
|
2127
2130
|
this.entityManager.changeEntityLocked = true;
|
|
2128
|
-
this.
|
|
2131
|
+
this.batchAddFromJSON(workflowJSON);
|
|
2129
2132
|
this.entityManager.changeEntityLocked = false;
|
|
2130
2133
|
this.transformer.loading = false;
|
|
2131
2134
|
if (fireRender) {
|
|
@@ -2145,9 +2148,17 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2145
2148
|
* 创建流程节点
|
|
2146
2149
|
* @param json
|
|
2147
2150
|
*/
|
|
2148
|
-
createWorkflowNode(json, isClone = false,
|
|
2151
|
+
createWorkflowNode(json, isClone = false, parentID) {
|
|
2152
|
+
return this._createWorkflowNode(json, { parentID });
|
|
2153
|
+
}
|
|
2154
|
+
/**
|
|
2155
|
+
* 创建流程节点
|
|
2156
|
+
* @param json
|
|
2157
|
+
*/
|
|
2158
|
+
_createWorkflowNode(json, options) {
|
|
2159
|
+
const { parentID, onNodeCreated, onEdgeCreated } = options ?? {};
|
|
2149
2160
|
const isExistedNode = this.getNode(json.id);
|
|
2150
|
-
const parent = this.getNode(
|
|
2161
|
+
const parent = this.getNode(parentID ?? this.root.id) ?? this.root;
|
|
2151
2162
|
const node = this.addNode(
|
|
2152
2163
|
{
|
|
2153
2164
|
...json,
|
|
@@ -2174,15 +2185,19 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2174
2185
|
node.getData(import_core14.TransformData).update({
|
|
2175
2186
|
position
|
|
2176
2187
|
});
|
|
2177
|
-
if (formMeta && formData
|
|
2178
|
-
formData.
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2188
|
+
if (formMeta && formData) {
|
|
2189
|
+
if (!formData.formModel.initialized) {
|
|
2190
|
+
formData.createForm(formMeta, json.data);
|
|
2191
|
+
formData.onDataChange(() => {
|
|
2192
|
+
this.fireContentChange({
|
|
2193
|
+
type: "NODE_DATA_CHANGE" /* NODE_DATA_CHANGE */,
|
|
2194
|
+
toJSON: () => formData.toJSON(),
|
|
2195
|
+
entity: node
|
|
2196
|
+
});
|
|
2184
2197
|
});
|
|
2185
|
-
}
|
|
2198
|
+
} else {
|
|
2199
|
+
formData.updateFormValues(json.data);
|
|
2200
|
+
}
|
|
2186
2201
|
}
|
|
2187
2202
|
const positionData = node.getData(import_core14.PositionData);
|
|
2188
2203
|
if (!isExistedNode) {
|
|
@@ -2221,11 +2236,12 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2221
2236
|
});
|
|
2222
2237
|
}
|
|
2223
2238
|
if (json.blocks) {
|
|
2224
|
-
this.
|
|
2239
|
+
this.batchAddFromJSON(
|
|
2225
2240
|
{ nodes: json.blocks, edges: json.edges ?? [] },
|
|
2226
2241
|
{
|
|
2227
2242
|
parent: node,
|
|
2228
|
-
|
|
2243
|
+
onNodeCreated,
|
|
2244
|
+
onEdgeCreated
|
|
2229
2245
|
}
|
|
2230
2246
|
);
|
|
2231
2247
|
}
|
|
@@ -2357,7 +2373,7 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2357
2373
|
throw new Error(`[WorkflowDocument.createWorkflowNodeByType] Node Id "${id}" duplicated.`);
|
|
2358
2374
|
}
|
|
2359
2375
|
}
|
|
2360
|
-
return this.
|
|
2376
|
+
return this._createWorkflowNode(
|
|
2361
2377
|
{
|
|
2362
2378
|
...json,
|
|
2363
2379
|
id,
|
|
@@ -2368,13 +2384,15 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2368
2384
|
blocks: json?.blocks,
|
|
2369
2385
|
edges: json?.edges
|
|
2370
2386
|
},
|
|
2371
|
-
|
|
2372
|
-
parentID
|
|
2387
|
+
{ parentID }
|
|
2373
2388
|
);
|
|
2374
2389
|
}
|
|
2375
2390
|
getAllNodes() {
|
|
2376
2391
|
return this.entityManager.getEntities(WorkflowNodeEntity).filter((n) => n.id !== import_document8.FlowNodeBaseType.ROOT);
|
|
2377
2392
|
}
|
|
2393
|
+
getAllEdges() {
|
|
2394
|
+
return this.entityManager.getEntities(WorkflowLineEntity);
|
|
2395
|
+
}
|
|
2378
2396
|
getAllPorts() {
|
|
2379
2397
|
return this.entityManager.getEntities(WorkflowPortEntity).filter((p) => p.node.id !== import_document8.FlowNodeBaseType.ROOT);
|
|
2380
2398
|
}
|
|
@@ -2475,7 +2493,7 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2475
2493
|
x: json.meta.position.x + 30,
|
|
2476
2494
|
y: json.meta.position.y + 30
|
|
2477
2495
|
};
|
|
2478
|
-
return this.
|
|
2496
|
+
return this._createWorkflowNode(
|
|
2479
2497
|
{
|
|
2480
2498
|
id: newNodeId || `1${nanoid2()}`,
|
|
2481
2499
|
type: node.flowNodeType,
|
|
@@ -2487,16 +2505,17 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2487
2505
|
blocks: json.blocks,
|
|
2488
2506
|
edges: json.edges
|
|
2489
2507
|
},
|
|
2490
|
-
|
|
2491
|
-
|
|
2508
|
+
{
|
|
2509
|
+
parentID: node.parent?.id
|
|
2510
|
+
}
|
|
2492
2511
|
);
|
|
2493
2512
|
}
|
|
2494
|
-
copyNodeFromJSON(flowNodeType, nodeJSON, newNodeId, position,
|
|
2513
|
+
copyNodeFromJSON(flowNodeType, nodeJSON, newNodeId, position, parentID) {
|
|
2495
2514
|
position = position || {
|
|
2496
2515
|
x: nodeJSON.meta.position.x + 30,
|
|
2497
2516
|
y: nodeJSON.meta.position.y + 30
|
|
2498
2517
|
};
|
|
2499
|
-
return this.
|
|
2518
|
+
return this._createWorkflowNode(
|
|
2500
2519
|
{
|
|
2501
2520
|
id: newNodeId || `1${nanoid2()}`,
|
|
2502
2521
|
type: flowNodeType,
|
|
@@ -2508,8 +2527,9 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2508
2527
|
blocks: nodeJSON.blocks,
|
|
2509
2528
|
edges: nodeJSON.edges
|
|
2510
2529
|
},
|
|
2511
|
-
|
|
2512
|
-
|
|
2530
|
+
{
|
|
2531
|
+
parentID
|
|
2532
|
+
}
|
|
2513
2533
|
);
|
|
2514
2534
|
}
|
|
2515
2535
|
canRemove(node, silent) {
|
|
@@ -2564,13 +2584,17 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2564
2584
|
* 批量添加节点
|
|
2565
2585
|
*/
|
|
2566
2586
|
batchAddFromJSON(json, options) {
|
|
2567
|
-
const { parent = this.root
|
|
2568
|
-
const
|
|
2587
|
+
const { parent = this.root } = options ?? {};
|
|
2588
|
+
const parentID = this.getNodeSubCanvas(parent)?.canvasNode.id ?? parent.id;
|
|
2569
2589
|
const processedJSON = buildGroupJSON(json);
|
|
2570
2590
|
const nodes = processedJSON.nodes.map(
|
|
2571
|
-
(nodeJSON) => this.
|
|
2591
|
+
(nodeJSON) => this._createWorkflowNode(nodeJSON, {
|
|
2592
|
+
parentID
|
|
2593
|
+
})
|
|
2572
2594
|
);
|
|
2573
|
-
const edges = processedJSON.edges.map((edge) => this.createWorkflowLine(edge,
|
|
2595
|
+
const edges = processedJSON.edges.map((edge) => this.createWorkflowLine(edge, parentID)).filter(Boolean);
|
|
2596
|
+
nodes.forEach((node) => options?.onNodeCreated?.(node));
|
|
2597
|
+
edges.forEach((edge) => options?.onEdgeCreated?.(edge));
|
|
2574
2598
|
return { nodes, edges };
|
|
2575
2599
|
}
|
|
2576
2600
|
getNodeSubCanvas(node) {
|
|
@@ -2619,7 +2643,7 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2619
2643
|
}
|
|
2620
2644
|
return lineJSON;
|
|
2621
2645
|
}
|
|
2622
|
-
createWorkflowLine(json,
|
|
2646
|
+
createWorkflowLine(json, parentID) {
|
|
2623
2647
|
const fromNode = this.getNode(json.sourceNodeID);
|
|
2624
2648
|
const toNode = this.getNode(json.targetNodeID);
|
|
2625
2649
|
if (!fromNode || !toNode) {
|
|
@@ -2632,10 +2656,10 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2632
2656
|
toPort: json.targetPortID,
|
|
2633
2657
|
data: json.data
|
|
2634
2658
|
};
|
|
2635
|
-
if (!
|
|
2659
|
+
if (!parentID) {
|
|
2636
2660
|
return this.linesManager.createLine(lineInfo);
|
|
2637
2661
|
}
|
|
2638
|
-
const canvasNode = this.getNode(
|
|
2662
|
+
const canvasNode = this.getNode(parentID);
|
|
2639
2663
|
if (!canvasNode) {
|
|
2640
2664
|
return this.linesManager.createLine(lineInfo);
|
|
2641
2665
|
}
|
|
@@ -3580,10 +3604,57 @@ var WorkflowOperationBaseServiceImpl = class extends import_document12.FlowOpera
|
|
|
3580
3604
|
newPosition: position
|
|
3581
3605
|
});
|
|
3582
3606
|
}
|
|
3607
|
+
fromJSON(json) {
|
|
3608
|
+
if (this.document.disposed) return;
|
|
3609
|
+
const workflowJSON = {
|
|
3610
|
+
nodes: json.nodes ?? [],
|
|
3611
|
+
edges: json.edges ?? []
|
|
3612
|
+
};
|
|
3613
|
+
const oldNodes = this.document.getAllNodes();
|
|
3614
|
+
const oldPositionMap = new Map(
|
|
3615
|
+
oldNodes.map((node) => [
|
|
3616
|
+
node.id,
|
|
3617
|
+
{
|
|
3618
|
+
x: node.transform.transform.position.x,
|
|
3619
|
+
y: node.transform.transform.position.y
|
|
3620
|
+
}
|
|
3621
|
+
])
|
|
3622
|
+
);
|
|
3623
|
+
const newNodes = [];
|
|
3624
|
+
const newEdges = [];
|
|
3625
|
+
this.linesManager.getAllLines().map((line) => line.dispose());
|
|
3626
|
+
this.document.batchAddFromJSON(workflowJSON, {
|
|
3627
|
+
onNodeCreated: (node) => newNodes.push(node),
|
|
3628
|
+
onEdgeCreated: (edge) => newEdges.push(edge)
|
|
3629
|
+
});
|
|
3630
|
+
const newNodeIDSet = new Set(newNodes.map((node) => node.id));
|
|
3631
|
+
oldNodes.forEach((node) => {
|
|
3632
|
+
if (!newNodeIDSet.has(node.id)) {
|
|
3633
|
+
node.dispose();
|
|
3634
|
+
return;
|
|
3635
|
+
}
|
|
3636
|
+
const oldPosition = oldPositionMap.get(node.id);
|
|
3637
|
+
const newPosition = {
|
|
3638
|
+
x: node.transform.transform.position.x,
|
|
3639
|
+
y: node.transform.transform.position.y
|
|
3640
|
+
};
|
|
3641
|
+
if (oldPosition && (oldPosition.x !== newPosition.x || oldPosition.y !== newPosition.y)) {
|
|
3642
|
+
this.onNodePostionUpdateEmitter.fire({
|
|
3643
|
+
node,
|
|
3644
|
+
oldPosition,
|
|
3645
|
+
newPosition
|
|
3646
|
+
});
|
|
3647
|
+
}
|
|
3648
|
+
});
|
|
3649
|
+
this.document.fireRender();
|
|
3650
|
+
}
|
|
3583
3651
|
};
|
|
3584
3652
|
__decorateClass([
|
|
3585
3653
|
(0, import_inversify8.inject)(WorkflowDocument)
|
|
3586
3654
|
], WorkflowOperationBaseServiceImpl.prototype, "document", 2);
|
|
3655
|
+
__decorateClass([
|
|
3656
|
+
(0, import_inversify8.inject)(WorkflowLinesManager)
|
|
3657
|
+
], WorkflowOperationBaseServiceImpl.prototype, "linesManager", 2);
|
|
3587
3658
|
|
|
3588
3659
|
// src/hooks/use-playground-readonly-state.ts
|
|
3589
3660
|
var import_react = require("react");
|