@blueking/flow-canvas 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.esm.js +1106 -1082
- package/dist/style.css +1 -1
- package/package.json +4 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as H, computed as V, onScopeDispose as it, defineComponent as fe, h as qe, watch as ge, onBeforeUnmount as Te, createElementBlock as T, openBlock as A, normalizeStyle as Ee, createElementVNode as q, createVNode as at, createCommentVNode as Y, normalizeClass as te, 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 de, renderList as Ce, toDisplayString as ce, unref as re, 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";
|
|
@@ -20,7 +20,7 @@ class kt extends Error {
|
|
|
20
20
|
super(e), this.name = "CanvasSchemaError";
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
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))
|
|
@@ -55,9 +55,9 @@ function ct(n, e) {
|
|
|
55
55
|
case "edge.remove":
|
|
56
56
|
return Tt(n, e.edgeId);
|
|
57
57
|
case "edge.reconnect":
|
|
58
|
-
return
|
|
58
|
+
return Rt(n, e.edgeId, e.source, e.target);
|
|
59
59
|
case "edge.update":
|
|
60
|
-
return
|
|
60
|
+
return Lt(n, e.edgeId, e.patch);
|
|
61
61
|
case "edge.set-payload":
|
|
62
62
|
return Ot(n, e.edgeId, e.path, e.value);
|
|
63
63
|
case "edge.label.update":
|
|
@@ -85,7 +85,7 @@ function ke(n, e, o) {
|
|
|
85
85
|
if (e.portId && t.ports && !t.ports.some((r) => r.id === e.portId))
|
|
86
86
|
throw new ue(`${o} port "${e.portId}" not found on node "${e.nodeId}"`);
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function Le(n, e, o) {
|
|
89
89
|
return { ...n, nodes: { ...n.nodes, [e]: o } };
|
|
90
90
|
}
|
|
91
91
|
function Oe(n, e, o) {
|
|
@@ -98,7 +98,7 @@ function St(n, e) {
|
|
|
98
98
|
}
|
|
99
99
|
function Mt(n, e, o) {
|
|
100
100
|
const t = Ne(n, e);
|
|
101
|
-
return
|
|
101
|
+
return Le(n, e, { ...t, position: o });
|
|
102
102
|
}
|
|
103
103
|
function Nt(n, e) {
|
|
104
104
|
Ne(n, e);
|
|
@@ -109,15 +109,15 @@ function Nt(n, e) {
|
|
|
109
109
|
}
|
|
110
110
|
function Dt(n, e, o) {
|
|
111
111
|
const t = Ne(n, e);
|
|
112
|
-
return
|
|
112
|
+
return Le(n, e, { ...t, ...o, id: t.id });
|
|
113
113
|
}
|
|
114
114
|
function At(n, e, o, t) {
|
|
115
|
-
const s = Ne(n, e), r =
|
|
116
|
-
return
|
|
115
|
+
const s = Ne(n, e), r = Re(s.payload, o, t);
|
|
116
|
+
return Le(n, e, { ...s, payload: r });
|
|
117
117
|
}
|
|
118
118
|
function _t(n, e, o, t) {
|
|
119
|
-
const s = Ne(n, e), r =
|
|
120
|
-
return
|
|
119
|
+
const s = Ne(n, e), r = Re(s.extensions, o, t);
|
|
120
|
+
return Le(n, e, { ...s, extensions: r });
|
|
121
121
|
}
|
|
122
122
|
function Pt(n, e) {
|
|
123
123
|
if (n.edges[e.id])
|
|
@@ -137,16 +137,16 @@ function Tt(n, e) {
|
|
|
137
137
|
const { [e]: o, ...t } = n.edges;
|
|
138
138
|
return { ...n, edges: t };
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function Rt(n, e, o, t) {
|
|
141
141
|
const s = De(n, e), r = o ?? s.source, i = t ?? s.target;
|
|
142
142
|
return ke(n, r, "Source"), ke(n, i, "Target"), Oe(n, e, { ...s, source: r, target: i });
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function Lt(n, e, o) {
|
|
145
145
|
const t = De(n, e), s = { ...t, ...o, id: t.id };
|
|
146
146
|
return o.source && ke(n, s.source, "Source"), o.target && ke(n, s.target, "Target"), Oe(n, e, s);
|
|
147
147
|
}
|
|
148
148
|
function Ot(n, e, o, t) {
|
|
149
|
-
const s = De(n, e), r =
|
|
149
|
+
const s = De(n, e), r = Re(s.payload, o, t);
|
|
150
150
|
return Oe(n, e, { ...s, payload: r });
|
|
151
151
|
}
|
|
152
152
|
function $t(n, e, o, t) {
|
|
@@ -160,66 +160,66 @@ function $t(n, e, o, t) {
|
|
|
160
160
|
return i[r] = { ...i[r], ...t, id: o }, Oe(n, e, { ...s, labels: i });
|
|
161
161
|
}
|
|
162
162
|
function Bt(n, e, o) {
|
|
163
|
-
const t =
|
|
163
|
+
const t = Re(n.meta, e, o);
|
|
164
164
|
return { ...n, meta: t };
|
|
165
165
|
}
|
|
166
166
|
function Ft(n, e) {
|
|
167
|
-
const o = e?.maxHistorySize ?? 100, t =
|
|
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 v(b) {
|
|
172
|
-
const
|
|
173
|
-
let
|
|
174
|
-
for (const
|
|
175
|
-
|
|
172
|
+
const S = t.value;
|
|
173
|
+
let M = S;
|
|
174
|
+
for (const B of b.commands)
|
|
175
|
+
M = ct(M, B);
|
|
176
176
|
if (!b.skipHistory) {
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
const k =
|
|
180
|
-
s.push({ snapshot:
|
|
177
|
+
const B = e?.excludeCommandFromHistory, j = B ? b.commands.filter((k) => !B(k)) : b.commands;
|
|
178
|
+
if (j.length > 0) {
|
|
179
|
+
const k = j.length < b.commands.length ? { ...b, commands: j } : b;
|
|
180
|
+
s.push({ snapshot: S, envelope: k }), s.length > o && s.shift(), r.length = 0;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
return t.value =
|
|
183
|
+
return t.value = M, a(), M;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function f() {
|
|
186
186
|
const b = s.pop();
|
|
187
187
|
if (!b) return null;
|
|
188
188
|
r.push({ snapshot: t.value, envelope: b.envelope });
|
|
189
|
-
const
|
|
190
|
-
return t.value =
|
|
189
|
+
const S = e?.preserveMetaOnUndoRedo ? { ...b.snapshot, meta: t.value.meta } : b.snapshot;
|
|
190
|
+
return t.value = S, a(), S;
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function p() {
|
|
193
193
|
const b = r.pop();
|
|
194
194
|
if (!b) return null;
|
|
195
195
|
s.push({ snapshot: t.value, envelope: b.envelope });
|
|
196
|
-
const
|
|
197
|
-
return t.value =
|
|
196
|
+
const S = e?.preserveMetaOnUndoRedo ? { ...b.snapshot, meta: t.value.meta } : b.snapshot;
|
|
197
|
+
return t.value = S, a(), S;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function u() {
|
|
200
200
|
s.length = 0, r.length = 0, a();
|
|
201
201
|
}
|
|
202
202
|
function w() {
|
|
203
203
|
return t.value;
|
|
204
204
|
}
|
|
205
|
-
function
|
|
206
|
-
t.value = b,
|
|
205
|
+
function D(b) {
|
|
206
|
+
t.value = b, u();
|
|
207
207
|
}
|
|
208
|
-
function O(b,
|
|
209
|
-
const
|
|
208
|
+
function O(b, S) {
|
|
209
|
+
const M = {
|
|
210
210
|
id: `update-${Date.now()}`,
|
|
211
211
|
source: "system:update",
|
|
212
|
-
label:
|
|
212
|
+
label: S ?? "更新模型",
|
|
213
213
|
timestamp: Date.now(),
|
|
214
214
|
commands: []
|
|
215
215
|
};
|
|
216
|
-
s.push({ snapshot: t.value, envelope:
|
|
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: v,
|
|
221
|
-
undo:
|
|
222
|
-
redo:
|
|
221
|
+
undo: f,
|
|
222
|
+
redo: p,
|
|
223
223
|
canUndo: i,
|
|
224
224
|
canRedo: l,
|
|
225
225
|
get undoStack() {
|
|
@@ -228,9 +228,9 @@ function Ft(n, e) {
|
|
|
228
228
|
get redoStack() {
|
|
229
229
|
return r.map((b) => b.envelope);
|
|
230
230
|
},
|
|
231
|
-
clear:
|
|
231
|
+
clear: u,
|
|
232
232
|
createSnapshot: w,
|
|
233
|
-
replaceFlowModel:
|
|
233
|
+
replaceFlowModel: D,
|
|
234
234
|
updateFlowModel: O
|
|
235
235
|
};
|
|
236
236
|
}
|
|
@@ -274,9 +274,9 @@ class Ht {
|
|
|
274
274
|
const t = this, s = new Proxy(e.graph, {
|
|
275
275
|
get(r, i, l) {
|
|
276
276
|
const a = Reflect.get(r, i, l);
|
|
277
|
-
return i === "use" && typeof a == "function" ? function(...
|
|
277
|
+
return i === "use" && typeof a == "function" ? function(...f) {
|
|
278
278
|
if (t.runtimeVersion === o)
|
|
279
|
-
return a.apply(r,
|
|
279
|
+
return a.apply(r, f);
|
|
280
280
|
} : a;
|
|
281
281
|
}
|
|
282
282
|
});
|
|
@@ -402,41 +402,41 @@ class Ht {
|
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
let Gt = 0;
|
|
405
|
-
function
|
|
405
|
+
function J() {
|
|
406
406
|
const n = Date.now().toString(36), e = Math.random().toString(36).substring(2, 8);
|
|
407
407
|
return `${n}-${e}-${++Gt}`;
|
|
408
408
|
}
|
|
409
|
-
const
|
|
409
|
+
const ze = () => J();
|
|
410
410
|
function Nn(n) {
|
|
411
|
-
const { schema: e, plugins: o = [], historyOptions: t } = n, s = n.idGenerator ??
|
|
412
|
-
function w(
|
|
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), v = H(null), f = H([]), p = {}, u = new Ht();
|
|
412
|
+
function w(S, M, B, j = "user:toolbar") {
|
|
413
413
|
const k = {
|
|
414
414
|
id: `history-${Date.now()}`,
|
|
415
|
-
source:
|
|
416
|
-
label:
|
|
415
|
+
source: j,
|
|
416
|
+
label: S,
|
|
417
417
|
timestamp: Date.now(),
|
|
418
418
|
commands: []
|
|
419
419
|
};
|
|
420
|
-
|
|
420
|
+
u.afterCommand(k, M, B), f.value = u.collectToolbarItems(), n.onCommandResult?.({
|
|
421
421
|
status: "applied",
|
|
422
422
|
envelope: k,
|
|
423
|
-
flowModel:
|
|
423
|
+
flowModel: B
|
|
424
424
|
}), n.onFlowModelChange?.({
|
|
425
|
-
flowModel:
|
|
426
|
-
prevFlowModel:
|
|
425
|
+
flowModel: B,
|
|
426
|
+
prevFlowModel: M,
|
|
427
427
|
envelope: k,
|
|
428
|
-
source:
|
|
428
|
+
source: j
|
|
429
429
|
});
|
|
430
430
|
}
|
|
431
|
-
const
|
|
431
|
+
const D = {
|
|
432
432
|
execute: i.execute,
|
|
433
433
|
undo() {
|
|
434
|
-
const
|
|
435
|
-
return
|
|
434
|
+
const S = i.currentFlowModel.value, M = i.undo();
|
|
435
|
+
return M && w("撤销", S, M), M;
|
|
436
436
|
},
|
|
437
437
|
redo() {
|
|
438
|
-
const
|
|
439
|
-
return
|
|
438
|
+
const S = i.currentFlowModel.value, M = i.redo();
|
|
439
|
+
return M && w("重做", S, M), M;
|
|
440
440
|
},
|
|
441
441
|
get canUndo() {
|
|
442
442
|
return i.canUndo;
|
|
@@ -452,87 +452,87 @@ function Nn(n) {
|
|
|
452
452
|
},
|
|
453
453
|
clear: i.clear,
|
|
454
454
|
createSnapshot: i.createSnapshot,
|
|
455
|
-
replaceFlowModel(
|
|
456
|
-
const
|
|
457
|
-
i.replaceFlowModel(
|
|
455
|
+
replaceFlowModel(S) {
|
|
456
|
+
const M = i.currentFlowModel.value;
|
|
457
|
+
i.replaceFlowModel(S), w("替换 FlowModel", M, S, "system:replace");
|
|
458
458
|
},
|
|
459
|
-
updateFlowModel(
|
|
460
|
-
const
|
|
461
|
-
i.updateFlowModel(
|
|
459
|
+
updateFlowModel(S, M) {
|
|
460
|
+
const B = i.currentFlowModel.value;
|
|
461
|
+
i.updateFlowModel(S, M), w(M ?? "更新 FlowModel", B, S, "system:update");
|
|
462
462
|
}
|
|
463
463
|
}, O = {
|
|
464
464
|
flowModel: V(() => i.currentFlowModel.value),
|
|
465
|
-
history:
|
|
465
|
+
history: D,
|
|
466
466
|
schema: e,
|
|
467
467
|
mode: l,
|
|
468
468
|
idGenerator: s,
|
|
469
469
|
executeCommand: b,
|
|
470
|
-
replaceFlowModel(
|
|
471
|
-
|
|
470
|
+
replaceFlowModel(S) {
|
|
471
|
+
D.replaceFlowModel(S);
|
|
472
472
|
},
|
|
473
|
-
updateFlowModel(
|
|
474
|
-
|
|
473
|
+
updateFlowModel(S, M) {
|
|
474
|
+
D.updateFlowModel(S, M);
|
|
475
475
|
},
|
|
476
|
-
setMode(
|
|
477
|
-
l.value =
|
|
476
|
+
setMode(S) {
|
|
477
|
+
l.value = S;
|
|
478
478
|
},
|
|
479
479
|
selectionMode: a,
|
|
480
|
-
setSelectionMode(
|
|
481
|
-
a.value =
|
|
480
|
+
setSelectionMode(S) {
|
|
481
|
+
a.value = S;
|
|
482
482
|
},
|
|
483
483
|
api: v,
|
|
484
|
-
toolbarItems:
|
|
485
|
-
extendedApi:
|
|
486
|
-
_pluginManager:
|
|
487
|
-
_emitUiEvent: (
|
|
488
|
-
|
|
484
|
+
toolbarItems: f,
|
|
485
|
+
extendedApi: p,
|
|
486
|
+
_pluginManager: u,
|
|
487
|
+
_emitUiEvent: (S) => {
|
|
488
|
+
u.dispatchUiEvent(S);
|
|
489
489
|
}
|
|
490
490
|
};
|
|
491
|
-
|
|
491
|
+
u.install(o, {
|
|
492
492
|
flowModel: O.flowModel,
|
|
493
|
-
history:
|
|
493
|
+
history: D,
|
|
494
494
|
schema: e,
|
|
495
495
|
mode: l,
|
|
496
496
|
idGenerator: s,
|
|
497
497
|
executeCommand: b
|
|
498
|
-
}),
|
|
499
|
-
|
|
498
|
+
}), f.value = u.collectToolbarItems(), it(() => {
|
|
499
|
+
u.dispose();
|
|
500
500
|
});
|
|
501
|
-
function b(
|
|
502
|
-
const
|
|
503
|
-
if ("rejected" in
|
|
501
|
+
function b(S) {
|
|
502
|
+
const M = u.transformCommand(S);
|
|
503
|
+
if ("rejected" in M) {
|
|
504
504
|
const k = {
|
|
505
505
|
status: "rejected",
|
|
506
|
-
envelope:
|
|
507
|
-
error:
|
|
506
|
+
envelope: S,
|
|
507
|
+
error: M.error
|
|
508
508
|
};
|
|
509
509
|
return n.onCommandResult?.(k), k;
|
|
510
510
|
}
|
|
511
|
-
const
|
|
511
|
+
const B = M.envelope, j = i.currentFlowModel.value;
|
|
512
512
|
try {
|
|
513
|
-
const k = i.execute(
|
|
513
|
+
const k = i.execute(B), X = {
|
|
514
514
|
status: "applied",
|
|
515
|
-
envelope:
|
|
515
|
+
envelope: B,
|
|
516
516
|
flowModel: k
|
|
517
517
|
};
|
|
518
|
-
return
|
|
518
|
+
return u.afterCommand(B, j, k), f.value = u.collectToolbarItems(), n.onCommandResult?.(X), n.onFlowModelChange?.({
|
|
519
519
|
flowModel: k,
|
|
520
|
-
prevFlowModel:
|
|
521
|
-
envelope:
|
|
522
|
-
source:
|
|
523
|
-
}),
|
|
520
|
+
prevFlowModel: j,
|
|
521
|
+
envelope: B,
|
|
522
|
+
source: B.source
|
|
523
|
+
}), X;
|
|
524
524
|
} catch (k) {
|
|
525
525
|
if (k instanceof ue) {
|
|
526
|
-
const
|
|
526
|
+
const X = {
|
|
527
527
|
status: "invalid",
|
|
528
|
-
envelope:
|
|
528
|
+
envelope: B,
|
|
529
529
|
error: {
|
|
530
530
|
code: "constraint_violated",
|
|
531
531
|
reason: k.message,
|
|
532
532
|
source: "engine"
|
|
533
533
|
}
|
|
534
534
|
};
|
|
535
|
-
return n.onCommandResult?.(
|
|
535
|
+
return n.onCommandResult?.(X), X;
|
|
536
536
|
}
|
|
537
537
|
throw k;
|
|
538
538
|
}
|
|
@@ -543,10 +543,10 @@ const zt = ["top", "right", "bottom", "left"];
|
|
|
543
543
|
function ut() {
|
|
544
544
|
return zt.map((n) => ({ id: n, group: n }));
|
|
545
545
|
}
|
|
546
|
-
function
|
|
546
|
+
function Ue(n, e) {
|
|
547
547
|
return e?.(n) ?? n.ports ?? ut();
|
|
548
548
|
}
|
|
549
|
-
const Fe = -1, Ut = "flow-canvas-node-ring-target",
|
|
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 {
|
|
551
551
|
graph;
|
|
552
552
|
schema;
|
|
@@ -679,7 +679,7 @@ class Wt {
|
|
|
679
679
|
throw new kt(
|
|
680
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 i = this.shapeRegistry.registerNodeType(s.type, r.component), l = r.getSize(s), a =
|
|
682
|
+
const i = this.shapeRegistry.registerNodeType(s.type, r.component), l = r.getSize(s), a = Ue(s, r.getPorts);
|
|
683
683
|
o.set(t, { model: s, definition: r, shapeName: i, size: l, ports: a });
|
|
684
684
|
}
|
|
685
685
|
return o;
|
|
@@ -760,7 +760,7 @@ class Wt {
|
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
762
|
},
|
|
763
|
-
items: i.map((
|
|
763
|
+
items: i.map((f) => ({ id: f.id, group: f.group, ...f.x6PortConfig }))
|
|
764
764
|
},
|
|
765
765
|
...l.x6CellConfig
|
|
766
766
|
};
|
|
@@ -838,18 +838,18 @@ class Wt {
|
|
|
838
838
|
updateExistingEdge(e, o, t, s) {
|
|
839
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
|
-
const
|
|
842
|
-
if (
|
|
841
|
+
const f = (e.getData()?.type ?? void 0) !== (o.type ?? void 0);
|
|
842
|
+
if (f) {
|
|
843
843
|
if (t?.router) {
|
|
844
|
-
const
|
|
845
|
-
e.setRouter(
|
|
844
|
+
const p = typeof t.router == "string" ? { name: t.router } : t.router;
|
|
845
|
+
e.setRouter(p);
|
|
846
846
|
}
|
|
847
847
|
if (t?.connector) {
|
|
848
|
-
const
|
|
849
|
-
e.setConnector(
|
|
848
|
+
const p = typeof t.connector == "string" ? { name: t.connector } : t.connector;
|
|
849
|
+
e.setConnector(p);
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
|
-
(
|
|
852
|
+
(f || l || a) && (this.syncEdgeMarker(e, t, "sourceMarker"), this.syncEdgeMarker(e, t, "targetMarker")), this.syncEdgeLabels(e, o), e.getZIndex() !== Fe && e.setZIndex(Fe), e.setData({ ...o }, { silent: !0 }), this.applyEdgeStyleAndDecoration(e, o, t);
|
|
853
853
|
}
|
|
854
854
|
syncEdgeLabels(e, o) {
|
|
855
855
|
if (!o.labels?.length) {
|
|
@@ -930,11 +930,11 @@ class Wt {
|
|
|
930
930
|
applyNodeHighlightAndDecoration(e, o) {
|
|
931
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
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,
|
|
934
|
-
|
|
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
|
-
), i.style.setProperty("--flow-canvas-node-pulse-ring-opacity", "0.95")) : (i.classList.remove(
|
|
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;
|
|
@@ -965,15 +965,15 @@ class Wt {
|
|
|
965
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, v;
|
|
967
967
|
if (t?.style) {
|
|
968
|
-
const O = this.graph.isSelected?.(e) ?? !1, b = this.hoveredEdgeId === e.id,
|
|
969
|
-
l =
|
|
968
|
+
const O = this.graph.isSelected?.(e) ?? !1, b = this.hoveredEdgeId === e.id, S = t.style(o, { selected: O, highlighted: s, hovered: b });
|
|
969
|
+
l = S.stroke, a = S.strokeWidth, v = S.strokeDasharray;
|
|
970
970
|
}
|
|
971
|
-
const
|
|
972
|
-
w ? this.setEdgeAttrIfChanged(e, "line/stroke", w) :
|
|
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
|
+
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"), v ? this.setEdgeAttrIfChanged(e, "line/strokeDasharray", v) : 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 = J();
|
|
977
977
|
registeredShapes = /* @__PURE__ */ new Map();
|
|
978
978
|
wrappedComponents = /* @__PURE__ */ new Map();
|
|
979
979
|
getShapeName(e) {
|
|
@@ -1007,7 +1007,7 @@ class Xt {
|
|
|
1007
1007
|
idGenerator;
|
|
1008
1008
|
disposers = [];
|
|
1009
1009
|
constructor(e, o, t, s, r) {
|
|
1010
|
-
this.graph = e, this.onUiEvent = o, this.onCommand = t, this.flowModelRef = s, this.idGenerator = 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();
|
|
@@ -1047,7 +1047,7 @@ class Xt {
|
|
|
1047
1047
|
}), this.on("node:moved", ({ node: e }) => {
|
|
1048
1048
|
const o = e.getPosition();
|
|
1049
1049
|
this.onCommand({
|
|
1050
|
-
id:
|
|
1050
|
+
id: J(),
|
|
1051
1051
|
source: "user:drag",
|
|
1052
1052
|
label: "移动节点",
|
|
1053
1053
|
timestamp: Date.now(),
|
|
@@ -1058,7 +1058,7 @@ class Xt {
|
|
|
1058
1058
|
if (!t || !s) return;
|
|
1059
1059
|
const r = e.getSourcePortId(), i = e.getTargetPortId(), l = e.id in this.flowModelRef.value.edges;
|
|
1060
1060
|
o && !l ? (this.graph.removeCell(e), this.onCommand({
|
|
1061
|
-
id:
|
|
1061
|
+
id: J(),
|
|
1062
1062
|
source: "user:drag",
|
|
1063
1063
|
label: "连线",
|
|
1064
1064
|
timestamp: Date.now(),
|
|
@@ -1073,7 +1073,7 @@ class Xt {
|
|
|
1073
1073
|
}
|
|
1074
1074
|
]
|
|
1075
1075
|
})) : this.onCommand({
|
|
1076
|
-
id:
|
|
1076
|
+
id: J(),
|
|
1077
1077
|
source: "user:drag",
|
|
1078
1078
|
label: "重连",
|
|
1079
1079
|
timestamp: Date.now(),
|
|
@@ -1102,7 +1102,7 @@ class Xt {
|
|
|
1102
1102
|
});
|
|
1103
1103
|
}
|
|
1104
1104
|
r.length && this.onCommand({
|
|
1105
|
-
id:
|
|
1105
|
+
id: J(),
|
|
1106
1106
|
source: "user:drag",
|
|
1107
1107
|
label: "拖动标签",
|
|
1108
1108
|
timestamp: Date.now(),
|
|
@@ -1186,85 +1186,85 @@ function to({
|
|
|
1186
1186
|
defaultInsertGap: l,
|
|
1187
1187
|
getContextMenuItems: a,
|
|
1188
1188
|
onHighlightChange: v,
|
|
1189
|
-
resolveNodeShape:
|
|
1189
|
+
resolveNodeShape: f
|
|
1190
1190
|
}) {
|
|
1191
|
-
const
|
|
1192
|
-
let
|
|
1193
|
-
async function
|
|
1194
|
-
if (O) return
|
|
1191
|
+
const p = i ?? ze;
|
|
1192
|
+
let u = [], w = [], D = null, O = !1, b = null;
|
|
1193
|
+
async function S() {
|
|
1194
|
+
if (O) return D;
|
|
1195
1195
|
O = !0;
|
|
1196
1196
|
try {
|
|
1197
|
-
const
|
|
1198
|
-
return y ? (
|
|
1197
|
+
const d = await import("@antv/x6-plugin-dnd"), y = d.Dnd ?? d.default;
|
|
1198
|
+
return y ? (D = new y({
|
|
1199
1199
|
target: n,
|
|
1200
1200
|
scaled: !0,
|
|
1201
1201
|
animation: !0,
|
|
1202
|
-
getDragNode: (
|
|
1203
|
-
getDropNode: (
|
|
1204
|
-
}),
|
|
1202
|
+
getDragNode: (c) => c.clone(),
|
|
1203
|
+
getDropNode: (c) => c.clone()
|
|
1204
|
+
}), D) : null;
|
|
1205
1205
|
} catch {
|
|
1206
1206
|
return console.warn("[flow-canvas] @antv/x6-plugin-dnd not available, add it to your dependencies"), null;
|
|
1207
1207
|
}
|
|
1208
1208
|
}
|
|
1209
|
-
function
|
|
1210
|
-
return new Promise((
|
|
1211
|
-
requestAnimationFrame(() => requestAnimationFrame(() =>
|
|
1209
|
+
function M() {
|
|
1210
|
+
return new Promise((d) => {
|
|
1211
|
+
requestAnimationFrame(() => requestAnimationFrame(() => d()));
|
|
1212
1212
|
});
|
|
1213
1213
|
}
|
|
1214
|
-
const
|
|
1215
|
-
const y =
|
|
1214
|
+
const B = ({ node: d }) => {
|
|
1215
|
+
const y = d.getData?.();
|
|
1216
1216
|
if (!y?._dndSessionId || y._dndSessionId !== b) return;
|
|
1217
1217
|
b = null;
|
|
1218
|
-
const
|
|
1219
|
-
n.removeNode(
|
|
1220
|
-
const { _dndSessionId: g, ...
|
|
1218
|
+
const c = d.getPosition();
|
|
1219
|
+
n.removeNode(d.id);
|
|
1220
|
+
const { _dndSessionId: g, ...h } = y, m = h.id || p("node");
|
|
1221
1221
|
o({
|
|
1222
|
-
id:
|
|
1222
|
+
id: J(),
|
|
1223
1223
|
source: "user:drag",
|
|
1224
1224
|
label: "拖入节点",
|
|
1225
1225
|
timestamp: Date.now(),
|
|
1226
1226
|
commands: [
|
|
1227
1227
|
{
|
|
1228
1228
|
type: "node.add",
|
|
1229
|
-
node: { ...
|
|
1229
|
+
node: { ...h, id: m, position: { x: c.x, y: c.y } }
|
|
1230
1230
|
}
|
|
1231
1231
|
]
|
|
1232
1232
|
});
|
|
1233
1233
|
};
|
|
1234
|
-
n.on("node:added",
|
|
1235
|
-
function
|
|
1236
|
-
const y = t.nodeTypes[
|
|
1237
|
-
return
|
|
1234
|
+
n.on("node:added", B);
|
|
1235
|
+
function j(d) {
|
|
1236
|
+
const y = t.nodeTypes[d.type];
|
|
1237
|
+
return Ue(d, y?.getPorts);
|
|
1238
1238
|
}
|
|
1239
|
-
function k(
|
|
1240
|
-
return
|
|
1239
|
+
function k(d) {
|
|
1240
|
+
return d ?? ft(n.getSelectedCells?.() ?? []);
|
|
1241
1241
|
}
|
|
1242
|
-
function
|
|
1243
|
-
switch (
|
|
1242
|
+
function X(d, y, c, g, h) {
|
|
1243
|
+
switch (d) {
|
|
1244
1244
|
case "left":
|
|
1245
1245
|
return {
|
|
1246
|
-
x: y.position.x -
|
|
1247
|
-
y: y.position.y + (
|
|
1246
|
+
x: y.position.x - h - g.width,
|
|
1247
|
+
y: y.position.y + (c.height - g.height) / 2
|
|
1248
1248
|
};
|
|
1249
1249
|
case "top":
|
|
1250
1250
|
return {
|
|
1251
|
-
x: y.position.x + (
|
|
1252
|
-
y: y.position.y -
|
|
1251
|
+
x: y.position.x + (c.width - g.width) / 2,
|
|
1252
|
+
y: y.position.y - h - g.height
|
|
1253
1253
|
};
|
|
1254
1254
|
case "bottom":
|
|
1255
1255
|
return {
|
|
1256
|
-
x: y.position.x + (
|
|
1257
|
-
y: y.position.y +
|
|
1256
|
+
x: y.position.x + (c.width - g.width) / 2,
|
|
1257
|
+
y: y.position.y + c.height + h
|
|
1258
1258
|
};
|
|
1259
1259
|
default:
|
|
1260
1260
|
return {
|
|
1261
|
-
x: y.position.x +
|
|
1262
|
-
y: y.position.y + (
|
|
1261
|
+
x: y.position.x + c.width + h,
|
|
1262
|
+
y: y.position.y + (c.height - g.height) / 2
|
|
1263
1263
|
};
|
|
1264
1264
|
}
|
|
1265
1265
|
}
|
|
1266
|
-
function
|
|
1267
|
-
switch (
|
|
1266
|
+
function U(d) {
|
|
1267
|
+
switch (d) {
|
|
1268
1268
|
case "left":
|
|
1269
1269
|
return "right";
|
|
1270
1270
|
case "top":
|
|
@@ -1275,18 +1275,18 @@ function to({
|
|
|
1275
1275
|
return "left";
|
|
1276
1276
|
}
|
|
1277
1277
|
}
|
|
1278
|
-
const
|
|
1278
|
+
const G = {
|
|
1279
1279
|
zoomIn() {
|
|
1280
1280
|
n.zoom(0.1);
|
|
1281
1281
|
},
|
|
1282
1282
|
zoomOut() {
|
|
1283
1283
|
n.zoom(-0.1);
|
|
1284
1284
|
},
|
|
1285
|
-
zoomTo(
|
|
1286
|
-
n.zoomTo(
|
|
1285
|
+
zoomTo(d) {
|
|
1286
|
+
n.zoomTo(d);
|
|
1287
1287
|
},
|
|
1288
|
-
zoomToFit() {
|
|
1289
|
-
n.zoomToFit({ padding: 40, maxScale: 1
|
|
1288
|
+
zoomToFit(d) {
|
|
1289
|
+
n.zoomToFit({ padding: 40, maxScale: 1, ...d });
|
|
1290
1290
|
},
|
|
1291
1291
|
getZoom() {
|
|
1292
1292
|
return n.zoom();
|
|
@@ -1297,218 +1297,218 @@ function to({
|
|
|
1297
1297
|
scrollToOrigin() {
|
|
1298
1298
|
n.translate(0, 0);
|
|
1299
1299
|
},
|
|
1300
|
-
scrollToNode(
|
|
1301
|
-
const y = n.getCellById(
|
|
1300
|
+
scrollToNode(d) {
|
|
1301
|
+
const y = n.getCellById(d);
|
|
1302
1302
|
y && n.centerCell(y);
|
|
1303
1303
|
},
|
|
1304
1304
|
getSelection() {
|
|
1305
1305
|
return k();
|
|
1306
1306
|
},
|
|
1307
|
-
getSelectionBounds(
|
|
1308
|
-
return Qt(n, k(
|
|
1307
|
+
getSelectionBounds(d) {
|
|
1308
|
+
return Qt(n, k(d));
|
|
1309
1309
|
},
|
|
1310
|
-
selectNodes(
|
|
1311
|
-
const y =
|
|
1310
|
+
selectNodes(d) {
|
|
1311
|
+
const y = d.map((c) => n.getCellById(c)).filter(Boolean);
|
|
1312
1312
|
n.select?.(y);
|
|
1313
1313
|
},
|
|
1314
|
-
selectEdges(
|
|
1315
|
-
const y =
|
|
1314
|
+
selectEdges(d) {
|
|
1315
|
+
const y = d.map((c) => n.getCellById(c)).filter(Boolean);
|
|
1316
1316
|
n.select?.(y);
|
|
1317
1317
|
},
|
|
1318
1318
|
clearSelection() {
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1319
|
+
const d = n.getSelectedCells?.();
|
|
1320
|
+
d?.length && n.unselect?.(d);
|
|
1321
1321
|
},
|
|
1322
|
-
deleteSelection(
|
|
1323
|
-
const y = k(
|
|
1322
|
+
deleteSelection(d) {
|
|
1323
|
+
const y = k(d?.selection), c = gt(y, s.value, r ?? (() => ({}))), g = Jt(c);
|
|
1324
1324
|
if (g.length === 0) return null;
|
|
1325
|
-
const
|
|
1326
|
-
id:
|
|
1327
|
-
source:
|
|
1328
|
-
label:
|
|
1325
|
+
const h = o({
|
|
1326
|
+
id: J(),
|
|
1327
|
+
source: d?.source ?? "user:toolbar",
|
|
1328
|
+
label: d?.label ?? "删除选中",
|
|
1329
1329
|
timestamp: Date.now(),
|
|
1330
1330
|
commands: g
|
|
1331
1331
|
});
|
|
1332
|
-
return
|
|
1332
|
+
return h.status === "applied" && d?.clearSelectionAfterApply !== !1 && G.clearSelection(), h;
|
|
1333
1333
|
},
|
|
1334
|
-
registerDndSource(
|
|
1335
|
-
const
|
|
1336
|
-
const
|
|
1337
|
-
if (!
|
|
1338
|
-
const m =
|
|
1334
|
+
registerDndSource(d, y) {
|
|
1335
|
+
const c = async (g) => {
|
|
1336
|
+
const h = await S();
|
|
1337
|
+
if (!h) return;
|
|
1338
|
+
const m = J();
|
|
1339
1339
|
b = m;
|
|
1340
|
-
const E = y(),
|
|
1341
|
-
width:
|
|
1342
|
-
height:
|
|
1343
|
-
shape:
|
|
1340
|
+
const E = y(), L = f?.(E.type), z = n.createNode({
|
|
1341
|
+
width: L?.width ?? 154,
|
|
1342
|
+
height: L?.height ?? 54,
|
|
1343
|
+
shape: L?.shapeName ?? "rect",
|
|
1344
1344
|
data: { ...E, _dndSessionId: m }
|
|
1345
1345
|
});
|
|
1346
|
-
|
|
1346
|
+
h.start(z, g);
|
|
1347
1347
|
};
|
|
1348
|
-
return
|
|
1349
|
-
|
|
1348
|
+
return d.addEventListener("mousedown", c), () => {
|
|
1349
|
+
d.removeEventListener("mousedown", c);
|
|
1350
1350
|
};
|
|
1351
1351
|
},
|
|
1352
1352
|
/**
|
|
1353
1353
|
* 通过编程方式发起连线:直接命中真实 port 元素,
|
|
1354
1354
|
* 复用 X6 原生的连线拖拽流程与 connecting.createEdge 配置。
|
|
1355
1355
|
*/
|
|
1356
|
-
startConnection(
|
|
1357
|
-
const
|
|
1358
|
-
if (!
|
|
1359
|
-
const g =
|
|
1360
|
-
if (!
|
|
1361
|
-
const m =
|
|
1356
|
+
startConnection(d, y) {
|
|
1357
|
+
const c = n.getCellById(d);
|
|
1358
|
+
if (!c?.isNode()) return;
|
|
1359
|
+
const g = c, h = n.findViewByCell(g);
|
|
1360
|
+
if (!h) return;
|
|
1361
|
+
const m = h.findPortElem(y, "circle") ?? h.findPortElem(y);
|
|
1362
1362
|
if (!m) return;
|
|
1363
|
-
const
|
|
1364
|
-
clientX:
|
|
1365
|
-
clientY:
|
|
1363
|
+
const L = (m.matches?.("[magnet]") ? m : m.querySelector?.("[magnet]")) ?? m, z = L.getBoundingClientRect(), ie = z.left + z.width / 2, N = z.top + z.height / 2, _ = new MouseEvent("mousedown", {
|
|
1364
|
+
clientX: ie,
|
|
1365
|
+
clientY: N,
|
|
1366
1366
|
button: 0,
|
|
1367
1367
|
buttons: 1,
|
|
1368
1368
|
bubbles: !0,
|
|
1369
1369
|
cancelable: !0
|
|
1370
1370
|
});
|
|
1371
|
-
|
|
1371
|
+
L.dispatchEvent(_);
|
|
1372
1372
|
},
|
|
1373
|
-
async exportAsImage(
|
|
1374
|
-
const { domToBlob: y } = await import("modern-screenshot"),
|
|
1375
|
-
if (
|
|
1373
|
+
async exportAsImage(d) {
|
|
1374
|
+
const { domToBlob: y } = await import("modern-screenshot"), c = d?.padding ?? 20, g = d?.backgroundColor ?? n.options.background?.color ?? "#ffffff", h = n.zoom(), m = n.translate(), E = n.getContentBBox(), L = E.width / h, z = E.height / h;
|
|
1375
|
+
if (L === 0 || z === 0)
|
|
1376
1376
|
return new Blob();
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1377
|
+
const ie = (E.x - m.tx) / h, N = (E.y - m.ty) / h, _ = Math.ceil(L + c * 2), x = Math.ceil(z + c * 2), R = document.createElement("div");
|
|
1378
|
+
R.style.cssText = "position:fixed;left:-99999px;top:0;pointer-events:none;";
|
|
1379
|
+
const F = n.container.cloneNode(!0);
|
|
1380
|
+
F.style.width = `${_}px`, F.style.height = `${x}px`, F.style.overflow = "visible";
|
|
1381
|
+
const Z = F.querySelector("svg");
|
|
1382
|
+
Z && (Z.setAttribute("width", String(_)), Z.setAttribute("height", String(x)), Z.style.width = `${_}px`, Z.style.height = `${x}px`), F.querySelector(".x6-graph-svg-viewport")?.setAttribute("transform", `matrix(1,0,0,1,${-ie + c},${-N + c})`), R.appendChild(F), document.body.appendChild(R);
|
|
1383
1383
|
try {
|
|
1384
|
-
return await
|
|
1385
|
-
width:
|
|
1386
|
-
height:
|
|
1384
|
+
return await M(), await y(F, {
|
|
1385
|
+
width: _,
|
|
1386
|
+
height: x,
|
|
1387
1387
|
backgroundColor: g,
|
|
1388
|
-
scale:
|
|
1389
|
-
filter: (
|
|
1390
|
-
if (
|
|
1391
|
-
const
|
|
1392
|
-
if (
|
|
1388
|
+
scale: d?.scale ?? window.devicePixelRatio,
|
|
1389
|
+
filter: (Q) => {
|
|
1390
|
+
if (Q instanceof Element) {
|
|
1391
|
+
const K = Q.getAttribute("class") ?? "";
|
|
1392
|
+
if (K.includes("x6-widget-selection") || K.includes("x6-widget-transform") || K.includes("x6-graph-grid") || K.includes("x6-graph-background"))
|
|
1393
1393
|
return !1;
|
|
1394
1394
|
}
|
|
1395
1395
|
return !0;
|
|
1396
1396
|
}
|
|
1397
1397
|
});
|
|
1398
|
-
} catch (
|
|
1399
|
-
return console.warn("[flow-canvas] Export failed:",
|
|
1398
|
+
} catch (Q) {
|
|
1399
|
+
return console.warn("[flow-canvas] Export failed:", Q), new Blob();
|
|
1400
1400
|
} finally {
|
|
1401
|
-
|
|
1401
|
+
R.remove();
|
|
1402
1402
|
}
|
|
1403
1403
|
},
|
|
1404
|
-
highlightNodes(
|
|
1405
|
-
|
|
1404
|
+
highlightNodes(d) {
|
|
1405
|
+
u = d, v?.(u, w);
|
|
1406
1406
|
},
|
|
1407
|
-
highlightEdges(
|
|
1408
|
-
w =
|
|
1407
|
+
highlightEdges(d) {
|
|
1408
|
+
w = d, v?.(u, w);
|
|
1409
1409
|
},
|
|
1410
1410
|
clearHighlight() {
|
|
1411
|
-
|
|
1411
|
+
u = [], w = [], v?.([], []);
|
|
1412
1412
|
},
|
|
1413
1413
|
overlay: e,
|
|
1414
|
-
getContextMenuItems(
|
|
1415
|
-
return a?.(
|
|
1414
|
+
getContextMenuItems(d) {
|
|
1415
|
+
return a?.(d) ?? [];
|
|
1416
1416
|
},
|
|
1417
|
-
insertNodeToRight(
|
|
1418
|
-
const g = s.value,
|
|
1419
|
-
if (!
|
|
1417
|
+
insertNodeToRight(d, y, c) {
|
|
1418
|
+
const g = s.value, h = g.nodes[d];
|
|
1419
|
+
if (!h)
|
|
1420
1420
|
return {
|
|
1421
1421
|
status: "invalid",
|
|
1422
1422
|
envelope: { id: "", source: "user:toolbar", timestamp: Date.now(), commands: [] },
|
|
1423
|
-
error: { code: "constraint_violated", reason: `Source node "${
|
|
1423
|
+
error: { code: "constraint_violated", reason: `Source node "${d}" not found`, source: "api" }
|
|
1424
1424
|
};
|
|
1425
|
-
const m =
|
|
1425
|
+
const m = c?.gap ?? l ?? eo, E = c?.direction ?? "right", L = t.nodeTypes[h.type], z = t.nodeTypes[y.type], ie = L?.getSize(h) ?? { width: 154, height: 54 }, N = z?.getSize({ ...y, position: { x: 0, y: 0 } }) ?? {
|
|
1426
1426
|
width: 154,
|
|
1427
1427
|
height: 54
|
|
1428
|
-
},
|
|
1429
|
-
if (
|
|
1430
|
-
const
|
|
1431
|
-
(I) => I.source.nodeId ===
|
|
1432
|
-
) : Object.values(g.edges).find((I) => I.source.nodeId ===
|
|
1428
|
+
}, _ = X(E, h, ie, N, m), x = y.id || p("node"), R = { ...y, id: x, position: _ }, F = [{ type: "node.add", node: R }];
|
|
1429
|
+
if (c?.autoWireEdges) {
|
|
1430
|
+
const ae = j(h), Q = j(R), K = E, me = U(E), pe = ae.find((I) => I.group === K), we = Q.find((I) => I.group === me), $e = Q.find((I) => I.group === K), Se = pe ? Object.values(g.edges).find(
|
|
1431
|
+
(I) => I.source.nodeId === d && I.source.portId === pe.id
|
|
1432
|
+
) : Object.values(g.edges).find((I) => I.source.nodeId === d);
|
|
1433
1433
|
if (Se) {
|
|
1434
|
-
const I = Se.target, C =
|
|
1435
|
-
for (;
|
|
1436
|
-
const
|
|
1437
|
-
if (
|
|
1438
|
-
|
|
1439
|
-
const xe = g.nodes[
|
|
1434
|
+
const I = Se.target, C = N.width + m, P = E === "right" ? C : E === "left" ? -C : 0, W = E === "bottom" ? C : E === "top" ? -C : 0, ee = /* @__PURE__ */ new Set(), le = [I.nodeId];
|
|
1435
|
+
for (; le.length > 0; ) {
|
|
1436
|
+
const oe = le.shift();
|
|
1437
|
+
if (ee.has(oe) || oe === d) continue;
|
|
1438
|
+
ee.add(oe);
|
|
1439
|
+
const xe = g.nodes[oe];
|
|
1440
1440
|
if (xe) {
|
|
1441
|
-
|
|
1441
|
+
F.push({
|
|
1442
1442
|
type: "node.move",
|
|
1443
|
-
nodeId:
|
|
1443
|
+
nodeId: oe,
|
|
1444
1444
|
position: {
|
|
1445
|
-
x: xe.position.x +
|
|
1445
|
+
x: xe.position.x + P,
|
|
1446
1446
|
y: xe.position.y + W
|
|
1447
1447
|
}
|
|
1448
1448
|
});
|
|
1449
|
-
for (const
|
|
1450
|
-
|
|
1449
|
+
for (const be of Object.values(g.edges))
|
|
1450
|
+
be.source.nodeId === oe && !ee.has(be.target.nodeId) && le.push(be.target.nodeId);
|
|
1451
1451
|
}
|
|
1452
1452
|
}
|
|
1453
|
-
|
|
1453
|
+
F.push({ type: "edge.remove", edgeId: Se.id }), F.push({
|
|
1454
1454
|
type: "edge.add",
|
|
1455
1455
|
edge: {
|
|
1456
|
-
id:
|
|
1457
|
-
source: { nodeId:
|
|
1458
|
-
target: { nodeId:
|
|
1456
|
+
id: p("edge"),
|
|
1457
|
+
source: { nodeId: d, portId: pe?.id },
|
|
1458
|
+
target: { nodeId: x, portId: we?.id }
|
|
1459
1459
|
}
|
|
1460
|
-
}),
|
|
1460
|
+
}), F.push({
|
|
1461
1461
|
type: "edge.add",
|
|
1462
1462
|
edge: {
|
|
1463
|
-
id:
|
|
1464
|
-
source: { nodeId:
|
|
1463
|
+
id: p("edge"),
|
|
1464
|
+
source: { nodeId: x, portId: $e?.id },
|
|
1465
1465
|
target: I
|
|
1466
1466
|
}
|
|
1467
1467
|
});
|
|
1468
1468
|
} else
|
|
1469
|
-
|
|
1469
|
+
F.push({
|
|
1470
1470
|
type: "edge.add",
|
|
1471
1471
|
edge: {
|
|
1472
|
-
id:
|
|
1473
|
-
source: { nodeId:
|
|
1474
|
-
target: { nodeId:
|
|
1472
|
+
id: p("edge"),
|
|
1473
|
+
source: { nodeId: d, portId: pe?.id },
|
|
1474
|
+
target: { nodeId: x, portId: we?.id }
|
|
1475
1475
|
}
|
|
1476
1476
|
});
|
|
1477
1477
|
}
|
|
1478
|
-
const
|
|
1479
|
-
id:
|
|
1480
|
-
source:
|
|
1481
|
-
label:
|
|
1478
|
+
const Z = {
|
|
1479
|
+
id: J(),
|
|
1480
|
+
source: c?.source ?? "user:toolbar",
|
|
1481
|
+
label: c?.label ?? "插入节点",
|
|
1482
1482
|
timestamp: Date.now(),
|
|
1483
|
-
commands:
|
|
1483
|
+
commands: F
|
|
1484
1484
|
};
|
|
1485
|
-
return o(
|
|
1485
|
+
return o(Z);
|
|
1486
1486
|
},
|
|
1487
|
-
onGraphEvent(
|
|
1488
|
-
return n.on(
|
|
1487
|
+
onGraphEvent(d, y) {
|
|
1488
|
+
return n.on(d, y), () => n.off(d, y);
|
|
1489
1489
|
},
|
|
1490
1490
|
unsafeGetGraph() {
|
|
1491
1491
|
return n;
|
|
1492
1492
|
}
|
|
1493
1493
|
};
|
|
1494
|
-
return
|
|
1494
|
+
return G;
|
|
1495
1495
|
}
|
|
1496
1496
|
function oo() {
|
|
1497
|
-
const n =
|
|
1497
|
+
const n = H(null), e = H(!1);
|
|
1498
1498
|
let o = null, t = !1;
|
|
1499
|
-
function s(
|
|
1500
|
-
o && (clearTimeout(o), o = null), n.value =
|
|
1499
|
+
function s(p) {
|
|
1500
|
+
o && (clearTimeout(o), o = null), n.value = p;
|
|
1501
1501
|
}
|
|
1502
|
-
function r(
|
|
1502
|
+
function r(p = 100) {
|
|
1503
1503
|
t || (o && clearTimeout(o), o = setTimeout(() => {
|
|
1504
1504
|
n.value = null, o = null;
|
|
1505
|
-
},
|
|
1505
|
+
}, p));
|
|
1506
1506
|
}
|
|
1507
1507
|
function i() {
|
|
1508
1508
|
t = !0, o && (clearTimeout(o), o = null);
|
|
1509
1509
|
}
|
|
1510
|
-
function l(
|
|
1511
|
-
t = !1, r(
|
|
1510
|
+
function l(p = 100) {
|
|
1511
|
+
t = !1, r(p);
|
|
1512
1512
|
}
|
|
1513
1513
|
function a() {
|
|
1514
1514
|
o && (clearTimeout(o), o = null);
|
|
@@ -1516,33 +1516,33 @@ function oo() {
|
|
|
1516
1516
|
function v() {
|
|
1517
1517
|
a(), t = !1, n.value = null;
|
|
1518
1518
|
}
|
|
1519
|
-
function
|
|
1519
|
+
function f() {
|
|
1520
1520
|
o && clearTimeout(o);
|
|
1521
1521
|
}
|
|
1522
|
-
return { hoveredNodeId: n, isDraggingNode: e, enter: s, leave: r, enterOverlay: i, leaveOverlay: l, cancelLeave: a, reset: v, cleanup:
|
|
1522
|
+
return { hoveredNodeId: n, isDraggingNode: e, enter: s, leave: r, enterOverlay: i, leaveOverlay: l, cancelLeave: a, reset: v, cleanup: f };
|
|
1523
1523
|
}
|
|
1524
|
-
const
|
|
1525
|
-
function
|
|
1524
|
+
const Xe = 10, Ae = 12;
|
|
1525
|
+
function Ke(n, e) {
|
|
1526
1526
|
const o = n.getTotalLength();
|
|
1527
1527
|
if (o === 0) return { ...e, length: 0, totalLength: 0 };
|
|
1528
1528
|
let t = n.getPointAtLength(0), s = 1 / 0;
|
|
1529
1529
|
const r = 50, i = o / r;
|
|
1530
1530
|
let l = 0;
|
|
1531
|
-
for (let
|
|
1532
|
-
const
|
|
1533
|
-
|
|
1531
|
+
for (let p = 0; p <= r; p++) {
|
|
1532
|
+
const u = p * i, w = n.getPointAtLength(u), D = (w.x - e.x) ** 2 + (w.y - e.y) ** 2;
|
|
1533
|
+
D < s && (s = D, t = w, l = u);
|
|
1534
1534
|
}
|
|
1535
|
-
const a = Math.max(0, l - i), v = Math.min(o, l + i),
|
|
1536
|
-
for (let
|
|
1537
|
-
const
|
|
1538
|
-
w < s && (s = w, t =
|
|
1535
|
+
const a = Math.max(0, l - i), v = Math.min(o, l + i), f = (v - a) / 20;
|
|
1536
|
+
for (let p = a; p <= v; p += f) {
|
|
1537
|
+
const u = n.getPointAtLength(p), w = (u.x - e.x) ** 2 + (u.y - e.y) ** 2;
|
|
1538
|
+
w < s && (s = w, t = u, l = p);
|
|
1539
1539
|
}
|
|
1540
1540
|
return { x: t.x, y: t.y, length: l, totalLength: o };
|
|
1541
1541
|
}
|
|
1542
|
-
function
|
|
1543
|
-
return n <
|
|
1542
|
+
function Ye(n, e) {
|
|
1543
|
+
return n < Xe || n > e - Xe;
|
|
1544
1544
|
}
|
|
1545
|
-
function
|
|
1545
|
+
function Ze(n, e, o) {
|
|
1546
1546
|
const t = n.querySelectorAll(".x6-edge-label");
|
|
1547
1547
|
for (const s of t) {
|
|
1548
1548
|
const r = s.getBoundingClientRect();
|
|
@@ -1551,7 +1551,7 @@ function Ye(n, e, o) {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
return !1;
|
|
1553
1553
|
}
|
|
1554
|
-
function
|
|
1554
|
+
function Qe() {
|
|
1555
1555
|
const n = "http://www.w3.org/2000/svg", e = document.createElementNS(n, "g");
|
|
1556
1556
|
e.setAttribute("class", "flow-canvas-edge-delete-tool"), e.style.cursor = "pointer";
|
|
1557
1557
|
const o = document.createElementNS(n, "rect");
|
|
@@ -1563,16 +1563,16 @@ function no(n) {
|
|
|
1563
1563
|
let e = null, o = null;
|
|
1564
1564
|
function t(l, a) {
|
|
1565
1565
|
if (r(), o = l, a.target?.closest?.(".x6-edge-label")) return;
|
|
1566
|
-
const
|
|
1567
|
-
if (!
|
|
1568
|
-
const
|
|
1569
|
-
if (!
|
|
1570
|
-
const
|
|
1571
|
-
if (!
|
|
1572
|
-
const w = n.clientToLocal(a.clientX, a.clientY),
|
|
1573
|
-
if (
|
|
1574
|
-
const O =
|
|
1575
|
-
O.setAttribute("transform", `translate(${
|
|
1566
|
+
const f = n.getCellById(l);
|
|
1567
|
+
if (!f?.isEdge()) return;
|
|
1568
|
+
const p = n.findViewByCell(f);
|
|
1569
|
+
if (!p) return;
|
|
1570
|
+
const u = p.container.querySelector("path");
|
|
1571
|
+
if (!u) return;
|
|
1572
|
+
const w = n.clientToLocal(a.clientX, a.clientY), D = Ke(u, w);
|
|
1573
|
+
if (Ye(D.length, D.totalLength) || Ze(p.container, a.clientX, a.clientY)) return;
|
|
1574
|
+
const O = Qe();
|
|
1575
|
+
O.setAttribute("transform", `translate(${D.x}, ${D.y})`), p.container.appendChild(O), e = O;
|
|
1576
1576
|
}
|
|
1577
1577
|
function s(l) {
|
|
1578
1578
|
if (!o) return;
|
|
@@ -1582,18 +1582,18 @@ function no(n) {
|
|
|
1582
1582
|
}
|
|
1583
1583
|
const v = n.getCellById(o);
|
|
1584
1584
|
if (!v?.isEdge()) return;
|
|
1585
|
-
const
|
|
1586
|
-
if (!
|
|
1587
|
-
const
|
|
1588
|
-
if (!
|
|
1589
|
-
const
|
|
1590
|
-
if (
|
|
1585
|
+
const f = n.findViewByCell(v);
|
|
1586
|
+
if (!f) return;
|
|
1587
|
+
const p = f.container.querySelector("path");
|
|
1588
|
+
if (!p) return;
|
|
1589
|
+
const u = n.clientToLocal(l.clientX, l.clientY), w = Ke(p, u);
|
|
1590
|
+
if (Ye(w.length, w.totalLength) || Ze(f.container, l.clientX, l.clientY))
|
|
1591
1591
|
e && e.setAttribute("display", "none");
|
|
1592
1592
|
else if (e)
|
|
1593
1593
|
e.removeAttribute("display"), e.setAttribute("transform", `translate(${w.x}, ${w.y})`);
|
|
1594
1594
|
else {
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1595
|
+
const D = Qe();
|
|
1596
|
+
D.setAttribute("transform", `translate(${w.x}, ${w.y})`), f.container.appendChild(D), e = D;
|
|
1597
1597
|
}
|
|
1598
1598
|
}
|
|
1599
1599
|
function r() {
|
|
@@ -1606,29 +1606,29 @@ function no(n) {
|
|
|
1606
1606
|
}
|
|
1607
1607
|
function so(n) {
|
|
1608
1608
|
let e = null, o = 0;
|
|
1609
|
-
function t(
|
|
1610
|
-
const
|
|
1611
|
-
for (const
|
|
1612
|
-
for (const w of
|
|
1613
|
-
|
|
1609
|
+
function t(f) {
|
|
1610
|
+
const p = f ? "visible" : "hidden";
|
|
1611
|
+
for (const u of n.getNodes())
|
|
1612
|
+
for (const w of u.getPorts())
|
|
1613
|
+
u.setPortProp(w.id, "attrs/circle/visibility", p);
|
|
1614
1614
|
}
|
|
1615
|
-
function s(
|
|
1615
|
+
function s(f) {
|
|
1616
1616
|
if (!e)
|
|
1617
|
-
for (const
|
|
1618
|
-
|
|
1617
|
+
for (const p of f.getPorts())
|
|
1618
|
+
f.setPortProp(p.id, "attrs/circle/visibility", "visible");
|
|
1619
1619
|
}
|
|
1620
|
-
function r(
|
|
1620
|
+
function r(f) {
|
|
1621
1621
|
if (!e)
|
|
1622
|
-
for (const
|
|
1623
|
-
|
|
1624
|
-
}
|
|
1625
|
-
function i(
|
|
1626
|
-
if (!
|
|
1627
|
-
if (e =
|
|
1628
|
-
for (const
|
|
1629
|
-
const w =
|
|
1630
|
-
for (const
|
|
1631
|
-
|
|
1622
|
+
for (const p of f.getPorts())
|
|
1623
|
+
f.setPortProp(p.id, "attrs/circle/visibility", "hidden");
|
|
1624
|
+
}
|
|
1625
|
+
function i(f, p) {
|
|
1626
|
+
if (!f.getTargetCell())
|
|
1627
|
+
if (e = f.id, p?.size)
|
|
1628
|
+
for (const u of n.getNodes()) {
|
|
1629
|
+
const w = p.has(u.id) ? "hidden" : "visible";
|
|
1630
|
+
for (const D of u.getPorts())
|
|
1631
|
+
u.setPortProp(D.id, "attrs/circle/visibility", w);
|
|
1632
1632
|
}
|
|
1633
1633
|
else
|
|
1634
1634
|
t(!0);
|
|
@@ -1636,8 +1636,8 @@ function so(n) {
|
|
|
1636
1636
|
function l() {
|
|
1637
1637
|
e = null, t(!1), o = Date.now() + 300;
|
|
1638
1638
|
}
|
|
1639
|
-
function a(
|
|
1640
|
-
|
|
1639
|
+
function a(f) {
|
|
1640
|
+
f === e && (e = null, t(!1));
|
|
1641
1641
|
}
|
|
1642
1642
|
function v() {
|
|
1643
1643
|
return !e && Date.now() >= o;
|
|
@@ -1651,48 +1651,50 @@ function so(n) {
|
|
|
1651
1651
|
canShowEdgeTool: v
|
|
1652
1652
|
};
|
|
1653
1653
|
}
|
|
1654
|
-
function
|
|
1654
|
+
function Je(n) {
|
|
1655
1655
|
return n === "top" || n === "right" || n === "bottom" || n === "left";
|
|
1656
1656
|
}
|
|
1657
1657
|
function ro(n) {
|
|
1658
|
-
const { editor: e, nodeHover: o, isSelectionModeActive: t, viewportVersion: s, getNodeBehavior: r, getInsertGap: i } = n, { isDraggingNode: l } = n, a =
|
|
1659
|
-
let
|
|
1658
|
+
const { editor: e, nodeHover: o, isSelectionModeActive: t, viewportVersion: s, getNodeBehavior: r, getInsertGap: i } = n, { isDraggingNode: l } = n, a = H(null), v = H(!1);
|
|
1659
|
+
let f = null, p = null, u = null;
|
|
1660
1660
|
const w = V(() => ({
|
|
1661
1661
|
enabled: !0,
|
|
1662
1662
|
portGroup: "right",
|
|
1663
|
+
autoPanOnOpen: !0,
|
|
1664
|
+
autoPanPadding: 16,
|
|
1663
1665
|
...n.quickAddProp.value
|
|
1664
1666
|
}));
|
|
1665
|
-
function
|
|
1666
|
-
|
|
1667
|
+
function D() {
|
|
1668
|
+
f && (clearTimeout(f), f = null);
|
|
1667
1669
|
}
|
|
1668
1670
|
function O() {
|
|
1669
|
-
|
|
1670
|
-
a.value = null,
|
|
1671
|
+
f && clearTimeout(f), f = setTimeout(() => {
|
|
1672
|
+
a.value = null, f = null;
|
|
1671
1673
|
}, 150);
|
|
1672
1674
|
}
|
|
1673
|
-
function b(
|
|
1674
|
-
return v.value ? !0 : (
|
|
1675
|
-
}
|
|
1676
|
-
function M() {
|
|
1677
|
-
N(), o.enterOverlay();
|
|
1675
|
+
function b(N) {
|
|
1676
|
+
return v.value ? !0 : (D(), d(N) ? (a.value = N, !0) : (a.value = null, !1));
|
|
1678
1677
|
}
|
|
1679
1678
|
function S() {
|
|
1679
|
+
D(), o.enterOverlay();
|
|
1680
|
+
}
|
|
1681
|
+
function M() {
|
|
1680
1682
|
O(), o.leaveOverlay();
|
|
1681
1683
|
}
|
|
1682
|
-
function
|
|
1683
|
-
const
|
|
1684
|
-
return
|
|
1684
|
+
function B(N) {
|
|
1685
|
+
const _ = e.schema.nodeTypes[N.type];
|
|
1686
|
+
return Ue(N, _?.getPorts);
|
|
1685
1687
|
}
|
|
1686
|
-
function
|
|
1687
|
-
const x = w.value.getPort?.(
|
|
1688
|
+
function j(N, _) {
|
|
1689
|
+
const x = w.value.getPort?.(N, _);
|
|
1688
1690
|
if (!x) return null;
|
|
1689
|
-
const
|
|
1690
|
-
return
|
|
1691
|
+
const R = typeof x == "string" ? x : x.id;
|
|
1692
|
+
return _.find((F) => F.id === R) ?? null;
|
|
1691
1693
|
}
|
|
1692
|
-
function k(
|
|
1693
|
-
const x = e.api.value?.overlay.getNodeScreenRect(
|
|
1694
|
+
function k(N, _) {
|
|
1695
|
+
const x = e.api.value?.overlay.getNodeScreenRect(N);
|
|
1694
1696
|
if (!x) return null;
|
|
1695
|
-
switch (
|
|
1697
|
+
switch (_) {
|
|
1696
1698
|
case "top":
|
|
1697
1699
|
return { x: x.x + x.width / 2, y: x.y };
|
|
1698
1700
|
case "bottom":
|
|
@@ -1705,113 +1707,118 @@ function ro(n) {
|
|
|
1705
1707
|
return null;
|
|
1706
1708
|
}
|
|
1707
1709
|
}
|
|
1708
|
-
function
|
|
1709
|
-
if (!
|
|
1710
|
-
const
|
|
1711
|
-
if (
|
|
1712
|
-
const
|
|
1713
|
-
if (
|
|
1714
|
-
const
|
|
1710
|
+
function X(N, _, x) {
|
|
1711
|
+
if (!p) return k(N, x);
|
|
1712
|
+
const R = p.getCellById(N);
|
|
1713
|
+
if (R?.isNode()) {
|
|
1714
|
+
const F = R, Z = p.findViewByCell(F), ae = Z?.findPortElem(_, "circle") ?? Z?.findPortElem(_);
|
|
1715
|
+
if (ae) {
|
|
1716
|
+
const Q = p.container.getBoundingClientRect(), K = ae.getBoundingClientRect();
|
|
1715
1717
|
return {
|
|
1716
|
-
x:
|
|
1717
|
-
y:
|
|
1718
|
+
x: K.left - Q.left + K.width / 2,
|
|
1719
|
+
y: K.top - Q.top + K.height / 2
|
|
1718
1720
|
};
|
|
1719
1721
|
}
|
|
1720
1722
|
}
|
|
1721
|
-
return k(
|
|
1723
|
+
return k(N, x);
|
|
1722
1724
|
}
|
|
1723
|
-
function
|
|
1724
|
-
const
|
|
1725
|
+
function U(N) {
|
|
1726
|
+
const _ = B(N), x = j(N, _) ?? _.find((F) => F.group === w.value.portGroup) ?? null;
|
|
1725
1727
|
if (!x) return null;
|
|
1726
|
-
const
|
|
1727
|
-
return
|
|
1728
|
+
const R = X(N.id, x.id, x.group);
|
|
1729
|
+
return R ? { portId: x.id, portGroup: x.group, portPosition: R } : null;
|
|
1728
1730
|
}
|
|
1729
|
-
function
|
|
1730
|
-
const
|
|
1731
|
+
function G(N) {
|
|
1732
|
+
const _ = U(N), x = w.value.insertDirection;
|
|
1731
1733
|
if (typeof x == "function") {
|
|
1732
|
-
const
|
|
1733
|
-
if (
|
|
1734
|
+
const R = x(N, _ ? { id: _.portId, group: _.portGroup } : null);
|
|
1735
|
+
if (R) return R;
|
|
1734
1736
|
} else if (x)
|
|
1735
1737
|
return x;
|
|
1736
|
-
return
|
|
1738
|
+
return _ && Je(_.portGroup) ? _.portGroup : Je(w.value.portGroup) ? w.value.portGroup : "right";
|
|
1737
1739
|
}
|
|
1738
|
-
function
|
|
1740
|
+
function d(N) {
|
|
1739
1741
|
if (!w.value.enabled || e.mode.value !== "edit") return !1;
|
|
1740
|
-
const x = e.flowModel.value.nodes[
|
|
1741
|
-
return !x || r(x).quickAddEnabled === !1 ? !1 : !!
|
|
1742
|
+
const x = e.flowModel.value.nodes[N];
|
|
1743
|
+
return !x || r(x).quickAddEnabled === !1 ? !1 : !!U(x);
|
|
1742
1744
|
}
|
|
1743
1745
|
const y = V(() => {
|
|
1744
1746
|
if (s.value, !w.value.enabled) return null;
|
|
1745
|
-
const
|
|
1746
|
-
if (!
|
|
1747
|
+
const N = a.value;
|
|
1748
|
+
if (!N || l.value || !e.api.value || e.mode.value !== "edit" || t.value)
|
|
1747
1749
|
return null;
|
|
1748
|
-
const x = e.flowModel.value.nodes[
|
|
1750
|
+
const x = e.flowModel.value.nodes[N];
|
|
1749
1751
|
if (!x) return null;
|
|
1750
|
-
const
|
|
1751
|
-
if (
|
|
1752
|
-
const
|
|
1753
|
-
return
|
|
1752
|
+
const R = r(x);
|
|
1753
|
+
if (R.quickAddEnabled === !1) return null;
|
|
1754
|
+
const F = U(x);
|
|
1755
|
+
return F ? { node: x, ...F, behavior: R } : null;
|
|
1754
1756
|
});
|
|
1755
|
-
function
|
|
1756
|
-
v.value = !0, y.value && e._emitUiEvent({ type: "node.quick-add", nodeId:
|
|
1757
|
+
function c(N) {
|
|
1758
|
+
v.value = !0, y.value && e._emitUiEvent({ type: "node.quick-add", nodeId: N, position: y.value.portPosition });
|
|
1757
1759
|
}
|
|
1758
1760
|
function g() {
|
|
1759
1761
|
v.value = !1;
|
|
1760
1762
|
}
|
|
1761
|
-
function
|
|
1762
|
-
const
|
|
1763
|
-
if (!
|
|
1764
|
-
const x = e.flowModel.value.nodes[
|
|
1763
|
+
function h(N) {
|
|
1764
|
+
const _ = e.api.value;
|
|
1765
|
+
if (!_) return;
|
|
1766
|
+
const x = e.flowModel.value.nodes[N];
|
|
1765
1767
|
if (!x) return;
|
|
1766
|
-
const
|
|
1767
|
-
|
|
1768
|
+
const R = U(x);
|
|
1769
|
+
R && _.startConnection(N, R.portId);
|
|
1770
|
+
}
|
|
1771
|
+
function m(N) {
|
|
1772
|
+
if (!p || !w.value.autoPanOnOpen || N <= 0) return;
|
|
1773
|
+
const _ = p.translate();
|
|
1774
|
+
p.translate(_.tx - N, _.ty);
|
|
1768
1775
|
}
|
|
1769
|
-
function
|
|
1776
|
+
function E(N, _) {
|
|
1770
1777
|
const x = e.api.value;
|
|
1771
1778
|
if (!x) return;
|
|
1772
|
-
const
|
|
1773
|
-
if (!
|
|
1774
|
-
x.insertNodeToRight(
|
|
1779
|
+
const R = _.id || e.idGenerator("node"), F = { ..._, id: R }, Z = e.flowModel.value.nodes[N];
|
|
1780
|
+
if (!Z) return;
|
|
1781
|
+
x.insertNodeToRight(N, F, {
|
|
1775
1782
|
autoWireEdges: !0,
|
|
1776
|
-
direction:
|
|
1783
|
+
direction: G(Z),
|
|
1777
1784
|
gap: i(),
|
|
1778
1785
|
source: "user:quick-add",
|
|
1779
1786
|
label: "快捷插入节点"
|
|
1780
|
-
}).status === "applied" && e._emitUiEvent({ type: "node.action.quick-insert", sourceNodeId:
|
|
1781
|
-
}
|
|
1782
|
-
function
|
|
1783
|
-
if (!
|
|
1784
|
-
const
|
|
1785
|
-
if (!
|
|
1786
|
-
const x =
|
|
1787
|
-
if (!
|
|
1788
|
-
const
|
|
1789
|
-
let
|
|
1790
|
-
r(
|
|
1791
|
-
const
|
|
1792
|
-
for (const
|
|
1793
|
-
const
|
|
1794
|
-
x.setPortProp(
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
function
|
|
1798
|
-
|
|
1787
|
+
}).status === "applied" && e._emitUiEvent({ type: "node.action.quick-insert", sourceNodeId: N, newNodeId: R }), n.closePopover();
|
|
1788
|
+
}
|
|
1789
|
+
function L(N) {
|
|
1790
|
+
if (!p) return;
|
|
1791
|
+
const _ = p.getCellById(N);
|
|
1792
|
+
if (!_?.isNode()) return;
|
|
1793
|
+
const x = _, R = e.flowModel.value.nodes[N];
|
|
1794
|
+
if (!R) return;
|
|
1795
|
+
const F = U(R);
|
|
1796
|
+
let Z = !0;
|
|
1797
|
+
r(R).hidePortForQuickAdd === !1 && (Z = !1);
|
|
1798
|
+
const Q = Z && !l.value && !!F && d(N);
|
|
1799
|
+
for (const K of x.getPorts()) {
|
|
1800
|
+
const me = Q && K.id === F?.portId ? "hidden" : "visible";
|
|
1801
|
+
x.setPortProp(K.id, "attrs/circle/visibility", me);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
function z(N, _) {
|
|
1805
|
+
u?.(), p = N, u = ge(
|
|
1799
1806
|
[a, l],
|
|
1800
|
-
([x], [
|
|
1801
|
-
if (
|
|
1802
|
-
const
|
|
1803
|
-
|
|
1807
|
+
([x], [R]) => {
|
|
1808
|
+
if (R && R !== x) {
|
|
1809
|
+
const F = N.getCellById(R);
|
|
1810
|
+
F?.isNode() && _(F);
|
|
1804
1811
|
}
|
|
1805
|
-
x &&
|
|
1812
|
+
x && L(x);
|
|
1806
1813
|
},
|
|
1807
1814
|
{ flush: "sync" }
|
|
1808
1815
|
);
|
|
1809
1816
|
}
|
|
1810
|
-
ge(y, (
|
|
1811
|
-
|
|
1817
|
+
ge(y, (N) => {
|
|
1818
|
+
N || (v.value = !1);
|
|
1812
1819
|
});
|
|
1813
|
-
function
|
|
1814
|
-
|
|
1820
|
+
function ie() {
|
|
1821
|
+
f && clearTimeout(f), u?.(), u = null, p = null;
|
|
1815
1822
|
}
|
|
1816
1823
|
return {
|
|
1817
1824
|
quickAddNodeId: a,
|
|
@@ -1820,17 +1827,18 @@ function ro(n) {
|
|
|
1820
1827
|
data: y,
|
|
1821
1828
|
enter: b,
|
|
1822
1829
|
leave: O,
|
|
1823
|
-
cancelLeave:
|
|
1824
|
-
handleOverlayEnter:
|
|
1825
|
-
handleOverlayLeave:
|
|
1826
|
-
handleOpen:
|
|
1830
|
+
cancelLeave: D,
|
|
1831
|
+
handleOverlayEnter: S,
|
|
1832
|
+
handleOverlayLeave: M,
|
|
1833
|
+
handleOpen: c,
|
|
1827
1834
|
handleClose: g,
|
|
1828
|
-
handleStartDrag:
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1835
|
+
handleStartDrag: h,
|
|
1836
|
+
handlePopoverViewportOverflow: m,
|
|
1837
|
+
handleInsert: E,
|
|
1838
|
+
isActiveForNode: d,
|
|
1839
|
+
syncNodePorts: L,
|
|
1840
|
+
attachRuntime: z,
|
|
1841
|
+
cleanup: ie
|
|
1834
1842
|
};
|
|
1835
1843
|
}
|
|
1836
1844
|
const io = 15, ao = 10;
|
|
@@ -1846,125 +1854,125 @@ function lo(n) {
|
|
|
1846
1854
|
outgoingPortGroup: "right",
|
|
1847
1855
|
...n.edgeDropProp.value
|
|
1848
1856
|
}));
|
|
1849
|
-
function v(
|
|
1857
|
+
function v(d) {
|
|
1850
1858
|
if (!o) return null;
|
|
1851
|
-
const y = o.getCellById(
|
|
1859
|
+
const y = o.getCellById(d);
|
|
1852
1860
|
if (!y?.isEdge()) return null;
|
|
1853
|
-
const
|
|
1854
|
-
if (!
|
|
1855
|
-
const g =
|
|
1856
|
-
for (const
|
|
1857
|
-
if (
|
|
1861
|
+
const c = o.findViewByCell(y)?.container;
|
|
1862
|
+
if (!c) return null;
|
|
1863
|
+
const g = c.querySelectorAll("path");
|
|
1864
|
+
for (const h of g)
|
|
1865
|
+
if (h.getAttribute("stroke") !== "transparent") return h;
|
|
1858
1866
|
return null;
|
|
1859
1867
|
}
|
|
1860
|
-
function
|
|
1861
|
-
const y = v(
|
|
1862
|
-
y && (y.style.stroke = "#3a84ff", r =
|
|
1868
|
+
function f(d) {
|
|
1869
|
+
const y = v(d);
|
|
1870
|
+
y && (y.style.stroke = "#3a84ff", r = d);
|
|
1863
1871
|
}
|
|
1864
|
-
function
|
|
1872
|
+
function p() {
|
|
1865
1873
|
if (!r) return;
|
|
1866
|
-
const
|
|
1867
|
-
|
|
1874
|
+
const d = v(r);
|
|
1875
|
+
d && (d.style.stroke = ""), r = null;
|
|
1868
1876
|
}
|
|
1869
|
-
function
|
|
1877
|
+
function u(d, y, c) {
|
|
1870
1878
|
if (o) {
|
|
1871
|
-
const g = o.getCellById(
|
|
1879
|
+
const g = o.getCellById(d);
|
|
1872
1880
|
if (g?.isNode()) {
|
|
1873
|
-
const
|
|
1874
|
-
if (
|
|
1881
|
+
const h = g.getPorts().find((m) => m.group === c);
|
|
1882
|
+
if (h?.id) return h.id;
|
|
1875
1883
|
}
|
|
1876
1884
|
}
|
|
1877
1885
|
if (y.ports?.length) {
|
|
1878
|
-
const g = y.ports.find((
|
|
1886
|
+
const g = y.ports.find((h) => h.group === c);
|
|
1879
1887
|
if (g) return g.id;
|
|
1880
1888
|
}
|
|
1881
|
-
return
|
|
1889
|
+
return c;
|
|
1882
1890
|
}
|
|
1883
|
-
function w(
|
|
1884
|
-
const y =
|
|
1891
|
+
function w(d) {
|
|
1892
|
+
const y = d.getTotalLength();
|
|
1885
1893
|
if (y === 0) return [];
|
|
1886
|
-
const
|
|
1887
|
-
for (let
|
|
1888
|
-
const m =
|
|
1889
|
-
|
|
1894
|
+
const c = [];
|
|
1895
|
+
for (let h = 0; h <= y; h += ao) {
|
|
1896
|
+
const m = d.getPointAtLength(h);
|
|
1897
|
+
c.push({ x: m.x, y: m.y });
|
|
1890
1898
|
}
|
|
1891
|
-
const g =
|
|
1892
|
-
return
|
|
1899
|
+
const g = d.getPointAtLength(y);
|
|
1900
|
+
return c.push({ x: g.x, y: g.y }), c;
|
|
1893
1901
|
}
|
|
1894
|
-
function
|
|
1902
|
+
function D(d, y, c) {
|
|
1895
1903
|
if (!o) return null;
|
|
1896
|
-
const g = a.value,
|
|
1897
|
-
x:
|
|
1898
|
-
y:
|
|
1899
|
-
width: Math.max(0,
|
|
1900
|
-
height: Math.max(0,
|
|
1904
|
+
const g = a.value, h = g.bufferMargin, m = {
|
|
1905
|
+
x: d.x + h,
|
|
1906
|
+
y: d.y + h,
|
|
1907
|
+
width: Math.max(0, d.width - h * 2),
|
|
1908
|
+
height: Math.max(0, d.height - h * 2)
|
|
1901
1909
|
};
|
|
1902
1910
|
if (m.width <= 0 || m.height <= 0) return null;
|
|
1903
|
-
const E = m.x + m.width,
|
|
1904
|
-
let
|
|
1905
|
-
const
|
|
1906
|
-
for (const
|
|
1907
|
-
const
|
|
1908
|
-
if (!
|
|
1909
|
-
const
|
|
1910
|
-
if (!
|
|
1911
|
-
const
|
|
1912
|
-
if (!
|
|
1913
|
-
const
|
|
1914
|
-
if (!
|
|
1915
|
-
let
|
|
1916
|
-
for (const
|
|
1917
|
-
if (
|
|
1918
|
-
const
|
|
1919
|
-
|
|
1911
|
+
const E = m.x + m.width, L = m.y + m.height;
|
|
1912
|
+
let z = null;
|
|
1913
|
+
const ie = d.x + d.width / 2, N = d.y + d.height / 2;
|
|
1914
|
+
for (const _ of o.getEdges()) {
|
|
1915
|
+
const x = y.edges[_.id];
|
|
1916
|
+
if (!x || c && (x.source.nodeId === c || x.target.nodeId === c) || g.isEdgeDropTarget && !g.isEdgeDropTarget(x, y)) continue;
|
|
1917
|
+
const R = o.findViewByCell(_);
|
|
1918
|
+
if (!R) continue;
|
|
1919
|
+
const F = R.findOne?.("path");
|
|
1920
|
+
if (!F || typeof F.getTotalLength != "function") continue;
|
|
1921
|
+
const Z = w(F);
|
|
1922
|
+
if (!Z.length) continue;
|
|
1923
|
+
let ae = !1, Q = 1 / 0;
|
|
1924
|
+
for (const K of Z)
|
|
1925
|
+
if (K.x >= m.x && K.x <= E && K.y >= m.y && K.y <= L) {
|
|
1926
|
+
const me = K.x - ie, pe = K.y - N, we = me * me + pe * pe;
|
|
1927
|
+
we < Q && (Q = we), ae = !0;
|
|
1920
1928
|
}
|
|
1921
|
-
|
|
1929
|
+
ae && (!z || Q < z.distSq) && (z = { edgeId: _.id, edge: x, distSq: Q });
|
|
1922
1930
|
}
|
|
1923
|
-
return
|
|
1931
|
+
return z ? { edgeId: z.edgeId, edge: z.edge } : null;
|
|
1924
1932
|
}
|
|
1925
|
-
function O(
|
|
1933
|
+
function O(d, y) {
|
|
1926
1934
|
if (!a.value.enabled) return;
|
|
1927
|
-
const g = e.flowModel.value,
|
|
1928
|
-
|
|
1935
|
+
const g = e.flowModel.value, h = D(d, g, y);
|
|
1936
|
+
h ? t !== h.edgeId && (p(), t = h.edgeId, f(h.edgeId)) : t && (p(), t = null);
|
|
1929
1937
|
}
|
|
1930
1938
|
let b = !0;
|
|
1931
|
-
function
|
|
1939
|
+
function S({ node: d }) {
|
|
1932
1940
|
if (t = null, !a.value.enabled) return;
|
|
1933
|
-
const y = e.flowModel.value,
|
|
1934
|
-
if (!
|
|
1941
|
+
const y = e.flowModel.value, c = y.nodes[d.id];
|
|
1942
|
+
if (!c) {
|
|
1935
1943
|
b = !1;
|
|
1936
1944
|
return;
|
|
1937
1945
|
}
|
|
1938
1946
|
const g = a.value;
|
|
1939
|
-
b = !g.isNodeInsertable || g.isNodeInsertable(
|
|
1947
|
+
b = !g.isNodeInsertable || g.isNodeInsertable(c, y);
|
|
1940
1948
|
}
|
|
1941
|
-
function
|
|
1949
|
+
function M({ node: d }) {
|
|
1942
1950
|
!a.value.enabled || !b || s === null && (s = requestAnimationFrame(() => {
|
|
1943
1951
|
if (s = null, !o) return;
|
|
1944
|
-
const y =
|
|
1945
|
-
O({ x: y.x, y: y.y, width:
|
|
1952
|
+
const y = d.getPosition(), c = d.getSize();
|
|
1953
|
+
O({ x: y.x, y: y.y, width: c.width, height: c.height }, d.id);
|
|
1946
1954
|
}));
|
|
1947
1955
|
}
|
|
1948
|
-
function
|
|
1949
|
-
s !== null && (cancelAnimationFrame(s), s = null),
|
|
1956
|
+
function B() {
|
|
1957
|
+
s !== null && (cancelAnimationFrame(s), s = null), p(), b = !0;
|
|
1950
1958
|
}
|
|
1951
|
-
function
|
|
1959
|
+
function j() {
|
|
1952
1960
|
if (!o) return;
|
|
1953
|
-
let
|
|
1961
|
+
let d = !1;
|
|
1954
1962
|
l = () => {
|
|
1955
1963
|
if (!a.value.enabled) return;
|
|
1956
1964
|
const y = document.querySelector(".x6-widget-dnd");
|
|
1957
1965
|
if (!y) {
|
|
1958
|
-
|
|
1966
|
+
d && (d = !1, p(), t = null);
|
|
1959
1967
|
return;
|
|
1960
1968
|
}
|
|
1961
|
-
|
|
1969
|
+
d = !0, s === null && (s = requestAnimationFrame(() => {
|
|
1962
1970
|
if (s = null, !o) return;
|
|
1963
|
-
const
|
|
1971
|
+
const c = y.getBoundingClientRect(), g = o.clientToLocal(c.left, c.top), h = o.clientToLocal(c.right, c.bottom), m = {
|
|
1964
1972
|
x: g.x,
|
|
1965
1973
|
y: g.y,
|
|
1966
|
-
width:
|
|
1967
|
-
height:
|
|
1974
|
+
width: h.x - g.x,
|
|
1975
|
+
height: h.y - g.y
|
|
1968
1976
|
};
|
|
1969
1977
|
O(m);
|
|
1970
1978
|
}));
|
|
@@ -1973,64 +1981,64 @@ function lo(n) {
|
|
|
1973
1981
|
});
|
|
1974
1982
|
}
|
|
1975
1983
|
function k() {
|
|
1976
|
-
|
|
1984
|
+
p(), t = null, s !== null && (cancelAnimationFrame(s), s = null);
|
|
1977
1985
|
}
|
|
1978
|
-
function
|
|
1979
|
-
if (!t ||
|
|
1986
|
+
function X(d) {
|
|
1987
|
+
if (!t || d.source !== "user:drag") return d;
|
|
1980
1988
|
const y = t;
|
|
1981
|
-
t = null,
|
|
1982
|
-
const
|
|
1983
|
-
if (!g) return
|
|
1984
|
-
const
|
|
1985
|
-
if (!
|
|
1986
|
-
const m =
|
|
1987
|
-
if (!E) return
|
|
1988
|
-
const
|
|
1989
|
-
if (
|
|
1990
|
-
return
|
|
1991
|
-
const
|
|
1989
|
+
t = null, p();
|
|
1990
|
+
const c = e.flowModel.value, g = c.edges[y];
|
|
1991
|
+
if (!g) return d;
|
|
1992
|
+
const h = d.commands.find((R) => R.type === "node.add" || R.type === "node.move");
|
|
1993
|
+
if (!h) return d;
|
|
1994
|
+
const m = h.type === "node.add" ? h.node.id : h.nodeId, E = h.type === "node.add" ? h.node : c.nodes[h.nodeId];
|
|
1995
|
+
if (!E) return d;
|
|
1996
|
+
const L = a.value;
|
|
1997
|
+
if (L.isNodeInsertable && !L.isNodeInsertable(E, c))
|
|
1998
|
+
return d;
|
|
1999
|
+
const z = u(m, E, L.incomingPortGroup), ie = u(m, E, L.outgoingPortGroup), N = e.idGenerator("edge"), _ = e.idGenerator("edge"), x = [
|
|
1992
2000
|
{ type: "edge.remove", edgeId: y },
|
|
1993
2001
|
{
|
|
1994
2002
|
type: "edge.add",
|
|
1995
2003
|
edge: {
|
|
1996
|
-
id:
|
|
2004
|
+
id: N,
|
|
1997
2005
|
type: g.type,
|
|
1998
2006
|
source: { nodeId: g.source.nodeId, portId: g.source.portId },
|
|
1999
|
-
target: { nodeId: m, portId:
|
|
2007
|
+
target: { nodeId: m, portId: z }
|
|
2000
2008
|
}
|
|
2001
2009
|
},
|
|
2002
2010
|
{
|
|
2003
2011
|
type: "edge.add",
|
|
2004
2012
|
edge: {
|
|
2005
|
-
id:
|
|
2013
|
+
id: _,
|
|
2006
2014
|
type: g.type,
|
|
2007
|
-
source: { nodeId: m, portId:
|
|
2015
|
+
source: { nodeId: m, portId: ie },
|
|
2008
2016
|
target: { nodeId: g.target.nodeId, portId: g.target.portId }
|
|
2009
2017
|
}
|
|
2010
2018
|
}
|
|
2011
2019
|
];
|
|
2012
2020
|
return {
|
|
2013
|
-
...
|
|
2021
|
+
...d,
|
|
2014
2022
|
source: "user:edge-drop",
|
|
2015
|
-
commands: [...
|
|
2023
|
+
commands: [...d.commands, ...x]
|
|
2016
2024
|
};
|
|
2017
2025
|
}
|
|
2018
|
-
function
|
|
2019
|
-
o =
|
|
2020
|
-
const y = (
|
|
2021
|
-
|
|
2026
|
+
function U(d) {
|
|
2027
|
+
o = d;
|
|
2028
|
+
const y = (c, g) => {
|
|
2029
|
+
d.on(c, g), i.push(() => d.off(c, g));
|
|
2022
2030
|
};
|
|
2023
|
-
y("node:move",
|
|
2031
|
+
y("node:move", S), y("node:change:position", M), y("node:moved", B), j();
|
|
2024
2032
|
}
|
|
2025
|
-
function
|
|
2033
|
+
function G() {
|
|
2026
2034
|
k();
|
|
2027
|
-
for (const
|
|
2035
|
+
for (const d of i) d();
|
|
2028
2036
|
i.length = 0, o = null, b = !0;
|
|
2029
2037
|
}
|
|
2030
2038
|
return {
|
|
2031
|
-
attachRuntime:
|
|
2032
|
-
tryExpandForEdgeDrop:
|
|
2033
|
-
cleanup:
|
|
2039
|
+
attachRuntime: U,
|
|
2040
|
+
tryExpandForEdgeDrop: X,
|
|
2041
|
+
cleanup: G
|
|
2034
2042
|
};
|
|
2035
2043
|
}
|
|
2036
2044
|
function co(n) {
|
|
@@ -2049,7 +2057,7 @@ function co(n) {
|
|
|
2049
2057
|
switch (s) {
|
|
2050
2058
|
case "delete":
|
|
2051
2059
|
return n.executeCommand({
|
|
2052
|
-
id:
|
|
2060
|
+
id: J(),
|
|
2053
2061
|
source: "user:toolbar",
|
|
2054
2062
|
label: "删除节点",
|
|
2055
2063
|
timestamp: Date.now(),
|
|
@@ -2059,9 +2067,9 @@ function co(n) {
|
|
|
2059
2067
|
if (!l) break;
|
|
2060
2068
|
const a = n.flowModel.value.nodes[r];
|
|
2061
2069
|
if (!a) break;
|
|
2062
|
-
const v = e(a),
|
|
2070
|
+
const v = e(a), f = 50;
|
|
2063
2071
|
n.executeCommand({
|
|
2064
|
-
id:
|
|
2072
|
+
id: J(),
|
|
2065
2073
|
source: "user:toolbar",
|
|
2066
2074
|
label: "复制节点",
|
|
2067
2075
|
timestamp: Date.now(),
|
|
@@ -2071,8 +2079,8 @@ function co(n) {
|
|
|
2071
2079
|
node: {
|
|
2072
2080
|
...v,
|
|
2073
2081
|
position: {
|
|
2074
|
-
x: a.position.x +
|
|
2075
|
-
y: a.position.y +
|
|
2082
|
+
x: a.position.x + f,
|
|
2083
|
+
y: a.position.y + f
|
|
2076
2084
|
}
|
|
2077
2085
|
}
|
|
2078
2086
|
}
|
|
@@ -2093,17 +2101,17 @@ function co(n) {
|
|
|
2093
2101
|
break;
|
|
2094
2102
|
}
|
|
2095
2103
|
case "disconnect": {
|
|
2096
|
-
const a = n.flowModel.value, v = Object.entries(a.edges).filter(([,
|
|
2097
|
-
const
|
|
2098
|
-
return
|
|
2099
|
-
}).map(([
|
|
2104
|
+
const a = n.flowModel.value, v = Object.entries(a.edges).filter(([, f]) => {
|
|
2105
|
+
const p = f;
|
|
2106
|
+
return p.source.nodeId === r || p.target.nodeId === r;
|
|
2107
|
+
}).map(([f]) => f);
|
|
2100
2108
|
if (v.length === 0) break;
|
|
2101
2109
|
n.executeCommand({
|
|
2102
|
-
id:
|
|
2110
|
+
id: J(),
|
|
2103
2111
|
source: "user:toolbar",
|
|
2104
2112
|
label: "断开连线",
|
|
2105
2113
|
timestamp: Date.now(),
|
|
2106
|
-
commands: v.map((
|
|
2114
|
+
commands: v.map((f) => ({ type: "edge.remove", edgeId: f }))
|
|
2107
2115
|
}), n._emitUiEvent({ type: "node.action.disconnect", nodeId: r, edgeIds: v });
|
|
2108
2116
|
break;
|
|
2109
2117
|
}
|
|
@@ -2165,13 +2173,13 @@ function fo(n, e) {
|
|
|
2165
2173
|
}
|
|
2166
2174
|
}, n.createEdge(s);
|
|
2167
2175
|
}
|
|
2168
|
-
const go = ".x6-widget-selection",
|
|
2169
|
-
function
|
|
2170
|
-
const e = n.querySelector(go), o = n.querySelector(
|
|
2176
|
+
const go = ".x6-widget-selection", po = ".x6-graph-svg";
|
|
2177
|
+
function ho(n) {
|
|
2178
|
+
const e = n.querySelector(go), o = n.querySelector(po);
|
|
2171
2179
|
return !e || !o || e.parentNode !== o.parentNode || !o.parentNode || o.previousSibling === e ? !1 : (o.parentNode.insertBefore(e, o), !0);
|
|
2172
2180
|
}
|
|
2173
2181
|
function vo(n) {
|
|
2174
|
-
const e = () =>
|
|
2182
|
+
const e = () => ho(n);
|
|
2175
2183
|
e();
|
|
2176
2184
|
const o = new MutationObserver(() => {
|
|
2177
2185
|
e();
|
|
@@ -2199,11 +2207,11 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2199
2207
|
emits: ["action"],
|
|
2200
2208
|
setup(n, { emit: e }) {
|
|
2201
2209
|
const o = n, t = V(() => {
|
|
2202
|
-
const
|
|
2210
|
+
const p = o.actionsOffset?.x ?? 0, u = o.actionsOffset?.y ?? 0, w = p !== 0 || u !== 0;
|
|
2203
2211
|
return {
|
|
2204
2212
|
left: `${o.position.x}px`,
|
|
2205
2213
|
top: `${o.position.y}px`,
|
|
2206
|
-
transform: w ? `translate(${
|
|
2214
|
+
transform: w ? `translate(${p}px, ${u}px)` : "translateX(-100%)"
|
|
2207
2215
|
};
|
|
2208
2216
|
}), s = e, r = V(() => ({
|
|
2209
2217
|
debug: {
|
|
@@ -2226,71 +2234,71 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2226
2234
|
visible: o.config.showDisconnect && o.behavior.disconnectable !== !1,
|
|
2227
2235
|
disabled: o.behavior.disconnectDisabled === !0
|
|
2228
2236
|
}
|
|
2229
|
-
})), i = V(() => r.value.copy.visible || r.value.copyInsert.visible || r.value.disconnect.visible), l =
|
|
2237
|
+
})), i = V(() => r.value.copy.visible || r.value.copyInsert.visible || r.value.disconnect.visible), l = H(!1);
|
|
2230
2238
|
let a = null;
|
|
2231
2239
|
function v() {
|
|
2232
2240
|
a && (clearTimeout(a), a = null), l.value = !0;
|
|
2233
2241
|
}
|
|
2234
|
-
function
|
|
2242
|
+
function f() {
|
|
2235
2243
|
a = setTimeout(() => {
|
|
2236
2244
|
l.value = !1, a = null;
|
|
2237
2245
|
}, 100);
|
|
2238
2246
|
}
|
|
2239
2247
|
return Te(() => {
|
|
2240
2248
|
a && clearTimeout(a);
|
|
2241
|
-
}), (
|
|
2249
|
+
}), (p, u) => (A(), T("div", {
|
|
2242
2250
|
class: "flow-canvas-node-actions",
|
|
2243
|
-
style:
|
|
2251
|
+
style: Ee(t.value)
|
|
2244
2252
|
}, [
|
|
2245
2253
|
q("div", yo, [
|
|
2246
|
-
r.value.debug.visible ? (A(),
|
|
2254
|
+
r.value.debug.visible ? (A(), T("i", {
|
|
2247
2255
|
key: 0,
|
|
2248
|
-
class:
|
|
2249
|
-
onClick:
|
|
2256
|
+
class: te(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon", { "is-disabled": r.value.debug.disabled }]),
|
|
2257
|
+
onClick: u[0] || (u[0] = (w) => !r.value.debug.disabled && s("action", "debug", n.node.id))
|
|
2250
2258
|
}, null, 2)) : Y("", !0),
|
|
2251
|
-
r.value.delete.visible ? (A(),
|
|
2259
|
+
r.value.delete.visible ? (A(), T("i", {
|
|
2252
2260
|
key: 1,
|
|
2253
|
-
class:
|
|
2254
|
-
onClick:
|
|
2261
|
+
class: te(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon", { "is-disabled": r.value.delete.disabled }]),
|
|
2262
|
+
onClick: u[1] || (u[1] = (w) => !r.value.delete.disabled && s("action", "delete", n.node.id))
|
|
2255
2263
|
}, null, 2)) : Y("", !0),
|
|
2256
|
-
i.value ? (A(),
|
|
2264
|
+
i.value ? (A(), T("div", {
|
|
2257
2265
|
key: 2,
|
|
2258
2266
|
class: "flow-canvas-node-actions__more-wrapper",
|
|
2259
2267
|
onMouseenter: v,
|
|
2260
|
-
onMouseleave:
|
|
2261
|
-
}, [...
|
|
2268
|
+
onMouseleave: f
|
|
2269
|
+
}, [...u[5] || (u[5] = [
|
|
2262
2270
|
q("i", { class: "flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon" }, null, -1)
|
|
2263
2271
|
])], 32)) : Y("", !0)
|
|
2264
2272
|
]),
|
|
2265
|
-
|
|
2273
|
+
at(lt, { name: "flow-canvas-fade" }, {
|
|
2266
2274
|
default: He(() => [
|
|
2267
|
-
l.value && i.value ? (A(),
|
|
2275
|
+
l.value && i.value ? (A(), T("div", {
|
|
2268
2276
|
key: 0,
|
|
2269
2277
|
class: "flow-canvas-node-actions__dropdown",
|
|
2270
2278
|
onMouseenter: v,
|
|
2271
|
-
onMouseleave:
|
|
2279
|
+
onMouseleave: f
|
|
2272
2280
|
}, [
|
|
2273
|
-
r.value.copy.visible ? (A(),
|
|
2281
|
+
r.value.copy.visible ? (A(), T("div", {
|
|
2274
2282
|
key: 0,
|
|
2275
|
-
class:
|
|
2276
|
-
onClick:
|
|
2277
|
-
}, [...
|
|
2283
|
+
class: te(["flow-canvas-node-actions__dropdown-item", { "is-disabled": r.value.copy.disabled }]),
|
|
2284
|
+
onClick: u[2] || (u[2] = (w) => !r.value.copy.disabled && s("action", "copy", n.node.id))
|
|
2285
|
+
}, [...u[6] || (u[6] = [
|
|
2278
2286
|
q("i", { class: "flow-canvas-icon canvas-copy-fuzhi-2" }, null, -1),
|
|
2279
2287
|
q("span", null, "复制", -1)
|
|
2280
2288
|
])], 2)) : Y("", !0),
|
|
2281
|
-
r.value.copyInsert.visible ? (A(),
|
|
2289
|
+
r.value.copyInsert.visible ? (A(), T("div", {
|
|
2282
2290
|
key: 1,
|
|
2283
|
-
class:
|
|
2284
|
-
onClick:
|
|
2285
|
-
}, [...
|
|
2291
|
+
class: te(["flow-canvas-node-actions__dropdown-item", { "is-disabled": r.value.copyInsert.disabled }]),
|
|
2292
|
+
onClick: u[3] || (u[3] = (w) => !r.value.copyInsert.disabled && s("action", "copy-insert", n.node.id))
|
|
2293
|
+
}, [...u[7] || (u[7] = [
|
|
2286
2294
|
q("i", { class: "flow-canvas-icon canvas-fuzhibingcharu" }, null, -1),
|
|
2287
2295
|
q("span", null, "复制并插入", -1)
|
|
2288
2296
|
])], 2)) : Y("", !0),
|
|
2289
|
-
r.value.disconnect.visible ? (A(),
|
|
2297
|
+
r.value.disconnect.visible ? (A(), T("div", {
|
|
2290
2298
|
key: 2,
|
|
2291
|
-
class:
|
|
2292
|
-
onClick:
|
|
2293
|
-
}, [...
|
|
2299
|
+
class: te(["flow-canvas-node-actions__dropdown-item", { "is-disabled": r.value.disconnect.disabled }]),
|
|
2300
|
+
onClick: u[4] || (u[4] = (w) => !r.value.disconnect.disabled && s("action", "disconnect", n.node.id))
|
|
2301
|
+
}, [...u[8] || (u[8] = [
|
|
2294
2302
|
q("i", { class: "flow-canvas-icon canvas-unlock-jiebang" }, null, -1),
|
|
2295
2303
|
q("span", null, "断开连线", -1)
|
|
2296
2304
|
])], 2)) : Y("", !0)
|
|
@@ -2312,94 +2320,107 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2312
2320
|
__name: "node-quick-add-popover",
|
|
2313
2321
|
props: {
|
|
2314
2322
|
node: {},
|
|
2315
|
-
portPosition: {}
|
|
2323
|
+
portPosition: {},
|
|
2324
|
+
autoPanOnOpen: { type: Boolean },
|
|
2325
|
+
autoPanPadding: {}
|
|
2316
2326
|
},
|
|
2317
|
-
emits: ["open", "close", "start-drag", "mouseenter", "mouseleave"],
|
|
2327
|
+
emits: ["open", "close", "start-drag", "viewport-overflow-right", "mouseenter", "mouseleave"],
|
|
2318
2328
|
setup(n, { expose: e, emit: o }) {
|
|
2319
|
-
const t = n, s = o, r =
|
|
2320
|
-
let v = null,
|
|
2321
|
-
function
|
|
2322
|
-
|
|
2329
|
+
const t = n, s = o, r = H(), i = H(), l = H(!1), a = H(!1);
|
|
2330
|
+
let v = null, f = !1, p = null;
|
|
2331
|
+
function u(G) {
|
|
2332
|
+
G.preventDefault(), G.stopPropagation(), v = { x: G.clientX, y: G.clientY }, f = !1, document.addEventListener("mousemove", w), document.addEventListener("mouseup", D);
|
|
2323
2333
|
}
|
|
2324
|
-
function w(
|
|
2334
|
+
function w(G) {
|
|
2325
2335
|
if (!v) return;
|
|
2326
|
-
const
|
|
2327
|
-
Math.sqrt(
|
|
2336
|
+
const d = G.clientX - v.x, y = G.clientY - v.y;
|
|
2337
|
+
Math.sqrt(d * d + y * y) >= xo && (f = !0, O(), s("start-drag", t.node.id));
|
|
2328
2338
|
}
|
|
2329
|
-
function
|
|
2330
|
-
O(),
|
|
2339
|
+
function D() {
|
|
2340
|
+
O(), f || b(), v = null, f = !1;
|
|
2331
2341
|
}
|
|
2332
2342
|
function O() {
|
|
2333
|
-
document.removeEventListener("mousemove", w), document.removeEventListener("mouseup",
|
|
2343
|
+
document.removeEventListener("mousemove", w), document.removeEventListener("mouseup", D);
|
|
2334
2344
|
}
|
|
2335
2345
|
function b() {
|
|
2336
|
-
a.value ?
|
|
2346
|
+
a.value ? B() : S();
|
|
2337
2347
|
}
|
|
2338
|
-
function
|
|
2339
|
-
a.value = !0, s("open", t.node.id),
|
|
2340
|
-
|
|
2348
|
+
function S() {
|
|
2349
|
+
a.value = !0, s("open", t.node.id), Ge(() => {
|
|
2350
|
+
requestAnimationFrame(() => {
|
|
2351
|
+
M();
|
|
2352
|
+
});
|
|
2353
|
+
}), requestAnimationFrame(() => {
|
|
2354
|
+
document.addEventListener("mousedown", j);
|
|
2341
2355
|
});
|
|
2342
2356
|
}
|
|
2343
|
-
function
|
|
2344
|
-
a.value
|
|
2357
|
+
function M() {
|
|
2358
|
+
if (!a.value || !t.autoPanOnOpen || !i.value) return;
|
|
2359
|
+
const G = window.innerWidth || document.documentElement.clientWidth || 0;
|
|
2360
|
+
if (G <= 0) return;
|
|
2361
|
+
const d = t.autoPanPadding ?? 16, c = i.value.getBoundingClientRect().right + d - G;
|
|
2362
|
+
c > 0 && s("viewport-overflow-right", c);
|
|
2345
2363
|
}
|
|
2346
|
-
function
|
|
2347
|
-
|
|
2348
|
-
r.value?.contains(B) || i.value?.contains(B) || S();
|
|
2364
|
+
function B() {
|
|
2365
|
+
a.value = !1, s("close"), document.removeEventListener("mousedown", j);
|
|
2349
2366
|
}
|
|
2350
|
-
function
|
|
2351
|
-
|
|
2367
|
+
function j(G) {
|
|
2368
|
+
const d = G.target;
|
|
2369
|
+
r.value?.contains(d) || i.value?.contains(d) || B();
|
|
2352
2370
|
}
|
|
2353
2371
|
function k() {
|
|
2354
|
-
|
|
2372
|
+
a.value || s("mouseleave");
|
|
2373
|
+
}
|
|
2374
|
+
function X() {
|
|
2375
|
+
p && (clearTimeout(p), p = null), s("mouseenter");
|
|
2355
2376
|
}
|
|
2356
|
-
function
|
|
2357
|
-
|
|
2358
|
-
|
|
2377
|
+
function U() {
|
|
2378
|
+
p = setTimeout(() => {
|
|
2379
|
+
B(), s("mouseleave"), p = null;
|
|
2359
2380
|
}, 150);
|
|
2360
2381
|
}
|
|
2361
2382
|
return Te(() => {
|
|
2362
|
-
O(),
|
|
2363
|
-
}), e({ closePopover:
|
|
2383
|
+
O(), p && clearTimeout(p), document.removeEventListener("mousedown", j);
|
|
2384
|
+
}), e({ closePopover: B }), (G, d) => (A(), T("div", {
|
|
2364
2385
|
class: "flow-canvas-quick-add",
|
|
2365
|
-
style:
|
|
2366
|
-
onMouseenter:
|
|
2367
|
-
onMouseleave:
|
|
2368
|
-
onClick:
|
|
2386
|
+
style: Ee({ left: `${n.portPosition.x}px`, top: `${n.portPosition.y}px` }),
|
|
2387
|
+
onMouseenter: d[2] || (d[2] = (y) => s("mouseenter")),
|
|
2388
|
+
onMouseleave: k,
|
|
2389
|
+
onClick: d[3] || (d[3] = ht(() => {
|
|
2369
2390
|
}, ["stop"]))
|
|
2370
2391
|
}, [
|
|
2371
2392
|
q("div", {
|
|
2372
2393
|
ref_key: "btnRef",
|
|
2373
2394
|
ref: r,
|
|
2374
|
-
class:
|
|
2375
|
-
onMouseenter:
|
|
2376
|
-
onMouseleave:
|
|
2377
|
-
onMousedown:
|
|
2378
|
-
}, [...
|
|
2395
|
+
class: te(["flow-canvas-quick-add__btn", { "is-hovered": l.value, "is-active": a.value }]),
|
|
2396
|
+
onMouseenter: d[0] || (d[0] = (y) => l.value = !0),
|
|
2397
|
+
onMouseleave: d[1] || (d[1] = (y) => l.value = !1),
|
|
2398
|
+
onMousedown: u
|
|
2399
|
+
}, [...d[4] || (d[4] = [
|
|
2379
2400
|
q("i", { class: "flow-canvas-icon canvas-zoom-add" }, null, -1)
|
|
2380
2401
|
])], 34),
|
|
2381
|
-
l.value && !a.value ? (A(),
|
|
2402
|
+
l.value && !a.value ? (A(), T("div", Eo, [...d[5] || (d[5] = [
|
|
2382
2403
|
q("div", null, [
|
|
2383
2404
|
q("b", null, "点击"),
|
|
2384
|
-
|
|
2405
|
+
je(" 添加节点")
|
|
2385
2406
|
], -1),
|
|
2386
2407
|
q("div", null, [
|
|
2387
2408
|
q("b", null, "拖拽"),
|
|
2388
|
-
|
|
2409
|
+
je(" 连接节点")
|
|
2389
2410
|
], -1)
|
|
2390
2411
|
])])) : Y("", !0),
|
|
2391
|
-
|
|
2412
|
+
at(lt, { name: "flow-canvas-fade" }, {
|
|
2392
2413
|
default: He(() => [
|
|
2393
|
-
a.value ? (A(),
|
|
2414
|
+
a.value ? (A(), T("div", {
|
|
2394
2415
|
key: 0,
|
|
2395
2416
|
ref_key: "popoverRef",
|
|
2396
2417
|
ref: i,
|
|
2397
2418
|
class: "flow-canvas-quick-add__popover",
|
|
2398
|
-
onMouseenter:
|
|
2399
|
-
onMouseleave:
|
|
2419
|
+
onMouseenter: X,
|
|
2420
|
+
onMouseleave: U
|
|
2400
2421
|
}, [
|
|
2401
|
-
Me(
|
|
2402
|
-
|
|
2422
|
+
Me(G.$slots, "default", {}, () => [
|
|
2423
|
+
d[6] || (d[6] = q("div", { class: "flow-canvas-quick-add__default-content" }, "节点快捷操作面板", -1))
|
|
2403
2424
|
], !0)
|
|
2404
2425
|
], 544)) : Y("", !0)
|
|
2405
2426
|
]),
|
|
@@ -2407,7 +2428,7 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2407
2428
|
})
|
|
2408
2429
|
], 36));
|
|
2409
2430
|
}
|
|
2410
|
-
}), Co = /* @__PURE__ */ ve(Io, [["__scopeId", "data-v-
|
|
2431
|
+
}), Co = /* @__PURE__ */ ve(Io, [["__scopeId", "data-v-255b3d8c"]]), ko = { class: "flow-canvas-selection-actions__bar" }, So = /* @__PURE__ */ fe({
|
|
2411
2432
|
__name: "selection-actions-toolbar",
|
|
2412
2433
|
props: {
|
|
2413
2434
|
position: {},
|
|
@@ -2420,13 +2441,13 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2420
2441
|
top: `${o.position.y}px`,
|
|
2421
2442
|
transform: "translateX(-100%)"
|
|
2422
2443
|
}));
|
|
2423
|
-
return (r, i) => (A(),
|
|
2444
|
+
return (r, i) => (A(), T("div", {
|
|
2424
2445
|
class: "flow-canvas-selection-actions",
|
|
2425
|
-
style:
|
|
2446
|
+
style: Ee(s.value)
|
|
2426
2447
|
}, [
|
|
2427
2448
|
q("div", ko, [
|
|
2428
2449
|
q("i", {
|
|
2429
|
-
class:
|
|
2450
|
+
class: te(["flow-canvas-icon canvas-shanchu flow-canvas-selection-actions__icon", { "is-disabled": !n.canDelete }]),
|
|
2430
2451
|
onClick: i[0] || (i[0] = (l) => n.canDelete && t("action", "delete"))
|
|
2431
2452
|
}, null, 2)
|
|
2432
2453
|
])
|
|
@@ -2445,10 +2466,10 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2445
2466
|
},
|
|
2446
2467
|
emits: ["ui-event"],
|
|
2447
2468
|
setup(n, { expose: e, emit: o }) {
|
|
2448
|
-
const t = n, s = o, r =
|
|
2449
|
-
let l, a, v,
|
|
2450
|
-
const b = oo(), { hoveredNodeId:
|
|
2451
|
-
function
|
|
2469
|
+
const t = n, s = o, r = H(), i = H();
|
|
2470
|
+
let l, a, v, f, p = null, u = null, w = null, D = null, O = null;
|
|
2471
|
+
const b = oo(), { hoveredNodeId: S, isDraggingNode: M } = b, B = b.enterOverlay, j = () => b.leaveOverlay(), k = H(0), X = H({ nodeIds: [], edgeIds: [] });
|
|
2472
|
+
function U(I) {
|
|
2452
2473
|
const C = t.editor.api.value;
|
|
2453
2474
|
return C ? t.editor.schema.nodeTypes[I.type]?.getBehavior?.(I, {
|
|
2454
2475
|
api: C,
|
|
@@ -2457,7 +2478,7 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2457
2478
|
mode: t.editor.mode.value
|
|
2458
2479
|
}) ?? {} : {};
|
|
2459
2480
|
}
|
|
2460
|
-
const
|
|
2481
|
+
const G = V(() => t.editor.mode.value === "edit" && t.editor.selectionMode.value), d = V(() => ({
|
|
2461
2482
|
showDebug: !1,
|
|
2462
2483
|
showDelete: !0,
|
|
2463
2484
|
showCopy: !0,
|
|
@@ -2468,71 +2489,71 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2468
2489
|
})), y = V(
|
|
2469
2490
|
() => {
|
|
2470
2491
|
if (k.value, !t.editor.api.value) return [];
|
|
2471
|
-
const I = t.editor.flowModel.value, C = t.editor.api.value.overlay,
|
|
2472
|
-
for (const [W,
|
|
2473
|
-
const
|
|
2474
|
-
if (!
|
|
2475
|
-
const
|
|
2476
|
-
|
|
2492
|
+
const I = t.editor.flowModel.value, C = t.editor.api.value.overlay, P = [];
|
|
2493
|
+
for (const [W, ee] of Object.entries(I.nodes)) {
|
|
2494
|
+
const le = t.editor._pluginManager.collectNodeDecorations(ee);
|
|
2495
|
+
if (!le?.badge) continue;
|
|
2496
|
+
const oe = C.getNodeScreenRect(W);
|
|
2497
|
+
oe && P.push({
|
|
2477
2498
|
nodeId: W,
|
|
2478
|
-
x:
|
|
2479
|
-
y:
|
|
2480
|
-
badge:
|
|
2499
|
+
x: oe.x + oe.width - 4,
|
|
2500
|
+
y: oe.y - 8,
|
|
2501
|
+
badge: le.badge
|
|
2481
2502
|
});
|
|
2482
2503
|
}
|
|
2483
|
-
return
|
|
2504
|
+
return P;
|
|
2484
2505
|
}
|
|
2485
|
-
),
|
|
2506
|
+
), c = V(() => {
|
|
2486
2507
|
k.value;
|
|
2487
|
-
const I =
|
|
2488
|
-
if (!I ||
|
|
2508
|
+
const I = S.value;
|
|
2509
|
+
if (!I || M.value || !t.editor.api.value || t.editor.mode.value !== "edit" || G.value)
|
|
2489
2510
|
return null;
|
|
2490
|
-
const
|
|
2491
|
-
if (!
|
|
2511
|
+
const P = t.editor.flowModel.value.nodes[I];
|
|
2512
|
+
if (!P) return null;
|
|
2492
2513
|
const W = t.editor.api.value.overlay.getNodeScreenRect(I);
|
|
2493
2514
|
if (!W) return null;
|
|
2494
|
-
const
|
|
2495
|
-
return
|
|
2496
|
-
node:
|
|
2515
|
+
const ee = U(P);
|
|
2516
|
+
return ee.showActions === !1 ? null : {
|
|
2517
|
+
node: P,
|
|
2497
2518
|
position: { x: W.x + W.width, y: W.y + W.height + 4 },
|
|
2498
|
-
behavior:
|
|
2519
|
+
behavior: ee
|
|
2499
2520
|
};
|
|
2500
2521
|
}), g = V(() => {
|
|
2501
2522
|
if (k.value, !t.editor.api.value || t.editor.mode.value !== "edit") return null;
|
|
2502
|
-
const I =
|
|
2523
|
+
const I = X.value;
|
|
2503
2524
|
if (I.nodeIds.length + I.edgeIds.length === 0) return null;
|
|
2504
2525
|
const C = t.editor.api.value.getSelectionBounds(I);
|
|
2505
2526
|
if (!C) return null;
|
|
2506
|
-
const
|
|
2527
|
+
const P = gt(I, t.editor.flowModel.value, U);
|
|
2507
2528
|
return {
|
|
2508
2529
|
position: { x: C.x + C.width, y: C.y + C.height + 4 },
|
|
2509
|
-
canDelete:
|
|
2530
|
+
canDelete: P.nodeIds.length > 0 || P.edgeIds.length > 0
|
|
2510
2531
|
};
|
|
2511
|
-
}),
|
|
2532
|
+
}), h = H(), m = ro({
|
|
2512
2533
|
editor: t.editor,
|
|
2513
2534
|
quickAddProp: V(() => t.quickAdd),
|
|
2514
|
-
isDraggingNode:
|
|
2535
|
+
isDraggingNode: M,
|
|
2515
2536
|
nodeHover: b,
|
|
2516
|
-
isSelectionModeActive:
|
|
2537
|
+
isSelectionModeActive: G,
|
|
2517
2538
|
viewportVersion: k,
|
|
2518
|
-
getNodeBehavior:
|
|
2519
|
-
getInsertGap: () =>
|
|
2520
|
-
closePopover: () =>
|
|
2521
|
-
}), E = m.data,
|
|
2522
|
-
function
|
|
2539
|
+
getNodeBehavior: U,
|
|
2540
|
+
getInsertGap: () => d.value.insertGap,
|
|
2541
|
+
closePopover: () => h.value?.closePopover()
|
|
2542
|
+
}), E = m.data, L = m.handleOpen, z = m.handleStartDrag;
|
|
2543
|
+
function ie() {
|
|
2523
2544
|
m.handleClose(), b.leaveOverlay(200), m.leave();
|
|
2524
2545
|
}
|
|
2525
|
-
const
|
|
2546
|
+
const N = m.handleOverlayEnter, _ = m.handleOverlayLeave, x = m.handleInsert, R = lo({
|
|
2526
2547
|
editor: t.editor,
|
|
2527
2548
|
edgeDropProp: V(() => t.edgeDrop)
|
|
2528
|
-
}),
|
|
2529
|
-
function
|
|
2530
|
-
|
|
2549
|
+
}), F = co(t.editor);
|
|
2550
|
+
function Z(I, C) {
|
|
2551
|
+
F.handleNodeAction(I, C, d.value.insertGap) && (S.value = null);
|
|
2531
2552
|
}
|
|
2532
|
-
function
|
|
2533
|
-
I === "delete" &&
|
|
2553
|
+
function ae(I) {
|
|
2554
|
+
I === "delete" && F.deleteSelection(X.value);
|
|
2534
2555
|
}
|
|
2535
|
-
function
|
|
2556
|
+
function Q(I) {
|
|
2536
2557
|
if (t.editor.mode.value !== "edit") return;
|
|
2537
2558
|
if ((I.metaKey || I.ctrlKey) && (I.key === "z" || I.key === "Z")) {
|
|
2538
2559
|
if (I.shiftKey) {
|
|
@@ -2547,84 +2568,84 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2547
2568
|
}
|
|
2548
2569
|
t.editor._pluginManager.dispatchKeyboardShortcut(I) && (I.preventDefault(), I.stopPropagation());
|
|
2549
2570
|
}
|
|
2550
|
-
function
|
|
2551
|
-
const
|
|
2552
|
-
const
|
|
2553
|
-
|
|
2571
|
+
function K(I, C) {
|
|
2572
|
+
const P = l, W = (ee) => {
|
|
2573
|
+
const le = P.isRubberbandEnabled?.() ?? !1;
|
|
2574
|
+
le && P.disableRubberband?.(), ee ? l.enablePanning() : l.disablePanning(), le && P.enableRubberband?.();
|
|
2554
2575
|
};
|
|
2555
|
-
I && C ? (
|
|
2576
|
+
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?.());
|
|
2556
2577
|
}
|
|
2557
|
-
function
|
|
2578
|
+
function me(I) {
|
|
2558
2579
|
l.on("node:move", ({ node: C }) => {
|
|
2559
|
-
|
|
2560
|
-
const
|
|
2561
|
-
|
|
2580
|
+
M.value = !0;
|
|
2581
|
+
const P = t.editor.flowModel.value.nodes[C.id];
|
|
2582
|
+
P && U(P).bringToFrontOnDrag === !1 || C.toFront?.();
|
|
2562
2583
|
}), l.on("node:moved", () => {
|
|
2563
|
-
|
|
2584
|
+
M.value = !1;
|
|
2564
2585
|
}), l.on("node:mouseenter", ({ node: C }) => {
|
|
2565
|
-
if (
|
|
2566
|
-
|
|
2586
|
+
if (G.value) {
|
|
2587
|
+
S.value = null, m.quickAddNodeId.value = null, I.hideNodePorts(C);
|
|
2567
2588
|
return;
|
|
2568
2589
|
}
|
|
2569
2590
|
b.enter(C.id);
|
|
2570
|
-
const
|
|
2571
|
-
if (
|
|
2591
|
+
const P = t.editor.flowModel.value.nodes[C.id];
|
|
2592
|
+
if (P && U(P).showPorts === !1) {
|
|
2572
2593
|
m.mergedConfig.value.enabled && m.enter(C.id);
|
|
2573
2594
|
return;
|
|
2574
2595
|
}
|
|
2575
2596
|
m.mergedConfig.value.enabled && m.enter(C.id) || I.showNodePorts(C);
|
|
2576
2597
|
}), l.on("node:mouseleave", ({ node: C }) => {
|
|
2577
|
-
if (
|
|
2598
|
+
if (G.value) {
|
|
2578
2599
|
I.hideNodePorts(C);
|
|
2579
2600
|
return;
|
|
2580
2601
|
}
|
|
2581
|
-
const
|
|
2602
|
+
const P = t.editor.flowModel.value.nodes[C.id];
|
|
2582
2603
|
let W = 100;
|
|
2583
|
-
|
|
2604
|
+
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);
|
|
2584
2605
|
});
|
|
2585
2606
|
}
|
|
2586
|
-
function
|
|
2607
|
+
function pe(I) {
|
|
2587
2608
|
l.on("edge:added", ({ edge: C }) => {
|
|
2588
|
-
let
|
|
2609
|
+
let P;
|
|
2589
2610
|
if (t.getConnectionExcludedNodeIds && !C.getTargetCell()) {
|
|
2590
2611
|
const W = C.getSourceCell();
|
|
2591
2612
|
if (W) {
|
|
2592
|
-
const
|
|
2593
|
-
|
|
2613
|
+
const ee = t.getConnectionExcludedNodeIds(W.id);
|
|
2614
|
+
P = ee instanceof Set ? ee : new Set(ee);
|
|
2594
2615
|
}
|
|
2595
2616
|
}
|
|
2596
|
-
I.handleEdgeAdded(C,
|
|
2617
|
+
I.handleEdgeAdded(C, P);
|
|
2597
2618
|
}), l.on("edge:connected", () => {
|
|
2598
2619
|
I.handleEdgeConnected();
|
|
2599
2620
|
}), l.on("edge:removed", ({ edge: C }) => {
|
|
2600
|
-
I.handleEdgeRemoved(C.id),
|
|
2601
|
-
}), l.on("edge:mouseenter", ({ edge: C, e:
|
|
2621
|
+
I.handleEdgeRemoved(C.id), p.handleEdgeRemoved(C.id);
|
|
2622
|
+
}), l.on("edge:mouseenter", ({ edge: C, e: P }) => {
|
|
2602
2623
|
const W = a.getHoveredEdgeId();
|
|
2603
|
-
a.setHoveredEdge(C.id), W && W !== C.id && a.refreshSingleEdgeStyle(W), a.refreshSingleEdgeStyle(C.id), t.editor.mode.value === "edit" && !
|
|
2624
|
+
a.setHoveredEdge(C.id), W && W !== C.id && a.refreshSingleEdgeStyle(W), a.refreshSingleEdgeStyle(C.id), t.editor.mode.value === "edit" && !G.value && I.canShowEdgeTool() && p.show(C.id, P);
|
|
2604
2625
|
}), l.on("edge:mouseleave", ({ edge: C }) => {
|
|
2605
|
-
a.setHoveredEdge(null), a.refreshSingleEdgeStyle(C.id),
|
|
2606
|
-
}), l.on("edge:click", ({ edge: C, e:
|
|
2607
|
-
|
|
2608
|
-
id:
|
|
2626
|
+
a.setHoveredEdge(null), a.refreshSingleEdgeStyle(C.id), p.remove();
|
|
2627
|
+
}), l.on("edge:click", ({ edge: C, e: P }) => {
|
|
2628
|
+
P.target?.closest?.(".flow-canvas-edge-delete-tool") && t.editor.mode.value === "edit" && (p.remove(), t.editor.executeCommand({
|
|
2629
|
+
id: J(),
|
|
2609
2630
|
source: "user:toolbar",
|
|
2610
2631
|
label: "删除连线",
|
|
2611
2632
|
timestamp: Date.now(),
|
|
2612
2633
|
commands: [{ type: "edge.remove", edgeId: C.id }]
|
|
2613
2634
|
}));
|
|
2614
|
-
}),
|
|
2635
|
+
}), u = (C) => p.move(C), l.container.addEventListener("mousemove", u);
|
|
2615
2636
|
}
|
|
2616
|
-
function
|
|
2637
|
+
function we() {
|
|
2617
2638
|
w = (I) => {
|
|
2618
|
-
if (!
|
|
2639
|
+
if (!S.value && !m.quickAddNodeId.value) return;
|
|
2619
2640
|
const C = I.target;
|
|
2620
2641
|
if (C?.closest?.(".x6-node") || C?.closest?.(".flow-canvas-node-actions") || C?.closest?.(".flow-canvas-quick-add")) {
|
|
2621
2642
|
b.cancelLeave(), m.cancelLeave();
|
|
2622
2643
|
return;
|
|
2623
2644
|
}
|
|
2624
2645
|
b.leave(180), m.quickAddPopoverOpen.value || m.leave();
|
|
2625
|
-
}, r.value?.addEventListener("mousemove", w),
|
|
2646
|
+
}, r.value?.addEventListener("mousemove", w), D = () => {
|
|
2626
2647
|
b.reset(), m.quickAddPopoverOpen.value || (m.quickAddNodeId.value = null);
|
|
2627
|
-
}, r.value?.addEventListener("mouseleave",
|
|
2648
|
+
}, r.value?.addEventListener("mouseleave", D), r.value?.addEventListener("keydown", Q);
|
|
2628
2649
|
}
|
|
2629
2650
|
function $e() {
|
|
2630
2651
|
ge(
|
|
@@ -2633,21 +2654,21 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2633
2654
|
), ge(
|
|
2634
2655
|
[() => t.editor.mode.value, () => t.editor.selectionMode.value],
|
|
2635
2656
|
([I, C]) => {
|
|
2636
|
-
|
|
2657
|
+
K(I === "edit", C);
|
|
2637
2658
|
},
|
|
2638
2659
|
{ immediate: !0 }
|
|
2639
2660
|
);
|
|
2640
2661
|
}
|
|
2641
|
-
|
|
2662
|
+
dt(() => {
|
|
2642
2663
|
if (!i.value) return;
|
|
2643
2664
|
const I = /* @__PURE__ */ new Set(["model", "container"]), C = {};
|
|
2644
2665
|
if (t.graphOptions)
|
|
2645
|
-
for (const [
|
|
2646
|
-
if (I.has(
|
|
2647
|
-
console.warn(`[flow-canvas] graphOptions.${
|
|
2666
|
+
for (const [$, ne] of Object.entries(t.graphOptions)) {
|
|
2667
|
+
if (I.has($)) {
|
|
2668
|
+
console.warn(`[flow-canvas] graphOptions.${$} is managed by the engine and will be ignored`);
|
|
2648
2669
|
continue;
|
|
2649
2670
|
}
|
|
2650
|
-
C[
|
|
2671
|
+
C[$] = ne;
|
|
2651
2672
|
}
|
|
2652
2673
|
l = new Et({
|
|
2653
2674
|
container: i.value,
|
|
@@ -2668,8 +2689,8 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2668
2689
|
panning: { enabled: !0 },
|
|
2669
2690
|
mousewheel: { enabled: !0, modifiers: ["ctrl", "meta"] },
|
|
2670
2691
|
interacting: {
|
|
2671
|
-
nodeMovable(
|
|
2672
|
-
return
|
|
2692
|
+
nodeMovable($) {
|
|
2693
|
+
return $.cell.getProp("draggable") !== !1;
|
|
2673
2694
|
}
|
|
2674
2695
|
},
|
|
2675
2696
|
connecting: {
|
|
@@ -2691,8 +2712,8 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2691
2712
|
l,
|
|
2692
2713
|
t.editor.schema,
|
|
2693
2714
|
v,
|
|
2694
|
-
(
|
|
2695
|
-
(
|
|
2715
|
+
($) => t.editor._pluginManager.collectNodeDecorations($),
|
|
2716
|
+
($) => t.editor._pluginManager.collectEdgeDecorations($),
|
|
2696
2717
|
() => t.editor.api.value ? {
|
|
2697
2718
|
api: t.editor.api.value,
|
|
2698
2719
|
flowModel: t.editor.flowModel.value,
|
|
@@ -2700,35 +2721,35 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2700
2721
|
mode: t.editor.mode.value
|
|
2701
2722
|
} : null
|
|
2702
2723
|
);
|
|
2703
|
-
const
|
|
2724
|
+
const P = Kt(l), W = to({
|
|
2704
2725
|
graph: l,
|
|
2705
|
-
overlayManager:
|
|
2706
|
-
executeCommand: (
|
|
2726
|
+
overlayManager: P,
|
|
2727
|
+
executeCommand: ($) => t.editor.executeCommand(R.tryExpandForEdgeDrop($)),
|
|
2707
2728
|
schema: t.editor.schema,
|
|
2708
2729
|
flowModel: t.editor.flowModel,
|
|
2709
|
-
getNodeBehavior:
|
|
2730
|
+
getNodeBehavior: U,
|
|
2710
2731
|
idGenerator: t.editor.idGenerator,
|
|
2711
2732
|
defaultInsertGap: t.nodeActions?.insertGap,
|
|
2712
|
-
getContextMenuItems: (
|
|
2713
|
-
onHighlightChange: (
|
|
2714
|
-
a.setHighlightedNodes(
|
|
2715
|
-
const
|
|
2733
|
+
getContextMenuItems: ($) => t.editor._pluginManager.collectContextMenuItems($),
|
|
2734
|
+
onHighlightChange: ($, ne) => {
|
|
2735
|
+
a.setHighlightedNodes($);
|
|
2736
|
+
const he = a.setHighlightedEdges(ne);
|
|
2716
2737
|
a.refreshNodeHighlights();
|
|
2717
|
-
const
|
|
2718
|
-
for (const
|
|
2719
|
-
|
|
2720
|
-
for (const
|
|
2721
|
-
|
|
2738
|
+
const se = new Set(ne);
|
|
2739
|
+
for (const ye of he)
|
|
2740
|
+
se.has(ye) || a.refreshSingleEdgeStyle(ye);
|
|
2741
|
+
for (const ye of se)
|
|
2742
|
+
he.has(ye) || a.refreshSingleEdgeStyle(ye);
|
|
2722
2743
|
},
|
|
2723
|
-
resolveNodeShape: (
|
|
2724
|
-
const
|
|
2725
|
-
if (!
|
|
2726
|
-
const
|
|
2727
|
-
return { shapeName:
|
|
2744
|
+
resolveNodeShape: ($) => {
|
|
2745
|
+
const ne = t.editor.schema.nodeTypes[$];
|
|
2746
|
+
if (!ne) return null;
|
|
2747
|
+
const he = v.registerNodeType($, ne.component), se = ne.getSize({ id: "", type: $, position: { x: 0, y: 0 } });
|
|
2748
|
+
return { shapeName: he, width: se.width, height: se.height };
|
|
2728
2749
|
}
|
|
2729
2750
|
});
|
|
2730
2751
|
t.editor.api.value = W;
|
|
2731
|
-
const
|
|
2752
|
+
const ee = {
|
|
2732
2753
|
flowModel: t.editor.flowModel,
|
|
2733
2754
|
history: t.editor.history,
|
|
2734
2755
|
schema: t.editor.schema,
|
|
@@ -2737,66 +2758,66 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2737
2758
|
executeCommand: t.editor.executeCommand,
|
|
2738
2759
|
selectionMode: t.editor.selectionMode,
|
|
2739
2760
|
api: W,
|
|
2740
|
-
overlay:
|
|
2761
|
+
overlay: P,
|
|
2741
2762
|
graph: l
|
|
2742
2763
|
};
|
|
2743
|
-
t.editor._pluginManager.attachRuntime(
|
|
2744
|
-
const
|
|
2745
|
-
Object.assign(t.editor.extendedApi,
|
|
2746
|
-
t.editor._pluginManager.dispatchUiEvent(
|
|
2747
|
-
},
|
|
2764
|
+
t.editor._pluginManager.attachRuntime(ee);
|
|
2765
|
+
const le = t.editor._pluginManager.collectExtendedApi();
|
|
2766
|
+
Object.assign(t.editor.extendedApi, le), t.editor._emitUiEvent = ($) => {
|
|
2767
|
+
t.editor._pluginManager.dispatchUiEvent($), s("ui-event", $);
|
|
2768
|
+
}, f = new Xt(
|
|
2748
2769
|
l,
|
|
2749
|
-
(
|
|
2750
|
-
(
|
|
2770
|
+
($) => {
|
|
2771
|
+
($.type === "node.click" || $.type === "node.dblclick" || $.type === "node.contextmenu") && b.enter($.nodeId), t.editor._emitUiEvent($);
|
|
2751
2772
|
},
|
|
2752
|
-
(
|
|
2773
|
+
($) => {
|
|
2753
2774
|
if (a.isSyncing) return;
|
|
2754
|
-
const
|
|
2755
|
-
if (t.editor.executeCommand(
|
|
2756
|
-
for (const
|
|
2757
|
-
if (
|
|
2758
|
-
const
|
|
2759
|
-
|
|
2775
|
+
const ne = R.tryExpandForEdgeDrop($);
|
|
2776
|
+
if (t.editor.executeCommand(ne).status !== "applied") {
|
|
2777
|
+
for (const se of ne.commands)
|
|
2778
|
+
if (se.type === "edge.add") {
|
|
2779
|
+
const ye = l.getCellById(se.edge.id);
|
|
2780
|
+
ye && l.removeCell(ye);
|
|
2760
2781
|
}
|
|
2761
2782
|
}
|
|
2762
2783
|
},
|
|
2763
2784
|
t.editor.flowModel,
|
|
2764
2785
|
t.editor.idGenerator
|
|
2765
|
-
),
|
|
2766
|
-
const
|
|
2767
|
-
m.attachRuntime(l, (
|
|
2768
|
-
let xe = /* @__PURE__ */ new Set(),
|
|
2786
|
+
), p = no(l);
|
|
2787
|
+
const oe = so(l);
|
|
2788
|
+
m.attachRuntime(l, ($) => oe.hideNodePorts($)), R.attachRuntime(l), me(oe), pe(oe), O = vo(l.container);
|
|
2789
|
+
let xe = /* @__PURE__ */ new Set(), be = /* @__PURE__ */ new Set();
|
|
2769
2790
|
l.on("selection:changed", () => {
|
|
2770
|
-
const
|
|
2771
|
-
mo(l, xe,
|
|
2791
|
+
const $ = ft(l.getSelectedCells?.() ?? []), ne = new Set($.nodeIds);
|
|
2792
|
+
mo(l, xe, ne), xe = ne, X.value = $, t.editor._pluginManager.dispatchSelectionChange($), s("ui-event", {
|
|
2772
2793
|
type: "selection.change",
|
|
2773
|
-
nodeIds:
|
|
2774
|
-
edgeIds:
|
|
2794
|
+
nodeIds: $.nodeIds,
|
|
2795
|
+
edgeIds: $.edgeIds
|
|
2775
2796
|
}), a.refreshNodeHighlights();
|
|
2776
|
-
const
|
|
2777
|
-
for (const
|
|
2778
|
-
|
|
2779
|
-
for (const
|
|
2780
|
-
|
|
2781
|
-
|
|
2797
|
+
const he = new Set($.edgeIds);
|
|
2798
|
+
for (const se of be)
|
|
2799
|
+
he.has(se) || a.refreshSingleEdgeStyle(se);
|
|
2800
|
+
for (const se of he)
|
|
2801
|
+
be.has(se) || a.refreshSingleEdgeStyle(se);
|
|
2802
|
+
be = he;
|
|
2782
2803
|
});
|
|
2783
2804
|
const Be = () => {
|
|
2784
2805
|
k.value++;
|
|
2785
2806
|
};
|
|
2786
|
-
l.on("translate", Be), l.on("scale", Be), l.on("resize", Be),
|
|
2807
|
+
l.on("translate", Be), l.on("scale", Be), l.on("resize", Be), we(), a.syncFlowModel(t.editor.flowModel.value), $e();
|
|
2787
2808
|
});
|
|
2788
2809
|
function Se() {
|
|
2789
2810
|
b.reset(), m.quickAddNodeId.value = null, m.quickAddPopoverOpen.value = !1;
|
|
2790
2811
|
}
|
|
2791
2812
|
return e({ resetHoverState: Se }), Te(() => {
|
|
2792
|
-
b.cleanup(), m.cleanup(),
|
|
2813
|
+
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", Q), t.editor._pluginManager.detachRuntime(), t.editor.api.value = null;
|
|
2793
2814
|
for (const I of Object.keys(t.editor.extendedApi))
|
|
2794
2815
|
delete t.editor.extendedApi[I];
|
|
2795
|
-
|
|
2796
|
-
}), (I, C) => (A(),
|
|
2816
|
+
f?.dispose(), a?.dispose(), v?.dispose(), l?.dispose();
|
|
2817
|
+
}), (I, C) => (A(), T("div", {
|
|
2797
2818
|
ref_key: "rootRef",
|
|
2798
2819
|
ref: r,
|
|
2799
|
-
class:
|
|
2820
|
+
class: te(["flow-canvas-runtime-core", { "flow-canvas-runtime-core--selection-mode": G.value }]),
|
|
2800
2821
|
tabindex: "0"
|
|
2801
2822
|
}, [
|
|
2802
2823
|
q("div", {
|
|
@@ -2805,61 +2826,64 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2805
2826
|
class: "flow-canvas-runtime-core__graph"
|
|
2806
2827
|
}, null, 512),
|
|
2807
2828
|
q("div", No, [
|
|
2808
|
-
(A(!0),
|
|
2809
|
-
key: `badge-${
|
|
2829
|
+
(A(!0), T(de, null, Ce(y.value, (P) => (A(), T("div", {
|
|
2830
|
+
key: `badge-${P.nodeId}`,
|
|
2810
2831
|
class: "flow-canvas-runtime-core__badge",
|
|
2811
|
-
style:
|
|
2812
|
-
}, ce(
|
|
2813
|
-
|
|
2832
|
+
style: Ee({ left: `${P.x}px`, top: `${P.y}px`, backgroundColor: P.badge.color })
|
|
2833
|
+
}, ce(P.badge.text), 5))), 128)),
|
|
2834
|
+
re(E) ? (A(), Ie(Co, {
|
|
2814
2835
|
key: 0,
|
|
2815
2836
|
ref_key: "quickAddPopoverRef",
|
|
2816
|
-
ref:
|
|
2817
|
-
node:
|
|
2818
|
-
"port-position":
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2837
|
+
ref: h,
|
|
2838
|
+
node: re(E).node,
|
|
2839
|
+
"port-position": re(E).portPosition,
|
|
2840
|
+
"auto-pan-on-open": re(m).mergedConfig.value.autoPanOnOpen,
|
|
2841
|
+
"auto-pan-padding": re(m).mergedConfig.value.autoPanPadding,
|
|
2842
|
+
onOpen: re(L),
|
|
2843
|
+
onClose: ie,
|
|
2844
|
+
onStartDrag: re(z),
|
|
2845
|
+
onViewportOverflowRight: re(m).handlePopoverViewportOverflow,
|
|
2846
|
+
onMouseenter: re(N),
|
|
2847
|
+
onMouseleave: re(_)
|
|
2824
2848
|
}, {
|
|
2825
2849
|
default: He(() => [
|
|
2826
2850
|
Me(I.$slots, "quick-add-panel", {
|
|
2827
|
-
node:
|
|
2851
|
+
node: re(E).node,
|
|
2828
2852
|
api: n.editor.api.value,
|
|
2829
|
-
insertNodeToRight: (
|
|
2830
|
-
closePopover: () =>
|
|
2853
|
+
insertNodeToRight: (P) => re(x)(re(E).node.id, P),
|
|
2854
|
+
closePopover: () => h.value?.closePopover()
|
|
2831
2855
|
}, void 0, !0)
|
|
2832
2856
|
]),
|
|
2833
2857
|
_: 3
|
|
2834
|
-
}, 8, ["node", "port-position", "onOpen", "onStartDrag", "onMouseenter", "onMouseleave"])) : Y("", !0),
|
|
2835
|
-
|
|
2858
|
+
}, 8, ["node", "port-position", "auto-pan-on-open", "auto-pan-padding", "onOpen", "onStartDrag", "onViewportOverflowRight", "onMouseenter", "onMouseleave"])) : Y("", !0),
|
|
2859
|
+
c.value ? (A(), Ie(bo, {
|
|
2836
2860
|
key: 1,
|
|
2837
|
-
node:
|
|
2838
|
-
position:
|
|
2839
|
-
config:
|
|
2840
|
-
behavior:
|
|
2841
|
-
"actions-offset":
|
|
2842
|
-
onAction:
|
|
2843
|
-
onMouseenter:
|
|
2844
|
-
onMouseleave:
|
|
2861
|
+
node: c.value.node,
|
|
2862
|
+
position: c.value.position,
|
|
2863
|
+
config: d.value,
|
|
2864
|
+
behavior: c.value.behavior,
|
|
2865
|
+
"actions-offset": c.value.behavior.actionsOffset,
|
|
2866
|
+
onAction: Z,
|
|
2867
|
+
onMouseenter: re(B),
|
|
2868
|
+
onMouseleave: j
|
|
2845
2869
|
}, null, 8, ["node", "position", "config", "behavior", "actions-offset", "onMouseenter"])) : Y("", !0),
|
|
2846
2870
|
g.value ? (A(), Ie(Mo, {
|
|
2847
2871
|
key: 2,
|
|
2848
2872
|
position: g.value.position,
|
|
2849
2873
|
"can-delete": g.value.canDelete,
|
|
2850
|
-
onAction:
|
|
2874
|
+
onAction: ae
|
|
2851
2875
|
}, null, 8, ["position", "can-delete"])) : Y("", !0)
|
|
2852
2876
|
])
|
|
2853
2877
|
], 2));
|
|
2854
2878
|
}
|
|
2855
|
-
}), Dn = /* @__PURE__ */ ve(Do, [["__scopeId", "data-v-
|
|
2879
|
+
}), Dn = /* @__PURE__ */ ve(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__ */ fe({
|
|
2856
2880
|
__name: "canvas-node-palette",
|
|
2857
2881
|
props: {
|
|
2858
2882
|
editor: {},
|
|
2859
2883
|
items: {}
|
|
2860
2884
|
},
|
|
2861
2885
|
setup(n) {
|
|
2862
|
-
const e = n, o =
|
|
2886
|
+
const e = n, o = H(), t = V(() => e.items ? e.items : Object.keys(e.editor.schema.nodeTypes).map((s) => ({
|
|
2863
2887
|
type: s,
|
|
2864
2888
|
label: s.charAt(0).toUpperCase() + s.slice(1)
|
|
2865
2889
|
})));
|
|
@@ -2868,43 +2892,43 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2868
2892
|
([s, r, i], l, a) => {
|
|
2869
2893
|
if (!s || !i) return;
|
|
2870
2894
|
const v = [];
|
|
2871
|
-
for (const
|
|
2872
|
-
const
|
|
2873
|
-
if (!
|
|
2874
|
-
const
|
|
2875
|
-
id:
|
|
2876
|
-
type:
|
|
2877
|
-
label:
|
|
2895
|
+
for (const f of r) {
|
|
2896
|
+
const p = i.querySelector(`[data-node-type="${f.type}"]`);
|
|
2897
|
+
if (!p) continue;
|
|
2898
|
+
const u = s.registerDndSource(p, () => ({
|
|
2899
|
+
id: J(),
|
|
2900
|
+
type: f.type,
|
|
2901
|
+
label: f.label,
|
|
2878
2902
|
position: { x: 0, y: 0 }
|
|
2879
2903
|
}));
|
|
2880
|
-
v.push(
|
|
2904
|
+
v.push(u);
|
|
2881
2905
|
}
|
|
2882
2906
|
a(() => {
|
|
2883
|
-
for (const
|
|
2907
|
+
for (const f of v) f();
|
|
2884
2908
|
});
|
|
2885
2909
|
},
|
|
2886
2910
|
{ flush: "post" }
|
|
2887
|
-
), (s, r) => (A(),
|
|
2911
|
+
), (s, r) => (A(), T("div", Ao, [
|
|
2888
2912
|
q("div", {
|
|
2889
2913
|
ref_key: "listRef",
|
|
2890
2914
|
ref: o,
|
|
2891
2915
|
class: "flow-canvas-node-palette__list"
|
|
2892
2916
|
}, [
|
|
2893
|
-
(A(!0),
|
|
2917
|
+
(A(!0), T(de, null, Ce(t.value, (i) => (A(), T("div", {
|
|
2894
2918
|
key: i.type,
|
|
2895
2919
|
class: "flow-canvas-node-palette__item",
|
|
2896
2920
|
"data-node-type": i.type
|
|
2897
2921
|
}, [
|
|
2898
|
-
i.icon ? (A(),
|
|
2922
|
+
i.icon ? (A(), T("i", {
|
|
2899
2923
|
key: 0,
|
|
2900
|
-
class:
|
|
2924
|
+
class: te([i.icon, "flow-canvas-node-palette__item-icon"])
|
|
2901
2925
|
}, null, 2)) : Y("", !0),
|
|
2902
2926
|
q("span", Po, ce(i.label), 1)
|
|
2903
2927
|
], 8, _o))), 128))
|
|
2904
2928
|
], 512)
|
|
2905
2929
|
]));
|
|
2906
2930
|
}
|
|
2907
|
-
}),
|
|
2931
|
+
}), Ro = /* @__PURE__ */ ve(To, [["__scopeId", "data-v-300314b7"]]), Lo = { class: "flow-canvas-layout" }, Oo = { class: "flow-canvas-layout__main" }, $o = { class: "flow-canvas-layout__content" }, Bo = {
|
|
2908
2932
|
key: 0,
|
|
2909
2933
|
class: "flow-canvas-layout__footer"
|
|
2910
2934
|
}, Fo = /* @__PURE__ */ fe({
|
|
@@ -2919,14 +2943,14 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2919
2943
|
},
|
|
2920
2944
|
emits: ["update:sidebarCollapsed"],
|
|
2921
2945
|
setup(n) {
|
|
2922
|
-
return (e, o) => (A(),
|
|
2923
|
-
!n.hideSidebar && (e.$slots.sidebar || n.editor) ? (A(),
|
|
2946
|
+
return (e, o) => (A(), T("div", Lo, [
|
|
2947
|
+
!n.hideSidebar && (e.$slots.sidebar || n.editor) ? (A(), T("aside", {
|
|
2924
2948
|
key: 0,
|
|
2925
|
-
class:
|
|
2926
|
-
style:
|
|
2949
|
+
class: te(["flow-canvas-layout__sidebar", { "is-collapsed": n.sidebarCollapsed }]),
|
|
2950
|
+
style: Ee({ width: n.sidebarCollapsed ? "0px" : `${n.sidebarWidth}px` })
|
|
2927
2951
|
}, [
|
|
2928
2952
|
Me(e.$slots, "sidebar", {}, () => [
|
|
2929
|
-
n.editor ? (A(), Ie(
|
|
2953
|
+
n.editor ? (A(), Ie(Ro, {
|
|
2930
2954
|
key: 0,
|
|
2931
2955
|
editor: n.editor,
|
|
2932
2956
|
items: n.paletteItems
|
|
@@ -2937,13 +2961,13 @@ const yo = { class: "flow-canvas-node-actions__bar" }, wo = /* @__PURE__ */ fe({
|
|
|
2937
2961
|
q("div", $o, [
|
|
2938
2962
|
Me(e.$slots, "default", {}, void 0, !0)
|
|
2939
2963
|
]),
|
|
2940
|
-
!n.hideFooter && e.$slots.footer ? (A(),
|
|
2964
|
+
!n.hideFooter && e.$slots.footer ? (A(), T("div", Bo, [
|
|
2941
2965
|
Me(e.$slots, "footer", {}, void 0, !0)
|
|
2942
2966
|
])) : Y("", !0)
|
|
2943
2967
|
])
|
|
2944
2968
|
]));
|
|
2945
2969
|
}
|
|
2946
|
-
}), An = /* @__PURE__ */ ve(Fo, [["__scopeId", "data-v-26f35b6b"]]),
|
|
2970
|
+
}), An = /* @__PURE__ */ ve(Fo, [["__scopeId", "data-v-26f35b6b"]]), et = typeof navigator < "u" && /Mac|iPod|iPhone|iPad/.test(navigator.platform ?? navigator.userAgent), qo = ["undo", "redo"];
|
|
2947
2971
|
function Ho(n) {
|
|
2948
2972
|
const e = new Set(n?.include), o = new Set(qo.filter((a) => !e.has(a))), t = [
|
|
2949
2973
|
{
|
|
@@ -2952,7 +2976,7 @@ function Ho(n) {
|
|
|
2952
2976
|
group: "history",
|
|
2953
2977
|
icon: "flow-canvas-icon canvas-undo",
|
|
2954
2978
|
description: "撤销",
|
|
2955
|
-
shortcut:
|
|
2979
|
+
shortcut: et ? ["⌘", "Z"] : ["Ctrl", "Z"],
|
|
2956
2980
|
order: 10
|
|
2957
2981
|
},
|
|
2958
2982
|
{
|
|
@@ -2961,7 +2985,7 @@ function Ho(n) {
|
|
|
2961
2985
|
group: "history",
|
|
2962
2986
|
icon: "flow-canvas-icon canvas-redo",
|
|
2963
2987
|
description: "重做",
|
|
2964
|
-
shortcut:
|
|
2988
|
+
shortcut: et ? ["⇧", "⌘", "Z"] : ["Ctrl", "Shift", "Z"],
|
|
2965
2989
|
order: 11
|
|
2966
2990
|
}
|
|
2967
2991
|
], s = [
|
|
@@ -3048,47 +3072,47 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3048
3072
|
"minimap",
|
|
3049
3073
|
"export"
|
|
3050
3074
|
]), o = /* @__PURE__ */ new Set(["select", "search", "minimap"]);
|
|
3051
|
-
function t(
|
|
3052
|
-
return
|
|
3075
|
+
function t(c) {
|
|
3076
|
+
return c.id.startsWith("plugin:") || c.type === "custom";
|
|
3053
3077
|
}
|
|
3054
|
-
function s(
|
|
3055
|
-
return
|
|
3078
|
+
function s(c) {
|
|
3079
|
+
return c !== "custom" && o.has(c);
|
|
3056
3080
|
}
|
|
3057
3081
|
const r = n, i = V(() => {
|
|
3058
3082
|
if (r.items) return r.items;
|
|
3059
|
-
const
|
|
3060
|
-
for (const E of
|
|
3083
|
+
const c = Ho({ include: r.include }), g = r.editor.toolbarItems.value, h = new Set(r.exclude ?? []), m = /* @__PURE__ */ new Map();
|
|
3084
|
+
for (const E of c)
|
|
3061
3085
|
m.set(E.id, E);
|
|
3062
3086
|
for (const E of g) {
|
|
3063
|
-
const
|
|
3064
|
-
|
|
3087
|
+
const L = m.get(E.id);
|
|
3088
|
+
L ? m.set(E.id, { ...L, ...E, order: L.order, group: L.group }) : t(E) && m.set(E.id, E);
|
|
3065
3089
|
}
|
|
3066
|
-
return [...m.values()].filter((E) => E.type === "custom" || !e.has(E.type) ? !0 : !
|
|
3067
|
-
}), l =
|
|
3068
|
-
let
|
|
3090
|
+
return [...m.values()].filter((E) => E.type === "custom" || !e.has(E.type) ? !0 : !h.has(E.type)).sort((E, L) => (E.order ?? 0) - (L.order ?? 0));
|
|
3091
|
+
}), l = H(1), a = H(null), v = H(null), f = H(!1);
|
|
3092
|
+
let p = null;
|
|
3069
3093
|
ge(
|
|
3070
3094
|
() => r.editor.api.value,
|
|
3071
|
-
(
|
|
3072
|
-
|
|
3073
|
-
l.value =
|
|
3095
|
+
(c) => {
|
|
3096
|
+
p?.(), p = null, c && (l.value = c.getZoom(), p = c.onGraphEvent("scale", () => {
|
|
3097
|
+
l.value = c.getZoom();
|
|
3074
3098
|
}));
|
|
3075
3099
|
},
|
|
3076
3100
|
{ immediate: !0 }
|
|
3077
3101
|
);
|
|
3078
|
-
const
|
|
3079
|
-
function w(
|
|
3102
|
+
const u = vt({ visible: !1, text: "", shortcut: [], x: 0, y: 0 });
|
|
3103
|
+
function w(c, g) {
|
|
3080
3104
|
if (!g.description) return;
|
|
3081
|
-
const m =
|
|
3082
|
-
|
|
3083
|
-
const E = a.value?.offsetWidth ?? 0,
|
|
3084
|
-
|
|
3105
|
+
const m = c.currentTarget.getBoundingClientRect();
|
|
3106
|
+
u.text = g.description, u.shortcut = g.shortcut ?? [], u.visible = !0, Ge(() => {
|
|
3107
|
+
const E = a.value?.offsetWidth ?? 0, L = a.value?.offsetHeight ?? 0;
|
|
3108
|
+
u.x = m.left + m.width / 2 - E / 2, u.y = m.top - L - 6;
|
|
3085
3109
|
});
|
|
3086
3110
|
}
|
|
3087
|
-
function
|
|
3088
|
-
|
|
3111
|
+
function D() {
|
|
3112
|
+
u.visible = !1, a.value = null;
|
|
3089
3113
|
}
|
|
3090
|
-
|
|
3091
|
-
|
|
3114
|
+
it(() => {
|
|
3115
|
+
p?.();
|
|
3092
3116
|
});
|
|
3093
3117
|
const O = V(() => `${Math.round(l.value * 100)}%`), b = V(() => r.editor.api.value ? {
|
|
3094
3118
|
api: r.editor.api.value,
|
|
@@ -3096,48 +3120,48 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3096
3120
|
history: r.editor.history,
|
|
3097
3121
|
mode: r.editor.mode.value
|
|
3098
3122
|
} : null);
|
|
3099
|
-
function
|
|
3100
|
-
return
|
|
3123
|
+
function S(c) {
|
|
3124
|
+
return c.visible === !1 ? !1 : typeof c.visible == "function" ? b.value ? c.visible(b.value) : !1 : !0;
|
|
3101
3125
|
}
|
|
3102
|
-
function
|
|
3103
|
-
return typeof
|
|
3126
|
+
function M(c) {
|
|
3127
|
+
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;
|
|
3104
3128
|
}
|
|
3105
|
-
const
|
|
3106
|
-
const
|
|
3107
|
-
(
|
|
3129
|
+
const B = V(() => {
|
|
3130
|
+
const c = d.value.filter(
|
|
3131
|
+
(h) => s(h.type) && M(h)
|
|
3108
3132
|
);
|
|
3109
|
-
if (
|
|
3133
|
+
if (c.length === 0) return null;
|
|
3110
3134
|
const g = v.value;
|
|
3111
|
-
return g &&
|
|
3135
|
+
return g && c.some((h) => h.type === g) ? g : c[0]?.type ?? null;
|
|
3112
3136
|
});
|
|
3113
|
-
function
|
|
3114
|
-
return s(
|
|
3137
|
+
function j(c) {
|
|
3138
|
+
return s(c.type) ? B.value === c.type : M(c);
|
|
3115
3139
|
}
|
|
3116
|
-
function k(
|
|
3117
|
-
return !b.value ||
|
|
3140
|
+
function k(c) {
|
|
3141
|
+
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;
|
|
3118
3142
|
}
|
|
3119
|
-
function
|
|
3120
|
-
if (!(!b.value || !s(
|
|
3121
|
-
if (
|
|
3143
|
+
function X(c) {
|
|
3144
|
+
if (!(!b.value || !s(c.type) || !M(c))) {
|
|
3145
|
+
if (c.type === "select") {
|
|
3122
3146
|
r.editor.setSelectionMode(!1);
|
|
3123
3147
|
return;
|
|
3124
3148
|
}
|
|
3125
|
-
|
|
3149
|
+
c.onClick?.(b.value);
|
|
3126
3150
|
}
|
|
3127
3151
|
}
|
|
3128
|
-
function
|
|
3129
|
-
if (s(
|
|
3130
|
-
for (const g of
|
|
3131
|
-
!s(g.type) || g.id ===
|
|
3152
|
+
function U(c) {
|
|
3153
|
+
if (s(c.type))
|
|
3154
|
+
for (const g of d.value)
|
|
3155
|
+
!s(g.type) || g.id === c.id || X(g);
|
|
3132
3156
|
}
|
|
3133
|
-
function
|
|
3134
|
-
if (!b.value || k(
|
|
3135
|
-
if (s(
|
|
3136
|
-
|
|
3157
|
+
function G(c) {
|
|
3158
|
+
if (!b.value || k(c)) return;
|
|
3159
|
+
if (s(c.type) && (v.value = c.type, U(c)), c.onClick) {
|
|
3160
|
+
c.onClick(b.value);
|
|
3137
3161
|
return;
|
|
3138
3162
|
}
|
|
3139
3163
|
const { api: g } = b.value;
|
|
3140
|
-
switch (
|
|
3164
|
+
switch (c.type) {
|
|
3141
3165
|
case "undo":
|
|
3142
3166
|
r.editor.history.undo();
|
|
3143
3167
|
break;
|
|
@@ -3157,14 +3181,14 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3157
3181
|
g.zoomTo(1), g.scrollToOrigin(), l.value = 1;
|
|
3158
3182
|
break;
|
|
3159
3183
|
case "export":
|
|
3160
|
-
if (
|
|
3161
|
-
|
|
3162
|
-
const m = URL.createObjectURL(
|
|
3184
|
+
if (f.value) break;
|
|
3185
|
+
f.value = !0, g.exportAsImage().then((h) => {
|
|
3186
|
+
const m = URL.createObjectURL(h), E = document.createElement("a");
|
|
3163
3187
|
E.href = m, E.download = "canvas-export.png", E.click(), URL.revokeObjectURL(m);
|
|
3164
|
-
}).catch((
|
|
3165
|
-
console.warn("[flow-canvas] Export failed:",
|
|
3188
|
+
}).catch((h) => {
|
|
3189
|
+
console.warn("[flow-canvas] Export failed:", h);
|
|
3166
3190
|
}).finally(() => {
|
|
3167
|
-
|
|
3191
|
+
f.value = !1;
|
|
3168
3192
|
});
|
|
3169
3193
|
break;
|
|
3170
3194
|
case "select":
|
|
@@ -3175,49 +3199,49 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3175
3199
|
break;
|
|
3176
3200
|
case "search":
|
|
3177
3201
|
case "minimap":
|
|
3178
|
-
console.warn(`[flow-canvas] "${
|
|
3202
|
+
console.warn(`[flow-canvas] "${c.type}" toolbar item has no built-in handler. Provide an onClick callback.`);
|
|
3179
3203
|
break;
|
|
3180
3204
|
default:
|
|
3181
|
-
|
|
3205
|
+
c.type !== "custom" && console.warn(`[flow-canvas] No default handler for toolbar type "${c.type}". Provide an onClick handler.`);
|
|
3182
3206
|
break;
|
|
3183
3207
|
}
|
|
3184
3208
|
}
|
|
3185
|
-
const
|
|
3186
|
-
const
|
|
3187
|
-
for (const
|
|
3188
|
-
const m =
|
|
3189
|
-
|
|
3209
|
+
const d = V(() => i.value.filter(S)), y = V(() => {
|
|
3210
|
+
const c = /* @__PURE__ */ new Map(), g = [];
|
|
3211
|
+
for (const h of d.value) {
|
|
3212
|
+
const m = h.group ?? "default";
|
|
3213
|
+
c.has(m) || (c.set(m, []), g.push(m)), c.get(m).push(h);
|
|
3190
3214
|
}
|
|
3191
|
-
return g.map((
|
|
3215
|
+
return g.map((h) => ({ name: h, items: c.get(h) })).filter((h) => h.items.length > 0);
|
|
3192
3216
|
});
|
|
3193
|
-
return (
|
|
3194
|
-
(A(!0),
|
|
3195
|
-
key:
|
|
3217
|
+
return (c, g) => (A(), T("div", Go, [
|
|
3218
|
+
(A(!0), T(de, null, Ce(y.value, (h, m) => (A(), T(de, {
|
|
3219
|
+
key: h.name
|
|
3196
3220
|
}, [
|
|
3197
|
-
m > 0 ? (A(),
|
|
3221
|
+
m > 0 ? (A(), T("div", zo)) : Y("", !0),
|
|
3198
3222
|
q("div", Uo, [
|
|
3199
|
-
(A(!0),
|
|
3223
|
+
(A(!0), T(de, null, Ce(h.items, (E) => (A(), T(de, {
|
|
3200
3224
|
key: E.id
|
|
3201
3225
|
}, [
|
|
3202
|
-
E.type === "zoom-display" ? (A(),
|
|
3226
|
+
E.type === "zoom-display" ? (A(), T("span", jo, ce(O.value), 1)) : (A(), T("button", {
|
|
3203
3227
|
key: 1,
|
|
3204
3228
|
type: "button",
|
|
3205
|
-
class:
|
|
3229
|
+
class: te(["flow-canvas-toolbar__btn", {
|
|
3206
3230
|
"is-disabled": k(E),
|
|
3207
|
-
"is-active":
|
|
3208
|
-
"is-exporting": E.type === "export" &&
|
|
3231
|
+
"is-active": j(E),
|
|
3232
|
+
"is-exporting": E.type === "export" && f.value
|
|
3209
3233
|
}]),
|
|
3210
3234
|
"data-toolbar-id": E.id,
|
|
3211
3235
|
"data-toolbar-type": E.type,
|
|
3212
3236
|
disabled: k(E),
|
|
3213
|
-
onClick: (
|
|
3214
|
-
onMouseenter: (
|
|
3215
|
-
onMouseleave:
|
|
3237
|
+
onClick: (L) => G(E),
|
|
3238
|
+
onMouseenter: (L) => w(L, E),
|
|
3239
|
+
onMouseleave: D
|
|
3216
3240
|
}, [
|
|
3217
|
-
E.component ? (A(), Ie(mt(E.component), { key: 0 })) : E.icon ? (A(),
|
|
3241
|
+
E.component ? (A(), Ie(mt(E.component), { key: 0 })) : E.icon ? (A(), T("i", {
|
|
3218
3242
|
key: 1,
|
|
3219
|
-
class:
|
|
3220
|
-
}, null, 2)) : (A(),
|
|
3243
|
+
class: te(E.icon)
|
|
3244
|
+
}, null, 2)) : (A(), T("span", {
|
|
3221
3245
|
key: 2,
|
|
3222
3246
|
class: "flow-canvas-toolbar__text",
|
|
3223
3247
|
textContent: ce(E.text ?? E.description ?? E.id)
|
|
@@ -3227,16 +3251,16 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3227
3251
|
])
|
|
3228
3252
|
], 64))), 128)),
|
|
3229
3253
|
(A(), Ie(yt, { to: "body" }, [
|
|
3230
|
-
|
|
3254
|
+
u.visible ? (A(), T("div", {
|
|
3231
3255
|
key: 0,
|
|
3232
3256
|
ref_key: "tooltipRef",
|
|
3233
3257
|
ref: a,
|
|
3234
3258
|
class: "flow-canvas-toolbar-tooltip",
|
|
3235
|
-
style:
|
|
3259
|
+
style: Ee({ left: `${u.x}px`, top: `${u.y}px` })
|
|
3236
3260
|
}, [
|
|
3237
|
-
q("span", null, ce(
|
|
3238
|
-
|
|
3239
|
-
(A(!0),
|
|
3261
|
+
q("span", null, ce(u.text), 1),
|
|
3262
|
+
u.shortcut.length ? (A(), T("kbd", Xo, [
|
|
3263
|
+
(A(!0), T(de, null, Ce(u.shortcut, (h, m) => (A(), T("span", { key: m }, ce(h), 1))), 128))
|
|
3240
3264
|
])) : Y("", !0),
|
|
3241
3265
|
g[0] || (g[0] = q("div", { class: "flow-canvas-toolbar-tooltip__arrow" }, null, -1))
|
|
3242
3266
|
], 4)) : Y("", !0)
|
|
@@ -3265,24 +3289,24 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3265
3289
|
"converge-gateway",
|
|
3266
3290
|
"conditional-parallel-gateway"
|
|
3267
3291
|
]), a = V(() => {
|
|
3268
|
-
const
|
|
3269
|
-
return i.has(
|
|
3292
|
+
const f = t.value?.type ?? "";
|
|
3293
|
+
return i.has(f) ? "endpoint" : l.has(f) ? "gateway" : "task";
|
|
3270
3294
|
}), v = V(() => r[t.value?.type ?? ""] ?? "");
|
|
3271
|
-
return (
|
|
3272
|
-
class:
|
|
3295
|
+
return (f, p) => (A(), T("div", {
|
|
3296
|
+
class: te(["flow-canvas-default-node", [`is-${a.value}`, { "flow-canvas-highlight-target": a.value !== "gateway" }]])
|
|
3273
3297
|
}, [
|
|
3274
|
-
a.value === "endpoint" ? (A(),
|
|
3275
|
-
v.value ? (A(),
|
|
3298
|
+
a.value === "endpoint" ? (A(), T(de, { key: 0 }, [
|
|
3299
|
+
v.value ? (A(), T("i", {
|
|
3276
3300
|
key: 0,
|
|
3277
|
-
class:
|
|
3301
|
+
class: te([["flow-canvas-icon", v.value], "flow-canvas-default-node__ep-icon"])
|
|
3278
3302
|
}, null, 2)) : Y("", !0),
|
|
3279
3303
|
q("span", Yo, ce(s.value), 1)
|
|
3280
|
-
], 64)) : a.value === "gateway" ? (A(),
|
|
3281
|
-
v.value ? (A(),
|
|
3304
|
+
], 64)) : a.value === "gateway" ? (A(), T("div", Zo, [
|
|
3305
|
+
v.value ? (A(), T("i", {
|
|
3282
3306
|
key: 0,
|
|
3283
|
-
class:
|
|
3307
|
+
class: te([["flow-canvas-icon", v.value], "flow-canvas-default-node__gw-icon"])
|
|
3284
3308
|
}, null, 2)) : Y("", !0)
|
|
3285
|
-
])) : (A(),
|
|
3309
|
+
])) : (A(), T("span", Qo, ce(s.value), 1))
|
|
3286
3310
|
], 2));
|
|
3287
3311
|
}
|
|
3288
3312
|
}), en = /* @__PURE__ */ ve(Jo, [["__scopeId", "data-v-f0e24a9f"]]), tn = {
|
|
@@ -3298,11 +3322,11 @@ const Go = { class: "flow-canvas-toolbar" }, zo = {
|
|
|
3298
3322
|
width: 64,
|
|
3299
3323
|
height: 64
|
|
3300
3324
|
}
|
|
3301
|
-
},
|
|
3325
|
+
}, tt = (n, e) => ({
|
|
3302
3326
|
stroke: e.hovered ? "#3a84ff" : "#abb5cc",
|
|
3303
3327
|
strokeWidth: 2
|
|
3304
3328
|
});
|
|
3305
|
-
function
|
|
3329
|
+
function ot() {
|
|
3306
3330
|
return {
|
|
3307
3331
|
attrs: {
|
|
3308
3332
|
line: {
|
|
@@ -3318,13 +3342,13 @@ function on() {
|
|
|
3318
3342
|
manhattan: {
|
|
3319
3343
|
router: { name: "manhattan", args: { padding: 10, maxDirectionChange: 90 } },
|
|
3320
3344
|
connector: { name: "rounded", args: { radius: 8 } },
|
|
3321
|
-
style:
|
|
3322
|
-
x6EdgeConfig:
|
|
3345
|
+
style: tt,
|
|
3346
|
+
x6EdgeConfig: ot()
|
|
3323
3347
|
},
|
|
3324
3348
|
bezier: {
|
|
3325
3349
|
connector: { name: "smooth" },
|
|
3326
|
-
style:
|
|
3327
|
-
x6EdgeConfig:
|
|
3350
|
+
style: tt,
|
|
3351
|
+
x6EdgeConfig: ot()
|
|
3328
3352
|
}
|
|
3329
3353
|
};
|
|
3330
3354
|
}
|
|
@@ -3363,22 +3387,22 @@ function Tn(n) {
|
|
|
3363
3387
|
if (r.type !== "edge.add" && r.type !== "edge.reconnect") continue;
|
|
3364
3388
|
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;
|
|
3365
3389
|
if (!l || !a) continue;
|
|
3366
|
-
const v = i.nodes[l],
|
|
3367
|
-
if (!v || !
|
|
3368
|
-
const
|
|
3369
|
-
(
|
|
3370
|
-
),
|
|
3390
|
+
const v = i.nodes[l], f = i.nodes[a];
|
|
3391
|
+
if (!v || !f) continue;
|
|
3392
|
+
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 ? v.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(
|
|
3393
|
+
(M) => M.id !== O && !s.has(M.id)
|
|
3394
|
+
), S = n({
|
|
3371
3395
|
flowModel: i,
|
|
3372
3396
|
sourceNode: v,
|
|
3373
|
-
targetNode:
|
|
3397
|
+
targetNode: f,
|
|
3374
3398
|
sourcePort: w,
|
|
3375
|
-
targetPort:
|
|
3399
|
+
targetPort: D,
|
|
3376
3400
|
existingEdges: b
|
|
3377
3401
|
});
|
|
3378
|
-
if (!
|
|
3402
|
+
if (!S.valid)
|
|
3379
3403
|
return {
|
|
3380
3404
|
rejected: !0,
|
|
3381
|
-
reason:
|
|
3405
|
+
reason: S.reason ?? "Connection validation failed",
|
|
3382
3406
|
code: "validation_failed"
|
|
3383
3407
|
};
|
|
3384
3408
|
}
|
|
@@ -3386,7 +3410,7 @@ function Tn(n) {
|
|
|
3386
3410
|
}
|
|
3387
3411
|
};
|
|
3388
3412
|
}
|
|
3389
|
-
function
|
|
3413
|
+
function Rn(n) {
|
|
3390
3414
|
const { rubberband: e = !0, multiple: o = !0, movable: t = !0 } = n ?? {};
|
|
3391
3415
|
return {
|
|
3392
3416
|
name: "selection",
|
|
@@ -3406,7 +3430,7 @@ function Ln(n) {
|
|
|
3406
3430
|
}
|
|
3407
3431
|
};
|
|
3408
3432
|
}
|
|
3409
|
-
function
|
|
3433
|
+
function Ln(n) {
|
|
3410
3434
|
const { tolerance: e = 10, color: o = "#3a84ff" } = n ?? {};
|
|
3411
3435
|
let t = null;
|
|
3412
3436
|
return {
|
|
@@ -3443,11 +3467,11 @@ const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "p
|
|
|
3443
3467
|
},
|
|
3444
3468
|
emits: ["update:query", "select", "nextMatch", "prevMatch", "close"],
|
|
3445
3469
|
setup(n, { emit: e }) {
|
|
3446
|
-
const o = n, t = e, s =
|
|
3470
|
+
const o = n, t = e, s = H(null), r = H(null), i = H(-1);
|
|
3447
3471
|
ge(
|
|
3448
3472
|
() => o.open,
|
|
3449
|
-
(
|
|
3450
|
-
|
|
3473
|
+
(u) => {
|
|
3474
|
+
u && (i.value = -1, Ge(() => {
|
|
3451
3475
|
s.value?.focus(), s.value?.select();
|
|
3452
3476
|
}));
|
|
3453
3477
|
}
|
|
@@ -3458,62 +3482,62 @@ const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "p
|
|
|
3458
3482
|
}
|
|
3459
3483
|
), ge(
|
|
3460
3484
|
() => o.results.length,
|
|
3461
|
-
(
|
|
3462
|
-
if (!
|
|
3485
|
+
(u) => {
|
|
3486
|
+
if (!u) {
|
|
3463
3487
|
i.value = -1;
|
|
3464
3488
|
return;
|
|
3465
3489
|
}
|
|
3466
|
-
i.value >=
|
|
3490
|
+
i.value >= u && (i.value = -1);
|
|
3467
3491
|
}
|
|
3468
3492
|
);
|
|
3469
|
-
function l(
|
|
3470
|
-
t("update:query",
|
|
3493
|
+
function l(u) {
|
|
3494
|
+
t("update:query", u.target.value);
|
|
3471
3495
|
}
|
|
3472
|
-
function a(
|
|
3473
|
-
i.value =
|
|
3496
|
+
function a(u) {
|
|
3497
|
+
i.value = u;
|
|
3474
3498
|
}
|
|
3475
3499
|
function v() {
|
|
3476
3500
|
i.value = -1;
|
|
3477
3501
|
}
|
|
3478
|
-
function u
|
|
3479
|
-
if (
|
|
3480
|
-
|
|
3502
|
+
function f(u) {
|
|
3503
|
+
if (u.key === "Escape") {
|
|
3504
|
+
u.preventDefault(), t("close");
|
|
3481
3505
|
return;
|
|
3482
3506
|
}
|
|
3483
|
-
if (
|
|
3484
|
-
if (
|
|
3507
|
+
if (u.key === "ArrowDown") {
|
|
3508
|
+
if (u.preventDefault(), !o.results.length) return;
|
|
3485
3509
|
i.value = i.value < o.results.length - 1 ? i.value + 1 : 0;
|
|
3486
3510
|
return;
|
|
3487
3511
|
}
|
|
3488
|
-
if (
|
|
3489
|
-
if (
|
|
3512
|
+
if (u.key === "ArrowUp") {
|
|
3513
|
+
if (u.preventDefault(), !o.results.length) return;
|
|
3490
3514
|
i.value = i.value > 0 ? i.value - 1 : o.results.length - 1;
|
|
3491
3515
|
return;
|
|
3492
3516
|
}
|
|
3493
|
-
if (
|
|
3494
|
-
if (
|
|
3517
|
+
if (u.key === "Enter") {
|
|
3518
|
+
if (u.preventDefault(), i.value >= 0) {
|
|
3495
3519
|
const w = o.results[i.value];
|
|
3496
3520
|
w && t("select", w.id);
|
|
3497
3521
|
return;
|
|
3498
3522
|
}
|
|
3499
|
-
|
|
3523
|
+
u.shiftKey ? t("prevMatch") : t("nextMatch");
|
|
3500
3524
|
}
|
|
3501
3525
|
}
|
|
3502
|
-
function
|
|
3526
|
+
function p(u) {
|
|
3503
3527
|
if (!o.open) return;
|
|
3504
|
-
const w =
|
|
3505
|
-
w && r.value?.contains(w) || o.isAnchorTarget?.(
|
|
3528
|
+
const w = u.target;
|
|
3529
|
+
w && r.value?.contains(w) || o.isAnchorTarget?.(u.target) || t("close");
|
|
3506
3530
|
}
|
|
3507
|
-
return
|
|
3508
|
-
document.addEventListener("mousedown",
|
|
3531
|
+
return dt(() => {
|
|
3532
|
+
document.addEventListener("mousedown", p);
|
|
3509
3533
|
}), Te(() => {
|
|
3510
|
-
document.removeEventListener("mousedown",
|
|
3511
|
-
}), (
|
|
3534
|
+
document.removeEventListener("mousedown", p);
|
|
3535
|
+
}), (u, w) => n.open ? (A(), T("div", {
|
|
3512
3536
|
key: 0,
|
|
3513
3537
|
ref_key: "panelRef",
|
|
3514
3538
|
ref: r,
|
|
3515
3539
|
class: "flow-canvas-search-popover",
|
|
3516
|
-
style:
|
|
3540
|
+
style: Ee({ left: `${n.position.x}px`, top: `${n.position.y}px`, width: `${n.position.width}px` })
|
|
3517
3541
|
}, [
|
|
3518
3542
|
q("div", nn, [
|
|
3519
3543
|
q("input", {
|
|
@@ -3522,15 +3546,15 @@ const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "p
|
|
|
3522
3546
|
value: n.query,
|
|
3523
3547
|
placeholder: n.placeholder,
|
|
3524
3548
|
onInput: l,
|
|
3525
|
-
onKeydown:
|
|
3549
|
+
onKeydown: f
|
|
3526
3550
|
}, null, 40, sn),
|
|
3527
|
-
n.query ? (A(),
|
|
3528
|
-
n.results.length ? (A(),
|
|
3551
|
+
n.query ? (A(), T(de, { key: 0 }, [
|
|
3552
|
+
n.results.length ? (A(), T(de, { key: 1 }, [
|
|
3529
3553
|
q("button", {
|
|
3530
3554
|
type: "button",
|
|
3531
3555
|
class: "flow-canvas-search-popover__nav-btn",
|
|
3532
3556
|
"aria-label": "上一个",
|
|
3533
|
-
onClick: w[0] || (w[0] = (
|
|
3557
|
+
onClick: w[0] || (w[0] = (D) => t("prevMatch"))
|
|
3534
3558
|
}, [...w[2] || (w[2] = [
|
|
3535
3559
|
q("svg", {
|
|
3536
3560
|
viewBox: "0 0 16 16",
|
|
@@ -3552,7 +3576,7 @@ const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "p
|
|
|
3552
3576
|
type: "button",
|
|
3553
3577
|
class: "flow-canvas-search-popover__nav-btn",
|
|
3554
3578
|
"aria-label": "下一个",
|
|
3555
|
-
onClick: w[1] || (w[1] = (
|
|
3579
|
+
onClick: w[1] || (w[1] = (D) => t("nextMatch"))
|
|
3556
3580
|
}, [...w[3] || (w[3] = [
|
|
3557
3581
|
q("svg", {
|
|
3558
3582
|
viewBox: "0 0 16 16",
|
|
@@ -3569,29 +3593,29 @@ const nn = { class: "flow-canvas-search-popover__input-box" }, sn = ["value", "p
|
|
|
3569
3593
|
})
|
|
3570
3594
|
], -1)
|
|
3571
3595
|
])])
|
|
3572
|
-
], 64)) : (A(),
|
|
3596
|
+
], 64)) : (A(), T("span", rn, "无结果"))
|
|
3573
3597
|
], 64)) : Y("", !0),
|
|
3574
3598
|
w[4] || (w[4] = q("i", { class: "flow-canvas-icon canvas-search flow-canvas-search-popover__search-icon" }, null, -1))
|
|
3575
3599
|
]),
|
|
3576
|
-
n.query && n.results.length ? (A(),
|
|
3600
|
+
n.query && n.results.length ? (A(), T("div", {
|
|
3577
3601
|
key: 0,
|
|
3578
3602
|
class: "flow-canvas-search-popover__list-box",
|
|
3579
3603
|
onMouseleave: v
|
|
3580
3604
|
}, [
|
|
3581
|
-
(A(!0),
|
|
3582
|
-
key:
|
|
3605
|
+
(A(!0), T(de, null, Ce(n.results, (D, O) => (A(), T("button", {
|
|
3606
|
+
key: D.id,
|
|
3583
3607
|
type: "button",
|
|
3584
|
-
class:
|
|
3608
|
+
class: te(["flow-canvas-search-popover__item", { "is-active": O === i.value, "is-matched": O === n.matchIndex }]),
|
|
3585
3609
|
onMouseenter: (b) => a(O),
|
|
3586
|
-
onClick: (b) => t("select",
|
|
3610
|
+
onClick: (b) => t("select", D.id)
|
|
3587
3611
|
}, [
|
|
3588
|
-
q("span", dn, ce(
|
|
3612
|
+
q("span", dn, ce(D.label), 1)
|
|
3589
3613
|
], 42, ln))), 128))
|
|
3590
3614
|
], 32)) : Y("", !0)
|
|
3591
3615
|
], 4)) : Y("", !0);
|
|
3592
3616
|
}
|
|
3593
|
-
}), un = /* @__PURE__ */ ve(cn, [["__scopeId", "data-v-aca2b1c1"]]),
|
|
3594
|
-
function
|
|
3617
|
+
}), un = /* @__PURE__ */ ve(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";
|
|
3618
|
+
function hn(n) {
|
|
3595
3619
|
return n !== null;
|
|
3596
3620
|
}
|
|
3597
3621
|
function vn(n) {
|
|
@@ -3618,20 +3642,20 @@ function yn(n, e) {
|
|
|
3618
3642
|
}
|
|
3619
3643
|
function On(n) {
|
|
3620
3644
|
let e = null, o = null, t = null, s = null, r = null, i = null;
|
|
3621
|
-
const l =
|
|
3622
|
-
const g = a.value.trim().toLowerCase(),
|
|
3623
|
-
return g ?
|
|
3645
|
+
const l = H(!1), a = H(""), v = 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(() => {
|
|
3646
|
+
const g = a.value.trim().toLowerCase(), h = Math.max(1, n?.maxResults ?? gn);
|
|
3647
|
+
return g ? p.value.filter((m) => m.keywords.some((E) => E.toLowerCase().includes(g))).slice(0, h) : p.value.slice(0, h);
|
|
3624
3648
|
});
|
|
3625
3649
|
function w() {
|
|
3626
3650
|
return t?.querySelector('.flow-canvas-toolbar__btn[data-toolbar-type="search"]');
|
|
3627
3651
|
}
|
|
3628
|
-
function
|
|
3652
|
+
function D() {
|
|
3629
3653
|
return w()?.closest(".flow-canvas-toolbar");
|
|
3630
3654
|
}
|
|
3631
3655
|
function O() {
|
|
3632
|
-
const g =
|
|
3656
|
+
const g = D(), h = t?.getBoundingClientRect(), m = g?.getBoundingClientRect() ?? h;
|
|
3633
3657
|
if (!m) return;
|
|
3634
|
-
const E = Math.max(
|
|
3658
|
+
const E = Math.max(nt, Math.round(m.width));
|
|
3635
3659
|
v.value = {
|
|
3636
3660
|
x: mn(m.left, E),
|
|
3637
3661
|
y: m.bottom + fn,
|
|
@@ -3640,87 +3664,87 @@ function On(n) {
|
|
|
3640
3664
|
}
|
|
3641
3665
|
function b(g) {
|
|
3642
3666
|
if (!o) return null;
|
|
3643
|
-
const
|
|
3644
|
-
if (!
|
|
3645
|
-
const m = o.graph.findViewByCell(
|
|
3667
|
+
const h = o.graph.getCellById(g);
|
|
3668
|
+
if (!h?.isNode()) return null;
|
|
3669
|
+
const m = o.graph.findViewByCell(h)?.container;
|
|
3646
3670
|
return m ? m.querySelector(".flow-canvas-highlight-target") ?? m.querySelector(".flow-canvas-node-surface > :first-child") : null;
|
|
3647
3671
|
}
|
|
3648
|
-
function
|
|
3672
|
+
function S() {
|
|
3649
3673
|
if (!o) return;
|
|
3650
3674
|
const g = o.graph.getNodes();
|
|
3651
|
-
for (const
|
|
3652
|
-
const m = b(
|
|
3675
|
+
for (const h of g) {
|
|
3676
|
+
const m = b(h.id);
|
|
3653
3677
|
m && m.classList.remove(_e, Pe);
|
|
3654
3678
|
}
|
|
3655
3679
|
}
|
|
3656
|
-
function
|
|
3680
|
+
function M() {
|
|
3657
3681
|
if (!o) return;
|
|
3658
3682
|
const g = a.value.trim().toLowerCase();
|
|
3659
3683
|
if (!l.value || !g) {
|
|
3660
|
-
|
|
3684
|
+
S();
|
|
3661
3685
|
return;
|
|
3662
3686
|
}
|
|
3663
|
-
const
|
|
3664
|
-
for (const
|
|
3665
|
-
const
|
|
3666
|
-
|
|
3687
|
+
const h = new Set(u.value.map((L) => L.id)), m = f.value >= 0 ? u.value[f.value]?.id : null, E = o.graph.getNodes();
|
|
3688
|
+
for (const L of E) {
|
|
3689
|
+
const z = b(L.id);
|
|
3690
|
+
z && (z.classList.add(pn), L.id === m ? (z.classList.remove(_e), z.classList.add(Pe)) : h.has(L.id) ? (z.classList.remove(Pe), z.classList.add(_e)) : z.classList.remove(_e, Pe));
|
|
3667
3691
|
}
|
|
3668
3692
|
}
|
|
3669
|
-
function
|
|
3693
|
+
function B(g) {
|
|
3670
3694
|
if (!o) return;
|
|
3671
|
-
const
|
|
3672
|
-
|
|
3695
|
+
const h = u.value.findIndex((m) => m.id === g);
|
|
3696
|
+
h >= 0 && (f.value = h), o.api.scrollToNode(g), M();
|
|
3673
3697
|
}
|
|
3674
|
-
function
|
|
3675
|
-
const g =
|
|
3698
|
+
function j() {
|
|
3699
|
+
const g = u.value;
|
|
3676
3700
|
if (g.length === 0) return;
|
|
3677
|
-
const
|
|
3678
|
-
|
|
3701
|
+
const h = f.value < g.length - 1 ? f.value + 1 : 0;
|
|
3702
|
+
f.value = h, B(g[h].id);
|
|
3679
3703
|
}
|
|
3680
3704
|
function k() {
|
|
3681
|
-
const g =
|
|
3705
|
+
const g = u.value;
|
|
3682
3706
|
if (g.length === 0) return;
|
|
3683
|
-
const
|
|
3684
|
-
|
|
3707
|
+
const h = f.value > 0 ? f.value - 1 : g.length - 1;
|
|
3708
|
+
f.value = h, B(g[h].id);
|
|
3685
3709
|
}
|
|
3686
|
-
function
|
|
3710
|
+
function X() {
|
|
3687
3711
|
o && (l.value = !0, O(), requestAnimationFrame(() => O()));
|
|
3688
3712
|
}
|
|
3689
|
-
function
|
|
3690
|
-
l.value = !1, a.value = "",
|
|
3713
|
+
function U() {
|
|
3714
|
+
l.value = !1, a.value = "", f.value = -1, S();
|
|
3691
3715
|
}
|
|
3692
|
-
function
|
|
3716
|
+
function G() {
|
|
3693
3717
|
if (l.value) {
|
|
3694
|
-
|
|
3718
|
+
U();
|
|
3695
3719
|
return;
|
|
3696
3720
|
}
|
|
3697
|
-
|
|
3721
|
+
X();
|
|
3698
3722
|
}
|
|
3699
|
-
function
|
|
3700
|
-
const
|
|
3701
|
-
return !!(
|
|
3723
|
+
function d(g) {
|
|
3724
|
+
const h = w();
|
|
3725
|
+
return !!(h && g instanceof Node && h.contains(g));
|
|
3702
3726
|
}
|
|
3703
3727
|
function y() {
|
|
3704
3728
|
l.value && O();
|
|
3705
3729
|
}
|
|
3706
|
-
const
|
|
3730
|
+
const c = fe({
|
|
3707
3731
|
name: "FlowCanvasSearchHost",
|
|
3708
3732
|
setup() {
|
|
3709
3733
|
return () => qe(un, {
|
|
3710
3734
|
open: l.value,
|
|
3711
3735
|
position: v.value,
|
|
3712
3736
|
query: a.value,
|
|
3713
|
-
results:
|
|
3714
|
-
matchIndex:
|
|
3737
|
+
results: u.value,
|
|
3738
|
+
matchIndex: f.value,
|
|
3715
3739
|
placeholder: n?.placeholder ?? "搜索节点名称",
|
|
3716
|
-
isAnchorTarget:
|
|
3740
|
+
isAnchorTarget: d,
|
|
3717
3741
|
"onUpdate:query": (g) => {
|
|
3718
|
-
a.value = g,
|
|
3742
|
+
a.value = g, f.value = -1;
|
|
3719
3743
|
},
|
|
3720
|
-
onSelect:
|
|
3721
|
-
onNextMatch:
|
|
3744
|
+
onSelect: B,
|
|
3745
|
+
onNextMatch: j,
|
|
3722
3746
|
onPrevMatch: k,
|
|
3723
|
-
onClose:
|
|
3747
|
+
onClose: U
|
|
3724
3748
|
});
|
|
3725
3749
|
}
|
|
3726
3750
|
});
|
|
@@ -3731,18 +3755,18 @@ function On(n) {
|
|
|
3731
3755
|
e = g;
|
|
3732
3756
|
},
|
|
3733
3757
|
attachRuntime(g) {
|
|
3734
|
-
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(
|
|
3735
|
-
() => [a.value,
|
|
3758
|
+
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 = ge(
|
|
3759
|
+
() => [a.value, u.value.length],
|
|
3736
3760
|
() => {
|
|
3737
|
-
|
|
3761
|
+
f.value = -1, M();
|
|
3738
3762
|
}
|
|
3739
3763
|
), window.addEventListener("resize", y), window.addEventListener("scroll", y, !0);
|
|
3740
3764
|
},
|
|
3741
3765
|
detachRuntime() {
|
|
3742
|
-
|
|
3766
|
+
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;
|
|
3743
3767
|
},
|
|
3744
3768
|
dispose() {
|
|
3745
|
-
|
|
3769
|
+
U(), i?.(), i = null, e = null;
|
|
3746
3770
|
},
|
|
3747
3771
|
provideToolbarItems() {
|
|
3748
3772
|
return [
|
|
@@ -3754,15 +3778,15 @@ function On(n) {
|
|
|
3754
3778
|
group: "tools",
|
|
3755
3779
|
order: 22,
|
|
3756
3780
|
active: () => l.value,
|
|
3757
|
-
onClick:
|
|
3781
|
+
onClick: G
|
|
3758
3782
|
}
|
|
3759
3783
|
];
|
|
3760
3784
|
}
|
|
3761
3785
|
};
|
|
3762
3786
|
}
|
|
3763
|
-
const
|
|
3787
|
+
const st = 52, rt = 16, pt = 4, wn = 40;
|
|
3764
3788
|
function bn(n) {
|
|
3765
|
-
const { mountRect: e, toolbarRect: o, fallbackLeft: t, fallbackTop: s, fallbackWidth: r, height: i } = n, l = n.offset ??
|
|
3789
|
+
const { mountRect: e, toolbarRect: o, fallbackLeft: t, fallbackTop: s, fallbackWidth: r, height: i } = n, l = n.offset ?? pt;
|
|
3766
3790
|
return !o || o.width <= 0 ? {
|
|
3767
3791
|
left: t,
|
|
3768
3792
|
top: s,
|
|
@@ -3783,28 +3807,28 @@ function En(n) {
|
|
|
3783
3807
|
width: `${n.width}px`,
|
|
3784
3808
|
height: `${n.height}px`
|
|
3785
3809
|
}), n.floating !== !1 && Object.assign(e.style, {
|
|
3786
|
-
top: `${
|
|
3787
|
-
left: `${
|
|
3810
|
+
top: `${st}px`,
|
|
3811
|
+
left: `${rt}px`
|
|
3788
3812
|
});
|
|
3789
3813
|
let t = null, s = n.defaultOpen ?? !1, r = null, i = null, l = null, a = null, v = {
|
|
3790
3814
|
width: n.width,
|
|
3791
3815
|
height: n.height
|
|
3792
3816
|
};
|
|
3793
|
-
function
|
|
3817
|
+
function f(k, X) {
|
|
3794
3818
|
if (!t) return;
|
|
3795
|
-
const
|
|
3796
|
-
|
|
3819
|
+
const U = t;
|
|
3820
|
+
U.options.width = k, U.options.height = X, U.updatePaper(n.sourceGraph.container.clientWidth, n.sourceGraph.container.clientHeight);
|
|
3797
3821
|
}
|
|
3798
|
-
function
|
|
3822
|
+
function p() {
|
|
3799
3823
|
if (n.floating === !1) return;
|
|
3800
3824
|
const k = bn({
|
|
3801
3825
|
mountRect: n.mountTarget.getBoundingClientRect(),
|
|
3802
3826
|
toolbarRect: n.getToolbarElement?.()?.getBoundingClientRect() ?? null,
|
|
3803
|
-
fallbackLeft:
|
|
3804
|
-
fallbackTop:
|
|
3827
|
+
fallbackLeft: rt,
|
|
3828
|
+
fallbackTop: st,
|
|
3805
3829
|
fallbackWidth: n.width,
|
|
3806
3830
|
height: n.height,
|
|
3807
|
-
offset: n.panelOffset ??
|
|
3831
|
+
offset: n.panelOffset ?? pt
|
|
3808
3832
|
});
|
|
3809
3833
|
v = {
|
|
3810
3834
|
width: k.width,
|
|
@@ -3814,33 +3838,33 @@ function En(n) {
|
|
|
3814
3838
|
top: `${k.top}px`,
|
|
3815
3839
|
width: `${k.width}px`,
|
|
3816
3840
|
height: `${k.height}px`
|
|
3817
|
-
}),
|
|
3841
|
+
}), f(k.width, k.height);
|
|
3818
3842
|
}
|
|
3819
|
-
function
|
|
3843
|
+
function u() {
|
|
3820
3844
|
if (n.floating === !1 || typeof ResizeObserver > "u") return;
|
|
3821
3845
|
const k = n.getToolbarElement?.() ?? null;
|
|
3822
3846
|
i || (i = new ResizeObserver(() => {
|
|
3823
|
-
s && (
|
|
3847
|
+
s && (u(), p());
|
|
3824
3848
|
})), a !== k && (i.disconnect(), i.observe(n.mountTarget), k && i.observe(k), a = k);
|
|
3825
3849
|
}
|
|
3826
3850
|
function w() {
|
|
3827
|
-
n.floating !== !1 && (
|
|
3828
|
-
s && (
|
|
3851
|
+
n.floating !== !1 && (p(), u(), l || (l = () => {
|
|
3852
|
+
s && (u(), p());
|
|
3829
3853
|
}, window.addEventListener("resize", l)));
|
|
3830
3854
|
}
|
|
3831
|
-
function
|
|
3855
|
+
function D() {
|
|
3832
3856
|
l && (window.removeEventListener("resize", l), l = null), i?.disconnect(), i = null, a = null;
|
|
3833
3857
|
}
|
|
3834
3858
|
function O() {
|
|
3835
3859
|
!n.onClickOutside || r || (r = (k) => {
|
|
3836
|
-
const
|
|
3837
|
-
|
|
3860
|
+
const X = k.target;
|
|
3861
|
+
X && e.contains(X) || k.target?.closest('[data-toolbar-type="minimap"]') || k.target?.closest(".flow-canvas-layout__content") || n.onClickOutside();
|
|
3838
3862
|
}, document.addEventListener("mousedown", r));
|
|
3839
3863
|
}
|
|
3840
3864
|
function b() {
|
|
3841
3865
|
r && (document.removeEventListener("mousedown", r), r = null);
|
|
3842
3866
|
}
|
|
3843
|
-
function
|
|
3867
|
+
function S() {
|
|
3844
3868
|
t || (t = new Ct({
|
|
3845
3869
|
container: o,
|
|
3846
3870
|
width: v.width,
|
|
@@ -3849,31 +3873,31 @@ function En(n) {
|
|
|
3849
3873
|
scalable: !1
|
|
3850
3874
|
}), n.sourceGraph.use(t));
|
|
3851
3875
|
}
|
|
3852
|
-
function
|
|
3853
|
-
s = k, e.style.display = s ? "" : "none", s ? (w(),
|
|
3854
|
-
s && (
|
|
3855
|
-
})) : (b(),
|
|
3876
|
+
function M(k) {
|
|
3877
|
+
s = k, e.style.display = s ? "" : "none", s ? (w(), S(), O(), requestAnimationFrame(() => {
|
|
3878
|
+
s && (u(), p());
|
|
3879
|
+
})) : (b(), D());
|
|
3856
3880
|
}
|
|
3857
|
-
function
|
|
3858
|
-
|
|
3881
|
+
function B() {
|
|
3882
|
+
M(s), n.mountTarget.appendChild(e);
|
|
3859
3883
|
}
|
|
3860
|
-
function
|
|
3861
|
-
b(),
|
|
3884
|
+
function j() {
|
|
3885
|
+
b(), D(), t?.dispose(), t = null, e.remove();
|
|
3862
3886
|
}
|
|
3863
|
-
return
|
|
3887
|
+
return B(), {
|
|
3864
3888
|
element: e,
|
|
3865
3889
|
isOpen: () => s,
|
|
3866
|
-
setOpen:
|
|
3890
|
+
setOpen: M,
|
|
3867
3891
|
toggle() {
|
|
3868
3892
|
const k = !s;
|
|
3869
|
-
return
|
|
3893
|
+
return M(k), k;
|
|
3870
3894
|
},
|
|
3871
|
-
destroy:
|
|
3895
|
+
destroy: j
|
|
3872
3896
|
};
|
|
3873
3897
|
}
|
|
3874
3898
|
function $n(n) {
|
|
3875
3899
|
let e = null, o = null;
|
|
3876
|
-
const t =
|
|
3900
|
+
const t = H(!1);
|
|
3877
3901
|
function s() {
|
|
3878
3902
|
return o?.querySelector('.flow-canvas-toolbar__btn[data-toolbar-type="minimap"]');
|
|
3879
3903
|
}
|
|
@@ -3890,14 +3914,14 @@ function $n(n) {
|
|
|
3890
3914
|
name: "minimap",
|
|
3891
3915
|
priority: 90,
|
|
3892
3916
|
attachRuntime(a) {
|
|
3893
|
-
const v = a,
|
|
3917
|
+
const v = a, f = n?.width ?? 334, p = n?.height ?? 180;
|
|
3894
3918
|
o = v.graph.container.closest(".flow-canvas-layout__content") ?? v.graph.container.parentElement;
|
|
3895
|
-
const
|
|
3896
|
-
|
|
3919
|
+
const u = n?.container ?? o;
|
|
3920
|
+
u && (e = En({
|
|
3897
3921
|
sourceGraph: a.graph,
|
|
3898
|
-
mountTarget:
|
|
3899
|
-
width:
|
|
3900
|
-
height:
|
|
3922
|
+
mountTarget: u,
|
|
3923
|
+
width: f,
|
|
3924
|
+
height: p,
|
|
3901
3925
|
floating: !n?.container,
|
|
3902
3926
|
defaultOpen: !1,
|
|
3903
3927
|
getToolbarElement: n?.container ? void 0 : r,
|
|
@@ -3933,10 +3957,10 @@ function Bn() {
|
|
|
3933
3957
|
if (s && o.key === "c") {
|
|
3934
3958
|
const r = t.graph.getSelectedCells?.() ?? [];
|
|
3935
3959
|
if (!r.length) return !1;
|
|
3936
|
-
const i = t.flowModel.value, l = new Set(r.filter((
|
|
3960
|
+
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);
|
|
3937
3961
|
if (!a.length) return !1;
|
|
3938
3962
|
const v = Object.values(i.edges).filter(
|
|
3939
|
-
(
|
|
3963
|
+
(f) => l.has(f.source.nodeId) && l.has(f.target.nodeId)
|
|
3940
3964
|
);
|
|
3941
3965
|
return n = { nodes: a, edges: v }, e = 0, !0;
|
|
3942
3966
|
}
|
|
@@ -3945,7 +3969,7 @@ function Bn() {
|
|
|
3945
3969
|
e++;
|
|
3946
3970
|
const r = e * 30, i = /* @__PURE__ */ new Map(), l = [];
|
|
3947
3971
|
for (const a of n.nodes) {
|
|
3948
|
-
const v = `${a.id}_cp${
|
|
3972
|
+
const v = `${a.id}_cp${J().slice(0, 6)}`;
|
|
3949
3973
|
i.set(a.id, v), l.push({
|
|
3950
3974
|
type: "node.add",
|
|
3951
3975
|
node: {
|
|
@@ -3961,21 +3985,21 @@ function Bn() {
|
|
|
3961
3985
|
});
|
|
3962
3986
|
}
|
|
3963
3987
|
for (const a of n.edges) {
|
|
3964
|
-
const v = i.get(a.source.nodeId),
|
|
3965
|
-
!v || !
|
|
3988
|
+
const v = i.get(a.source.nodeId), f = i.get(a.target.nodeId);
|
|
3989
|
+
!v || !f || l.push({
|
|
3966
3990
|
type: "edge.add",
|
|
3967
3991
|
edge: {
|
|
3968
3992
|
...a,
|
|
3969
|
-
id: `${a.id}_cp${
|
|
3993
|
+
id: `${a.id}_cp${J().slice(0, 6)}`,
|
|
3970
3994
|
source: { ...a.source, nodeId: v },
|
|
3971
|
-
target: { ...a.target, nodeId:
|
|
3972
|
-
labels: a.labels?.map((
|
|
3995
|
+
target: { ...a.target, nodeId: f },
|
|
3996
|
+
labels: a.labels?.map((p) => ({ ...p, id: `${p.id}_cp${J().slice(0, 6)}` })),
|
|
3973
3997
|
payload: a.payload ? { ...a.payload } : {}
|
|
3974
3998
|
}
|
|
3975
3999
|
});
|
|
3976
4000
|
}
|
|
3977
4001
|
return l.length && t.executeCommand({
|
|
3978
|
-
id:
|
|
4002
|
+
id: J(),
|
|
3979
4003
|
source: "user:keyboard",
|
|
3980
4004
|
label: "粘贴",
|
|
3981
4005
|
timestamp: Date.now(),
|
|
@@ -3989,7 +4013,7 @@ function Bn() {
|
|
|
3989
4013
|
export {
|
|
3990
4014
|
ue as CanvasConstraintError,
|
|
3991
4015
|
An as CanvasLayout,
|
|
3992
|
-
|
|
4016
|
+
Ro as CanvasNodePalette,
|
|
3993
4017
|
Dn as CanvasRuntime,
|
|
3994
4018
|
kt as CanvasSchemaError,
|
|
3995
4019
|
_n as CanvasToolbar,
|
|
@@ -4004,10 +4028,10 @@ export {
|
|
|
4004
4028
|
Pn as createDefaultSchema,
|
|
4005
4029
|
Ho as createDefaultToolbarItems,
|
|
4006
4030
|
Mn as createEmptyFlowModel,
|
|
4007
|
-
|
|
4031
|
+
J as generateId,
|
|
4008
4032
|
$n as minimapPlugin,
|
|
4009
4033
|
On as searchPlugin,
|
|
4010
|
-
|
|
4011
|
-
|
|
4034
|
+
Rn as selectionPlugin,
|
|
4035
|
+
Ln as snaplinePlugin,
|
|
4012
4036
|
Nn as useCanvasEditor
|
|
4013
4037
|
};
|