@blueking/flow-canvas 0.0.1-beta.1 → 0.0.1-beta.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/README.md +528 -29
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +983 -992
- package/dist/runtime/canvas-runtime-core.vue.d.ts +1 -6
- package/dist/runtime/overlay-manager.d.ts +1 -2
- package/dist/runtime/use-node-hover.d.ts +3 -1
- package/dist/shell/node-actions-toolbar.vue.d.ts +4 -0
- package/dist/shell/toolbar-items.d.ts +3 -1
- package/dist/style.css +1 -1
- package/dist/types/flow-model.d.ts +1 -1
- package/dist/types/overlay.d.ts +0 -14
- package/dist/types/schema.d.ts +5 -2
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { Graph as
|
|
3
|
-
import { register as
|
|
1
|
+
import { ref as z, computed as j, onScopeDispose as Le, defineComponent as re, onBeforeUnmount as Se, createElementBlock as S, openBlock as k, normalizeStyle as me, createElementVNode as A, createVNode as Be, createCommentVNode as H, normalizeClass as W, Transition as ze, withCtx as Ne, withModifiers as He, createTextVNode as De, renderSlot as fe, onMounted as Fe, watch as le, createBlock as ve, Fragment as ie, renderList as ye, toDisplayString as de, unref as Ue, resolveDynamicComponent as qe, inject as Ge } from "vue";
|
|
2
|
+
import { Graph as Ve } from "@antv/x6";
|
|
3
|
+
import { register as We } from "@antv/x6-vue-shape";
|
|
4
4
|
function io() {
|
|
5
5
|
return {
|
|
6
6
|
version: "1.0",
|
|
@@ -13,12 +13,12 @@ class K extends Error {
|
|
|
13
13
|
super(e), this.name = "CanvasConstraintError";
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class Qe extends Error {
|
|
17
17
|
constructor(e) {
|
|
18
18
|
super(e), this.name = "CanvasSchemaError";
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function be(s, e, t) {
|
|
22
22
|
if (e.length === 0) {
|
|
23
23
|
if (t === void 0) return;
|
|
24
24
|
if (typeof t != "object" || t === null || Array.isArray(t))
|
|
@@ -28,99 +28,99 @@ function xe(s, e, t) {
|
|
|
28
28
|
const o = s ? { ...s } : {};
|
|
29
29
|
let n = o;
|
|
30
30
|
for (let r = 0; r < e.length - 1; r++) {
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const l = e[r], a = n[l];
|
|
32
|
+
a && typeof a == "object" && !Array.isArray(a) ? n[l] = { ...a } : n[l] = {}, n = n[l];
|
|
33
33
|
}
|
|
34
34
|
const i = e[e.length - 1];
|
|
35
35
|
return t === void 0 ? delete n[i] : n[i] = t, o;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function Me(s, e) {
|
|
38
38
|
switch (e.type) {
|
|
39
39
|
case "node.add":
|
|
40
|
-
return
|
|
40
|
+
return Xe(s, e.node);
|
|
41
41
|
case "node.move":
|
|
42
|
-
return
|
|
42
|
+
return Ke(s, e.nodeId, e.position);
|
|
43
43
|
case "node.remove":
|
|
44
|
-
return
|
|
44
|
+
return Ye(s, e.nodeId);
|
|
45
45
|
case "node.update":
|
|
46
|
-
return
|
|
46
|
+
return Ze(s, e.nodeId, e.patch);
|
|
47
47
|
case "node.set-payload":
|
|
48
|
-
return
|
|
48
|
+
return Je(s, e.nodeId, e.path, e.value);
|
|
49
49
|
case "node.set-extensions":
|
|
50
|
-
return
|
|
50
|
+
return et(s, e.nodeId, e.path, e.value);
|
|
51
51
|
case "edge.add":
|
|
52
|
-
return
|
|
52
|
+
return tt(s, e.edge);
|
|
53
53
|
case "edge.remove":
|
|
54
|
-
return
|
|
54
|
+
return ot(s, e.edgeId);
|
|
55
55
|
case "edge.reconnect":
|
|
56
|
-
return
|
|
56
|
+
return nt(s, e.edgeId, e.source, e.target);
|
|
57
57
|
case "edge.update":
|
|
58
|
-
return
|
|
58
|
+
return st(s, e.edgeId, e.patch);
|
|
59
59
|
case "edge.set-payload":
|
|
60
|
-
return
|
|
60
|
+
return it(s, e.edgeId, e.path, e.value);
|
|
61
61
|
case "edge.label.update":
|
|
62
|
-
return
|
|
62
|
+
return rt(s, e.edgeId, e.labelId, e.patch);
|
|
63
63
|
case "model.set-meta":
|
|
64
|
-
return
|
|
64
|
+
return at(s, e.path, e.value);
|
|
65
65
|
default:
|
|
66
66
|
throw new K(`Unknown command type: ${e.type}`);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function pe(s, e) {
|
|
70
70
|
const t = s.nodes[e];
|
|
71
71
|
if (!t) throw new K(`Node "${e}" does not exist`);
|
|
72
72
|
return t;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function ge(s, e) {
|
|
75
75
|
const t = s.edges[e];
|
|
76
76
|
if (!t) throw new K(`Edge "${e}" does not exist`);
|
|
77
77
|
return t;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function ce(s, e, t) {
|
|
80
80
|
const o = s.nodes[e.nodeId];
|
|
81
81
|
if (!o)
|
|
82
82
|
throw new K(`${t} node "${e.nodeId}" does not exist`);
|
|
83
83
|
if (e.portId && o.ports && !o.ports.some((i) => i.id === e.portId))
|
|
84
84
|
throw new K(`${t} port "${e.portId}" not found on node "${e.nodeId}"`);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function we(s, e, t) {
|
|
87
87
|
return { ...s, nodes: { ...s.nodes, [e]: t } };
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function xe(s, e, t) {
|
|
90
90
|
return { ...s, edges: { ...s.edges, [e]: t } };
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function Xe(s, e) {
|
|
93
93
|
if (s.nodes[e.id])
|
|
94
94
|
throw new K(`Node id "${e.id}" already exists`);
|
|
95
95
|
return { ...s, nodes: { ...s.nodes, [e.id]: e } };
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
const o =
|
|
99
|
-
return
|
|
97
|
+
function Ke(s, e, t) {
|
|
98
|
+
const o = pe(s, e);
|
|
99
|
+
return we(s, e, { ...o, position: t });
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
101
|
+
function Ye(s, e) {
|
|
102
|
+
pe(s, e);
|
|
103
103
|
const { [e]: t, ...o } = s.nodes, n = {};
|
|
104
104
|
for (const [i, r] of Object.entries(s.edges))
|
|
105
105
|
r.source.nodeId !== e && r.target.nodeId !== e && (n[i] = r);
|
|
106
106
|
return { ...s, nodes: o, edges: n };
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
const o =
|
|
110
|
-
return
|
|
108
|
+
function Ze(s, e, t) {
|
|
109
|
+
const o = pe(s, e);
|
|
110
|
+
return we(s, e, { ...o, ...t, id: o.id });
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
const n =
|
|
114
|
-
return
|
|
112
|
+
function Je(s, e, t, o) {
|
|
113
|
+
const n = pe(s, e), i = be(n.payload, t, o);
|
|
114
|
+
return we(s, e, { ...n, payload: i });
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
const n =
|
|
118
|
-
return
|
|
116
|
+
function et(s, e, t, o) {
|
|
117
|
+
const n = pe(s, e), i = be(n.extensions, t, o);
|
|
118
|
+
return we(s, e, { ...n, extensions: i });
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function tt(s, e) {
|
|
121
121
|
if (s.edges[e.id])
|
|
122
122
|
throw new K(`Edge id "${e.id}" already exists`);
|
|
123
|
-
if (
|
|
123
|
+
if (ce(s, e.source, "Source"), ce(s, e.target, "Target"), e.labels) {
|
|
124
124
|
const t = /* @__PURE__ */ new Set();
|
|
125
125
|
for (const o of e.labels) {
|
|
126
126
|
if (t.has(o.id))
|
|
@@ -130,93 +130,93 @@ function nt(s, e) {
|
|
|
130
130
|
}
|
|
131
131
|
return { ...s, edges: { ...s.edges, [e.id]: e } };
|
|
132
132
|
}
|
|
133
|
-
function
|
|
134
|
-
|
|
133
|
+
function ot(s, e) {
|
|
134
|
+
ge(s, e);
|
|
135
135
|
const { [e]: t, ...o } = s.edges;
|
|
136
136
|
return { ...s, edges: o };
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
const n =
|
|
140
|
-
return
|
|
138
|
+
function nt(s, e, t, o) {
|
|
139
|
+
const n = ge(s, e), i = t ?? n.source, r = o ?? n.target;
|
|
140
|
+
return ce(s, i, "Source"), ce(s, r, "Target"), xe(s, e, { ...n, source: i, target: r });
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
const o =
|
|
144
|
-
return t.source &&
|
|
142
|
+
function st(s, e, t) {
|
|
143
|
+
const o = ge(s, e), n = { ...o, ...t, id: o.id };
|
|
144
|
+
return t.source && ce(s, n.source, "Source"), t.target && ce(s, n.target, "Target"), xe(s, e, n);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
const n =
|
|
148
|
-
return
|
|
146
|
+
function it(s, e, t, o) {
|
|
147
|
+
const n = ge(s, e), i = be(n.payload, t, o);
|
|
148
|
+
return xe(s, e, { ...n, payload: i });
|
|
149
149
|
}
|
|
150
|
-
function
|
|
151
|
-
const n =
|
|
150
|
+
function rt(s, e, t, o) {
|
|
151
|
+
const n = ge(s, e);
|
|
152
152
|
if (!n.labels)
|
|
153
153
|
throw new K(`Edge "${e}" has no labels`);
|
|
154
|
-
const i = n.labels.findIndex((
|
|
154
|
+
const i = n.labels.findIndex((l) => l.id === t);
|
|
155
155
|
if (i === -1)
|
|
156
156
|
throw new K(`Label "${t}" not found in edge "${e}"`);
|
|
157
157
|
const r = [...n.labels];
|
|
158
|
-
return r[i] = { ...r[i], ...o, id: t },
|
|
158
|
+
return r[i] = { ...r[i], ...o, id: t }, xe(s, e, { ...n, labels: r });
|
|
159
159
|
}
|
|
160
|
-
function
|
|
161
|
-
const o =
|
|
160
|
+
function at(s, e, t) {
|
|
161
|
+
const o = be(s.meta, e, t);
|
|
162
162
|
return { ...s, meta: o };
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
const t = e?.maxHistorySize ?? 100, o =
|
|
166
|
-
function
|
|
167
|
-
r.value = n.length > 0,
|
|
164
|
+
function lt(s, e) {
|
|
165
|
+
const t = e?.maxHistorySize ?? 100, o = z(s), n = [], i = [], r = z(!1), l = z(!1);
|
|
166
|
+
function a() {
|
|
167
|
+
r.value = n.length > 0, l.value = i.length > 0;
|
|
168
168
|
}
|
|
169
169
|
function c(b) {
|
|
170
|
-
const
|
|
171
|
-
let
|
|
172
|
-
for (const
|
|
173
|
-
|
|
174
|
-
return n.push({ snapshot:
|
|
170
|
+
const y = o.value;
|
|
171
|
+
let m = y;
|
|
172
|
+
for (const R of b.commands)
|
|
173
|
+
m = Me(m, R);
|
|
174
|
+
return n.push({ snapshot: y, envelope: b }), n.length > t && n.shift(), i.length = 0, o.value = m, a(), m;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function d() {
|
|
177
177
|
const b = n.pop();
|
|
178
|
-
return b ? (i.push({ snapshot: o.value, envelope: b.envelope }), o.value = b.snapshot,
|
|
178
|
+
return b ? (i.push({ snapshot: o.value, envelope: b.envelope }), o.value = b.snapshot, a(), b.snapshot) : null;
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function g() {
|
|
181
181
|
const b = i.pop();
|
|
182
182
|
if (!b) return null;
|
|
183
183
|
n.push({ snapshot: o.value, envelope: b.envelope });
|
|
184
|
-
let
|
|
185
|
-
for (const
|
|
186
|
-
|
|
187
|
-
return o.value =
|
|
184
|
+
let y = o.value;
|
|
185
|
+
for (const m of b.envelope.commands)
|
|
186
|
+
y = Me(y, m);
|
|
187
|
+
return o.value = y, a(), y;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
190
|
-
n.length = 0, i.length = 0,
|
|
189
|
+
function p() {
|
|
190
|
+
n.length = 0, i.length = 0, a();
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function u() {
|
|
193
193
|
return o.value;
|
|
194
194
|
}
|
|
195
|
-
function
|
|
196
|
-
o.value = b,
|
|
195
|
+
function N(b) {
|
|
196
|
+
o.value = b, p();
|
|
197
197
|
}
|
|
198
198
|
return {
|
|
199
199
|
currentFlowModel: o,
|
|
200
200
|
execute: c,
|
|
201
|
-
undo:
|
|
202
|
-
redo:
|
|
201
|
+
undo: d,
|
|
202
|
+
redo: g,
|
|
203
203
|
canUndo: r,
|
|
204
|
-
canRedo:
|
|
204
|
+
canRedo: l,
|
|
205
205
|
get undoStack() {
|
|
206
206
|
return n.map((b) => b.envelope);
|
|
207
207
|
},
|
|
208
208
|
get redoStack() {
|
|
209
209
|
return i.map((b) => b.envelope);
|
|
210
210
|
},
|
|
211
|
-
clear:
|
|
212
|
-
createSnapshot:
|
|
213
|
-
replaceFlowModel:
|
|
211
|
+
clear: p,
|
|
212
|
+
createSnapshot: u,
|
|
213
|
+
replaceFlowModel: N
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function dt(s) {
|
|
217
217
|
return s !== null && typeof s == "object" && s.rejected === !0;
|
|
218
218
|
}
|
|
219
|
-
class
|
|
219
|
+
class ct {
|
|
220
220
|
plugins = [];
|
|
221
221
|
editorContext = null;
|
|
222
222
|
runtimeCtx = null;
|
|
@@ -251,12 +251,12 @@ class ft {
|
|
|
251
251
|
*/
|
|
252
252
|
createSafeRuntimeContext(e, t) {
|
|
253
253
|
const o = this, n = new Proxy(e.graph, {
|
|
254
|
-
get(i, r,
|
|
255
|
-
const
|
|
256
|
-
return r === "use" && typeof
|
|
254
|
+
get(i, r, l) {
|
|
255
|
+
const a = Reflect.get(i, r, l);
|
|
256
|
+
return r === "use" && typeof a == "function" ? function(...d) {
|
|
257
257
|
if (o.runtimeVersion === t)
|
|
258
|
-
return
|
|
259
|
-
} :
|
|
258
|
+
return a.apply(i, d);
|
|
259
|
+
} : a;
|
|
260
260
|
}
|
|
261
261
|
});
|
|
262
262
|
return { ...e, graph: n };
|
|
@@ -281,7 +281,7 @@ class ft {
|
|
|
281
281
|
source: o.name
|
|
282
282
|
}
|
|
283
283
|
};
|
|
284
|
-
if (
|
|
284
|
+
if (dt(i))
|
|
285
285
|
return {
|
|
286
286
|
rejected: !0,
|
|
287
287
|
error: {
|
|
@@ -374,42 +374,42 @@ class ft {
|
|
|
374
374
|
const n = o ?? e.commands;
|
|
375
375
|
let i = t.flowModel.value;
|
|
376
376
|
for (const r of n)
|
|
377
|
-
i =
|
|
377
|
+
i = Me(i, r);
|
|
378
378
|
return i;
|
|
379
379
|
}
|
|
380
380
|
};
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
function ro(s) {
|
|
384
|
-
const {
|
|
385
|
-
function
|
|
384
|
+
const { schema: e, plugins: t = [], historyOptions: o } = s, n = { version: "1.0", ...s.initialFlowModel }, i = lt(n, o), r = z(s.mode ?? "edit"), l = z(!1), a = z(null), c = z([]), d = {}, g = new ct();
|
|
385
|
+
function p(y, m, R, h = "user:toolbar") {
|
|
386
386
|
const v = {
|
|
387
387
|
id: `history-${Date.now()}`,
|
|
388
|
-
source:
|
|
389
|
-
label:
|
|
388
|
+
source: h,
|
|
389
|
+
label: y,
|
|
390
390
|
timestamp: Date.now(),
|
|
391
391
|
commands: []
|
|
392
392
|
};
|
|
393
|
-
|
|
393
|
+
g.afterCommand(v, m, R), c.value = g.collectToolbarItems(), s.onCommandResult?.({
|
|
394
394
|
status: "applied",
|
|
395
395
|
envelope: v,
|
|
396
|
-
flowModel:
|
|
396
|
+
flowModel: R
|
|
397
397
|
}), s.onFlowModelChange?.({
|
|
398
|
-
flowModel:
|
|
399
|
-
prevFlowModel:
|
|
398
|
+
flowModel: R,
|
|
399
|
+
prevFlowModel: m,
|
|
400
400
|
envelope: v,
|
|
401
|
-
source:
|
|
401
|
+
source: h
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
-
const
|
|
404
|
+
const u = {
|
|
405
405
|
execute: i.execute,
|
|
406
406
|
undo() {
|
|
407
|
-
const
|
|
408
|
-
return
|
|
407
|
+
const y = i.currentFlowModel.value, m = i.undo();
|
|
408
|
+
return m && p("撤销", y, m), m;
|
|
409
409
|
},
|
|
410
410
|
redo() {
|
|
411
|
-
const
|
|
412
|
-
return
|
|
411
|
+
const y = i.currentFlowModel.value, m = i.redo();
|
|
412
|
+
return m && p("重做", y, m), m;
|
|
413
413
|
},
|
|
414
414
|
get canUndo() {
|
|
415
415
|
return i.canUndo;
|
|
@@ -425,82 +425,82 @@ function ro(s) {
|
|
|
425
425
|
},
|
|
426
426
|
clear: i.clear,
|
|
427
427
|
createSnapshot: i.createSnapshot,
|
|
428
|
-
replaceFlowModel(
|
|
429
|
-
const
|
|
430
|
-
i.replaceFlowModel(
|
|
431
|
-
}
|
|
432
|
-
},
|
|
433
|
-
flowModel:
|
|
434
|
-
history:
|
|
435
|
-
schema:
|
|
428
|
+
replaceFlowModel(y) {
|
|
429
|
+
const m = i.currentFlowModel.value;
|
|
430
|
+
i.replaceFlowModel(y), p("替换 FlowModel", m, y, "system:replace");
|
|
431
|
+
}
|
|
432
|
+
}, N = {
|
|
433
|
+
flowModel: j(() => i.currentFlowModel.value),
|
|
434
|
+
history: u,
|
|
435
|
+
schema: e,
|
|
436
436
|
mode: r,
|
|
437
437
|
executeCommand: b,
|
|
438
|
-
replaceFlowModel(
|
|
439
|
-
|
|
438
|
+
replaceFlowModel(y) {
|
|
439
|
+
u.replaceFlowModel(y);
|
|
440
440
|
},
|
|
441
|
-
setMode(
|
|
442
|
-
r.value =
|
|
441
|
+
setMode(y) {
|
|
442
|
+
r.value = y;
|
|
443
443
|
},
|
|
444
|
-
selectionMode:
|
|
445
|
-
setSelectionMode(
|
|
446
|
-
|
|
444
|
+
selectionMode: l,
|
|
445
|
+
setSelectionMode(y) {
|
|
446
|
+
l.value = y;
|
|
447
447
|
},
|
|
448
|
-
api:
|
|
448
|
+
api: a,
|
|
449
449
|
toolbarItems: c,
|
|
450
|
-
extendedApi:
|
|
451
|
-
_pluginManager:
|
|
450
|
+
extendedApi: d,
|
|
451
|
+
_pluginManager: g
|
|
452
452
|
};
|
|
453
|
-
|
|
454
|
-
flowModel:
|
|
455
|
-
history:
|
|
456
|
-
schema:
|
|
453
|
+
g.install(t, {
|
|
454
|
+
flowModel: N.flowModel,
|
|
455
|
+
history: u,
|
|
456
|
+
schema: e,
|
|
457
457
|
mode: r,
|
|
458
458
|
executeCommand: b
|
|
459
|
-
}), c.value =
|
|
460
|
-
|
|
459
|
+
}), c.value = g.collectToolbarItems(), Le(() => {
|
|
460
|
+
g.dispose();
|
|
461
461
|
});
|
|
462
|
-
function b(
|
|
463
|
-
const
|
|
464
|
-
if ("rejected" in
|
|
462
|
+
function b(y) {
|
|
463
|
+
const m = g.transformCommand(y);
|
|
464
|
+
if ("rejected" in m) {
|
|
465
465
|
const v = {
|
|
466
466
|
status: "rejected",
|
|
467
|
-
envelope:
|
|
468
|
-
error:
|
|
467
|
+
envelope: y,
|
|
468
|
+
error: m.error
|
|
469
469
|
};
|
|
470
470
|
return s.onCommandResult?.(v), v;
|
|
471
471
|
}
|
|
472
|
-
const
|
|
472
|
+
const R = m.envelope, h = i.currentFlowModel.value;
|
|
473
473
|
try {
|
|
474
|
-
const v = i.execute(
|
|
474
|
+
const v = i.execute(R), I = {
|
|
475
475
|
status: "applied",
|
|
476
|
-
envelope:
|
|
476
|
+
envelope: R,
|
|
477
477
|
flowModel: v
|
|
478
478
|
};
|
|
479
|
-
return
|
|
479
|
+
return g.afterCommand(R, h, v), c.value = g.collectToolbarItems(), s.onCommandResult?.(I), s.onFlowModelChange?.({
|
|
480
480
|
flowModel: v,
|
|
481
|
-
prevFlowModel:
|
|
482
|
-
envelope:
|
|
483
|
-
source:
|
|
484
|
-
}),
|
|
481
|
+
prevFlowModel: h,
|
|
482
|
+
envelope: R,
|
|
483
|
+
source: R.source
|
|
484
|
+
}), I;
|
|
485
485
|
} catch (v) {
|
|
486
486
|
if (v instanceof K) {
|
|
487
|
-
const
|
|
487
|
+
const I = {
|
|
488
488
|
status: "invalid",
|
|
489
|
-
envelope:
|
|
489
|
+
envelope: R,
|
|
490
490
|
error: {
|
|
491
491
|
code: "constraint_violated",
|
|
492
492
|
reason: v.message,
|
|
493
493
|
source: "engine"
|
|
494
494
|
}
|
|
495
495
|
};
|
|
496
|
-
return s.onCommandResult?.(
|
|
496
|
+
return s.onCommandResult?.(I), I;
|
|
497
497
|
}
|
|
498
498
|
throw v;
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
|
-
return
|
|
501
|
+
return N;
|
|
502
502
|
}
|
|
503
|
-
class
|
|
503
|
+
class ut {
|
|
504
504
|
graph;
|
|
505
505
|
schema;
|
|
506
506
|
shapeRegistry;
|
|
@@ -586,11 +586,11 @@ class pt {
|
|
|
586
586
|
for (const [o, n] of Object.entries(e.nodes)) {
|
|
587
587
|
const i = this.schema.nodeTypes[n.type];
|
|
588
588
|
if (!i)
|
|
589
|
-
throw new
|
|
589
|
+
throw new Qe(
|
|
590
590
|
`Unknown node type "${n.type}" for node "${o}". Registered types: [${Object.keys(this.schema.nodeTypes).join(", ")}]. Register the type in CanvasSchema.nodeTypes before using it in a FlowModel.`
|
|
591
591
|
);
|
|
592
|
-
const r = this.shapeRegistry.registerNodeType(n.type, i.component),
|
|
593
|
-
t.set(o, { model: n, definition: i, shapeName: r, size:
|
|
592
|
+
const r = this.shapeRegistry.registerNodeType(n.type, i.component), l = i.getSize(n), a = i.getPorts?.(n) ?? n.ports ?? [];
|
|
593
|
+
t.set(o, { model: n, definition: i, shapeName: r, size: l, ports: a });
|
|
594
594
|
}
|
|
595
595
|
return t;
|
|
596
596
|
}
|
|
@@ -615,10 +615,10 @@ class pt {
|
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
617
|
updateExistingNode(e, t) {
|
|
618
|
-
const { model: o, size: n, ports: i, definition: r } = t,
|
|
619
|
-
(
|
|
620
|
-
const
|
|
621
|
-
(
|
|
618
|
+
const { model: o, size: n, ports: i, definition: r } = t, l = e.getPosition();
|
|
619
|
+
(l.x !== o.position.x || l.y !== o.position.y) && e.setPosition(o.position.x, o.position.y);
|
|
620
|
+
const a = e.getSize();
|
|
621
|
+
(a.width !== n.width || a.height !== n.height) && e.setSize(n.width, n.height, { silent: !0 }), this.syncNodePorts(e, i), e.setData({ ...o }), this.applyNodeBehavior(e, o, r), this.applyNodeHighlightAndDecoration(e, o);
|
|
622
622
|
}
|
|
623
623
|
syncNodePorts(e, t) {
|
|
624
624
|
const o = e.getPorts(), n = new Set(t.map((r) => r.id)), i = new Set(o.map((r) => r.id));
|
|
@@ -628,7 +628,7 @@ class pt {
|
|
|
628
628
|
i.has(r.id) || e.addPort({ id: r.id, group: r.group, ...r.x6PortConfig });
|
|
629
629
|
}
|
|
630
630
|
addNewNode(e, t) {
|
|
631
|
-
const { model: o, shapeName: n, size: i, ports: r, definition:
|
|
631
|
+
const { model: o, shapeName: n, size: i, ports: r, definition: l } = t, a = {
|
|
632
632
|
id: o.id,
|
|
633
633
|
shape: n,
|
|
634
634
|
x: o.position.x,
|
|
@@ -663,13 +663,13 @@ class pt {
|
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
},
|
|
666
|
-
items: r.map((
|
|
666
|
+
items: r.map((d) => ({ id: d.id, group: d.group, ...d.x6PortConfig }))
|
|
667
667
|
},
|
|
668
|
-
...
|
|
668
|
+
...l.x6CellConfig
|
|
669
669
|
};
|
|
670
|
-
this.graph.addNode(
|
|
670
|
+
this.graph.addNode(a), this.knownNodeIds.add(e), this.saveNodeDefaultAttrs(e, l);
|
|
671
671
|
const c = this.graph.getCellById(e);
|
|
672
|
-
c && (this.applyNodeBehavior(c, o,
|
|
672
|
+
c && (this.applyNodeBehavior(c, o, l), this.applyNodeHighlightAndDecoration(c, o));
|
|
673
673
|
}
|
|
674
674
|
/**
|
|
675
675
|
* 将 schema 定义的 getBehavior 映射到 X6 节点属性。
|
|
@@ -686,14 +686,14 @@ class pt {
|
|
|
686
686
|
if (!n) return;
|
|
687
687
|
const i = o.getBehavior(t, n);
|
|
688
688
|
if (i.draggable !== void 0 && e.setProp("draggable", i.draggable, { silent: !0 }), i.connectable !== void 0) {
|
|
689
|
-
const
|
|
690
|
-
for (const
|
|
691
|
-
e.setPortProp(
|
|
689
|
+
const l = i.connectable;
|
|
690
|
+
for (const a of e.getPorts())
|
|
691
|
+
e.setPortProp(a.id, "attrs/circle/magnet", l, { silent: !0 });
|
|
692
692
|
}
|
|
693
693
|
if (i.showPorts !== void 0) {
|
|
694
|
-
const
|
|
695
|
-
for (const
|
|
696
|
-
e.setPortProp(
|
|
694
|
+
const l = i.showPorts;
|
|
695
|
+
for (const a of e.getPorts())
|
|
696
|
+
e.setPortProp(a.id, "attrs/circle/style/visibility", l ? "visible" : "hidden", { silent: !0 });
|
|
697
697
|
}
|
|
698
698
|
const r = e.getData() ?? {};
|
|
699
699
|
i.deletable !== void 0 && r._deletable !== i.deletable && e.setData({ ...r, _deletable: i.deletable }, { silent: !0 }), i.selectable !== void 0 && r._selectable !== i.selectable && e.setData({ ...e.getData(), _selectable: i.selectable }, { silent: !0 });
|
|
@@ -706,8 +706,8 @@ class pt {
|
|
|
706
706
|
i && this.graph.removeCell(i), this.knownEdgeIds.delete(n), this.defaultHighlightedEdgeIds.delete(n), this.prevEdgeDecorationClasses.delete(n), this.prevEdgeDecorationColors.delete(n), this.prevEdgeStyleIds.delete(n), this.edgeDefaultAttrs.delete(n);
|
|
707
707
|
}
|
|
708
708
|
for (const [n, i] of e) {
|
|
709
|
-
const r = this.graph.getCellById(n), { model:
|
|
710
|
-
r ? (this.updateExistingEdge(r,
|
|
709
|
+
const r = this.graph.getCellById(n), { model: l, definition: a } = i;
|
|
710
|
+
r ? (this.updateExistingEdge(r, l, a, t), this.knownEdgeIds.has(n) || (this.knownEdgeIds.add(n), this.saveEdgeDefaultAttrs(n, a))) : this.addNewEdge(n, l, a);
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
713
|
/**
|
|
@@ -718,12 +718,12 @@ class pt {
|
|
|
718
718
|
updateExistingEdge(e, t, o, n) {
|
|
719
719
|
const i = e.getSource(), r = e.getTarget();
|
|
720
720
|
if ((i.cell !== t.source.nodeId || i.port !== t.source.portId) && e.setSource({ cell: t.source.nodeId, port: t.source.portId }), (r.cell !== t.target.nodeId || r.port !== t.target.portId) && e.setTarget({ cell: t.target.nodeId, port: t.target.portId }), o?.router) {
|
|
721
|
-
const
|
|
722
|
-
e.setRouter(
|
|
721
|
+
const l = typeof o.router == "string" ? { name: o.router } : o.router;
|
|
722
|
+
e.setRouter(l);
|
|
723
723
|
}
|
|
724
724
|
if (o?.connector) {
|
|
725
|
-
const
|
|
726
|
-
e.setConnector(
|
|
725
|
+
const l = typeof o.connector == "string" ? { name: o.connector } : o.connector;
|
|
726
|
+
e.setConnector(l);
|
|
727
727
|
}
|
|
728
728
|
this.syncEdgeMarker(e, o, "sourceMarker"), this.syncEdgeMarker(e, o, "targetMarker"), this.syncEdgeLabels(e, t), e.setData({ ...t }, { silent: !0 }), this.applyEdgeStyleAndDecoration(e, t, o);
|
|
729
729
|
}
|
|
@@ -793,8 +793,8 @@ class pt {
|
|
|
793
793
|
applyNodeHighlightAndDecoration(e, t) {
|
|
794
794
|
const o = this.highlightedNodeIds.has(e.id), n = this.resolveNodeDecoration?.(t), i = this.prevNodeDecorationClasses.get(e.id);
|
|
795
795
|
i && (this.graph.findViewByCell(e)?.container?.classList.remove(i), this.prevNodeDecorationClasses.delete(e.id)), n?.className && (this.graph.findViewByCell(e)?.container?.classList.add(n.className), this.prevNodeDecorationClasses.set(e.id, n.className));
|
|
796
|
-
const r = n?.borderColor,
|
|
797
|
-
|
|
796
|
+
const r = n?.borderColor, a = r ?? (o ? "#3a84ff" : void 0), c = this.prevNodeDecorationColors.has(e.id) || this.defaultHighlightedNodeIds.has(e.id);
|
|
797
|
+
a ? (e.setAttrByPath("body/stroke", a), e.setAttrByPath("body/strokeWidth", 2)) : c && (this.restoreNodeAttr(e, "body/stroke", "stroke"), this.restoreNodeAttr(e, "body/strokeWidth", "strokeWidth")), r ? this.prevNodeDecorationColors.add(e.id) : this.prevNodeDecorationColors.delete(e.id), o && !r ? this.defaultHighlightedNodeIds.add(e.id) : this.defaultHighlightedNodeIds.delete(e.id);
|
|
798
798
|
}
|
|
799
799
|
setHoveredEdge(e) {
|
|
800
800
|
this.hoveredEdgeId = e;
|
|
@@ -819,22 +819,22 @@ class pt {
|
|
|
819
819
|
applyEdgeStyleAndDecoration(e, t, o) {
|
|
820
820
|
const n = this.highlightedEdgeIds.has(e.id), i = this.resolveEdgeDecoration?.(t), r = this.prevEdgeDecorationClasses.get(e.id);
|
|
821
821
|
r && (this.graph.findViewByCell(e)?.container?.classList.remove(r), this.prevEdgeDecorationClasses.delete(e.id)), i?.className && (this.graph.findViewByCell(e)?.container?.classList.add(i.className), this.prevEdgeDecorationClasses.set(e.id, i.className));
|
|
822
|
-
let
|
|
822
|
+
let l, a, c;
|
|
823
823
|
if (o?.style) {
|
|
824
|
-
const
|
|
825
|
-
|
|
824
|
+
const N = this.graph.isSelected?.(e) ?? !1, b = this.hoveredEdgeId === e.id, y = o.style(t, { selected: N, highlighted: n, hovered: b });
|
|
825
|
+
l = y.stroke, a = y.strokeWidth, c = y.strokeDasharray;
|
|
826
826
|
}
|
|
827
|
-
const
|
|
828
|
-
|
|
827
|
+
const d = !o?.style && n ? "#3a84ff" : void 0, g = i?.strokeColor, p = g ?? l ?? d, u = !!o?.style || this.prevEdgeDecorationColors.has(e.id) || this.defaultHighlightedEdgeIds.has(e.id) || this.prevEdgeStyleIds.has(e.id);
|
|
828
|
+
p ? e.setAttrByPath("line/stroke", p) : u && this.restoreEdgeAttr(e, "line/stroke", "stroke"), o?.style ? (this.prevEdgeStyleIds.add(e.id), a ? e.setAttrByPath("line/strokeWidth", a) : this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), c ? e.setAttrByPath("line/strokeDasharray", c) : this.restoreEdgeAttr(e, "line/strokeDasharray", "strokeDasharray")) : this.prevEdgeStyleIds.has(e.id) && (this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), this.restoreEdgeAttr(e, "line/strokeDasharray", "strokeDasharray"), this.prevEdgeStyleIds.delete(e.id)), g ? this.prevEdgeDecorationColors.add(e.id) : this.prevEdgeDecorationColors.delete(e.id), d ? this.defaultHighlightedEdgeIds.add(e.id) : this.defaultHighlightedEdgeIds.delete(e.id);
|
|
829
829
|
}
|
|
830
830
|
}
|
|
831
|
-
let
|
|
832
|
-
function
|
|
831
|
+
let ft = 0;
|
|
832
|
+
function T() {
|
|
833
833
|
const s = Date.now().toString(36), e = Math.random().toString(36).substring(2, 8);
|
|
834
|
-
return `${s}-${e}-${++
|
|
834
|
+
return `${s}-${e}-${++ft}`;
|
|
835
835
|
}
|
|
836
|
-
class
|
|
837
|
-
instanceId =
|
|
836
|
+
class pt {
|
|
837
|
+
instanceId = T();
|
|
838
838
|
registeredShapes = /* @__PURE__ */ new Map();
|
|
839
839
|
getShapeName(e) {
|
|
840
840
|
let t = this.registeredShapes.get(e);
|
|
@@ -842,7 +842,7 @@ class ht {
|
|
|
842
842
|
}
|
|
843
843
|
registerNodeType(e, t) {
|
|
844
844
|
const o = this.getShapeName(e);
|
|
845
|
-
return
|
|
845
|
+
return We({
|
|
846
846
|
shape: o,
|
|
847
847
|
component: t,
|
|
848
848
|
width: 100,
|
|
@@ -853,7 +853,7 @@ class ht {
|
|
|
853
853
|
this.registeredShapes.clear();
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
|
-
class
|
|
856
|
+
class gt {
|
|
857
857
|
graph;
|
|
858
858
|
onUiEvent;
|
|
859
859
|
onCommand;
|
|
@@ -880,11 +880,11 @@ class vt {
|
|
|
880
880
|
}), this.on("edge:click", ({ edge: e, e: t }) => {
|
|
881
881
|
const n = t.target?.closest?.(".x6-edge-label");
|
|
882
882
|
if (n) {
|
|
883
|
-
const r = e.getData?.()?.labels ?? [],
|
|
883
|
+
const r = e.getData?.()?.labels ?? [], l = n.parentElement?.querySelectorAll(".x6-edge-label"), a = l ? Array.from(l).indexOf(n) : 0, c = r[Math.max(0, a)];
|
|
884
884
|
this.onUiEvent({
|
|
885
885
|
type: "edge.label.click",
|
|
886
886
|
edgeId: e.id,
|
|
887
|
-
labelId: c?.id ?? `label-${
|
|
887
|
+
labelId: c?.id ?? `label-${a}`
|
|
888
888
|
});
|
|
889
889
|
return;
|
|
890
890
|
}
|
|
@@ -900,7 +900,7 @@ class vt {
|
|
|
900
900
|
}), this.on("node:moved", ({ node: e }) => {
|
|
901
901
|
const t = e.getPosition();
|
|
902
902
|
this.onCommand({
|
|
903
|
-
id:
|
|
903
|
+
id: T(),
|
|
904
904
|
source: "user:drag",
|
|
905
905
|
label: "移动节点",
|
|
906
906
|
timestamp: Date.now(),
|
|
@@ -909,9 +909,9 @@ class vt {
|
|
|
909
909
|
}), this.on("edge:connected", ({ edge: e, isNew: t }) => {
|
|
910
910
|
const o = e.getSourceCell(), n = e.getTargetCell();
|
|
911
911
|
if (!o || !n) return;
|
|
912
|
-
const i = e.getSourcePortId(), r = e.getTargetPortId(),
|
|
913
|
-
t && !
|
|
914
|
-
id:
|
|
912
|
+
const i = e.getSourcePortId(), r = e.getTargetPortId(), l = e.id in this.flowModelRef.value.edges;
|
|
913
|
+
t && !l ? this.onCommand({
|
|
914
|
+
id: T(),
|
|
915
915
|
source: "user:drag",
|
|
916
916
|
label: "连线",
|
|
917
917
|
timestamp: Date.now(),
|
|
@@ -926,7 +926,7 @@ class vt {
|
|
|
926
926
|
}
|
|
927
927
|
]
|
|
928
928
|
}) : this.onCommand({
|
|
929
|
-
id:
|
|
929
|
+
id: T(),
|
|
930
930
|
source: "user:drag",
|
|
931
931
|
label: "重连",
|
|
932
932
|
timestamp: Date.now(),
|
|
@@ -944,18 +944,18 @@ class vt {
|
|
|
944
944
|
if (!n.length || !t?.length) return;
|
|
945
945
|
const i = [];
|
|
946
946
|
for (let r = 0; r < Math.min(n.length, t.length); r++) {
|
|
947
|
-
const
|
|
948
|
-
if (!
|
|
949
|
-
const c = typeof
|
|
947
|
+
const l = t[r], a = n[r];
|
|
948
|
+
if (!a?.id) continue;
|
|
949
|
+
const c = typeof l.position == "object" ? l.position?.distance : l.position;
|
|
950
950
|
c != null && i.push({
|
|
951
951
|
type: "edge.label.update",
|
|
952
952
|
edgeId: e.id,
|
|
953
|
-
labelId:
|
|
953
|
+
labelId: a.id,
|
|
954
954
|
patch: { position: c }
|
|
955
955
|
});
|
|
956
956
|
}
|
|
957
957
|
i.length && this.onCommand({
|
|
958
|
-
id:
|
|
958
|
+
id: T(),
|
|
959
959
|
source: "user:drag",
|
|
960
960
|
label: "拖动标签",
|
|
961
961
|
timestamp: Date.now(),
|
|
@@ -967,31 +967,19 @@ class vt {
|
|
|
967
967
|
this.graph.on(e, t), this.disposers.push(() => this.graph.off(e, t));
|
|
968
968
|
}
|
|
969
969
|
}
|
|
970
|
-
function
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
return new DOMRect(d.x, d.y, d.width, d.height);
|
|
977
|
-
}
|
|
978
|
-
function n(i, r) {
|
|
979
|
-
const a = s.getCellById(i);
|
|
980
|
-
if (!a || !a.isNode()) return null;
|
|
981
|
-
const l = a, c = l.getData() ?? {}, u = c.type, f = ((u ? e.nodeTypes[u] : void 0)?.getOverlayAnchors?.(c) ?? {})[r], E = f && typeof f == "object" && "x" in f ? f : void 0, b = l.getPosition(), m = b.x + (E?.x ?? 0), p = b.y + (E?.y ?? 0), P = s.localToGraph({ x: m, y: p });
|
|
982
|
-
return {
|
|
983
|
-
x: P.x,
|
|
984
|
-
y: P.y
|
|
985
|
-
};
|
|
970
|
+
function ht(s) {
|
|
971
|
+
function e(t) {
|
|
972
|
+
const o = s.getCellById(t);
|
|
973
|
+
if (!o || !o.isNode()) return null;
|
|
974
|
+
const n = o, i = n.getPosition(), r = n.getSize(), l = { x: i.x, y: i.y, width: r.width, height: r.height }, a = s.localToGraph(l);
|
|
975
|
+
return new DOMRect(a.x, a.y, a.width, a.height);
|
|
986
976
|
}
|
|
987
977
|
return {
|
|
988
|
-
|
|
989
|
-
getNodeScreenRect: o,
|
|
990
|
-
getAnchorScreenPosition: n
|
|
978
|
+
getNodeScreenRect: e
|
|
991
979
|
};
|
|
992
980
|
}
|
|
993
|
-
const
|
|
994
|
-
function
|
|
981
|
+
const vt = 100;
|
|
982
|
+
function yt({
|
|
995
983
|
graph: s,
|
|
996
984
|
overlayManager: e,
|
|
997
985
|
executeCommand: t,
|
|
@@ -999,66 +987,66 @@ function bt({
|
|
|
999
987
|
flowModel: n,
|
|
1000
988
|
defaultInsertGap: i,
|
|
1001
989
|
getContextMenuItems: r,
|
|
1002
|
-
onHighlightChange:
|
|
1003
|
-
resolveNodeShape:
|
|
990
|
+
onHighlightChange: l,
|
|
991
|
+
resolveNodeShape: a
|
|
1004
992
|
}) {
|
|
1005
|
-
let c = [],
|
|
993
|
+
let c = [], d = [], g = null, p = !1, u = null, N = !1;
|
|
1006
994
|
async function b() {
|
|
1007
|
-
if (
|
|
1008
|
-
|
|
995
|
+
if (p) return g;
|
|
996
|
+
p = !0;
|
|
1009
997
|
try {
|
|
1010
|
-
const
|
|
1011
|
-
return v ? (
|
|
998
|
+
const h = await import("./index-BAAMFT_J.js"), v = h.Dnd ?? h.default;
|
|
999
|
+
return v ? (g = new v({
|
|
1012
1000
|
target: s,
|
|
1013
1001
|
scaled: !0,
|
|
1014
1002
|
animation: !0,
|
|
1015
|
-
getDragNode: (
|
|
1016
|
-
getDropNode: (
|
|
1017
|
-
}),
|
|
1003
|
+
getDragNode: (I) => I.clone(),
|
|
1004
|
+
getDropNode: (I) => I.clone()
|
|
1005
|
+
}), g) : null;
|
|
1018
1006
|
} catch {
|
|
1019
1007
|
return console.warn("[flow-canvas] @antv/x6-plugin-dnd not available, add it to your dependencies"), null;
|
|
1020
1008
|
}
|
|
1021
1009
|
}
|
|
1022
|
-
async function
|
|
1023
|
-
if (!
|
|
1024
|
-
|
|
1010
|
+
async function y() {
|
|
1011
|
+
if (!N) {
|
|
1012
|
+
N = !0;
|
|
1025
1013
|
try {
|
|
1026
|
-
const
|
|
1014
|
+
const h = await import("./index-siYsjzl4.js"), v = h.Export ?? h.default;
|
|
1027
1015
|
v && s.use(new v());
|
|
1028
1016
|
} catch {
|
|
1029
1017
|
console.warn("[flow-canvas] @antv/x6-plugin-export not available, add it to your dependencies");
|
|
1030
1018
|
}
|
|
1031
1019
|
}
|
|
1032
1020
|
}
|
|
1033
|
-
const
|
|
1034
|
-
const v =
|
|
1035
|
-
if (!v?._dndSessionId || v._dndSessionId !==
|
|
1036
|
-
|
|
1037
|
-
const
|
|
1038
|
-
s.removeNode(
|
|
1039
|
-
const { _dndSessionId:
|
|
1021
|
+
const m = ({ node: h }) => {
|
|
1022
|
+
const v = h.getData?.();
|
|
1023
|
+
if (!v?._dndSessionId || v._dndSessionId !== u) return;
|
|
1024
|
+
u = null;
|
|
1025
|
+
const I = h.getPosition();
|
|
1026
|
+
s.removeNode(h.id);
|
|
1027
|
+
const { _dndSessionId: L, ...D } = v, C = D.id || T();
|
|
1040
1028
|
t({
|
|
1041
|
-
id:
|
|
1029
|
+
id: T(),
|
|
1042
1030
|
source: "user:drag",
|
|
1043
1031
|
label: "拖入节点",
|
|
1044
1032
|
timestamp: Date.now(),
|
|
1045
1033
|
commands: [
|
|
1046
1034
|
{
|
|
1047
1035
|
type: "node.add",
|
|
1048
|
-
node: { ...
|
|
1036
|
+
node: { ...D, id: C, position: { x: I.x, y: I.y } }
|
|
1049
1037
|
}
|
|
1050
1038
|
]
|
|
1051
1039
|
});
|
|
1052
1040
|
};
|
|
1053
|
-
return s.on("node:added",
|
|
1041
|
+
return s.on("node:added", m), {
|
|
1054
1042
|
zoomIn() {
|
|
1055
1043
|
s.zoom(0.1);
|
|
1056
1044
|
},
|
|
1057
1045
|
zoomOut() {
|
|
1058
1046
|
s.zoom(-0.1);
|
|
1059
1047
|
},
|
|
1060
|
-
zoomTo(
|
|
1061
|
-
s.zoomTo(
|
|
1048
|
+
zoomTo(h) {
|
|
1049
|
+
s.zoomTo(h);
|
|
1062
1050
|
},
|
|
1063
1051
|
zoomToFit() {
|
|
1064
1052
|
s.zoomToFit({ padding: 40, maxScale: 1.5 });
|
|
@@ -1072,218 +1060,224 @@ function bt({
|
|
|
1072
1060
|
scrollToOrigin() {
|
|
1073
1061
|
s.translate(0, 0);
|
|
1074
1062
|
},
|
|
1075
|
-
scrollToNode(
|
|
1076
|
-
const v = s.getCellById(
|
|
1063
|
+
scrollToNode(h) {
|
|
1064
|
+
const v = s.getCellById(h);
|
|
1077
1065
|
v && s.centerCell(v);
|
|
1078
1066
|
},
|
|
1079
1067
|
getSelection() {
|
|
1080
|
-
const
|
|
1068
|
+
const h = s.getSelectedCells?.() ?? [];
|
|
1081
1069
|
return {
|
|
1082
|
-
nodeIds:
|
|
1083
|
-
edgeIds:
|
|
1070
|
+
nodeIds: h.filter((v) => v.isNode()).map((v) => v.id),
|
|
1071
|
+
edgeIds: h.filter((v) => v.isEdge()).map((v) => v.id)
|
|
1084
1072
|
};
|
|
1085
1073
|
},
|
|
1086
|
-
selectNodes(
|
|
1087
|
-
const v =
|
|
1074
|
+
selectNodes(h) {
|
|
1075
|
+
const v = h.map((I) => s.getCellById(I)).filter(Boolean);
|
|
1088
1076
|
s.select?.(v);
|
|
1089
1077
|
},
|
|
1090
|
-
selectEdges(
|
|
1091
|
-
const v =
|
|
1078
|
+
selectEdges(h) {
|
|
1079
|
+
const v = h.map((I) => s.getCellById(I)).filter(Boolean);
|
|
1092
1080
|
s.select?.(v);
|
|
1093
1081
|
},
|
|
1094
1082
|
clearSelection() {
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1083
|
+
const h = s.getSelectedCells?.();
|
|
1084
|
+
h?.length && s.unselect?.(h);
|
|
1097
1085
|
},
|
|
1098
|
-
registerDndSource(
|
|
1099
|
-
const
|
|
1100
|
-
const
|
|
1101
|
-
if (!
|
|
1102
|
-
const
|
|
1103
|
-
|
|
1104
|
-
const
|
|
1105
|
-
width:
|
|
1106
|
-
height:
|
|
1107
|
-
shape:
|
|
1108
|
-
data: { ...
|
|
1086
|
+
registerDndSource(h, v) {
|
|
1087
|
+
const I = async (L) => {
|
|
1088
|
+
const D = await b();
|
|
1089
|
+
if (!D) return;
|
|
1090
|
+
const C = T();
|
|
1091
|
+
u = C;
|
|
1092
|
+
const F = v(), Y = a?.(F.type), q = s.createNode({
|
|
1093
|
+
width: Y?.width ?? 154,
|
|
1094
|
+
height: Y?.height ?? 54,
|
|
1095
|
+
shape: Y?.shapeName ?? "rect",
|
|
1096
|
+
data: { ...F, _dndSessionId: C }
|
|
1109
1097
|
});
|
|
1110
|
-
|
|
1098
|
+
D.start(q, L);
|
|
1111
1099
|
};
|
|
1112
|
-
return
|
|
1113
|
-
|
|
1100
|
+
return h.addEventListener("mousedown", I), () => {
|
|
1101
|
+
h.removeEventListener("mousedown", I);
|
|
1114
1102
|
};
|
|
1115
1103
|
},
|
|
1116
1104
|
/**
|
|
1117
1105
|
* 通过编程方式发起连线:直接命中真实 port 元素,
|
|
1118
1106
|
* 复用 X6 原生的连线拖拽流程与 connecting.createEdge 配置。
|
|
1119
1107
|
*/
|
|
1120
|
-
startConnection(
|
|
1121
|
-
const
|
|
1122
|
-
if (!
|
|
1123
|
-
const
|
|
1124
|
-
if (!
|
|
1125
|
-
const
|
|
1126
|
-
if (!
|
|
1127
|
-
const
|
|
1128
|
-
clientX:
|
|
1129
|
-
clientY:
|
|
1108
|
+
startConnection(h, v) {
|
|
1109
|
+
const I = s.getCellById(h);
|
|
1110
|
+
if (!I?.isNode()) return;
|
|
1111
|
+
const L = I, D = s.findViewByCell(L);
|
|
1112
|
+
if (!D) return;
|
|
1113
|
+
const C = D.findPortElem(v, "circle") ?? D.findPortElem(v);
|
|
1114
|
+
if (!C) return;
|
|
1115
|
+
const Y = (C.matches?.("[magnet]") ? C : C.querySelector?.("[magnet]")) ?? C, q = Y.getBoundingClientRect(), Q = q.left + q.width / 2, X = q.top + q.height / 2, G = new MouseEvent("mousedown", {
|
|
1116
|
+
clientX: Q,
|
|
1117
|
+
clientY: X,
|
|
1130
1118
|
button: 0,
|
|
1131
1119
|
buttons: 1,
|
|
1132
1120
|
bubbles: !0,
|
|
1133
1121
|
cancelable: !0
|
|
1134
1122
|
});
|
|
1135
|
-
|
|
1123
|
+
Y.dispatchEvent(G);
|
|
1136
1124
|
},
|
|
1137
|
-
async exportAsImage(
|
|
1138
|
-
await
|
|
1125
|
+
async exportAsImage(h) {
|
|
1126
|
+
await y();
|
|
1139
1127
|
const v = s;
|
|
1140
|
-
return typeof v.toPNG != "function" ? (console.warn("[flow-canvas] exportAsImage requires @antv/x6-plugin-export, add it to your dependencies"), new Blob()) : new Promise((
|
|
1128
|
+
return typeof v.toPNG != "function" ? (console.warn("[flow-canvas] exportAsImage requires @antv/x6-plugin-export, add it to your dependencies"), new Blob()) : new Promise((I) => {
|
|
1141
1129
|
v.toPNG(
|
|
1142
|
-
(
|
|
1143
|
-
fetch(
|
|
1130
|
+
(L) => {
|
|
1131
|
+
fetch(L).then((D) => D.blob()).then(I).catch(() => I(new Blob()));
|
|
1144
1132
|
},
|
|
1145
1133
|
{
|
|
1146
|
-
backgroundColor:
|
|
1147
|
-
padding:
|
|
1148
|
-
quality:
|
|
1134
|
+
backgroundColor: h?.backgroundColor ?? "#ffffff",
|
|
1135
|
+
padding: h?.padding ?? 20,
|
|
1136
|
+
quality: h?.quality,
|
|
1149
1137
|
copyStyles: !0
|
|
1150
1138
|
}
|
|
1151
1139
|
);
|
|
1152
1140
|
});
|
|
1153
1141
|
},
|
|
1154
1142
|
async exportAsSVG() {
|
|
1155
|
-
await
|
|
1156
|
-
const
|
|
1157
|
-
return typeof
|
|
1158
|
-
|
|
1143
|
+
await y();
|
|
1144
|
+
const h = s;
|
|
1145
|
+
return typeof h.toSVG != "function" ? (console.warn("[flow-canvas] exportAsSVG requires @antv/x6-plugin-export, add it to your dependencies"), "") : new Promise((v) => {
|
|
1146
|
+
h.toSVG((I) => v(I));
|
|
1159
1147
|
});
|
|
1160
1148
|
},
|
|
1161
|
-
highlightNodes(
|
|
1162
|
-
c =
|
|
1149
|
+
highlightNodes(h) {
|
|
1150
|
+
c = h, l?.(c, d);
|
|
1163
1151
|
},
|
|
1164
|
-
highlightEdges(
|
|
1165
|
-
|
|
1152
|
+
highlightEdges(h) {
|
|
1153
|
+
d = h, l?.(c, d);
|
|
1166
1154
|
},
|
|
1167
1155
|
clearHighlight() {
|
|
1168
|
-
c = [],
|
|
1156
|
+
c = [], d = [], l?.([], []);
|
|
1169
1157
|
},
|
|
1170
1158
|
overlay: e,
|
|
1171
|
-
getContextMenuItems(
|
|
1172
|
-
return r?.(
|
|
1159
|
+
getContextMenuItems(h) {
|
|
1160
|
+
return r?.(h) ?? [];
|
|
1173
1161
|
},
|
|
1174
|
-
insertNodeToRight(
|
|
1175
|
-
const
|
|
1176
|
-
if (!
|
|
1162
|
+
insertNodeToRight(h, v, I) {
|
|
1163
|
+
const L = n.value, D = L.nodes[h];
|
|
1164
|
+
if (!D)
|
|
1177
1165
|
return {
|
|
1178
1166
|
status: "invalid",
|
|
1179
1167
|
envelope: { id: "", source: "user:toolbar", timestamp: Date.now(), commands: [] },
|
|
1180
|
-
error: { code: "constraint_violated", reason: `Source node "${
|
|
1168
|
+
error: { code: "constraint_violated", reason: `Source node "${h}" not found`, source: "api" }
|
|
1181
1169
|
};
|
|
1182
|
-
const
|
|
1170
|
+
const C = I?.gap ?? i ?? vt, F = o.nodeTypes[D.type], Y = o.nodeTypes[v.type], q = F?.getSize(D) ?? { width: 154, height: 54 }, Q = Y?.getSize({ ...v, position: { x: 0, y: 0 } }) ?? {
|
|
1183
1171
|
width: 154,
|
|
1184
1172
|
height: 54
|
|
1185
|
-
},
|
|
1186
|
-
x:
|
|
1187
|
-
y:
|
|
1188
|
-
},
|
|
1189
|
-
for (const [
|
|
1190
|
-
if (
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1173
|
+
}, X = {
|
|
1174
|
+
x: D.position.x + q.width + C,
|
|
1175
|
+
y: D.position.y + (q.height - Q.height) / 2
|
|
1176
|
+
}, G = v.id || T(), se = { ...v, id: G, position: X }, ee = [{ type: "node.add", node: se }], ke = Q.width + C, te = { x: X.x, y: X.y, width: Q.width, height: Q.height };
|
|
1177
|
+
for (const [Z, V] of Object.entries(L.nodes)) {
|
|
1178
|
+
if (Z === h || Z === G) continue;
|
|
1179
|
+
const oe = o.nodeTypes[V.type]?.getSize(V) ?? { width: 154, height: 54 }, U = te.x < V.position.x + oe.width && te.x + te.width > V.position.x, x = te.y < V.position.y + oe.height && te.y + te.height > V.position.y;
|
|
1180
|
+
U && x && ee.push({
|
|
1193
1181
|
type: "node.move",
|
|
1194
|
-
nodeId:
|
|
1195
|
-
position: { x:
|
|
1182
|
+
nodeId: Z,
|
|
1183
|
+
position: { x: V.position.x + ke, y: V.position.y }
|
|
1196
1184
|
});
|
|
1197
1185
|
}
|
|
1198
|
-
if (
|
|
1199
|
-
const
|
|
1200
|
-
(
|
|
1201
|
-
) : Object.values(
|
|
1202
|
-
if (
|
|
1203
|
-
const
|
|
1204
|
-
|
|
1186
|
+
if (I?.autoWireEdges) {
|
|
1187
|
+
const Z = D.ports?.find((U) => U.group === "right"), V = se.ports?.find((U) => U.group === "left"), ue = se.ports?.find((U) => U.group === "right"), oe = Z ? Object.values(L.edges).find(
|
|
1188
|
+
(U) => U.source.nodeId === h && U.source.portId === Z.id
|
|
1189
|
+
) : Object.values(L.edges).find((U) => U.source.nodeId === h);
|
|
1190
|
+
if (oe) {
|
|
1191
|
+
const U = oe.target;
|
|
1192
|
+
ee.push({ type: "edge.remove", edgeId: oe.id }), ee.push({
|
|
1205
1193
|
type: "edge.add",
|
|
1206
1194
|
edge: {
|
|
1207
|
-
id:
|
|
1208
|
-
source: { nodeId:
|
|
1209
|
-
target: { nodeId:
|
|
1195
|
+
id: T(),
|
|
1196
|
+
source: { nodeId: h, portId: Z?.id },
|
|
1197
|
+
target: { nodeId: G, portId: V?.id }
|
|
1210
1198
|
}
|
|
1211
|
-
}),
|
|
1199
|
+
}), ee.push({
|
|
1212
1200
|
type: "edge.add",
|
|
1213
1201
|
edge: {
|
|
1214
|
-
id:
|
|
1215
|
-
source: { nodeId:
|
|
1216
|
-
target:
|
|
1202
|
+
id: T(),
|
|
1203
|
+
source: { nodeId: G, portId: ue?.id },
|
|
1204
|
+
target: U
|
|
1217
1205
|
}
|
|
1218
1206
|
});
|
|
1219
1207
|
} else
|
|
1220
|
-
|
|
1208
|
+
ee.push({
|
|
1221
1209
|
type: "edge.add",
|
|
1222
1210
|
edge: {
|
|
1223
|
-
id:
|
|
1224
|
-
source: { nodeId:
|
|
1225
|
-
target: { nodeId:
|
|
1211
|
+
id: T(),
|
|
1212
|
+
source: { nodeId: h, portId: Z?.id },
|
|
1213
|
+
target: { nodeId: G, portId: V?.id }
|
|
1226
1214
|
}
|
|
1227
1215
|
});
|
|
1228
1216
|
}
|
|
1229
|
-
const
|
|
1230
|
-
id:
|
|
1231
|
-
source:
|
|
1232
|
-
label:
|
|
1217
|
+
const he = {
|
|
1218
|
+
id: T(),
|
|
1219
|
+
source: I?.source ?? "user:toolbar",
|
|
1220
|
+
label: I?.label ?? "插入节点",
|
|
1233
1221
|
timestamp: Date.now(),
|
|
1234
|
-
commands:
|
|
1222
|
+
commands: ee
|
|
1235
1223
|
};
|
|
1236
|
-
return t(
|
|
1224
|
+
return t(he);
|
|
1237
1225
|
},
|
|
1238
|
-
onGraphEvent(
|
|
1239
|
-
return s.on(
|
|
1226
|
+
onGraphEvent(h, v) {
|
|
1227
|
+
return s.on(h, v), () => s.off(h, v);
|
|
1240
1228
|
},
|
|
1241
1229
|
unsafeGetGraph() {
|
|
1242
1230
|
return s;
|
|
1243
1231
|
}
|
|
1244
1232
|
};
|
|
1245
1233
|
}
|
|
1246
|
-
function
|
|
1247
|
-
const s =
|
|
1248
|
-
let t = null;
|
|
1249
|
-
function
|
|
1250
|
-
t && (clearTimeout(t), t = null), s.value =
|
|
1251
|
-
}
|
|
1252
|
-
function
|
|
1253
|
-
t = setTimeout(() => {
|
|
1234
|
+
function mt() {
|
|
1235
|
+
const s = z(null), e = z(!1);
|
|
1236
|
+
let t = null, o = !1;
|
|
1237
|
+
function n(d) {
|
|
1238
|
+
t && (clearTimeout(t), t = null), s.value = d;
|
|
1239
|
+
}
|
|
1240
|
+
function i(d = 100) {
|
|
1241
|
+
o || (t && clearTimeout(t), t = setTimeout(() => {
|
|
1254
1242
|
s.value = null, t = null;
|
|
1255
|
-
},
|
|
1243
|
+
}, d));
|
|
1256
1244
|
}
|
|
1257
|
-
function
|
|
1245
|
+
function r() {
|
|
1246
|
+
o = !0, t && (clearTimeout(t), t = null);
|
|
1247
|
+
}
|
|
1248
|
+
function l(d = 100) {
|
|
1249
|
+
o = !1, i(d);
|
|
1250
|
+
}
|
|
1251
|
+
function a() {
|
|
1258
1252
|
t && (clearTimeout(t), t = null);
|
|
1259
1253
|
}
|
|
1260
|
-
function
|
|
1254
|
+
function c() {
|
|
1261
1255
|
t && clearTimeout(t);
|
|
1262
1256
|
}
|
|
1263
|
-
return { hoveredNodeId: s, isDraggingNode: e, enter:
|
|
1257
|
+
return { hoveredNodeId: s, isDraggingNode: e, enter: n, leave: i, enterOverlay: r, leaveOverlay: l, cancelLeave: a, cleanup: c };
|
|
1264
1258
|
}
|
|
1265
|
-
const
|
|
1266
|
-
function
|
|
1259
|
+
const _e = 10;
|
|
1260
|
+
function Pe(s, e) {
|
|
1267
1261
|
const t = s.getTotalLength();
|
|
1268
1262
|
if (t === 0) return { ...e, length: 0, totalLength: 0 };
|
|
1269
1263
|
let o = s.getPointAtLength(0), n = 1 / 0;
|
|
1270
1264
|
const i = 50, r = t / i;
|
|
1271
|
-
let
|
|
1272
|
-
for (let
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1265
|
+
let l = 0;
|
|
1266
|
+
for (let g = 0; g <= i; g++) {
|
|
1267
|
+
const p = g * r, u = s.getPointAtLength(p), N = (u.x - e.x) ** 2 + (u.y - e.y) ** 2;
|
|
1268
|
+
N < n && (n = N, o = u, l = p);
|
|
1275
1269
|
}
|
|
1276
|
-
const
|
|
1277
|
-
for (let
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1270
|
+
const a = Math.max(0, l - r), c = Math.min(t, l + r), d = (c - a) / 20;
|
|
1271
|
+
for (let g = a; g <= c; g += d) {
|
|
1272
|
+
const p = s.getPointAtLength(g), u = (p.x - e.x) ** 2 + (p.y - e.y) ** 2;
|
|
1273
|
+
u < n && (n = u, o = p, l = g);
|
|
1280
1274
|
}
|
|
1281
|
-
return { x: o.x, y: o.y, length:
|
|
1275
|
+
return { x: o.x, y: o.y, length: l, totalLength: t };
|
|
1282
1276
|
}
|
|
1283
|
-
function
|
|
1284
|
-
return s <
|
|
1277
|
+
function Ae(s, e) {
|
|
1278
|
+
return s < _e || s > e - _e;
|
|
1285
1279
|
}
|
|
1286
|
-
function
|
|
1280
|
+
function Te() {
|
|
1287
1281
|
const s = "http://www.w3.org/2000/svg", e = document.createElementNS(s, "g");
|
|
1288
1282
|
e.setAttribute("class", "flow-canvas-edge-delete-tool"), e.style.cursor = "pointer";
|
|
1289
1283
|
const t = document.createElementNS(s, "rect");
|
|
@@ -1291,73 +1285,73 @@ function $e() {
|
|
|
1291
1285
|
const o = document.createElementNS(s, "text");
|
|
1292
1286
|
return o.setAttribute("font-family", "flow-canvas"), o.setAttribute("font-size", "16"), o.setAttribute("fill", "#ffffff"), o.setAttribute("text-anchor", "middle"), o.setAttribute("dominant-baseline", "central"), o.textContent = "", e.appendChild(o), e;
|
|
1293
1287
|
}
|
|
1294
|
-
function
|
|
1288
|
+
function bt(s) {
|
|
1295
1289
|
let e = null, t = null;
|
|
1296
|
-
function o(
|
|
1297
|
-
i(), t =
|
|
1298
|
-
const c = s.getCellById(
|
|
1290
|
+
function o(l, a) {
|
|
1291
|
+
i(), t = l;
|
|
1292
|
+
const c = s.getCellById(l);
|
|
1299
1293
|
if (!c?.isEdge()) return;
|
|
1300
|
-
const
|
|
1301
|
-
if (!u) return;
|
|
1302
|
-
const d = u.container.querySelector("path");
|
|
1294
|
+
const d = s.findViewByCell(c);
|
|
1303
1295
|
if (!d) return;
|
|
1304
|
-
const
|
|
1305
|
-
if (
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1296
|
+
const g = d.container.querySelector("path");
|
|
1297
|
+
if (!g) return;
|
|
1298
|
+
const p = s.clientToLocal(a.clientX, a.clientY), u = Pe(g, p);
|
|
1299
|
+
if (Ae(u.length, u.totalLength)) return;
|
|
1300
|
+
const N = Te();
|
|
1301
|
+
N.setAttribute("transform", `translate(${u.x}, ${u.y})`), d.container.appendChild(N), e = N;
|
|
1302
|
+
}
|
|
1303
|
+
function n(l) {
|
|
1310
1304
|
if (!t) return;
|
|
1311
|
-
const
|
|
1312
|
-
if (!
|
|
1313
|
-
const c = s.findViewByCell(
|
|
1305
|
+
const a = s.getCellById(t);
|
|
1306
|
+
if (!a?.isEdge()) return;
|
|
1307
|
+
const c = s.findViewByCell(a);
|
|
1314
1308
|
if (!c) return;
|
|
1315
|
-
const
|
|
1316
|
-
if (!
|
|
1317
|
-
const
|
|
1318
|
-
if (
|
|
1309
|
+
const d = c.container.querySelector("path");
|
|
1310
|
+
if (!d) return;
|
|
1311
|
+
const g = s.clientToLocal(l.clientX, l.clientY), p = Pe(d, g);
|
|
1312
|
+
if (Ae(p.length, p.totalLength))
|
|
1319
1313
|
e && e.setAttribute("display", "none");
|
|
1320
1314
|
else if (e)
|
|
1321
|
-
e.removeAttribute("display"), e.setAttribute("transform", `translate(${
|
|
1315
|
+
e.removeAttribute("display"), e.setAttribute("transform", `translate(${p.x}, ${p.y})`);
|
|
1322
1316
|
else {
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1317
|
+
const u = Te();
|
|
1318
|
+
u.setAttribute("transform", `translate(${p.x}, ${p.y})`), c.container.appendChild(u), e = u;
|
|
1325
1319
|
}
|
|
1326
1320
|
}
|
|
1327
1321
|
function i() {
|
|
1328
1322
|
e && (e.remove(), e = null), t = null;
|
|
1329
1323
|
}
|
|
1330
|
-
function r(
|
|
1331
|
-
|
|
1324
|
+
function r(l) {
|
|
1325
|
+
l === t && (e = null, t = null);
|
|
1332
1326
|
}
|
|
1333
1327
|
return { show: o, move: n, remove: i, handleEdgeRemoved: r };
|
|
1334
1328
|
}
|
|
1335
|
-
function
|
|
1329
|
+
function wt(s) {
|
|
1336
1330
|
let e = null, t = 0;
|
|
1337
|
-
function o(
|
|
1338
|
-
const
|
|
1339
|
-
for (const
|
|
1340
|
-
for (const
|
|
1341
|
-
|
|
1331
|
+
function o(d) {
|
|
1332
|
+
const g = d ? "visible" : "hidden";
|
|
1333
|
+
for (const p of s.getNodes())
|
|
1334
|
+
for (const u of p.getPorts())
|
|
1335
|
+
p.setPortProp(u.id, "attrs/circle/visibility", g);
|
|
1342
1336
|
}
|
|
1343
|
-
function n(
|
|
1337
|
+
function n(d) {
|
|
1344
1338
|
if (!e)
|
|
1345
|
-
for (const
|
|
1346
|
-
|
|
1339
|
+
for (const g of d.getPorts())
|
|
1340
|
+
d.setPortProp(g.id, "attrs/circle/visibility", "visible");
|
|
1347
1341
|
}
|
|
1348
|
-
function i(
|
|
1342
|
+
function i(d) {
|
|
1349
1343
|
if (!e)
|
|
1350
|
-
for (const
|
|
1351
|
-
|
|
1344
|
+
for (const g of d.getPorts())
|
|
1345
|
+
d.setPortProp(g.id, "attrs/circle/visibility", "hidden");
|
|
1352
1346
|
}
|
|
1353
|
-
function r(
|
|
1354
|
-
|
|
1347
|
+
function r(d) {
|
|
1348
|
+
d.getTargetCell() || (e = d.id, o(!0));
|
|
1355
1349
|
}
|
|
1356
|
-
function
|
|
1350
|
+
function l() {
|
|
1357
1351
|
e = null, o(!1), t = Date.now() + 300;
|
|
1358
1352
|
}
|
|
1359
|
-
function
|
|
1360
|
-
|
|
1353
|
+
function a(d) {
|
|
1354
|
+
d === e && (e = null, o(!1));
|
|
1361
1355
|
}
|
|
1362
1356
|
function c() {
|
|
1363
1357
|
return !e && Date.now() >= t;
|
|
@@ -1366,22 +1360,30 @@ function kt(s) {
|
|
|
1366
1360
|
showNodePorts: n,
|
|
1367
1361
|
hideNodePorts: i,
|
|
1368
1362
|
handleEdgeAdded: r,
|
|
1369
|
-
handleEdgeConnected:
|
|
1370
|
-
handleEdgeRemoved:
|
|
1363
|
+
handleEdgeConnected: l,
|
|
1364
|
+
handleEdgeRemoved: a,
|
|
1371
1365
|
canShowEdgeTool: c
|
|
1372
1366
|
};
|
|
1373
1367
|
}
|
|
1374
|
-
const
|
|
1368
|
+
const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
|
|
1375
1369
|
__name: "node-actions-toolbar",
|
|
1376
1370
|
props: {
|
|
1377
1371
|
node: {},
|
|
1378
1372
|
position: {},
|
|
1379
1373
|
config: {},
|
|
1380
|
-
behavior: {}
|
|
1374
|
+
behavior: {},
|
|
1375
|
+
actionsOffset: {}
|
|
1381
1376
|
},
|
|
1382
1377
|
emits: ["action"],
|
|
1383
1378
|
setup(s, { emit: e }) {
|
|
1384
|
-
const t = s, o =
|
|
1379
|
+
const t = s, o = j(() => {
|
|
1380
|
+
const g = t.actionsOffset?.x ?? 0, p = t.actionsOffset?.y ?? 0, u = g !== 0 || p !== 0;
|
|
1381
|
+
return {
|
|
1382
|
+
left: `${t.position.x}px`,
|
|
1383
|
+
top: `${t.position.y}px`,
|
|
1384
|
+
transform: u ? `translate(${g}px, ${p}px)` : "translateX(-100%)"
|
|
1385
|
+
};
|
|
1386
|
+
}), n = e, i = j(() => ({
|
|
1385
1387
|
debug: {
|
|
1386
1388
|
visible: t.config.showDebug && t.behavior.debuggable !== !1,
|
|
1387
1389
|
disabled: t.behavior.debugDisabled === !0
|
|
@@ -1402,89 +1404,89 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
|
|
|
1402
1404
|
visible: t.config.showDisconnect && t.behavior.disconnectable !== !1,
|
|
1403
1405
|
disabled: t.behavior.disconnectDisabled === !0
|
|
1404
1406
|
}
|
|
1405
|
-
})),
|
|
1407
|
+
})), r = j(() => i.value.copy.visible || i.value.copyInsert.visible || i.value.disconnect.visible), l = z(!1);
|
|
1406
1408
|
let a = null;
|
|
1407
|
-
function l() {
|
|
1408
|
-
a && (clearTimeout(a), a = null), r.value = !0;
|
|
1409
|
-
}
|
|
1410
1409
|
function c() {
|
|
1410
|
+
a && (clearTimeout(a), a = null), l.value = !0;
|
|
1411
|
+
}
|
|
1412
|
+
function d() {
|
|
1411
1413
|
a = setTimeout(() => {
|
|
1412
|
-
|
|
1414
|
+
l.value = !1, a = null;
|
|
1413
1415
|
}, 100);
|
|
1414
1416
|
}
|
|
1415
|
-
return
|
|
1417
|
+
return Se(() => {
|
|
1416
1418
|
a && clearTimeout(a);
|
|
1417
|
-
}), (
|
|
1419
|
+
}), (g, p) => (k(), S("div", {
|
|
1418
1420
|
class: "flow-canvas-node-actions",
|
|
1419
|
-
style:
|
|
1421
|
+
style: me(o.value)
|
|
1420
1422
|
}, [
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
+
A("div", xt, [
|
|
1424
|
+
i.value.debug.visible ? (k(), S("i", {
|
|
1423
1425
|
key: 0,
|
|
1424
|
-
class:
|
|
1425
|
-
onClick:
|
|
1426
|
-
}, null, 2)) :
|
|
1427
|
-
|
|
1426
|
+
class: W(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon", { "is-disabled": i.value.debug.disabled }]),
|
|
1427
|
+
onClick: p[0] || (p[0] = (u) => !i.value.debug.disabled && n("action", "debug", s.node.id))
|
|
1428
|
+
}, null, 2)) : H("", !0),
|
|
1429
|
+
i.value.delete.visible ? (k(), S("i", {
|
|
1428
1430
|
key: 1,
|
|
1429
|
-
class:
|
|
1430
|
-
onClick:
|
|
1431
|
-
}, null, 2)) :
|
|
1432
|
-
|
|
1431
|
+
class: W(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon", { "is-disabled": i.value.delete.disabled }]),
|
|
1432
|
+
onClick: p[1] || (p[1] = (u) => !i.value.delete.disabled && n("action", "delete", s.node.id))
|
|
1433
|
+
}, null, 2)) : H("", !0),
|
|
1434
|
+
r.value ? (k(), S("div", {
|
|
1433
1435
|
key: 2,
|
|
1434
1436
|
class: "flow-canvas-node-actions__more-wrapper",
|
|
1435
|
-
onMouseenter:
|
|
1436
|
-
onMouseleave:
|
|
1437
|
-
}, [...
|
|
1438
|
-
|
|
1439
|
-
])], 32)) :
|
|
1437
|
+
onMouseenter: c,
|
|
1438
|
+
onMouseleave: d
|
|
1439
|
+
}, [...p[5] || (p[5] = [
|
|
1440
|
+
A("i", { class: "flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon" }, null, -1)
|
|
1441
|
+
])], 32)) : H("", !0)
|
|
1440
1442
|
]),
|
|
1441
|
-
|
|
1442
|
-
default:
|
|
1443
|
-
|
|
1443
|
+
Be(ze, { name: "flow-canvas-fade" }, {
|
|
1444
|
+
default: Ne(() => [
|
|
1445
|
+
l.value && r.value ? (k(), S("div", {
|
|
1444
1446
|
key: 0,
|
|
1445
1447
|
class: "flow-canvas-node-actions__dropdown",
|
|
1446
|
-
onMouseenter:
|
|
1447
|
-
onMouseleave:
|
|
1448
|
+
onMouseenter: c,
|
|
1449
|
+
onMouseleave: d
|
|
1448
1450
|
}, [
|
|
1449
|
-
|
|
1451
|
+
i.value.copy.visible ? (k(), S("div", {
|
|
1450
1452
|
key: 0,
|
|
1451
|
-
class:
|
|
1452
|
-
onClick:
|
|
1453
|
-
}, [...
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
])], 2)) :
|
|
1457
|
-
|
|
1453
|
+
class: W(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.copy.disabled }]),
|
|
1454
|
+
onClick: p[2] || (p[2] = (u) => !i.value.copy.disabled && n("action", "copy", s.node.id))
|
|
1455
|
+
}, [...p[6] || (p[6] = [
|
|
1456
|
+
A("i", { class: "flow-canvas-icon canvas-copy-fuzhi-2" }, null, -1),
|
|
1457
|
+
A("span", null, "复制", -1)
|
|
1458
|
+
])], 2)) : H("", !0),
|
|
1459
|
+
i.value.copyInsert.visible ? (k(), S("div", {
|
|
1458
1460
|
key: 1,
|
|
1459
|
-
class:
|
|
1460
|
-
onClick:
|
|
1461
|
-
}, [...
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
])], 2)) :
|
|
1465
|
-
|
|
1461
|
+
class: W(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.copyInsert.disabled }]),
|
|
1462
|
+
onClick: p[3] || (p[3] = (u) => !i.value.copyInsert.disabled && n("action", "copy-insert", s.node.id))
|
|
1463
|
+
}, [...p[7] || (p[7] = [
|
|
1464
|
+
A("i", { class: "flow-canvas-icon canvas-fuzhibingcharu" }, null, -1),
|
|
1465
|
+
A("span", null, "复制并插入", -1)
|
|
1466
|
+
])], 2)) : H("", !0),
|
|
1467
|
+
i.value.disconnect.visible ? (k(), S("div", {
|
|
1466
1468
|
key: 2,
|
|
1467
|
-
class:
|
|
1468
|
-
onClick:
|
|
1469
|
-
}, [...
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
])], 2)) :
|
|
1473
|
-
], 32)) :
|
|
1469
|
+
class: W(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.disconnect.disabled }]),
|
|
1470
|
+
onClick: p[4] || (p[4] = (u) => !i.value.disconnect.disabled && n("action", "disconnect", s.node.id))
|
|
1471
|
+
}, [...p[8] || (p[8] = [
|
|
1472
|
+
A("i", { class: "flow-canvas-icon canvas-unlock-jiebang" }, null, -1),
|
|
1473
|
+
A("span", null, "断开连线", -1)
|
|
1474
|
+
])], 2)) : H("", !0)
|
|
1475
|
+
], 32)) : H("", !0)
|
|
1474
1476
|
]),
|
|
1475
1477
|
_: 1
|
|
1476
1478
|
})
|
|
1477
1479
|
], 4));
|
|
1478
1480
|
}
|
|
1479
|
-
}),
|
|
1481
|
+
}), ae = (s, e) => {
|
|
1480
1482
|
const t = s.__vccOpts || s;
|
|
1481
1483
|
for (const [o, n] of e)
|
|
1482
1484
|
t[o] = n;
|
|
1483
1485
|
return t;
|
|
1484
|
-
},
|
|
1486
|
+
}, Ct = /* @__PURE__ */ ae(kt, [["__scopeId", "data-v-3b39dab5"]]), Et = {
|
|
1485
1487
|
key: 0,
|
|
1486
1488
|
class: "flow-canvas-quick-add__tooltip"
|
|
1487
|
-
},
|
|
1489
|
+
}, It = 5, Mt = /* @__PURE__ */ re({
|
|
1488
1490
|
__name: "node-quick-add-popover",
|
|
1489
1491
|
props: {
|
|
1490
1492
|
node: {},
|
|
@@ -1493,98 +1495,98 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
|
|
|
1493
1495
|
},
|
|
1494
1496
|
emits: ["open", "close", "start-drag", "mouseenter", "mouseleave"],
|
|
1495
1497
|
setup(s, { expose: e, emit: t }) {
|
|
1496
|
-
const o = s, n = t, i =
|
|
1497
|
-
let c = null,
|
|
1498
|
-
function
|
|
1499
|
-
|
|
1498
|
+
const o = s, n = t, i = z(), r = z(), l = z(!1), a = z(!1);
|
|
1499
|
+
let c = null, d = !1, g = null;
|
|
1500
|
+
function p(D) {
|
|
1501
|
+
D.preventDefault(), D.stopPropagation(), c = { x: D.clientX, y: D.clientY }, d = !1, document.addEventListener("mousemove", u), document.addEventListener("mouseup", N);
|
|
1500
1502
|
}
|
|
1501
|
-
function
|
|
1503
|
+
function u(D) {
|
|
1502
1504
|
if (!c) return;
|
|
1503
|
-
const
|
|
1504
|
-
Math.sqrt(
|
|
1505
|
+
const C = D.clientX - c.x, F = D.clientY - c.y;
|
|
1506
|
+
Math.sqrt(C * C + F * F) >= It && (d = !0, b(), n("start-drag", o.node.id));
|
|
1505
1507
|
}
|
|
1506
|
-
function
|
|
1507
|
-
b(),
|
|
1508
|
+
function N() {
|
|
1509
|
+
b(), d || y(), c = null, d = !1;
|
|
1508
1510
|
}
|
|
1509
1511
|
function b() {
|
|
1510
|
-
document.removeEventListener("mousemove",
|
|
1512
|
+
document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", N);
|
|
1511
1513
|
}
|
|
1512
|
-
function
|
|
1513
|
-
|
|
1514
|
+
function y() {
|
|
1515
|
+
a.value ? R() : m();
|
|
1514
1516
|
}
|
|
1515
|
-
function
|
|
1516
|
-
|
|
1517
|
-
document.addEventListener("mousedown",
|
|
1517
|
+
function m() {
|
|
1518
|
+
a.value = !0, n("open", o.node.id), requestAnimationFrame(() => {
|
|
1519
|
+
document.addEventListener("mousedown", h);
|
|
1518
1520
|
});
|
|
1519
1521
|
}
|
|
1520
|
-
function
|
|
1521
|
-
|
|
1522
|
+
function R() {
|
|
1523
|
+
a.value = !1, n("close"), document.removeEventListener("mousedown", h);
|
|
1522
1524
|
}
|
|
1523
|
-
function
|
|
1524
|
-
const
|
|
1525
|
-
i.value?.contains(
|
|
1525
|
+
function h(D) {
|
|
1526
|
+
const C = D.target;
|
|
1527
|
+
i.value?.contains(C) || r.value?.contains(C) || R();
|
|
1526
1528
|
}
|
|
1527
1529
|
function v() {
|
|
1528
|
-
|
|
1530
|
+
a.value || n("mouseleave");
|
|
1529
1531
|
}
|
|
1530
|
-
function
|
|
1531
|
-
|
|
1532
|
+
function I() {
|
|
1533
|
+
g && (clearTimeout(g), g = null), n("mouseenter");
|
|
1532
1534
|
}
|
|
1533
|
-
function
|
|
1534
|
-
|
|
1535
|
-
|
|
1535
|
+
function L() {
|
|
1536
|
+
g = setTimeout(() => {
|
|
1537
|
+
R(), n("mouseleave"), g = null;
|
|
1536
1538
|
}, 150);
|
|
1537
1539
|
}
|
|
1538
|
-
return
|
|
1539
|
-
b(),
|
|
1540
|
-
}), e({ closePopover:
|
|
1540
|
+
return Se(() => {
|
|
1541
|
+
b(), g && clearTimeout(g), document.removeEventListener("mousedown", h);
|
|
1542
|
+
}), e({ closePopover: R }), (D, C) => (k(), S("div", {
|
|
1541
1543
|
class: "flow-canvas-quick-add",
|
|
1542
|
-
style:
|
|
1543
|
-
onMouseenter:
|
|
1544
|
+
style: me({ left: `${s.portPosition.x}px`, top: `${s.portPosition.y}px` }),
|
|
1545
|
+
onMouseenter: C[2] || (C[2] = (F) => n("mouseenter")),
|
|
1544
1546
|
onMouseleave: v,
|
|
1545
|
-
onClick:
|
|
1547
|
+
onClick: C[3] || (C[3] = He(() => {
|
|
1546
1548
|
}, ["stop"]))
|
|
1547
1549
|
}, [
|
|
1548
|
-
|
|
1550
|
+
A("div", {
|
|
1549
1551
|
ref_key: "btnRef",
|
|
1550
1552
|
ref: i,
|
|
1551
|
-
class:
|
|
1552
|
-
onMouseenter:
|
|
1553
|
-
onMouseleave:
|
|
1554
|
-
onMousedown:
|
|
1555
|
-
}, [...
|
|
1556
|
-
|
|
1553
|
+
class: W(["flow-canvas-quick-add__btn", { "is-hovered": l.value, "is-active": a.value }]),
|
|
1554
|
+
onMouseenter: C[0] || (C[0] = (F) => l.value = !0),
|
|
1555
|
+
onMouseleave: C[1] || (C[1] = (F) => l.value = !1),
|
|
1556
|
+
onMousedown: p
|
|
1557
|
+
}, [...C[4] || (C[4] = [
|
|
1558
|
+
A("i", { class: "flow-canvas-icon canvas-zoom-add" }, null, -1)
|
|
1557
1559
|
])], 34),
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1560
|
+
l.value && !a.value ? (k(), S("div", Et, [...C[5] || (C[5] = [
|
|
1561
|
+
A("div", null, [
|
|
1562
|
+
A("b", null, "点击"),
|
|
1563
|
+
De(" 添加节点")
|
|
1562
1564
|
], -1),
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1565
|
+
A("div", null, [
|
|
1566
|
+
A("b", null, "拖拽"),
|
|
1567
|
+
De(" 连接节点")
|
|
1566
1568
|
], -1)
|
|
1567
|
-
])])) :
|
|
1568
|
-
|
|
1569
|
-
default:
|
|
1570
|
-
|
|
1569
|
+
])])) : H("", !0),
|
|
1570
|
+
Be(ze, { name: "flow-canvas-fade" }, {
|
|
1571
|
+
default: Ne(() => [
|
|
1572
|
+
a.value ? (k(), S("div", {
|
|
1571
1573
|
key: 0,
|
|
1572
1574
|
ref_key: "popoverRef",
|
|
1573
1575
|
ref: r,
|
|
1574
1576
|
class: "flow-canvas-quick-add__popover",
|
|
1575
|
-
onMouseenter:
|
|
1576
|
-
onMouseleave:
|
|
1577
|
+
onMouseenter: I,
|
|
1578
|
+
onMouseleave: L
|
|
1577
1579
|
}, [
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
+
fe(D.$slots, "default", {}, () => [
|
|
1581
|
+
C[6] || (C[6] = A("div", { class: "flow-canvas-quick-add__default-content" }, "节点快捷操作面板", -1))
|
|
1580
1582
|
], !0)
|
|
1581
|
-
], 544)) :
|
|
1583
|
+
], 544)) : H("", !0)
|
|
1582
1584
|
]),
|
|
1583
1585
|
_: 3
|
|
1584
1586
|
})
|
|
1585
1587
|
], 36));
|
|
1586
1588
|
}
|
|
1587
|
-
}),
|
|
1589
|
+
}), St = /* @__PURE__ */ ae(Mt, [["__scopeId", "data-v-deb5af25"]]), Nt = { class: "flow-canvas-runtime-core__overlay" }, Dt = /* @__PURE__ */ re({
|
|
1588
1590
|
__name: "canvas-runtime-core",
|
|
1589
1591
|
props: {
|
|
1590
1592
|
editor: {},
|
|
@@ -1594,60 +1596,46 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
|
|
|
1594
1596
|
},
|
|
1595
1597
|
emits: ["ui-event"],
|
|
1596
1598
|
setup(s, { emit: e }) {
|
|
1597
|
-
const t = s, o = e, n =
|
|
1598
|
-
let
|
|
1599
|
-
const d =
|
|
1600
|
-
let
|
|
1601
|
-
function
|
|
1602
|
-
return
|
|
1603
|
-
}
|
|
1604
|
-
function
|
|
1605
|
-
|
|
1606
|
-
|
|
1599
|
+
const t = s, o = e, n = z(), i = z();
|
|
1600
|
+
let r, l, a, c;
|
|
1601
|
+
const d = mt(), { hoveredNodeId: g, isDraggingNode: p } = d, u = d.enterOverlay, N = () => d.leaveOverlay(), b = z(null);
|
|
1602
|
+
let y = null;
|
|
1603
|
+
function m(x) {
|
|
1604
|
+
return h(), V(x) ? (b.value = x, !0) : (b.value = null, !1);
|
|
1605
|
+
}
|
|
1606
|
+
function R() {
|
|
1607
|
+
y && clearTimeout(y), y = setTimeout(() => {
|
|
1608
|
+
b.value = null, y = null;
|
|
1607
1609
|
}, 150);
|
|
1608
1610
|
}
|
|
1609
|
-
function
|
|
1610
|
-
|
|
1611
|
+
function h() {
|
|
1612
|
+
y && (clearTimeout(y), y = null);
|
|
1611
1613
|
}
|
|
1612
|
-
function
|
|
1613
|
-
|
|
1614
|
+
function v() {
|
|
1615
|
+
h(), d.enterOverlay();
|
|
1614
1616
|
}
|
|
1615
|
-
function
|
|
1616
|
-
|
|
1617
|
+
function I() {
|
|
1618
|
+
R(), d.leaveOverlay();
|
|
1617
1619
|
}
|
|
1618
|
-
let
|
|
1619
|
-
const
|
|
1620
|
+
let L = null, D = null, C = null;
|
|
1621
|
+
const F = z(0), Y = j(
|
|
1620
1622
|
() => {
|
|
1621
|
-
if (
|
|
1622
|
-
const x = t.editor.flowModel.value,
|
|
1623
|
-
for (const [
|
|
1624
|
-
const
|
|
1625
|
-
if (!
|
|
1626
|
-
const
|
|
1627
|
-
|
|
1628
|
-
nodeId:
|
|
1629
|
-
x:
|
|
1630
|
-
y:
|
|
1631
|
-
badge:
|
|
1623
|
+
if (F.value, !t.editor.api.value) return [];
|
|
1624
|
+
const x = t.editor.flowModel.value, E = t.editor.api.value.overlay, w = [];
|
|
1625
|
+
for (const [_, B] of Object.entries(x.nodes)) {
|
|
1626
|
+
const P = t.editor._pluginManager.collectNodeDecorations(B);
|
|
1627
|
+
if (!P?.badge) continue;
|
|
1628
|
+
const O = E.getNodeScreenRect(_);
|
|
1629
|
+
O && w.push({
|
|
1630
|
+
nodeId: _,
|
|
1631
|
+
x: O.x + O.width - 4,
|
|
1632
|
+
y: O.y - 8,
|
|
1633
|
+
badge: P.badge
|
|
1632
1634
|
});
|
|
1633
1635
|
}
|
|
1634
|
-
return
|
|
1636
|
+
return w;
|
|
1635
1637
|
}
|
|
1636
|
-
),
|
|
1637
|
-
q.value;
|
|
1638
|
-
const x = w.value;
|
|
1639
|
-
if (!x || !t.editor.api.value) return [];
|
|
1640
|
-
const y = t.editor.flowModel.value.nodes[x];
|
|
1641
|
-
if (!y) return [];
|
|
1642
|
-
const D = t.editor.schema.nodeTypes[y.type];
|
|
1643
|
-
if (!D?.getOverlayAnchors) return [];
|
|
1644
|
-
const T = D.getOverlayAnchors(y), A = t.editor.api.value.overlay, R = {};
|
|
1645
|
-
for (const W of Object.keys(T)) {
|
|
1646
|
-
const ae = A.getAnchorScreenPosition(x, W);
|
|
1647
|
-
ae && (R[W] = ae);
|
|
1648
|
-
}
|
|
1649
|
-
return [{ node: y, screenAnchors: R }];
|
|
1650
|
-
}), Z = z(() => ({
|
|
1638
|
+
), q = j(() => ({
|
|
1651
1639
|
showDebug: !1,
|
|
1652
1640
|
showDelete: !0,
|
|
1653
1641
|
showCopy: !0,
|
|
@@ -1655,75 +1643,75 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
|
|
|
1655
1643
|
showDisconnect: !0,
|
|
1656
1644
|
insertGap: 100,
|
|
1657
1645
|
...t.nodeActions
|
|
1658
|
-
})),
|
|
1659
|
-
|
|
1660
|
-
const x =
|
|
1661
|
-
if (!x ||
|
|
1662
|
-
const
|
|
1663
|
-
if (!
|
|
1664
|
-
const
|
|
1665
|
-
if (!
|
|
1666
|
-
const
|
|
1646
|
+
})), Q = j(() => {
|
|
1647
|
+
F.value;
|
|
1648
|
+
const x = g.value;
|
|
1649
|
+
if (!x || p.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
|
|
1650
|
+
const E = t.editor.flowModel.value, w = E.nodes[x];
|
|
1651
|
+
if (!w) return null;
|
|
1652
|
+
const _ = t.editor.api.value.overlay.getNodeScreenRect(x);
|
|
1653
|
+
if (!_) return null;
|
|
1654
|
+
const P = t.editor.schema.nodeTypes[w.type]?.getBehavior?.(w, {
|
|
1667
1655
|
api: t.editor.api.value,
|
|
1668
|
-
flowModel:
|
|
1656
|
+
flowModel: E,
|
|
1669
1657
|
history: t.editor.history,
|
|
1670
1658
|
mode: t.editor.mode.value
|
|
1671
1659
|
}) ?? {};
|
|
1672
|
-
return
|
|
1673
|
-
node:
|
|
1674
|
-
position: { x:
|
|
1675
|
-
behavior:
|
|
1660
|
+
return P.showActions === !1 ? null : {
|
|
1661
|
+
node: w,
|
|
1662
|
+
position: { x: _.x + _.width, y: _.y + _.height + 4 },
|
|
1663
|
+
behavior: P
|
|
1676
1664
|
};
|
|
1677
|
-
}),
|
|
1665
|
+
}), X = j(() => ({
|
|
1678
1666
|
enabled: !0,
|
|
1679
1667
|
tooltipText: "",
|
|
1680
1668
|
...t.quickAdd
|
|
1681
|
-
})),
|
|
1682
|
-
if (
|
|
1683
|
-
const x =
|
|
1684
|
-
if (!x ||
|
|
1685
|
-
const
|
|
1686
|
-
if (!
|
|
1687
|
-
const
|
|
1669
|
+
})), G = j(() => {
|
|
1670
|
+
if (F.value, !X.value.enabled) return null;
|
|
1671
|
+
const x = b.value;
|
|
1672
|
+
if (!x || p.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
|
|
1673
|
+
const E = t.editor.flowModel.value, w = E.nodes[x];
|
|
1674
|
+
if (!w) return null;
|
|
1675
|
+
const B = t.editor.schema.nodeTypes[w.type]?.getBehavior?.(w, {
|
|
1688
1676
|
api: t.editor.api.value,
|
|
1689
|
-
flowModel:
|
|
1677
|
+
flowModel: E,
|
|
1690
1678
|
history: t.editor.history,
|
|
1691
1679
|
mode: t.editor.mode.value
|
|
1692
1680
|
}) ?? {};
|
|
1693
|
-
if (
|
|
1694
|
-
const
|
|
1695
|
-
return
|
|
1696
|
-
node:
|
|
1697
|
-
portPosition: { x:
|
|
1698
|
-
behavior:
|
|
1681
|
+
if (B.quickAddEnabled === !1) return null;
|
|
1682
|
+
const P = t.editor.api.value.overlay.getNodeScreenRect(x);
|
|
1683
|
+
return P ? {
|
|
1684
|
+
node: w,
|
|
1685
|
+
portPosition: { x: P.x + P.width, y: P.y + P.height / 2 },
|
|
1686
|
+
behavior: B
|
|
1699
1687
|
} : null;
|
|
1700
|
-
}),
|
|
1701
|
-
function
|
|
1702
|
-
const
|
|
1703
|
-
|
|
1688
|
+
}), se = z();
|
|
1689
|
+
function ee(x) {
|
|
1690
|
+
const E = G.value;
|
|
1691
|
+
E && o("ui-event", {
|
|
1704
1692
|
type: "node.quick-add",
|
|
1705
1693
|
nodeId: x,
|
|
1706
|
-
position:
|
|
1694
|
+
position: E.portPosition
|
|
1707
1695
|
});
|
|
1708
1696
|
}
|
|
1709
|
-
function
|
|
1710
|
-
const
|
|
1711
|
-
|
|
1697
|
+
function ke(x) {
|
|
1698
|
+
const E = t.editor.api.value;
|
|
1699
|
+
E && E.startConnection(x, "right");
|
|
1712
1700
|
}
|
|
1713
|
-
function
|
|
1714
|
-
const
|
|
1715
|
-
if (!
|
|
1716
|
-
const
|
|
1717
|
-
|
|
1701
|
+
function te(x, E) {
|
|
1702
|
+
const w = t.editor.api.value;
|
|
1703
|
+
if (!w) return;
|
|
1704
|
+
const _ = E.id || T(), B = { ...E, id: _ };
|
|
1705
|
+
w.insertNodeToRight(x, B, {
|
|
1718
1706
|
autoWireEdges: !0,
|
|
1719
|
-
gap:
|
|
1707
|
+
gap: q.value.insertGap,
|
|
1720
1708
|
source: "user:quick-add",
|
|
1721
1709
|
label: "快捷插入节点"
|
|
1722
|
-
}).status === "applied" && o("ui-event", { type: "node.action.quick-insert", sourceNodeId: x, newNodeId:
|
|
1710
|
+
}).status === "applied" && o("ui-event", { type: "node.action.quick-insert", sourceNodeId: x, newNodeId: _ }), se.value?.closePopover();
|
|
1723
1711
|
}
|
|
1724
|
-
function
|
|
1712
|
+
function he(x) {
|
|
1725
1713
|
return {
|
|
1726
|
-
id:
|
|
1714
|
+
id: T(),
|
|
1727
1715
|
type: x.type,
|
|
1728
1716
|
label: x.label,
|
|
1729
1717
|
ports: x.ports ? JSON.parse(JSON.stringify(x.ports)) : void 0,
|
|
@@ -1731,79 +1719,79 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
|
|
|
1731
1719
|
extensions: x.extensions ? JSON.parse(JSON.stringify(x.extensions)) : void 0
|
|
1732
1720
|
};
|
|
1733
1721
|
}
|
|
1734
|
-
function
|
|
1735
|
-
const
|
|
1722
|
+
function Z(x, E) {
|
|
1723
|
+
const w = t.editor, _ = w.api.value;
|
|
1736
1724
|
switch (x) {
|
|
1737
1725
|
case "delete": {
|
|
1738
|
-
|
|
1739
|
-
id:
|
|
1726
|
+
w.executeCommand({
|
|
1727
|
+
id: T(),
|
|
1740
1728
|
source: "user:toolbar",
|
|
1741
1729
|
label: "删除节点",
|
|
1742
1730
|
timestamp: Date.now(),
|
|
1743
|
-
commands: [{ type: "node.remove", nodeId:
|
|
1744
|
-
}), o("ui-event", { type: "node.action.delete", nodeId:
|
|
1731
|
+
commands: [{ type: "node.remove", nodeId: E }]
|
|
1732
|
+
}), o("ui-event", { type: "node.action.delete", nodeId: E }), g.value = null;
|
|
1745
1733
|
break;
|
|
1746
1734
|
}
|
|
1747
1735
|
case "copy": {
|
|
1748
|
-
if (!
|
|
1749
|
-
const
|
|
1750
|
-
if (!
|
|
1751
|
-
const
|
|
1752
|
-
|
|
1736
|
+
if (!_) break;
|
|
1737
|
+
const B = w.flowModel.value.nodes[E];
|
|
1738
|
+
if (!B) break;
|
|
1739
|
+
const P = he(B);
|
|
1740
|
+
_.insertNodeToRight(E, P, {
|
|
1753
1741
|
autoWireEdges: !1,
|
|
1754
|
-
gap:
|
|
1742
|
+
gap: q.value.insertGap,
|
|
1755
1743
|
label: "复制节点"
|
|
1756
|
-
}), o("ui-event", { type: "node.action.copy", sourceNodeId:
|
|
1744
|
+
}), o("ui-event", { type: "node.action.copy", sourceNodeId: E, newNodeId: P.id });
|
|
1757
1745
|
break;
|
|
1758
1746
|
}
|
|
1759
1747
|
case "copy-insert": {
|
|
1760
|
-
if (!
|
|
1761
|
-
const
|
|
1762
|
-
if (!
|
|
1763
|
-
const
|
|
1764
|
-
|
|
1748
|
+
if (!_) break;
|
|
1749
|
+
const B = w.flowModel.value.nodes[E];
|
|
1750
|
+
if (!B) break;
|
|
1751
|
+
const P = he(B);
|
|
1752
|
+
_.insertNodeToRight(E, P, {
|
|
1765
1753
|
autoWireEdges: !0,
|
|
1766
|
-
gap:
|
|
1754
|
+
gap: q.value.insertGap,
|
|
1767
1755
|
label: "复制并插入节点"
|
|
1768
|
-
}), o("ui-event", { type: "node.action.copy-insert", sourceNodeId:
|
|
1756
|
+
}), o("ui-event", { type: "node.action.copy-insert", sourceNodeId: E, newNodeId: P.id });
|
|
1769
1757
|
break;
|
|
1770
1758
|
}
|
|
1771
1759
|
case "disconnect": {
|
|
1772
|
-
const
|
|
1773
|
-
const
|
|
1774
|
-
return
|
|
1775
|
-
}).map(([
|
|
1776
|
-
if (
|
|
1777
|
-
|
|
1778
|
-
id:
|
|
1760
|
+
const B = w.flowModel.value, P = Object.entries(B.edges).filter(([, O]) => {
|
|
1761
|
+
const J = O;
|
|
1762
|
+
return J.source.nodeId === E || J.target.nodeId === E;
|
|
1763
|
+
}).map(([O]) => O);
|
|
1764
|
+
if (P.length === 0) break;
|
|
1765
|
+
w.executeCommand({
|
|
1766
|
+
id: T(),
|
|
1779
1767
|
source: "user:toolbar",
|
|
1780
1768
|
label: "断开连线",
|
|
1781
1769
|
timestamp: Date.now(),
|
|
1782
|
-
commands:
|
|
1783
|
-
}), o("ui-event", { type: "node.action.disconnect", nodeId:
|
|
1770
|
+
commands: P.map((O) => ({ type: "edge.remove", edgeId: O }))
|
|
1771
|
+
}), o("ui-event", { type: "node.action.disconnect", nodeId: E, edgeIds: P });
|
|
1784
1772
|
break;
|
|
1785
1773
|
}
|
|
1786
1774
|
case "debug": {
|
|
1787
|
-
o("ui-event", { type: "node.action.debug", nodeId:
|
|
1775
|
+
o("ui-event", { type: "node.action.debug", nodeId: E });
|
|
1788
1776
|
break;
|
|
1789
1777
|
}
|
|
1790
1778
|
}
|
|
1791
1779
|
}
|
|
1792
|
-
function
|
|
1793
|
-
if (!
|
|
1794
|
-
const
|
|
1795
|
-
return
|
|
1780
|
+
function V(x) {
|
|
1781
|
+
if (!X.value.enabled || t.editor.mode.value !== "edit") return !1;
|
|
1782
|
+
const E = t.editor.flowModel.value, w = E.nodes[x];
|
|
1783
|
+
return w ? (t.editor.schema.nodeTypes[w.type]?.getBehavior?.(w, {
|
|
1796
1784
|
api: t.editor.api.value,
|
|
1797
|
-
flowModel:
|
|
1785
|
+
flowModel: E,
|
|
1798
1786
|
history: t.editor.history,
|
|
1799
1787
|
mode: t.editor.mode.value
|
|
1800
1788
|
}) ?? {}).quickAddEnabled !== !1 : !1;
|
|
1801
1789
|
}
|
|
1802
|
-
function
|
|
1790
|
+
function ue(x) {
|
|
1803
1791
|
if (t.editor.mode.value !== "edit") return;
|
|
1804
1792
|
t.editor._pluginManager.dispatchKeyboardShortcut(x) && (x.preventDefault(), x.stopPropagation());
|
|
1805
1793
|
}
|
|
1806
|
-
function
|
|
1794
|
+
function oe() {
|
|
1807
1795
|
return {
|
|
1808
1796
|
refX: 0,
|
|
1809
1797
|
children: [
|
|
@@ -1824,8 +1812,8 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
|
|
|
1824
1812
|
]
|
|
1825
1813
|
};
|
|
1826
1814
|
}
|
|
1827
|
-
function
|
|
1828
|
-
const
|
|
1815
|
+
function U(x) {
|
|
1816
|
+
const E = t.editor.schema.defaultEdgeType ?? "default", w = t.editor.schema.edgeTypes?.[E], _ = {
|
|
1829
1817
|
zIndex: -1,
|
|
1830
1818
|
attrs: {
|
|
1831
1819
|
line: {
|
|
@@ -1835,34 +1823,39 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
|
|
|
1835
1823
|
}
|
|
1836
1824
|
}
|
|
1837
1825
|
};
|
|
1838
|
-
|
|
1839
|
-
const
|
|
1840
|
-
return
|
|
1841
|
-
...
|
|
1826
|
+
w?.router && (_.router = typeof w.router == "string" ? { name: w.router } : w.router), w?.connector && (_.connector = typeof w.connector == "string" ? { name: w.connector } : w.connector), w?.x6EdgeConfig && Object.assign(_, w.x6EdgeConfig);
|
|
1827
|
+
const B = _.attrs ?? {}, P = B.line ?? {};
|
|
1828
|
+
return _.attrs = {
|
|
1829
|
+
...B,
|
|
1842
1830
|
line: {
|
|
1843
|
-
...
|
|
1844
|
-
targetMarker:
|
|
1831
|
+
...P,
|
|
1832
|
+
targetMarker: oe()
|
|
1845
1833
|
}
|
|
1846
|
-
}, x.createEdge(
|
|
1834
|
+
}, x.createEdge(_);
|
|
1847
1835
|
}
|
|
1848
|
-
return
|
|
1836
|
+
return Fe(() => {
|
|
1849
1837
|
if (!i.value) return;
|
|
1850
|
-
const x = /* @__PURE__ */ new Set(["model", "container"]),
|
|
1838
|
+
const x = /* @__PURE__ */ new Set(["model", "container"]), E = {};
|
|
1851
1839
|
if (t.graphOptions)
|
|
1852
|
-
for (const [
|
|
1853
|
-
if (x.has(
|
|
1854
|
-
console.warn(`[flow-canvas] graphOptions.${
|
|
1840
|
+
for (const [f, M] of Object.entries(t.graphOptions)) {
|
|
1841
|
+
if (x.has(f)) {
|
|
1842
|
+
console.warn(`[flow-canvas] graphOptions.${f} is managed by the engine and will be ignored`);
|
|
1855
1843
|
continue;
|
|
1856
1844
|
}
|
|
1857
|
-
|
|
1845
|
+
E[f] = M;
|
|
1858
1846
|
}
|
|
1859
|
-
|
|
1847
|
+
r = new Ve({
|
|
1860
1848
|
container: i.value,
|
|
1861
1849
|
autoResize: !0,
|
|
1862
1850
|
background: { color: "#edf2fc" },
|
|
1863
1851
|
grid: { visible: !0, size: 20, type: "dot" },
|
|
1864
1852
|
panning: { enabled: !0 },
|
|
1865
1853
|
mousewheel: { enabled: !0, modifiers: ["ctrl", "meta"] },
|
|
1854
|
+
interacting: {
|
|
1855
|
+
nodeMovable(f) {
|
|
1856
|
+
return f.cell.getProp("draggable") !== !1;
|
|
1857
|
+
}
|
|
1858
|
+
},
|
|
1866
1859
|
connecting: {
|
|
1867
1860
|
allowBlank: !1,
|
|
1868
1861
|
allowMulti: !0,
|
|
@@ -1874,16 +1867,16 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
|
|
|
1874
1867
|
connectionPoint: "anchor",
|
|
1875
1868
|
snap: { radius: 30 },
|
|
1876
1869
|
createEdge() {
|
|
1877
|
-
return
|
|
1870
|
+
return U(this);
|
|
1878
1871
|
}
|
|
1879
1872
|
},
|
|
1880
|
-
...
|
|
1881
|
-
}),
|
|
1882
|
-
|
|
1873
|
+
...E
|
|
1874
|
+
}), a = new pt(), l = new ut(
|
|
1875
|
+
r,
|
|
1883
1876
|
t.editor.schema,
|
|
1884
|
-
|
|
1885
|
-
(
|
|
1886
|
-
(
|
|
1877
|
+
a,
|
|
1878
|
+
(f) => t.editor._pluginManager.collectNodeDecorations(f),
|
|
1879
|
+
(f) => t.editor._pluginManager.collectEdgeDecorations(f),
|
|
1887
1880
|
() => t.editor.api.value ? {
|
|
1888
1881
|
api: t.editor.api.value,
|
|
1889
1882
|
flowModel: t.editor.flowModel.value,
|
|
@@ -1891,266 +1884,261 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
|
|
|
1891
1884
|
mode: t.editor.mode.value
|
|
1892
1885
|
} : null
|
|
1893
1886
|
);
|
|
1894
|
-
const
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
overlayManager: y,
|
|
1899
|
-
executeCommand: (h) => t.editor.executeCommand(h),
|
|
1887
|
+
const w = ht(r), _ = yt({
|
|
1888
|
+
graph: r,
|
|
1889
|
+
overlayManager: w,
|
|
1890
|
+
executeCommand: (f) => t.editor.executeCommand(f),
|
|
1900
1891
|
schema: t.editor.schema,
|
|
1901
1892
|
flowModel: t.editor.flowModel,
|
|
1902
1893
|
defaultInsertGap: t.nodeActions?.insertGap,
|
|
1903
|
-
getContextMenuItems: (
|
|
1904
|
-
onHighlightChange: (
|
|
1905
|
-
l.setHighlightedNodes(
|
|
1894
|
+
getContextMenuItems: (f) => t.editor._pluginManager.collectContextMenuItems(f),
|
|
1895
|
+
onHighlightChange: (f, M) => {
|
|
1896
|
+
l.setHighlightedNodes(f), l.setHighlightedEdges(M), l.refreshNodeHighlights(), l.refreshEdgeStyles();
|
|
1906
1897
|
},
|
|
1907
|
-
resolveNodeShape: (
|
|
1908
|
-
const
|
|
1909
|
-
if (!
|
|
1910
|
-
const
|
|
1911
|
-
return { shapeName:
|
|
1898
|
+
resolveNodeShape: (f) => {
|
|
1899
|
+
const M = t.editor.schema.nodeTypes[f];
|
|
1900
|
+
if (!M) return null;
|
|
1901
|
+
const $ = a.registerNodeType(f, M.component), ne = M.getSize({ id: "", type: f, position: { x: 0, y: 0 } });
|
|
1902
|
+
return { shapeName: $, width: ne.width, height: ne.height };
|
|
1912
1903
|
}
|
|
1913
1904
|
});
|
|
1914
|
-
t.editor.api.value =
|
|
1915
|
-
const
|
|
1905
|
+
t.editor.api.value = _;
|
|
1906
|
+
const B = {
|
|
1916
1907
|
flowModel: t.editor.flowModel,
|
|
1917
1908
|
history: t.editor.history,
|
|
1918
1909
|
schema: t.editor.schema,
|
|
1919
1910
|
mode: t.editor.mode,
|
|
1920
1911
|
executeCommand: t.editor.executeCommand,
|
|
1921
|
-
api:
|
|
1922
|
-
overlay:
|
|
1923
|
-
graph:
|
|
1912
|
+
api: _,
|
|
1913
|
+
overlay: w,
|
|
1914
|
+
graph: r
|
|
1924
1915
|
};
|
|
1925
|
-
t.editor._pluginManager.attachRuntime(
|
|
1926
|
-
const
|
|
1927
|
-
Object.assign(t.editor.extendedApi,
|
|
1928
|
-
|
|
1929
|
-
(
|
|
1930
|
-
(
|
|
1916
|
+
t.editor._pluginManager.attachRuntime(B);
|
|
1917
|
+
const P = t.editor._pluginManager.collectExtendedApi();
|
|
1918
|
+
Object.assign(t.editor.extendedApi, P), c = new gt(
|
|
1919
|
+
r,
|
|
1920
|
+
(f) => {
|
|
1921
|
+
(f.type === "node.click" || f.type === "node.dblclick" || f.type === "node.contextmenu") && d.enter(f.nodeId), t.editor._pluginManager.dispatchUiEvent(f), o("ui-event", f);
|
|
1931
1922
|
},
|
|
1932
|
-
(
|
|
1933
|
-
l.isSyncing
|
|
1923
|
+
(f) => {
|
|
1924
|
+
if (l.isSyncing) return;
|
|
1925
|
+
if (t.editor.executeCommand(f).status !== "applied") {
|
|
1926
|
+
for (const $ of f.commands)
|
|
1927
|
+
if ($.type === "edge.add") {
|
|
1928
|
+
const ne = r.getCellById($.edge.id);
|
|
1929
|
+
ne && r.removeCell(ne);
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1934
1932
|
},
|
|
1935
1933
|
t.editor.flowModel
|
|
1936
|
-
),
|
|
1937
|
-
const
|
|
1938
|
-
const
|
|
1939
|
-
|
|
1940
|
-
},
|
|
1941
|
-
|
|
1934
|
+
), L = bt(r);
|
|
1935
|
+
const O = wt(r), J = r, Ce = (f) => {
|
|
1936
|
+
const M = J.isRubberbandEnabled?.() ?? !1;
|
|
1937
|
+
M && J.disableRubberband?.(), f ? r.enablePanning() : r.disablePanning(), M && J.enableRubberband?.();
|
|
1938
|
+
}, Ee = () => {
|
|
1939
|
+
F.value++;
|
|
1942
1940
|
};
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
}),
|
|
1946
|
-
|
|
1947
|
-
}),
|
|
1948
|
-
d.enter(
|
|
1949
|
-
}),
|
|
1950
|
-
|
|
1941
|
+
r.on("translate", Ee), r.on("scale", Ee), r.on("resize", Ee), r.on("node:move", () => {
|
|
1942
|
+
p.value = !0;
|
|
1943
|
+
}), r.on("node:moved", () => {
|
|
1944
|
+
p.value = !1;
|
|
1945
|
+
}), r.on("node:mouseenter", ({ node: f }) => {
|
|
1946
|
+
d.enter(f.id), X.value.enabled && m(f.id) || O.showNodePorts(f);
|
|
1947
|
+
}), r.on("node:mouseleave", ({ node: f }) => {
|
|
1948
|
+
const M = t.editor.flowModel.value.nodes[f.id];
|
|
1949
|
+
let $ = 100;
|
|
1950
|
+
M && t.editor.api.value && t.editor.schema.nodeTypes[M.type]?.getBehavior?.(M, {
|
|
1951
|
+
api: t.editor.api.value,
|
|
1952
|
+
flowModel: t.editor.flowModel.value,
|
|
1953
|
+
history: t.editor.history,
|
|
1954
|
+
mode: t.editor.mode.value
|
|
1955
|
+
})?.actionsOffset && ($ = 300), d.leave($), X.value.enabled && b.value === f.id ? R() : O.hideNodePorts(f);
|
|
1951
1956
|
});
|
|
1952
|
-
function
|
|
1953
|
-
const
|
|
1954
|
-
if (!
|
|
1955
|
-
const
|
|
1956
|
-
for (const
|
|
1957
|
-
const
|
|
1958
|
-
|
|
1957
|
+
function Oe(f) {
|
|
1958
|
+
const M = r.getCellById(f);
|
|
1959
|
+
if (!M?.isNode()) return;
|
|
1960
|
+
const $ = M, ne = !p.value && V(f);
|
|
1961
|
+
for (const Ie of $.getPorts()) {
|
|
1962
|
+
const je = ne && Ie.group === "right" ? "hidden" : "visible";
|
|
1963
|
+
$.setPortProp(Ie.id, "attrs/circle/visibility", je);
|
|
1959
1964
|
}
|
|
1960
1965
|
}
|
|
1961
|
-
|
|
1962
|
-
[
|
|
1963
|
-
([
|
|
1964
|
-
if (
|
|
1965
|
-
const
|
|
1966
|
-
|
|
1966
|
+
le(
|
|
1967
|
+
[b, p],
|
|
1968
|
+
([f], [M]) => {
|
|
1969
|
+
if (M && M !== f) {
|
|
1970
|
+
const $ = r.getCellById(M);
|
|
1971
|
+
$?.isNode() && O.hideNodePorts($);
|
|
1967
1972
|
}
|
|
1968
|
-
|
|
1973
|
+
f && Oe(f);
|
|
1969
1974
|
},
|
|
1970
1975
|
{ flush: "sync" }
|
|
1971
|
-
),
|
|
1972
|
-
|
|
1973
|
-
}),
|
|
1974
|
-
|
|
1975
|
-
}),
|
|
1976
|
-
|
|
1977
|
-
}),
|
|
1978
|
-
const
|
|
1979
|
-
nodeIds:
|
|
1980
|
-
edgeIds:
|
|
1976
|
+
), r.on("edge:added", ({ edge: f }) => {
|
|
1977
|
+
O.handleEdgeAdded(f);
|
|
1978
|
+
}), r.on("edge:connected", () => {
|
|
1979
|
+
O.handleEdgeConnected();
|
|
1980
|
+
}), r.on("edge:removed", ({ edge: f }) => {
|
|
1981
|
+
O.handleEdgeRemoved(f.id), L.handleEdgeRemoved(f.id);
|
|
1982
|
+
}), r.on("selection:changed", () => {
|
|
1983
|
+
const f = r.getSelectedCells?.() ?? [], M = {
|
|
1984
|
+
nodeIds: f.filter(($) => $.isNode()).map(($) => $.id),
|
|
1985
|
+
edgeIds: f.filter(($) => $.isEdge()).map(($) => $.id)
|
|
1981
1986
|
};
|
|
1982
|
-
t.editor._pluginManager.dispatchSelectionChange(
|
|
1987
|
+
t.editor._pluginManager.dispatchSelectionChange(M), o("ui-event", {
|
|
1983
1988
|
type: "selection.change",
|
|
1984
|
-
nodeIds:
|
|
1985
|
-
edgeIds:
|
|
1989
|
+
nodeIds: M.nodeIds,
|
|
1990
|
+
edgeIds: M.edgeIds
|
|
1986
1991
|
}), l.refreshEdgeStyles();
|
|
1987
|
-
}),
|
|
1988
|
-
l.setHoveredEdge(
|
|
1989
|
-
}),
|
|
1990
|
-
l.setHoveredEdge(null), l.refreshEdgeStyles(),
|
|
1991
|
-
}),
|
|
1992
|
-
|
|
1993
|
-
id:
|
|
1992
|
+
}), r.on("edge:mouseenter", ({ edge: f, e: M }) => {
|
|
1993
|
+
l.setHoveredEdge(f.id), l.refreshEdgeStyles(), t.editor.mode.value === "edit" && O.canShowEdgeTool() && L.show(f.id, M);
|
|
1994
|
+
}), D = (f) => L.move(f), r.container.addEventListener("mousemove", D), r.on("edge:mouseleave", () => {
|
|
1995
|
+
l.setHoveredEdge(null), l.refreshEdgeStyles(), L.remove();
|
|
1996
|
+
}), r.on("edge:click", ({ edge: f, e: M }) => {
|
|
1997
|
+
M.target?.closest?.(".flow-canvas-edge-delete-tool") && t.editor.mode.value === "edit" && (L.remove(), t.editor.executeCommand({
|
|
1998
|
+
id: T(),
|
|
1994
1999
|
source: "user:toolbar",
|
|
1995
2000
|
label: "删除连线",
|
|
1996
2001
|
timestamp: Date.now(),
|
|
1997
|
-
commands: [{ type: "edge.remove", edgeId:
|
|
2002
|
+
commands: [{ type: "edge.remove", edgeId: f.id }]
|
|
1998
2003
|
}));
|
|
1999
|
-
}), n.value?.addEventListener("keydown",
|
|
2004
|
+
}), n.value?.addEventListener("keydown", ue), l.syncFlowModel(t.editor.flowModel.value), le(
|
|
2000
2005
|
() => t.editor.flowModel.value,
|
|
2001
|
-
(
|
|
2002
|
-
),
|
|
2006
|
+
(f) => l.syncFlowModel(f)
|
|
2007
|
+
), le(
|
|
2003
2008
|
() => t.editor.selectionMode.value,
|
|
2004
|
-
(
|
|
2005
|
-
if (
|
|
2006
|
-
|
|
2007
|
-
const
|
|
2008
|
-
|
|
2009
|
+
(f) => {
|
|
2010
|
+
if (C?.(), C = null, f) {
|
|
2011
|
+
Ce(!1), J.enableRubberband?.();
|
|
2012
|
+
const M = () => {
|
|
2013
|
+
r.container.removeEventListener("mouseup", M), C = null, setTimeout(() => {
|
|
2009
2014
|
t.editor.selectionMode.value && t.editor.setSelectionMode(!1);
|
|
2010
2015
|
}, 50);
|
|
2011
2016
|
};
|
|
2012
|
-
|
|
2017
|
+
r.container.addEventListener("mouseup", M), C = () => r.container.removeEventListener("mouseup", M);
|
|
2013
2018
|
} else
|
|
2014
|
-
|
|
2019
|
+
J.disableRubberband?.(), Ce(!0);
|
|
2015
2020
|
}
|
|
2016
|
-
),
|
|
2021
|
+
), le(
|
|
2017
2022
|
() => t.editor.mode.value,
|
|
2018
|
-
(
|
|
2019
|
-
const
|
|
2020
|
-
|
|
2023
|
+
(f) => {
|
|
2024
|
+
const M = f === "edit";
|
|
2025
|
+
Ce(!0), M ? J.enableSelection?.() : J.disableSelection?.();
|
|
2021
2026
|
}
|
|
2022
2027
|
);
|
|
2023
|
-
}),
|
|
2024
|
-
d.cleanup(),
|
|
2028
|
+
}), Se(() => {
|
|
2029
|
+
d.cleanup(), y && clearTimeout(y), L?.remove(), C?.(), D && r?.container?.removeEventListener("mousemove", D), n.value?.removeEventListener("keydown", ue), t.editor._pluginManager.detachRuntime(), t.editor.api.value = null;
|
|
2025
2030
|
for (const x of Object.keys(t.editor.extendedApi))
|
|
2026
2031
|
delete t.editor.extendedApi[x];
|
|
2027
|
-
|
|
2028
|
-
}), (x,
|
|
2032
|
+
c?.dispose(), l?.dispose(), a?.dispose(), r?.dispose();
|
|
2033
|
+
}), (x, E) => (k(), S("div", {
|
|
2029
2034
|
ref_key: "rootRef",
|
|
2030
2035
|
ref: n,
|
|
2031
2036
|
class: "flow-canvas-runtime-core",
|
|
2032
2037
|
tabindex: "0"
|
|
2033
2038
|
}, [
|
|
2034
|
-
|
|
2039
|
+
A("div", {
|
|
2035
2040
|
ref_key: "containerRef",
|
|
2036
2041
|
ref: i,
|
|
2037
2042
|
class: "flow-canvas-runtime-core__graph"
|
|
2038
2043
|
}, null, 512),
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
class: "flow-canvas-runtime-core__overlay"
|
|
2043
|
-
}, [
|
|
2044
|
-
(C(!0), M(se, null, ge(Y.value, (y) => (C(), M("div", {
|
|
2045
|
-
key: `badge-${y.nodeId}`,
|
|
2044
|
+
A("div", Nt, [
|
|
2045
|
+
(k(!0), S(ie, null, ye(Y.value, (w) => (k(), S("div", {
|
|
2046
|
+
key: `badge-${w.nodeId}`,
|
|
2046
2047
|
class: "flow-canvas-runtime-core__badge",
|
|
2047
|
-
style:
|
|
2048
|
-
},
|
|
2049
|
-
|
|
2048
|
+
style: me({ left: `${w.x}px`, top: `${w.y}px`, backgroundColor: w.badge.color })
|
|
2049
|
+
}, de(w.badge.text), 5))), 128)),
|
|
2050
|
+
G.value ? (k(), ve(St, {
|
|
2050
2051
|
key: 0,
|
|
2051
2052
|
ref_key: "quickAddPopoverRef",
|
|
2052
|
-
ref:
|
|
2053
|
-
node:
|
|
2054
|
-
"port-position":
|
|
2055
|
-
"tooltip-text":
|
|
2056
|
-
onOpen:
|
|
2057
|
-
onStartDrag:
|
|
2058
|
-
onMouseenter:
|
|
2059
|
-
onMouseleave:
|
|
2053
|
+
ref: se,
|
|
2054
|
+
node: G.value.node,
|
|
2055
|
+
"port-position": G.value.portPosition,
|
|
2056
|
+
"tooltip-text": X.value.tooltipText,
|
|
2057
|
+
onOpen: ee,
|
|
2058
|
+
onStartDrag: ke,
|
|
2059
|
+
onMouseenter: v,
|
|
2060
|
+
onMouseleave: I
|
|
2060
2061
|
}, {
|
|
2061
|
-
default:
|
|
2062
|
-
|
|
2063
|
-
node:
|
|
2062
|
+
default: Ne(() => [
|
|
2063
|
+
fe(x.$slots, "quick-add-panel", {
|
|
2064
|
+
node: G.value.node,
|
|
2064
2065
|
api: s.editor.api.value,
|
|
2065
|
-
insertNodeToRight: (
|
|
2066
|
-
closePopover: () =>
|
|
2066
|
+
insertNodeToRight: (w) => te(G.value.node.id, w),
|
|
2067
|
+
closePopover: () => se.value?.closePopover()
|
|
2067
2068
|
}, void 0, !0)
|
|
2068
2069
|
]),
|
|
2069
2070
|
_: 3
|
|
2070
|
-
}, 8, ["node", "port-position", "tooltip-text"])) :
|
|
2071
|
-
|
|
2071
|
+
}, 8, ["node", "port-position", "tooltip-text"])) : H("", !0),
|
|
2072
|
+
Q.value ? (k(), ve(Ct, {
|
|
2072
2073
|
key: 1,
|
|
2073
|
-
node:
|
|
2074
|
-
position:
|
|
2075
|
-
config:
|
|
2076
|
-
behavior:
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
class: "flow-canvas-runtime-core__node-overlay",
|
|
2084
|
-
onMouseenter: k[0] || (k[0] = //@ts-ignore
|
|
2085
|
-
(...D) => le(E) && le(E)(...D)),
|
|
2086
|
-
onMouseleave: k[1] || (k[1] = //@ts-ignore
|
|
2087
|
-
(...D) => le(b) && le(b)(...D))
|
|
2088
|
-
}, [
|
|
2089
|
-
ce(x.$slots, "node-overlay", {
|
|
2090
|
-
node: y.node,
|
|
2091
|
-
screenAnchors: y.screenAnchors,
|
|
2092
|
-
api: s.editor.api.value
|
|
2093
|
-
}, void 0, !0)
|
|
2094
|
-
], 32))), 128))
|
|
2095
|
-
], 512)
|
|
2074
|
+
node: Q.value.node,
|
|
2075
|
+
position: Q.value.position,
|
|
2076
|
+
config: q.value,
|
|
2077
|
+
behavior: Q.value.behavior,
|
|
2078
|
+
"actions-offset": Q.value.behavior.actionsOffset,
|
|
2079
|
+
onAction: Z,
|
|
2080
|
+
onMouseenter: Ue(u),
|
|
2081
|
+
onMouseleave: N
|
|
2082
|
+
}, null, 8, ["node", "position", "config", "behavior", "actions-offset", "onMouseenter"])) : H("", !0)
|
|
2083
|
+
])
|
|
2096
2084
|
], 512));
|
|
2097
2085
|
}
|
|
2098
|
-
}), ao = /* @__PURE__ */
|
|
2086
|
+
}), ao = /* @__PURE__ */ ae(Dt, [["__scopeId", "data-v-96013976"]]), _t = { class: "flow-canvas-node-palette" }, Pt = ["data-node-type"], At = { class: "flow-canvas-node-palette__item-label" }, Tt = /* @__PURE__ */ re({
|
|
2099
2087
|
__name: "canvas-node-palette",
|
|
2100
2088
|
props: {
|
|
2101
2089
|
editor: {},
|
|
2102
2090
|
items: {}
|
|
2103
2091
|
},
|
|
2104
2092
|
setup(s) {
|
|
2105
|
-
const e = s, t =
|
|
2093
|
+
const e = s, t = z(), o = j(() => e.items ? e.items : Object.keys(e.editor.schema.nodeTypes).map((n) => ({
|
|
2106
2094
|
type: n,
|
|
2107
2095
|
label: n.charAt(0).toUpperCase() + n.slice(1)
|
|
2108
2096
|
})));
|
|
2109
|
-
return
|
|
2097
|
+
return le(
|
|
2110
2098
|
[() => e.editor.api.value, o, t],
|
|
2111
|
-
([n, i, r],
|
|
2099
|
+
([n, i, r], l, a) => {
|
|
2112
2100
|
if (!n || !r) return;
|
|
2113
2101
|
const c = [];
|
|
2114
|
-
for (const
|
|
2115
|
-
const
|
|
2116
|
-
if (!
|
|
2117
|
-
const
|
|
2118
|
-
id:
|
|
2119
|
-
type:
|
|
2120
|
-
label:
|
|
2102
|
+
for (const d of i) {
|
|
2103
|
+
const g = r.querySelector(`[data-node-type="${d.type}"]`);
|
|
2104
|
+
if (!g) continue;
|
|
2105
|
+
const p = n.registerDndSource(g, () => ({
|
|
2106
|
+
id: T(),
|
|
2107
|
+
type: d.type,
|
|
2108
|
+
label: d.label,
|
|
2121
2109
|
position: { x: 0, y: 0 }
|
|
2122
2110
|
}));
|
|
2123
|
-
c.push(
|
|
2111
|
+
c.push(p);
|
|
2124
2112
|
}
|
|
2125
|
-
|
|
2126
|
-
for (const
|
|
2113
|
+
a(() => {
|
|
2114
|
+
for (const d of c) d();
|
|
2127
2115
|
});
|
|
2128
2116
|
},
|
|
2129
2117
|
{ flush: "post" }
|
|
2130
|
-
), (n, i) => (
|
|
2131
|
-
|
|
2118
|
+
), (n, i) => (k(), S("div", _t, [
|
|
2119
|
+
A("div", {
|
|
2132
2120
|
ref_key: "listRef",
|
|
2133
2121
|
ref: t,
|
|
2134
2122
|
class: "flow-canvas-node-palette__list"
|
|
2135
2123
|
}, [
|
|
2136
|
-
(
|
|
2124
|
+
(k(!0), S(ie, null, ye(o.value, (r) => (k(), S("div", {
|
|
2137
2125
|
key: r.type,
|
|
2138
2126
|
class: "flow-canvas-node-palette__item",
|
|
2139
2127
|
"data-node-type": r.type
|
|
2140
2128
|
}, [
|
|
2141
|
-
r.icon ? (
|
|
2129
|
+
r.icon ? (k(), S("i", {
|
|
2142
2130
|
key: 0,
|
|
2143
|
-
class:
|
|
2144
|
-
}, null, 2)) :
|
|
2145
|
-
|
|
2131
|
+
class: W([r.icon, "flow-canvas-node-palette__item-icon"])
|
|
2132
|
+
}, null, 2)) : H("", !0),
|
|
2133
|
+
A("span", At, de(r.label), 1)
|
|
2146
2134
|
], 8, Pt))), 128))
|
|
2147
2135
|
], 512)
|
|
2148
2136
|
]));
|
|
2149
2137
|
}
|
|
2150
|
-
}),
|
|
2138
|
+
}), Rt = /* @__PURE__ */ ae(Tt, [["__scopeId", "data-v-300314b7"]]), $t = { class: "flow-canvas-layout" }, Lt = { class: "flow-canvas-layout__main" }, Bt = { class: "flow-canvas-layout__content" }, zt = {
|
|
2151
2139
|
key: 0,
|
|
2152
2140
|
class: "flow-canvas-layout__footer"
|
|
2153
|
-
},
|
|
2141
|
+
}, Ot = /* @__PURE__ */ re({
|
|
2154
2142
|
__name: "canvas-layout",
|
|
2155
2143
|
props: {
|
|
2156
2144
|
sidebarCollapsed: { type: Boolean, default: !1 },
|
|
@@ -2162,33 +2150,36 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
|
|
|
2162
2150
|
},
|
|
2163
2151
|
emits: ["update:sidebarCollapsed"],
|
|
2164
2152
|
setup(s) {
|
|
2165
|
-
return (e, t) => (
|
|
2166
|
-
!s.hideSidebar && (e.$slots.sidebar || s.editor) ? (
|
|
2153
|
+
return (e, t) => (k(), S("div", $t, [
|
|
2154
|
+
!s.hideSidebar && (e.$slots.sidebar || s.editor) ? (k(), S("aside", {
|
|
2167
2155
|
key: 0,
|
|
2168
|
-
class:
|
|
2169
|
-
style:
|
|
2156
|
+
class: W(["flow-canvas-layout__sidebar", { "is-collapsed": s.sidebarCollapsed }]),
|
|
2157
|
+
style: me({ width: s.sidebarCollapsed ? "0px" : `${s.sidebarWidth}px` })
|
|
2170
2158
|
}, [
|
|
2171
|
-
|
|
2172
|
-
s.editor ? (
|
|
2159
|
+
fe(e.$slots, "sidebar", {}, () => [
|
|
2160
|
+
s.editor ? (k(), ve(Rt, {
|
|
2173
2161
|
key: 0,
|
|
2174
2162
|
editor: s.editor,
|
|
2175
2163
|
items: s.paletteItems
|
|
2176
|
-
}, null, 8, ["editor", "items"])) :
|
|
2164
|
+
}, null, 8, ["editor", "items"])) : H("", !0)
|
|
2177
2165
|
], !0)
|
|
2178
|
-
], 6)) :
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2166
|
+
], 6)) : H("", !0),
|
|
2167
|
+
A("div", Lt, [
|
|
2168
|
+
A("div", Bt, [
|
|
2169
|
+
fe(e.$slots, "default", {}, void 0, !0)
|
|
2182
2170
|
]),
|
|
2183
|
-
!s.hideFooter && e.$slots.footer ? (
|
|
2184
|
-
|
|
2185
|
-
])) :
|
|
2171
|
+
!s.hideFooter && e.$slots.footer ? (k(), S("div", zt, [
|
|
2172
|
+
fe(e.$slots, "footer", {}, void 0, !0)
|
|
2173
|
+
])) : H("", !0)
|
|
2186
2174
|
])
|
|
2187
2175
|
]));
|
|
2188
2176
|
}
|
|
2189
|
-
}), lo = /* @__PURE__ */
|
|
2177
|
+
}), lo = /* @__PURE__ */ ae(Ot, [["__scopeId", "data-v-26f35b6b"]]), jt = ["undo", "redo"];
|
|
2190
2178
|
function Ht(s) {
|
|
2191
|
-
const e = new Set(s?.
|
|
2179
|
+
const e = new Set(s?.include), t = /* @__PURE__ */ new Set([
|
|
2180
|
+
...jt.filter((a) => !e.has(a)),
|
|
2181
|
+
...s?.exclude ?? []
|
|
2182
|
+
]), o = [
|
|
2192
2183
|
{
|
|
2193
2184
|
id: "undo",
|
|
2194
2185
|
type: "undo",
|
|
@@ -2205,7 +2196,7 @@ function Ht(s) {
|
|
|
2205
2196
|
description: "重做",
|
|
2206
2197
|
order: 11
|
|
2207
2198
|
}
|
|
2208
|
-
],
|
|
2199
|
+
], n = [
|
|
2209
2200
|
{
|
|
2210
2201
|
id: "select",
|
|
2211
2202
|
type: "select",
|
|
@@ -2246,7 +2237,7 @@ function Ht(s) {
|
|
|
2246
2237
|
description: "导出为图片",
|
|
2247
2238
|
order: 24
|
|
2248
2239
|
}
|
|
2249
|
-
],
|
|
2240
|
+
], i = [
|
|
2250
2241
|
{
|
|
2251
2242
|
id: "zoom-out",
|
|
2252
2243
|
type: "zoom-out",
|
|
@@ -2264,7 +2255,7 @@ function Ht(s) {
|
|
|
2264
2255
|
description: "放大画布",
|
|
2265
2256
|
order: 32
|
|
2266
2257
|
}
|
|
2267
|
-
],
|
|
2258
|
+
], r = [
|
|
2268
2259
|
{
|
|
2269
2260
|
id: "reset",
|
|
2270
2261
|
type: "reset",
|
|
@@ -2274,9 +2265,9 @@ function Ht(s) {
|
|
|
2274
2265
|
order: 40
|
|
2275
2266
|
}
|
|
2276
2267
|
];
|
|
2277
|
-
return [...[...
|
|
2278
|
-
(a) => !
|
|
2279
|
-
), ...
|
|
2268
|
+
return [...[...o, ...n].filter(
|
|
2269
|
+
(a) => !t.has(a.type)
|
|
2270
|
+
), ...i, ...r];
|
|
2280
2271
|
}
|
|
2281
2272
|
const Ft = { class: "flow-canvas-toolbar" }, Ut = {
|
|
2282
2273
|
key: 0,
|
|
@@ -2284,7 +2275,7 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
|
|
|
2284
2275
|
}, qt = { class: "flow-canvas-toolbar__group" }, Gt = {
|
|
2285
2276
|
key: 0,
|
|
2286
2277
|
class: "flow-canvas-toolbar__zoom-display"
|
|
2287
|
-
}, Vt = ["data-description", "disabled", "onClick"], Wt = ["textContent"], Qt = /* @__PURE__ */
|
|
2278
|
+
}, Vt = ["data-description", "disabled", "onClick"], Wt = ["textContent"], Qt = /* @__PURE__ */ re({
|
|
2288
2279
|
__name: "canvas-toolbar",
|
|
2289
2280
|
props: {
|
|
2290
2281
|
items: {},
|
|
@@ -2292,42 +2283,42 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
|
|
|
2292
2283
|
editor: {}
|
|
2293
2284
|
},
|
|
2294
2285
|
setup(s) {
|
|
2295
|
-
const e = s, t =
|
|
2286
|
+
const e = s, t = j(() => e.items ? e.items : Ht({ exclude: e.exclude })), o = z(1);
|
|
2296
2287
|
let n = null;
|
|
2297
|
-
|
|
2288
|
+
le(
|
|
2298
2289
|
() => e.editor.api.value,
|
|
2299
|
-
(
|
|
2300
|
-
n?.(), n = null,
|
|
2301
|
-
o.value =
|
|
2290
|
+
(u) => {
|
|
2291
|
+
n?.(), n = null, u && (o.value = u.getZoom(), n = u.onGraphEvent("scale", () => {
|
|
2292
|
+
o.value = u.getZoom();
|
|
2302
2293
|
}));
|
|
2303
2294
|
},
|
|
2304
2295
|
{ immediate: !0 }
|
|
2305
|
-
),
|
|
2296
|
+
), Le(() => {
|
|
2306
2297
|
n?.();
|
|
2307
2298
|
});
|
|
2308
|
-
const i =
|
|
2299
|
+
const i = j(() => `${Math.round(o.value * 100)}%`), r = j(() => e.editor.api.value ? {
|
|
2309
2300
|
api: e.editor.api.value,
|
|
2310
2301
|
flowModel: e.editor.flowModel.value,
|
|
2311
2302
|
history: e.editor.history,
|
|
2312
2303
|
mode: e.editor.mode.value
|
|
2313
2304
|
} : null);
|
|
2314
|
-
function
|
|
2315
|
-
return
|
|
2305
|
+
function l(u) {
|
|
2306
|
+
return u.visible === !1 ? !1 : typeof u.visible == "function" ? r.value ? u.visible(r.value) : !1 : !0;
|
|
2316
2307
|
}
|
|
2317
|
-
function
|
|
2318
|
-
return
|
|
2308
|
+
function a(u) {
|
|
2309
|
+
return u.type === "select" ? e.editor.selectionMode.value : !1;
|
|
2319
2310
|
}
|
|
2320
|
-
function c(
|
|
2321
|
-
return !r.value ||
|
|
2311
|
+
function c(u) {
|
|
2312
|
+
return !r.value || u.disabled === !0 ? !0 : typeof u.disabled == "function" ? u.disabled(r.value) : u.type === "undo" ? !e.editor.history.canUndo.value : u.type === "redo" ? !e.editor.history.canRedo.value : !1;
|
|
2322
2313
|
}
|
|
2323
|
-
function u
|
|
2324
|
-
if (!r.value || c(
|
|
2325
|
-
if (
|
|
2326
|
-
|
|
2314
|
+
function d(u) {
|
|
2315
|
+
if (!r.value || c(u)) return;
|
|
2316
|
+
if (u.onClick) {
|
|
2317
|
+
u.onClick(r.value);
|
|
2327
2318
|
return;
|
|
2328
2319
|
}
|
|
2329
|
-
const { api:
|
|
2330
|
-
switch (
|
|
2320
|
+
const { api: N } = r.value;
|
|
2321
|
+
switch (u.type) {
|
|
2331
2322
|
case "undo":
|
|
2332
2323
|
e.editor.history.undo();
|
|
2333
2324
|
break;
|
|
@@ -2335,21 +2326,21 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
|
|
|
2335
2326
|
e.editor.history.redo();
|
|
2336
2327
|
break;
|
|
2337
2328
|
case "zoom-in":
|
|
2338
|
-
|
|
2329
|
+
N.zoomIn(), o.value = N.getZoom();
|
|
2339
2330
|
break;
|
|
2340
2331
|
case "zoom-out":
|
|
2341
|
-
|
|
2332
|
+
N.zoomOut(), o.value = N.getZoom();
|
|
2342
2333
|
break;
|
|
2343
2334
|
case "fit":
|
|
2344
|
-
|
|
2335
|
+
N.zoomToFit();
|
|
2345
2336
|
break;
|
|
2346
2337
|
case "reset":
|
|
2347
|
-
|
|
2338
|
+
N.zoomTo(1), N.scrollToOrigin(), o.value = 1;
|
|
2348
2339
|
break;
|
|
2349
2340
|
case "export":
|
|
2350
|
-
|
|
2351
|
-
const
|
|
2352
|
-
|
|
2341
|
+
N.exportAsImage().then((b) => {
|
|
2342
|
+
const y = URL.createObjectURL(b), m = document.createElement("a");
|
|
2343
|
+
m.href = y, m.download = "canvas-export.png", m.click(), URL.revokeObjectURL(y);
|
|
2353
2344
|
}).catch((b) => {
|
|
2354
2345
|
console.warn("[flow-canvas] Export failed:", b);
|
|
2355
2346
|
});
|
|
@@ -2360,44 +2351,44 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
|
|
|
2360
2351
|
case "search":
|
|
2361
2352
|
case "auto-layout":
|
|
2362
2353
|
case "minimap":
|
|
2363
|
-
console.warn(`[flow-canvas] "${
|
|
2354
|
+
console.warn(`[flow-canvas] "${u.type}" toolbar item has no built-in handler. Provide an onClick callback.`);
|
|
2364
2355
|
break;
|
|
2365
2356
|
default:
|
|
2366
|
-
|
|
2357
|
+
u.type !== "custom" && console.warn(`[flow-canvas] No default handler for toolbar type "${u.type}". Provide an onClick handler.`);
|
|
2367
2358
|
break;
|
|
2368
2359
|
}
|
|
2369
2360
|
}
|
|
2370
|
-
const
|
|
2371
|
-
const
|
|
2372
|
-
for (const b of
|
|
2373
|
-
const
|
|
2374
|
-
|
|
2361
|
+
const g = j(() => t.value.filter(l)), p = j(() => {
|
|
2362
|
+
const u = /* @__PURE__ */ new Map(), N = [];
|
|
2363
|
+
for (const b of g.value) {
|
|
2364
|
+
const y = b.group ?? "default";
|
|
2365
|
+
u.has(y) || (u.set(y, []), N.push(y)), u.get(y).push(b);
|
|
2375
2366
|
}
|
|
2376
|
-
return
|
|
2367
|
+
return N.map((b) => ({ name: b, items: u.get(b) })).filter((b) => b.items.length > 0);
|
|
2377
2368
|
});
|
|
2378
|
-
return (
|
|
2379
|
-
(
|
|
2369
|
+
return (u, N) => (k(), S("div", Ft, [
|
|
2370
|
+
(k(!0), S(ie, null, ye(p.value, (b, y) => (k(), S(ie, {
|
|
2380
2371
|
key: b.name
|
|
2381
2372
|
}, [
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
(
|
|
2385
|
-
key:
|
|
2373
|
+
y > 0 ? (k(), S("div", Ut)) : H("", !0),
|
|
2374
|
+
A("div", qt, [
|
|
2375
|
+
(k(!0), S(ie, null, ye(b.items, (m) => (k(), S(ie, {
|
|
2376
|
+
key: m.id
|
|
2386
2377
|
}, [
|
|
2387
|
-
|
|
2378
|
+
m.type === "zoom-display" ? (k(), S("span", Gt, de(i.value), 1)) : (k(), S("button", {
|
|
2388
2379
|
key: 1,
|
|
2389
|
-
class:
|
|
2390
|
-
"data-description":
|
|
2391
|
-
disabled: c(
|
|
2392
|
-
onClick: (
|
|
2380
|
+
class: W(["flow-canvas-toolbar__btn", { "is-disabled": c(m), "is-active": a(m) }]),
|
|
2381
|
+
"data-description": m.description,
|
|
2382
|
+
disabled: c(m),
|
|
2383
|
+
onClick: (R) => d(m)
|
|
2393
2384
|
}, [
|
|
2394
|
-
|
|
2385
|
+
m.component ? (k(), ve(qe(m.component), { key: 0 })) : m.icon ? (k(), S("i", {
|
|
2395
2386
|
key: 1,
|
|
2396
|
-
class:
|
|
2397
|
-
}, null, 2)) : (
|
|
2387
|
+
class: W(m.icon)
|
|
2388
|
+
}, null, 2)) : (k(), S("span", {
|
|
2398
2389
|
key: 2,
|
|
2399
2390
|
class: "flow-canvas-toolbar__text",
|
|
2400
|
-
textContent:
|
|
2391
|
+
textContent: de(m.text ?? m.description ?? m.id)
|
|
2401
2392
|
}, null, 8, Wt))
|
|
2402
2393
|
], 10, Vt))
|
|
2403
2394
|
], 64))), 128))
|
|
@@ -2405,49 +2396,49 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
|
|
|
2405
2396
|
], 64))), 128))
|
|
2406
2397
|
]));
|
|
2407
2398
|
}
|
|
2408
|
-
}), co = /* @__PURE__ */
|
|
2399
|
+
}), co = /* @__PURE__ */ ae(Qt, [["__scopeId", "data-v-ca50cd45"]]), Xt = { class: "flow-canvas-default-node__ep-label" }, Kt = {
|
|
2409
2400
|
key: 1,
|
|
2410
2401
|
class: "flow-canvas-default-node__diamond"
|
|
2411
|
-
},
|
|
2402
|
+
}, Yt = {
|
|
2412
2403
|
key: 2,
|
|
2413
2404
|
class: "flow-canvas-default-node__task-label"
|
|
2414
|
-
}, Zt = /* @__PURE__ */
|
|
2405
|
+
}, Zt = /* @__PURE__ */ re({
|
|
2415
2406
|
__name: "default-node",
|
|
2416
2407
|
setup(s) {
|
|
2417
|
-
const t =
|
|
2408
|
+
const t = Ge("getNode")?.(), o = j(() => t?.getData?.() ?? null), n = j(() => o.value?.label || o.value?.type || ""), i = {
|
|
2418
2409
|
start: "canvas-kaishi",
|
|
2419
2410
|
end: "canvas-stop",
|
|
2420
2411
|
"parallel-gateway": "canvas-bingxingwangguan",
|
|
2421
2412
|
"branch-gateway": "canvas-fenzhiwangguan",
|
|
2422
2413
|
"converge-gateway": "canvas-huijuwangguan",
|
|
2423
2414
|
"conditional-parallel-gateway": "canvas-tiaojianbingxingwangguan"
|
|
2424
|
-
}, r = /* @__PURE__ */ new Set(["start", "end"]),
|
|
2415
|
+
}, r = /* @__PURE__ */ new Set(["start", "end"]), l = /* @__PURE__ */ new Set([
|
|
2425
2416
|
"parallel-gateway",
|
|
2426
2417
|
"branch-gateway",
|
|
2427
2418
|
"converge-gateway",
|
|
2428
2419
|
"conditional-parallel-gateway"
|
|
2429
|
-
]),
|
|
2430
|
-
const
|
|
2431
|
-
return r.has(
|
|
2432
|
-
}), c =
|
|
2433
|
-
return (
|
|
2434
|
-
class:
|
|
2420
|
+
]), a = j(() => {
|
|
2421
|
+
const d = o.value?.type ?? "";
|
|
2422
|
+
return r.has(d) ? "endpoint" : l.has(d) ? "gateway" : "task";
|
|
2423
|
+
}), c = j(() => i[o.value?.type ?? ""] ?? "");
|
|
2424
|
+
return (d, g) => (k(), S("div", {
|
|
2425
|
+
class: W(["flow-canvas-default-node", `is-${a.value}`])
|
|
2435
2426
|
}, [
|
|
2436
|
-
|
|
2437
|
-
c.value ? (
|
|
2427
|
+
a.value === "endpoint" ? (k(), S(ie, { key: 0 }, [
|
|
2428
|
+
c.value ? (k(), S("i", {
|
|
2438
2429
|
key: 0,
|
|
2439
|
-
class:
|
|
2440
|
-
}, null, 2)) :
|
|
2441
|
-
|
|
2442
|
-
], 64)) :
|
|
2443
|
-
c.value ? (
|
|
2430
|
+
class: W([["flow-canvas-icon", c.value], "flow-canvas-default-node__ep-icon"])
|
|
2431
|
+
}, null, 2)) : H("", !0),
|
|
2432
|
+
A("span", Xt, de(n.value), 1)
|
|
2433
|
+
], 64)) : a.value === "gateway" ? (k(), S("div", Kt, [
|
|
2434
|
+
c.value ? (k(), S("i", {
|
|
2444
2435
|
key: 0,
|
|
2445
|
-
class:
|
|
2446
|
-
}, null, 2)) :
|
|
2447
|
-
])) : (
|
|
2436
|
+
class: W([["flow-canvas-icon", c.value], "flow-canvas-default-node__gw-icon"])
|
|
2437
|
+
}, null, 2)) : H("", !0)
|
|
2438
|
+
])) : (k(), S("span", Yt, de(n.value), 1))
|
|
2448
2439
|
], 2));
|
|
2449
2440
|
}
|
|
2450
|
-
}), Jt = /* @__PURE__ */
|
|
2441
|
+
}), Jt = /* @__PURE__ */ ae(Zt, [["__scopeId", "data-v-c88cdae7"]]), eo = {
|
|
2451
2442
|
start: { label: "开始", icon: "flow-canvas-icon canvas-kaishi", width: 88, height: 40 },
|
|
2452
2443
|
end: { label: "结束", icon: "flow-canvas-icon canvas-stop", width: 88, height: 40 },
|
|
2453
2444
|
empty: { label: "空节点", icon: "flow-canvas-icon canvas-jiedi", width: 240, height: 48 },
|
|
@@ -2460,10 +2451,10 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
|
|
|
2460
2451
|
width: 64,
|
|
2461
2452
|
height: 64
|
|
2462
2453
|
}
|
|
2463
|
-
},
|
|
2454
|
+
}, Re = (s, e) => ({
|
|
2464
2455
|
stroke: e.hovered ? "#3a84ff" : "#abb5cc",
|
|
2465
2456
|
strokeWidth: 2
|
|
2466
|
-
}),
|
|
2457
|
+
}), $e = {
|
|
2467
2458
|
attrs: {
|
|
2468
2459
|
line: {
|
|
2469
2460
|
stroke: "#abb5cc",
|
|
@@ -2475,22 +2466,22 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
|
|
|
2475
2466
|
manhattan: {
|
|
2476
2467
|
router: { name: "manhattan", args: { padding: 10, maxDirectionChange: 90 } },
|
|
2477
2468
|
connector: { name: "rounded", args: { radius: 8 } },
|
|
2478
|
-
style:
|
|
2479
|
-
x6EdgeConfig:
|
|
2469
|
+
style: Re,
|
|
2470
|
+
x6EdgeConfig: $e
|
|
2480
2471
|
},
|
|
2481
2472
|
bezier: {
|
|
2482
2473
|
connector: { name: "smooth" },
|
|
2483
|
-
style:
|
|
2484
|
-
x6EdgeConfig:
|
|
2474
|
+
style: Re,
|
|
2475
|
+
x6EdgeConfig: $e
|
|
2485
2476
|
}
|
|
2486
2477
|
};
|
|
2487
2478
|
function uo(s) {
|
|
2488
2479
|
const e = s?.nodeTypes ?? eo, t = {}, o = [];
|
|
2489
|
-
for (const [r,
|
|
2490
|
-
const
|
|
2480
|
+
for (const [r, l] of Object.entries(e)) {
|
|
2481
|
+
const a = l.width ?? 150, c = l.height ?? 50;
|
|
2491
2482
|
t[r] = {
|
|
2492
2483
|
component: Jt,
|
|
2493
|
-
getSize: () => ({ width:
|
|
2484
|
+
getSize: () => ({ width: a, height: c }),
|
|
2494
2485
|
getPorts: () => [
|
|
2495
2486
|
{ id: "top", group: "top" },
|
|
2496
2487
|
{ id: "right", group: "right" },
|
|
@@ -2499,8 +2490,8 @@ function uo(s) {
|
|
|
2499
2490
|
]
|
|
2500
2491
|
}, o.push({
|
|
2501
2492
|
type: r,
|
|
2502
|
-
label:
|
|
2503
|
-
icon:
|
|
2493
|
+
label: l.label ?? r,
|
|
2494
|
+
icon: l.icon
|
|
2504
2495
|
});
|
|
2505
2496
|
}
|
|
2506
2497
|
const n = {
|
|
@@ -2519,22 +2510,22 @@ function fo(s) {
|
|
|
2519
2510
|
transformCommand(e, t, o) {
|
|
2520
2511
|
for (const n of e.commands) {
|
|
2521
2512
|
if (n.type !== "edge.add" && n.type !== "edge.reconnect") continue;
|
|
2522
|
-
const i = o.flowModel.value, r = n.type === "edge.add" ? n.edge.source.nodeId : n.source?.nodeId,
|
|
2523
|
-
if (!r || !
|
|
2524
|
-
const
|
|
2525
|
-
if (!
|
|
2526
|
-
const
|
|
2513
|
+
const i = o.flowModel.value, r = n.type === "edge.add" ? n.edge.source.nodeId : n.source?.nodeId, l = n.type === "edge.add" ? n.edge.target.nodeId : n.target?.nodeId;
|
|
2514
|
+
if (!r || !l) continue;
|
|
2515
|
+
const a = i.nodes[r], c = i.nodes[l];
|
|
2516
|
+
if (!a || !c) continue;
|
|
2517
|
+
const d = n.type === "edge.add" ? n.edge.source.portId : n.source?.portId, g = n.type === "edge.add" ? n.edge.target.portId : n.target?.portId, p = d ? a.ports?.find((m) => m.id === d) : void 0, u = g ? c.ports?.find((m) => m.id === g) : void 0, N = n.type === "edge.reconnect" ? n.edgeId : void 0, b = Object.values(i.edges).filter((m) => m.id !== N), y = s({
|
|
2527
2518
|
flowModel: i,
|
|
2528
|
-
sourceNode:
|
|
2519
|
+
sourceNode: a,
|
|
2529
2520
|
targetNode: c,
|
|
2530
|
-
sourcePort:
|
|
2531
|
-
targetPort:
|
|
2521
|
+
sourcePort: p,
|
|
2522
|
+
targetPort: u,
|
|
2532
2523
|
existingEdges: b
|
|
2533
2524
|
});
|
|
2534
|
-
if (!
|
|
2525
|
+
if (!y.valid)
|
|
2535
2526
|
return {
|
|
2536
2527
|
rejected: !0,
|
|
2537
|
-
reason:
|
|
2528
|
+
reason: y.reason ?? "Connection validation failed",
|
|
2538
2529
|
code: "validation_failed"
|
|
2539
2530
|
};
|
|
2540
2531
|
}
|
|
@@ -2552,7 +2543,7 @@ function po(s) {
|
|
|
2552
2543
|
n.graph.use(
|
|
2553
2544
|
new i({
|
|
2554
2545
|
enabled: !0,
|
|
2555
|
-
rubberband:
|
|
2546
|
+
rubberband: e,
|
|
2556
2547
|
multiple: t,
|
|
2557
2548
|
movable: o,
|
|
2558
2549
|
showNodeSelectionBox: !0,
|
|
@@ -2631,53 +2622,53 @@ function vo() {
|
|
|
2631
2622
|
if (n && t.key === "c") {
|
|
2632
2623
|
const i = o.graph.getSelectedCells?.() ?? [];
|
|
2633
2624
|
if (!i.length) return !1;
|
|
2634
|
-
const r = o.flowModel.value,
|
|
2635
|
-
if (!
|
|
2625
|
+
const r = o.flowModel.value, l = new Set(i.filter((d) => d.isNode()).map((d) => d.id)), a = [...l].map((d) => r.nodes[d]).filter(Boolean);
|
|
2626
|
+
if (!a.length) return !1;
|
|
2636
2627
|
const c = Object.values(r.edges).filter(
|
|
2637
|
-
(
|
|
2628
|
+
(d) => l.has(d.source.nodeId) && l.has(d.target.nodeId)
|
|
2638
2629
|
);
|
|
2639
|
-
return s = { nodes:
|
|
2630
|
+
return s = { nodes: a, edges: c }, e = 0, !0;
|
|
2640
2631
|
}
|
|
2641
2632
|
if (n && t.key === "v") {
|
|
2642
2633
|
if (!s?.nodes.length) return !1;
|
|
2643
2634
|
e++;
|
|
2644
|
-
const i = e * 30, r = /* @__PURE__ */ new Map(),
|
|
2645
|
-
for (const
|
|
2646
|
-
const c = `${
|
|
2647
|
-
r.set(
|
|
2635
|
+
const i = e * 30, r = /* @__PURE__ */ new Map(), l = [];
|
|
2636
|
+
for (const a of s.nodes) {
|
|
2637
|
+
const c = `${a.id}_cp${T().slice(0, 6)}`;
|
|
2638
|
+
r.set(a.id, c), l.push({
|
|
2648
2639
|
type: "node.add",
|
|
2649
2640
|
node: {
|
|
2650
|
-
...
|
|
2641
|
+
...a,
|
|
2651
2642
|
id: c,
|
|
2652
2643
|
position: {
|
|
2653
|
-
x:
|
|
2654
|
-
y:
|
|
2644
|
+
x: a.position.x + i,
|
|
2645
|
+
y: a.position.y + i
|
|
2655
2646
|
},
|
|
2656
|
-
payload:
|
|
2657
|
-
extensions:
|
|
2647
|
+
payload: a.payload ? { ...a.payload } : {},
|
|
2648
|
+
extensions: a.extensions ? { ...a.extensions } : void 0
|
|
2658
2649
|
}
|
|
2659
2650
|
});
|
|
2660
2651
|
}
|
|
2661
|
-
for (const
|
|
2662
|
-
const c = r.get(
|
|
2663
|
-
!c || !
|
|
2652
|
+
for (const a of s.edges) {
|
|
2653
|
+
const c = r.get(a.source.nodeId), d = r.get(a.target.nodeId);
|
|
2654
|
+
!c || !d || l.push({
|
|
2664
2655
|
type: "edge.add",
|
|
2665
2656
|
edge: {
|
|
2666
|
-
...
|
|
2667
|
-
id: `${
|
|
2668
|
-
source: { ...
|
|
2669
|
-
target: { ...
|
|
2670
|
-
labels:
|
|
2671
|
-
payload:
|
|
2657
|
+
...a,
|
|
2658
|
+
id: `${a.id}_cp${T().slice(0, 6)}`,
|
|
2659
|
+
source: { ...a.source, nodeId: c },
|
|
2660
|
+
target: { ...a.target, nodeId: d },
|
|
2661
|
+
labels: a.labels?.map((g) => ({ ...g, id: `${g.id}_cp${T().slice(0, 6)}` })),
|
|
2662
|
+
payload: a.payload ? { ...a.payload } : {}
|
|
2672
2663
|
}
|
|
2673
2664
|
});
|
|
2674
2665
|
}
|
|
2675
|
-
return
|
|
2676
|
-
id:
|
|
2666
|
+
return l.length && o.executeCommand({
|
|
2667
|
+
id: T(),
|
|
2677
2668
|
source: "user:keyboard",
|
|
2678
2669
|
label: "粘贴",
|
|
2679
2670
|
timestamp: Date.now(),
|
|
2680
|
-
commands:
|
|
2671
|
+
commands: l
|
|
2681
2672
|
}), !0;
|
|
2682
2673
|
}
|
|
2683
2674
|
return !1;
|
|
@@ -2687,21 +2678,21 @@ function vo() {
|
|
|
2687
2678
|
export {
|
|
2688
2679
|
K as CanvasConstraintError,
|
|
2689
2680
|
lo as CanvasLayout,
|
|
2690
|
-
|
|
2681
|
+
Rt as CanvasNodePalette,
|
|
2691
2682
|
ao as CanvasRuntime,
|
|
2692
|
-
|
|
2683
|
+
Qe as CanvasSchemaError,
|
|
2693
2684
|
co as CanvasToolbar,
|
|
2694
2685
|
Jt as DefaultNode,
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2686
|
+
Ct as NodeActionsToolbar,
|
|
2687
|
+
St as NodeQuickAddPopover,
|
|
2688
|
+
Me as applyCanvasCommand,
|
|
2698
2689
|
vo as clipboardPlugin,
|
|
2699
2690
|
fo as connectionValidatorPlugin,
|
|
2700
|
-
|
|
2691
|
+
lt as createCanvasHistory,
|
|
2701
2692
|
uo as createDefaultSchema,
|
|
2702
2693
|
Ht as createDefaultToolbarItems,
|
|
2703
2694
|
io as createEmptyFlowModel,
|
|
2704
|
-
|
|
2695
|
+
T as generateId,
|
|
2705
2696
|
ho as minimapPlugin,
|
|
2706
2697
|
po as selectionPlugin,
|
|
2707
2698
|
go as snaplinePlugin,
|