@blueking/flow-canvas 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1060 -1055
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref as H, computed as V, onScopeDispose as
|
|
1
|
+
import { ref as H, computed as V, onScopeDispose as it, defineComponent as pe, h as qe, watch as he, onBeforeUnmount as Te, createElementBlock as T, openBlock as A, normalizeStyle as Ee, createElementVNode as F, createVNode as at, createCommentVNode as K, normalizeClass as oe, Transition as lt, withCtx as He, withModifiers as ht, createTextVNode as je, renderSlot as Me, nextTick as Ge, onMounted as dt, createBlock as Ie, Fragment as ue, renderList as Ce, toDisplayString as fe, unref as le, reactive as vt, resolveDynamicComponent as mt, Teleport as yt, inject as wt, createApp as bt } from "vue";
|
|
2
2
|
import { Graph as Et } from "@antv/x6";
|
|
3
3
|
import { register as xt } from "@antv/x6-vue-shape";
|
|
4
4
|
import { Selection as It } from "@antv/x6-plugin-selection";
|
|
@@ -10,7 +10,7 @@ function Mn() {
|
|
|
10
10
|
edges: {}
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
class
|
|
13
|
+
class ge extends Error {
|
|
14
14
|
constructor(e) {
|
|
15
15
|
super(e), this.name = "CanvasConstraintError";
|
|
16
16
|
}
|
|
@@ -20,153 +20,153 @@ class kt extends Error {
|
|
|
20
20
|
super(e), this.name = "CanvasSchemaError";
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function Re(
|
|
23
|
+
function Re(n, e, o) {
|
|
24
24
|
if (e.length === 0) {
|
|
25
25
|
if (o === void 0) return;
|
|
26
26
|
if (typeof o != "object" || o === null || Array.isArray(o))
|
|
27
27
|
throw new Error("Root value of payload/extensions/meta must be an object or undefined");
|
|
28
28
|
return o;
|
|
29
29
|
}
|
|
30
|
-
const t =
|
|
31
|
-
let
|
|
32
|
-
for (let
|
|
33
|
-
const l = e[
|
|
34
|
-
a && typeof a == "object" && !Array.isArray(a) ?
|
|
30
|
+
const t = n ? { ...n } : {};
|
|
31
|
+
let s = t;
|
|
32
|
+
for (let i = 0; i < e.length - 1; i++) {
|
|
33
|
+
const l = e[i], a = s[l];
|
|
34
|
+
a && typeof a == "object" && !Array.isArray(a) ? s[l] = { ...a } : s[l] = {}, s = s[l];
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
return o === void 0 ? delete
|
|
36
|
+
const r = e[e.length - 1];
|
|
37
|
+
return o === void 0 ? delete s[r] : s[r] = o, t;
|
|
38
38
|
}
|
|
39
|
-
function ct(
|
|
39
|
+
function ct(n, e) {
|
|
40
40
|
switch (e.type) {
|
|
41
41
|
case "node.add":
|
|
42
|
-
return St(
|
|
42
|
+
return St(n, e.node);
|
|
43
43
|
case "node.move":
|
|
44
|
-
return Mt(
|
|
44
|
+
return Mt(n, e.nodeId, e.position);
|
|
45
45
|
case "node.remove":
|
|
46
|
-
return Nt(
|
|
46
|
+
return Nt(n, e.nodeId);
|
|
47
47
|
case "node.update":
|
|
48
|
-
return Dt(
|
|
48
|
+
return Dt(n, e.nodeId, e.patch);
|
|
49
49
|
case "node.set-payload":
|
|
50
|
-
return At(
|
|
50
|
+
return At(n, e.nodeId, e.path, e.value);
|
|
51
51
|
case "node.set-extensions":
|
|
52
|
-
return _t(
|
|
52
|
+
return _t(n, e.nodeId, e.path, e.value);
|
|
53
53
|
case "edge.add":
|
|
54
|
-
return Pt(
|
|
54
|
+
return Pt(n, e.edge);
|
|
55
55
|
case "edge.remove":
|
|
56
|
-
return Tt(
|
|
56
|
+
return Tt(n, e.edgeId);
|
|
57
57
|
case "edge.reconnect":
|
|
58
|
-
return Rt(
|
|
58
|
+
return Rt(n, e.edgeId, e.source, e.target);
|
|
59
59
|
case "edge.update":
|
|
60
|
-
return Lt(
|
|
60
|
+
return Lt(n, e.edgeId, e.patch);
|
|
61
61
|
case "edge.set-payload":
|
|
62
|
-
return Ot(
|
|
62
|
+
return Ot(n, e.edgeId, e.path, e.value);
|
|
63
63
|
case "edge.label.update":
|
|
64
|
-
return $t(
|
|
64
|
+
return $t(n, e.edgeId, e.labelId, e.patch);
|
|
65
65
|
case "model.set-meta":
|
|
66
|
-
return Bt(
|
|
66
|
+
return Bt(n, e.path, e.value);
|
|
67
67
|
default:
|
|
68
|
-
throw new
|
|
68
|
+
throw new ge(`Unknown command type: ${e.type}`);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
function Ne(
|
|
72
|
-
const o =
|
|
73
|
-
if (!o) throw new
|
|
71
|
+
function Ne(n, e) {
|
|
72
|
+
const o = n.nodes[e];
|
|
73
|
+
if (!o) throw new ge(`Node "${e}" does not exist`);
|
|
74
74
|
return o;
|
|
75
75
|
}
|
|
76
|
-
function De(
|
|
77
|
-
const o =
|
|
78
|
-
if (!o) throw new
|
|
76
|
+
function De(n, e) {
|
|
77
|
+
const o = n.edges[e];
|
|
78
|
+
if (!o) throw new ge(`Edge "${e}" does not exist`);
|
|
79
79
|
return o;
|
|
80
80
|
}
|
|
81
|
-
function ke(
|
|
82
|
-
const t =
|
|
81
|
+
function ke(n, e, o) {
|
|
82
|
+
const t = n.nodes[e.nodeId];
|
|
83
83
|
if (!t)
|
|
84
|
-
throw new
|
|
85
|
-
if (e.portId && t.ports && !t.ports.some((
|
|
86
|
-
throw new
|
|
87
|
-
}
|
|
88
|
-
function Le(
|
|
89
|
-
return { ...
|
|
90
|
-
}
|
|
91
|
-
function Oe(
|
|
92
|
-
return { ...
|
|
93
|
-
}
|
|
94
|
-
function St(
|
|
95
|
-
if (
|
|
96
|
-
throw new
|
|
97
|
-
return { ...
|
|
98
|
-
}
|
|
99
|
-
function Mt(
|
|
100
|
-
const t = Ne(
|
|
101
|
-
return Le(
|
|
102
|
-
}
|
|
103
|
-
function Nt(
|
|
104
|
-
Ne(
|
|
105
|
-
const { [e]: o, ...t } =
|
|
106
|
-
for (const [
|
|
107
|
-
|
|
108
|
-
return { ...
|
|
109
|
-
}
|
|
110
|
-
function Dt(
|
|
111
|
-
const t = Ne(
|
|
112
|
-
return Le(
|
|
113
|
-
}
|
|
114
|
-
function At(
|
|
115
|
-
const
|
|
116
|
-
return Le(
|
|
117
|
-
}
|
|
118
|
-
function _t(
|
|
119
|
-
const
|
|
120
|
-
return Le(
|
|
121
|
-
}
|
|
122
|
-
function Pt(
|
|
123
|
-
if (
|
|
124
|
-
throw new
|
|
125
|
-
if (ke(
|
|
84
|
+
throw new ge(`${o} node "${e.nodeId}" does not exist`);
|
|
85
|
+
if (e.portId && t.ports && !t.ports.some((r) => r.id === e.portId))
|
|
86
|
+
throw new ge(`${o} port "${e.portId}" not found on node "${e.nodeId}"`);
|
|
87
|
+
}
|
|
88
|
+
function Le(n, e, o) {
|
|
89
|
+
return { ...n, nodes: { ...n.nodes, [e]: o } };
|
|
90
|
+
}
|
|
91
|
+
function Oe(n, e, o) {
|
|
92
|
+
return { ...n, edges: { ...n.edges, [e]: o } };
|
|
93
|
+
}
|
|
94
|
+
function St(n, e) {
|
|
95
|
+
if (n.nodes[e.id])
|
|
96
|
+
throw new ge(`Node id "${e.id}" already exists`);
|
|
97
|
+
return { ...n, nodes: { ...n.nodes, [e.id]: e } };
|
|
98
|
+
}
|
|
99
|
+
function Mt(n, e, o) {
|
|
100
|
+
const t = Ne(n, e);
|
|
101
|
+
return Le(n, e, { ...t, position: o });
|
|
102
|
+
}
|
|
103
|
+
function Nt(n, e) {
|
|
104
|
+
Ne(n, e);
|
|
105
|
+
const { [e]: o, ...t } = n.nodes, s = {};
|
|
106
|
+
for (const [r, i] of Object.entries(n.edges))
|
|
107
|
+
i.source.nodeId !== e && i.target.nodeId !== e && (s[r] = i);
|
|
108
|
+
return { ...n, nodes: t, edges: s };
|
|
109
|
+
}
|
|
110
|
+
function Dt(n, e, o) {
|
|
111
|
+
const t = Ne(n, e);
|
|
112
|
+
return Le(n, e, { ...t, ...o, id: t.id });
|
|
113
|
+
}
|
|
114
|
+
function At(n, e, o, t) {
|
|
115
|
+
const s = Ne(n, e), r = Re(s.payload, o, t);
|
|
116
|
+
return Le(n, e, { ...s, payload: r });
|
|
117
|
+
}
|
|
118
|
+
function _t(n, e, o, t) {
|
|
119
|
+
const s = Ne(n, e), r = Re(s.extensions, o, t);
|
|
120
|
+
return Le(n, e, { ...s, extensions: r });
|
|
121
|
+
}
|
|
122
|
+
function Pt(n, e) {
|
|
123
|
+
if (n.edges[e.id])
|
|
124
|
+
throw new ge(`Edge id "${e.id}" already exists`);
|
|
125
|
+
if (ke(n, e.source, "Source"), ke(n, e.target, "Target"), e.labels) {
|
|
126
126
|
const o = /* @__PURE__ */ new Set();
|
|
127
127
|
for (const t of e.labels) {
|
|
128
128
|
if (o.has(t.id))
|
|
129
|
-
throw new
|
|
129
|
+
throw new ge(`Duplicate label id "${t.id}" in edge "${e.id}"`);
|
|
130
130
|
o.add(t.id);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
return { ...
|
|
133
|
+
return { ...n, edges: { ...n.edges, [e.id]: e } };
|
|
134
134
|
}
|
|
135
|
-
function Tt(
|
|
136
|
-
De(
|
|
137
|
-
const { [e]: o, ...t } =
|
|
138
|
-
return { ...
|
|
135
|
+
function Tt(n, e) {
|
|
136
|
+
De(n, e);
|
|
137
|
+
const { [e]: o, ...t } = n.edges;
|
|
138
|
+
return { ...n, edges: t };
|
|
139
139
|
}
|
|
140
|
-
function Rt(
|
|
141
|
-
const
|
|
142
|
-
return ke(
|
|
140
|
+
function Rt(n, e, o, t) {
|
|
141
|
+
const s = De(n, e), r = o ?? s.source, i = t ?? s.target;
|
|
142
|
+
return ke(n, r, "Source"), ke(n, i, "Target"), Oe(n, e, { ...s, source: r, target: i });
|
|
143
143
|
}
|
|
144
|
-
function Lt(
|
|
145
|
-
const t = De(
|
|
146
|
-
return o.source && ke(
|
|
144
|
+
function Lt(n, e, o) {
|
|
145
|
+
const t = De(n, e), s = { ...t, ...o, id: t.id };
|
|
146
|
+
return o.source && ke(n, s.source, "Source"), o.target && ke(n, s.target, "Target"), Oe(n, e, s);
|
|
147
147
|
}
|
|
148
|
-
function Ot(
|
|
149
|
-
const
|
|
150
|
-
return Oe(
|
|
148
|
+
function Ot(n, e, o, t) {
|
|
149
|
+
const s = De(n, e), r = Re(s.payload, o, t);
|
|
150
|
+
return Oe(n, e, { ...s, payload: r });
|
|
151
151
|
}
|
|
152
|
-
function $t(
|
|
153
|
-
const
|
|
154
|
-
if (!
|
|
155
|
-
throw new
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
throw new
|
|
159
|
-
const
|
|
160
|
-
return r
|
|
152
|
+
function $t(n, e, o, t) {
|
|
153
|
+
const s = De(n, e);
|
|
154
|
+
if (!s.labels)
|
|
155
|
+
throw new ge(`Edge "${e}" has no labels`);
|
|
156
|
+
const r = s.labels.findIndex((l) => l.id === o);
|
|
157
|
+
if (r === -1)
|
|
158
|
+
throw new ge(`Label "${o}" not found in edge "${e}"`);
|
|
159
|
+
const i = [...s.labels];
|
|
160
|
+
return i[r] = { ...i[r], ...t, id: o }, Oe(n, e, { ...s, labels: i });
|
|
161
161
|
}
|
|
162
|
-
function Bt(
|
|
163
|
-
const t = Re(
|
|
164
|
-
return { ...
|
|
162
|
+
function Bt(n, e, o) {
|
|
163
|
+
const t = Re(n.meta, e, o);
|
|
164
|
+
return { ...n, meta: t };
|
|
165
165
|
}
|
|
166
|
-
function Ft(
|
|
167
|
-
const o = e?.maxHistorySize ?? 100, t = H(
|
|
166
|
+
function Ft(n, e) {
|
|
167
|
+
const o = e?.maxHistorySize ?? 100, t = H(n), s = [], r = [], i = H(!1), l = H(!1);
|
|
168
168
|
function a() {
|
|
169
|
-
|
|
169
|
+
i.value = s.length > 0, l.value = r.length > 0;
|
|
170
170
|
}
|
|
171
171
|
function h(b) {
|
|
172
172
|
const S = t.value;
|
|
@@ -177,27 +177,27 @@ function Ft(s, e) {
|
|
|
177
177
|
const B = e?.excludeCommandFromHistory, j = B ? b.commands.filter((k) => !B(k)) : b.commands;
|
|
178
178
|
if (j.length > 0) {
|
|
179
179
|
const k = j.length < b.commands.length ? { ...b, commands: j } : b;
|
|
180
|
-
|
|
180
|
+
s.push({ snapshot: S, envelope: k }), s.length > o && s.shift(), r.length = 0;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
return t.value = M, a(), M;
|
|
184
184
|
}
|
|
185
185
|
function f() {
|
|
186
|
-
const b =
|
|
186
|
+
const b = s.pop();
|
|
187
187
|
if (!b) return null;
|
|
188
|
-
|
|
188
|
+
r.push({ snapshot: t.value, envelope: b.envelope });
|
|
189
189
|
const S = e?.preserveMetaOnUndoRedo ? { ...b.snapshot, meta: t.value.meta } : b.snapshot;
|
|
190
190
|
return t.value = S, a(), S;
|
|
191
191
|
}
|
|
192
192
|
function p() {
|
|
193
|
-
const b =
|
|
193
|
+
const b = r.pop();
|
|
194
194
|
if (!b) return null;
|
|
195
|
-
|
|
195
|
+
s.push({ snapshot: t.value, envelope: b.envelope });
|
|
196
196
|
const S = e?.preserveMetaOnUndoRedo ? { ...b.snapshot, meta: t.value.meta } : b.snapshot;
|
|
197
197
|
return t.value = S, a(), S;
|
|
198
198
|
}
|
|
199
199
|
function u() {
|
|
200
|
-
|
|
200
|
+
s.length = 0, r.length = 0, a();
|
|
201
201
|
}
|
|
202
202
|
function w() {
|
|
203
203
|
return t.value;
|
|
@@ -213,20 +213,20 @@ function Ft(s, e) {
|
|
|
213
213
|
timestamp: Date.now(),
|
|
214
214
|
commands: []
|
|
215
215
|
};
|
|
216
|
-
|
|
216
|
+
s.push({ snapshot: t.value, envelope: M }), s.length > o && s.shift(), r.length = 0, t.value = b, a();
|
|
217
217
|
}
|
|
218
218
|
return {
|
|
219
219
|
currentFlowModel: t,
|
|
220
220
|
execute: h,
|
|
221
221
|
undo: f,
|
|
222
222
|
redo: p,
|
|
223
|
-
canUndo:
|
|
223
|
+
canUndo: i,
|
|
224
224
|
canRedo: l,
|
|
225
225
|
get undoStack() {
|
|
226
|
-
return
|
|
226
|
+
return s.map((b) => b.envelope);
|
|
227
227
|
},
|
|
228
228
|
get redoStack() {
|
|
229
|
-
return
|
|
229
|
+
return r.map((b) => b.envelope);
|
|
230
230
|
},
|
|
231
231
|
clear: u,
|
|
232
232
|
createSnapshot: w,
|
|
@@ -234,8 +234,8 @@ function Ft(s, e) {
|
|
|
234
234
|
updateFlowModel: O
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
|
-
function qt(
|
|
238
|
-
return
|
|
237
|
+
function qt(n) {
|
|
238
|
+
return n !== null && typeof n == "object" && n.rejected === !0;
|
|
239
239
|
}
|
|
240
240
|
class Ht {
|
|
241
241
|
plugins = [];
|
|
@@ -244,7 +244,7 @@ class Ht {
|
|
|
244
244
|
/** 每次 attachRuntime 递增,detachRuntime 时旧 generation 的异步调用自动作废 */
|
|
245
245
|
runtimeVersion = 0;
|
|
246
246
|
install(e, o) {
|
|
247
|
-
this.plugins = [...e].sort((t,
|
|
247
|
+
this.plugins = [...e].sort((t, s) => (t.priority ?? 100) - (s.priority ?? 100)), this.editorContext = o;
|
|
248
248
|
for (const t of this.plugins)
|
|
249
249
|
t.install?.(o);
|
|
250
250
|
}
|
|
@@ -257,8 +257,8 @@ class Ht {
|
|
|
257
257
|
const o = ++this.runtimeVersion;
|
|
258
258
|
this.runtimeCtx = e;
|
|
259
259
|
const t = this.createSafeRuntimeContext(e, o);
|
|
260
|
-
for (const
|
|
261
|
-
|
|
260
|
+
for (const s of this.plugins)
|
|
261
|
+
s.attachRuntime?.(t);
|
|
262
262
|
}
|
|
263
263
|
/** 按安装的逆序 detach,保证后安装的插件先释放运行时资源 */
|
|
264
264
|
detachRuntime() {
|
|
@@ -271,16 +271,16 @@ class Ht {
|
|
|
271
271
|
* 如果在 await 期间 detachRuntime 已执行,代理会将 graph 操作变为 no-op。
|
|
272
272
|
*/
|
|
273
273
|
createSafeRuntimeContext(e, o) {
|
|
274
|
-
const t = this,
|
|
275
|
-
get(
|
|
276
|
-
const a = Reflect.get(
|
|
277
|
-
return
|
|
274
|
+
const t = this, s = new Proxy(e.graph, {
|
|
275
|
+
get(r, i, l) {
|
|
276
|
+
const a = Reflect.get(r, i, l);
|
|
277
|
+
return i === "use" && typeof a == "function" ? function(...f) {
|
|
278
278
|
if (t.runtimeVersion === o)
|
|
279
|
-
return a.apply(
|
|
279
|
+
return a.apply(r, f);
|
|
280
280
|
} : a;
|
|
281
281
|
}
|
|
282
282
|
});
|
|
283
|
-
return { ...e, graph:
|
|
283
|
+
return { ...e, graph: s };
|
|
284
284
|
}
|
|
285
285
|
dispose() {
|
|
286
286
|
for (const e of [...this.plugins].reverse())
|
|
@@ -292,8 +292,8 @@ class Ht {
|
|
|
292
292
|
let o = e;
|
|
293
293
|
for (const t of this.plugins) {
|
|
294
294
|
if (!t.transformCommand) continue;
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
295
|
+
const s = this.createPreview(o), r = t.transformCommand(o, s, this.editorContext);
|
|
296
|
+
if (r === null)
|
|
297
297
|
return {
|
|
298
298
|
rejected: !0,
|
|
299
299
|
error: {
|
|
@@ -302,23 +302,23 @@ class Ht {
|
|
|
302
302
|
source: t.name
|
|
303
303
|
}
|
|
304
304
|
};
|
|
305
|
-
if (qt(
|
|
305
|
+
if (qt(r))
|
|
306
306
|
return {
|
|
307
307
|
rejected: !0,
|
|
308
308
|
error: {
|
|
309
|
-
code:
|
|
310
|
-
reason:
|
|
309
|
+
code: r.code ?? "plugin_rejected",
|
|
310
|
+
reason: r.reason,
|
|
311
311
|
source: t.name
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
|
-
o =
|
|
314
|
+
o = r;
|
|
315
315
|
}
|
|
316
316
|
return { envelope: o };
|
|
317
317
|
}
|
|
318
318
|
afterCommand(e, o, t) {
|
|
319
319
|
if (this.editorContext)
|
|
320
|
-
for (const
|
|
321
|
-
|
|
320
|
+
for (const s of this.plugins)
|
|
321
|
+
s.afterCommand?.(e, o, t, this.editorContext);
|
|
322
322
|
}
|
|
323
323
|
dispatchUiEvent(e) {
|
|
324
324
|
if (this.runtimeCtx)
|
|
@@ -341,8 +341,8 @@ class Ht {
|
|
|
341
341
|
if (!this.runtimeCtx) return [];
|
|
342
342
|
const o = [];
|
|
343
343
|
for (const t of this.plugins) {
|
|
344
|
-
const
|
|
345
|
-
|
|
344
|
+
const s = t.onBlankContextMenu?.(e, this.runtimeCtx);
|
|
345
|
+
s && o.push(...s);
|
|
346
346
|
}
|
|
347
347
|
return o;
|
|
348
348
|
}
|
|
@@ -353,8 +353,8 @@ class Ht {
|
|
|
353
353
|
for (const o of this.plugins) {
|
|
354
354
|
const t = o.provideToolbarItems?.(this.editorContext);
|
|
355
355
|
if (t)
|
|
356
|
-
for (const
|
|
357
|
-
e.set(
|
|
356
|
+
for (const s of t)
|
|
357
|
+
e.set(s.id, s);
|
|
358
358
|
}
|
|
359
359
|
return [...e.values()].sort((o, t) => (o.order ?? 0) - (t.order ?? 0));
|
|
360
360
|
}
|
|
@@ -363,8 +363,8 @@ class Ht {
|
|
|
363
363
|
if (!this.editorContext) return;
|
|
364
364
|
let o;
|
|
365
365
|
for (const t of this.plugins) {
|
|
366
|
-
const
|
|
367
|
-
|
|
366
|
+
const s = t.decorateNode?.(e, this.editorContext);
|
|
367
|
+
s && (o = o ? { ...o, ...s } : s);
|
|
368
368
|
}
|
|
369
369
|
return o;
|
|
370
370
|
}
|
|
@@ -373,8 +373,8 @@ class Ht {
|
|
|
373
373
|
if (!this.editorContext) return;
|
|
374
374
|
let o;
|
|
375
375
|
for (const t of this.plugins) {
|
|
376
|
-
const
|
|
377
|
-
|
|
376
|
+
const s = t.decorateEdge?.(e, this.editorContext);
|
|
377
|
+
s && (o = o ? { ...o, ...s } : s);
|
|
378
378
|
}
|
|
379
379
|
return o;
|
|
380
380
|
}
|
|
@@ -392,23 +392,23 @@ class Ht {
|
|
|
392
392
|
const o = this.editorContext;
|
|
393
393
|
return {
|
|
394
394
|
previewFlowModel(t) {
|
|
395
|
-
const
|
|
396
|
-
let
|
|
397
|
-
for (const
|
|
398
|
-
|
|
399
|
-
return
|
|
395
|
+
const s = t ?? e.commands;
|
|
396
|
+
let r = o.flowModel.value;
|
|
397
|
+
for (const i of s)
|
|
398
|
+
r = ct(r, i);
|
|
399
|
+
return r;
|
|
400
400
|
}
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
let Gt = 0;
|
|
405
|
-
function
|
|
406
|
-
const
|
|
407
|
-
return `${
|
|
405
|
+
function ee() {
|
|
406
|
+
const n = Date.now().toString(36), e = Math.random().toString(36).substring(2, 8);
|
|
407
|
+
return `${n}-${e}-${++Gt}`;
|
|
408
408
|
}
|
|
409
|
-
const ze = () =>
|
|
410
|
-
function Nn(
|
|
411
|
-
const { schema: e, plugins: o = [], historyOptions: t } =
|
|
409
|
+
const ze = () => ee();
|
|
410
|
+
function Nn(n) {
|
|
411
|
+
const { schema: e, plugins: o = [], historyOptions: t } = n, s = n.idGenerator ?? ze, r = { version: "1.0", ...n.initialFlowModel }, i = Ft(r, t), l = H(n.mode ?? "edit"), a = H(!1), h = H(null), f = H([]), p = {}, u = new Ht();
|
|
412
412
|
function w(S, M, B, j = "user:toolbar") {
|
|
413
413
|
const k = {
|
|
414
414
|
id: `history-${Date.now()}`,
|
|
@@ -417,11 +417,11 @@ function Nn(s) {
|
|
|
417
417
|
timestamp: Date.now(),
|
|
418
418
|
commands: []
|
|
419
419
|
};
|
|
420
|
-
u.afterCommand(k, M, B), f.value = u.collectToolbarItems(),
|
|
420
|
+
u.afterCommand(k, M, B), f.value = u.collectToolbarItems(), n.onCommandResult?.({
|
|
421
421
|
status: "applied",
|
|
422
422
|
envelope: k,
|
|
423
423
|
flowModel: B
|
|
424
|
-
}),
|
|
424
|
+
}), n.onFlowModelChange?.({
|
|
425
425
|
flowModel: B,
|
|
426
426
|
prevFlowModel: M,
|
|
427
427
|
envelope: k,
|
|
@@ -429,43 +429,43 @@ function Nn(s) {
|
|
|
429
429
|
});
|
|
430
430
|
}
|
|
431
431
|
const D = {
|
|
432
|
-
execute:
|
|
432
|
+
execute: i.execute,
|
|
433
433
|
undo() {
|
|
434
|
-
const S =
|
|
434
|
+
const S = i.currentFlowModel.value, M = i.undo();
|
|
435
435
|
return M && w("撤销", S, M), M;
|
|
436
436
|
},
|
|
437
437
|
redo() {
|
|
438
|
-
const S =
|
|
438
|
+
const S = i.currentFlowModel.value, M = i.redo();
|
|
439
439
|
return M && w("重做", S, M), M;
|
|
440
440
|
},
|
|
441
441
|
get canUndo() {
|
|
442
|
-
return
|
|
442
|
+
return i.canUndo;
|
|
443
443
|
},
|
|
444
444
|
get canRedo() {
|
|
445
|
-
return
|
|
445
|
+
return i.canRedo;
|
|
446
446
|
},
|
|
447
447
|
get undoStack() {
|
|
448
|
-
return
|
|
448
|
+
return i.undoStack;
|
|
449
449
|
},
|
|
450
450
|
get redoStack() {
|
|
451
|
-
return
|
|
451
|
+
return i.redoStack;
|
|
452
452
|
},
|
|
453
|
-
clear:
|
|
454
|
-
createSnapshot:
|
|
453
|
+
clear: i.clear,
|
|
454
|
+
createSnapshot: i.createSnapshot,
|
|
455
455
|
replaceFlowModel(S) {
|
|
456
|
-
const M =
|
|
457
|
-
|
|
456
|
+
const M = i.currentFlowModel.value;
|
|
457
|
+
i.replaceFlowModel(S), w("替换 FlowModel", M, S, "system:replace");
|
|
458
458
|
},
|
|
459
459
|
updateFlowModel(S, M) {
|
|
460
|
-
const B =
|
|
461
|
-
|
|
460
|
+
const B = i.currentFlowModel.value;
|
|
461
|
+
i.updateFlowModel(S, M), w(M ?? "更新 FlowModel", B, S, "system:update");
|
|
462
462
|
}
|
|
463
463
|
}, O = {
|
|
464
|
-
flowModel: V(() =>
|
|
464
|
+
flowModel: V(() => i.currentFlowModel.value),
|
|
465
465
|
history: D,
|
|
466
466
|
schema: e,
|
|
467
467
|
mode: l,
|
|
468
|
-
idGenerator:
|
|
468
|
+
idGenerator: s,
|
|
469
469
|
executeCommand: b,
|
|
470
470
|
replaceFlowModel(S) {
|
|
471
471
|
D.replaceFlowModel(S);
|
|
@@ -493,9 +493,9 @@ function Nn(s) {
|
|
|
493
493
|
history: D,
|
|
494
494
|
schema: e,
|
|
495
495
|
mode: l,
|
|
496
|
-
idGenerator:
|
|
496
|
+
idGenerator: s,
|
|
497
497
|
executeCommand: b
|
|
498
|
-
}), f.value = u.collectToolbarItems(),
|
|
498
|
+
}), f.value = u.collectToolbarItems(), it(() => {
|
|
499
499
|
u.dispose();
|
|
500
500
|
});
|
|
501
501
|
function b(S) {
|
|
@@ -506,23 +506,23 @@ function Nn(s) {
|
|
|
506
506
|
envelope: S,
|
|
507
507
|
error: M.error
|
|
508
508
|
};
|
|
509
|
-
return
|
|
509
|
+
return n.onCommandResult?.(k), k;
|
|
510
510
|
}
|
|
511
|
-
const B = M.envelope, j =
|
|
511
|
+
const B = M.envelope, j = i.currentFlowModel.value;
|
|
512
512
|
try {
|
|
513
|
-
const k =
|
|
513
|
+
const k = i.execute(B), X = {
|
|
514
514
|
status: "applied",
|
|
515
515
|
envelope: B,
|
|
516
516
|
flowModel: k
|
|
517
517
|
};
|
|
518
|
-
return u.afterCommand(B, j, k), f.value = u.collectToolbarItems(),
|
|
518
|
+
return u.afterCommand(B, j, k), f.value = u.collectToolbarItems(), n.onCommandResult?.(X), n.onFlowModelChange?.({
|
|
519
519
|
flowModel: k,
|
|
520
520
|
prevFlowModel: j,
|
|
521
521
|
envelope: B,
|
|
522
522
|
source: B.source
|
|
523
523
|
}), X;
|
|
524
524
|
} catch (k) {
|
|
525
|
-
if (k instanceof
|
|
525
|
+
if (k instanceof ge) {
|
|
526
526
|
const X = {
|
|
527
527
|
status: "invalid",
|
|
528
528
|
envelope: B,
|
|
@@ -532,7 +532,7 @@ function Nn(s) {
|
|
|
532
532
|
source: "engine"
|
|
533
533
|
}
|
|
534
534
|
};
|
|
535
|
-
return
|
|
535
|
+
return n.onCommandResult?.(X), X;
|
|
536
536
|
}
|
|
537
537
|
throw k;
|
|
538
538
|
}
|
|
@@ -541,10 +541,10 @@ function Nn(s) {
|
|
|
541
541
|
}
|
|
542
542
|
const zt = ["top", "right", "bottom", "left"];
|
|
543
543
|
function ut() {
|
|
544
|
-
return zt.map((
|
|
544
|
+
return zt.map((n) => ({ id: n, group: n }));
|
|
545
545
|
}
|
|
546
|
-
function Ue(
|
|
547
|
-
return e?.(
|
|
546
|
+
function Ue(n, e) {
|
|
547
|
+
return e?.(n) ?? n.ports ?? ut();
|
|
548
548
|
}
|
|
549
549
|
const Fe = -1, Ut = "flow-canvas-node-ring-target", We = "flow-canvas-node-ring-target--decorated", Ve = "flow-canvas-node-ring-target--pulse", jt = "linear-gradient(135deg, #cadcfa 0%, #cee0ff 100%)";
|
|
550
550
|
class Wt {
|
|
@@ -574,8 +574,8 @@ class Wt {
|
|
|
574
574
|
edgeDefaultAttrs = /* @__PURE__ */ new Map();
|
|
575
575
|
lastModel = null;
|
|
576
576
|
pendingDecorationRAFs = /* @__PURE__ */ new Map();
|
|
577
|
-
constructor(e, o, t,
|
|
578
|
-
this.graph = e, this.schema = o, this.shapeRegistry = t, this.resolveNodeDecoration =
|
|
577
|
+
constructor(e, o, t, s, r, i) {
|
|
578
|
+
this.graph = e, this.schema = o, this.shapeRegistry = t, this.resolveNodeDecoration = s, this.resolveEdgeDecoration = r, this.resolveCanvasContext = i;
|
|
579
579
|
}
|
|
580
580
|
syncFlowModel(e) {
|
|
581
581
|
if (!this.syncing) {
|
|
@@ -596,21 +596,21 @@ class Wt {
|
|
|
596
596
|
* 仅在节点首次创建时调用一次。
|
|
597
597
|
*/
|
|
598
598
|
saveNodeDefaultAttrs(e, o) {
|
|
599
|
-
const
|
|
600
|
-
if (!
|
|
601
|
-
const
|
|
602
|
-
let
|
|
603
|
-
|
|
599
|
+
const s = o.x6CellConfig?.attrs?.body;
|
|
600
|
+
if (!s) return;
|
|
601
|
+
const r = {};
|
|
602
|
+
let i = !1;
|
|
603
|
+
s.stroke !== void 0 && (r.stroke = s.stroke, i = !0), s.strokeWidth !== void 0 && (r.strokeWidth = s.strokeWidth, i = !0), i && this.nodeDefaultAttrs.set(e, r);
|
|
604
604
|
}
|
|
605
605
|
/**
|
|
606
606
|
* 从 x6EdgeConfig.attrs.line 中提取基线描边,用于管理层清理时恢复。
|
|
607
607
|
*/
|
|
608
608
|
saveEdgeDefaultAttrs(e, o) {
|
|
609
|
-
const
|
|
610
|
-
if (!
|
|
611
|
-
const
|
|
612
|
-
let
|
|
613
|
-
|
|
609
|
+
const s = o?.x6EdgeConfig?.attrs?.line;
|
|
610
|
+
if (!s) return;
|
|
611
|
+
const r = {};
|
|
612
|
+
let i = !1;
|
|
613
|
+
s.stroke !== void 0 && (r.stroke = s.stroke, i = !0), s.strokeWidth !== void 0 && (r.strokeWidth = s.strokeWidth, i = !0), s.strokeDasharray !== void 0 && (r.strokeDasharray = s.strokeDasharray, i = !0), i && this.edgeDefaultAttrs.set(e, r);
|
|
614
614
|
}
|
|
615
615
|
/**
|
|
616
616
|
* 恢复节点 attr 到基线值;无基线时设为安全默认值。
|
|
@@ -619,18 +619,18 @@ class Wt {
|
|
|
619
619
|
* 使得内部 Vue 组件 (width/height: 100%) 折叠后无法恢复。
|
|
620
620
|
*/
|
|
621
621
|
restoreNodeAttr(e, o, t) {
|
|
622
|
-
const
|
|
623
|
-
if (
|
|
624
|
-
e.setAttrByPath(o,
|
|
622
|
+
const s = this.nodeDefaultAttrs.get(e.id)?.[t];
|
|
623
|
+
if (s !== void 0)
|
|
624
|
+
e.setAttrByPath(o, s);
|
|
625
625
|
else {
|
|
626
|
-
const
|
|
627
|
-
e.setAttrByPath(o,
|
|
626
|
+
const r = t === "stroke" ? "none" : 0;
|
|
627
|
+
e.setAttrByPath(o, r);
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
/** 恢复边 attr 到基线值;无基线时移除。 */
|
|
631
631
|
restoreEdgeAttr(e, o, t) {
|
|
632
|
-
const
|
|
633
|
-
|
|
632
|
+
const s = this.edgeDefaultAttrs.get(e.id)?.[t];
|
|
633
|
+
s !== void 0 ? this.setEdgeAttrIfChanged(e, o, s) : e.attr(o) !== void 0 && e.removeAttrByPath(o);
|
|
634
634
|
}
|
|
635
635
|
/**
|
|
636
636
|
* 仅在值实际变化时调用 setAttrByPath。
|
|
@@ -638,32 +638,32 @@ class Wt {
|
|
|
638
638
|
* 即使值相同也会导致 EdgeView.update() → updateConnection() → 路由器全量重算。
|
|
639
639
|
*/
|
|
640
640
|
setEdgeAttrIfChanged(e, o, t) {
|
|
641
|
-
const
|
|
642
|
-
|
|
641
|
+
const s = e.attr(o), r = typeof s == "object" && s !== null, i = typeof t == "object" && t !== null;
|
|
642
|
+
s !== t && (r && i && JSON.stringify(s) === JSON.stringify(t) || e.setAttrByPath(o, t));
|
|
643
643
|
}
|
|
644
644
|
getNodeRingTarget(e) {
|
|
645
645
|
return e ? e.querySelector(".flow-canvas-highlight-target") ?? e.querySelector(".flow-canvas-node-surface > :first-child") : null;
|
|
646
646
|
}
|
|
647
647
|
/** 让正式边接管交互式预览边时,恢复 schema 定义的端点 marker。 */
|
|
648
648
|
syncEdgeMarker(e, o, t) {
|
|
649
|
-
const
|
|
650
|
-
e.removeAttrByPath(
|
|
649
|
+
const r = o?.x6EdgeConfig?.attrs?.line?.[t], i = `line/${t}`;
|
|
650
|
+
e.removeAttrByPath(i), r !== void 0 && e.setAttrByPath(i, r);
|
|
651
651
|
}
|
|
652
652
|
getEdgeMarkerConfig(e, o) {
|
|
653
|
-
const
|
|
654
|
-
if (
|
|
655
|
-
return typeof
|
|
653
|
+
const s = e?.x6EdgeConfig?.attrs?.line?.[o];
|
|
654
|
+
if (s)
|
|
655
|
+
return typeof s == "string" ? { name: s } : { ...s };
|
|
656
656
|
}
|
|
657
|
-
applyEdgeMarkerDecoration(e, o, t,
|
|
658
|
-
if (!
|
|
657
|
+
applyEdgeMarkerDecoration(e, o, t, s) {
|
|
658
|
+
if (!s) {
|
|
659
659
|
this.prevEdgeDecorationMarkerIds.has(e.id) && (this.syncEdgeMarker(e, o, t), this.prevEdgeDecorationMarkerIds.delete(e.id));
|
|
660
660
|
return;
|
|
661
661
|
}
|
|
662
|
-
const
|
|
662
|
+
const r = this.getEdgeMarkerConfig(o, t) ?? { name: "block", width: 8, height: 8 };
|
|
663
663
|
this.setEdgeAttrIfChanged(e, `line/${t}`, {
|
|
664
|
-
...
|
|
665
|
-
stroke:
|
|
666
|
-
fill:
|
|
664
|
+
...r,
|
|
665
|
+
stroke: s,
|
|
666
|
+
fill: s
|
|
667
667
|
}), this.prevEdgeDecorationMarkerIds.add(e.id);
|
|
668
668
|
}
|
|
669
669
|
dispose() {
|
|
@@ -673,22 +673,22 @@ class Wt {
|
|
|
673
673
|
}
|
|
674
674
|
resolveNodes(e) {
|
|
675
675
|
const o = /* @__PURE__ */ new Map();
|
|
676
|
-
for (const [t,
|
|
677
|
-
const
|
|
678
|
-
if (!
|
|
676
|
+
for (const [t, s] of Object.entries(e.nodes)) {
|
|
677
|
+
const r = this.schema.nodeTypes[s.type];
|
|
678
|
+
if (!r)
|
|
679
679
|
throw new kt(
|
|
680
|
-
`Unknown node type "${
|
|
680
|
+
`Unknown node type "${s.type}" for node "${t}". Registered types: [${Object.keys(this.schema.nodeTypes).join(", ")}]. Register the type in CanvasSchema.nodeTypes before using it in a FlowModel.`
|
|
681
681
|
);
|
|
682
|
-
const
|
|
683
|
-
o.set(t, { model:
|
|
682
|
+
const i = this.shapeRegistry.registerNodeType(s.type, r.component), l = r.getSize(s), a = Ue(s, r.getPorts);
|
|
683
|
+
o.set(t, { model: s, definition: r, shapeName: i, size: l, ports: a });
|
|
684
684
|
}
|
|
685
685
|
return o;
|
|
686
686
|
}
|
|
687
687
|
resolveEdges(e) {
|
|
688
688
|
const o = /* @__PURE__ */ new Map();
|
|
689
|
-
for (const [t,
|
|
690
|
-
const
|
|
691
|
-
o.set(t, { model:
|
|
689
|
+
for (const [t, s] of Object.entries(e.edges)) {
|
|
690
|
+
const r = s.type ?? this.schema.defaultEdgeType ?? "default", i = this.schema.edgeTypes?.[r];
|
|
691
|
+
o.set(t, { model: s, definition: i });
|
|
692
692
|
}
|
|
693
693
|
return o;
|
|
694
694
|
}
|
|
@@ -696,18 +696,18 @@ class Wt {
|
|
|
696
696
|
const o = new Set(e.keys());
|
|
697
697
|
for (const t of this.knownNodeIds)
|
|
698
698
|
if (!o.has(t)) {
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
const
|
|
702
|
-
|
|
699
|
+
const s = this.graph.getCellById(t);
|
|
700
|
+
s && this.graph.removeCell(s), this.knownNodeIds.delete(t), this.defaultHighlightedNodeIds.delete(t), this.prevNodeDecorationClasses.delete(t), this.prevNodeDecorationColors.delete(t), this.nodeDefaultAttrs.delete(t);
|
|
701
|
+
const r = this.pendingDecorationRAFs.get(t);
|
|
702
|
+
r && (cancelAnimationFrame(r), this.pendingDecorationRAFs.delete(t));
|
|
703
703
|
}
|
|
704
|
-
for (const [t,
|
|
705
|
-
const
|
|
706
|
-
|
|
704
|
+
for (const [t, s] of e) {
|
|
705
|
+
const r = this.graph.getCellById(t);
|
|
706
|
+
r ? this.updateExistingNode(r, s) : this.addNewNode(t, s);
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
709
|
updateExistingNode(e, o) {
|
|
710
|
-
const { model: t, size:
|
|
710
|
+
const { model: t, size: s, ports: r, definition: i } = o;
|
|
711
711
|
if (e.getData()?.type !== t.type) {
|
|
712
712
|
this.graph.removeCell(e), this.addNewNode(e.id, o);
|
|
713
713
|
return;
|
|
@@ -715,23 +715,23 @@ class Wt {
|
|
|
715
715
|
const a = e.getPosition();
|
|
716
716
|
(a.x !== t.position.x || a.y !== t.position.y) && e.setPosition(t.position.x, t.position.y);
|
|
717
717
|
const h = e.getSize();
|
|
718
|
-
(h.width !==
|
|
718
|
+
(h.width !== s.width || h.height !== s.height) && e.setSize(s.width, s.height, { silent: !0 }), this.syncNodePorts(e, r), e.setData({ ...t }), this.applyNodeBehavior(e, t, i), this.applyNodeHighlightAndDecoration(e, t);
|
|
719
719
|
}
|
|
720
720
|
syncNodePorts(e, o) {
|
|
721
|
-
const t = e.getPorts(),
|
|
722
|
-
for (const
|
|
723
|
-
|
|
724
|
-
for (const
|
|
725
|
-
|
|
721
|
+
const t = e.getPorts(), s = new Set(o.map((i) => i.id)), r = new Set(t.map((i) => i.id));
|
|
722
|
+
for (const i of t)
|
|
723
|
+
i.id && !s.has(i.id) && e.removePort(i.id);
|
|
724
|
+
for (const i of o)
|
|
725
|
+
r.has(i.id) || e.addPort({ id: i.id, group: i.group, ...i.x6PortConfig });
|
|
726
726
|
}
|
|
727
727
|
addNewNode(e, o) {
|
|
728
|
-
const { model: t, shapeName:
|
|
728
|
+
const { model: t, shapeName: s, size: r, ports: i, definition: l } = o, a = {
|
|
729
729
|
id: t.id,
|
|
730
|
-
shape:
|
|
730
|
+
shape: s,
|
|
731
731
|
x: t.position.x,
|
|
732
732
|
y: t.position.y,
|
|
733
|
-
width:
|
|
734
|
-
height:
|
|
733
|
+
width: r.width,
|
|
734
|
+
height: r.height,
|
|
735
735
|
data: { ...t },
|
|
736
736
|
ports: {
|
|
737
737
|
groups: {
|
|
@@ -760,7 +760,7 @@ class Wt {
|
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
762
|
},
|
|
763
|
-
items:
|
|
763
|
+
items: i.map((f) => ({ id: f.id, group: f.group, ...f.x6PortConfig }))
|
|
764
764
|
},
|
|
765
765
|
...l.x6CellConfig
|
|
766
766
|
};
|
|
@@ -777,16 +777,16 @@ class Wt {
|
|
|
777
777
|
scheduleDecorationRetryIfNeeded(e) {
|
|
778
778
|
const o = this.graph.findViewByCell(e)?.container;
|
|
779
779
|
if (this.getNodeRingTarget(o)) return;
|
|
780
|
-
const t = e.id,
|
|
781
|
-
|
|
782
|
-
const
|
|
780
|
+
const t = e.id, s = this.pendingDecorationRAFs.get(t);
|
|
781
|
+
s && cancelAnimationFrame(s);
|
|
782
|
+
const r = requestAnimationFrame(() => {
|
|
783
783
|
if (this.pendingDecorationRAFs.delete(t), !this.knownNodeIds.has(t)) return;
|
|
784
|
-
const
|
|
785
|
-
if (!
|
|
784
|
+
const i = this.lastModel?.nodes[t];
|
|
785
|
+
if (!i) return;
|
|
786
786
|
const l = this.graph.getCellById(t);
|
|
787
|
-
l?.isNode() && this.applyNodeHighlightAndDecoration(l,
|
|
787
|
+
l?.isNode() && this.applyNodeHighlightAndDecoration(l, i);
|
|
788
788
|
});
|
|
789
|
-
this.pendingDecorationRAFs.set(t,
|
|
789
|
+
this.pendingDecorationRAFs.set(t, r);
|
|
790
790
|
}
|
|
791
791
|
/**
|
|
792
792
|
* 将 schema 定义的 getBehavior 映射到 X6 节点属性。
|
|
@@ -802,32 +802,32 @@ class Wt {
|
|
|
802
802
|
*/
|
|
803
803
|
applyNodeBehavior(e, o, t) {
|
|
804
804
|
if (!t.getBehavior) return;
|
|
805
|
-
const
|
|
806
|
-
if (!
|
|
807
|
-
const
|
|
808
|
-
if (
|
|
809
|
-
const l =
|
|
805
|
+
const s = this.resolveCanvasContext?.();
|
|
806
|
+
if (!s) return;
|
|
807
|
+
const r = t.getBehavior(o, s);
|
|
808
|
+
if (r.draggable !== void 0 && e.setProp("draggable", r.draggable, { silent: !0 }), r.connectable !== void 0) {
|
|
809
|
+
const l = r.connectable ? !0 : r.targetable === !1 ? !1 : "passive";
|
|
810
810
|
for (const a of e.getPorts())
|
|
811
811
|
e.setPortProp(a.id, "attrs/circle/magnet", l, { silent: !0 });
|
|
812
812
|
}
|
|
813
|
-
if (
|
|
814
|
-
const l =
|
|
813
|
+
if (r.showPorts !== void 0) {
|
|
814
|
+
const l = r.showPorts;
|
|
815
815
|
for (const a of e.getPorts())
|
|
816
816
|
e.setPortProp(a.id, "attrs/circle/visibility", l ? "visible" : "hidden", { silent: !0 });
|
|
817
817
|
}
|
|
818
|
-
const
|
|
819
|
-
|
|
818
|
+
const i = e.getData() ?? {};
|
|
819
|
+
r.deletable !== void 0 && i._deletable !== r.deletable && e.setData({ ...i, _deletable: r.deletable }, { silent: !0 }), r.selectable !== void 0 && i._selectable !== r.selectable && e.setData({ ...e.getData(), _selectable: r.selectable }, { silent: !0 });
|
|
820
820
|
}
|
|
821
821
|
syncEdges(e, o) {
|
|
822
822
|
const t = new Set(e.keys());
|
|
823
|
-
for (const
|
|
824
|
-
if (!t.has(
|
|
825
|
-
const
|
|
826
|
-
|
|
823
|
+
for (const s of this.knownEdgeIds)
|
|
824
|
+
if (!t.has(s)) {
|
|
825
|
+
const r = this.graph.getCellById(s);
|
|
826
|
+
r && this.graph.removeCell(r), this.knownEdgeIds.delete(s), this.defaultHighlightedEdgeIds.delete(s), this.prevEdgeDecorationClasses.delete(s), this.prevEdgeDecorationColors.delete(s), this.prevEdgeDecorationMarkerIds.delete(s), this.prevEdgeStyleIds.delete(s), this.edgeDefaultAttrs.delete(s);
|
|
827
827
|
}
|
|
828
|
-
for (const [
|
|
829
|
-
const
|
|
830
|
-
|
|
828
|
+
for (const [s, r] of e) {
|
|
829
|
+
const i = this.graph.getCellById(s), { model: l, definition: a } = r;
|
|
830
|
+
i ? (this.updateExistingEdge(i, l, a, o), this.knownEdgeIds.has(s) || (this.knownEdgeIds.add(s), this.saveEdgeDefaultAttrs(s, a))) : this.addNewEdge(s, l, a);
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
833
|
/**
|
|
@@ -835,8 +835,8 @@ class Wt {
|
|
|
835
835
|
* X6 Edge.getSource() 返回 { cell, port } 格式,与 FlowEdgeModel 的 { nodeId, portId } 不同,
|
|
836
836
|
* 需要用 (currentSource as any).cell 来比较。
|
|
837
837
|
*/
|
|
838
|
-
updateExistingEdge(e, o, t,
|
|
839
|
-
const
|
|
838
|
+
updateExistingEdge(e, o, t, s) {
|
|
839
|
+
const r = e.getSource(), i = e.getTarget(), l = r.cell !== o.source.nodeId || r.port !== o.source.portId, a = i.cell !== o.target.nodeId || i.port !== o.target.portId;
|
|
840
840
|
l && e.setSource({ cell: o.source.nodeId, port: o.source.portId }), a && e.setTarget({ cell: o.target.nodeId, port: o.target.portId });
|
|
841
841
|
const f = (e.getData()?.type ?? void 0) !== (o.type ?? void 0);
|
|
842
842
|
if (f) {
|
|
@@ -856,28 +856,28 @@ class Wt {
|
|
|
856
856
|
e.getLabels().length > 0 && e.setLabels([]);
|
|
857
857
|
return;
|
|
858
858
|
}
|
|
859
|
-
const t = o.labels.map((
|
|
859
|
+
const t = o.labels.map((s) => ({
|
|
860
860
|
attrs: {
|
|
861
|
-
label: { text:
|
|
861
|
+
label: { text: s.text ?? "" }
|
|
862
862
|
},
|
|
863
|
-
position:
|
|
863
|
+
position: s.position != null ? { distance: s.position } : void 0
|
|
864
864
|
}));
|
|
865
865
|
e.setLabels(t);
|
|
866
866
|
}
|
|
867
867
|
addNewEdge(e, o, t) {
|
|
868
|
-
const
|
|
868
|
+
const s = {
|
|
869
869
|
id: o.id,
|
|
870
870
|
source: { cell: o.source.nodeId, port: o.source.portId },
|
|
871
871
|
target: { cell: o.target.nodeId, port: o.target.portId },
|
|
872
872
|
data: { ...o },
|
|
873
873
|
zIndex: Fe
|
|
874
874
|
};
|
|
875
|
-
t?.router && (
|
|
876
|
-
attrs: { label: { text:
|
|
877
|
-
position:
|
|
878
|
-
}))), this.graph.addEdge(
|
|
879
|
-
const
|
|
880
|
-
|
|
875
|
+
t?.router && (s.router = typeof t.router == "string" ? { name: t.router } : t.router), t?.connector && (s.connector = typeof t.connector == "string" ? { name: t.connector } : t.connector), t?.x6EdgeConfig && Object.assign(s, t.x6EdgeConfig), o.labels?.length && (s.labels = o.labels.map((i) => ({
|
|
876
|
+
attrs: { label: { text: i.text ?? "" } },
|
|
877
|
+
position: i.position != null ? { distance: i.position } : void 0
|
|
878
|
+
}))), this.graph.addEdge(s), this.knownEdgeIds.add(e), this.saveEdgeDefaultAttrs(e, t);
|
|
879
|
+
const r = this.graph.getCellById(e);
|
|
880
|
+
r && this.applyEdgeStyleAndDecoration(r, o, t);
|
|
881
881
|
}
|
|
882
882
|
/**
|
|
883
883
|
* 重算所有边的视觉样式。
|
|
@@ -888,8 +888,8 @@ class Wt {
|
|
|
888
888
|
for (const [e, o] of Object.entries(this.lastModel.edges)) {
|
|
889
889
|
const t = this.graph.getCellById(e);
|
|
890
890
|
if (!t?.isEdge()) continue;
|
|
891
|
-
const
|
|
892
|
-
this.applyEdgeStyleAndDecoration(t, o,
|
|
891
|
+
const s = o.type ?? this.schema.defaultEdgeType ?? "default", r = this.schema.edgeTypes?.[s];
|
|
892
|
+
this.applyEdgeStyleAndDecoration(t, o, r);
|
|
893
893
|
}
|
|
894
894
|
}
|
|
895
895
|
/**
|
|
@@ -902,8 +902,8 @@ class Wt {
|
|
|
902
902
|
if (!o) return;
|
|
903
903
|
const t = this.graph.getCellById(e);
|
|
904
904
|
if (!t?.isEdge()) return;
|
|
905
|
-
const
|
|
906
|
-
this.applyEdgeStyleAndDecoration(t, o,
|
|
905
|
+
const s = o.type ?? this.schema.defaultEdgeType ?? "default", r = this.schema.edgeTypes?.[s];
|
|
906
|
+
this.applyEdgeStyleAndDecoration(t, o, r);
|
|
907
907
|
}
|
|
908
908
|
/**
|
|
909
909
|
* 重算所有节点的高亮 + 装饰视觉。
|
|
@@ -928,13 +928,13 @@ class Wt {
|
|
|
928
928
|
* body/stroke 仅作为普通 SVG shape 的兜底同步。
|
|
929
929
|
*/
|
|
930
930
|
applyNodeHighlightAndDecoration(e, o) {
|
|
931
|
-
const t = this.highlightedNodeIds.has(e.id),
|
|
932
|
-
l && (
|
|
933
|
-
const a =
|
|
934
|
-
f ? (e.setAttrByPath("body/stroke", f), e.setAttrByPath("body/strokeWidth", 2)) : p && (this.restoreNodeAttr(e, "body/stroke", "stroke"), this.restoreNodeAttr(e, "body/strokeWidth", "strokeWidth")),
|
|
931
|
+
const t = this.highlightedNodeIds.has(e.id), s = this.resolveNodeDecoration?.(o), r = this.graph.findViewByCell(e)?.container, i = this.getNodeRingTarget(r), l = this.prevNodeDecorationClasses.get(e.id);
|
|
932
|
+
l && (r?.classList.remove(l), this.prevNodeDecorationClasses.delete(e.id)), s?.className && (r?.classList.add(s.className), this.prevNodeDecorationClasses.set(e.id, s.className));
|
|
933
|
+
const a = s?.borderColor, f = a ?? (t ? "#3a84ff" : void 0), p = this.prevNodeDecorationColors.has(e.id) || this.defaultHighlightedNodeIds.has(e.id);
|
|
934
|
+
f ? (e.setAttrByPath("body/stroke", f), e.setAttrByPath("body/strokeWidth", 2)) : p && (this.restoreNodeAttr(e, "body/stroke", "stroke"), this.restoreNodeAttr(e, "body/strokeWidth", "strokeWidth")), i && (i.classList.add(Ut), a ? (i.classList.add(We), i.style.setProperty("--flow-canvas-node-decoration-ring-background", a), i.style.setProperty("--flow-canvas-node-decoration-ring-opacity", "0.95")) : (i.classList.remove(We), i.style.removeProperty("--flow-canvas-node-decoration-ring-background"), i.style.removeProperty("--flow-canvas-node-decoration-ring-opacity")), t ? (i.classList.add(Ve), i.style.setProperty(
|
|
935
935
|
"--flow-canvas-node-pulse-ring-background",
|
|
936
936
|
a ?? jt
|
|
937
|
-
),
|
|
937
|
+
), i.style.setProperty("--flow-canvas-node-pulse-ring-opacity", "0.95")) : (i.classList.remove(Ve), i.style.removeProperty("--flow-canvas-node-pulse-ring-background"), i.style.removeProperty("--flow-canvas-node-pulse-ring-opacity"))), a ? this.prevNodeDecorationColors.add(e.id) : this.prevNodeDecorationColors.delete(e.id), t && !a ? this.defaultHighlightedNodeIds.add(e.id) : this.defaultHighlightedNodeIds.delete(e.id);
|
|
938
938
|
}
|
|
939
939
|
getHoveredEdgeId() {
|
|
940
940
|
return this.hoveredEdgeId;
|
|
@@ -961,19 +961,19 @@ class Wt {
|
|
|
961
961
|
* 最终值 = decorationStroke ?? styleStroke ?? defaultHighlightStroke ?? (清除)。
|
|
962
962
|
*/
|
|
963
963
|
applyEdgeStyleAndDecoration(e, o, t) {
|
|
964
|
-
const
|
|
965
|
-
|
|
964
|
+
const s = this.highlightedEdgeIds.has(e.id), r = this.resolveEdgeDecoration?.(o), i = this.prevEdgeDecorationClasses.get(e.id);
|
|
965
|
+
i && (this.graph.findViewByCell(e)?.container?.classList.remove(i), this.prevEdgeDecorationClasses.delete(e.id)), r?.className && (this.graph.findViewByCell(e)?.container?.classList.add(r.className), this.prevEdgeDecorationClasses.set(e.id, r.className));
|
|
966
966
|
let l, a, h;
|
|
967
967
|
if (t?.style) {
|
|
968
|
-
const O = this.graph.isSelected?.(e) ?? !1, b = this.hoveredEdgeId === e.id, S = t.style(o, { selected: O, highlighted:
|
|
968
|
+
const O = this.graph.isSelected?.(e) ?? !1, b = this.hoveredEdgeId === e.id, S = t.style(o, { selected: O, highlighted: s, hovered: b });
|
|
969
969
|
l = S.stroke, a = S.strokeWidth, h = S.strokeDasharray;
|
|
970
970
|
}
|
|
971
|
-
const f = !t?.style &&
|
|
971
|
+
const f = !t?.style && s ? "#3a84ff" : void 0, p = r?.strokeColor, u = r?.targetMarkerColor, w = p ?? l ?? f, D = !!t?.style || this.prevEdgeDecorationColors.has(e.id) || this.defaultHighlightedEdgeIds.has(e.id) || this.prevEdgeStyleIds.has(e.id);
|
|
972
972
|
w ? this.setEdgeAttrIfChanged(e, "line/stroke", w) : D && this.restoreEdgeAttr(e, "line/stroke", "stroke"), this.applyEdgeMarkerDecoration(e, t, "targetMarker", u), t?.style ? (this.prevEdgeStyleIds.add(e.id), a ? this.setEdgeAttrIfChanged(e, "line/strokeWidth", a) : this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), h ? this.setEdgeAttrIfChanged(e, "line/strokeDasharray", h) : 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)), p ? this.prevEdgeDecorationColors.add(e.id) : this.prevEdgeDecorationColors.delete(e.id), f ? this.defaultHighlightedEdgeIds.add(e.id) : this.defaultHighlightedEdgeIds.delete(e.id);
|
|
973
973
|
}
|
|
974
974
|
}
|
|
975
975
|
class Vt {
|
|
976
|
-
instanceId =
|
|
976
|
+
instanceId = ee();
|
|
977
977
|
registeredShapes = /* @__PURE__ */ new Map();
|
|
978
978
|
wrappedComponents = /* @__PURE__ */ new Map();
|
|
979
979
|
getShapeName(e) {
|
|
@@ -982,15 +982,15 @@ class Vt {
|
|
|
982
982
|
}
|
|
983
983
|
registerNodeType(e, o) {
|
|
984
984
|
const t = this.getShapeName(e);
|
|
985
|
-
let
|
|
986
|
-
return
|
|
987
|
-
name: `FlowCanvasNodeShape${e.replace(/(^|[-_])(\w)/g, (
|
|
985
|
+
let s = this.wrappedComponents.get(e);
|
|
986
|
+
return s || (s = pe({
|
|
987
|
+
name: `FlowCanvasNodeShape${e.replace(/(^|[-_])(\w)/g, (r, i, l) => l.toUpperCase())}`,
|
|
988
988
|
setup() {
|
|
989
989
|
return () => qe("div", { class: "flow-canvas-node-surface" }, [qe(o)]);
|
|
990
990
|
}
|
|
991
|
-
}), this.wrappedComponents.set(e,
|
|
991
|
+
}), this.wrappedComponents.set(e, s)), xt({
|
|
992
992
|
shape: t,
|
|
993
|
-
component:
|
|
993
|
+
component: s,
|
|
994
994
|
width: 100,
|
|
995
995
|
height: 40
|
|
996
996
|
}), t;
|
|
@@ -1006,8 +1006,8 @@ class Xt {
|
|
|
1006
1006
|
flowModelRef;
|
|
1007
1007
|
idGenerator;
|
|
1008
1008
|
disposers = [];
|
|
1009
|
-
constructor(e, o, t,
|
|
1010
|
-
this.graph = e, this.onUiEvent = o, this.onCommand = t, this.flowModelRef =
|
|
1009
|
+
constructor(e, o, t, s, r) {
|
|
1010
|
+
this.graph = e, this.onUiEvent = o, this.onCommand = t, this.flowModelRef = s, this.idGenerator = r ?? ze, this.bindEvents();
|
|
1011
1011
|
}
|
|
1012
1012
|
dispose() {
|
|
1013
1013
|
for (const e of this.disposers) e();
|
|
@@ -1029,9 +1029,9 @@ class Xt {
|
|
|
1029
1029
|
position: { x: o.clientX, y: o.clientY }
|
|
1030
1030
|
});
|
|
1031
1031
|
}), this.on("edge:click", ({ edge: e, e: o }) => {
|
|
1032
|
-
const
|
|
1033
|
-
if (
|
|
1034
|
-
const
|
|
1032
|
+
const s = o.target?.closest?.(".x6-edge-label");
|
|
1033
|
+
if (s) {
|
|
1034
|
+
const i = e.getData?.()?.labels ?? [], l = s.parentElement?.querySelectorAll(".x6-edge-label"), a = l ? Array.from(l).indexOf(s) : 0, h = i[Math.max(0, a)];
|
|
1035
1035
|
this.onUiEvent({
|
|
1036
1036
|
type: "edge.label.click",
|
|
1037
1037
|
edgeId: e.id,
|
|
@@ -1051,18 +1051,18 @@ class Xt {
|
|
|
1051
1051
|
}), this.on("node:moved", ({ node: e }) => {
|
|
1052
1052
|
const o = e.getPosition();
|
|
1053
1053
|
this.onCommand({
|
|
1054
|
-
id:
|
|
1054
|
+
id: ee(),
|
|
1055
1055
|
source: "user:drag",
|
|
1056
1056
|
label: "移动节点",
|
|
1057
1057
|
timestamp: Date.now(),
|
|
1058
1058
|
commands: [{ type: "node.move", nodeId: e.id, position: { x: o.x, y: o.y } }]
|
|
1059
1059
|
});
|
|
1060
1060
|
}), this.on("edge:connected", ({ edge: e, isNew: o }) => {
|
|
1061
|
-
const t = e.getSourceCell(),
|
|
1062
|
-
if (!t || !
|
|
1063
|
-
const
|
|
1061
|
+
const t = e.getSourceCell(), s = e.getTargetCell();
|
|
1062
|
+
if (!t || !s) return;
|
|
1063
|
+
const r = e.getSourcePortId(), i = e.getTargetPortId(), l = e.id in this.flowModelRef.value.edges;
|
|
1064
1064
|
o && !l ? (this.graph.removeCell(e), this.onCommand({
|
|
1065
|
-
id:
|
|
1065
|
+
id: ee(),
|
|
1066
1066
|
source: "user:drag",
|
|
1067
1067
|
label: "连线",
|
|
1068
1068
|
timestamp: Date.now(),
|
|
@@ -1071,13 +1071,13 @@ class Xt {
|
|
|
1071
1071
|
type: "edge.add",
|
|
1072
1072
|
edge: {
|
|
1073
1073
|
id: this.idGenerator("edge"),
|
|
1074
|
-
source: { nodeId: t.id, portId:
|
|
1075
|
-
target: { nodeId:
|
|
1074
|
+
source: { nodeId: t.id, portId: r ?? void 0 },
|
|
1075
|
+
target: { nodeId: s.id, portId: i ?? void 0 }
|
|
1076
1076
|
}
|
|
1077
1077
|
}
|
|
1078
1078
|
]
|
|
1079
1079
|
})) : this.onCommand({
|
|
1080
|
-
id:
|
|
1080
|
+
id: ee(),
|
|
1081
1081
|
source: "user:drag",
|
|
1082
1082
|
label: "重连",
|
|
1083
1083
|
timestamp: Date.now(),
|
|
@@ -1085,32 +1085,32 @@ class Xt {
|
|
|
1085
1085
|
{
|
|
1086
1086
|
type: "edge.reconnect",
|
|
1087
1087
|
edgeId: e.id,
|
|
1088
|
-
source: { nodeId: t.id, portId:
|
|
1089
|
-
target: { nodeId:
|
|
1088
|
+
source: { nodeId: t.id, portId: r ?? void 0 },
|
|
1089
|
+
target: { nodeId: s.id, portId: i ?? void 0 }
|
|
1090
1090
|
}
|
|
1091
1091
|
]
|
|
1092
1092
|
});
|
|
1093
1093
|
}), this.on("edge:change:labels", ({ edge: e, current: o }) => {
|
|
1094
|
-
const
|
|
1095
|
-
if (!
|
|
1096
|
-
const
|
|
1097
|
-
for (let
|
|
1098
|
-
const l = o[
|
|
1094
|
+
const s = e.getData?.()?.labels ?? [];
|
|
1095
|
+
if (!s.length || !o?.length) return;
|
|
1096
|
+
const r = [];
|
|
1097
|
+
for (let i = 0; i < Math.min(s.length, o.length); i++) {
|
|
1098
|
+
const l = o[i], a = s[i];
|
|
1099
1099
|
if (!a?.id) continue;
|
|
1100
1100
|
const h = typeof l.position == "object" ? l.position?.distance : l.position;
|
|
1101
|
-
h != null &&
|
|
1101
|
+
h != null && r.push({
|
|
1102
1102
|
type: "edge.label.update",
|
|
1103
1103
|
edgeId: e.id,
|
|
1104
1104
|
labelId: a.id,
|
|
1105
1105
|
patch: { position: h }
|
|
1106
1106
|
});
|
|
1107
1107
|
}
|
|
1108
|
-
|
|
1109
|
-
id:
|
|
1108
|
+
r.length && this.onCommand({
|
|
1109
|
+
id: ee(),
|
|
1110
1110
|
source: "user:drag",
|
|
1111
1111
|
label: "拖动标签",
|
|
1112
1112
|
timestamp: Date.now(),
|
|
1113
|
-
commands:
|
|
1113
|
+
commands: r
|
|
1114
1114
|
});
|
|
1115
1115
|
});
|
|
1116
1116
|
}
|
|
@@ -1118,20 +1118,20 @@ class Xt {
|
|
|
1118
1118
|
this.graph.on(e, o), this.disposers.push(() => this.graph.off(e, o));
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
|
-
function Kt(
|
|
1121
|
+
function Kt(n) {
|
|
1122
1122
|
function e(t) {
|
|
1123
|
-
const
|
|
1124
|
-
if (!
|
|
1125
|
-
const
|
|
1123
|
+
const s = n.getCellById(t);
|
|
1124
|
+
if (!s || !s.isNode()) return null;
|
|
1125
|
+
const r = s, i = r.getPosition(), l = r.getSize(), a = { x: i.x, y: i.y, width: l.width, height: l.height }, h = n.localToGraph(a);
|
|
1126
1126
|
return new DOMRect(h.x, h.y, h.width, h.height);
|
|
1127
1127
|
}
|
|
1128
1128
|
function o(t) {
|
|
1129
|
-
const
|
|
1130
|
-
if (!
|
|
1131
|
-
const
|
|
1132
|
-
if (!
|
|
1133
|
-
const
|
|
1134
|
-
return new DOMRect(
|
|
1129
|
+
const s = e(t);
|
|
1130
|
+
if (!s) return null;
|
|
1131
|
+
const r = n.container;
|
|
1132
|
+
if (!r || typeof r.getBoundingClientRect != "function") return s;
|
|
1133
|
+
const i = r.getBoundingClientRect();
|
|
1134
|
+
return new DOMRect(s.x + i.left, s.y + i.top, s.width, s.height);
|
|
1135
1135
|
}
|
|
1136
1136
|
return {
|
|
1137
1137
|
getNodeScreenRect: e,
|
|
@@ -1144,64 +1144,64 @@ const Yt = Object.freeze({
|
|
|
1144
1144
|
bottom: 8,
|
|
1145
1145
|
left: 8
|
|
1146
1146
|
});
|
|
1147
|
-
function ft(
|
|
1147
|
+
function ft(n) {
|
|
1148
1148
|
return {
|
|
1149
|
-
nodeIds:
|
|
1150
|
-
edgeIds:
|
|
1149
|
+
nodeIds: n.filter((e) => e.isNode()).map((e) => e.id),
|
|
1150
|
+
edgeIds: n.filter((e) => e.isEdge()).map((e) => e.id)
|
|
1151
1151
|
};
|
|
1152
1152
|
}
|
|
1153
|
-
function Zt(
|
|
1153
|
+
function Zt(n, e = Yt) {
|
|
1154
1154
|
return new DOMRect(
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1155
|
+
n.x - e.left,
|
|
1156
|
+
n.y - e.top,
|
|
1157
|
+
n.width + e.left + e.right,
|
|
1158
|
+
n.height + e.top + e.bottom
|
|
1159
1159
|
);
|
|
1160
1160
|
}
|
|
1161
|
-
function Qt(
|
|
1161
|
+
function Qt(n, e) {
|
|
1162
1162
|
const o = [
|
|
1163
|
-
...e.nodeIds.map((
|
|
1164
|
-
...e.edgeIds.map((
|
|
1165
|
-
].filter((
|
|
1163
|
+
...e.nodeIds.map((r) => n.getCellById(r)),
|
|
1164
|
+
...e.edgeIds.map((r) => n.getCellById(r))
|
|
1165
|
+
].filter((r) => !!r);
|
|
1166
1166
|
if (o.length === 0) return null;
|
|
1167
|
-
const t =
|
|
1167
|
+
const t = n.getCellsBBox(o);
|
|
1168
1168
|
if (!t) return null;
|
|
1169
|
-
const
|
|
1170
|
-
return Zt(
|
|
1169
|
+
const s = n.localToGraph(t);
|
|
1170
|
+
return Zt(s);
|
|
1171
1171
|
}
|
|
1172
|
-
function gt(
|
|
1173
|
-
const t =
|
|
1174
|
-
const l = e.nodes[
|
|
1172
|
+
function gt(n, e, o) {
|
|
1173
|
+
const t = n.nodeIds.filter((i) => {
|
|
1174
|
+
const l = e.nodes[i];
|
|
1175
1175
|
if (!l) return !1;
|
|
1176
1176
|
const a = o(l);
|
|
1177
1177
|
return a.deletable !== !1 && a.deleteDisabled !== !0;
|
|
1178
|
-
}),
|
|
1179
|
-
const l = e.edges[
|
|
1180
|
-
return l ? !
|
|
1178
|
+
}), s = new Set(t), r = n.edgeIds.filter((i) => {
|
|
1179
|
+
const l = e.edges[i];
|
|
1180
|
+
return l ? !s.has(l.source.nodeId) && !s.has(l.target.nodeId) : !1;
|
|
1181
1181
|
});
|
|
1182
|
-
return { nodeIds: t, edgeIds:
|
|
1182
|
+
return { nodeIds: t, edgeIds: r };
|
|
1183
1183
|
}
|
|
1184
|
-
function Jt(
|
|
1184
|
+
function Jt(n) {
|
|
1185
1185
|
return [
|
|
1186
|
-
...
|
|
1187
|
-
...
|
|
1186
|
+
...n.edgeIds.map((e) => ({ type: "edge.remove", edgeId: e })),
|
|
1187
|
+
...n.nodeIds.map((e) => ({ type: "node.remove", nodeId: e }))
|
|
1188
1188
|
];
|
|
1189
1189
|
}
|
|
1190
1190
|
const eo = 100;
|
|
1191
1191
|
function to({
|
|
1192
|
-
graph:
|
|
1192
|
+
graph: n,
|
|
1193
1193
|
overlayManager: e,
|
|
1194
1194
|
executeCommand: o,
|
|
1195
1195
|
schema: t,
|
|
1196
|
-
flowModel:
|
|
1197
|
-
getNodeBehavior:
|
|
1198
|
-
idGenerator:
|
|
1196
|
+
flowModel: s,
|
|
1197
|
+
getNodeBehavior: r,
|
|
1198
|
+
idGenerator: i,
|
|
1199
1199
|
defaultInsertGap: l,
|
|
1200
1200
|
getContextMenuItems: a,
|
|
1201
1201
|
onHighlightChange: h,
|
|
1202
1202
|
resolveNodeShape: f
|
|
1203
1203
|
}) {
|
|
1204
|
-
const p =
|
|
1204
|
+
const p = i ?? ze;
|
|
1205
1205
|
let u = [], w = [], D = null, O = !1, b = null;
|
|
1206
1206
|
async function S() {
|
|
1207
1207
|
if (O) return D;
|
|
@@ -1209,7 +1209,7 @@ function to({
|
|
|
1209
1209
|
try {
|
|
1210
1210
|
const d = await import("@antv/x6-plugin-dnd"), y = d.Dnd ?? d.default;
|
|
1211
1211
|
return y ? (D = new y({
|
|
1212
|
-
target:
|
|
1212
|
+
target: n,
|
|
1213
1213
|
scaled: !0,
|
|
1214
1214
|
animation: !0,
|
|
1215
1215
|
getDragNode: (c) => c.clone(),
|
|
@@ -1229,10 +1229,10 @@ function to({
|
|
|
1229
1229
|
if (!y?._dndSessionId || y._dndSessionId !== b) return;
|
|
1230
1230
|
b = null;
|
|
1231
1231
|
const c = d.getPosition();
|
|
1232
|
-
|
|
1232
|
+
n.removeNode(d.id);
|
|
1233
1233
|
const { _dndSessionId: g, ...v } = y, m = v.id || p("node");
|
|
1234
1234
|
o({
|
|
1235
|
-
id:
|
|
1235
|
+
id: ee(),
|
|
1236
1236
|
source: "user:drag",
|
|
1237
1237
|
label: "拖入节点",
|
|
1238
1238
|
timestamp: Date.now(),
|
|
@@ -1244,13 +1244,13 @@ function to({
|
|
|
1244
1244
|
]
|
|
1245
1245
|
});
|
|
1246
1246
|
};
|
|
1247
|
-
|
|
1247
|
+
n.on("node:added", B);
|
|
1248
1248
|
function j(d) {
|
|
1249
1249
|
const y = t.nodeTypes[d.type];
|
|
1250
1250
|
return Ue(d, y?.getPorts);
|
|
1251
1251
|
}
|
|
1252
1252
|
function k(d) {
|
|
1253
|
-
return d ?? ft(
|
|
1253
|
+
return d ?? ft(n.getSelectedCells?.() ?? []);
|
|
1254
1254
|
}
|
|
1255
1255
|
function X(d, y, c, g, v) {
|
|
1256
1256
|
switch (d) {
|
|
@@ -1290,53 +1290,53 @@ function to({
|
|
|
1290
1290
|
}
|
|
1291
1291
|
const G = {
|
|
1292
1292
|
zoomIn() {
|
|
1293
|
-
|
|
1293
|
+
n.zoom(0.1);
|
|
1294
1294
|
},
|
|
1295
1295
|
zoomOut() {
|
|
1296
|
-
|
|
1296
|
+
n.zoom(-0.1);
|
|
1297
1297
|
},
|
|
1298
1298
|
zoomTo(d) {
|
|
1299
|
-
|
|
1299
|
+
n.zoomTo(d);
|
|
1300
1300
|
},
|
|
1301
1301
|
zoomToFit(d) {
|
|
1302
|
-
|
|
1302
|
+
n.zoomToFit({ padding: 40, maxScale: 1, ...d });
|
|
1303
1303
|
},
|
|
1304
1304
|
getZoom() {
|
|
1305
|
-
return
|
|
1305
|
+
return n.zoom();
|
|
1306
1306
|
},
|
|
1307
1307
|
centerContent() {
|
|
1308
|
-
|
|
1308
|
+
n.centerContent();
|
|
1309
1309
|
},
|
|
1310
1310
|
scrollToOrigin() {
|
|
1311
|
-
|
|
1311
|
+
n.translate(0, 0);
|
|
1312
1312
|
},
|
|
1313
1313
|
scrollToNode(d) {
|
|
1314
|
-
const y =
|
|
1315
|
-
y &&
|
|
1314
|
+
const y = n.getCellById(d);
|
|
1315
|
+
y && n.centerCell(y);
|
|
1316
1316
|
},
|
|
1317
1317
|
getSelection() {
|
|
1318
1318
|
return k();
|
|
1319
1319
|
},
|
|
1320
1320
|
getSelectionBounds(d) {
|
|
1321
|
-
return Qt(
|
|
1321
|
+
return Qt(n, k(d));
|
|
1322
1322
|
},
|
|
1323
1323
|
selectNodes(d) {
|
|
1324
|
-
const y = d.map((c) =>
|
|
1325
|
-
|
|
1324
|
+
const y = d.map((c) => n.getCellById(c)).filter(Boolean);
|
|
1325
|
+
n.select?.(y);
|
|
1326
1326
|
},
|
|
1327
1327
|
selectEdges(d) {
|
|
1328
|
-
const y = d.map((c) =>
|
|
1329
|
-
|
|
1328
|
+
const y = d.map((c) => n.getCellById(c)).filter(Boolean);
|
|
1329
|
+
n.select?.(y);
|
|
1330
1330
|
},
|
|
1331
1331
|
clearSelection() {
|
|
1332
|
-
const d =
|
|
1333
|
-
d?.length &&
|
|
1332
|
+
const d = n.getSelectedCells?.();
|
|
1333
|
+
d?.length && n.unselect?.(d);
|
|
1334
1334
|
},
|
|
1335
1335
|
deleteSelection(d) {
|
|
1336
|
-
const y = k(d?.selection), c = gt(y,
|
|
1336
|
+
const y = k(d?.selection), c = gt(y, s.value, r ?? (() => ({}))), g = Jt(c);
|
|
1337
1337
|
if (g.length === 0) return null;
|
|
1338
1338
|
const v = o({
|
|
1339
|
-
id:
|
|
1339
|
+
id: ee(),
|
|
1340
1340
|
source: d?.source ?? "user:toolbar",
|
|
1341
1341
|
label: d?.label ?? "删除选中",
|
|
1342
1342
|
timestamp: Date.now(),
|
|
@@ -1348,9 +1348,9 @@ function to({
|
|
|
1348
1348
|
const c = async (g) => {
|
|
1349
1349
|
const v = await S();
|
|
1350
1350
|
if (!v) return;
|
|
1351
|
-
const m =
|
|
1351
|
+
const m = ee();
|
|
1352
1352
|
b = m;
|
|
1353
|
-
const E = y(), L = f?.(E.type), z =
|
|
1353
|
+
const E = y(), L = f?.(E.type), z = n.createNode({
|
|
1354
1354
|
width: L?.width ?? 154,
|
|
1355
1355
|
height: L?.height ?? 54,
|
|
1356
1356
|
shape: L?.shapeName ?? "rect",
|
|
@@ -1367,14 +1367,14 @@ function to({
|
|
|
1367
1367
|
* 复用 X6 原生的连线拖拽流程与 connecting.createEdge 配置。
|
|
1368
1368
|
*/
|
|
1369
1369
|
startConnection(d, y) {
|
|
1370
|
-
const c =
|
|
1370
|
+
const c = n.getCellById(d);
|
|
1371
1371
|
if (!c?.isNode()) return;
|
|
1372
|
-
const g = c, v =
|
|
1372
|
+
const g = c, v = n.findViewByCell(g);
|
|
1373
1373
|
if (!v) return;
|
|
1374
1374
|
const m = v.findPortElem(y, "circle") ?? v.findPortElem(y);
|
|
1375
1375
|
if (!m) return;
|
|
1376
|
-
const L = (m.matches?.("[magnet]") ? m : m.querySelector?.("[magnet]")) ?? m, z = L.getBoundingClientRect(),
|
|
1377
|
-
clientX:
|
|
1376
|
+
const L = (m.matches?.("[magnet]") ? m : m.querySelector?.("[magnet]")) ?? m, z = L.getBoundingClientRect(), de = z.left + z.width / 2, N = z.top + z.height / 2, _ = new MouseEvent("mousedown", {
|
|
1377
|
+
clientX: de,
|
|
1378
1378
|
clientY: N,
|
|
1379
1379
|
button: 0,
|
|
1380
1380
|
buttons: 1,
|
|
@@ -1384,32 +1384,37 @@ function to({
|
|
|
1384
1384
|
L.dispatchEvent(_);
|
|
1385
1385
|
},
|
|
1386
1386
|
async exportAsImage(d) {
|
|
1387
|
-
const { domToBlob: y } = await import("modern-screenshot"), c = d?.padding ?? 20, g = d?.backgroundColor ??
|
|
1387
|
+
const { domToBlob: y } = await import("modern-screenshot"), c = d?.padding ?? 20, g = d?.backgroundColor ?? n.options.background?.color ?? "#ffffff", v = n.zoom(), m = n.translate(), E = n.getContentBBox(), L = E.width / v, z = E.height / v;
|
|
1388
1388
|
if (L === 0 || z === 0)
|
|
1389
1389
|
return new Blob();
|
|
1390
|
-
const
|
|
1390
|
+
const de = (E.x - m.tx) / v, N = (E.y - m.ty) / v, _ = Math.ceil(L + c * 2), x = Math.ceil(z + c * 2), R = document.createElement("div");
|
|
1391
1391
|
R.style.cssText = "position:fixed;left:-99999px;top:0;pointer-events:none;";
|
|
1392
|
-
const
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1392
|
+
const q = /* @__PURE__ */ new Set();
|
|
1393
|
+
let Y = n.container.parentElement;
|
|
1394
|
+
for (; Y && Y !== document.body && Y !== document.documentElement; )
|
|
1395
|
+
Y.classList.forEach((ne) => q.add(ne)), Y = Y.parentElement;
|
|
1396
|
+
q.size > 0 && (R.className = Array.from(q).join(" "));
|
|
1397
|
+
const J = n.container.cloneNode(!0);
|
|
1398
|
+
J.style.width = `${_}px`, J.style.height = `${x}px`, J.style.overflow = "visible";
|
|
1399
|
+
const Z = J.querySelector("svg");
|
|
1400
|
+
Z && (Z.setAttribute("width", String(_)), Z.setAttribute("height", String(x)), Z.style.width = `${_}px`, Z.style.height = `${x}px`), J.querySelector(".x6-graph-svg-viewport")?.setAttribute("transform", `matrix(1,0,0,1,${-de + c},${-N + c})`), R.appendChild(J), document.body.appendChild(R);
|
|
1396
1401
|
try {
|
|
1397
|
-
return await M(), await y(
|
|
1402
|
+
return await M(), await y(J, {
|
|
1398
1403
|
width: _,
|
|
1399
1404
|
height: x,
|
|
1400
1405
|
backgroundColor: g,
|
|
1401
1406
|
scale: d?.scale ?? window.devicePixelRatio,
|
|
1402
|
-
filter: (
|
|
1403
|
-
if (
|
|
1404
|
-
const
|
|
1405
|
-
if (
|
|
1407
|
+
filter: (ne) => {
|
|
1408
|
+
if (ne instanceof Element) {
|
|
1409
|
+
const re = ne.getAttribute("class") ?? "";
|
|
1410
|
+
if (re.includes("x6-widget-selection") || re.includes("x6-widget-transform") || re.includes("x6-graph-grid") || re.includes("x6-graph-background"))
|
|
1406
1411
|
return !1;
|
|
1407
1412
|
}
|
|
1408
1413
|
return !0;
|
|
1409
1414
|
}
|
|
1410
1415
|
});
|
|
1411
|
-
} catch (
|
|
1412
|
-
return console.warn("[flow-canvas] Export failed:",
|
|
1416
|
+
} catch (ne) {
|
|
1417
|
+
return console.warn("[flow-canvas] Export failed:", ne), new Blob();
|
|
1413
1418
|
} finally {
|
|
1414
1419
|
R.remove();
|
|
1415
1420
|
}
|
|
@@ -1428,49 +1433,49 @@ function to({
|
|
|
1428
1433
|
return a?.(d) ?? [];
|
|
1429
1434
|
},
|
|
1430
1435
|
insertNodeToRight(d, y, c) {
|
|
1431
|
-
const g =
|
|
1436
|
+
const g = s.value, v = g.nodes[d];
|
|
1432
1437
|
if (!v)
|
|
1433
1438
|
return {
|
|
1434
1439
|
status: "invalid",
|
|
1435
1440
|
envelope: { id: "", source: "user:toolbar", timestamp: Date.now(), commands: [] },
|
|
1436
1441
|
error: { code: "constraint_violated", reason: `Source node "${d}" not found`, source: "api" }
|
|
1437
1442
|
};
|
|
1438
|
-
const m = c?.gap ?? l ?? eo, E = c?.direction ?? "right", L = t.nodeTypes[v.type], z = t.nodeTypes[y.type],
|
|
1443
|
+
const m = c?.gap ?? l ?? eo, E = c?.direction ?? "right", L = t.nodeTypes[v.type], z = t.nodeTypes[y.type], de = L?.getSize(v) ?? { width: 154, height: 54 }, N = z?.getSize({ ...y, position: { x: 0, y: 0 } }) ?? {
|
|
1439
1444
|
width: 154,
|
|
1440
1445
|
height: 54
|
|
1441
|
-
}, _ = X(E, v,
|
|
1446
|
+
}, _ = X(E, v, de, N, m), x = y.id || p("node"), R = { ...y, id: x, position: _ }, q = [{ type: "node.add", node: R }];
|
|
1442
1447
|
if (c?.autoWireEdges) {
|
|
1443
|
-
const
|
|
1444
|
-
(I) => I.source.nodeId === d && I.source.portId ===
|
|
1448
|
+
const J = j(v), Z = j(R), Q = E, ne = U(E), re = J.find((I) => I.group === Q), we = Z.find((I) => I.group === ne), $e = Z.find((I) => I.group === Q), Se = re ? Object.values(g.edges).find(
|
|
1449
|
+
(I) => I.source.nodeId === d && I.source.portId === re.id
|
|
1445
1450
|
) : Object.values(g.edges).find((I) => I.source.nodeId === d);
|
|
1446
1451
|
if (Se) {
|
|
1447
|
-
const I = Se.target, C = N.width + m, P = E === "right" ? C : E === "left" ? -C : 0, W = E === "bottom" ? C : E === "top" ? -C : 0,
|
|
1448
|
-
for (;
|
|
1449
|
-
const
|
|
1450
|
-
if (
|
|
1451
|
-
|
|
1452
|
-
const xe = g.nodes[
|
|
1452
|
+
const I = Se.target, C = N.width + m, P = E === "right" ? C : E === "left" ? -C : 0, W = E === "bottom" ? C : E === "top" ? -C : 0, te = /* @__PURE__ */ new Set(), ce = [I.nodeId];
|
|
1453
|
+
for (; ce.length > 0; ) {
|
|
1454
|
+
const se = ce.shift();
|
|
1455
|
+
if (te.has(se) || se === d) continue;
|
|
1456
|
+
te.add(se);
|
|
1457
|
+
const xe = g.nodes[se];
|
|
1453
1458
|
if (xe) {
|
|
1454
|
-
|
|
1459
|
+
q.push({
|
|
1455
1460
|
type: "node.move",
|
|
1456
|
-
nodeId:
|
|
1461
|
+
nodeId: se,
|
|
1457
1462
|
position: {
|
|
1458
1463
|
x: xe.position.x + P,
|
|
1459
1464
|
y: xe.position.y + W
|
|
1460
1465
|
}
|
|
1461
1466
|
});
|
|
1462
1467
|
for (const be of Object.values(g.edges))
|
|
1463
|
-
be.source.nodeId ===
|
|
1468
|
+
be.source.nodeId === se && !te.has(be.target.nodeId) && ce.push(be.target.nodeId);
|
|
1464
1469
|
}
|
|
1465
1470
|
}
|
|
1466
|
-
|
|
1471
|
+
q.push({ type: "edge.remove", edgeId: Se.id }), q.push({
|
|
1467
1472
|
type: "edge.add",
|
|
1468
1473
|
edge: {
|
|
1469
1474
|
id: p("edge"),
|
|
1470
|
-
source: { nodeId: d, portId:
|
|
1475
|
+
source: { nodeId: d, portId: re?.id },
|
|
1471
1476
|
target: { nodeId: x, portId: we?.id }
|
|
1472
1477
|
}
|
|
1473
|
-
}),
|
|
1478
|
+
}), q.push({
|
|
1474
1479
|
type: "edge.add",
|
|
1475
1480
|
edge: {
|
|
1476
1481
|
id: p("edge"),
|
|
@@ -1479,127 +1484,127 @@ function to({
|
|
|
1479
1484
|
}
|
|
1480
1485
|
});
|
|
1481
1486
|
} else
|
|
1482
|
-
|
|
1487
|
+
q.push({
|
|
1483
1488
|
type: "edge.add",
|
|
1484
1489
|
edge: {
|
|
1485
1490
|
id: p("edge"),
|
|
1486
|
-
source: { nodeId: d, portId:
|
|
1491
|
+
source: { nodeId: d, portId: re?.id },
|
|
1487
1492
|
target: { nodeId: x, portId: we?.id }
|
|
1488
1493
|
}
|
|
1489
1494
|
});
|
|
1490
1495
|
}
|
|
1491
|
-
const
|
|
1492
|
-
id:
|
|
1496
|
+
const Y = {
|
|
1497
|
+
id: ee(),
|
|
1493
1498
|
source: c?.source ?? "user:toolbar",
|
|
1494
1499
|
label: c?.label ?? "插入节点",
|
|
1495
1500
|
timestamp: Date.now(),
|
|
1496
|
-
commands:
|
|
1501
|
+
commands: q
|
|
1497
1502
|
};
|
|
1498
|
-
return o(
|
|
1503
|
+
return o(Y);
|
|
1499
1504
|
},
|
|
1500
1505
|
onGraphEvent(d, y) {
|
|
1501
|
-
return
|
|
1506
|
+
return n.on(d, y), () => n.off(d, y);
|
|
1502
1507
|
},
|
|
1503
1508
|
unsafeGetGraph() {
|
|
1504
|
-
return
|
|
1509
|
+
return n;
|
|
1505
1510
|
}
|
|
1506
1511
|
};
|
|
1507
1512
|
return G;
|
|
1508
1513
|
}
|
|
1509
1514
|
function oo() {
|
|
1510
|
-
const
|
|
1515
|
+
const n = H(null), e = H(!1);
|
|
1511
1516
|
let o = null, t = !1;
|
|
1512
|
-
function
|
|
1513
|
-
o && (clearTimeout(o), o = null),
|
|
1517
|
+
function s(p) {
|
|
1518
|
+
o && (clearTimeout(o), o = null), n.value = p;
|
|
1514
1519
|
}
|
|
1515
|
-
function
|
|
1520
|
+
function r(p = 100) {
|
|
1516
1521
|
t || (o && clearTimeout(o), o = setTimeout(() => {
|
|
1517
|
-
|
|
1522
|
+
n.value = null, o = null;
|
|
1518
1523
|
}, p));
|
|
1519
1524
|
}
|
|
1520
|
-
function
|
|
1525
|
+
function i() {
|
|
1521
1526
|
t = !0, o && (clearTimeout(o), o = null);
|
|
1522
1527
|
}
|
|
1523
1528
|
function l(p = 100) {
|
|
1524
|
-
t = !1,
|
|
1529
|
+
t = !1, r(p);
|
|
1525
1530
|
}
|
|
1526
1531
|
function a() {
|
|
1527
1532
|
o && (clearTimeout(o), o = null);
|
|
1528
1533
|
}
|
|
1529
1534
|
function h() {
|
|
1530
|
-
a(), t = !1,
|
|
1535
|
+
a(), t = !1, n.value = null;
|
|
1531
1536
|
}
|
|
1532
1537
|
function f() {
|
|
1533
1538
|
o && clearTimeout(o);
|
|
1534
1539
|
}
|
|
1535
|
-
return { hoveredNodeId:
|
|
1540
|
+
return { hoveredNodeId: n, isDraggingNode: e, enter: s, leave: r, enterOverlay: i, leaveOverlay: l, cancelLeave: a, reset: h, cleanup: f };
|
|
1536
1541
|
}
|
|
1537
1542
|
const Xe = 10, Ae = 12;
|
|
1538
|
-
function Ke(
|
|
1539
|
-
const o =
|
|
1543
|
+
function Ke(n, e) {
|
|
1544
|
+
const o = n.getTotalLength();
|
|
1540
1545
|
if (o === 0) return { ...e, length: 0, totalLength: 0 };
|
|
1541
|
-
let t =
|
|
1542
|
-
const
|
|
1546
|
+
let t = n.getPointAtLength(0), s = 1 / 0;
|
|
1547
|
+
const r = 50, i = o / r;
|
|
1543
1548
|
let l = 0;
|
|
1544
|
-
for (let p = 0; p <=
|
|
1545
|
-
const u = p *
|
|
1546
|
-
D <
|
|
1549
|
+
for (let p = 0; p <= r; p++) {
|
|
1550
|
+
const u = p * i, w = n.getPointAtLength(u), D = (w.x - e.x) ** 2 + (w.y - e.y) ** 2;
|
|
1551
|
+
D < s && (s = D, t = w, l = u);
|
|
1547
1552
|
}
|
|
1548
|
-
const a = Math.max(0, l -
|
|
1553
|
+
const a = Math.max(0, l - i), h = Math.min(o, l + i), f = (h - a) / 20;
|
|
1549
1554
|
for (let p = a; p <= h; p += f) {
|
|
1550
|
-
const u =
|
|
1551
|
-
w <
|
|
1555
|
+
const u = n.getPointAtLength(p), w = (u.x - e.x) ** 2 + (u.y - e.y) ** 2;
|
|
1556
|
+
w < s && (s = w, t = u, l = p);
|
|
1552
1557
|
}
|
|
1553
1558
|
return { x: t.x, y: t.y, length: l, totalLength: o };
|
|
1554
1559
|
}
|
|
1555
|
-
function Ye(
|
|
1556
|
-
return
|
|
1560
|
+
function Ye(n, e) {
|
|
1561
|
+
return n < Xe || n > e - Xe;
|
|
1557
1562
|
}
|
|
1558
|
-
function Ze(
|
|
1559
|
-
const t =
|
|
1560
|
-
for (const
|
|
1561
|
-
const
|
|
1562
|
-
if (e >=
|
|
1563
|
+
function Ze(n, e, o) {
|
|
1564
|
+
const t = n.querySelectorAll(".x6-edge-label");
|
|
1565
|
+
for (const s of t) {
|
|
1566
|
+
const r = s.getBoundingClientRect();
|
|
1567
|
+
if (e >= r.left - Ae && e <= r.right + Ae && o >= r.top - Ae && o <= r.bottom + Ae)
|
|
1563
1568
|
return !0;
|
|
1564
1569
|
}
|
|
1565
1570
|
return !1;
|
|
1566
1571
|
}
|
|
1567
1572
|
function Qe() {
|
|
1568
|
-
const
|
|
1573
|
+
const n = "http://www.w3.org/2000/svg", e = document.createElementNS(n, "g");
|
|
1569
1574
|
e.setAttribute("class", "flow-canvas-edge-delete-tool"), e.style.cursor = "pointer";
|
|
1570
|
-
const o = document.createElementNS(
|
|
1575
|
+
const o = document.createElementNS(n, "rect");
|
|
1571
1576
|
o.setAttribute("width", "20"), o.setAttribute("height", "20"), o.setAttribute("x", "-10"), o.setAttribute("y", "-10"), o.setAttribute("rx", "4"), o.setAttribute("ry", "4"), o.setAttribute("fill", "#3a84ff"), e.appendChild(o);
|
|
1572
|
-
const t = document.createElementNS(
|
|
1577
|
+
const t = document.createElementNS(n, "text");
|
|
1573
1578
|
return t.setAttribute("font-family", "flow-canvas"), t.setAttribute("font-size", "16"), t.setAttribute("fill", "#ffffff"), t.setAttribute("text-anchor", "middle"), t.setAttribute("dominant-baseline", "central"), t.textContent = "", e.appendChild(t), e;
|
|
1574
1579
|
}
|
|
1575
|
-
function no(
|
|
1580
|
+
function no(n) {
|
|
1576
1581
|
let e = null, o = null;
|
|
1577
1582
|
function t(l, a) {
|
|
1578
|
-
if (
|
|
1579
|
-
const f =
|
|
1583
|
+
if (r(), o = l, a.target?.closest?.(".x6-edge-label")) return;
|
|
1584
|
+
const f = n.getCellById(l);
|
|
1580
1585
|
if (!f?.isEdge()) return;
|
|
1581
|
-
const p =
|
|
1586
|
+
const p = n.findViewByCell(f);
|
|
1582
1587
|
if (!p) return;
|
|
1583
1588
|
const u = p.container.querySelector("path");
|
|
1584
1589
|
if (!u) return;
|
|
1585
|
-
const w =
|
|
1590
|
+
const w = n.clientToLocal(a.clientX, a.clientY), D = Ke(u, w);
|
|
1586
1591
|
if (Ye(D.length, D.totalLength) || Ze(p.container, a.clientX, a.clientY)) return;
|
|
1587
1592
|
const O = Qe();
|
|
1588
1593
|
O.setAttribute("transform", `translate(${D.x}, ${D.y})`), p.container.appendChild(O), e = O;
|
|
1589
1594
|
}
|
|
1590
|
-
function
|
|
1595
|
+
function s(l) {
|
|
1591
1596
|
if (!o) return;
|
|
1592
1597
|
if (l.target?.closest?.(".x6-edge-label")) {
|
|
1593
1598
|
e && e.setAttribute("display", "none");
|
|
1594
1599
|
return;
|
|
1595
1600
|
}
|
|
1596
|
-
const h =
|
|
1601
|
+
const h = n.getCellById(o);
|
|
1597
1602
|
if (!h?.isEdge()) return;
|
|
1598
|
-
const f =
|
|
1603
|
+
const f = n.findViewByCell(h);
|
|
1599
1604
|
if (!f) return;
|
|
1600
1605
|
const p = f.container.querySelector("path");
|
|
1601
1606
|
if (!p) return;
|
|
1602
|
-
const u =
|
|
1607
|
+
const u = n.clientToLocal(l.clientX, l.clientY), w = Ke(p, u);
|
|
1603
1608
|
if (Ye(w.length, w.totalLength) || Ze(f.container, l.clientX, l.clientY))
|
|
1604
1609
|
e && e.setAttribute("display", "none");
|
|
1605
1610
|
else if (e)
|
|
@@ -1609,36 +1614,36 @@ function no(s) {
|
|
|
1609
1614
|
D.setAttribute("transform", `translate(${w.x}, ${w.y})`), f.container.appendChild(D), e = D;
|
|
1610
1615
|
}
|
|
1611
1616
|
}
|
|
1612
|
-
function
|
|
1617
|
+
function r() {
|
|
1613
1618
|
e && (e.remove(), e = null), o = null;
|
|
1614
1619
|
}
|
|
1615
|
-
function
|
|
1620
|
+
function i(l) {
|
|
1616
1621
|
l === o && (e = null, o = null);
|
|
1617
1622
|
}
|
|
1618
|
-
return { show: t, move:
|
|
1623
|
+
return { show: t, move: s, remove: r, handleEdgeRemoved: i };
|
|
1619
1624
|
}
|
|
1620
|
-
function so(
|
|
1625
|
+
function so(n) {
|
|
1621
1626
|
let e = null, o = 0;
|
|
1622
1627
|
function t(f) {
|
|
1623
1628
|
const p = f ? "visible" : "hidden";
|
|
1624
|
-
for (const u of
|
|
1629
|
+
for (const u of n.getNodes())
|
|
1625
1630
|
for (const w of u.getPorts())
|
|
1626
1631
|
u.setPortProp(w.id, "attrs/circle/visibility", p);
|
|
1627
1632
|
}
|
|
1628
|
-
function
|
|
1633
|
+
function s(f) {
|
|
1629
1634
|
if (!e)
|
|
1630
1635
|
for (const p of f.getPorts())
|
|
1631
1636
|
f.setPortProp(p.id, "attrs/circle/visibility", "visible");
|
|
1632
1637
|
}
|
|
1633
|
-
function
|
|
1638
|
+
function r(f) {
|
|
1634
1639
|
if (!e)
|
|
1635
1640
|
for (const p of f.getPorts())
|
|
1636
1641
|
f.setPortProp(p.id, "attrs/circle/visibility", "hidden");
|
|
1637
1642
|
}
|
|
1638
|
-
function
|
|
1643
|
+
function i(f, p) {
|
|
1639
1644
|
if (!f.getTargetCell())
|
|
1640
1645
|
if (e = f.id, p?.size)
|
|
1641
|
-
for (const u of
|
|
1646
|
+
for (const u of n.getNodes()) {
|
|
1642
1647
|
const w = p.has(u.id) ? "hidden" : "visible";
|
|
1643
1648
|
for (const D of u.getPorts())
|
|
1644
1649
|
u.setPortProp(D.id, "attrs/circle/visibility", w);
|
|
@@ -1656,26 +1661,26 @@ function so(s) {
|
|
|
1656
1661
|
return !e && Date.now() >= o;
|
|
1657
1662
|
}
|
|
1658
1663
|
return {
|
|
1659
|
-
showNodePorts:
|
|
1660
|
-
hideNodePorts:
|
|
1661
|
-
handleEdgeAdded:
|
|
1664
|
+
showNodePorts: s,
|
|
1665
|
+
hideNodePorts: r,
|
|
1666
|
+
handleEdgeAdded: i,
|
|
1662
1667
|
handleEdgeConnected: l,
|
|
1663
1668
|
handleEdgeRemoved: a,
|
|
1664
1669
|
canShowEdgeTool: h
|
|
1665
1670
|
};
|
|
1666
1671
|
}
|
|
1667
|
-
function Je(
|
|
1668
|
-
return
|
|
1672
|
+
function Je(n) {
|
|
1673
|
+
return n === "top" || n === "right" || n === "bottom" || n === "left";
|
|
1669
1674
|
}
|
|
1670
|
-
function
|
|
1671
|
-
const { editor: e, nodeHover: o, isSelectionModeActive: t, viewportVersion:
|
|
1675
|
+
function ro(n) {
|
|
1676
|
+
const { editor: e, nodeHover: o, isSelectionModeActive: t, viewportVersion: s, getNodeBehavior: r, getInsertGap: i } = n, { isDraggingNode: l } = n, a = H(null), h = H(!1);
|
|
1672
1677
|
let f = null, p = null, u = null;
|
|
1673
1678
|
const w = V(() => ({
|
|
1674
1679
|
enabled: !0,
|
|
1675
1680
|
portGroup: "right",
|
|
1676
1681
|
autoPanOnOpen: !0,
|
|
1677
1682
|
autoPanPadding: 16,
|
|
1678
|
-
...
|
|
1683
|
+
...n.quickAddProp.value
|
|
1679
1684
|
}));
|
|
1680
1685
|
function D() {
|
|
1681
1686
|
f && (clearTimeout(f), f = null);
|
|
@@ -1702,7 +1707,7 @@ function io(s) {
|
|
|
1702
1707
|
const x = w.value.getPort?.(N, _);
|
|
1703
1708
|
if (!x) return null;
|
|
1704
1709
|
const R = typeof x == "string" ? x : x.id;
|
|
1705
|
-
return _.find((
|
|
1710
|
+
return _.find((q) => q.id === R) ?? null;
|
|
1706
1711
|
}
|
|
1707
1712
|
function k(N, _) {
|
|
1708
1713
|
const x = e.api.value?.overlay.getNodeScreenRect(N);
|
|
@@ -1724,19 +1729,19 @@ function io(s) {
|
|
|
1724
1729
|
if (!p) return k(N, x);
|
|
1725
1730
|
const R = p.getCellById(N);
|
|
1726
1731
|
if (R?.isNode()) {
|
|
1727
|
-
const
|
|
1728
|
-
if (
|
|
1729
|
-
const
|
|
1732
|
+
const q = R, Y = p.findViewByCell(q), J = Y?.findPortElem(_, "circle") ?? Y?.findPortElem(_);
|
|
1733
|
+
if (J) {
|
|
1734
|
+
const Z = p.container.getBoundingClientRect(), Q = J.getBoundingClientRect();
|
|
1730
1735
|
return {
|
|
1731
|
-
x:
|
|
1732
|
-
y:
|
|
1736
|
+
x: Q.left - Z.left + Q.width / 2,
|
|
1737
|
+
y: Q.top - Z.top + Q.height / 2
|
|
1733
1738
|
};
|
|
1734
1739
|
}
|
|
1735
1740
|
}
|
|
1736
1741
|
return k(N, x);
|
|
1737
1742
|
}
|
|
1738
1743
|
function U(N) {
|
|
1739
|
-
const _ = B(N), x = j(N, _) ?? _.find((
|
|
1744
|
+
const _ = B(N), x = j(N, _) ?? _.find((q) => q.group === w.value.portGroup) ?? null;
|
|
1740
1745
|
if (!x) return null;
|
|
1741
1746
|
const R = X(N.id, x.id, x.group);
|
|
1742
1747
|
return R ? { portId: x.id, portGroup: x.group, portPosition: R } : null;
|
|
@@ -1753,19 +1758,19 @@ function io(s) {
|
|
|
1753
1758
|
function d(N) {
|
|
1754
1759
|
if (!w.value.enabled || e.mode.value !== "edit") return !1;
|
|
1755
1760
|
const x = e.flowModel.value.nodes[N];
|
|
1756
|
-
return !x ||
|
|
1761
|
+
return !x || r(x).quickAddEnabled === !1 ? !1 : !!U(x);
|
|
1757
1762
|
}
|
|
1758
1763
|
const y = V(() => {
|
|
1759
|
-
if (
|
|
1764
|
+
if (s.value, !w.value.enabled) return null;
|
|
1760
1765
|
const N = a.value;
|
|
1761
1766
|
if (!N || l.value || !e.api.value || e.mode.value !== "edit" || t.value)
|
|
1762
1767
|
return null;
|
|
1763
1768
|
const x = e.flowModel.value.nodes[N];
|
|
1764
1769
|
if (!x) return null;
|
|
1765
|
-
const R =
|
|
1770
|
+
const R = r(x);
|
|
1766
1771
|
if (R.quickAddEnabled === !1) return null;
|
|
1767
|
-
const
|
|
1768
|
-
return
|
|
1772
|
+
const q = U(x);
|
|
1773
|
+
return q ? { node: x, ...q, behavior: R } : null;
|
|
1769
1774
|
});
|
|
1770
1775
|
function c(N) {
|
|
1771
1776
|
h.value = !0, y.value && e._emitUiEvent({ type: "node.quick-add", nodeId: N, position: y.value.portPosition });
|
|
@@ -1789,15 +1794,15 @@ function io(s) {
|
|
|
1789
1794
|
function E(N, _) {
|
|
1790
1795
|
const x = e.api.value;
|
|
1791
1796
|
if (!x) return;
|
|
1792
|
-
const R = _.id || e.idGenerator("node"),
|
|
1793
|
-
if (!
|
|
1794
|
-
x.insertNodeToRight(N,
|
|
1797
|
+
const R = _.id || e.idGenerator("node"), q = { ..._, id: R }, Y = e.flowModel.value.nodes[N];
|
|
1798
|
+
if (!Y) return;
|
|
1799
|
+
x.insertNodeToRight(N, q, {
|
|
1795
1800
|
autoWireEdges: !0,
|
|
1796
|
-
direction: G(
|
|
1797
|
-
gap:
|
|
1801
|
+
direction: G(Y),
|
|
1802
|
+
gap: i(),
|
|
1798
1803
|
source: "user:quick-add",
|
|
1799
1804
|
label: "快捷插入节点"
|
|
1800
|
-
}).status === "applied" && e._emitUiEvent({ type: "node.action.quick-insert", sourceNodeId: N, newNodeId: R }),
|
|
1805
|
+
}).status === "applied" && e._emitUiEvent({ type: "node.action.quick-insert", sourceNodeId: N, newNodeId: R }), n.closePopover();
|
|
1801
1806
|
}
|
|
1802
1807
|
function L(N) {
|
|
1803
1808
|
if (!p) return;
|
|
@@ -1805,32 +1810,32 @@ function io(s) {
|
|
|
1805
1810
|
if (!_?.isNode()) return;
|
|
1806
1811
|
const x = _, R = e.flowModel.value.nodes[N];
|
|
1807
1812
|
if (!R) return;
|
|
1808
|
-
const
|
|
1809
|
-
let
|
|
1810
|
-
|
|
1811
|
-
const
|
|
1812
|
-
for (const
|
|
1813
|
-
const
|
|
1814
|
-
x.setPortProp(
|
|
1813
|
+
const q = U(R);
|
|
1814
|
+
let Y = !0;
|
|
1815
|
+
r(R).hidePortForQuickAdd === !1 && (Y = !1);
|
|
1816
|
+
const Z = Y && !l.value && !!q && d(N);
|
|
1817
|
+
for (const Q of x.getPorts()) {
|
|
1818
|
+
const ne = Z && Q.id === q?.portId ? "hidden" : "visible";
|
|
1819
|
+
x.setPortProp(Q.id, "attrs/circle/visibility", ne);
|
|
1815
1820
|
}
|
|
1816
1821
|
}
|
|
1817
1822
|
function z(N, _) {
|
|
1818
|
-
u?.(), p = N, u =
|
|
1823
|
+
u?.(), p = N, u = he(
|
|
1819
1824
|
[a, l],
|
|
1820
1825
|
([x], [R]) => {
|
|
1821
1826
|
if (R && R !== x) {
|
|
1822
|
-
const
|
|
1823
|
-
|
|
1827
|
+
const q = N.getCellById(R);
|
|
1828
|
+
q?.isNode() && _(q);
|
|
1824
1829
|
}
|
|
1825
1830
|
x && L(x);
|
|
1826
1831
|
},
|
|
1827
1832
|
{ flush: "sync" }
|
|
1828
1833
|
);
|
|
1829
1834
|
}
|
|
1830
|
-
|
|
1835
|
+
he(y, (N) => {
|
|
1831
1836
|
N || (h.value = !1);
|
|
1832
1837
|
});
|
|
1833
|
-
function
|
|
1838
|
+
function de() {
|
|
1834
1839
|
f && clearTimeout(f), u?.(), u = null, p = null;
|
|
1835
1840
|
}
|
|
1836
1841
|
return {
|
|
@@ -1851,21 +1856,21 @@ function io(s) {
|
|
|
1851
1856
|
isActiveForNode: d,
|
|
1852
1857
|
syncNodePorts: L,
|
|
1853
1858
|
attachRuntime: z,
|
|
1854
|
-
cleanup:
|
|
1859
|
+
cleanup: de
|
|
1855
1860
|
};
|
|
1856
1861
|
}
|
|
1857
|
-
const
|
|
1858
|
-
function lo(
|
|
1859
|
-
const { editor: e } =
|
|
1860
|
-
let o = null, t = null,
|
|
1861
|
-
const
|
|
1862
|
+
const io = 15, ao = 10;
|
|
1863
|
+
function lo(n) {
|
|
1864
|
+
const { editor: e } = n;
|
|
1865
|
+
let o = null, t = null, s = null, r = null;
|
|
1866
|
+
const i = [];
|
|
1862
1867
|
let l = null;
|
|
1863
1868
|
const a = V(() => ({
|
|
1864
1869
|
enabled: !1,
|
|
1865
|
-
bufferMargin:
|
|
1870
|
+
bufferMargin: io,
|
|
1866
1871
|
incomingPortGroup: "left",
|
|
1867
1872
|
outgoingPortGroup: "right",
|
|
1868
|
-
...
|
|
1873
|
+
...n.edgeDropProp.value
|
|
1869
1874
|
}));
|
|
1870
1875
|
function h(d) {
|
|
1871
1876
|
if (!o) return null;
|
|
@@ -1880,12 +1885,12 @@ function lo(s) {
|
|
|
1880
1885
|
}
|
|
1881
1886
|
function f(d) {
|
|
1882
1887
|
const y = h(d);
|
|
1883
|
-
y && (y.style.stroke = "#3a84ff",
|
|
1888
|
+
y && (y.style.stroke = "#3a84ff", r = d);
|
|
1884
1889
|
}
|
|
1885
1890
|
function p() {
|
|
1886
|
-
if (!
|
|
1887
|
-
const d = h(
|
|
1888
|
-
d && (d.style.stroke = ""),
|
|
1891
|
+
if (!r) return;
|
|
1892
|
+
const d = h(r);
|
|
1893
|
+
d && (d.style.stroke = ""), r = null;
|
|
1889
1894
|
}
|
|
1890
1895
|
function u(d, y, c) {
|
|
1891
1896
|
if (o) {
|
|
@@ -1923,23 +1928,23 @@ function lo(s) {
|
|
|
1923
1928
|
if (m.width <= 0 || m.height <= 0) return null;
|
|
1924
1929
|
const E = m.x + m.width, L = m.y + m.height;
|
|
1925
1930
|
let z = null;
|
|
1926
|
-
const
|
|
1931
|
+
const de = d.x + d.width / 2, N = d.y + d.height / 2;
|
|
1927
1932
|
for (const _ of o.getEdges()) {
|
|
1928
1933
|
const x = y.edges[_.id];
|
|
1929
1934
|
if (!x || c && (x.source.nodeId === c || x.target.nodeId === c) || g.isEdgeDropTarget && !g.isEdgeDropTarget(x, y)) continue;
|
|
1930
1935
|
const R = o.findViewByCell(_);
|
|
1931
1936
|
if (!R) continue;
|
|
1932
|
-
const
|
|
1933
|
-
if (!
|
|
1934
|
-
const
|
|
1935
|
-
if (!
|
|
1936
|
-
let
|
|
1937
|
-
for (const
|
|
1938
|
-
if (
|
|
1939
|
-
const
|
|
1940
|
-
we <
|
|
1937
|
+
const q = R.findOne?.("path");
|
|
1938
|
+
if (!q || typeof q.getTotalLength != "function") continue;
|
|
1939
|
+
const Y = w(q);
|
|
1940
|
+
if (!Y.length) continue;
|
|
1941
|
+
let J = !1, Z = 1 / 0;
|
|
1942
|
+
for (const Q of Y)
|
|
1943
|
+
if (Q.x >= m.x && Q.x <= E && Q.y >= m.y && Q.y <= L) {
|
|
1944
|
+
const ne = Q.x - de, re = Q.y - N, we = ne * ne + re * re;
|
|
1945
|
+
we < Z && (Z = we), J = !0;
|
|
1941
1946
|
}
|
|
1942
|
-
|
|
1947
|
+
J && (!z || Z < z.distSq) && (z = { edgeId: _.id, edge: x, distSq: Z });
|
|
1943
1948
|
}
|
|
1944
1949
|
return z ? { edgeId: z.edgeId, edge: z.edge } : null;
|
|
1945
1950
|
}
|
|
@@ -1960,14 +1965,14 @@ function lo(s) {
|
|
|
1960
1965
|
b = !g.isNodeInsertable || g.isNodeInsertable(c, y);
|
|
1961
1966
|
}
|
|
1962
1967
|
function M({ node: d }) {
|
|
1963
|
-
!a.value.enabled || !b ||
|
|
1964
|
-
if (
|
|
1968
|
+
!a.value.enabled || !b || s === null && (s = requestAnimationFrame(() => {
|
|
1969
|
+
if (s = null, !o) return;
|
|
1965
1970
|
const y = d.getPosition(), c = d.getSize();
|
|
1966
1971
|
O({ x: y.x, y: y.y, width: c.width, height: c.height }, d.id);
|
|
1967
1972
|
}));
|
|
1968
1973
|
}
|
|
1969
1974
|
function B() {
|
|
1970
|
-
|
|
1975
|
+
s !== null && (cancelAnimationFrame(s), s = null), p(), b = !0;
|
|
1971
1976
|
}
|
|
1972
1977
|
function j() {
|
|
1973
1978
|
if (!o) return;
|
|
@@ -1979,8 +1984,8 @@ function lo(s) {
|
|
|
1979
1984
|
d && (d = !1, p(), t = null);
|
|
1980
1985
|
return;
|
|
1981
1986
|
}
|
|
1982
|
-
d = !0,
|
|
1983
|
-
if (
|
|
1987
|
+
d = !0, s === null && (s = requestAnimationFrame(() => {
|
|
1988
|
+
if (s = null, !o) return;
|
|
1984
1989
|
const c = y.getBoundingClientRect(), g = o.clientToLocal(c.left, c.top), v = o.clientToLocal(c.right, c.bottom), m = {
|
|
1985
1990
|
x: g.x,
|
|
1986
1991
|
y: g.y,
|
|
@@ -1989,12 +1994,12 @@ function lo(s) {
|
|
|
1989
1994
|
};
|
|
1990
1995
|
O(m);
|
|
1991
1996
|
}));
|
|
1992
|
-
}, document.addEventListener("mousemove", l),
|
|
1997
|
+
}, document.addEventListener("mousemove", l), i.push(() => {
|
|
1993
1998
|
l && (document.removeEventListener("mousemove", l), l = null);
|
|
1994
1999
|
});
|
|
1995
2000
|
}
|
|
1996
2001
|
function k() {
|
|
1997
|
-
p(), t = null,
|
|
2002
|
+
p(), t = null, s !== null && (cancelAnimationFrame(s), s = null);
|
|
1998
2003
|
}
|
|
1999
2004
|
function X(d) {
|
|
2000
2005
|
if (!t || d.source !== "user:drag") return d;
|
|
@@ -2009,7 +2014,7 @@ function lo(s) {
|
|
|
2009
2014
|
const L = a.value;
|
|
2010
2015
|
if (L.isNodeInsertable && !L.isNodeInsertable(E, c))
|
|
2011
2016
|
return d;
|
|
2012
|
-
const z = u(m, E, L.incomingPortGroup),
|
|
2017
|
+
const z = u(m, E, L.incomingPortGroup), de = u(m, E, L.outgoingPortGroup), N = e.idGenerator("edge"), _ = e.idGenerator("edge"), x = [
|
|
2013
2018
|
{ type: "edge.remove", edgeId: y },
|
|
2014
2019
|
{
|
|
2015
2020
|
type: "edge.add",
|
|
@@ -2025,7 +2030,7 @@ function lo(s) {
|
|
|
2025
2030
|
edge: {
|
|
2026
2031
|
id: _,
|
|
2027
2032
|
type: g.type,
|
|
2028
|
-
source: { nodeId: m, portId:
|
|
2033
|
+
source: { nodeId: m, portId: de },
|
|
2029
2034
|
target: { nodeId: g.target.nodeId, portId: g.target.portId }
|
|
2030
2035
|
}
|
|
2031
2036
|
}
|
|
@@ -2039,14 +2044,14 @@ function lo(s) {
|
|
|
2039
2044
|
function U(d) {
|
|
2040
2045
|
o = d;
|
|
2041
2046
|
const y = (c, g) => {
|
|
2042
|
-
d.on(c, g),
|
|
2047
|
+
d.on(c, g), i.push(() => d.off(c, g));
|
|
2043
2048
|
};
|
|
2044
2049
|
y("node:move", S), y("node:change:position", M), y("node:moved", B), j();
|
|
2045
2050
|
}
|
|
2046
2051
|
function G() {
|
|
2047
2052
|
k();
|
|
2048
|
-
for (const d of
|
|
2049
|
-
|
|
2053
|
+
for (const d of i) d();
|
|
2054
|
+
i.length = 0, o = null, b = !0;
|
|
2050
2055
|
}
|
|
2051
2056
|
return {
|
|
2052
2057
|
attachRuntime: U,
|
|
@@ -2054,35 +2059,35 @@ function lo(s) {
|
|
|
2054
2059
|
cleanup: G
|
|
2055
2060
|
};
|
|
2056
2061
|
}
|
|
2057
|
-
function co(
|
|
2058
|
-
function e(
|
|
2062
|
+
function co(n) {
|
|
2063
|
+
function e(s) {
|
|
2059
2064
|
return {
|
|
2060
|
-
id:
|
|
2061
|
-
type:
|
|
2062
|
-
label:
|
|
2063
|
-
ports:
|
|
2064
|
-
payload:
|
|
2065
|
-
extensions:
|
|
2065
|
+
id: n.idGenerator("node"),
|
|
2066
|
+
type: s.type,
|
|
2067
|
+
label: s.label,
|
|
2068
|
+
ports: s.ports ? JSON.parse(JSON.stringify(s.ports)) : void 0,
|
|
2069
|
+
payload: s.payload ? JSON.parse(JSON.stringify(s.payload)) : void 0,
|
|
2070
|
+
extensions: s.extensions ? JSON.parse(JSON.stringify(s.extensions)) : void 0
|
|
2066
2071
|
};
|
|
2067
2072
|
}
|
|
2068
|
-
function o(
|
|
2069
|
-
const l =
|
|
2070
|
-
switch (
|
|
2073
|
+
function o(s, r, i) {
|
|
2074
|
+
const l = n.api.value;
|
|
2075
|
+
switch (s) {
|
|
2071
2076
|
case "delete":
|
|
2072
|
-
return
|
|
2073
|
-
id:
|
|
2077
|
+
return n.executeCommand({
|
|
2078
|
+
id: ee(),
|
|
2074
2079
|
source: "user:toolbar",
|
|
2075
2080
|
label: "删除节点",
|
|
2076
2081
|
timestamp: Date.now(),
|
|
2077
|
-
commands: [{ type: "node.remove", nodeId:
|
|
2078
|
-
}),
|
|
2082
|
+
commands: [{ type: "node.remove", nodeId: r }]
|
|
2083
|
+
}), n._emitUiEvent({ type: "node.action.delete", nodeId: r }), !0;
|
|
2079
2084
|
case "copy": {
|
|
2080
2085
|
if (!l) break;
|
|
2081
|
-
const a =
|
|
2086
|
+
const a = n.flowModel.value.nodes[r];
|
|
2082
2087
|
if (!a) break;
|
|
2083
2088
|
const h = e(a), f = 50;
|
|
2084
|
-
|
|
2085
|
-
id:
|
|
2089
|
+
n.executeCommand({
|
|
2090
|
+
id: ee(),
|
|
2086
2091
|
source: "user:toolbar",
|
|
2087
2092
|
label: "复制节点",
|
|
2088
2093
|
timestamp: Date.now(),
|
|
@@ -2098,46 +2103,46 @@ function co(s) {
|
|
|
2098
2103
|
}
|
|
2099
2104
|
}
|
|
2100
2105
|
]
|
|
2101
|
-
}), l.selectNodes([h.id]),
|
|
2106
|
+
}), l.selectNodes([h.id]), n._emitUiEvent({ type: "node.action.copy", sourceNodeId: r, newNodeId: h.id });
|
|
2102
2107
|
break;
|
|
2103
2108
|
}
|
|
2104
2109
|
case "copy-insert": {
|
|
2105
2110
|
if (!l) break;
|
|
2106
|
-
const a =
|
|
2111
|
+
const a = n.flowModel.value.nodes[r];
|
|
2107
2112
|
if (!a) break;
|
|
2108
2113
|
const h = e(a);
|
|
2109
|
-
l.insertNodeToRight(
|
|
2114
|
+
l.insertNodeToRight(r, h, {
|
|
2110
2115
|
autoWireEdges: !0,
|
|
2111
|
-
gap:
|
|
2116
|
+
gap: i,
|
|
2112
2117
|
label: "复制并插入节点"
|
|
2113
|
-
}), l.selectNodes([h.id]),
|
|
2118
|
+
}), l.selectNodes([h.id]), n._emitUiEvent({ type: "node.action.copy-insert", sourceNodeId: r, newNodeId: h.id });
|
|
2114
2119
|
break;
|
|
2115
2120
|
}
|
|
2116
2121
|
case "disconnect": {
|
|
2117
|
-
const a =
|
|
2122
|
+
const a = n.flowModel.value, h = Object.entries(a.edges).filter(([, f]) => {
|
|
2118
2123
|
const p = f;
|
|
2119
|
-
return p.source.nodeId ===
|
|
2124
|
+
return p.source.nodeId === r || p.target.nodeId === r;
|
|
2120
2125
|
}).map(([f]) => f);
|
|
2121
2126
|
if (h.length === 0) break;
|
|
2122
|
-
|
|
2123
|
-
id:
|
|
2127
|
+
n.executeCommand({
|
|
2128
|
+
id: ee(),
|
|
2124
2129
|
source: "user:toolbar",
|
|
2125
2130
|
label: "断开连线",
|
|
2126
2131
|
timestamp: Date.now(),
|
|
2127
2132
|
commands: h.map((f) => ({ type: "edge.remove", edgeId: f }))
|
|
2128
|
-
}),
|
|
2133
|
+
}), n._emitUiEvent({ type: "node.action.disconnect", nodeId: r, edgeIds: h });
|
|
2129
2134
|
break;
|
|
2130
2135
|
}
|
|
2131
2136
|
case "debug": {
|
|
2132
|
-
|
|
2137
|
+
n._emitUiEvent({ type: "node.action.debug", nodeId: r });
|
|
2133
2138
|
break;
|
|
2134
2139
|
}
|
|
2135
2140
|
}
|
|
2136
2141
|
return !1;
|
|
2137
2142
|
}
|
|
2138
|
-
function t(
|
|
2139
|
-
|
|
2140
|
-
selection:
|
|
2143
|
+
function t(s) {
|
|
2144
|
+
n.api.value?.deleteSelection({
|
|
2145
|
+
selection: s,
|
|
2141
2146
|
source: "user:toolbar",
|
|
2142
2147
|
label: "批量删除选中"
|
|
2143
2148
|
});
|
|
@@ -2165,8 +2170,8 @@ function uo() {
|
|
|
2165
2170
|
]
|
|
2166
2171
|
};
|
|
2167
2172
|
}
|
|
2168
|
-
function fo(
|
|
2169
|
-
const o = e.defaultEdgeType ?? "default", t = e.edgeTypes?.[o],
|
|
2173
|
+
function fo(n, e) {
|
|
2174
|
+
const o = e.defaultEdgeType ?? "default", t = e.edgeTypes?.[o], s = {
|
|
2170
2175
|
zIndex: -1,
|
|
2171
2176
|
attrs: {
|
|
2172
2177
|
line: {
|
|
@@ -2176,39 +2181,39 @@ function fo(s, e) {
|
|
|
2176
2181
|
}
|
|
2177
2182
|
}
|
|
2178
2183
|
};
|
|
2179
|
-
t?.router && (
|
|
2180
|
-
const
|
|
2181
|
-
return
|
|
2182
|
-
...
|
|
2184
|
+
t?.router && (s.router = typeof t.router == "string" ? { name: t.router } : t.router), t?.connector && (s.connector = typeof t.connector == "string" ? { name: t.connector } : t.connector), t?.x6EdgeConfig && Object.assign(s, t.x6EdgeConfig);
|
|
2185
|
+
const r = s.attrs ?? {}, i = r.line ?? {};
|
|
2186
|
+
return s.attrs = {
|
|
2187
|
+
...r,
|
|
2183
2188
|
line: {
|
|
2184
|
-
...
|
|
2189
|
+
...i,
|
|
2185
2190
|
targetMarker: uo()
|
|
2186
2191
|
}
|
|
2187
|
-
},
|
|
2192
|
+
}, n.createEdge(s);
|
|
2188
2193
|
}
|
|
2189
2194
|
const go = ".x6-widget-selection", po = ".x6-graph-svg";
|
|
2190
|
-
function ho(
|
|
2191
|
-
const e =
|
|
2195
|
+
function ho(n) {
|
|
2196
|
+
const e = n.querySelector(go), o = n.querySelector(po);
|
|
2192
2197
|
return !e || !o || e.parentNode !== o.parentNode || !o.parentNode || o.previousSibling === e ? !1 : (o.parentNode.insertBefore(e, o), !0);
|
|
2193
2198
|
}
|
|
2194
|
-
function vo(
|
|
2195
|
-
const e = () => ho(
|
|
2199
|
+
function vo(n) {
|
|
2200
|
+
const e = () => ho(n);
|
|
2196
2201
|
e();
|
|
2197
2202
|
const o = new MutationObserver(() => {
|
|
2198
2203
|
e();
|
|
2199
2204
|
});
|
|
2200
|
-
return o.observe(
|
|
2205
|
+
return o.observe(n, { childList: !0 }), () => o.disconnect();
|
|
2201
2206
|
}
|
|
2202
|
-
function mo(
|
|
2203
|
-
const t = new Set(e),
|
|
2204
|
-
for (const
|
|
2205
|
-
const l =
|
|
2207
|
+
function mo(n, e, o) {
|
|
2208
|
+
const t = new Set(e), s = new Set(o), r = /* @__PURE__ */ new Set([...t, ...s]);
|
|
2209
|
+
for (const i of r) {
|
|
2210
|
+
const l = n.getCellById(i);
|
|
2206
2211
|
if (!l?.isNode()) continue;
|
|
2207
|
-
const a =
|
|
2212
|
+
const a = s.has(i), h = l.getData() ?? {};
|
|
2208
2213
|
h._selected !== a && l.setData({ ...h, _selected: a });
|
|
2209
2214
|
}
|
|
2210
2215
|
}
|
|
2211
|
-
const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */
|
|
2216
|
+
const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ pe({
|
|
2212
2217
|
__name: "node-actions-toolbar",
|
|
2213
2218
|
props: {
|
|
2214
2219
|
node: {},
|
|
@@ -2218,15 +2223,15 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2218
2223
|
actionsOffset: {}
|
|
2219
2224
|
},
|
|
2220
2225
|
emits: ["action"],
|
|
2221
|
-
setup(
|
|
2222
|
-
const o =
|
|
2226
|
+
setup(n, { emit: e }) {
|
|
2227
|
+
const o = n, t = V(() => {
|
|
2223
2228
|
const p = o.actionsOffset?.x ?? 0, u = o.actionsOffset?.y ?? 0, w = p !== 0 || u !== 0;
|
|
2224
2229
|
return {
|
|
2225
2230
|
left: `${o.position.x}px`,
|
|
2226
2231
|
top: `${o.position.y}px`,
|
|
2227
2232
|
transform: w ? `translate(${p}px, ${u}px)` : "translateX(-100%)"
|
|
2228
2233
|
};
|
|
2229
|
-
}),
|
|
2234
|
+
}), s = e, r = V(() => ({
|
|
2230
2235
|
debug: {
|
|
2231
2236
|
visible: o.config.showDebug && o.behavior.debuggable !== !1,
|
|
2232
2237
|
disabled: o.behavior.debugDisabled === !0
|
|
@@ -2247,7 +2252,7 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2247
2252
|
visible: o.config.showDisconnect && o.behavior.disconnectable !== !1,
|
|
2248
2253
|
disabled: o.behavior.disconnectDisabled === !0
|
|
2249
2254
|
}
|
|
2250
|
-
})),
|
|
2255
|
+
})), i = V(() => r.value.copy.visible || r.value.copyInsert.visible || r.value.disconnect.visible), l = H(!1);
|
|
2251
2256
|
let a = null;
|
|
2252
2257
|
function h() {
|
|
2253
2258
|
a && (clearTimeout(a), a = null), l.value = !0;
|
|
@@ -2263,73 +2268,73 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2263
2268
|
class: "flow-canvas-node-actions",
|
|
2264
2269
|
style: Ee(t.value)
|
|
2265
2270
|
}, [
|
|
2266
|
-
|
|
2267
|
-
|
|
2271
|
+
F("div", yo, [
|
|
2272
|
+
r.value.debug.visible ? (A(), T("i", {
|
|
2268
2273
|
key: 0,
|
|
2269
|
-
class:
|
|
2270
|
-
onClick: u[0] || (u[0] = (w) => !
|
|
2271
|
-
}, null, 2)) :
|
|
2272
|
-
|
|
2274
|
+
class: oe(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon", { "is-disabled": r.value.debug.disabled }]),
|
|
2275
|
+
onClick: u[0] || (u[0] = (w) => !r.value.debug.disabled && s("action", "debug", n.node.id))
|
|
2276
|
+
}, null, 2)) : K("", !0),
|
|
2277
|
+
r.value.delete.visible ? (A(), T("i", {
|
|
2273
2278
|
key: 1,
|
|
2274
|
-
class:
|
|
2275
|
-
onClick: u[1] || (u[1] = (w) => !
|
|
2276
|
-
}, null, 2)) :
|
|
2277
|
-
|
|
2279
|
+
class: oe(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon", { "is-disabled": r.value.delete.disabled }]),
|
|
2280
|
+
onClick: u[1] || (u[1] = (w) => !r.value.delete.disabled && s("action", "delete", n.node.id))
|
|
2281
|
+
}, null, 2)) : K("", !0),
|
|
2282
|
+
i.value ? (A(), T("div", {
|
|
2278
2283
|
key: 2,
|
|
2279
2284
|
class: "flow-canvas-node-actions__more-wrapper",
|
|
2280
2285
|
onMouseenter: h,
|
|
2281
2286
|
onMouseleave: f
|
|
2282
2287
|
}, [...u[5] || (u[5] = [
|
|
2283
|
-
|
|
2284
|
-
])], 32)) :
|
|
2288
|
+
F("i", { class: "flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon" }, null, -1)
|
|
2289
|
+
])], 32)) : K("", !0)
|
|
2285
2290
|
]),
|
|
2286
2291
|
at(lt, { name: "flow-canvas-fade" }, {
|
|
2287
2292
|
default: He(() => [
|
|
2288
|
-
l.value &&
|
|
2293
|
+
l.value && i.value ? (A(), T("div", {
|
|
2289
2294
|
key: 0,
|
|
2290
2295
|
class: "flow-canvas-node-actions__dropdown",
|
|
2291
2296
|
onMouseenter: h,
|
|
2292
2297
|
onMouseleave: f
|
|
2293
2298
|
}, [
|
|
2294
|
-
|
|
2299
|
+
r.value.copy.visible ? (A(), T("div", {
|
|
2295
2300
|
key: 0,
|
|
2296
|
-
class:
|
|
2297
|
-
onClick: u[2] || (u[2] = (w) => !
|
|
2301
|
+
class: oe(["flow-canvas-node-actions__dropdown-item", { "is-disabled": r.value.copy.disabled }]),
|
|
2302
|
+
onClick: u[2] || (u[2] = (w) => !r.value.copy.disabled && s("action", "copy", n.node.id))
|
|
2298
2303
|
}, [...u[6] || (u[6] = [
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
])], 2)) :
|
|
2302
|
-
|
|
2304
|
+
F("i", { class: "flow-canvas-icon canvas-copy-fuzhi-2" }, null, -1),
|
|
2305
|
+
F("span", null, "复制", -1)
|
|
2306
|
+
])], 2)) : K("", !0),
|
|
2307
|
+
r.value.copyInsert.visible ? (A(), T("div", {
|
|
2303
2308
|
key: 1,
|
|
2304
|
-
class:
|
|
2305
|
-
onClick: u[3] || (u[3] = (w) => !
|
|
2309
|
+
class: oe(["flow-canvas-node-actions__dropdown-item", { "is-disabled": r.value.copyInsert.disabled }]),
|
|
2310
|
+
onClick: u[3] || (u[3] = (w) => !r.value.copyInsert.disabled && s("action", "copy-insert", n.node.id))
|
|
2306
2311
|
}, [...u[7] || (u[7] = [
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
])], 2)) :
|
|
2310
|
-
|
|
2312
|
+
F("i", { class: "flow-canvas-icon canvas-fuzhibingcharu" }, null, -1),
|
|
2313
|
+
F("span", null, "复制并插入", -1)
|
|
2314
|
+
])], 2)) : K("", !0),
|
|
2315
|
+
r.value.disconnect.visible ? (A(), T("div", {
|
|
2311
2316
|
key: 2,
|
|
2312
|
-
class:
|
|
2313
|
-
onClick: u[4] || (u[4] = (w) => !
|
|
2317
|
+
class: oe(["flow-canvas-node-actions__dropdown-item", { "is-disabled": r.value.disconnect.disabled }]),
|
|
2318
|
+
onClick: u[4] || (u[4] = (w) => !r.value.disconnect.disabled && s("action", "disconnect", n.node.id))
|
|
2314
2319
|
}, [...u[8] || (u[8] = [
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
])], 2)) :
|
|
2318
|
-
], 32)) :
|
|
2320
|
+
F("i", { class: "flow-canvas-icon canvas-unlock-jiebang" }, null, -1),
|
|
2321
|
+
F("span", null, "断开连线", -1)
|
|
2322
|
+
])], 2)) : K("", !0)
|
|
2323
|
+
], 32)) : K("", !0)
|
|
2319
2324
|
]),
|
|
2320
2325
|
_: 1
|
|
2321
2326
|
})
|
|
2322
2327
|
], 4));
|
|
2323
2328
|
}
|
|
2324
|
-
}),
|
|
2325
|
-
const o =
|
|
2326
|
-
for (const [t,
|
|
2327
|
-
o[t] =
|
|
2329
|
+
}), me = (n, e) => {
|
|
2330
|
+
const o = n.__vccOpts || n;
|
|
2331
|
+
for (const [t, s] of e)
|
|
2332
|
+
o[t] = s;
|
|
2328
2333
|
return o;
|
|
2329
|
-
}, bo = /* @__PURE__ */
|
|
2334
|
+
}, bo = /* @__PURE__ */ me(wo, [["__scopeId", "data-v-3b39dab5"]]), Eo = {
|
|
2330
2335
|
key: 0,
|
|
2331
2336
|
class: "flow-canvas-quick-add__tooltip"
|
|
2332
|
-
}, xo = 5, Io = /* @__PURE__ */
|
|
2337
|
+
}, xo = 5, Io = /* @__PURE__ */ pe({
|
|
2333
2338
|
__name: "node-quick-add-popover",
|
|
2334
2339
|
props: {
|
|
2335
2340
|
node: {},
|
|
@@ -2338,8 +2343,8 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2338
2343
|
autoPanPadding: {}
|
|
2339
2344
|
},
|
|
2340
2345
|
emits: ["open", "close", "start-drag", "viewport-overflow-right", "mouseenter", "mouseleave"],
|
|
2341
|
-
setup(
|
|
2342
|
-
const t =
|
|
2346
|
+
setup(n, { expose: e, emit: o }) {
|
|
2347
|
+
const t = n, s = o, r = H(), i = H(), l = H(!1), a = H(!1);
|
|
2343
2348
|
let h = null, f = !1, p = null;
|
|
2344
2349
|
function u(G) {
|
|
2345
2350
|
G.preventDefault(), G.stopPropagation(), h = { x: G.clientX, y: G.clientY }, f = !1, document.addEventListener("mousemove", w), document.addEventListener("mouseup", D);
|
|
@@ -2347,7 +2352,7 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2347
2352
|
function w(G) {
|
|
2348
2353
|
if (!h) return;
|
|
2349
2354
|
const d = G.clientX - h.x, y = G.clientY - h.y;
|
|
2350
|
-
Math.sqrt(d * d + y * y) >= xo && (f = !0, O(),
|
|
2355
|
+
Math.sqrt(d * d + y * y) >= xo && (f = !0, O(), s("start-drag", t.node.id));
|
|
2351
2356
|
}
|
|
2352
2357
|
function D() {
|
|
2353
2358
|
O(), f || b(), h = null, f = !1;
|
|
@@ -2359,7 +2364,7 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2359
2364
|
a.value ? B() : S();
|
|
2360
2365
|
}
|
|
2361
2366
|
function S() {
|
|
2362
|
-
a.value = !0,
|
|
2367
|
+
a.value = !0, s("open", t.node.id), Ge(() => {
|
|
2363
2368
|
requestAnimationFrame(() => {
|
|
2364
2369
|
M();
|
|
2365
2370
|
});
|
|
@@ -2368,105 +2373,105 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2368
2373
|
});
|
|
2369
2374
|
}
|
|
2370
2375
|
function M() {
|
|
2371
|
-
if (!a.value || !t.autoPanOnOpen || !
|
|
2376
|
+
if (!a.value || !t.autoPanOnOpen || !i.value) return;
|
|
2372
2377
|
const G = window.innerWidth || document.documentElement.clientWidth || 0;
|
|
2373
2378
|
if (G <= 0) return;
|
|
2374
|
-
const d = t.autoPanPadding ?? 16, c =
|
|
2375
|
-
c > 0 &&
|
|
2379
|
+
const d = t.autoPanPadding ?? 16, c = i.value.getBoundingClientRect().right + d - G;
|
|
2380
|
+
c > 0 && s("viewport-overflow-right", c);
|
|
2376
2381
|
}
|
|
2377
2382
|
function B() {
|
|
2378
|
-
a.value = !1,
|
|
2383
|
+
a.value = !1, s("close"), document.removeEventListener("mousedown", j);
|
|
2379
2384
|
}
|
|
2380
2385
|
function j(G) {
|
|
2381
2386
|
const d = G.target;
|
|
2382
|
-
|
|
2387
|
+
r.value?.contains(d) || i.value?.contains(d) || B();
|
|
2383
2388
|
}
|
|
2384
2389
|
function k() {
|
|
2385
|
-
a.value ||
|
|
2390
|
+
a.value || s("mouseleave");
|
|
2386
2391
|
}
|
|
2387
2392
|
function X() {
|
|
2388
|
-
p && (clearTimeout(p), p = null),
|
|
2393
|
+
p && (clearTimeout(p), p = null), s("mouseenter");
|
|
2389
2394
|
}
|
|
2390
2395
|
function U() {
|
|
2391
2396
|
p = setTimeout(() => {
|
|
2392
|
-
B(),
|
|
2397
|
+
B(), s("mouseleave"), p = null;
|
|
2393
2398
|
}, 150);
|
|
2394
2399
|
}
|
|
2395
2400
|
return Te(() => {
|
|
2396
2401
|
O(), p && clearTimeout(p), document.removeEventListener("mousedown", j);
|
|
2397
2402
|
}), e({ closePopover: B }), (G, d) => (A(), T("div", {
|
|
2398
2403
|
class: "flow-canvas-quick-add",
|
|
2399
|
-
style: Ee({ left: `${
|
|
2400
|
-
onMouseenter: d[2] || (d[2] = (y) =>
|
|
2404
|
+
style: Ee({ left: `${n.portPosition.x}px`, top: `${n.portPosition.y}px` }),
|
|
2405
|
+
onMouseenter: d[2] || (d[2] = (y) => s("mouseenter")),
|
|
2401
2406
|
onMouseleave: k,
|
|
2402
2407
|
onClick: d[3] || (d[3] = ht(() => {
|
|
2403
2408
|
}, ["stop"]))
|
|
2404
2409
|
}, [
|
|
2405
|
-
|
|
2410
|
+
F("div", {
|
|
2406
2411
|
ref_key: "btnRef",
|
|
2407
|
-
ref:
|
|
2408
|
-
class:
|
|
2412
|
+
ref: r,
|
|
2413
|
+
class: oe(["flow-canvas-quick-add__btn", { "is-hovered": l.value, "is-active": a.value }]),
|
|
2409
2414
|
onMouseenter: d[0] || (d[0] = (y) => l.value = !0),
|
|
2410
2415
|
onMouseleave: d[1] || (d[1] = (y) => l.value = !1),
|
|
2411
2416
|
onMousedown: u
|
|
2412
2417
|
}, [...d[4] || (d[4] = [
|
|
2413
|
-
|
|
2418
|
+
F("i", { class: "flow-canvas-icon canvas-zoom-add" }, null, -1)
|
|
2414
2419
|
])], 34),
|
|
2415
2420
|
l.value && !a.value ? (A(), T("div", Eo, [...d[5] || (d[5] = [
|
|
2416
|
-
|
|
2417
|
-
|
|
2421
|
+
F("div", null, [
|
|
2422
|
+
F("b", null, "点击"),
|
|
2418
2423
|
je(" 添加节点")
|
|
2419
2424
|
], -1),
|
|
2420
|
-
|
|
2421
|
-
|
|
2425
|
+
F("div", null, [
|
|
2426
|
+
F("b", null, "拖拽"),
|
|
2422
2427
|
je(" 连接节点")
|
|
2423
2428
|
], -1)
|
|
2424
|
-
])])) :
|
|
2429
|
+
])])) : K("", !0),
|
|
2425
2430
|
at(lt, { name: "flow-canvas-fade" }, {
|
|
2426
2431
|
default: He(() => [
|
|
2427
2432
|
a.value ? (A(), T("div", {
|
|
2428
2433
|
key: 0,
|
|
2429
2434
|
ref_key: "popoverRef",
|
|
2430
|
-
ref:
|
|
2435
|
+
ref: i,
|
|
2431
2436
|
class: "flow-canvas-quick-add__popover",
|
|
2432
2437
|
onMouseenter: X,
|
|
2433
2438
|
onMouseleave: U
|
|
2434
2439
|
}, [
|
|
2435
2440
|
Me(G.$slots, "default", {}, () => [
|
|
2436
|
-
d[6] || (d[6] =
|
|
2441
|
+
d[6] || (d[6] = F("div", { class: "flow-canvas-quick-add__default-content" }, "节点快捷操作面板", -1))
|
|
2437
2442
|
], !0)
|
|
2438
|
-
], 544)) :
|
|
2443
|
+
], 544)) : K("", !0)
|
|
2439
2444
|
]),
|
|
2440
2445
|
_: 3
|
|
2441
2446
|
})
|
|
2442
2447
|
], 36));
|
|
2443
2448
|
}
|
|
2444
|
-
}), Co = /* @__PURE__ */
|
|
2449
|
+
}), Co = /* @__PURE__ */ me(Io, [["__scopeId", "data-v-255b3d8c"]]), ko = { class: "flow-canvas-selection-actions__bar" }, So = /* @__PURE__ */ pe({
|
|
2445
2450
|
__name: "selection-actions-toolbar",
|
|
2446
2451
|
props: {
|
|
2447
2452
|
position: {},
|
|
2448
2453
|
canDelete: { type: Boolean }
|
|
2449
2454
|
},
|
|
2450
2455
|
emits: ["action"],
|
|
2451
|
-
setup(
|
|
2452
|
-
const o =
|
|
2456
|
+
setup(n, { emit: e }) {
|
|
2457
|
+
const o = n, t = e, s = V(() => ({
|
|
2453
2458
|
left: `${o.position.x}px`,
|
|
2454
2459
|
top: `${o.position.y}px`,
|
|
2455
2460
|
transform: "translateX(-100%)"
|
|
2456
2461
|
}));
|
|
2457
|
-
return (
|
|
2462
|
+
return (r, i) => (A(), T("div", {
|
|
2458
2463
|
class: "flow-canvas-selection-actions",
|
|
2459
|
-
style: Ee(
|
|
2464
|
+
style: Ee(s.value)
|
|
2460
2465
|
}, [
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
class:
|
|
2464
|
-
onClick:
|
|
2466
|
+
F("div", ko, [
|
|
2467
|
+
F("i", {
|
|
2468
|
+
class: oe(["flow-canvas-icon canvas-shanchu flow-canvas-selection-actions__icon", { "is-disabled": !n.canDelete }]),
|
|
2469
|
+
onClick: i[0] || (i[0] = (l) => n.canDelete && t("action", "delete"))
|
|
2465
2470
|
}, null, 2)
|
|
2466
2471
|
])
|
|
2467
2472
|
], 4));
|
|
2468
2473
|
}
|
|
2469
|
-
}), Mo = /* @__PURE__ */
|
|
2474
|
+
}), Mo = /* @__PURE__ */ me(So, [["__scopeId", "data-v-25eb8b79"]]), No = { class: "flow-canvas-runtime-core__overlay" }, Do = /* @__PURE__ */ pe({
|
|
2470
2475
|
__name: "canvas-runtime-core",
|
|
2471
2476
|
props: {
|
|
2472
2477
|
editor: {},
|
|
@@ -2478,8 +2483,8 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2478
2483
|
toolbarInclude: {}
|
|
2479
2484
|
},
|
|
2480
2485
|
emits: ["ui-event"],
|
|
2481
|
-
setup(
|
|
2482
|
-
const t =
|
|
2486
|
+
setup(n, { expose: e, emit: o }) {
|
|
2487
|
+
const t = n, s = o, r = H(), i = H();
|
|
2483
2488
|
let l, a, h, f, p = null, u = null, w = null, D = null, O = null;
|
|
2484
2489
|
const b = oo(), { hoveredNodeId: S, isDraggingNode: M } = b, B = b.enterOverlay, j = () => b.leaveOverlay(), k = H(0), X = H({ nodeIds: [], edgeIds: [] });
|
|
2485
2490
|
function U(I) {
|
|
@@ -2503,15 +2508,15 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2503
2508
|
() => {
|
|
2504
2509
|
if (k.value, !t.editor.api.value) return [];
|
|
2505
2510
|
const I = t.editor.flowModel.value, C = t.editor.api.value.overlay, P = [];
|
|
2506
|
-
for (const [W,
|
|
2507
|
-
const
|
|
2508
|
-
if (!
|
|
2509
|
-
const
|
|
2510
|
-
|
|
2511
|
+
for (const [W, te] of Object.entries(I.nodes)) {
|
|
2512
|
+
const ce = t.editor._pluginManager.collectNodeDecorations(te);
|
|
2513
|
+
if (!ce?.badge) continue;
|
|
2514
|
+
const se = C.getNodeScreenRect(W);
|
|
2515
|
+
se && P.push({
|
|
2511
2516
|
nodeId: W,
|
|
2512
|
-
x:
|
|
2513
|
-
y:
|
|
2514
|
-
badge:
|
|
2517
|
+
x: se.x + se.width - 4,
|
|
2518
|
+
y: se.y - 8,
|
|
2519
|
+
badge: ce.badge
|
|
2515
2520
|
});
|
|
2516
2521
|
}
|
|
2517
2522
|
return P;
|
|
@@ -2525,11 +2530,11 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2525
2530
|
if (!P) return null;
|
|
2526
2531
|
const W = t.editor.api.value.overlay.getNodeScreenRect(I);
|
|
2527
2532
|
if (!W) return null;
|
|
2528
|
-
const
|
|
2529
|
-
return
|
|
2533
|
+
const te = U(P);
|
|
2534
|
+
return te.showActions === !1 ? null : {
|
|
2530
2535
|
node: P,
|
|
2531
2536
|
position: { x: W.x + W.width, y: W.y + W.height + 4 },
|
|
2532
|
-
behavior:
|
|
2537
|
+
behavior: te
|
|
2533
2538
|
};
|
|
2534
2539
|
}), g = V(() => {
|
|
2535
2540
|
if (k.value, !t.editor.api.value || t.editor.mode.value !== "edit") return null;
|
|
@@ -2542,7 +2547,7 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2542
2547
|
position: { x: C.x + C.width, y: C.y + C.height + 4 },
|
|
2543
2548
|
canDelete: P.nodeIds.length > 0 || P.edgeIds.length > 0
|
|
2544
2549
|
};
|
|
2545
|
-
}), v = H(), m =
|
|
2550
|
+
}), v = H(), m = ro({
|
|
2546
2551
|
editor: t.editor,
|
|
2547
2552
|
quickAddProp: V(() => t.quickAdd),
|
|
2548
2553
|
isDraggingNode: M,
|
|
@@ -2553,20 +2558,20 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2553
2558
|
getInsertGap: () => d.value.insertGap,
|
|
2554
2559
|
closePopover: () => v.value?.closePopover()
|
|
2555
2560
|
}), E = m.data, L = m.handleOpen, z = m.handleStartDrag;
|
|
2556
|
-
function
|
|
2561
|
+
function de() {
|
|
2557
2562
|
m.handleClose(), b.leaveOverlay(200), m.leave();
|
|
2558
2563
|
}
|
|
2559
2564
|
const N = m.handleOverlayEnter, _ = m.handleOverlayLeave, x = m.handleInsert, R = lo({
|
|
2560
2565
|
editor: t.editor,
|
|
2561
2566
|
edgeDropProp: V(() => t.edgeDrop)
|
|
2562
|
-
}),
|
|
2563
|
-
function
|
|
2564
|
-
|
|
2567
|
+
}), q = co(t.editor);
|
|
2568
|
+
function Y(I, C) {
|
|
2569
|
+
q.handleNodeAction(I, C, d.value.insertGap) && (S.value = null);
|
|
2565
2570
|
}
|
|
2566
|
-
function
|
|
2567
|
-
I === "delete" &&
|
|
2571
|
+
function J(I) {
|
|
2572
|
+
I === "delete" && q.deleteSelection(X.value);
|
|
2568
2573
|
}
|
|
2569
|
-
function
|
|
2574
|
+
function Z(I) {
|
|
2570
2575
|
if (t.editor.mode.value !== "edit") return;
|
|
2571
2576
|
if ((I.metaKey || I.ctrlKey) && (I.key === "z" || I.key === "Z")) {
|
|
2572
2577
|
if (I.shiftKey) {
|
|
@@ -2581,14 +2586,14 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2581
2586
|
}
|
|
2582
2587
|
t.editor._pluginManager.dispatchKeyboardShortcut(I) && (I.preventDefault(), I.stopPropagation());
|
|
2583
2588
|
}
|
|
2584
|
-
function
|
|
2585
|
-
const P = l, W = (
|
|
2586
|
-
const
|
|
2587
|
-
|
|
2589
|
+
function Q(I, C) {
|
|
2590
|
+
const P = l, W = (te) => {
|
|
2591
|
+
const ce = P.isRubberbandEnabled?.() ?? !1;
|
|
2592
|
+
ce && P.disableRubberband?.(), te ? l.enablePanning() : l.disablePanning(), ce && P.enableRubberband?.();
|
|
2588
2593
|
};
|
|
2589
2594
|
I && C ? (P.enableSelection?.(), b.reset(), m.quickAddNodeId.value = null, m.quickAddPopoverOpen.value = !1, p?.remove(), W(!1), P.enableRubberband?.()) : (P.disableRubberband?.(), W(!0), P.disableSelection?.(), P.cleanSelection?.());
|
|
2590
2595
|
}
|
|
2591
|
-
function
|
|
2596
|
+
function ne(I) {
|
|
2592
2597
|
l.on("node:move", ({ node: C }) => {
|
|
2593
2598
|
M.value = !0;
|
|
2594
2599
|
const P = t.editor.flowModel.value.nodes[C.id];
|
|
@@ -2617,14 +2622,14 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2617
2622
|
P && U(P).actionsOffset && (W = 300), b.leave(W), m.mergedConfig.value.enabled ? m.quickAddNodeId.value === C.id && !m.quickAddPopoverOpen.value ? m.leave() : m.quickAddNodeId.value !== C.id && I.hideNodePorts(C) : I.hideNodePorts(C);
|
|
2618
2623
|
});
|
|
2619
2624
|
}
|
|
2620
|
-
function
|
|
2625
|
+
function re(I) {
|
|
2621
2626
|
l.on("edge:added", ({ edge: C }) => {
|
|
2622
2627
|
let P;
|
|
2623
2628
|
if (t.getConnectionExcludedNodeIds && !C.getTargetCell()) {
|
|
2624
2629
|
const W = C.getSourceCell();
|
|
2625
2630
|
if (W) {
|
|
2626
|
-
const
|
|
2627
|
-
P =
|
|
2631
|
+
const te = t.getConnectionExcludedNodeIds(W.id);
|
|
2632
|
+
P = te instanceof Set ? te : new Set(te);
|
|
2628
2633
|
}
|
|
2629
2634
|
}
|
|
2630
2635
|
I.handleEdgeAdded(C, P);
|
|
@@ -2639,7 +2644,7 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2639
2644
|
a.setHoveredEdge(null), a.refreshSingleEdgeStyle(C.id), p.remove();
|
|
2640
2645
|
}), l.on("edge:click", ({ edge: C, e: P }) => {
|
|
2641
2646
|
P.target?.closest?.(".flow-canvas-edge-delete-tool") && t.editor.mode.value === "edit" && (p.remove(), t.editor.executeCommand({
|
|
2642
|
-
id:
|
|
2647
|
+
id: ee(),
|
|
2643
2648
|
source: "user:toolbar",
|
|
2644
2649
|
label: "删除连线",
|
|
2645
2650
|
timestamp: Date.now(),
|
|
@@ -2656,35 +2661,35 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2656
2661
|
return;
|
|
2657
2662
|
}
|
|
2658
2663
|
b.leave(180), m.quickAddPopoverOpen.value || m.leave();
|
|
2659
|
-
},
|
|
2664
|
+
}, r.value?.addEventListener("mousemove", w), D = () => {
|
|
2660
2665
|
b.reset(), m.quickAddPopoverOpen.value || (m.quickAddNodeId.value = null);
|
|
2661
|
-
},
|
|
2666
|
+
}, r.value?.addEventListener("mouseleave", D), r.value?.addEventListener("keydown", Z);
|
|
2662
2667
|
}
|
|
2663
2668
|
function $e() {
|
|
2664
|
-
|
|
2669
|
+
he(
|
|
2665
2670
|
() => t.editor.flowModel.value,
|
|
2666
2671
|
(I) => a.syncFlowModel(I)
|
|
2667
|
-
),
|
|
2672
|
+
), he(
|
|
2668
2673
|
[() => t.editor.mode.value, () => t.editor.selectionMode.value],
|
|
2669
2674
|
([I, C]) => {
|
|
2670
|
-
|
|
2675
|
+
Q(I === "edit", C);
|
|
2671
2676
|
},
|
|
2672
2677
|
{ immediate: !0 }
|
|
2673
2678
|
);
|
|
2674
2679
|
}
|
|
2675
2680
|
dt(() => {
|
|
2676
|
-
if (!
|
|
2681
|
+
if (!i.value) return;
|
|
2677
2682
|
const I = /* @__PURE__ */ new Set(["model", "container"]), C = {};
|
|
2678
2683
|
if (t.graphOptions)
|
|
2679
|
-
for (const [$,
|
|
2684
|
+
for (const [$, ie] of Object.entries(t.graphOptions)) {
|
|
2680
2685
|
if (I.has($)) {
|
|
2681
2686
|
console.warn(`[flow-canvas] graphOptions.${$} is managed by the engine and will be ignored`);
|
|
2682
2687
|
continue;
|
|
2683
2688
|
}
|
|
2684
|
-
C[$] =
|
|
2689
|
+
C[$] = ie;
|
|
2685
2690
|
}
|
|
2686
2691
|
l = new Et({
|
|
2687
|
-
container:
|
|
2692
|
+
container: i.value,
|
|
2688
2693
|
autoResize: !0,
|
|
2689
2694
|
background: { color: "#edf2fc" },
|
|
2690
2695
|
grid: {
|
|
@@ -2744,25 +2749,25 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2744
2749
|
idGenerator: t.editor.idGenerator,
|
|
2745
2750
|
defaultInsertGap: t.nodeActions?.insertGap,
|
|
2746
2751
|
getContextMenuItems: ($) => t.editor._pluginManager.collectContextMenuItems($),
|
|
2747
|
-
onHighlightChange: ($,
|
|
2752
|
+
onHighlightChange: ($, ie) => {
|
|
2748
2753
|
a.setHighlightedNodes($);
|
|
2749
|
-
const
|
|
2754
|
+
const ve = a.setHighlightedEdges(ie);
|
|
2750
2755
|
a.refreshNodeHighlights();
|
|
2751
|
-
const
|
|
2752
|
-
for (const ye of
|
|
2753
|
-
|
|
2754
|
-
for (const ye of
|
|
2755
|
-
|
|
2756
|
+
const ae = new Set(ie);
|
|
2757
|
+
for (const ye of ve)
|
|
2758
|
+
ae.has(ye) || a.refreshSingleEdgeStyle(ye);
|
|
2759
|
+
for (const ye of ae)
|
|
2760
|
+
ve.has(ye) || a.refreshSingleEdgeStyle(ye);
|
|
2756
2761
|
},
|
|
2757
2762
|
resolveNodeShape: ($) => {
|
|
2758
|
-
const
|
|
2759
|
-
if (!
|
|
2760
|
-
const
|
|
2761
|
-
return { shapeName:
|
|
2763
|
+
const ie = t.editor.schema.nodeTypes[$];
|
|
2764
|
+
if (!ie) return null;
|
|
2765
|
+
const ve = h.registerNodeType($, ie.component), ae = ie.getSize({ id: "", type: $, position: { x: 0, y: 0 } });
|
|
2766
|
+
return { shapeName: ve, width: ae.width, height: ae.height };
|
|
2762
2767
|
}
|
|
2763
2768
|
});
|
|
2764
2769
|
t.editor.api.value = W;
|
|
2765
|
-
const
|
|
2770
|
+
const te = {
|
|
2766
2771
|
flowModel: t.editor.flowModel,
|
|
2767
2772
|
history: t.editor.history,
|
|
2768
2773
|
schema: t.editor.schema,
|
|
@@ -2774,10 +2779,10 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2774
2779
|
overlay: P,
|
|
2775
2780
|
graph: l
|
|
2776
2781
|
};
|
|
2777
|
-
t.editor._pluginManager.attachRuntime(
|
|
2778
|
-
const
|
|
2779
|
-
Object.assign(t.editor.extendedApi,
|
|
2780
|
-
t.editor._pluginManager.dispatchUiEvent($),
|
|
2782
|
+
t.editor._pluginManager.attachRuntime(te);
|
|
2783
|
+
const ce = t.editor._pluginManager.collectExtendedApi();
|
|
2784
|
+
Object.assign(t.editor.extendedApi, ce), t.editor._emitUiEvent = ($) => {
|
|
2785
|
+
t.editor._pluginManager.dispatchUiEvent($), s("ui-event", $);
|
|
2781
2786
|
}, f = new Xt(
|
|
2782
2787
|
l,
|
|
2783
2788
|
($) => {
|
|
@@ -2785,11 +2790,11 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2785
2790
|
},
|
|
2786
2791
|
($) => {
|
|
2787
2792
|
if (a.isSyncing) return;
|
|
2788
|
-
const
|
|
2789
|
-
if (t.editor.executeCommand(
|
|
2790
|
-
for (const
|
|
2791
|
-
if (
|
|
2792
|
-
const ye = l.getCellById(
|
|
2793
|
+
const ie = R.tryExpandForEdgeDrop($);
|
|
2794
|
+
if (t.editor.executeCommand(ie).status !== "applied") {
|
|
2795
|
+
for (const ae of ie.commands)
|
|
2796
|
+
if (ae.type === "edge.add") {
|
|
2797
|
+
const ye = l.getCellById(ae.edge.id);
|
|
2793
2798
|
ye && l.removeCell(ye);
|
|
2794
2799
|
}
|
|
2795
2800
|
}
|
|
@@ -2797,22 +2802,22 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2797
2802
|
t.editor.flowModel,
|
|
2798
2803
|
t.editor.idGenerator
|
|
2799
2804
|
), p = no(l);
|
|
2800
|
-
const
|
|
2801
|
-
m.attachRuntime(l, ($) =>
|
|
2805
|
+
const se = so(l);
|
|
2806
|
+
m.attachRuntime(l, ($) => se.hideNodePorts($)), R.attachRuntime(l), ne(se), re(se), O = vo(l.container);
|
|
2802
2807
|
let xe = /* @__PURE__ */ new Set(), be = /* @__PURE__ */ new Set();
|
|
2803
2808
|
l.on("selection:changed", () => {
|
|
2804
|
-
const $ = ft(l.getSelectedCells?.() ?? []),
|
|
2805
|
-
mo(l, xe,
|
|
2809
|
+
const $ = ft(l.getSelectedCells?.() ?? []), ie = new Set($.nodeIds);
|
|
2810
|
+
mo(l, xe, ie), xe = ie, X.value = $, t.editor._pluginManager.dispatchSelectionChange($), s("ui-event", {
|
|
2806
2811
|
type: "selection.change",
|
|
2807
2812
|
nodeIds: $.nodeIds,
|
|
2808
2813
|
edgeIds: $.edgeIds
|
|
2809
2814
|
}), a.refreshNodeHighlights();
|
|
2810
|
-
const
|
|
2811
|
-
for (const
|
|
2812
|
-
|
|
2813
|
-
for (const
|
|
2814
|
-
be.has(
|
|
2815
|
-
be =
|
|
2815
|
+
const ve = new Set($.edgeIds);
|
|
2816
|
+
for (const ae of be)
|
|
2817
|
+
ve.has(ae) || a.refreshSingleEdgeStyle(ae);
|
|
2818
|
+
for (const ae of ve)
|
|
2819
|
+
be.has(ae) || a.refreshSingleEdgeStyle(ae);
|
|
2820
|
+
be = ve;
|
|
2816
2821
|
});
|
|
2817
2822
|
const Be = () => {
|
|
2818
2823
|
k.value++;
|
|
@@ -2823,93 +2828,93 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2823
2828
|
b.reset(), m.quickAddNodeId.value = null, m.quickAddPopoverOpen.value = !1;
|
|
2824
2829
|
}
|
|
2825
2830
|
return e({ resetHoverState: Se }), Te(() => {
|
|
2826
|
-
b.cleanup(), m.cleanup(), R.cleanup(), p?.remove(), u && l?.container?.removeEventListener("mousemove", u), w &&
|
|
2831
|
+
b.cleanup(), m.cleanup(), R.cleanup(), p?.remove(), u && l?.container?.removeEventListener("mousemove", u), w && r.value?.removeEventListener("mousemove", w), D && r.value?.removeEventListener("mouseleave", D), O?.(), r.value?.removeEventListener("keydown", Z), t.editor._pluginManager.detachRuntime(), t.editor.api.value = null;
|
|
2827
2832
|
for (const I of Object.keys(t.editor.extendedApi))
|
|
2828
2833
|
delete t.editor.extendedApi[I];
|
|
2829
2834
|
f?.dispose(), a?.dispose(), h?.dispose(), l?.dispose();
|
|
2830
2835
|
}), (I, C) => (A(), T("div", {
|
|
2831
2836
|
ref_key: "rootRef",
|
|
2832
|
-
ref:
|
|
2833
|
-
class:
|
|
2837
|
+
ref: r,
|
|
2838
|
+
class: oe(["flow-canvas-runtime-core", { "flow-canvas-runtime-core--selection-mode": G.value }]),
|
|
2834
2839
|
tabindex: "0"
|
|
2835
2840
|
}, [
|
|
2836
|
-
|
|
2841
|
+
F("div", {
|
|
2837
2842
|
ref_key: "containerRef",
|
|
2838
|
-
ref:
|
|
2843
|
+
ref: i,
|
|
2839
2844
|
class: "flow-canvas-runtime-core__graph"
|
|
2840
2845
|
}, null, 512),
|
|
2841
|
-
|
|
2842
|
-
(A(!0), T(
|
|
2846
|
+
F("div", No, [
|
|
2847
|
+
(A(!0), T(ue, null, Ce(y.value, (P) => (A(), T("div", {
|
|
2843
2848
|
key: `badge-${P.nodeId}`,
|
|
2844
2849
|
class: "flow-canvas-runtime-core__badge",
|
|
2845
2850
|
style: Ee({ left: `${P.x}px`, top: `${P.y}px`, backgroundColor: P.badge.color })
|
|
2846
|
-
},
|
|
2847
|
-
|
|
2851
|
+
}, fe(P.badge.text), 5))), 128)),
|
|
2852
|
+
le(E) ? (A(), Ie(Co, {
|
|
2848
2853
|
key: 0,
|
|
2849
2854
|
ref_key: "quickAddPopoverRef",
|
|
2850
2855
|
ref: v,
|
|
2851
|
-
node:
|
|
2852
|
-
"port-position":
|
|
2853
|
-
"auto-pan-on-open":
|
|
2854
|
-
"auto-pan-padding":
|
|
2855
|
-
onOpen:
|
|
2856
|
-
onClose:
|
|
2857
|
-
onStartDrag:
|
|
2858
|
-
onViewportOverflowRight:
|
|
2859
|
-
onMouseenter:
|
|
2860
|
-
onMouseleave:
|
|
2856
|
+
node: le(E).node,
|
|
2857
|
+
"port-position": le(E).portPosition,
|
|
2858
|
+
"auto-pan-on-open": le(m).mergedConfig.value.autoPanOnOpen,
|
|
2859
|
+
"auto-pan-padding": le(m).mergedConfig.value.autoPanPadding,
|
|
2860
|
+
onOpen: le(L),
|
|
2861
|
+
onClose: de,
|
|
2862
|
+
onStartDrag: le(z),
|
|
2863
|
+
onViewportOverflowRight: le(m).handlePopoverViewportOverflow,
|
|
2864
|
+
onMouseenter: le(N),
|
|
2865
|
+
onMouseleave: le(_)
|
|
2861
2866
|
}, {
|
|
2862
2867
|
default: He(() => [
|
|
2863
2868
|
Me(I.$slots, "quick-add-panel", {
|
|
2864
|
-
node:
|
|
2865
|
-
api:
|
|
2866
|
-
insertNodeToRight: (P) =>
|
|
2869
|
+
node: le(E).node,
|
|
2870
|
+
api: n.editor.api.value,
|
|
2871
|
+
insertNodeToRight: (P) => le(x)(le(E).node.id, P),
|
|
2867
2872
|
closePopover: () => v.value?.closePopover()
|
|
2868
2873
|
}, void 0, !0)
|
|
2869
2874
|
]),
|
|
2870
2875
|
_: 3
|
|
2871
|
-
}, 8, ["node", "port-position", "auto-pan-on-open", "auto-pan-padding", "onOpen", "onStartDrag", "onViewportOverflowRight", "onMouseenter", "onMouseleave"])) :
|
|
2872
|
-
c.value ? (A(),
|
|
2876
|
+
}, 8, ["node", "port-position", "auto-pan-on-open", "auto-pan-padding", "onOpen", "onStartDrag", "onViewportOverflowRight", "onMouseenter", "onMouseleave"])) : K("", !0),
|
|
2877
|
+
c.value ? (A(), Ie(bo, {
|
|
2873
2878
|
key: 1,
|
|
2874
2879
|
node: c.value.node,
|
|
2875
2880
|
position: c.value.position,
|
|
2876
2881
|
config: d.value,
|
|
2877
2882
|
behavior: c.value.behavior,
|
|
2878
2883
|
"actions-offset": c.value.behavior.actionsOffset,
|
|
2879
|
-
onAction:
|
|
2880
|
-
onMouseenter:
|
|
2884
|
+
onAction: Y,
|
|
2885
|
+
onMouseenter: le(B),
|
|
2881
2886
|
onMouseleave: j
|
|
2882
|
-
}, null, 8, ["node", "position", "config", "behavior", "actions-offset", "onMouseenter"])) :
|
|
2883
|
-
g.value ? (A(),
|
|
2887
|
+
}, null, 8, ["node", "position", "config", "behavior", "actions-offset", "onMouseenter"])) : K("", !0),
|
|
2888
|
+
g.value ? (A(), Ie(Mo, {
|
|
2884
2889
|
key: 2,
|
|
2885
2890
|
position: g.value.position,
|
|
2886
2891
|
"can-delete": g.value.canDelete,
|
|
2887
|
-
onAction:
|
|
2888
|
-
}, null, 8, ["position", "can-delete"])) :
|
|
2892
|
+
onAction: J
|
|
2893
|
+
}, null, 8, ["position", "can-delete"])) : K("", !0)
|
|
2889
2894
|
])
|
|
2890
2895
|
], 2));
|
|
2891
2896
|
}
|
|
2892
|
-
}), Dn = /* @__PURE__ */
|
|
2897
|
+
}), Dn = /* @__PURE__ */ me(Do, [["__scopeId", "data-v-84584822"]]), Ao = { class: "flow-canvas-node-palette" }, _o = ["data-node-type"], Po = { class: "flow-canvas-node-palette__item-label" }, To = /* @__PURE__ */ pe({
|
|
2893
2898
|
__name: "canvas-node-palette",
|
|
2894
2899
|
props: {
|
|
2895
2900
|
editor: {},
|
|
2896
2901
|
items: {}
|
|
2897
2902
|
},
|
|
2898
|
-
setup(
|
|
2899
|
-
const e =
|
|
2900
|
-
type:
|
|
2901
|
-
label:
|
|
2903
|
+
setup(n) {
|
|
2904
|
+
const e = n, o = H(), t = V(() => e.items ? e.items : Object.keys(e.editor.schema.nodeTypes).map((s) => ({
|
|
2905
|
+
type: s,
|
|
2906
|
+
label: s.charAt(0).toUpperCase() + s.slice(1)
|
|
2902
2907
|
})));
|
|
2903
|
-
return
|
|
2908
|
+
return he(
|
|
2904
2909
|
[() => e.editor.api.value, t, o],
|
|
2905
|
-
([
|
|
2906
|
-
if (!
|
|
2910
|
+
([s, r, i], l, a) => {
|
|
2911
|
+
if (!s || !i) return;
|
|
2907
2912
|
const h = [];
|
|
2908
|
-
for (const f of
|
|
2909
|
-
const p =
|
|
2913
|
+
for (const f of r) {
|
|
2914
|
+
const p = i.querySelector(`[data-node-type="${f.type}"]`);
|
|
2910
2915
|
if (!p) continue;
|
|
2911
|
-
const u =
|
|
2912
|
-
id:
|
|
2916
|
+
const u = s.registerDndSource(p, () => ({
|
|
2917
|
+
id: ee(),
|
|
2913
2918
|
type: f.type,
|
|
2914
2919
|
label: f.label,
|
|
2915
2920
|
position: { x: 0, y: 0 }
|
|
@@ -2921,30 +2926,30 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2921
2926
|
});
|
|
2922
2927
|
},
|
|
2923
2928
|
{ flush: "post" }
|
|
2924
|
-
), (
|
|
2925
|
-
|
|
2929
|
+
), (s, r) => (A(), T("div", Ao, [
|
|
2930
|
+
F("div", {
|
|
2926
2931
|
ref_key: "listRef",
|
|
2927
2932
|
ref: o,
|
|
2928
2933
|
class: "flow-canvas-node-palette__list"
|
|
2929
2934
|
}, [
|
|
2930
|
-
(A(!0), T(
|
|
2931
|
-
key:
|
|
2935
|
+
(A(!0), T(ue, null, Ce(t.value, (i) => (A(), T("div", {
|
|
2936
|
+
key: i.type,
|
|
2932
2937
|
class: "flow-canvas-node-palette__item",
|
|
2933
|
-
"data-node-type":
|
|
2938
|
+
"data-node-type": i.type
|
|
2934
2939
|
}, [
|
|
2935
|
-
|
|
2940
|
+
i.icon ? (A(), T("i", {
|
|
2936
2941
|
key: 0,
|
|
2937
|
-
class:
|
|
2938
|
-
}, null, 2)) :
|
|
2939
|
-
|
|
2942
|
+
class: oe([i.icon, "flow-canvas-node-palette__item-icon"])
|
|
2943
|
+
}, null, 2)) : K("", !0),
|
|
2944
|
+
F("span", Po, fe(i.label), 1)
|
|
2940
2945
|
], 8, _o))), 128))
|
|
2941
2946
|
], 512)
|
|
2942
2947
|
]));
|
|
2943
2948
|
}
|
|
2944
|
-
}), Ro = /* @__PURE__ */
|
|
2949
|
+
}), Ro = /* @__PURE__ */ me(To, [["__scopeId", "data-v-300314b7"]]), Lo = { class: "flow-canvas-layout" }, Oo = { class: "flow-canvas-layout__main" }, $o = { class: "flow-canvas-layout__content" }, Bo = {
|
|
2945
2950
|
key: 0,
|
|
2946
2951
|
class: "flow-canvas-layout__footer"
|
|
2947
|
-
}, Fo = /* @__PURE__ */
|
|
2952
|
+
}, Fo = /* @__PURE__ */ pe({
|
|
2948
2953
|
__name: "canvas-layout",
|
|
2949
2954
|
props: {
|
|
2950
2955
|
sidebarCollapsed: { type: Boolean, default: !1 },
|
|
@@ -2955,34 +2960,34 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2955
2960
|
paletteItems: { default: void 0 }
|
|
2956
2961
|
},
|
|
2957
2962
|
emits: ["update:sidebarCollapsed"],
|
|
2958
|
-
setup(
|
|
2963
|
+
setup(n) {
|
|
2959
2964
|
return (e, o) => (A(), T("div", Lo, [
|
|
2960
|
-
!
|
|
2965
|
+
!n.hideSidebar && (e.$slots.sidebar || n.editor) ? (A(), T("aside", {
|
|
2961
2966
|
key: 0,
|
|
2962
|
-
class:
|
|
2963
|
-
style: Ee({ width:
|
|
2967
|
+
class: oe(["flow-canvas-layout__sidebar", { "is-collapsed": n.sidebarCollapsed }]),
|
|
2968
|
+
style: Ee({ width: n.sidebarCollapsed ? "0px" : `${n.sidebarWidth}px` })
|
|
2964
2969
|
}, [
|
|
2965
2970
|
Me(e.$slots, "sidebar", {}, () => [
|
|
2966
|
-
|
|
2971
|
+
n.editor ? (A(), Ie(Ro, {
|
|
2967
2972
|
key: 0,
|
|
2968
|
-
editor:
|
|
2969
|
-
items:
|
|
2970
|
-
}, null, 8, ["editor", "items"])) :
|
|
2973
|
+
editor: n.editor,
|
|
2974
|
+
items: n.paletteItems
|
|
2975
|
+
}, null, 8, ["editor", "items"])) : K("", !0)
|
|
2971
2976
|
], !0)
|
|
2972
|
-
], 6)) :
|
|
2973
|
-
|
|
2974
|
-
|
|
2977
|
+
], 6)) : K("", !0),
|
|
2978
|
+
F("div", Oo, [
|
|
2979
|
+
F("div", $o, [
|
|
2975
2980
|
Me(e.$slots, "default", {}, void 0, !0)
|
|
2976
2981
|
]),
|
|
2977
|
-
!
|
|
2982
|
+
!n.hideFooter && e.$slots.footer ? (A(), T("div", Bo, [
|
|
2978
2983
|
Me(e.$slots, "footer", {}, void 0, !0)
|
|
2979
|
-
])) :
|
|
2984
|
+
])) : K("", !0)
|
|
2980
2985
|
])
|
|
2981
2986
|
]));
|
|
2982
2987
|
}
|
|
2983
|
-
}), An = /* @__PURE__ */
|
|
2984
|
-
function Ho(
|
|
2985
|
-
const e = new Set(
|
|
2988
|
+
}), An = /* @__PURE__ */ me(Fo, [["__scopeId", "data-v-26f35b6b"]]), et = typeof navigator < "u" && /Mac|iPod|iPhone|iPad/.test(navigator.platform ?? navigator.userAgent), qo = ["undo", "redo"];
|
|
2989
|
+
function Ho(n) {
|
|
2990
|
+
const e = new Set(n?.include), o = new Set(qo.filter((a) => !e.has(a))), t = [
|
|
2986
2991
|
{
|
|
2987
2992
|
id: "undo",
|
|
2988
2993
|
type: "undo",
|
|
@@ -3001,7 +3006,7 @@ function Ho(s) {
|
|
|
3001
3006
|
shortcut: et ? ["⇧", "⌘", "Z"] : ["Ctrl", "Shift", "Z"],
|
|
3002
3007
|
order: 11
|
|
3003
3008
|
}
|
|
3004
|
-
],
|
|
3009
|
+
], s = [
|
|
3005
3010
|
{
|
|
3006
3011
|
id: "select",
|
|
3007
3012
|
type: "select",
|
|
@@ -3026,7 +3031,7 @@ function Ho(s) {
|
|
|
3026
3031
|
description: "下载",
|
|
3027
3032
|
order: 24
|
|
3028
3033
|
}
|
|
3029
|
-
],
|
|
3034
|
+
], r = [
|
|
3030
3035
|
{
|
|
3031
3036
|
id: "zoom-out",
|
|
3032
3037
|
type: "zoom-out",
|
|
@@ -3044,7 +3049,7 @@ function Ho(s) {
|
|
|
3044
3049
|
description: "放大画布",
|
|
3045
3050
|
order: 32
|
|
3046
3051
|
}
|
|
3047
|
-
],
|
|
3052
|
+
], i = [
|
|
3048
3053
|
{
|
|
3049
3054
|
id: "reset",
|
|
3050
3055
|
type: "reset",
|
|
@@ -3054,9 +3059,9 @@ function Ho(s) {
|
|
|
3054
3059
|
order: 40
|
|
3055
3060
|
}
|
|
3056
3061
|
];
|
|
3057
|
-
return [...[...t, ...
|
|
3062
|
+
return [...[...t, ...s].filter(
|
|
3058
3063
|
(a) => !o.has(a.type)
|
|
3059
|
-
), ...
|
|
3064
|
+
), ...r, ...i];
|
|
3060
3065
|
}
|
|
3061
3066
|
const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
3062
3067
|
key: 0,
|
|
@@ -3067,7 +3072,7 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3067
3072
|
}, Wo = ["data-toolbar-id", "data-toolbar-type", "disabled", "onClick", "onMouseenter"], Vo = ["textContent"], Xo = {
|
|
3068
3073
|
key: 0,
|
|
3069
3074
|
class: "flow-canvas-toolbar-tooltip__kbd"
|
|
3070
|
-
}, Ko = /* @__PURE__ */
|
|
3075
|
+
}, Ko = /* @__PURE__ */ pe({
|
|
3071
3076
|
__name: "canvas-toolbar",
|
|
3072
3077
|
props: {
|
|
3073
3078
|
items: {},
|
|
@@ -3075,7 +3080,7 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3075
3080
|
include: {},
|
|
3076
3081
|
editor: {}
|
|
3077
3082
|
},
|
|
3078
|
-
setup(
|
|
3083
|
+
setup(n) {
|
|
3079
3084
|
const e = /* @__PURE__ */ new Set([
|
|
3080
3085
|
"undo",
|
|
3081
3086
|
"redo",
|
|
@@ -3088,12 +3093,12 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3088
3093
|
function t(c) {
|
|
3089
3094
|
return c.id.startsWith("plugin:") || c.type === "custom";
|
|
3090
3095
|
}
|
|
3091
|
-
function
|
|
3096
|
+
function s(c) {
|
|
3092
3097
|
return c !== "custom" && o.has(c);
|
|
3093
3098
|
}
|
|
3094
|
-
const
|
|
3095
|
-
if (
|
|
3096
|
-
const c = Ho({ include:
|
|
3099
|
+
const r = n, i = V(() => {
|
|
3100
|
+
if (r.items) return r.items;
|
|
3101
|
+
const c = Ho({ include: r.include }), g = r.editor.toolbarItems.value, v = new Set(r.exclude ?? []), m = /* @__PURE__ */ new Map();
|
|
3097
3102
|
for (const E of c)
|
|
3098
3103
|
m.set(E.id, E);
|
|
3099
3104
|
for (const E of g) {
|
|
@@ -3103,8 +3108,8 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3103
3108
|
return [...m.values()].filter((E) => E.type === "custom" || !e.has(E.type) ? !0 : !v.has(E.type)).sort((E, L) => (E.order ?? 0) - (L.order ?? 0));
|
|
3104
3109
|
}), l = H(1), a = H(null), h = H(null), f = H(!1);
|
|
3105
3110
|
let p = null;
|
|
3106
|
-
|
|
3107
|
-
() =>
|
|
3111
|
+
he(
|
|
3112
|
+
() => r.editor.api.value,
|
|
3108
3113
|
(c) => {
|
|
3109
3114
|
p?.(), p = null, c && (l.value = c.getZoom(), p = c.onGraphEvent("scale", () => {
|
|
3110
3115
|
l.value = c.getZoom();
|
|
@@ -3124,62 +3129,62 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3124
3129
|
function D() {
|
|
3125
3130
|
u.visible = !1, a.value = null;
|
|
3126
3131
|
}
|
|
3127
|
-
|
|
3132
|
+
it(() => {
|
|
3128
3133
|
p?.();
|
|
3129
3134
|
});
|
|
3130
|
-
const O = V(() => `${Math.round(l.value * 100)}%`), b = V(() =>
|
|
3131
|
-
api:
|
|
3132
|
-
flowModel:
|
|
3133
|
-
history:
|
|
3134
|
-
mode:
|
|
3135
|
+
const O = V(() => `${Math.round(l.value * 100)}%`), b = V(() => r.editor.api.value ? {
|
|
3136
|
+
api: r.editor.api.value,
|
|
3137
|
+
flowModel: r.editor.flowModel.value,
|
|
3138
|
+
history: r.editor.history,
|
|
3139
|
+
mode: r.editor.mode.value
|
|
3135
3140
|
} : null);
|
|
3136
3141
|
function S(c) {
|
|
3137
3142
|
return c.visible === !1 ? !1 : typeof c.visible == "function" ? b.value ? c.visible(b.value) : !1 : !0;
|
|
3138
3143
|
}
|
|
3139
3144
|
function M(c) {
|
|
3140
|
-
return typeof c.active == "function" ? b.value ? c.active(b.value) : !1 : c.active !== void 0 ? c.active : c.type === "select" ?
|
|
3145
|
+
return typeof c.active == "function" ? b.value ? c.active(b.value) : !1 : c.active !== void 0 ? c.active : c.type === "select" ? r.editor.selectionMode.value : !1;
|
|
3141
3146
|
}
|
|
3142
3147
|
const B = V(() => {
|
|
3143
3148
|
const c = d.value.filter(
|
|
3144
|
-
(v) =>
|
|
3149
|
+
(v) => s(v.type) && M(v)
|
|
3145
3150
|
);
|
|
3146
3151
|
if (c.length === 0) return null;
|
|
3147
3152
|
const g = h.value;
|
|
3148
3153
|
return g && c.some((v) => v.type === g) ? g : c[0]?.type ?? null;
|
|
3149
3154
|
});
|
|
3150
3155
|
function j(c) {
|
|
3151
|
-
return
|
|
3156
|
+
return s(c.type) ? B.value === c.type : M(c);
|
|
3152
3157
|
}
|
|
3153
3158
|
function k(c) {
|
|
3154
|
-
return !b.value || c.disabled === !0 ? !0 : typeof c.disabled == "function" ? c.disabled(b.value) : c.type === "undo" ? !
|
|
3159
|
+
return !b.value || c.disabled === !0 ? !0 : typeof c.disabled == "function" ? c.disabled(b.value) : c.type === "undo" ? !r.editor.history.canUndo.value : c.type === "redo" ? !r.editor.history.canRedo.value : c.type === "export" ? f.value : !1;
|
|
3155
3160
|
}
|
|
3156
3161
|
function X(c) {
|
|
3157
|
-
if (!(!b.value || !
|
|
3162
|
+
if (!(!b.value || !s(c.type) || !M(c))) {
|
|
3158
3163
|
if (c.type === "select") {
|
|
3159
|
-
|
|
3164
|
+
r.editor.setSelectionMode(!1);
|
|
3160
3165
|
return;
|
|
3161
3166
|
}
|
|
3162
3167
|
c.onClick?.(b.value);
|
|
3163
3168
|
}
|
|
3164
3169
|
}
|
|
3165
3170
|
function U(c) {
|
|
3166
|
-
if (
|
|
3171
|
+
if (s(c.type))
|
|
3167
3172
|
for (const g of d.value)
|
|
3168
|
-
!
|
|
3173
|
+
!s(g.type) || g.id === c.id || X(g);
|
|
3169
3174
|
}
|
|
3170
3175
|
function G(c) {
|
|
3171
3176
|
if (!b.value || k(c)) return;
|
|
3172
|
-
if (
|
|
3177
|
+
if (s(c.type) && (h.value = c.type, U(c)), c.onClick) {
|
|
3173
3178
|
c.onClick(b.value);
|
|
3174
3179
|
return;
|
|
3175
3180
|
}
|
|
3176
3181
|
const { api: g } = b.value;
|
|
3177
3182
|
switch (c.type) {
|
|
3178
3183
|
case "undo":
|
|
3179
|
-
|
|
3184
|
+
r.editor.history.undo();
|
|
3180
3185
|
break;
|
|
3181
3186
|
case "redo":
|
|
3182
|
-
|
|
3187
|
+
r.editor.history.redo();
|
|
3183
3188
|
break;
|
|
3184
3189
|
case "zoom-in":
|
|
3185
3190
|
g.zoomIn(), l.value = g.getZoom();
|
|
@@ -3205,10 +3210,10 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3205
3210
|
});
|
|
3206
3211
|
break;
|
|
3207
3212
|
case "select":
|
|
3208
|
-
|
|
3213
|
+
r.editor.setSelectionMode(!r.editor.selectionMode.value);
|
|
3209
3214
|
break;
|
|
3210
3215
|
case "auto-layout":
|
|
3211
|
-
|
|
3216
|
+
r.editor._emitUiEvent({ type: "toolbar.auto-layout" });
|
|
3212
3217
|
break;
|
|
3213
3218
|
case "search":
|
|
3214
3219
|
case "minimap":
|
|
@@ -3219,7 +3224,7 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3219
3224
|
break;
|
|
3220
3225
|
}
|
|
3221
3226
|
}
|
|
3222
|
-
const d = V(() =>
|
|
3227
|
+
const d = V(() => i.value.filter(S)), y = V(() => {
|
|
3223
3228
|
const c = /* @__PURE__ */ new Map(), g = [];
|
|
3224
3229
|
for (const v of d.value) {
|
|
3225
3230
|
const m = v.group ?? "default";
|
|
@@ -3228,18 +3233,18 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3228
3233
|
return g.map((v) => ({ name: v, items: c.get(v) })).filter((v) => v.items.length > 0);
|
|
3229
3234
|
});
|
|
3230
3235
|
return (c, g) => (A(), T("div", Go, [
|
|
3231
|
-
(A(!0), T(
|
|
3236
|
+
(A(!0), T(ue, null, Ce(y.value, (v, m) => (A(), T(ue, {
|
|
3232
3237
|
key: v.name
|
|
3233
3238
|
}, [
|
|
3234
|
-
m > 0 ? (A(), T("div", zo)) :
|
|
3235
|
-
|
|
3236
|
-
(A(!0), T(
|
|
3239
|
+
m > 0 ? (A(), T("div", zo)) : K("", !0),
|
|
3240
|
+
F("div", Uo, [
|
|
3241
|
+
(A(!0), T(ue, null, Ce(v.items, (E) => (A(), T(ue, {
|
|
3237
3242
|
key: E.id
|
|
3238
3243
|
}, [
|
|
3239
|
-
E.type === "zoom-display" ? (A(), T("span", jo,
|
|
3244
|
+
E.type === "zoom-display" ? (A(), T("span", jo, fe(O.value), 1)) : (A(), T("button", {
|
|
3240
3245
|
key: 1,
|
|
3241
3246
|
type: "button",
|
|
3242
|
-
class:
|
|
3247
|
+
class: oe(["flow-canvas-toolbar__btn", {
|
|
3243
3248
|
"is-disabled": k(E),
|
|
3244
3249
|
"is-active": j(E),
|
|
3245
3250
|
"is-exporting": E.type === "export" && f.value
|
|
@@ -3251,19 +3256,19 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3251
3256
|
onMouseenter: (L) => w(L, E),
|
|
3252
3257
|
onMouseleave: D
|
|
3253
3258
|
}, [
|
|
3254
|
-
E.component ? (A(),
|
|
3259
|
+
E.component ? (A(), Ie(mt(E.component), { key: 0 })) : E.icon ? (A(), T("i", {
|
|
3255
3260
|
key: 1,
|
|
3256
|
-
class:
|
|
3261
|
+
class: oe(E.icon)
|
|
3257
3262
|
}, null, 2)) : (A(), T("span", {
|
|
3258
3263
|
key: 2,
|
|
3259
3264
|
class: "flow-canvas-toolbar__text",
|
|
3260
|
-
textContent:
|
|
3265
|
+
textContent: fe(E.text ?? E.description ?? E.id)
|
|
3261
3266
|
}, null, 8, Vo))
|
|
3262
3267
|
], 42, Wo))
|
|
3263
3268
|
], 64))), 128))
|
|
3264
3269
|
])
|
|
3265
3270
|
], 64))), 128)),
|
|
3266
|
-
(A(),
|
|
3271
|
+
(A(), Ie(yt, { to: "body" }, [
|
|
3267
3272
|
u.visible ? (A(), T("div", {
|
|
3268
3273
|
key: 0,
|
|
3269
3274
|
ref_key: "tooltipRef",
|
|
@@ -3271,58 +3276,58 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3271
3276
|
class: "flow-canvas-toolbar-tooltip",
|
|
3272
3277
|
style: Ee({ left: `${u.x}px`, top: `${u.y}px` })
|
|
3273
3278
|
}, [
|
|
3274
|
-
|
|
3279
|
+
F("span", null, fe(u.text), 1),
|
|
3275
3280
|
u.shortcut.length ? (A(), T("kbd", Xo, [
|
|
3276
|
-
(A(!0), T(
|
|
3277
|
-
])) :
|
|
3278
|
-
g[0] || (g[0] =
|
|
3279
|
-
], 4)) :
|
|
3281
|
+
(A(!0), T(ue, null, Ce(u.shortcut, (v, m) => (A(), T("span", { key: m }, fe(v), 1))), 128))
|
|
3282
|
+
])) : K("", !0),
|
|
3283
|
+
g[0] || (g[0] = F("div", { class: "flow-canvas-toolbar-tooltip__arrow" }, null, -1))
|
|
3284
|
+
], 4)) : K("", !0)
|
|
3280
3285
|
]))
|
|
3281
3286
|
]));
|
|
3282
3287
|
}
|
|
3283
|
-
}), _n = /* @__PURE__ */
|
|
3288
|
+
}), _n = /* @__PURE__ */ me(Ko, [["__scopeId", "data-v-904248f4"]]), Yo = { class: "flow-canvas-default-node__ep-label" }, Zo = {
|
|
3284
3289
|
key: 1,
|
|
3285
3290
|
class: "flow-canvas-default-node__diamond flow-canvas-highlight-target"
|
|
3286
3291
|
}, Qo = {
|
|
3287
3292
|
key: 2,
|
|
3288
3293
|
class: "flow-canvas-default-node__task-label"
|
|
3289
|
-
}, Jo = /* @__PURE__ */
|
|
3294
|
+
}, Jo = /* @__PURE__ */ pe({
|
|
3290
3295
|
__name: "default-node",
|
|
3291
|
-
setup(
|
|
3292
|
-
const o = wt("getNode")?.(), t = V(() => o?.getData?.() ?? null),
|
|
3296
|
+
setup(n) {
|
|
3297
|
+
const o = wt("getNode")?.(), t = V(() => o?.getData?.() ?? null), s = V(() => t.value?.label || t.value?.type || ""), r = {
|
|
3293
3298
|
start: "canvas-kaishi",
|
|
3294
3299
|
end: "canvas-stop",
|
|
3295
3300
|
"parallel-gateway": "canvas-bingxingwangguan",
|
|
3296
3301
|
"branch-gateway": "canvas-fenzhiwangguan",
|
|
3297
3302
|
"converge-gateway": "canvas-huijuwangguan",
|
|
3298
3303
|
"conditional-parallel-gateway": "canvas-tiaojianbingxingwangguan"
|
|
3299
|
-
},
|
|
3304
|
+
}, i = /* @__PURE__ */ new Set(["start", "end"]), l = /* @__PURE__ */ new Set([
|
|
3300
3305
|
"parallel-gateway",
|
|
3301
3306
|
"branch-gateway",
|
|
3302
3307
|
"converge-gateway",
|
|
3303
3308
|
"conditional-parallel-gateway"
|
|
3304
3309
|
]), a = V(() => {
|
|
3305
3310
|
const f = t.value?.type ?? "";
|
|
3306
|
-
return
|
|
3307
|
-
}), h = V(() =>
|
|
3311
|
+
return i.has(f) ? "endpoint" : l.has(f) ? "gateway" : "task";
|
|
3312
|
+
}), h = V(() => r[t.value?.type ?? ""] ?? "");
|
|
3308
3313
|
return (f, p) => (A(), T("div", {
|
|
3309
|
-
class:
|
|
3314
|
+
class: oe(["flow-canvas-default-node", [`is-${a.value}`, { "flow-canvas-highlight-target": a.value !== "gateway" }]])
|
|
3310
3315
|
}, [
|
|
3311
|
-
a.value === "endpoint" ? (A(), T(
|
|
3316
|
+
a.value === "endpoint" ? (A(), T(ue, { key: 0 }, [
|
|
3312
3317
|
h.value ? (A(), T("i", {
|
|
3313
3318
|
key: 0,
|
|
3314
|
-
class:
|
|
3315
|
-
}, null, 2)) :
|
|
3316
|
-
|
|
3319
|
+
class: oe([["flow-canvas-icon", h.value], "flow-canvas-default-node__ep-icon"])
|
|
3320
|
+
}, null, 2)) : K("", !0),
|
|
3321
|
+
F("span", Yo, fe(s.value), 1)
|
|
3317
3322
|
], 64)) : a.value === "gateway" ? (A(), T("div", Zo, [
|
|
3318
3323
|
h.value ? (A(), T("i", {
|
|
3319
3324
|
key: 0,
|
|
3320
|
-
class:
|
|
3321
|
-
}, null, 2)) :
|
|
3322
|
-
])) : (A(), T("span", Qo,
|
|
3325
|
+
class: oe([["flow-canvas-icon", h.value], "flow-canvas-default-node__gw-icon"])
|
|
3326
|
+
}, null, 2)) : K("", !0)
|
|
3327
|
+
])) : (A(), T("span", Qo, fe(s.value), 1))
|
|
3323
3328
|
], 2));
|
|
3324
3329
|
}
|
|
3325
|
-
}), en = /* @__PURE__ */
|
|
3330
|
+
}), en = /* @__PURE__ */ me(Jo, [["__scopeId", "data-v-f0e24a9f"]]), tn = {
|
|
3326
3331
|
start: { label: "开始", icon: "flow-canvas-icon canvas-kaishi", width: 88, height: 40 },
|
|
3327
3332
|
end: { label: "结束", icon: "flow-canvas-icon canvas-stop", width: 88, height: 40 },
|
|
3328
3333
|
empty: { label: "空节点", icon: "flow-canvas-icon canvas-jiedi", width: 240, height: 48 },
|
|
@@ -3335,7 +3340,7 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3335
3340
|
width: 64,
|
|
3336
3341
|
height: 64
|
|
3337
3342
|
}
|
|
3338
|
-
}, tt = (
|
|
3343
|
+
}, tt = (n, e) => ({
|
|
3339
3344
|
stroke: e.hovered ? "#3a84ff" : "#abb5cc",
|
|
3340
3345
|
strokeWidth: 2
|
|
3341
3346
|
});
|
|
@@ -3365,47 +3370,47 @@ function on() {
|
|
|
3365
3370
|
}
|
|
3366
3371
|
};
|
|
3367
3372
|
}
|
|
3368
|
-
function Pn(
|
|
3369
|
-
const e =
|
|
3370
|
-
for (const [
|
|
3373
|
+
function Pn(n) {
|
|
3374
|
+
const e = n?.nodeTypes ?? tn, o = {}, t = [];
|
|
3375
|
+
for (const [i, l] of Object.entries(e)) {
|
|
3371
3376
|
const a = l.width ?? 150, h = l.height ?? 50;
|
|
3372
|
-
o[
|
|
3377
|
+
o[i] = {
|
|
3373
3378
|
component: en,
|
|
3374
3379
|
getSize: () => ({ width: a, height: h }),
|
|
3375
3380
|
getPorts: () => ut()
|
|
3376
3381
|
}, t.push({
|
|
3377
|
-
type:
|
|
3378
|
-
label: l.label ??
|
|
3382
|
+
type: i,
|
|
3383
|
+
label: l.label ?? i,
|
|
3379
3384
|
icon: l.icon
|
|
3380
3385
|
});
|
|
3381
3386
|
}
|
|
3382
|
-
const
|
|
3387
|
+
const s = {
|
|
3383
3388
|
...on(),
|
|
3384
|
-
...
|
|
3385
|
-
},
|
|
3389
|
+
...n?.edgeTypes
|
|
3390
|
+
}, r = n?.defaultEdgeType ?? "manhattan";
|
|
3386
3391
|
return {
|
|
3387
|
-
schema: { nodeTypes: o, defaultEdgeType:
|
|
3392
|
+
schema: { nodeTypes: o, defaultEdgeType: r, edgeTypes: s },
|
|
3388
3393
|
paletteItems: t
|
|
3389
3394
|
};
|
|
3390
3395
|
}
|
|
3391
|
-
function Tn(
|
|
3396
|
+
function Tn(n) {
|
|
3392
3397
|
return {
|
|
3393
3398
|
name: "connection-validator",
|
|
3394
3399
|
priority: 10,
|
|
3395
3400
|
transformCommand(e, o, t) {
|
|
3396
|
-
const
|
|
3397
|
-
for (const
|
|
3398
|
-
|
|
3399
|
-
for (const
|
|
3400
|
-
if (
|
|
3401
|
-
const
|
|
3401
|
+
const s = /* @__PURE__ */ new Set();
|
|
3402
|
+
for (const r of e.commands)
|
|
3403
|
+
r.type === "edge.remove" && s.add(r.edgeId);
|
|
3404
|
+
for (const r of e.commands) {
|
|
3405
|
+
if (r.type !== "edge.add" && r.type !== "edge.reconnect") continue;
|
|
3406
|
+
const i = t.flowModel.value, l = r.type === "edge.add" ? r.edge.source.nodeId : r.source?.nodeId, a = r.type === "edge.add" ? r.edge.target.nodeId : r.target?.nodeId;
|
|
3402
3407
|
if (!l || !a) continue;
|
|
3403
|
-
const h =
|
|
3408
|
+
const h = i.nodes[l], f = i.nodes[a];
|
|
3404
3409
|
if (!h || !f) continue;
|
|
3405
|
-
const p =
|
|
3406
|
-
(M) => M.id !== O && !
|
|
3407
|
-
), S =
|
|
3408
|
-
flowModel:
|
|
3410
|
+
const p = r.type === "edge.add" ? r.edge.source.portId : r.source?.portId, u = r.type === "edge.add" ? r.edge.target.portId : r.target?.portId, w = p ? h.ports?.find((M) => M.id === p) : void 0, D = u ? f.ports?.find((M) => M.id === u) : void 0, O = r.type === "edge.reconnect" ? r.edgeId : void 0, b = Object.values(i.edges).filter(
|
|
3411
|
+
(M) => M.id !== O && !s.has(M.id)
|
|
3412
|
+
), S = n({
|
|
3413
|
+
flowModel: i,
|
|
3409
3414
|
sourceNode: h,
|
|
3410
3415
|
targetNode: f,
|
|
3411
3416
|
sourcePort: w,
|
|
@@ -3423,13 +3428,13 @@ function Tn(s) {
|
|
|
3423
3428
|
}
|
|
3424
3429
|
};
|
|
3425
3430
|
}
|
|
3426
|
-
function Rn(
|
|
3427
|
-
const { rubberband: e = !0, multiple: o = !0, movable: t = !0 } =
|
|
3431
|
+
function Rn(n) {
|
|
3432
|
+
const { rubberband: e = !0, multiple: o = !0, movable: t = !0 } = n ?? {};
|
|
3428
3433
|
return {
|
|
3429
3434
|
name: "selection",
|
|
3430
3435
|
priority: 90,
|
|
3431
|
-
attachRuntime(
|
|
3432
|
-
|
|
3436
|
+
attachRuntime(s) {
|
|
3437
|
+
s.graph.use(
|
|
3433
3438
|
new It({
|
|
3434
3439
|
enabled: !0,
|
|
3435
3440
|
rubberband: e,
|
|
@@ -3437,22 +3442,22 @@ function Rn(s) {
|
|
|
3437
3442
|
movable: t,
|
|
3438
3443
|
pointerEvents: "none",
|
|
3439
3444
|
showNodeSelectionBox: !0,
|
|
3440
|
-
filter: (
|
|
3445
|
+
filter: (r) => !(r.isNode() && (r.getData?.() ?? {})._selectable === !1)
|
|
3441
3446
|
})
|
|
3442
3447
|
);
|
|
3443
3448
|
}
|
|
3444
3449
|
};
|
|
3445
3450
|
}
|
|
3446
|
-
function Ln(
|
|
3447
|
-
const { tolerance: e = 10, color: o = "#3a84ff" } =
|
|
3451
|
+
function Ln(n) {
|
|
3452
|
+
const { tolerance: e = 10, color: o = "#3a84ff" } = n ?? {};
|
|
3448
3453
|
let t = null;
|
|
3449
3454
|
return {
|
|
3450
3455
|
name: "snapline",
|
|
3451
3456
|
priority: 90,
|
|
3452
|
-
async attachRuntime(
|
|
3453
|
-
const { Snapline:
|
|
3454
|
-
|
|
3455
|
-
new
|
|
3457
|
+
async attachRuntime(s) {
|
|
3458
|
+
const { Snapline: r } = await import("@antv/x6-plugin-snapline");
|
|
3459
|
+
s.graph.use(
|
|
3460
|
+
new r({
|
|
3456
3461
|
enabled: !0,
|
|
3457
3462
|
tolerance: e,
|
|
3458
3463
|
className: "flow-canvas-snapline"
|
|
@@ -3467,7 +3472,7 @@ function Ln(s) {
|
|
|
3467
3472
|
const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "placeholder"], rn = {
|
|
3468
3473
|
key: 0,
|
|
3469
3474
|
class: "flow-canvas-search-popover__no-result"
|
|
3470
|
-
}, an = { class: "flow-canvas-search-popover__counter" }, ln = ["onMouseenter", "onClick"], dn = { class: "flow-canvas-search-popover__item-label" }, cn = /* @__PURE__ */
|
|
3475
|
+
}, an = { class: "flow-canvas-search-popover__counter" }, ln = ["onMouseenter", "onClick"], dn = { class: "flow-canvas-search-popover__item-label" }, cn = /* @__PURE__ */ pe({
|
|
3471
3476
|
__name: "search-popover",
|
|
3472
3477
|
props: {
|
|
3473
3478
|
open: { type: Boolean },
|
|
@@ -3479,38 +3484,38 @@ const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "p
|
|
|
3479
3484
|
isAnchorTarget: { type: Function, default: void 0 }
|
|
3480
3485
|
},
|
|
3481
3486
|
emits: ["update:query", "select", "nextMatch", "prevMatch", "close"],
|
|
3482
|
-
setup(
|
|
3483
|
-
const o =
|
|
3484
|
-
|
|
3487
|
+
setup(n, { emit: e }) {
|
|
3488
|
+
const o = n, t = e, s = H(null), r = H(null), i = H(-1);
|
|
3489
|
+
he(
|
|
3485
3490
|
() => o.open,
|
|
3486
3491
|
(u) => {
|
|
3487
|
-
u && (
|
|
3488
|
-
|
|
3492
|
+
u && (i.value = -1, Ge(() => {
|
|
3493
|
+
s.value?.focus(), s.value?.select();
|
|
3489
3494
|
}));
|
|
3490
3495
|
}
|
|
3491
|
-
),
|
|
3496
|
+
), he(
|
|
3492
3497
|
() => o.query,
|
|
3493
3498
|
() => {
|
|
3494
|
-
|
|
3499
|
+
i.value = -1;
|
|
3495
3500
|
}
|
|
3496
|
-
),
|
|
3501
|
+
), he(
|
|
3497
3502
|
() => o.results.length,
|
|
3498
3503
|
(u) => {
|
|
3499
3504
|
if (!u) {
|
|
3500
|
-
|
|
3505
|
+
i.value = -1;
|
|
3501
3506
|
return;
|
|
3502
3507
|
}
|
|
3503
|
-
|
|
3508
|
+
i.value >= u && (i.value = -1);
|
|
3504
3509
|
}
|
|
3505
3510
|
);
|
|
3506
3511
|
function l(u) {
|
|
3507
3512
|
t("update:query", u.target.value);
|
|
3508
3513
|
}
|
|
3509
3514
|
function a(u) {
|
|
3510
|
-
|
|
3515
|
+
i.value = u;
|
|
3511
3516
|
}
|
|
3512
3517
|
function h() {
|
|
3513
|
-
|
|
3518
|
+
i.value = -1;
|
|
3514
3519
|
}
|
|
3515
3520
|
function f(u) {
|
|
3516
3521
|
if (u.key === "Escape") {
|
|
@@ -3519,17 +3524,17 @@ const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "p
|
|
|
3519
3524
|
}
|
|
3520
3525
|
if (u.key === "ArrowDown") {
|
|
3521
3526
|
if (u.preventDefault(), !o.results.length) return;
|
|
3522
|
-
|
|
3527
|
+
i.value = i.value < o.results.length - 1 ? i.value + 1 : 0;
|
|
3523
3528
|
return;
|
|
3524
3529
|
}
|
|
3525
3530
|
if (u.key === "ArrowUp") {
|
|
3526
3531
|
if (u.preventDefault(), !o.results.length) return;
|
|
3527
|
-
|
|
3532
|
+
i.value = i.value > 0 ? i.value - 1 : o.results.length - 1;
|
|
3528
3533
|
return;
|
|
3529
3534
|
}
|
|
3530
3535
|
if (u.key === "Enter") {
|
|
3531
|
-
if (u.preventDefault(),
|
|
3532
|
-
const w = o.results[
|
|
3536
|
+
if (u.preventDefault(), i.value >= 0) {
|
|
3537
|
+
const w = o.results[i.value];
|
|
3533
3538
|
w && t("select", w.id);
|
|
3534
3539
|
return;
|
|
3535
3540
|
}
|
|
@@ -3539,42 +3544,42 @@ const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "p
|
|
|
3539
3544
|
function p(u) {
|
|
3540
3545
|
if (!o.open) return;
|
|
3541
3546
|
const w = u.target;
|
|
3542
|
-
w &&
|
|
3547
|
+
w && r.value?.contains(w) || o.isAnchorTarget?.(u.target) || t("close");
|
|
3543
3548
|
}
|
|
3544
3549
|
return dt(() => {
|
|
3545
3550
|
document.addEventListener("mousedown", p);
|
|
3546
3551
|
}), Te(() => {
|
|
3547
3552
|
document.removeEventListener("mousedown", p);
|
|
3548
|
-
}), (u, w) =>
|
|
3553
|
+
}), (u, w) => n.open ? (A(), T("div", {
|
|
3549
3554
|
key: 0,
|
|
3550
3555
|
ref_key: "panelRef",
|
|
3551
|
-
ref:
|
|
3556
|
+
ref: r,
|
|
3552
3557
|
class: "flow-canvas-search-popover",
|
|
3553
|
-
style: Ee({ left: `${
|
|
3558
|
+
style: Ee({ left: `${n.position.x}px`, top: `${n.position.y}px`, width: `${n.position.width}px` })
|
|
3554
3559
|
}, [
|
|
3555
|
-
|
|
3556
|
-
|
|
3560
|
+
F("div", nn, [
|
|
3561
|
+
F("input", {
|
|
3557
3562
|
ref_key: "inputRef",
|
|
3558
|
-
ref:
|
|
3559
|
-
value:
|
|
3560
|
-
placeholder:
|
|
3563
|
+
ref: s,
|
|
3564
|
+
value: n.query,
|
|
3565
|
+
placeholder: n.placeholder,
|
|
3561
3566
|
onInput: l,
|
|
3562
3567
|
onKeydown: f
|
|
3563
3568
|
}, null, 40, sn),
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3569
|
+
n.query ? (A(), T(ue, { key: 0 }, [
|
|
3570
|
+
n.results.length ? (A(), T(ue, { key: 1 }, [
|
|
3571
|
+
F("button", {
|
|
3567
3572
|
type: "button",
|
|
3568
3573
|
class: "flow-canvas-search-popover__nav-btn",
|
|
3569
3574
|
"aria-label": "上一个",
|
|
3570
3575
|
onClick: w[0] || (w[0] = (D) => t("prevMatch"))
|
|
3571
3576
|
}, [...w[2] || (w[2] = [
|
|
3572
|
-
|
|
3577
|
+
F("svg", {
|
|
3573
3578
|
viewBox: "0 0 16 16",
|
|
3574
3579
|
width: "12",
|
|
3575
3580
|
height: "12"
|
|
3576
3581
|
}, [
|
|
3577
|
-
|
|
3582
|
+
F("path", {
|
|
3578
3583
|
d: "M10.3 12.3 6 8l4.3-4.3",
|
|
3579
3584
|
fill: "none",
|
|
3580
3585
|
stroke: "currentColor",
|
|
@@ -3584,19 +3589,19 @@ const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "p
|
|
|
3584
3589
|
})
|
|
3585
3590
|
], -1)
|
|
3586
3591
|
])]),
|
|
3587
|
-
|
|
3588
|
-
|
|
3592
|
+
F("span", an, fe(n.matchIndex >= 0 ? n.matchIndex + 1 : 0) + " / " + fe(n.results.length), 1),
|
|
3593
|
+
F("button", {
|
|
3589
3594
|
type: "button",
|
|
3590
3595
|
class: "flow-canvas-search-popover__nav-btn",
|
|
3591
3596
|
"aria-label": "下一个",
|
|
3592
3597
|
onClick: w[1] || (w[1] = (D) => t("nextMatch"))
|
|
3593
3598
|
}, [...w[3] || (w[3] = [
|
|
3594
|
-
|
|
3599
|
+
F("svg", {
|
|
3595
3600
|
viewBox: "0 0 16 16",
|
|
3596
3601
|
width: "12",
|
|
3597
3602
|
height: "12"
|
|
3598
3603
|
}, [
|
|
3599
|
-
|
|
3604
|
+
F("path", {
|
|
3600
3605
|
d: "M5.7 3.7 10 8l-4.3 4.3",
|
|
3601
3606
|
fill: "none",
|
|
3602
3607
|
stroke: "currentColor",
|
|
@@ -3607,56 +3612,56 @@ const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "p
|
|
|
3607
3612
|
], -1)
|
|
3608
3613
|
])])
|
|
3609
3614
|
], 64)) : (A(), T("span", rn, "无结果"))
|
|
3610
|
-
], 64)) :
|
|
3611
|
-
w[4] || (w[4] =
|
|
3615
|
+
], 64)) : K("", !0),
|
|
3616
|
+
w[4] || (w[4] = F("i", { class: "flow-canvas-icon canvas-search flow-canvas-search-popover__search-icon" }, null, -1))
|
|
3612
3617
|
]),
|
|
3613
|
-
|
|
3618
|
+
n.query && n.results.length ? (A(), T("div", {
|
|
3614
3619
|
key: 0,
|
|
3615
3620
|
class: "flow-canvas-search-popover__list-box",
|
|
3616
3621
|
onMouseleave: h
|
|
3617
3622
|
}, [
|
|
3618
|
-
(A(!0), T(
|
|
3623
|
+
(A(!0), T(ue, null, Ce(n.results, (D, O) => (A(), T("button", {
|
|
3619
3624
|
key: D.id,
|
|
3620
3625
|
type: "button",
|
|
3621
|
-
class:
|
|
3626
|
+
class: oe(["flow-canvas-search-popover__item", { "is-active": O === i.value, "is-matched": O === n.matchIndex }]),
|
|
3622
3627
|
onMouseenter: (b) => a(O),
|
|
3623
3628
|
onClick: (b) => t("select", D.id)
|
|
3624
3629
|
}, [
|
|
3625
|
-
|
|
3630
|
+
F("span", dn, fe(D.label), 1)
|
|
3626
3631
|
], 42, ln))), 128))
|
|
3627
|
-
], 32)) :
|
|
3628
|
-
], 4)) :
|
|
3632
|
+
], 32)) : K("", !0)
|
|
3633
|
+
], 4)) : K("", !0);
|
|
3629
3634
|
}
|
|
3630
|
-
}), un = /* @__PURE__ */
|
|
3631
|
-
function hn(
|
|
3632
|
-
return
|
|
3635
|
+
}), un = /* @__PURE__ */ me(cn, [["__scopeId", "data-v-aca2b1c1"]]), nt = 282, fn = 4, gn = 300, _e = "flow-canvas-node-ring-target--search-match", Pe = "flow-canvas-node-ring-target--search-current", pn = "flow-canvas-node-ring-target";
|
|
3636
|
+
function hn(n) {
|
|
3637
|
+
return n !== null;
|
|
3633
3638
|
}
|
|
3634
|
-
function vn(
|
|
3639
|
+
function vn(n) {
|
|
3635
3640
|
const e = /* @__PURE__ */ new Set();
|
|
3636
|
-
return
|
|
3641
|
+
return n.map((o) => o?.trim()).filter((o) => !!o).filter((o) => {
|
|
3637
3642
|
const t = o.toLowerCase();
|
|
3638
3643
|
return e.has(t) ? !1 : (e.add(t), !0);
|
|
3639
3644
|
});
|
|
3640
3645
|
}
|
|
3641
|
-
function mn(
|
|
3646
|
+
function mn(n, e) {
|
|
3642
3647
|
const o = Math.max(8, window.innerWidth - e - 8);
|
|
3643
|
-
return Math.min(Math.max(8,
|
|
3648
|
+
return Math.min(Math.max(8, n), o);
|
|
3644
3649
|
}
|
|
3645
|
-
function yn(
|
|
3646
|
-
const o = e?.getNodeMeta?.(
|
|
3650
|
+
function yn(n, e) {
|
|
3651
|
+
const o = e?.getNodeMeta?.(n);
|
|
3647
3652
|
if (o === null) return null;
|
|
3648
|
-
const t = o?.label?.trim() ||
|
|
3649
|
-
return
|
|
3650
|
-
id:
|
|
3653
|
+
const t = o?.label?.trim() || n.label?.trim() || n.id, s = o?.subtitle?.trim() || void 0, r = vn(o?.keywords ?? [n.label, s]);
|
|
3654
|
+
return r.length ? {
|
|
3655
|
+
id: n.id,
|
|
3651
3656
|
label: t,
|
|
3652
|
-
subtitle:
|
|
3653
|
-
keywords:
|
|
3657
|
+
subtitle: s,
|
|
3658
|
+
keywords: r
|
|
3654
3659
|
} : null;
|
|
3655
3660
|
}
|
|
3656
|
-
function On(
|
|
3657
|
-
let e = null, o = null, t = null,
|
|
3658
|
-
const l = H(!1), a = H(""), h = H({ x: 0, y: 0, width: nt }), f = H(-1), p = V(() => e ? Object.values(e.flowModel.value.nodes).map((g) => yn(g,
|
|
3659
|
-
const g = a.value.trim().toLowerCase(), v = Math.max(1,
|
|
3661
|
+
function On(n) {
|
|
3662
|
+
let e = null, o = null, t = null, s = null, r = null, i = null;
|
|
3663
|
+
const l = H(!1), a = H(""), h = H({ x: 0, y: 0, width: nt }), f = H(-1), p = V(() => e ? Object.values(e.flowModel.value.nodes).map((g) => yn(g, n)).filter(hn) : []), u = V(() => {
|
|
3664
|
+
const g = a.value.trim().toLowerCase(), v = Math.max(1, n?.maxResults ?? gn);
|
|
3660
3665
|
return g ? p.value.filter((m) => m.keywords.some((E) => E.toLowerCase().includes(g))).slice(0, v) : p.value.slice(0, v);
|
|
3661
3666
|
});
|
|
3662
3667
|
function w() {
|
|
@@ -3740,7 +3745,7 @@ function On(s) {
|
|
|
3740
3745
|
function y() {
|
|
3741
3746
|
l.value && O();
|
|
3742
3747
|
}
|
|
3743
|
-
const c =
|
|
3748
|
+
const c = pe({
|
|
3744
3749
|
name: "FlowCanvasSearchHost",
|
|
3745
3750
|
setup() {
|
|
3746
3751
|
return () => qe(un, {
|
|
@@ -3749,7 +3754,7 @@ function On(s) {
|
|
|
3749
3754
|
query: a.value,
|
|
3750
3755
|
results: u.value,
|
|
3751
3756
|
matchIndex: f.value,
|
|
3752
|
-
placeholder:
|
|
3757
|
+
placeholder: n?.placeholder ?? "搜索节点名称",
|
|
3753
3758
|
isAnchorTarget: d,
|
|
3754
3759
|
"onUpdate:query": (g) => {
|
|
3755
3760
|
a.value = g, f.value = -1;
|
|
@@ -3768,7 +3773,7 @@ function On(s) {
|
|
|
3768
3773
|
e = g;
|
|
3769
3774
|
},
|
|
3770
3775
|
attachRuntime(g) {
|
|
3771
|
-
o = g, t = g.graph.container.closest(".flow-canvas-layout__content") ?? g.graph.container.parentElement,
|
|
3776
|
+
o = g, t = g.graph.container.closest(".flow-canvas-layout__content") ?? g.graph.container.parentElement, s = document.createElement("div"), s.className = "flow-canvas-search-host", document.body.append(s), r = bt(c), r.mount(s), i = he(
|
|
3772
3777
|
() => [a.value, u.value.length],
|
|
3773
3778
|
() => {
|
|
3774
3779
|
f.value = -1, M();
|
|
@@ -3776,10 +3781,10 @@ function On(s) {
|
|
|
3776
3781
|
), window.addEventListener("resize", y), window.addEventListener("scroll", y, !0);
|
|
3777
3782
|
},
|
|
3778
3783
|
detachRuntime() {
|
|
3779
|
-
U(),
|
|
3784
|
+
U(), i?.(), i = null, window.removeEventListener("resize", y), window.removeEventListener("scroll", y, !0), r?.unmount(), r = null, s?.remove(), s = null, t = null, o = null;
|
|
3780
3785
|
},
|
|
3781
3786
|
dispose() {
|
|
3782
|
-
U(),
|
|
3787
|
+
U(), i?.(), i = null, e = null;
|
|
3783
3788
|
},
|
|
3784
3789
|
provideToolbarItems() {
|
|
3785
3790
|
return [
|
|
@@ -3797,51 +3802,51 @@ function On(s) {
|
|
|
3797
3802
|
}
|
|
3798
3803
|
};
|
|
3799
3804
|
}
|
|
3800
|
-
const st = 52,
|
|
3801
|
-
function bn(
|
|
3802
|
-
const { mountRect: e, toolbarRect: o, fallbackLeft: t, fallbackTop:
|
|
3805
|
+
const st = 52, rt = 16, pt = 4, wn = 40;
|
|
3806
|
+
function bn(n) {
|
|
3807
|
+
const { mountRect: e, toolbarRect: o, fallbackLeft: t, fallbackTop: s, fallbackWidth: r, height: i } = n, l = n.offset ?? pt;
|
|
3803
3808
|
return !o || o.width <= 0 ? {
|
|
3804
3809
|
left: t,
|
|
3805
|
-
top:
|
|
3806
|
-
width:
|
|
3807
|
-
height:
|
|
3810
|
+
top: s,
|
|
3811
|
+
width: r,
|
|
3812
|
+
height: i
|
|
3808
3813
|
} : {
|
|
3809
3814
|
left: Math.round(o.left - e.left),
|
|
3810
3815
|
top: Math.round(o.bottom - e.top + l),
|
|
3811
3816
|
width: Math.round(o.width),
|
|
3812
|
-
height:
|
|
3817
|
+
height: i
|
|
3813
3818
|
};
|
|
3814
3819
|
}
|
|
3815
|
-
function En(
|
|
3820
|
+
function En(n) {
|
|
3816
3821
|
const e = document.createElement("div");
|
|
3817
|
-
e.className = "flow-canvas-minimap",
|
|
3822
|
+
e.className = "flow-canvas-minimap", n.floating !== !1 && e.classList.add("flow-canvas-minimap--floating");
|
|
3818
3823
|
const o = document.createElement("div");
|
|
3819
3824
|
o.className = "flow-canvas-minimap__host", e.append(o), Object.assign(e.style, {
|
|
3820
|
-
width: `${
|
|
3821
|
-
height: `${
|
|
3822
|
-
}),
|
|
3825
|
+
width: `${n.width}px`,
|
|
3826
|
+
height: `${n.height}px`
|
|
3827
|
+
}), n.floating !== !1 && Object.assign(e.style, {
|
|
3823
3828
|
top: `${st}px`,
|
|
3824
|
-
left: `${
|
|
3829
|
+
left: `${rt}px`
|
|
3825
3830
|
});
|
|
3826
|
-
let t = null,
|
|
3827
|
-
width:
|
|
3828
|
-
height:
|
|
3831
|
+
let t = null, s = n.defaultOpen ?? !1, r = null, i = null, l = null, a = null, h = {
|
|
3832
|
+
width: n.width,
|
|
3833
|
+
height: n.height
|
|
3829
3834
|
};
|
|
3830
3835
|
function f(k, X) {
|
|
3831
3836
|
if (!t) return;
|
|
3832
3837
|
const U = t;
|
|
3833
|
-
U.options.width = k, U.options.height = X, U.updatePaper(
|
|
3838
|
+
U.options.width = k, U.options.height = X, U.updatePaper(n.sourceGraph.container.clientWidth, n.sourceGraph.container.clientHeight);
|
|
3834
3839
|
}
|
|
3835
3840
|
function p() {
|
|
3836
|
-
if (
|
|
3841
|
+
if (n.floating === !1) return;
|
|
3837
3842
|
const k = bn({
|
|
3838
|
-
mountRect:
|
|
3839
|
-
toolbarRect:
|
|
3840
|
-
fallbackLeft:
|
|
3843
|
+
mountRect: n.mountTarget.getBoundingClientRect(),
|
|
3844
|
+
toolbarRect: n.getToolbarElement?.()?.getBoundingClientRect() ?? null,
|
|
3845
|
+
fallbackLeft: rt,
|
|
3841
3846
|
fallbackTop: st,
|
|
3842
|
-
fallbackWidth:
|
|
3843
|
-
height:
|
|
3844
|
-
offset:
|
|
3847
|
+
fallbackWidth: n.width,
|
|
3848
|
+
height: n.height,
|
|
3849
|
+
offset: n.panelOffset ?? pt
|
|
3845
3850
|
});
|
|
3846
3851
|
h = {
|
|
3847
3852
|
width: k.width,
|
|
@@ -3854,70 +3859,70 @@ function En(s) {
|
|
|
3854
3859
|
}), f(k.width, k.height);
|
|
3855
3860
|
}
|
|
3856
3861
|
function u() {
|
|
3857
|
-
if (
|
|
3858
|
-
const k =
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
})), a !== k && (
|
|
3862
|
+
if (n.floating === !1 || typeof ResizeObserver > "u") return;
|
|
3863
|
+
const k = n.getToolbarElement?.() ?? null;
|
|
3864
|
+
i || (i = new ResizeObserver(() => {
|
|
3865
|
+
s && (u(), p());
|
|
3866
|
+
})), a !== k && (i.disconnect(), i.observe(n.mountTarget), k && i.observe(k), a = k);
|
|
3862
3867
|
}
|
|
3863
3868
|
function w() {
|
|
3864
|
-
|
|
3865
|
-
|
|
3869
|
+
n.floating !== !1 && (p(), u(), l || (l = () => {
|
|
3870
|
+
s && (u(), p());
|
|
3866
3871
|
}, window.addEventListener("resize", l)));
|
|
3867
3872
|
}
|
|
3868
3873
|
function D() {
|
|
3869
|
-
l && (window.removeEventListener("resize", l), l = null),
|
|
3874
|
+
l && (window.removeEventListener("resize", l), l = null), i?.disconnect(), i = null, a = null;
|
|
3870
3875
|
}
|
|
3871
3876
|
function O() {
|
|
3872
|
-
!
|
|
3877
|
+
!n.onClickOutside || r || (r = (k) => {
|
|
3873
3878
|
const X = k.target;
|
|
3874
|
-
X && e.contains(X) || k.target?.closest('[data-toolbar-type="minimap"]') || k.target?.closest(".flow-canvas-layout__content") ||
|
|
3875
|
-
}, document.addEventListener("mousedown",
|
|
3879
|
+
X && e.contains(X) || k.target?.closest('[data-toolbar-type="minimap"]') || k.target?.closest(".flow-canvas-layout__content") || n.onClickOutside();
|
|
3880
|
+
}, document.addEventListener("mousedown", r));
|
|
3876
3881
|
}
|
|
3877
3882
|
function b() {
|
|
3878
|
-
|
|
3883
|
+
r && (document.removeEventListener("mousedown", r), r = null);
|
|
3879
3884
|
}
|
|
3880
3885
|
function S() {
|
|
3881
3886
|
t || (t = new Ct({
|
|
3882
3887
|
container: o,
|
|
3883
3888
|
width: h.width,
|
|
3884
3889
|
height: h.height,
|
|
3885
|
-
padding:
|
|
3890
|
+
padding: n.contentPadding ?? wn,
|
|
3886
3891
|
scalable: !1
|
|
3887
|
-
}),
|
|
3892
|
+
}), n.sourceGraph.use(t));
|
|
3888
3893
|
}
|
|
3889
3894
|
function M(k) {
|
|
3890
|
-
|
|
3891
|
-
|
|
3895
|
+
s = k, e.style.display = s ? "" : "none", s ? (w(), S(), O(), requestAnimationFrame(() => {
|
|
3896
|
+
s && (u(), p());
|
|
3892
3897
|
})) : (b(), D());
|
|
3893
3898
|
}
|
|
3894
3899
|
function B() {
|
|
3895
|
-
M(
|
|
3900
|
+
M(s), n.mountTarget.appendChild(e);
|
|
3896
3901
|
}
|
|
3897
3902
|
function j() {
|
|
3898
3903
|
b(), D(), t?.dispose(), t = null, e.remove();
|
|
3899
3904
|
}
|
|
3900
3905
|
return B(), {
|
|
3901
3906
|
element: e,
|
|
3902
|
-
isOpen: () =>
|
|
3907
|
+
isOpen: () => s,
|
|
3903
3908
|
setOpen: M,
|
|
3904
3909
|
toggle() {
|
|
3905
|
-
const k = !
|
|
3910
|
+
const k = !s;
|
|
3906
3911
|
return M(k), k;
|
|
3907
3912
|
},
|
|
3908
3913
|
destroy: j
|
|
3909
3914
|
};
|
|
3910
3915
|
}
|
|
3911
|
-
function $n(
|
|
3916
|
+
function $n(n) {
|
|
3912
3917
|
let e = null, o = null;
|
|
3913
3918
|
const t = H(!1);
|
|
3914
|
-
function
|
|
3919
|
+
function s() {
|
|
3915
3920
|
return o?.querySelector('.flow-canvas-toolbar__btn[data-toolbar-type="minimap"]');
|
|
3916
3921
|
}
|
|
3917
|
-
function
|
|
3918
|
-
return
|
|
3922
|
+
function r() {
|
|
3923
|
+
return s()?.closest(".flow-canvas-toolbar");
|
|
3919
3924
|
}
|
|
3920
|
-
function
|
|
3925
|
+
function i(a) {
|
|
3921
3926
|
e?.setOpen(a), t.value = a;
|
|
3922
3927
|
}
|
|
3923
3928
|
function l() {
|
|
@@ -3927,19 +3932,19 @@ function $n(s) {
|
|
|
3927
3932
|
name: "minimap",
|
|
3928
3933
|
priority: 90,
|
|
3929
3934
|
attachRuntime(a) {
|
|
3930
|
-
const h = a, f =
|
|
3935
|
+
const h = a, f = n?.width ?? 334, p = n?.height ?? 180;
|
|
3931
3936
|
o = h.graph.container.closest(".flow-canvas-layout__content") ?? h.graph.container.parentElement;
|
|
3932
|
-
const u =
|
|
3937
|
+
const u = n?.container ?? o;
|
|
3933
3938
|
u && (e = En({
|
|
3934
3939
|
sourceGraph: a.graph,
|
|
3935
3940
|
mountTarget: u,
|
|
3936
3941
|
width: f,
|
|
3937
3942
|
height: p,
|
|
3938
|
-
floating: !
|
|
3943
|
+
floating: !n?.container,
|
|
3939
3944
|
defaultOpen: !1,
|
|
3940
|
-
getToolbarElement:
|
|
3941
|
-
onClickOutside: () =>
|
|
3942
|
-
}),
|
|
3945
|
+
getToolbarElement: n?.container ? void 0 : r,
|
|
3946
|
+
onClickOutside: () => i(!1)
|
|
3947
|
+
}), i(!1));
|
|
3943
3948
|
},
|
|
3944
3949
|
detachRuntime() {
|
|
3945
3950
|
e?.destroy(), e = null, o = null, t.value = !1;
|
|
@@ -3961,58 +3966,58 @@ function $n(s) {
|
|
|
3961
3966
|
};
|
|
3962
3967
|
}
|
|
3963
3968
|
function Bn() {
|
|
3964
|
-
let
|
|
3969
|
+
let n = null, e = 0;
|
|
3965
3970
|
return {
|
|
3966
3971
|
name: "clipboard",
|
|
3967
3972
|
priority: 90,
|
|
3968
3973
|
onKeyboardShortcut(o, t) {
|
|
3969
|
-
const
|
|
3970
|
-
if (
|
|
3971
|
-
const
|
|
3972
|
-
if (!
|
|
3973
|
-
const
|
|
3974
|
+
const s = o.metaKey || o.ctrlKey;
|
|
3975
|
+
if (s && o.key === "c") {
|
|
3976
|
+
const r = t.graph.getSelectedCells?.() ?? [];
|
|
3977
|
+
if (!r.length) return !1;
|
|
3978
|
+
const i = t.flowModel.value, l = new Set(r.filter((f) => f.isNode()).map((f) => f.id)), a = [...l].map((f) => i.nodes[f]).filter(Boolean);
|
|
3974
3979
|
if (!a.length) return !1;
|
|
3975
|
-
const h = Object.values(
|
|
3980
|
+
const h = Object.values(i.edges).filter(
|
|
3976
3981
|
(f) => l.has(f.source.nodeId) && l.has(f.target.nodeId)
|
|
3977
3982
|
);
|
|
3978
|
-
return
|
|
3983
|
+
return n = { nodes: a, edges: h }, e = 0, !0;
|
|
3979
3984
|
}
|
|
3980
|
-
if (
|
|
3981
|
-
if (!
|
|
3985
|
+
if (s && o.key === "v") {
|
|
3986
|
+
if (!n?.nodes.length) return !1;
|
|
3982
3987
|
e++;
|
|
3983
|
-
const
|
|
3984
|
-
for (const a of
|
|
3985
|
-
const h = `${a.id}_cp${
|
|
3986
|
-
|
|
3988
|
+
const r = e * 30, i = /* @__PURE__ */ new Map(), l = [];
|
|
3989
|
+
for (const a of n.nodes) {
|
|
3990
|
+
const h = `${a.id}_cp${ee().slice(0, 6)}`;
|
|
3991
|
+
i.set(a.id, h), l.push({
|
|
3987
3992
|
type: "node.add",
|
|
3988
3993
|
node: {
|
|
3989
3994
|
...a,
|
|
3990
3995
|
id: h,
|
|
3991
3996
|
position: {
|
|
3992
|
-
x: a.position.x +
|
|
3993
|
-
y: a.position.y +
|
|
3997
|
+
x: a.position.x + r,
|
|
3998
|
+
y: a.position.y + r
|
|
3994
3999
|
},
|
|
3995
4000
|
payload: a.payload ? { ...a.payload } : {},
|
|
3996
4001
|
extensions: a.extensions ? { ...a.extensions } : void 0
|
|
3997
4002
|
}
|
|
3998
4003
|
});
|
|
3999
4004
|
}
|
|
4000
|
-
for (const a of
|
|
4001
|
-
const h =
|
|
4005
|
+
for (const a of n.edges) {
|
|
4006
|
+
const h = i.get(a.source.nodeId), f = i.get(a.target.nodeId);
|
|
4002
4007
|
!h || !f || l.push({
|
|
4003
4008
|
type: "edge.add",
|
|
4004
4009
|
edge: {
|
|
4005
4010
|
...a,
|
|
4006
|
-
id: `${a.id}_cp${
|
|
4011
|
+
id: `${a.id}_cp${ee().slice(0, 6)}`,
|
|
4007
4012
|
source: { ...a.source, nodeId: h },
|
|
4008
4013
|
target: { ...a.target, nodeId: f },
|
|
4009
|
-
labels: a.labels?.map((p) => ({ ...p, id: `${p.id}_cp${
|
|
4014
|
+
labels: a.labels?.map((p) => ({ ...p, id: `${p.id}_cp${ee().slice(0, 6)}` })),
|
|
4010
4015
|
payload: a.payload ? { ...a.payload } : {}
|
|
4011
4016
|
}
|
|
4012
4017
|
});
|
|
4013
4018
|
}
|
|
4014
4019
|
return l.length && t.executeCommand({
|
|
4015
|
-
id:
|
|
4020
|
+
id: ee(),
|
|
4016
4021
|
source: "user:keyboard",
|
|
4017
4022
|
label: "粘贴",
|
|
4018
4023
|
timestamp: Date.now(),
|
|
@@ -4024,7 +4029,7 @@ function Bn() {
|
|
|
4024
4029
|
};
|
|
4025
4030
|
}
|
|
4026
4031
|
export {
|
|
4027
|
-
|
|
4032
|
+
ge as CanvasConstraintError,
|
|
4028
4033
|
An as CanvasLayout,
|
|
4029
4034
|
Ro as CanvasNodePalette,
|
|
4030
4035
|
Dn as CanvasRuntime,
|
|
@@ -4041,7 +4046,7 @@ export {
|
|
|
4041
4046
|
Pn as createDefaultSchema,
|
|
4042
4047
|
Ho as createDefaultToolbarItems,
|
|
4043
4048
|
Mn as createEmptyFlowModel,
|
|
4044
|
-
|
|
4049
|
+
ee as generateId,
|
|
4045
4050
|
$n as minimapPlugin,
|
|
4046
4051
|
On as searchPlugin,
|
|
4047
4052
|
Rn as selectionPlugin,
|