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