@flowgram.ai/free-layout-core 0.1.0-alpha.6 → 0.1.0-alpha.8
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 +252 -279
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +246 -273
- 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-drag.js.map +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-BCAgoA18.d.mts → workflow-line-entity-DSMjQU0t.d.mts} +58 -16
- package/dist/{workflow-line-entity-DIyrK9yz.d.ts → workflow-line-entity-VNz8dyPS.d.ts} +58 -16
- package/package.json +11 -11
package/dist/esm/index.js
CHANGED
|
@@ -145,6 +145,7 @@ var PORT_SIZE = 24;
|
|
|
145
145
|
var WorkflowPortEntity = class extends Entity {
|
|
146
146
|
// relativePosition
|
|
147
147
|
constructor(opts) {
|
|
148
|
+
var _a;
|
|
148
149
|
super(opts);
|
|
149
150
|
this.portID = "";
|
|
150
151
|
this._disabled = false;
|
|
@@ -153,7 +154,7 @@ var WorkflowPortEntity = class extends Entity {
|
|
|
153
154
|
this.onErrorChanged = this._onErrorChangedEmitter.event;
|
|
154
155
|
this.portID = opts.portID || "";
|
|
155
156
|
this.portType = opts.type;
|
|
156
|
-
this._disabled = opts.disabled
|
|
157
|
+
this._disabled = (_a = opts.disabled) != null ? _a : false;
|
|
157
158
|
this.node = opts.node;
|
|
158
159
|
this.updateTargetElement(opts.targetElement);
|
|
159
160
|
this.toDispose.push(this.node.getData(TransformData3).onDataChange(() => this.fireChange()));
|
|
@@ -283,6 +284,7 @@ WorkflowPortEntity.type = "WorkflowPortEntity";
|
|
|
283
284
|
// src/entity-datas/workflow-node-ports-data.ts
|
|
284
285
|
var WorkflowNodePortsData = class extends EntityData {
|
|
285
286
|
constructor(entity) {
|
|
287
|
+
var _a;
|
|
286
288
|
super(entity);
|
|
287
289
|
/** 静态的 ports 数据 */
|
|
288
290
|
this._staticPorts = [];
|
|
@@ -291,7 +293,7 @@ var WorkflowNodePortsData = class extends EntityData {
|
|
|
291
293
|
this.entity = entity;
|
|
292
294
|
const meta = entity.getNodeMeta();
|
|
293
295
|
const defaultPorts = meta.useDynamicPort ? [] : [{ type: "input" }, { type: "output" }];
|
|
294
|
-
this._staticPorts = meta.defaultPorts
|
|
296
|
+
this._staticPorts = ((_a = meta.defaultPorts) == null ? void 0 : _a.slice()) || defaultPorts;
|
|
295
297
|
this.updatePorts(this._staticPorts);
|
|
296
298
|
if (meta.useDynamicPort) {
|
|
297
299
|
this.toDispose.push(
|
|
@@ -358,8 +360,9 @@ var WorkflowNodePortsData = class extends EntityData {
|
|
|
358
360
|
if (!isEqual(this._prePorts, ports)) {
|
|
359
361
|
const portKeys = ports.map((port) => this.getPortId(port.type, port.portID));
|
|
360
362
|
this._portIDSet.forEach((portId) => {
|
|
363
|
+
var _a;
|
|
361
364
|
if (!portKeys.includes(portId)) {
|
|
362
|
-
this.getPortEntity(portId)
|
|
365
|
+
(_a = this.getPortEntity(portId)) == null ? void 0 : _a.dispose();
|
|
363
366
|
}
|
|
364
367
|
});
|
|
365
368
|
ports.forEach((port) => this.updatePortEntity(port));
|
|
@@ -453,8 +456,9 @@ var WorkflowNodePortsData = class extends EntityData {
|
|
|
453
456
|
* 获取或创建 port 实体
|
|
454
457
|
*/
|
|
455
458
|
getOrCreatePortEntity(portInfo) {
|
|
459
|
+
var _a;
|
|
456
460
|
const id = this.getPortId(portInfo.type, portInfo.portID);
|
|
457
|
-
return this.getPortEntity(id)
|
|
461
|
+
return (_a = this.getPortEntity(id)) != null ? _a : this.createPortEntity(portInfo);
|
|
458
462
|
}
|
|
459
463
|
/**
|
|
460
464
|
* 更新 port 实体
|
|
@@ -482,7 +486,7 @@ var _WorkflowNodeLinesData = class _WorkflowNodeLinesData extends EntityData2 {
|
|
|
482
486
|
constructor(entity) {
|
|
483
487
|
super(entity);
|
|
484
488
|
this.entity = entity;
|
|
485
|
-
this.
|
|
489
|
+
this.entity.preDispose.push(
|
|
486
490
|
Disposable.create(() => {
|
|
487
491
|
this.inputLines.slice().forEach((line) => line.dispose());
|
|
488
492
|
this.outputLines.slice().forEach((line) => line.dispose());
|
|
@@ -522,7 +526,7 @@ var _WorkflowNodeLinesData = class _WorkflowNodeLinesData extends EntityData2 {
|
|
|
522
526
|
return;
|
|
523
527
|
}
|
|
524
528
|
inputNodes.forEach((inputNode) => {
|
|
525
|
-
if (inputNode
|
|
529
|
+
if ((inputNode == null ? void 0 : inputNode.parent) === node || (node == null ? void 0 : node.parent) === inputNode) {
|
|
526
530
|
return;
|
|
527
531
|
}
|
|
528
532
|
handleNode(inputNode);
|
|
@@ -553,7 +557,7 @@ var _WorkflowNodeLinesData = class _WorkflowNodeLinesData extends EntityData2 {
|
|
|
553
557
|
return;
|
|
554
558
|
}
|
|
555
559
|
outputNodes.forEach((outputNode) => {
|
|
556
|
-
if (outputNode
|
|
560
|
+
if ((outputNode == null ? void 0 : outputNode.parent) === node || (node == null ? void 0 : node.parent) === outputNode) {
|
|
557
561
|
return;
|
|
558
562
|
}
|
|
559
563
|
handleNode(outputNode);
|
|
@@ -613,19 +617,23 @@ var WorkflowLineRenderData = class extends EntityData3 {
|
|
|
613
617
|
return this.data.position;
|
|
614
618
|
}
|
|
615
619
|
get path() {
|
|
616
|
-
|
|
620
|
+
var _a, _b;
|
|
621
|
+
return (_b = (_a = this.currentLine) == null ? void 0 : _a.path) != null ? _b : "";
|
|
617
622
|
}
|
|
618
623
|
calcDistance(pos) {
|
|
619
|
-
|
|
624
|
+
var _a, _b;
|
|
625
|
+
return (_b = (_a = this.currentLine) == null ? void 0 : _a.calcDistance(pos)) != null ? _b : Number.MAX_SAFE_INTEGER;
|
|
620
626
|
}
|
|
621
627
|
get bounds() {
|
|
622
|
-
|
|
628
|
+
var _a, _b;
|
|
629
|
+
return (_b = (_a = this.currentLine) == null ? void 0 : _a.bounds) != null ? _b : new Rectangle4();
|
|
623
630
|
}
|
|
624
631
|
/**
|
|
625
632
|
* 更新数据
|
|
626
633
|
* WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
|
|
627
634
|
*/
|
|
628
635
|
update() {
|
|
636
|
+
var _a;
|
|
629
637
|
this.syncContributions();
|
|
630
638
|
const oldVersion = this.data.version;
|
|
631
639
|
this.updatePosition();
|
|
@@ -634,21 +642,23 @@ var WorkflowLineRenderData = class extends EntityData3 {
|
|
|
634
642
|
return;
|
|
635
643
|
}
|
|
636
644
|
this.data.version = newVersion;
|
|
637
|
-
this.currentLine
|
|
645
|
+
(_a = this.currentLine) == null ? void 0 : _a.update({
|
|
638
646
|
fromPos: this.data.position.from,
|
|
639
647
|
toPos: this.data.position.to
|
|
640
648
|
});
|
|
641
649
|
}
|
|
642
650
|
get lineType() {
|
|
643
|
-
|
|
651
|
+
var _a;
|
|
652
|
+
return (_a = this.entity.renderType) != null ? _a : this.entity.linesManager.lineType;
|
|
644
653
|
}
|
|
645
654
|
/**
|
|
646
655
|
* 更新版本
|
|
647
656
|
* WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
|
|
648
657
|
*/
|
|
649
658
|
updatePosition() {
|
|
659
|
+
var _a, _b, _c, _d;
|
|
650
660
|
this.data.position.from = this.entity.from.getData(WorkflowNodePortsData).getOutputPoint(this.entity.info.fromPort);
|
|
651
|
-
this.data.position.to = this.entity.info.drawingTo
|
|
661
|
+
this.data.position.to = (_d = (_c = this.entity.info.drawingTo) != null ? _c : (_b = (_a = this.entity.to) == null ? void 0 : _a.getData(WorkflowNodePortsData)) == null ? void 0 : _b.getInputPoint(this.entity.info.toPort)) != null ? _d : {
|
|
652
662
|
x: this.data.position.from.x,
|
|
653
663
|
y: this.data.position.from.y
|
|
654
664
|
};
|
|
@@ -732,7 +742,7 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
732
742
|
return this.highlightColor === this.linesManager.lineColor.hidden;
|
|
733
743
|
}
|
|
734
744
|
get inContainer() {
|
|
735
|
-
const nodeInContainer = (node) => !!node
|
|
745
|
+
const nodeInContainer = (node) => !!(node == null ? void 0 : node.parent) && node.parent.flowNodeType !== "root";
|
|
736
746
|
return nodeInContainer(this.from) || nodeInContainer(this.to);
|
|
737
747
|
}
|
|
738
748
|
/**
|
|
@@ -873,7 +883,8 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
873
883
|
}
|
|
874
884
|
/** 获取线条样式 */
|
|
875
885
|
get className() {
|
|
876
|
-
|
|
886
|
+
var _a;
|
|
887
|
+
return (_a = this.linesManager.setLineClassName(this)) != null ? _a : "";
|
|
877
888
|
}
|
|
878
889
|
get color() {
|
|
879
890
|
return this.linesManager.getLineColor(this);
|
|
@@ -894,8 +905,8 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
894
905
|
validate() {
|
|
895
906
|
const { fromPort, toPort } = this;
|
|
896
907
|
this.validateSelf();
|
|
897
|
-
fromPort
|
|
898
|
-
toPort
|
|
908
|
+
fromPort == null ? void 0 : fromPort.validate();
|
|
909
|
+
toPort == null ? void 0 : toPort.validate();
|
|
899
910
|
}
|
|
900
911
|
validateSelf() {
|
|
901
912
|
const { fromPort, toPort } = this;
|
|
@@ -913,14 +924,15 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
913
924
|
return this.linesManager.canRemove(this, newLineInfo);
|
|
914
925
|
}
|
|
915
926
|
get node() {
|
|
927
|
+
var _a, _b, _c, _d, _e, _f;
|
|
916
928
|
if (this._node) return this._node;
|
|
917
929
|
this._node = domUtils.createDivWithClass("gedit-flow-activity-line");
|
|
918
930
|
this._node.dataset.testid = "sdk.workflow.canvas.line";
|
|
919
931
|
this._node.dataset.lineId = this.id;
|
|
920
932
|
this._node.dataset.fromNodeId = this.from.id;
|
|
921
|
-
this._node.dataset.fromPortId = this.fromPort
|
|
922
|
-
this._node.dataset.toNodeId = this.to
|
|
923
|
-
this._node.dataset.toPortId = this.toPort
|
|
933
|
+
this._node.dataset.fromPortId = (_b = (_a = this.fromPort) == null ? void 0 : _a.id) != null ? _b : "";
|
|
934
|
+
this._node.dataset.toNodeId = (_d = (_c = this.to) == null ? void 0 : _c.id) != null ? _d : "";
|
|
935
|
+
this._node.dataset.toPortId = (_f = (_e = this.toPort) == null ? void 0 : _e.id) != null ? _f : "";
|
|
924
936
|
this._node.dataset.hasError = this.hasError ? "true" : "false";
|
|
925
937
|
return this._node;
|
|
926
938
|
}
|
|
@@ -972,7 +984,8 @@ var WorkflowSelectService = class {
|
|
|
972
984
|
return this.selectionService.selection.some((s) => s.id === id);
|
|
973
985
|
}
|
|
974
986
|
isActivated(id) {
|
|
975
|
-
|
|
987
|
+
var _a;
|
|
988
|
+
return ((_a = this.activatedNode) == null ? void 0 : _a.id) === id;
|
|
976
989
|
}
|
|
977
990
|
/**
|
|
978
991
|
* 选中的节点
|
|
@@ -1043,8 +1056,8 @@ WorkflowSelectService = __decorateClass([
|
|
|
1043
1056
|
|
|
1044
1057
|
// src/service/workflow-hover-service.ts
|
|
1045
1058
|
import { inject as inject2, injectable as injectable2 } from "inversify";
|
|
1046
|
-
import { EntityManager } from "@flowgram.ai/core";
|
|
1047
1059
|
import { Emitter as Emitter2 } from "@flowgram.ai/utils";
|
|
1060
|
+
import { EntityManager } from "@flowgram.ai/core";
|
|
1048
1061
|
var WorkflowHoverService = class {
|
|
1049
1062
|
constructor() {
|
|
1050
1063
|
this.onHoveredChangeEmitter = new Emitter2();
|
|
@@ -1125,7 +1138,7 @@ import {
|
|
|
1125
1138
|
// src/workflow-lines-manager.ts
|
|
1126
1139
|
import { last } from "lodash-es";
|
|
1127
1140
|
import { inject as inject3, injectable as injectable3 } from "inversify";
|
|
1128
|
-
import {
|
|
1141
|
+
import { DisposableCollection, Emitter as Emitter3 } from "@flowgram.ai/utils";
|
|
1129
1142
|
import { FlowNodeRenderData as FlowNodeRenderData2, FlowNodeTransformData as FlowNodeTransformData3 } from "@flowgram.ai/document";
|
|
1130
1143
|
import { EntityManager as EntityManager2, PlaygroundConfigEntity as PlaygroundConfigEntity2, TransformData as TransformData6 } from "@flowgram.ai/core";
|
|
1131
1144
|
|
|
@@ -1144,19 +1157,23 @@ function toFormJSON(node) {
|
|
|
1144
1157
|
if (!formData || !node.getNodeRegistry().formMeta) return void 0;
|
|
1145
1158
|
return formData.toJSON();
|
|
1146
1159
|
}
|
|
1147
|
-
function initFormDataFromJSON(node, json) {
|
|
1160
|
+
function initFormDataFromJSON(node, json, isFirstCreate) {
|
|
1148
1161
|
const formData = node.getData(FlowNodeFormData);
|
|
1149
1162
|
const registry = node.getNodeRegistry();
|
|
1150
1163
|
const { formMeta } = registry;
|
|
1151
1164
|
if (formData && formMeta) {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1165
|
+
if (isFirstCreate) {
|
|
1166
|
+
formData.createForm(formMeta, json.data);
|
|
1167
|
+
formData.onDataChange(() => {
|
|
1168
|
+
node.document.fireContentChange({
|
|
1169
|
+
type: "NODE_DATA_CHANGE" /* NODE_DATA_CHANGE */,
|
|
1170
|
+
toJSON: () => formData.toJSON(),
|
|
1171
|
+
entity: node
|
|
1172
|
+
});
|
|
1158
1173
|
});
|
|
1159
|
-
}
|
|
1174
|
+
} else {
|
|
1175
|
+
formData.updateFormValues(json.data);
|
|
1176
|
+
}
|
|
1160
1177
|
}
|
|
1161
1178
|
}
|
|
1162
1179
|
|
|
@@ -1167,12 +1184,13 @@ var WorkflowDocumentOptionsDefault = {
|
|
|
1167
1184
|
grab: 'url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMCAyMSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMC40ODczIDIuNjIzNzhDOS45MDczMSAyLjYyMzc4IDkuNDM3MTMgMy4wOTM5NiA5LjQzNzEzIDMuNjczOTZWNS4xNDM3NkM5LjM5NDI4IDQuNDAyNzQgOC43Nzk3OCAzLjgxNTA0IDguMDI4MDIgMy44MTUwNEM3LjI0ODQ4IDMuODE1MDQgNi42MTY1MyA0LjQ0Njk5IDYuNjE2NTMgNS4yMjY1M1YxMS44Mjg5TDUuNjc0MTggMTEuMDA0OUM1LjE1NDg3IDEwLjU1MDkgNC40MDk1IDEwLjQ2MzYgMy43OTkzOCAxMC43ODU1TDMuNjk2OTQgMTAuODM5NkMzLjA2MjE3IDExLjE3NDUgMi45MjI2IDEyLjAyMjggMy40MTY2MiAxMi41NDM0TDcuMzM5NTkgMTYuNjc3NVYxNy4zMjU5QzcuMzM5NTkgMTcuNzg2MiA3LjcxMjY5IDE4LjE1OTMgOC4xNzI5MiAxOC4xNTkzSDEzLjgwODRDMTQuMjY4NyAxOC4xNTkzIDE0LjY0MTcgMTcuNzg2MiAxNC42NDE3IDE3LjMyNTlWMTYuNzkzNUMxNS44MDk0IDE1LjY0ODUgMTYuNDY3MyAxNC4wODE5IDE2LjQ2NzMgMTIuNDQ2NVYxMS40OTY3TDE2LjQ2NzEgNi42MzY4NUMxNi40Njc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3NyAxMi40NDY3TDE2LjQ2NzYgOC4wMTk4M0MxNi40Njc2IDcuMzQ1MDQgMTUuOTI1MiA2Ljc5NjkzIDE1LjI1MjUgNi43ODc3MUwxNS4yMzUzIDYuNzg3NTlDMTUuMTI1IDYuNzg3NTkgMTUuMDE4IDYuODAyMSAxNC45MTYyIDYuODI5MzFWOS42MDEzNkMxNC45MTYyIDkuODUzNDIgMTQuNzExOSAxMC4wNTc3IDE0LjQ1OTggMTAuMDU3N0MxNC4yMDc4IDEwLjA1NzcgMTQuMDAzNCA5Ljg1MzQxIDE0LjAwMzQgOS42MDEzNlY3Ljk4OTg1QzE0LjAwMzIgNy45OTk4MiAxNC4wMDMxIDguMDA5ODEgMTQuMDAzMSA4LjAxOTgzTDE0LjAwMzQgOS42MDEzNkwxNC4wMDI1IDYuNzExNUMxNC4wMDI1IDYuNDQ5NzQgMTMuOTIwOSA2LjIwNzA1IDEzLjc4MTggNi4wMDc0OEMxMy41NjIgNS42OTI0MiAxMy4xOTg5IDUuNDg0ODMgMTIuNzg3IDUuNDc5MzdMMTIuNzcwMyA1LjQ3OTI2QzEyLjY1ODggNS40NzkyNiAxMi41NTA3IDUuNDk0MDggMTIuNDQ3OSA1LjUyMTg2WiIgZmlsbD0iIzFEMUMyMyIvPgo8L3N2Zz4="), auto'
|
|
1169
1186
|
},
|
|
1170
|
-
fromNodeJSON(node, json) {
|
|
1171
|
-
initFormDataFromJSON(node, json);
|
|
1187
|
+
fromNodeJSON(node, json, isFirstCreate) {
|
|
1188
|
+
initFormDataFromJSON(node, json, isFirstCreate);
|
|
1172
1189
|
return;
|
|
1173
1190
|
},
|
|
1174
1191
|
toNodeJSON(node) {
|
|
1175
|
-
|
|
1192
|
+
var _a, _b;
|
|
1193
|
+
const nodeError = (_a = node.getData(FlowNodeErrorData)) == null ? void 0 : _a.getError();
|
|
1176
1194
|
if (nodeError) {
|
|
1177
1195
|
throw nodeError;
|
|
1178
1196
|
}
|
|
@@ -1180,8 +1198,8 @@ var WorkflowDocumentOptionsDefault = {
|
|
|
1180
1198
|
let formJSON = toFormJSON(node);
|
|
1181
1199
|
const metaData = {};
|
|
1182
1200
|
const nodeMeta = node.getNodeMeta();
|
|
1183
|
-
const subCanvas = nodeMeta.subCanvas
|
|
1184
|
-
if (subCanvas
|
|
1201
|
+
const subCanvas = (_b = nodeMeta.subCanvas) == null ? void 0 : _b.call(nodeMeta, node);
|
|
1202
|
+
if ((subCanvas == null ? void 0 : subCanvas.isCanvas) === false) {
|
|
1185
1203
|
const canvasNodeTransform = subCanvas.canvasNode.getData(FlowNodeTransformData2);
|
|
1186
1204
|
const { x, y } = canvasNodeTransform.transform.position;
|
|
1187
1205
|
metaData.canvasPosition = { x, y };
|
|
@@ -1284,6 +1302,7 @@ var WorkflowLinesManager = class {
|
|
|
1284
1302
|
return this.createLine(newPortInfo);
|
|
1285
1303
|
}
|
|
1286
1304
|
createLine(options) {
|
|
1305
|
+
var _a;
|
|
1287
1306
|
const { from, to, drawingTo, fromPort, toPort } = options;
|
|
1288
1307
|
const available = Boolean(from && to);
|
|
1289
1308
|
const key = options.key || WorkflowLineEntity.portInfoToLineId(options);
|
|
@@ -1293,7 +1312,7 @@ var WorkflowLinesManager = class {
|
|
|
1293
1312
|
line.validate();
|
|
1294
1313
|
return line;
|
|
1295
1314
|
}
|
|
1296
|
-
const fromNode = this.entityManager.getEntityById(from)
|
|
1315
|
+
const fromNode = (_a = this.entityManager.getEntityById(from)) == null ? void 0 : _a.getData(WorkflowNodeLinesData);
|
|
1297
1316
|
const toNode = to ? this.entityManager.getEntityById(to).getData(WorkflowNodeLinesData) : void 0;
|
|
1298
1317
|
if (!fromNode) {
|
|
1299
1318
|
return;
|
|
@@ -1311,26 +1330,24 @@ var WorkflowLinesManager = class {
|
|
|
1311
1330
|
});
|
|
1312
1331
|
this.registerData(line);
|
|
1313
1332
|
fromNode.addLine(line);
|
|
1314
|
-
toNode
|
|
1333
|
+
toNode == null ? void 0 : toNode.addLine(line);
|
|
1315
1334
|
line.onDispose(() => {
|
|
1316
1335
|
if (drawingTo) {
|
|
1317
1336
|
this.isDrawing = false;
|
|
1318
1337
|
}
|
|
1319
1338
|
fromNode.removeLine(line);
|
|
1320
|
-
toNode
|
|
1339
|
+
toNode == null ? void 0 : toNode.removeLine(line);
|
|
1321
1340
|
line.validate();
|
|
1322
1341
|
});
|
|
1323
|
-
line.
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
})
|
|
1333
|
-
);
|
|
1342
|
+
line.onDispose(() => {
|
|
1343
|
+
if (available) {
|
|
1344
|
+
this.onAvailableLinesChangeEmitter.fire({
|
|
1345
|
+
type: "DELETE_LINE" /* DELETE_LINE */,
|
|
1346
|
+
toJSON: () => line.toJSON(),
|
|
1347
|
+
entity: line
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
});
|
|
1334
1351
|
if (available) {
|
|
1335
1352
|
this.onAvailableLinesChangeEmitter.fire({
|
|
1336
1353
|
type: "ADD_LINE" /* ADD_LINE */,
|
|
@@ -1468,7 +1485,10 @@ var WorkflowLinesManager = class {
|
|
|
1468
1485
|
const allPorts = this.entityManager.getEntities(WorkflowPortEntity).filter((port) => port.node.flowNodeType !== "root");
|
|
1469
1486
|
const targetPort = allPorts.find((port) => port.isHovered(pos.x, pos.y));
|
|
1470
1487
|
if (targetPort) {
|
|
1471
|
-
const targetNode = this.document.getAllNodes().slice().reverse().filter((node) =>
|
|
1488
|
+
const targetNode = this.document.getAllNodes().slice().reverse().filter((node) => {
|
|
1489
|
+
var _a, _b;
|
|
1490
|
+
return ((_b = (_a = targetPort.node) == null ? void 0 : _a.parent) == null ? void 0 : _b.id) !== node.id;
|
|
1491
|
+
}).find((node) => node.getData(TransformData6).contains(pos.x, pos.y));
|
|
1472
1492
|
if (targetNode && targetNode !== targetPort.node) {
|
|
1473
1493
|
return;
|
|
1474
1494
|
}
|
|
@@ -1480,21 +1500,22 @@ var WorkflowLinesManager = class {
|
|
|
1480
1500
|
* @param pos - 鼠标位置
|
|
1481
1501
|
*/
|
|
1482
1502
|
getNodeFromMousePos(pos) {
|
|
1503
|
+
var _a, _b;
|
|
1483
1504
|
const allNodes = this.document.getAllNodes().sort((a, b) => this.getNodeIndex(a) - this.getNodeIndex(b));
|
|
1484
1505
|
const containNodes = [];
|
|
1485
1506
|
const { selection } = this.selectService;
|
|
1486
|
-
const zoom = this.entityManager.getEntity(PlaygroundConfigEntity2)
|
|
1507
|
+
const zoom = ((_b = (_a = this.entityManager.getEntity(PlaygroundConfigEntity2)) == null ? void 0 : _a.config) == null ? void 0 : _b.zoom) || 1;
|
|
1487
1508
|
allNodes.forEach((node) => {
|
|
1488
1509
|
const { bounds } = node.getData(FlowNodeTransformData3);
|
|
1489
1510
|
if (bounds.clone().pad(4 / zoom).contains(pos.x, pos.y)) {
|
|
1490
1511
|
containNodes.push(node);
|
|
1491
1512
|
}
|
|
1492
1513
|
});
|
|
1493
|
-
if (selection
|
|
1514
|
+
if (selection == null ? void 0 : selection.length) {
|
|
1494
1515
|
const filteredNodes = containNodes.filter(
|
|
1495
1516
|
(node) => selection.some((_node) => node.id === _node.id)
|
|
1496
1517
|
);
|
|
1497
|
-
if (filteredNodes
|
|
1518
|
+
if (filteredNodes == null ? void 0 : filteredNodes.length) {
|
|
1498
1519
|
return last(filteredNodes);
|
|
1499
1520
|
}
|
|
1500
1521
|
}
|
|
@@ -1531,7 +1552,7 @@ WorkflowLinesManager = __decorateClass([
|
|
|
1531
1552
|
// src/workflow-document.ts
|
|
1532
1553
|
import { customAlphabet } from "nanoid";
|
|
1533
1554
|
import { inject as inject5, injectable as injectable5, optional, postConstruct } from "inversify";
|
|
1534
|
-
import {
|
|
1555
|
+
import { Emitter as Emitter4 } from "@flowgram.ai/utils";
|
|
1535
1556
|
import { NodeEngineContext } from "@flowgram.ai/form-core";
|
|
1536
1557
|
import { FlowDocument, FlowNodeBaseType, FlowNodeTransformData as FlowNodeTransformData5 } from "@flowgram.ai/document";
|
|
1537
1558
|
import {
|
|
@@ -1543,16 +1564,16 @@ import {
|
|
|
1543
1564
|
|
|
1544
1565
|
// src/layout/free-layout.ts
|
|
1545
1566
|
import { inject as inject4, injectable as injectable4 } from "inversify";
|
|
1546
|
-
import {
|
|
1547
|
-
FlowDocumentProvider,
|
|
1548
|
-
FlowNodeTransformData as FlowNodeTransformData4
|
|
1549
|
-
} from "@flowgram.ai/document";
|
|
1550
|
-
import { PlaygroundConfigEntity as PlaygroundConfigEntity3, TransformData as TransformData7 } from "@flowgram.ai/core";
|
|
1551
1567
|
import {
|
|
1552
1568
|
PaddingSchema,
|
|
1553
1569
|
Rectangle as Rectangle7,
|
|
1554
1570
|
SizeSchema as SizeSchema2
|
|
1555
1571
|
} from "@flowgram.ai/utils";
|
|
1572
|
+
import {
|
|
1573
|
+
FlowDocumentProvider,
|
|
1574
|
+
FlowNodeTransformData as FlowNodeTransformData4
|
|
1575
|
+
} from "@flowgram.ai/document";
|
|
1576
|
+
import { PlaygroundConfigEntity as PlaygroundConfigEntity3, TransformData as TransformData7 } from "@flowgram.ai/core";
|
|
1556
1577
|
var FREE_LAYOUT_KEY = "free-layout";
|
|
1557
1578
|
var FreeLayout = class {
|
|
1558
1579
|
constructor() {
|
|
@@ -1565,7 +1586,8 @@ var FreeLayout = class {
|
|
|
1565
1586
|
* 更新布局
|
|
1566
1587
|
*/
|
|
1567
1588
|
update() {
|
|
1568
|
-
|
|
1589
|
+
var _a;
|
|
1590
|
+
if ((_a = this.document.root.getData(FlowNodeTransformData4)) == null ? void 0 : _a.localDirty) {
|
|
1569
1591
|
this.document.root.clearMemoGlobal();
|
|
1570
1592
|
}
|
|
1571
1593
|
}
|
|
@@ -1587,6 +1609,21 @@ var FreeLayout = class {
|
|
|
1587
1609
|
const parentTransform = node.parent.getData(FlowNodeTransformData4);
|
|
1588
1610
|
parentTransform.transform.fireChange();
|
|
1589
1611
|
}
|
|
1612
|
+
/**
|
|
1613
|
+
* 更新所有受影响的上下游节点
|
|
1614
|
+
*/
|
|
1615
|
+
updateAffectedTransform(node) {
|
|
1616
|
+
const transformData = node.transform;
|
|
1617
|
+
if (!transformData.localDirty) {
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
const allParents = this.getAllParents(node);
|
|
1621
|
+
const allBlocks = this.getAllBlocks(node).reverse();
|
|
1622
|
+
const affectedNodes = [...allBlocks, ...allParents];
|
|
1623
|
+
affectedNodes.forEach((node2) => {
|
|
1624
|
+
this.fireChange(node2);
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1590
1627
|
/**
|
|
1591
1628
|
* 获取节点的 padding 数据
|
|
1592
1629
|
* @param node
|
|
@@ -1632,6 +1669,30 @@ var FreeLayout = class {
|
|
|
1632
1669
|
getDefaultNodeOrigin() {
|
|
1633
1670
|
return { x: 0.5, y: 0 };
|
|
1634
1671
|
}
|
|
1672
|
+
getAllParents(node) {
|
|
1673
|
+
const parents = [];
|
|
1674
|
+
let current = node.parent;
|
|
1675
|
+
while (current) {
|
|
1676
|
+
parents.push(current);
|
|
1677
|
+
current = current.parent;
|
|
1678
|
+
}
|
|
1679
|
+
return parents;
|
|
1680
|
+
}
|
|
1681
|
+
getAllBlocks(node) {
|
|
1682
|
+
return node.blocks.reduce(
|
|
1683
|
+
(acc, child) => [...acc, ...this.getAllBlocks(child)],
|
|
1684
|
+
[node]
|
|
1685
|
+
);
|
|
1686
|
+
}
|
|
1687
|
+
fireChange(node) {
|
|
1688
|
+
const transformData = node == null ? void 0 : node.transform;
|
|
1689
|
+
if (!node || !(transformData == null ? void 0 : transformData.localDirty)) {
|
|
1690
|
+
return;
|
|
1691
|
+
}
|
|
1692
|
+
node.clearMemoGlobal();
|
|
1693
|
+
node.clearMemoLocal();
|
|
1694
|
+
transformData.transform.fireChange();
|
|
1695
|
+
}
|
|
1635
1696
|
};
|
|
1636
1697
|
__decorateClass([
|
|
1637
1698
|
inject4(PlaygroundConfigEntity3)
|
|
@@ -1654,7 +1715,6 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1654
1715
|
this.onContentChange = this._onContentChangeEmitter.event;
|
|
1655
1716
|
this._onReloadEmitter = new Emitter4();
|
|
1656
1717
|
this.onReload = this._onReloadEmitter.event;
|
|
1657
|
-
this.disposed = false;
|
|
1658
1718
|
/**
|
|
1659
1719
|
* 数据加载完成
|
|
1660
1720
|
*/
|
|
@@ -1683,12 +1743,14 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1683
1743
|
});
|
|
1684
1744
|
}
|
|
1685
1745
|
async load() {
|
|
1746
|
+
if (this.disposed) return;
|
|
1686
1747
|
this._loading = true;
|
|
1687
1748
|
await super.load();
|
|
1688
1749
|
this._loading = false;
|
|
1689
1750
|
this.onLoadedEmitter.fire();
|
|
1690
1751
|
}
|
|
1691
1752
|
async reload(json, delayTime = 0) {
|
|
1753
|
+
if (this.disposed) return;
|
|
1692
1754
|
this._loading = true;
|
|
1693
1755
|
this.clear();
|
|
1694
1756
|
this.fromJSON(json);
|
|
@@ -1701,10 +1763,14 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1701
1763
|
* @param json
|
|
1702
1764
|
*/
|
|
1703
1765
|
fromJSON(json, fireRender = true) {
|
|
1704
|
-
|
|
1705
|
-
|
|
1766
|
+
var _a, _b;
|
|
1767
|
+
if (this.disposed) return;
|
|
1768
|
+
const workflowJSON = {
|
|
1769
|
+
nodes: (_a = json.nodes) != null ? _a : [],
|
|
1770
|
+
edges: (_b = json.edges) != null ? _b : []
|
|
1771
|
+
};
|
|
1706
1772
|
this.entityManager.changeEntityLocked = true;
|
|
1707
|
-
this.renderJSON(
|
|
1773
|
+
this.renderJSON(workflowJSON);
|
|
1708
1774
|
this.entityManager.changeEntityLocked = false;
|
|
1709
1775
|
this.transformer.loading = false;
|
|
1710
1776
|
if (fireRender) {
|
|
@@ -1725,14 +1791,16 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1725
1791
|
* @param json
|
|
1726
1792
|
*/
|
|
1727
1793
|
createWorkflowNode(json, isClone = false, parentId) {
|
|
1794
|
+
var _a, _b, _c;
|
|
1728
1795
|
const isExistedNode = this.getNode(json.id);
|
|
1729
|
-
const parent = this.getNode(parentId
|
|
1796
|
+
const parent = (_a = this.getNode(parentId != null ? parentId : this.root.id)) != null ? _a : this.root;
|
|
1730
1797
|
const node = this.addNode(
|
|
1731
1798
|
{
|
|
1732
1799
|
...json,
|
|
1733
1800
|
parent
|
|
1734
1801
|
},
|
|
1735
1802
|
void 0,
|
|
1803
|
+
true,
|
|
1736
1804
|
true
|
|
1737
1805
|
);
|
|
1738
1806
|
const registry = node.getNodeRegistry();
|
|
@@ -1741,9 +1809,11 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1741
1809
|
const formData = getFlowNodeFormData(node);
|
|
1742
1810
|
const transform = node.getData(FlowNodeTransformData5);
|
|
1743
1811
|
const freeLayout = this.layout;
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1812
|
+
if (!isExistedNode) {
|
|
1813
|
+
transform.onDataChange(() => {
|
|
1814
|
+
freeLayout.syncTransform(node);
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1747
1817
|
let { position } = meta;
|
|
1748
1818
|
if (!position) {
|
|
1749
1819
|
position = this.getNodeDefaultPosition(json.type);
|
|
@@ -1762,44 +1832,44 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1762
1832
|
});
|
|
1763
1833
|
}
|
|
1764
1834
|
const positionData = node.getData(PositionData);
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1835
|
+
if (!isExistedNode) {
|
|
1836
|
+
positionData.onDataChange(() => {
|
|
1837
|
+
this.fireContentChange({
|
|
1838
|
+
type: "MOVE_NODE" /* MOVE_NODE */,
|
|
1839
|
+
toJSON: () => positionData.toJSON(),
|
|
1840
|
+
entity: node
|
|
1841
|
+
});
|
|
1770
1842
|
});
|
|
1771
|
-
}
|
|
1843
|
+
}
|
|
1772
1844
|
const subCanvas = this.getNodeSubCanvas(node);
|
|
1773
|
-
if (!isExistedNode && !subCanvas
|
|
1845
|
+
if (!isExistedNode && !(subCanvas == null ? void 0 : subCanvas.isCanvas)) {
|
|
1774
1846
|
this.fireContentChange({
|
|
1775
1847
|
type: "ADD_NODE" /* ADD_NODE */,
|
|
1776
1848
|
entity: node,
|
|
1777
1849
|
toJSON: () => this.toNodeJSON(node)
|
|
1778
1850
|
});
|
|
1779
|
-
node.
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
)
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
})
|
|
1798
|
-
);
|
|
1851
|
+
node.onDispose(() => {
|
|
1852
|
+
if (!node.parent || node.parent.flowNodeType === FlowNodeBaseType.ROOT) {
|
|
1853
|
+
return;
|
|
1854
|
+
}
|
|
1855
|
+
const parentTransform = node.parent.getData(FlowNodeTransformData5);
|
|
1856
|
+
parentTransform.fireChange();
|
|
1857
|
+
});
|
|
1858
|
+
let lastDeleteNodeData;
|
|
1859
|
+
node.preDispose.onDispose(() => {
|
|
1860
|
+
lastDeleteNodeData = this.toNodeJSON(node);
|
|
1861
|
+
});
|
|
1862
|
+
node.onDispose(() => {
|
|
1863
|
+
this.fireContentChange({
|
|
1864
|
+
type: "DELETE_NODE" /* DELETE_NODE */,
|
|
1865
|
+
entity: node,
|
|
1866
|
+
toJSON: () => lastDeleteNodeData
|
|
1867
|
+
});
|
|
1868
|
+
});
|
|
1799
1869
|
}
|
|
1800
1870
|
if (json.blocks) {
|
|
1801
1871
|
this.renderJSON(
|
|
1802
|
-
{ nodes: json.blocks, edges: json.edges
|
|
1872
|
+
{ nodes: json.blocks, edges: (_b = json.edges) != null ? _b : [] },
|
|
1803
1873
|
{
|
|
1804
1874
|
parent: node,
|
|
1805
1875
|
isClone
|
|
@@ -1809,21 +1879,39 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1809
1879
|
if (subCanvas) {
|
|
1810
1880
|
const canvasTransform = subCanvas.canvasNode.getData(TransformData8);
|
|
1811
1881
|
canvasTransform.update({
|
|
1812
|
-
position: subCanvas.parentNode.getNodeMeta()
|
|
1882
|
+
position: (_c = subCanvas.parentNode.getNodeMeta()) == null ? void 0 : _c.canvasPosition
|
|
1813
1883
|
});
|
|
1814
|
-
|
|
1815
|
-
subCanvas.
|
|
1884
|
+
if (!isExistedNode) {
|
|
1885
|
+
subCanvas.parentNode.onDispose(() => {
|
|
1886
|
+
subCanvas.canvasNode.dispose();
|
|
1887
|
+
});
|
|
1888
|
+
subCanvas.canvasNode.onDispose(() => {
|
|
1889
|
+
subCanvas.parentNode.dispose();
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
if (!isExistedNode) {
|
|
1894
|
+
this.onNodeCreateEmitter.fire({
|
|
1895
|
+
node,
|
|
1896
|
+
data: json,
|
|
1897
|
+
json
|
|
1816
1898
|
});
|
|
1817
|
-
|
|
1818
|
-
|
|
1899
|
+
} else {
|
|
1900
|
+
this.onNodeUpdateEmitter.fire({
|
|
1901
|
+
node,
|
|
1902
|
+
data: json,
|
|
1903
|
+
json
|
|
1819
1904
|
});
|
|
1820
1905
|
}
|
|
1821
|
-
this.onNodeCreateEmitter.fire({
|
|
1822
|
-
node,
|
|
1823
|
-
data: json
|
|
1824
|
-
});
|
|
1825
1906
|
return node;
|
|
1826
1907
|
}
|
|
1908
|
+
get layout() {
|
|
1909
|
+
const layout = this.layouts.find((layout2) => layout2.name == this.currentLayoutKey);
|
|
1910
|
+
if (!layout) {
|
|
1911
|
+
throw new Error(`Unknown flow layout: ${this.currentLayoutKey}`);
|
|
1912
|
+
}
|
|
1913
|
+
return layout;
|
|
1914
|
+
}
|
|
1827
1915
|
/**
|
|
1828
1916
|
* 获取默认的 x y 坐标, 默认为当前画布可视区域中心
|
|
1829
1917
|
* @param type
|
|
@@ -1860,11 +1948,11 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1860
1948
|
...json,
|
|
1861
1949
|
id,
|
|
1862
1950
|
type,
|
|
1863
|
-
meta: { position, ...json
|
|
1951
|
+
meta: { position, ...json == null ? void 0 : json.meta },
|
|
1864
1952
|
// TODO title 和 meta 要从注册数据去拿
|
|
1865
|
-
data: json
|
|
1866
|
-
blocks: json
|
|
1867
|
-
edges: json
|
|
1953
|
+
data: json == null ? void 0 : json.data,
|
|
1954
|
+
blocks: json == null ? void 0 : json.blocks,
|
|
1955
|
+
edges: json == null ? void 0 : json.edges
|
|
1868
1956
|
},
|
|
1869
1957
|
false,
|
|
1870
1958
|
parentID
|
|
@@ -1891,7 +1979,10 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1891
1979
|
}));
|
|
1892
1980
|
const startNodeId = allNode.find((node) => node.isStart).id;
|
|
1893
1981
|
const endNodeId = allNode.find((node) => node.isNodeEnd).id;
|
|
1894
|
-
const nodeInContainer = allNode.filter((node) =>
|
|
1982
|
+
const nodeInContainer = allNode.filter((node) => {
|
|
1983
|
+
var _a;
|
|
1984
|
+
return (_a = node.parent) == null ? void 0 : _a.getNodeMeta().isContainer;
|
|
1985
|
+
}).map((node) => node.id);
|
|
1895
1986
|
const associatedCache = /* @__PURE__ */ new Set([endNodeId, ...nodeInContainer]);
|
|
1896
1987
|
const bfs = (nodeId) => {
|
|
1897
1988
|
if (associatedCache.has(nodeId)) {
|
|
@@ -1926,7 +2017,7 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1926
2017
|
}
|
|
1927
2018
|
toNodeJSON(node) {
|
|
1928
2019
|
const subCanvas = this.getNodeSubCanvas(node);
|
|
1929
|
-
if (subCanvas
|
|
2020
|
+
if ((subCanvas == null ? void 0 : subCanvas.isCanvas) === true) {
|
|
1930
2021
|
return this.toNodeJSON(subCanvas.parentNode);
|
|
1931
2022
|
}
|
|
1932
2023
|
const json = this.toNodeJSONFromOptions(node);
|
|
@@ -1960,6 +2051,7 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1960
2051
|
return WorkflowDocumentOptionsDefault.toNodeJSON(node);
|
|
1961
2052
|
}
|
|
1962
2053
|
copyNode(node, newNodeId, format, position) {
|
|
2054
|
+
var _a;
|
|
1963
2055
|
let json = this.toNodeJSON(node);
|
|
1964
2056
|
if (format) {
|
|
1965
2057
|
json = format(json);
|
|
@@ -1981,7 +2073,7 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1981
2073
|
edges: json.edges
|
|
1982
2074
|
},
|
|
1983
2075
|
true,
|
|
1984
|
-
node.parent
|
|
2076
|
+
(_a = node.parent) == null ? void 0 : _a.id
|
|
1985
2077
|
);
|
|
1986
2078
|
}
|
|
1987
2079
|
copyNodeFromJSON(flowNodeType, nodeJSON, newNodeId, position, parentId) {
|
|
@@ -2028,131 +2120,35 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
2028
2120
|
* 导出数据
|
|
2029
2121
|
*/
|
|
2030
2122
|
toJSON() {
|
|
2123
|
+
var _a, _b;
|
|
2031
2124
|
const rootJSON = this.toNodeJSON(this.root);
|
|
2032
2125
|
return {
|
|
2033
|
-
nodes: rootJSON.blocks
|
|
2034
|
-
edges: rootJSON.edges
|
|
2126
|
+
nodes: (_a = rootJSON.blocks) != null ? _a : [],
|
|
2127
|
+
edges: (_b = rootJSON.edges) != null ? _b : []
|
|
2035
2128
|
};
|
|
2036
2129
|
}
|
|
2037
2130
|
dispose() {
|
|
2038
|
-
if (this.disposed) {
|
|
2039
|
-
return;
|
|
2040
|
-
}
|
|
2041
2131
|
super.dispose();
|
|
2042
|
-
this.disposed = true;
|
|
2043
2132
|
this._onReloadEmitter.dispose();
|
|
2044
2133
|
}
|
|
2045
|
-
getEdgeID(edge) {
|
|
2046
|
-
return WorkflowLineEntity.portInfoToLineId({
|
|
2047
|
-
from: edge.sourceNodeID,
|
|
2048
|
-
to: edge.targetNodeID,
|
|
2049
|
-
fromPort: edge.sourcePortID,
|
|
2050
|
-
toPort: edge.targetPortID
|
|
2051
|
-
});
|
|
2052
|
-
}
|
|
2053
|
-
/**
|
|
2054
|
-
* 拍平树形json结构,将结构信息提取到map
|
|
2055
|
-
*/
|
|
2056
|
-
flatJSON(json = { nodes: [], edges: [] }) {
|
|
2057
|
-
const nodeBlocks = /* @__PURE__ */ new Map();
|
|
2058
|
-
const nodeEdges = /* @__PURE__ */ new Map();
|
|
2059
|
-
const rootNodes = json.nodes ?? [];
|
|
2060
|
-
const rootEdges = json.edges ?? [];
|
|
2061
|
-
const flattenNodeJSONs = [...rootNodes];
|
|
2062
|
-
const flattenEdgeJSONs = [...rootEdges];
|
|
2063
|
-
const rootBlockIDs = rootNodes.map((node) => node.id);
|
|
2064
|
-
const rootEdgeIDs = rootEdges.map((edge) => this.getEdgeID(edge));
|
|
2065
|
-
nodeBlocks.set(FlowNodeBaseType.ROOT, rootBlockIDs);
|
|
2066
|
-
nodeEdges.set(FlowNodeBaseType.ROOT, rootEdgeIDs);
|
|
2067
|
-
rootNodes.forEach((nodeJSON) => {
|
|
2068
|
-
const { blocks, edges } = nodeJSON;
|
|
2069
|
-
if (blocks) {
|
|
2070
|
-
flattenNodeJSONs.push(...blocks);
|
|
2071
|
-
const blockIDs = [];
|
|
2072
|
-
blocks.forEach((block) => {
|
|
2073
|
-
blockIDs.push(block.id);
|
|
2074
|
-
});
|
|
2075
|
-
nodeBlocks.set(nodeJSON.id, blockIDs);
|
|
2076
|
-
delete nodeJSON.blocks;
|
|
2077
|
-
}
|
|
2078
|
-
if (edges) {
|
|
2079
|
-
flattenEdgeJSONs.push(...edges);
|
|
2080
|
-
const edgeIDs = [];
|
|
2081
|
-
edges.forEach((edge) => {
|
|
2082
|
-
const edgeID = this.getEdgeID(edge);
|
|
2083
|
-
edgeIDs.push(edgeID);
|
|
2084
|
-
});
|
|
2085
|
-
nodeEdges.set(nodeJSON.id, edgeIDs);
|
|
2086
|
-
delete nodeJSON.edges;
|
|
2087
|
-
}
|
|
2088
|
-
});
|
|
2089
|
-
const flattenJSON = {
|
|
2090
|
-
nodes: flattenNodeJSONs,
|
|
2091
|
-
edges: flattenEdgeJSONs
|
|
2092
|
-
};
|
|
2093
|
-
return {
|
|
2094
|
-
flattenJSON,
|
|
2095
|
-
nodeBlocks,
|
|
2096
|
-
nodeEdges
|
|
2097
|
-
};
|
|
2098
|
-
}
|
|
2099
|
-
/**
|
|
2100
|
-
* 对JSON进行分层
|
|
2101
|
-
*/
|
|
2102
|
-
nestJSON(flattenJSON, nodeBlocks, nodeEdges) {
|
|
2103
|
-
const nestJSON = {
|
|
2104
|
-
nodes: [],
|
|
2105
|
-
edges: []
|
|
2106
|
-
};
|
|
2107
|
-
const nodeMap = /* @__PURE__ */ new Map();
|
|
2108
|
-
const edgeMap = /* @__PURE__ */ new Map();
|
|
2109
|
-
const rootBlockSet = new Set(nodeBlocks.get(FlowNodeBaseType.ROOT) ?? []);
|
|
2110
|
-
const rootEdgeSet = new Set(nodeEdges.get(FlowNodeBaseType.ROOT) ?? []);
|
|
2111
|
-
flattenJSON.nodes.forEach((nodeJSON) => {
|
|
2112
|
-
nodeMap.set(nodeJSON.id, nodeJSON);
|
|
2113
|
-
});
|
|
2114
|
-
flattenJSON.edges.forEach((edgeJSON) => {
|
|
2115
|
-
const edgeID = this.getEdgeID(edgeJSON);
|
|
2116
|
-
edgeMap.set(edgeID, edgeJSON);
|
|
2117
|
-
});
|
|
2118
|
-
flattenJSON.nodes.forEach((nodeJSON) => {
|
|
2119
|
-
if (rootBlockSet.has(nodeJSON.id)) {
|
|
2120
|
-
nestJSON.nodes.push(nodeJSON);
|
|
2121
|
-
}
|
|
2122
|
-
if (nodeBlocks.has(nodeJSON.id)) {
|
|
2123
|
-
const blockIDs = nodeBlocks.get(nodeJSON.id);
|
|
2124
|
-
const blockJSONs = blockIDs.map((blockID) => nodeMap.get(blockID)).filter(Boolean);
|
|
2125
|
-
nodeJSON.blocks = blockJSONs;
|
|
2126
|
-
}
|
|
2127
|
-
if (nodeEdges.has(nodeJSON.id)) {
|
|
2128
|
-
const edgeIDs = nodeEdges.get(nodeJSON.id);
|
|
2129
|
-
const edgeJSONs = edgeIDs.map((edgeID) => edgeMap.get(edgeID)).filter(Boolean);
|
|
2130
|
-
nodeJSON.edges = edgeJSONs;
|
|
2131
|
-
}
|
|
2132
|
-
});
|
|
2133
|
-
flattenJSON.edges.forEach((edgeJSON) => {
|
|
2134
|
-
const edgeID = this.getEdgeID(edgeJSON);
|
|
2135
|
-
if (rootEdgeSet.has(edgeID)) {
|
|
2136
|
-
nestJSON.edges.push(edgeJSON);
|
|
2137
|
-
}
|
|
2138
|
-
});
|
|
2139
|
-
return nestJSON;
|
|
2140
|
-
}
|
|
2141
2134
|
/**
|
|
2142
2135
|
* 逐层创建节点和线条
|
|
2143
2136
|
*/
|
|
2144
2137
|
renderJSON(json, options) {
|
|
2145
|
-
|
|
2146
|
-
const
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2138
|
+
var _a, _b;
|
|
2139
|
+
const { parent = this.root, isClone = false } = options != null ? options : {};
|
|
2140
|
+
const containerID = (_b = (_a = this.getNodeSubCanvas(parent)) == null ? void 0 : _a.canvasNode.id) != null ? _b : parent.id;
|
|
2141
|
+
const nodes = json.nodes.map(
|
|
2142
|
+
(nodeJSON) => this.createWorkflowNode(nodeJSON, isClone, containerID)
|
|
2143
|
+
);
|
|
2144
|
+
const edges = json.edges.map((edge) => this.createWorkflowLine(edge, containerID)).filter(Boolean);
|
|
2145
|
+
return { nodes, edges };
|
|
2151
2146
|
}
|
|
2152
2147
|
getNodeSubCanvas(node) {
|
|
2148
|
+
var _a;
|
|
2153
2149
|
if (!node) return;
|
|
2154
2150
|
const nodeMeta = node.getNodeMeta();
|
|
2155
|
-
const subCanvas = nodeMeta.subCanvas
|
|
2151
|
+
const subCanvas = (_a = nodeMeta.subCanvas) == null ? void 0 : _a.call(nodeMeta, node);
|
|
2156
2152
|
return subCanvas;
|
|
2157
2153
|
}
|
|
2158
2154
|
getNodeChildren(node) {
|
|
@@ -2160,8 +2156,9 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
2160
2156
|
const subCanvas = this.getNodeSubCanvas(node);
|
|
2161
2157
|
const childrenWithCanvas = subCanvas ? subCanvas.canvasNode.collapsedChildren : node.collapsedChildren;
|
|
2162
2158
|
const children = childrenWithCanvas.filter((child) => {
|
|
2159
|
+
var _a, _b;
|
|
2163
2160
|
const childMeta = child.getNodeMeta();
|
|
2164
|
-
return !childMeta.subCanvas
|
|
2161
|
+
return !((_b = (_a = childMeta.subCanvas) == null ? void 0 : _a.call(childMeta, node)) == null ? void 0 : _b.isCanvas);
|
|
2165
2162
|
}).filter(Boolean);
|
|
2166
2163
|
return children;
|
|
2167
2164
|
}
|
|
@@ -2287,7 +2284,8 @@ var WorkflowDragService = class {
|
|
|
2287
2284
|
* 拖拽选中节点
|
|
2288
2285
|
* @param triggerEvent
|
|
2289
2286
|
*/
|
|
2290
|
-
startDragSelectedNodes(triggerEvent) {
|
|
2287
|
+
async startDragSelectedNodes(triggerEvent) {
|
|
2288
|
+
var _a;
|
|
2291
2289
|
let { selectedNodes } = this.selectService;
|
|
2292
2290
|
if (selectedNodes.length === 0 || this.playgroundConfig.readonly || this.playgroundConfig.disabled || this.isDragging) {
|
|
2293
2291
|
return Promise.resolve(false);
|
|
@@ -2297,7 +2295,6 @@ var WorkflowDragService = class {
|
|
|
2297
2295
|
if (sameParent && sameParent.flowNodeType !== FlowNodeBaseType2.ROOT) {
|
|
2298
2296
|
selectedNodes = [sameParent];
|
|
2299
2297
|
}
|
|
2300
|
-
const { altKey } = triggerEvent;
|
|
2301
2298
|
let startPosition = this.getNodesPosition(selectedNodes);
|
|
2302
2299
|
let startPositions = selectedNodes.map((node) => {
|
|
2303
2300
|
const transform = node.getData(TransformData9);
|
|
@@ -2311,7 +2308,6 @@ var WorkflowDragService = class {
|
|
|
2311
2308
|
type: "onDragStart",
|
|
2312
2309
|
nodes: selectedNodes,
|
|
2313
2310
|
startPositions,
|
|
2314
|
-
altKey,
|
|
2315
2311
|
dragEvent,
|
|
2316
2312
|
triggerEvent,
|
|
2317
2313
|
dragger
|
|
@@ -2320,25 +2316,6 @@ var WorkflowDragService = class {
|
|
|
2320
2316
|
onDrag: (dragEvent) => {
|
|
2321
2317
|
if (!dragSuccess && checkDragSuccess(Date.now() - startTime, dragEvent)) {
|
|
2322
2318
|
dragSuccess = true;
|
|
2323
|
-
if (altKey) {
|
|
2324
|
-
const tryCopyNodes = selectedNodes;
|
|
2325
|
-
if (tryCopyNodes.length > 0) {
|
|
2326
|
-
this.selectService.clear();
|
|
2327
|
-
this.commandService.executeCommand("PASTE_NODES" /* PASTE_NODES */, tryCopyNodes, true).then((newNodes) => {
|
|
2328
|
-
if (newNodes && Array.isArray(newNodes) && newNodes.length > 0) {
|
|
2329
|
-
selectedNodes = newNodes;
|
|
2330
|
-
startPosition = this.getNodesPosition(tryCopyNodes);
|
|
2331
|
-
startPositions = tryCopyNodes.filter((n) => !n.getNodeMeta().copyDisable).map((node) => {
|
|
2332
|
-
const transform = node.getData(TransformData9);
|
|
2333
|
-
return {
|
|
2334
|
-
x: transform.position.x,
|
|
2335
|
-
y: transform.position.y
|
|
2336
|
-
};
|
|
2337
|
-
});
|
|
2338
|
-
}
|
|
2339
|
-
});
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
2319
|
}
|
|
2343
2320
|
const offset = this.getDragPosOffset({
|
|
2344
2321
|
event: dragEvent,
|
|
@@ -2353,15 +2330,10 @@ var WorkflowDragService = class {
|
|
|
2353
2330
|
x: nodeStartPosition.x + offset.x,
|
|
2354
2331
|
y: nodeStartPosition.y + offset.y
|
|
2355
2332
|
};
|
|
2356
|
-
if (node.collapsedChildren?.length > 0) {
|
|
2357
|
-
node.collapsedChildren.forEach((childNode) => {
|
|
2358
|
-
const childNodeTransformData = childNode.getData(FlowNodeTransformData6);
|
|
2359
|
-
childNodeTransformData.fireChange();
|
|
2360
|
-
});
|
|
2361
|
-
}
|
|
2362
2333
|
transform.update({
|
|
2363
2334
|
position: newPosition
|
|
2364
2335
|
});
|
|
2336
|
+
this.document.layout.updateAffectedTransform(node);
|
|
2365
2337
|
positions.push(newPosition);
|
|
2366
2338
|
});
|
|
2367
2339
|
this._nodesDragEmitter.fire({
|
|
@@ -2369,7 +2341,6 @@ var WorkflowDragService = class {
|
|
|
2369
2341
|
nodes: selectedNodes,
|
|
2370
2342
|
startPositions,
|
|
2371
2343
|
positions,
|
|
2372
|
-
altKey,
|
|
2373
2344
|
dragEvent,
|
|
2374
2345
|
triggerEvent,
|
|
2375
2346
|
dragger
|
|
@@ -2381,14 +2352,13 @@ var WorkflowDragService = class {
|
|
|
2381
2352
|
type: "onDragEnd",
|
|
2382
2353
|
nodes: selectedNodes,
|
|
2383
2354
|
startPositions,
|
|
2384
|
-
altKey,
|
|
2385
2355
|
dragEvent,
|
|
2386
2356
|
triggerEvent,
|
|
2387
2357
|
dragger
|
|
2388
2358
|
});
|
|
2389
2359
|
}
|
|
2390
2360
|
});
|
|
2391
|
-
return dragger.start(triggerEvent.clientX, triggerEvent.clientY, this.playgroundConfig)
|
|
2361
|
+
return (_a = dragger.start(triggerEvent.clientX, triggerEvent.clientY, this.playgroundConfig)) == null ? void 0 : _a.then(() => dragSuccess);
|
|
2392
2362
|
}
|
|
2393
2363
|
/**
|
|
2394
2364
|
* 通过拖入卡片添加
|
|
@@ -2406,7 +2376,7 @@ var WorkflowDragService = class {
|
|
|
2406
2376
|
type,
|
|
2407
2377
|
position,
|
|
2408
2378
|
data,
|
|
2409
|
-
parent
|
|
2379
|
+
parent == null ? void 0 : parent.id
|
|
2410
2380
|
);
|
|
2411
2381
|
return node;
|
|
2412
2382
|
}
|
|
@@ -2456,7 +2426,7 @@ var WorkflowDragService = class {
|
|
|
2456
2426
|
);
|
|
2457
2427
|
return Rectangle8.intersects(draggingRect, transformRect);
|
|
2458
2428
|
});
|
|
2459
|
-
this.updateDropNode(collisionTransform
|
|
2429
|
+
this.updateDropNode(collisionTransform == null ? void 0 : collisionTransform.entity);
|
|
2460
2430
|
},
|
|
2461
2431
|
onDragEnd: async (e) => {
|
|
2462
2432
|
const dropNode = this._dropNode;
|
|
@@ -2573,7 +2543,8 @@ var WorkflowDragService = class {
|
|
|
2573
2543
|
}
|
|
2574
2544
|
/** 是否容器节点 */
|
|
2575
2545
|
isContainer(node) {
|
|
2576
|
-
|
|
2546
|
+
var _a;
|
|
2547
|
+
return (_a = node == null ? void 0 : node.getNodeMeta().isContainer) != null ? _a : false;
|
|
2577
2548
|
}
|
|
2578
2549
|
/**
|
|
2579
2550
|
* 获取节点整体位置
|
|
@@ -2598,7 +2569,7 @@ var WorkflowDragService = class {
|
|
|
2598
2569
|
}
|
|
2599
2570
|
updateDropNode(node) {
|
|
2600
2571
|
if (this._dropNode) {
|
|
2601
|
-
if (this._dropNode.id === node
|
|
2572
|
+
if (this._dropNode.id === (node == null ? void 0 : node.id)) {
|
|
2602
2573
|
return;
|
|
2603
2574
|
}
|
|
2604
2575
|
this.selectService.clear();
|
|
@@ -2620,7 +2591,7 @@ var WorkflowDragService = class {
|
|
|
2620
2591
|
this.hoverService.clearHovered();
|
|
2621
2592
|
}
|
|
2622
2593
|
handleDragOnNode(toNode, fromPort, line, toPort, originLine) {
|
|
2623
|
-
if (toPort && (originLine
|
|
2594
|
+
if (toPort && ((originLine == null ? void 0 : originLine.toPort) === toPort || toPort.portType === "input" && this.linesManager.canAddLine(fromPort, toPort, true))) {
|
|
2624
2595
|
this.hoverService.updateHoveredKey(toPort.id);
|
|
2625
2596
|
line.setToPort(toPort);
|
|
2626
2597
|
this._onDragLineEventEmitter.fire({
|
|
@@ -2642,14 +2613,15 @@ var WorkflowDragService = class {
|
|
|
2642
2613
|
}
|
|
2643
2614
|
}
|
|
2644
2615
|
childrenOfContainer(nodes) {
|
|
2616
|
+
var _a;
|
|
2645
2617
|
if (nodes.length === 0) {
|
|
2646
2618
|
return;
|
|
2647
2619
|
}
|
|
2648
|
-
const sourceContainer = nodes[0]
|
|
2620
|
+
const sourceContainer = (_a = nodes[0]) == null ? void 0 : _a.parent;
|
|
2649
2621
|
if (!sourceContainer || sourceContainer.collapsedChildren.length !== nodes.length) {
|
|
2650
2622
|
return;
|
|
2651
2623
|
}
|
|
2652
|
-
const valid = nodes.every((node) => node
|
|
2624
|
+
const valid = nodes.every((node) => (node == null ? void 0 : node.parent) === sourceContainer);
|
|
2653
2625
|
if (!valid) {
|
|
2654
2626
|
return;
|
|
2655
2627
|
}
|
|
@@ -2662,7 +2634,7 @@ var WorkflowDragService = class {
|
|
|
2662
2634
|
*/
|
|
2663
2635
|
async startDrawingLine(fromPort, event, originLine) {
|
|
2664
2636
|
const isFromInActivePort = !originLine && fromPort.isErrorPort() && fromPort.disabled;
|
|
2665
|
-
if (originLine
|
|
2637
|
+
if ((originLine == null ? void 0 : originLine.disabled) || isFromInActivePort || this.playgroundConfig.readonly || this.playgroundConfig.disabled) {
|
|
2666
2638
|
return { dragSuccess: false, newLine: void 0 };
|
|
2667
2639
|
}
|
|
2668
2640
|
this.selectService.clear();
|
|
@@ -2725,7 +2697,7 @@ var WorkflowDragService = class {
|
|
|
2725
2697
|
} else {
|
|
2726
2698
|
line.drawingTo = { x: dragPos.x, y: dragPos.y };
|
|
2727
2699
|
}
|
|
2728
|
-
originLine
|
|
2700
|
+
originLine == null ? void 0 : originLine.validate();
|
|
2729
2701
|
line.validate();
|
|
2730
2702
|
},
|
|
2731
2703
|
// eslint-disable-next-line complexity
|
|
@@ -2745,7 +2717,7 @@ var WorkflowDragService = class {
|
|
|
2745
2717
|
})
|
|
2746
2718
|
)
|
|
2747
2719
|
);
|
|
2748
|
-
line
|
|
2720
|
+
line == null ? void 0 : line.dispose();
|
|
2749
2721
|
this._onDragLineEventEmitter.fire({
|
|
2750
2722
|
type: "onDragEnd"
|
|
2751
2723
|
});
|
|
@@ -2753,7 +2725,7 @@ var WorkflowDragService = class {
|
|
|
2753
2725
|
originLine.highlightColor = "";
|
|
2754
2726
|
}
|
|
2755
2727
|
const end = () => {
|
|
2756
|
-
originLine
|
|
2728
|
+
originLine == null ? void 0 : originLine.validate();
|
|
2757
2729
|
deferred.resolve({ dragSuccess });
|
|
2758
2730
|
};
|
|
2759
2731
|
if (dragSuccess) {
|
|
@@ -2780,7 +2752,7 @@ var WorkflowDragService = class {
|
|
|
2780
2752
|
if (originLine && (!this.linesManager.canRemove(originLine, newLineInfo, false) || lineErrorReset)) {
|
|
2781
2753
|
return end();
|
|
2782
2754
|
} else {
|
|
2783
|
-
originLine
|
|
2755
|
+
originLine == null ? void 0 : originLine.dispose();
|
|
2784
2756
|
}
|
|
2785
2757
|
if (!toPort || !this.linesManager.canAddLine(fromPort, toPort, false)) {
|
|
2786
2758
|
return end();
|
|
@@ -2884,18 +2856,14 @@ var layoutToPositions = async (nodes, nodePositionMap) => {
|
|
|
2884
2856
|
const transform = node.getData(TransformData10);
|
|
2885
2857
|
const deltaX = (nodePositionMap[node.id].x - transform.position.x) * v.d / 100;
|
|
2886
2858
|
const deltaY = (nodePositionMap[node.id].y - transform.bounds.height / 2 - transform.position.y) * v.d / 100;
|
|
2887
|
-
if (node.collapsedChildren?.length > 0) {
|
|
2888
|
-
node.collapsedChildren.forEach((childNode) => {
|
|
2889
|
-
const childNodeTransformData = childNode.getData(FlowNodeTransformData7);
|
|
2890
|
-
childNodeTransformData.fireChange();
|
|
2891
|
-
});
|
|
2892
|
-
}
|
|
2893
2859
|
transform.update({
|
|
2894
2860
|
position: {
|
|
2895
2861
|
x: transform.position.x + deltaX,
|
|
2896
2862
|
y: transform.position.y + deltaY
|
|
2897
2863
|
}
|
|
2898
2864
|
});
|
|
2865
|
+
const document2 = node.document;
|
|
2866
|
+
document2.layout.updateAffectedTransform(node);
|
|
2899
2867
|
});
|
|
2900
2868
|
},
|
|
2901
2869
|
onComplete: () => {
|
|
@@ -3011,7 +2979,7 @@ function usePlaygroundReadonlyState(listenChange) {
|
|
|
3011
2979
|
if (listenChange) {
|
|
3012
2980
|
dispose = playground.config.onReadonlyOrDisabledChange(() => refresh());
|
|
3013
2981
|
}
|
|
3014
|
-
return () => dispose
|
|
2982
|
+
return () => dispose == null ? void 0 : dispose.dispose();
|
|
3015
2983
|
}, [listenChange]);
|
|
3016
2984
|
return playground.config.readonly;
|
|
3017
2985
|
}
|
|
@@ -3021,6 +2989,7 @@ function checkTargetDraggable(el) {
|
|
|
3021
2989
|
return el && el.tagName !== "INPUT" && el.tagName !== "TEXTAREA" && !el.closest(".flow-canvas-not-draggable");
|
|
3022
2990
|
}
|
|
3023
2991
|
function useNodeRender(nodeFromProps) {
|
|
2992
|
+
var _a, _b;
|
|
3024
2993
|
const node = nodeFromProps || useContext(PlaygroundEntityContext);
|
|
3025
2994
|
const renderData = node.getData(FlowNodeRenderData3);
|
|
3026
2995
|
const portsData = node.getData(WorkflowNodePortsData);
|
|
@@ -3044,6 +3013,7 @@ function useNodeRender(nodeFromProps) {
|
|
|
3044
3013
|
}, []);
|
|
3045
3014
|
const startDrag = useCallback(
|
|
3046
3015
|
(e) => {
|
|
3016
|
+
var _a2;
|
|
3047
3017
|
e.preventDefault();
|
|
3048
3018
|
if (!selectionService.isSelected(node.id)) {
|
|
3049
3019
|
selectNode(e);
|
|
@@ -3052,7 +3022,7 @@ function useNodeRender(nodeFromProps) {
|
|
|
3052
3022
|
return;
|
|
3053
3023
|
}
|
|
3054
3024
|
isDragging.current = true;
|
|
3055
|
-
dragService.startDragSelectedNodes(e)
|
|
3025
|
+
(_a2 = dragService.startDragSelectedNodes(e)) == null ? void 0 : _a2.finally(
|
|
3056
3026
|
() => setTimeout(() => {
|
|
3057
3027
|
isDragging.current = false;
|
|
3058
3028
|
})
|
|
@@ -3078,15 +3048,17 @@ function useNodeRender(nodeFromProps) {
|
|
|
3078
3048
|
);
|
|
3079
3049
|
const deleteNode = useCallback(() => node.dispose(), [node]);
|
|
3080
3050
|
useListenEvents(portsData.onDataChange);
|
|
3081
|
-
const isFirefox = navigator
|
|
3051
|
+
const isFirefox = (_b = (_a = navigator == null ? void 0 : navigator.userAgent) == null ? void 0 : _a.includes) == null ? void 0 : _b.call(_a, "Firefox");
|
|
3082
3052
|
const onFocus = useCallback(() => {
|
|
3053
|
+
var _a2;
|
|
3083
3054
|
if (isFirefox) {
|
|
3084
|
-
nodeRef.current
|
|
3055
|
+
(_a2 = nodeRef.current) == null ? void 0 : _a2.setAttribute("draggable", "false");
|
|
3085
3056
|
}
|
|
3086
3057
|
}, []);
|
|
3087
3058
|
const onBlur = useCallback(() => {
|
|
3059
|
+
var _a2;
|
|
3088
3060
|
if (isFirefox) {
|
|
3089
|
-
nodeRef.current
|
|
3061
|
+
(_a2 = nodeRef.current) == null ? void 0 : _a2.setAttribute("draggable", "true");
|
|
3090
3062
|
}
|
|
3091
3063
|
}, []);
|
|
3092
3064
|
const getExtInfo = useCallback(() => node.getExtInfo(), [node]);
|
|
@@ -3097,7 +3069,7 @@ function useNodeRender(nodeFromProps) {
|
|
|
3097
3069
|
[node]
|
|
3098
3070
|
);
|
|
3099
3071
|
const form = useMemo(() => getNodeForm(node), [node]);
|
|
3100
|
-
const formState = useObserve(form
|
|
3072
|
+
const formState = useObserve(form == null ? void 0 : form.state);
|
|
3101
3073
|
const toggleExpand = useCallback(() => {
|
|
3102
3074
|
renderData.toggleExpand();
|
|
3103
3075
|
}, [renderData]);
|
|
@@ -3233,7 +3205,8 @@ var WorkflowSimpleLineContribution = class {
|
|
|
3233
3205
|
this.entity = entity;
|
|
3234
3206
|
}
|
|
3235
3207
|
get path() {
|
|
3236
|
-
|
|
3208
|
+
var _a, _b;
|
|
3209
|
+
return (_b = (_a = this.data) == null ? void 0 : _a.path) != null ? _b : "";
|
|
3237
3210
|
}
|
|
3238
3211
|
calcDistance(pos) {
|
|
3239
3212
|
if (!this.data) {
|