dishui 0.0.55 → 0.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/pro/Flow/Flow.js +410 -405
- package/dist/components/pro/Flow/Flow.js.map +1 -1
- package/dist/components/pro/Flow/context/FlowUIContext.d.ts +6 -1
- package/dist/components/pro/Flow/context/FlowUIContext.js +89 -81
- package/dist/components/pro/Flow/context/FlowUIContext.js.map +1 -1
- package/dist/utils/i18n.js +10 -0
- package/dist/utils/i18n.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DEFAULT_NODE_DATA as oe, ROOT_CANVAS_ID as
|
|
3
|
-
import { FlowProvider as
|
|
4
|
-
import { FlowUIProvider as
|
|
5
|
-
import { FlowAIProvider as
|
|
6
|
-
import { generateId as
|
|
7
|
-
import { normalizeEdgeHandles as
|
|
8
|
-
import
|
|
9
|
-
import { downloadDataURL as
|
|
10
|
-
import
|
|
11
|
-
import { MediaStampContent as
|
|
12
|
-
import { InspectorPanelContent as
|
|
13
|
-
import { OutlinePanelContent as
|
|
14
|
-
import { AIPanelContent as
|
|
15
|
-
import { PresentationMode as
|
|
16
|
-
import { MediaOverlay as
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { MiniMapRenderer as
|
|
21
|
-
import { useUndoRedo as
|
|
1
|
+
import he from "../CodeEditor/editors/CodeEditor.js";
|
|
2
|
+
import { DEFAULT_NODE_DATA as oe, ROOT_CANVAS_ID as pe, createEmptyDocument as me } from "./constants.js";
|
|
3
|
+
import { FlowProvider as ge, useFlowContext as ee } from "./context/FlowContext.js";
|
|
4
|
+
import { FlowUIProvider as we, useFlowUI as Y } from "./context/FlowUIContext.js";
|
|
5
|
+
import { FlowAIProvider as Ie } from "./context/FlowAIContext.js";
|
|
6
|
+
import { generateId as Q } from "./nodes/nodeUtils.js";
|
|
7
|
+
import { normalizeEdgeHandles as ve } from "./edges/edgePaths.js";
|
|
8
|
+
import ye from "./FlowCanvas.js";
|
|
9
|
+
import { downloadDataURL as xe, safeFileBaseName as be } from "./hooks/useFlowImportExport.js";
|
|
10
|
+
import Se, { FlowZoomControls as Ce } from "./panels/FlowToolbar.js";
|
|
11
|
+
import { MediaStampContent as Me, ShapePaletteContent as Pe, SvgStampContent as ze } from "./panels/ShapePalette.js";
|
|
12
|
+
import { InspectorPanelContent as Ee } from "./panels/InspectorPanel.js";
|
|
13
|
+
import { OutlinePanelContent as De } from "./panels/OutlinePanel.js";
|
|
14
|
+
import { AIPanelContent as Ae } from "./panels/AIPanel.js";
|
|
15
|
+
import { PresentationMode as Ne } from "./panels/PresentationMode.js";
|
|
16
|
+
import { MediaOverlay as Te } from "./nodes/MediaOverlay.js";
|
|
17
|
+
import q from "./panels/FlowPanelGroup.js";
|
|
18
|
+
import Re from "./panels/Breadcrumb.js";
|
|
19
|
+
import Le from "./panels/ContextMenu.js";
|
|
20
|
+
import { MiniMapRenderer as ke } from "./canvas/MiniMapRenderer.js";
|
|
21
|
+
import { useUndoRedo as Fe } from "./hooks/useUndoRedo.js";
|
|
22
22
|
import { useClipboard as re } from "./hooks/useClipboard.js";
|
|
23
|
-
import { usePdfExport as
|
|
24
|
-
import { useKeyboardShortcuts as
|
|
25
|
-
import { useMindMap as
|
|
23
|
+
import { usePdfExport as Ge } from "./hooks/usePdfExport.js";
|
|
24
|
+
import { useKeyboardShortcuts as We } from "./hooks/useKeyboardShortcuts.js";
|
|
25
|
+
import { useMindMap as Ke } from "./hooks/useMindMap.js";
|
|
26
26
|
/* empty css */
|
|
27
|
-
import { forwardRef as
|
|
28
|
-
import { jsx as h, jsxs as
|
|
29
|
-
import { EditorView as
|
|
30
|
-
function
|
|
27
|
+
import { forwardRef as Ue, useCallback as D, useEffect as $, useImperativeHandle as He, useMemo as ae, useRef as G, useState as j } from "react";
|
|
28
|
+
import { jsx as h, jsxs as X } from "react/jsx-runtime";
|
|
29
|
+
import { EditorView as Ze } from "@codemirror/view";
|
|
30
|
+
function Be(s) {
|
|
31
31
|
let p = !1;
|
|
32
|
-
const
|
|
33
|
-
for (const [
|
|
34
|
-
const
|
|
32
|
+
const l = { ...s.canvases };
|
|
33
|
+
for (const [w, i] of Object.entries(l)) {
|
|
34
|
+
const t = i.nodes.map((d) => {
|
|
35
35
|
if (d.type !== "shapeSvg") return d;
|
|
36
36
|
const o = d.data.labelPlacement, g = o === "above" ? "top" : o === "center" ? "middle" : o === "below" ? "bottom" : d.data.labelPlacement;
|
|
37
37
|
return g === d.data.labelPlacement ? d : (p = !0, {
|
|
@@ -42,238 +42,238 @@ function Ue(n) {
|
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
}), f = /* @__PURE__ */ new Map();
|
|
45
|
-
for (const d of
|
|
46
|
-
const e =
|
|
47
|
-
(
|
|
48
|
-
...
|
|
49
|
-
nodes:
|
|
45
|
+
for (const d of t) f.set(d.id, d);
|
|
46
|
+
const e = ve(i.edges, f);
|
|
47
|
+
(t !== i.nodes || e !== i.edges) && (l[w] = {
|
|
48
|
+
...i,
|
|
49
|
+
nodes: t,
|
|
50
50
|
edges: e
|
|
51
|
-
}, e !==
|
|
51
|
+
}, e !== i.edges && (p = !0));
|
|
52
52
|
}
|
|
53
53
|
return p ? {
|
|
54
|
-
...
|
|
55
|
-
canvases:
|
|
56
|
-
} :
|
|
54
|
+
...s,
|
|
55
|
+
canvases: l
|
|
56
|
+
} : s;
|
|
57
57
|
}
|
|
58
|
-
var
|
|
58
|
+
var ce = {
|
|
59
59
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
60
60
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
61
61
|
lineIds: /* @__PURE__ */ new Set()
|
|
62
62
|
};
|
|
63
|
-
function
|
|
64
|
-
const { selection:
|
|
65
|
-
const { nodeIds: c, edgeIds: m, lineIds: C } =
|
|
66
|
-
c.size === 0 && m.size === 0 && C.size === 0 || c.size > 1 && !window.confirm(`确定要删除选中的 ${c.size} 个节点吗?`) || (d((
|
|
67
|
-
const
|
|
68
|
-
return
|
|
69
|
-
...
|
|
63
|
+
function Je({ onUndo: s, onRedo: p, groupRef: l, geoGroupRef: w, ungroupRef: i }) {
|
|
64
|
+
const { selection: t, setSelection: f, currentCanvas: e, setDoc: d, currentCanvasId: o } = ee(), { viewport: g } = Y(), { copy: u, cut: M, paste: b, duplicate: n } = re(), v = D(() => {
|
|
65
|
+
const { nodeIds: c, edgeIds: m, lineIds: C } = t;
|
|
66
|
+
c.size === 0 && m.size === 0 && C.size === 0 || c.size > 1 && !window.confirm(`确定要删除选中的 ${c.size} 个节点吗?`) || (d((P) => {
|
|
67
|
+
const r = P.canvases[o];
|
|
68
|
+
return r ? {
|
|
69
|
+
...P,
|
|
70
70
|
canvases: {
|
|
71
|
-
...
|
|
71
|
+
...P.canvases,
|
|
72
72
|
[o]: {
|
|
73
|
-
...
|
|
74
|
-
nodes:
|
|
73
|
+
...r,
|
|
74
|
+
nodes: r.nodes.filter((a) => !c.has(a.id)).map((a) => a.parentId && c.has(a.parentId) ? {
|
|
75
75
|
...a,
|
|
76
76
|
parentId: void 0
|
|
77
77
|
} : a),
|
|
78
|
-
edges:
|
|
79
|
-
lines:
|
|
78
|
+
edges: r.edges.filter((a) => !m.has(a.id) && !c.has(a.source) && !c.has(a.target)),
|
|
79
|
+
lines: r.lines.filter((a) => !C.has(a.id)).map((a) => a.parentId && c.has(a.parentId) ? {
|
|
80
80
|
...a,
|
|
81
81
|
parentId: void 0
|
|
82
82
|
} : a)
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
} :
|
|
86
|
-
}), f(
|
|
85
|
+
} : P;
|
|
86
|
+
}), f(ce));
|
|
87
87
|
}, [
|
|
88
|
-
|
|
88
|
+
t,
|
|
89
89
|
d,
|
|
90
90
|
o,
|
|
91
91
|
f
|
|
92
|
-
]),
|
|
92
|
+
]), I = D(() => {
|
|
93
93
|
f({
|
|
94
94
|
nodeIds: new Set(e.nodes.map((c) => c.id)),
|
|
95
95
|
edgeIds: new Set(e.edges.map((c) => c.id)),
|
|
96
96
|
lineIds: new Set(e.lines.map((c) => c.id))
|
|
97
97
|
});
|
|
98
|
-
}, [e, f]), z =
|
|
99
|
-
const m =
|
|
98
|
+
}, [e, f]), z = D((c) => {
|
|
99
|
+
const m = t.nodeIds, C = t.lineIds;
|
|
100
100
|
if (m.size + C.size < 2) return;
|
|
101
|
-
const
|
|
102
|
-
let y = 1 / 0, L = 1 / 0,
|
|
103
|
-
for (const
|
|
104
|
-
y = Math.min(y,
|
|
105
|
-
for (const
|
|
106
|
-
y = Math.min(y,
|
|
107
|
-
const
|
|
108
|
-
id:
|
|
101
|
+
const P = e.nodes.filter((S) => m.has(S.id)), r = e.lines.filter((S) => C.has(S.id)), a = 20;
|
|
102
|
+
let y = 1 / 0, L = 1 / 0, T = -1 / 0, F = -1 / 0;
|
|
103
|
+
for (const S of P)
|
|
104
|
+
y = Math.min(y, S.position.x), L = Math.min(L, S.position.y), T = Math.max(T, S.position.x + S.width), F = Math.max(F, S.position.y + S.height);
|
|
105
|
+
for (const S of r) for (const A of S.points)
|
|
106
|
+
y = Math.min(y, A.x), L = Math.min(L, A.y), T = Math.max(T, A.x), F = Math.max(F, A.y);
|
|
107
|
+
const K = c === "geometryGroup", U = Q("group"), x = {
|
|
108
|
+
id: U,
|
|
109
109
|
type: c,
|
|
110
110
|
position: {
|
|
111
111
|
x: y - a,
|
|
112
112
|
y: L - a
|
|
113
113
|
},
|
|
114
|
-
width:
|
|
115
|
-
height:
|
|
114
|
+
width: T - y + a * 2,
|
|
115
|
+
height: F - L + a * 2,
|
|
116
116
|
data: {
|
|
117
117
|
...oe,
|
|
118
|
-
label:
|
|
119
|
-
fill:
|
|
118
|
+
label: K ? "Geo Group" : "Group",
|
|
119
|
+
fill: K ? "#fefce8" : "#f0f9ff",
|
|
120
120
|
stroke: "#9ca3af",
|
|
121
121
|
strokeWidth: 1.5,
|
|
122
|
-
borderStyle:
|
|
122
|
+
borderStyle: K ? "dashed" : "dotted",
|
|
123
123
|
isGroup: !0
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
-
d((
|
|
127
|
-
const
|
|
128
|
-
return
|
|
129
|
-
...
|
|
126
|
+
d((S) => {
|
|
127
|
+
const A = S.canvases[o];
|
|
128
|
+
return A ? {
|
|
129
|
+
...S,
|
|
130
130
|
canvases: {
|
|
131
|
-
...
|
|
131
|
+
...S.canvases,
|
|
132
132
|
[o]: {
|
|
133
|
-
...
|
|
134
|
-
nodes:
|
|
133
|
+
...A,
|
|
134
|
+
nodes: K ? [x, ...A.nodes] : [x, ...A.nodes.map((H) => m.has(H.id) ? {
|
|
135
135
|
...H,
|
|
136
|
-
parentId:
|
|
136
|
+
parentId: U
|
|
137
137
|
} : H)],
|
|
138
|
-
lines:
|
|
138
|
+
lines: K ? A.lines : A.lines.map((H) => C.has(H.id) ? {
|
|
139
139
|
...H,
|
|
140
|
-
parentId:
|
|
140
|
+
parentId: U
|
|
141
141
|
} : H)
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
} :
|
|
144
|
+
} : S;
|
|
145
145
|
}), f({
|
|
146
|
-
nodeIds: /* @__PURE__ */ new Set([
|
|
146
|
+
nodeIds: /* @__PURE__ */ new Set([U]),
|
|
147
147
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
148
148
|
lineIds: /* @__PURE__ */ new Set()
|
|
149
149
|
});
|
|
150
150
|
}, [
|
|
151
|
-
|
|
151
|
+
t,
|
|
152
152
|
e,
|
|
153
153
|
d,
|
|
154
154
|
o,
|
|
155
155
|
f
|
|
156
|
-
]),
|
|
157
|
-
const c =
|
|
156
|
+
]), B = D(() => z("flowGroup"), [z]), W = D(() => z("geometryGroup"), [z]), J = D(() => {
|
|
157
|
+
const c = t.nodeIds;
|
|
158
158
|
if (c.size === 0) return;
|
|
159
|
-
const m = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Set(),
|
|
160
|
-
for (const
|
|
159
|
+
const m = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Set(), P = /* @__PURE__ */ new Set();
|
|
160
|
+
for (const r of e.nodes) c.has(r.id) && (r.type === "flowGroup" || r.type === "geometryGroup" || r.data.isGroup) && m.add(r.id);
|
|
161
161
|
if (m.size !== 0) {
|
|
162
|
-
for (const
|
|
163
|
-
for (const
|
|
164
|
-
d((
|
|
165
|
-
const a =
|
|
162
|
+
for (const r of e.nodes) r.parentId && m.has(r.parentId) && C.add(r.id);
|
|
163
|
+
for (const r of e.lines) r.parentId && m.has(r.parentId) && P.add(r.id);
|
|
164
|
+
d((r) => {
|
|
165
|
+
const a = r.canvases[o];
|
|
166
166
|
return a ? {
|
|
167
|
-
...
|
|
167
|
+
...r,
|
|
168
168
|
canvases: {
|
|
169
|
-
...
|
|
169
|
+
...r.canvases,
|
|
170
170
|
[o]: {
|
|
171
171
|
...a,
|
|
172
172
|
nodes: a.nodes.filter((y) => !m.has(y.id)).map((y) => C.has(y.id) ? {
|
|
173
173
|
...y,
|
|
174
174
|
parentId: void 0
|
|
175
175
|
} : y),
|
|
176
|
-
lines: a.lines.map((y) =>
|
|
176
|
+
lines: a.lines.map((y) => P.has(y.id) ? {
|
|
177
177
|
...y,
|
|
178
178
|
parentId: void 0
|
|
179
179
|
} : y)
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
} :
|
|
182
|
+
} : r;
|
|
183
183
|
}), f({
|
|
184
184
|
nodeIds: C,
|
|
185
185
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
186
|
-
lineIds:
|
|
186
|
+
lineIds: P
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
}, [
|
|
190
|
-
|
|
190
|
+
t,
|
|
191
191
|
e,
|
|
192
192
|
d,
|
|
193
193
|
o,
|
|
194
194
|
f
|
|
195
195
|
]);
|
|
196
|
-
|
|
197
|
-
const E =
|
|
198
|
-
const m =
|
|
199
|
-
m.size === 0 && C.size === 0 || d((
|
|
200
|
-
const
|
|
201
|
-
if (!
|
|
202
|
-
const a =
|
|
196
|
+
l.current = B, w.current = W, i.current = J;
|
|
197
|
+
const E = D((c) => {
|
|
198
|
+
const m = t.nodeIds, C = t.lineIds;
|
|
199
|
+
m.size === 0 && C.size === 0 || d((P) => {
|
|
200
|
+
const r = P.canvases[o];
|
|
201
|
+
if (!r) return P;
|
|
202
|
+
const a = r.nodes.map((x) => x.zIndex ?? 0), y = a.length > 0 ? Math.max(...a) : 0, L = a.length > 0 ? Math.min(...a) : 0, T = r.lines.map((x) => x.zIndex ?? 0), F = T.length > 0 ? Math.max(...T) : 0, K = T.length > 0 ? Math.min(...T) : 0, U = (x, S, A) => c === "front" ? S + 1 : c === "back" ? A - 1 : c === "up" ? x + 1 : x - 1;
|
|
203
203
|
return {
|
|
204
|
-
...
|
|
204
|
+
...P,
|
|
205
205
|
canvases: {
|
|
206
|
-
...
|
|
206
|
+
...P.canvases,
|
|
207
207
|
[o]: {
|
|
208
|
-
...
|
|
209
|
-
nodes:
|
|
208
|
+
...r,
|
|
209
|
+
nodes: r.nodes.map((x) => m.has(x.id) ? {
|
|
210
210
|
...x,
|
|
211
|
-
zIndex:
|
|
211
|
+
zIndex: U(x.zIndex ?? 0, y, L)
|
|
212
212
|
} : x),
|
|
213
|
-
lines:
|
|
213
|
+
lines: r.lines.map((x) => C.has(x.id) ? {
|
|
214
214
|
...x,
|
|
215
|
-
zIndex:
|
|
215
|
+
zIndex: U(x.zIndex ?? 0, F, K)
|
|
216
216
|
} : x)
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
});
|
|
221
221
|
}, [
|
|
222
|
-
|
|
222
|
+
t,
|
|
223
223
|
d,
|
|
224
224
|
o
|
|
225
225
|
]);
|
|
226
|
-
return
|
|
226
|
+
return $(() => {
|
|
227
227
|
const c = (m) => {
|
|
228
228
|
const C = m.target;
|
|
229
229
|
if (C?.tagName === "INPUT" || C?.tagName === "TEXTAREA" || C?.isContentEditable) return;
|
|
230
|
-
const
|
|
231
|
-
if (!
|
|
232
|
-
m.preventDefault(),
|
|
230
|
+
const P = Array.from(m.clipboardData?.items ?? []).find((y) => y.type.startsWith("image/"));
|
|
231
|
+
if (!P) {
|
|
232
|
+
m.preventDefault(), b();
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
|
-
const
|
|
236
|
-
if (!
|
|
235
|
+
const r = P.getAsFile();
|
|
236
|
+
if (!r) return;
|
|
237
237
|
m.preventDefault();
|
|
238
238
|
const a = new FileReader();
|
|
239
239
|
a.onload = () => {
|
|
240
240
|
if (typeof a.result != "string") return;
|
|
241
|
-
const y =
|
|
241
|
+
const y = t.nodeIds.size === 1 ? e.nodes.find((N) => t.nodeIds.has(N.id) && N.type === "mediaNode" && N.data.mediaKind === "image") : void 0;
|
|
242
242
|
if (y) {
|
|
243
|
-
d((
|
|
244
|
-
const
|
|
245
|
-
return
|
|
246
|
-
...
|
|
243
|
+
d((N) => {
|
|
244
|
+
const O = N.canvases[o];
|
|
245
|
+
return O ? {
|
|
246
|
+
...N,
|
|
247
247
|
canvases: {
|
|
248
|
-
...
|
|
248
|
+
...N.canvases,
|
|
249
249
|
[o]: {
|
|
250
|
-
...
|
|
251
|
-
nodes:
|
|
252
|
-
...
|
|
250
|
+
...O,
|
|
251
|
+
nodes: O.nodes.map((_) => _.id === y.id ? {
|
|
252
|
+
..._,
|
|
253
253
|
data: {
|
|
254
|
-
...
|
|
254
|
+
..._.data,
|
|
255
255
|
mediaContent: a.result
|
|
256
256
|
}
|
|
257
|
-
} :
|
|
257
|
+
} : _)
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
} :
|
|
260
|
+
} : N;
|
|
261
261
|
});
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
264
|
-
const L =
|
|
264
|
+
const L = Q("node"), T = 320, F = 220, K = window.innerWidth, U = window.innerHeight, x = (K / 2 - g.x) / g.zoom, S = (U / 2 - g.y) / g.zoom, A = Math.max(0, ...e.nodes.map((N) => N.zIndex ?? 0)), H = {
|
|
265
265
|
id: L,
|
|
266
266
|
type: "mediaNode",
|
|
267
267
|
position: {
|
|
268
|
-
x: x -
|
|
269
|
-
y:
|
|
268
|
+
x: x - T / 2,
|
|
269
|
+
y: S - F / 2
|
|
270
270
|
},
|
|
271
|
-
width:
|
|
272
|
-
height:
|
|
273
|
-
zIndex:
|
|
271
|
+
width: T,
|
|
272
|
+
height: F,
|
|
273
|
+
zIndex: A + 1,
|
|
274
274
|
data: {
|
|
275
275
|
...oe,
|
|
276
|
-
label:
|
|
276
|
+
label: r.name || "Image",
|
|
277
277
|
fill: "theme:base-100",
|
|
278
278
|
stroke: "theme:base-content",
|
|
279
279
|
strokeWidth: 1.5,
|
|
@@ -284,172 +284,177 @@ function He({ onUndo: n, onRedo: p, groupRef: u, geoGroupRef: I, ungroupRef: s }
|
|
|
284
284
|
mediaContent: a.result
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
|
-
d((
|
|
288
|
-
const
|
|
289
|
-
return
|
|
290
|
-
...
|
|
287
|
+
d((N) => {
|
|
288
|
+
const O = N.canvases[o];
|
|
289
|
+
return O ? {
|
|
290
|
+
...N,
|
|
291
291
|
canvases: {
|
|
292
|
-
...
|
|
292
|
+
...N.canvases,
|
|
293
293
|
[o]: {
|
|
294
|
-
...
|
|
295
|
-
nodes: [...
|
|
294
|
+
...O,
|
|
295
|
+
nodes: [...O.nodes, H]
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
} :
|
|
298
|
+
} : N;
|
|
299
299
|
}), f({
|
|
300
300
|
nodeIds: /* @__PURE__ */ new Set([L]),
|
|
301
301
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
302
302
|
lineIds: /* @__PURE__ */ new Set()
|
|
303
303
|
});
|
|
304
|
-
}, a.readAsDataURL(
|
|
304
|
+
}, a.readAsDataURL(r);
|
|
305
305
|
};
|
|
306
306
|
return window.addEventListener("paste", c), () => window.removeEventListener("paste", c);
|
|
307
307
|
}, [
|
|
308
308
|
e,
|
|
309
309
|
o,
|
|
310
|
+
b,
|
|
310
311
|
t,
|
|
311
|
-
r,
|
|
312
312
|
d,
|
|
313
313
|
f,
|
|
314
314
|
g
|
|
315
|
-
]),
|
|
316
|
-
undo:
|
|
315
|
+
]), We(ae(() => ({
|
|
316
|
+
undo: s,
|
|
317
317
|
redo: p,
|
|
318
|
-
copy:
|
|
319
|
-
cut:
|
|
320
|
-
paste:
|
|
321
|
-
duplicate:
|
|
322
|
-
deleteSelected:
|
|
323
|
-
selectAll:
|
|
324
|
-
group:
|
|
325
|
-
geoGroup:
|
|
326
|
-
ungroup:
|
|
318
|
+
copy: u,
|
|
319
|
+
cut: M,
|
|
320
|
+
paste: b,
|
|
321
|
+
duplicate: n,
|
|
322
|
+
deleteSelected: v,
|
|
323
|
+
selectAll: I,
|
|
324
|
+
group: B,
|
|
325
|
+
geoGroup: W,
|
|
326
|
+
ungroup: J,
|
|
327
327
|
bringToFront: () => E("front"),
|
|
328
328
|
bringForward: () => E("up"),
|
|
329
329
|
sendBackward: () => E("down"),
|
|
330
330
|
sendToBack: () => E("back")
|
|
331
331
|
}), [
|
|
332
|
-
|
|
332
|
+
s,
|
|
333
333
|
p,
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
S,
|
|
334
|
+
u,
|
|
335
|
+
M,
|
|
336
|
+
b,
|
|
337
|
+
n,
|
|
339
338
|
v,
|
|
340
|
-
|
|
341
|
-
O,
|
|
339
|
+
I,
|
|
342
340
|
B,
|
|
341
|
+
W,
|
|
342
|
+
J,
|
|
343
343
|
E
|
|
344
|
-
])),
|
|
344
|
+
])), Ke(), null;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
347
|
-
return p.current =
|
|
346
|
+
function Oe({ pixiRef: s, exportPdfRef: p }) {
|
|
347
|
+
return p.current = Ge(s), null;
|
|
348
348
|
}
|
|
349
|
-
var
|
|
350
|
-
const [z,
|
|
351
|
-
|
|
349
|
+
var Nt = Ue(function({ initialDocument: p, onChange: l, width: w, height: i, readOnly: t = !1, onBack: f, onExportPNG: e, onPublish: d, showMiniMap: o = !0, showGrid: g = !0, gridSize: u = 20, className: M, showAI: b = !0, showAIConfig: n = !0, aiConfig: v }, I) {
|
|
350
|
+
const [z, B] = j(() => Be(p ?? me())), [W, J] = j(ce), E = G(null), c = G(null), m = G(null), { wrappedSetDoc: C, undo: P, redo: r, canUndo: a, canRedo: y } = Fe(z, B), L = G(null), T = G(null), F = G(null), K = G(null), U = G(l);
|
|
351
|
+
U.current = l;
|
|
352
352
|
const x = G(z);
|
|
353
|
-
x.current = z,
|
|
354
|
-
exportPNG: async (
|
|
355
|
-
const
|
|
356
|
-
return !
|
|
353
|
+
x.current = z, He(I, () => ({
|
|
354
|
+
exportPNG: async (k) => {
|
|
355
|
+
const R = E.current;
|
|
356
|
+
return !R || R.destroyed ? null : R.exportPNG(k);
|
|
357
357
|
},
|
|
358
358
|
getDocument: () => x.current
|
|
359
359
|
}), []);
|
|
360
|
-
const
|
|
361
|
-
C((
|
|
362
|
-
const
|
|
363
|
-
return queueMicrotask(() =>
|
|
360
|
+
const S = D((k) => {
|
|
361
|
+
C((R) => {
|
|
362
|
+
const V = typeof k == "function" ? k(R) : k;
|
|
363
|
+
return t ? V.canvases === R.canvases && V.title === R.title ? V : R : (queueMicrotask(() => U.current?.(V)), V);
|
|
364
364
|
});
|
|
365
|
-
}, [C]),
|
|
366
|
-
|
|
367
|
-
}, []), H =
|
|
365
|
+
}, [C, t]), A = D(() => {
|
|
366
|
+
t || P();
|
|
367
|
+
}, [t, P]), H = D(() => {
|
|
368
|
+
t || r();
|
|
369
|
+
}, [t, r]), N = D((k) => {
|
|
370
|
+
E.current = k, c.current && !m.current && (m.current = new ke(c.current));
|
|
371
|
+
}, []), O = D(async () => {
|
|
368
372
|
if (e) return void e();
|
|
369
|
-
const
|
|
370
|
-
if (!
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
}, [e]),
|
|
374
|
-
await
|
|
373
|
+
const k = E.current;
|
|
374
|
+
if (!k || k.destroyed) return;
|
|
375
|
+
const R = await k.exportPNG(16777215);
|
|
376
|
+
R && xe(R, `${be(x.current.title)}.png`);
|
|
377
|
+
}, [e]), _ = D(async () => {
|
|
378
|
+
await K.current?.();
|
|
375
379
|
}, []);
|
|
376
|
-
|
|
377
|
-
let
|
|
378
|
-
const
|
|
379
|
-
const
|
|
380
|
-
if (!
|
|
381
|
-
const
|
|
382
|
-
x:
|
|
383
|
-
y:
|
|
384
|
-
zoom:
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
},
|
|
388
|
-
if (
|
|
389
|
-
const
|
|
390
|
-
|
|
380
|
+
$(() => {
|
|
381
|
+
let k = !1, R = null;
|
|
382
|
+
const V = () => {
|
|
383
|
+
const Z = E.current, ne = m.current;
|
|
384
|
+
if (!Z || Z.destroyed || !ne) return;
|
|
385
|
+
const ue = {
|
|
386
|
+
x: Z.world.position.x,
|
|
387
|
+
y: Z.world.position.y,
|
|
388
|
+
zoom: Z.world.scale.x
|
|
389
|
+
}, fe = z.stack[z.stack.length - 1] ?? "root", se = z.canvases[fe];
|
|
390
|
+
se && ne.update(se.nodes, ue, Z.app.screen.width, Z.app.screen.height);
|
|
391
|
+
}, te = () => {
|
|
392
|
+
if (k) return;
|
|
393
|
+
const Z = E.current;
|
|
394
|
+
Z && !Z.destroyed && m.current ? (Z.app.ticker.add(V), R = Z) : requestAnimationFrame(te);
|
|
391
395
|
};
|
|
392
|
-
return
|
|
393
|
-
|
|
396
|
+
return te(), () => {
|
|
397
|
+
k = !0, R && !R.destroyed && R.app.ticker.remove(V);
|
|
394
398
|
};
|
|
395
399
|
}, [z]);
|
|
396
|
-
const
|
|
397
|
-
width:
|
|
398
|
-
height:
|
|
400
|
+
const le = {
|
|
401
|
+
width: w ?? "100%",
|
|
402
|
+
height: i ?? "100%"
|
|
399
403
|
};
|
|
400
404
|
return /* @__PURE__ */ h("div", {
|
|
401
|
-
className: `flow-container ${
|
|
402
|
-
style:
|
|
403
|
-
children: /* @__PURE__ */ h(
|
|
405
|
+
className: `flow-container ${M ?? ""}`,
|
|
406
|
+
style: le,
|
|
407
|
+
children: /* @__PURE__ */ h(ge, {
|
|
404
408
|
doc: z,
|
|
405
|
-
setDoc:
|
|
406
|
-
selection:
|
|
407
|
-
setSelection:
|
|
408
|
-
children: /* @__PURE__ */ h(
|
|
409
|
+
setDoc: S,
|
|
410
|
+
selection: W,
|
|
411
|
+
setSelection: J,
|
|
412
|
+
children: /* @__PURE__ */ h(we, {
|
|
409
413
|
showMiniMap: o,
|
|
410
414
|
showGrid: g,
|
|
411
|
-
gridSize:
|
|
412
|
-
showAI:
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
415
|
+
gridSize: u,
|
|
416
|
+
showAI: b,
|
|
417
|
+
readOnly: t,
|
|
418
|
+
children: /* @__PURE__ */ X(Ie, {
|
|
419
|
+
initialConfig: v,
|
|
420
|
+
showAIConfig: n,
|
|
416
421
|
children: [
|
|
417
|
-
/* @__PURE__ */ h(
|
|
418
|
-
onUndo:
|
|
419
|
-
onRedo:
|
|
422
|
+
/* @__PURE__ */ h(Je, {
|
|
423
|
+
onUndo: A,
|
|
424
|
+
onRedo: H,
|
|
420
425
|
groupRef: L,
|
|
421
|
-
geoGroupRef:
|
|
422
|
-
ungroupRef:
|
|
426
|
+
geoGroupRef: T,
|
|
427
|
+
ungroupRef: F
|
|
423
428
|
}),
|
|
424
|
-
/* @__PURE__ */ h(
|
|
429
|
+
/* @__PURE__ */ h(Oe, {
|
|
425
430
|
pixiRef: E,
|
|
426
|
-
exportPdfRef:
|
|
431
|
+
exportPdfRef: K
|
|
427
432
|
}),
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
toolbar:
|
|
433
|
+
/* @__PURE__ */ X(Ye, {
|
|
434
|
+
toolbar: t ? null : /* @__PURE__ */ h(Se, {
|
|
430
435
|
onBack: f,
|
|
431
|
-
onUndo:
|
|
432
|
-
onRedo:
|
|
436
|
+
onUndo: A,
|
|
437
|
+
onRedo: H,
|
|
433
438
|
canUndo: a,
|
|
434
439
|
canRedo: y,
|
|
435
440
|
onGroup: () => L.current?.(),
|
|
436
|
-
onGeoGroup: () =>
|
|
437
|
-
onUngroup: () =>
|
|
438
|
-
onExportPNG:
|
|
439
|
-
onExportPDF:
|
|
441
|
+
onGeoGroup: () => T.current?.(),
|
|
442
|
+
onUngroup: () => F.current?.(),
|
|
443
|
+
onExportPNG: O,
|
|
444
|
+
onExportPDF: _,
|
|
440
445
|
onPublish: d
|
|
441
446
|
}),
|
|
442
447
|
children: [
|
|
443
|
-
/* @__PURE__ */ h(
|
|
444
|
-
/* @__PURE__ */ h(
|
|
445
|
-
/* @__PURE__ */
|
|
446
|
-
/* @__PURE__ */ h(
|
|
447
|
-
/* @__PURE__ */ h(
|
|
448
|
+
/* @__PURE__ */ h(ye, { onPixiReady: N }),
|
|
449
|
+
/* @__PURE__ */ h(Te, {}),
|
|
450
|
+
/* @__PURE__ */ X(Ve, { children: [!t && /* @__PURE__ */ h(Ce, {}), /* @__PURE__ */ h(Re, {})] }),
|
|
451
|
+
!t && /* @__PURE__ */ h(et, {}),
|
|
452
|
+
/* @__PURE__ */ h($e, {
|
|
448
453
|
canvasRef: c,
|
|
449
454
|
pixiRef: E,
|
|
450
455
|
miniMapRef: m
|
|
451
456
|
}),
|
|
452
|
-
/* @__PURE__ */ h(
|
|
457
|
+
/* @__PURE__ */ h(Ne, {})
|
|
453
458
|
]
|
|
454
459
|
})
|
|
455
460
|
]
|
|
@@ -458,15 +463,15 @@ var An = Oe(function({ initialDocument: p, onChange: u, width: I, height: s, rea
|
|
|
458
463
|
})
|
|
459
464
|
});
|
|
460
465
|
});
|
|
461
|
-
function
|
|
462
|
-
const { presentation: p } =
|
|
466
|
+
function Ve({ children: s }) {
|
|
467
|
+
const { presentation: p } = Y();
|
|
463
468
|
return /* @__PURE__ */ h("div", {
|
|
464
469
|
className: "flow-overlay",
|
|
465
470
|
style: { display: p ? "none" : void 0 },
|
|
466
|
-
children:
|
|
471
|
+
children: s
|
|
467
472
|
});
|
|
468
473
|
}
|
|
469
|
-
var
|
|
474
|
+
var _e = [
|
|
470
475
|
{
|
|
471
476
|
id: "shapes",
|
|
472
477
|
label: "Shapes",
|
|
@@ -517,105 +522,105 @@ var Je = [
|
|
|
517
522
|
showKey: "showAI"
|
|
518
523
|
}
|
|
519
524
|
];
|
|
520
|
-
function
|
|
521
|
-
switch (
|
|
525
|
+
function Xe(s) {
|
|
526
|
+
switch (s) {
|
|
522
527
|
case "shapes":
|
|
523
|
-
return /* @__PURE__ */ h(
|
|
528
|
+
return /* @__PURE__ */ h(Pe, {});
|
|
524
529
|
case "icons":
|
|
525
|
-
return /* @__PURE__ */ h(
|
|
530
|
+
return /* @__PURE__ */ h(ze, {});
|
|
526
531
|
case "media":
|
|
527
|
-
return /* @__PURE__ */ h(
|
|
532
|
+
return /* @__PURE__ */ h(Me, {});
|
|
528
533
|
case "inspector":
|
|
529
|
-
return /* @__PURE__ */ h(
|
|
534
|
+
return /* @__PURE__ */ h(Ee, {});
|
|
530
535
|
case "outline":
|
|
531
|
-
return /* @__PURE__ */ h(
|
|
536
|
+
return /* @__PURE__ */ h(De, {});
|
|
532
537
|
case "json":
|
|
533
|
-
return /* @__PURE__ */ h(
|
|
538
|
+
return /* @__PURE__ */ h(Qe, {});
|
|
534
539
|
case "ai":
|
|
535
|
-
return /* @__PURE__ */ h(
|
|
540
|
+
return /* @__PURE__ */ h(Ae, {});
|
|
536
541
|
default:
|
|
537
542
|
return null;
|
|
538
543
|
}
|
|
539
544
|
}
|
|
540
|
-
function
|
|
541
|
-
const
|
|
542
|
-
id:
|
|
543
|
-
label:
|
|
544
|
-
icon:
|
|
545
|
-
content:
|
|
546
|
-
}),
|
|
547
|
-
return /* @__PURE__ */
|
|
545
|
+
function Ye({ children: s, toolbar: p }) {
|
|
546
|
+
const l = Y(), { detachedTabs: w, toggleDetach: i, presentation: t, readOnly: f } = l, e = f ? [] : _e.filter((n) => !n.showKey || l[n.showKey]), d = (n) => ({
|
|
547
|
+
id: n.id,
|
|
548
|
+
label: n.label,
|
|
549
|
+
icon: n.icon,
|
|
550
|
+
content: Xe(n.id)
|
|
551
|
+
}), o = e.filter((n) => n.side === "left" && !w.has(n.id)).map(d), g = e.filter((n) => n.side === "right" && !w.has(n.id)).map(d), u = e.filter((n) => w.has(n.id)), M = D((n) => i(n), [i]), b = D((n) => i(n), [i]);
|
|
552
|
+
return /* @__PURE__ */ X("div", {
|
|
548
553
|
className: "flow-workspace",
|
|
549
|
-
children: [!
|
|
554
|
+
children: [!t && p, /* @__PURE__ */ X("div", {
|
|
550
555
|
className: "flow-workspace-main",
|
|
551
556
|
children: [
|
|
552
|
-
!
|
|
553
|
-
tabs:
|
|
554
|
-
defaultTab:
|
|
557
|
+
!t && o.length > 0 && /* @__PURE__ */ h(q, {
|
|
558
|
+
tabs: o,
|
|
559
|
+
defaultTab: o[0]?.id,
|
|
555
560
|
resizeEdge: "right",
|
|
556
561
|
defaultWidth: 132,
|
|
557
|
-
onDetach:
|
|
562
|
+
onDetach: M
|
|
558
563
|
}),
|
|
559
564
|
/* @__PURE__ */ h("div", {
|
|
560
565
|
className: "flow-stage",
|
|
561
|
-
children:
|
|
566
|
+
children: s
|
|
562
567
|
}),
|
|
563
|
-
!
|
|
564
|
-
tabs:
|
|
565
|
-
defaultTab:
|
|
568
|
+
!t && g.length > 0 && /* @__PURE__ */ h(q, {
|
|
569
|
+
tabs: g,
|
|
570
|
+
defaultTab: g[0]?.id,
|
|
566
571
|
resizeEdge: "left",
|
|
567
572
|
defaultWidth: 220,
|
|
568
|
-
onDetach:
|
|
573
|
+
onDetach: M
|
|
569
574
|
}),
|
|
570
|
-
!
|
|
571
|
-
tabs: [
|
|
575
|
+
!t && u.map((n, v) => /* @__PURE__ */ h(q, {
|
|
576
|
+
tabs: [d(n)],
|
|
572
577
|
resizeEdge: "right",
|
|
573
578
|
defaultWidth: 220,
|
|
574
579
|
style: {
|
|
575
|
-
top: 48 +
|
|
576
|
-
left: 24 +
|
|
580
|
+
top: 48 + v * 40,
|
|
581
|
+
left: 24 + v * 30
|
|
577
582
|
},
|
|
578
583
|
isDetached: !0,
|
|
579
|
-
onAttach:
|
|
580
|
-
},
|
|
584
|
+
onAttach: b
|
|
585
|
+
}, n.id))
|
|
581
586
|
]
|
|
582
587
|
})]
|
|
583
588
|
});
|
|
584
589
|
}
|
|
585
|
-
function
|
|
586
|
-
const { showMiniMap:
|
|
587
|
-
const
|
|
588
|
-
if (!
|
|
589
|
-
const
|
|
590
|
-
if (
|
|
591
|
-
const { width: z, height:
|
|
590
|
+
function $e({ canvasRef: s, pixiRef: p, miniMapRef: l }) {
|
|
591
|
+
const { showMiniMap: w, setViewport: i, presentation: t } = Y(), f = G(!1), e = D((u, M) => {
|
|
592
|
+
const b = s.current, n = p.current, v = l.current;
|
|
593
|
+
if (!b || !n || n.destroyed || !v) return;
|
|
594
|
+
const I = b.getBoundingClientRect();
|
|
595
|
+
if (I.width === 0 || I.height === 0) return;
|
|
596
|
+
const { width: z, height: B } = v.size, W = (u - I.left) / I.width * z, J = (M - I.top) / I.height * B, E = v.minimapToWorld(W, J);
|
|
592
597
|
if (!E) return;
|
|
593
|
-
const c =
|
|
594
|
-
|
|
598
|
+
const c = n.world.scale.x || 1, m = n.app.screen.width, C = n.app.screen.height;
|
|
599
|
+
i({
|
|
595
600
|
x: m / 2 - E.x * c,
|
|
596
601
|
y: C / 2 - E.y * c,
|
|
597
602
|
zoom: c
|
|
598
603
|
});
|
|
599
604
|
}, [
|
|
600
|
-
|
|
605
|
+
s,
|
|
601
606
|
p,
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
]), d =
|
|
605
|
-
|
|
606
|
-
}, [e]), o =
|
|
607
|
-
f.current && e(
|
|
608
|
-
}, [e]), g =
|
|
607
|
+
l,
|
|
608
|
+
i
|
|
609
|
+
]), d = D((u) => {
|
|
610
|
+
u.preventDefault(), u.currentTarget.setPointerCapture(u.pointerId), f.current = !0, e(u.clientX, u.clientY);
|
|
611
|
+
}, [e]), o = D((u) => {
|
|
612
|
+
f.current && e(u.clientX, u.clientY);
|
|
613
|
+
}, [e]), g = D((u) => {
|
|
609
614
|
f.current = !1;
|
|
610
615
|
try {
|
|
611
|
-
|
|
616
|
+
u.currentTarget.releasePointerCapture(u.pointerId);
|
|
612
617
|
} catch {
|
|
613
618
|
}
|
|
614
619
|
}, []);
|
|
615
620
|
return /* @__PURE__ */ h("div", {
|
|
616
621
|
className: "flow-minimap",
|
|
617
622
|
style: {
|
|
618
|
-
display:
|
|
623
|
+
display: w && !t ? void 0 : "none",
|
|
619
624
|
cursor: "pointer"
|
|
620
625
|
},
|
|
621
626
|
onPointerDown: d,
|
|
@@ -623,7 +628,7 @@ function Xe({ canvasRef: n, pixiRef: p, miniMapRef: u }) {
|
|
|
623
628
|
onPointerUp: g,
|
|
624
629
|
title: "点击或拖动以移动画布",
|
|
625
630
|
children: /* @__PURE__ */ h("canvas", {
|
|
626
|
-
ref:
|
|
631
|
+
ref: s,
|
|
627
632
|
width: 180,
|
|
628
633
|
height: 120,
|
|
629
634
|
style: {
|
|
@@ -634,97 +639,97 @@ function Xe({ canvasRef: n, pixiRef: p, miniMapRef: u }) {
|
|
|
634
639
|
})
|
|
635
640
|
});
|
|
636
641
|
}
|
|
637
|
-
function
|
|
638
|
-
const
|
|
639
|
-
if (
|
|
640
|
-
let
|
|
641
|
-
for (let e =
|
|
642
|
-
if (
|
|
643
|
-
if (
|
|
644
|
-
|
|
642
|
+
function je(s, p) {
|
|
643
|
+
const l = `"id": "${p}"`, w = s.indexOf(l);
|
|
644
|
+
if (w === -1) return null;
|
|
645
|
+
let i = 0, t = -1;
|
|
646
|
+
for (let e = w; e >= 0; e--)
|
|
647
|
+
if (s[e] === "}" && i++, s[e] === "{") {
|
|
648
|
+
if (i === 0) {
|
|
649
|
+
t = e;
|
|
645
650
|
break;
|
|
646
651
|
}
|
|
647
|
-
|
|
652
|
+
i--;
|
|
648
653
|
}
|
|
649
|
-
if (
|
|
650
|
-
|
|
654
|
+
if (t === -1) return null;
|
|
655
|
+
i = 0;
|
|
651
656
|
let f = -1;
|
|
652
|
-
for (let e =
|
|
653
|
-
if (
|
|
657
|
+
for (let e = t; e < s.length; e++)
|
|
658
|
+
if (s[e] === "{" && i++, s[e] === "}" && (i--, i === 0)) {
|
|
654
659
|
f = e;
|
|
655
660
|
break;
|
|
656
661
|
}
|
|
657
662
|
return f === -1 ? null : {
|
|
658
|
-
startLine:
|
|
663
|
+
startLine: s.slice(0, t).split(`
|
|
659
664
|
`).length,
|
|
660
|
-
endLine:
|
|
665
|
+
endLine: s.slice(0, f + 1).split(`
|
|
661
666
|
`).length
|
|
662
667
|
};
|
|
663
668
|
}
|
|
664
|
-
function
|
|
665
|
-
|
|
669
|
+
function ie(s) {
|
|
670
|
+
s.querySelectorAll(".cm-line.flow-json-hl").forEach((p) => p.classList.remove("flow-json-hl"));
|
|
666
671
|
}
|
|
667
|
-
function
|
|
668
|
-
const
|
|
669
|
-
if (
|
|
670
|
-
for (let
|
|
671
|
-
const
|
|
672
|
+
function qe(s, p, l) {
|
|
673
|
+
const w = s.getView();
|
|
674
|
+
if (w)
|
|
675
|
+
for (let i = p; i <= l; i++) try {
|
|
676
|
+
const t = w.state.doc.line(i), f = w.domAtPos(t.from), e = f.node instanceof HTMLElement ? f.node.closest(".cm-line") : f.node.parentElement?.closest(".cm-line");
|
|
672
677
|
e && e.classList.add("flow-json-hl");
|
|
673
678
|
} catch {
|
|
674
679
|
}
|
|
675
680
|
}
|
|
676
|
-
function
|
|
677
|
-
const { setDoc:
|
|
678
|
-
|
|
681
|
+
function Qe() {
|
|
682
|
+
const { setDoc: s, currentCanvasId: p, selection: l, currentCanvas: w } = ee(), [i, t] = j(""), [f, e] = j(null), d = G(!1), o = G(null), g = G(null), u = ae(() => l.nodeIds.size + l.edgeIds.size + l.lineIds.size !== 1 ? null : l.nodeIds.size === 1 ? [...l.nodeIds][0] : l.edgeIds.size === 1 ? [...l.edgeIds][0] : l.lineIds.size === 1 ? [...l.lineIds][0] : null, [l]);
|
|
683
|
+
$(() => {
|
|
679
684
|
if (d.current) {
|
|
680
685
|
d.current = !1;
|
|
681
686
|
return;
|
|
682
687
|
}
|
|
683
|
-
|
|
684
|
-
}, [
|
|
685
|
-
const
|
|
686
|
-
if (
|
|
687
|
-
const
|
|
688
|
-
const
|
|
689
|
-
if (!
|
|
688
|
+
t(JSON.stringify(w, null, 2)), e(null);
|
|
689
|
+
}, [w]), $(() => {
|
|
690
|
+
const n = g.current;
|
|
691
|
+
if (n && ie(n), !u) return;
|
|
692
|
+
const v = setTimeout(() => {
|
|
693
|
+
const I = je(i, u);
|
|
694
|
+
if (!I || !g.current) return;
|
|
690
695
|
const z = o.current?.getView();
|
|
691
696
|
if (!z) return;
|
|
692
|
-
const
|
|
693
|
-
|
|
694
|
-
const
|
|
695
|
-
z.dispatch({ effects:
|
|
697
|
+
const B = g.current, W = z.scrollDOM;
|
|
698
|
+
W.style.scrollBehavior = "smooth";
|
|
699
|
+
const J = z.state.doc.line(I.startLine);
|
|
700
|
+
z.dispatch({ effects: Ze.scrollIntoView(J.from, {
|
|
696
701
|
y: "start",
|
|
697
702
|
yMargin: 0
|
|
698
703
|
}) });
|
|
699
704
|
const E = () => {
|
|
700
|
-
|
|
705
|
+
W.style.scrollBehavior = "", ie(B), qe(o.current, I.startLine, I.endLine);
|
|
701
706
|
};
|
|
702
707
|
let c;
|
|
703
708
|
const m = () => {
|
|
704
709
|
clearTimeout(c), c = setTimeout(E, 100);
|
|
705
710
|
};
|
|
706
|
-
|
|
707
|
-
|
|
711
|
+
W.addEventListener("scroll", m), c = setTimeout(() => {
|
|
712
|
+
W.removeEventListener("scroll", m), E();
|
|
708
713
|
}, 800);
|
|
709
714
|
}, 120);
|
|
710
|
-
return () => clearTimeout(
|
|
711
|
-
}, [
|
|
712
|
-
const
|
|
713
|
-
|
|
715
|
+
return () => clearTimeout(v);
|
|
716
|
+
}, [u, i]);
|
|
717
|
+
const M = D((n) => {
|
|
718
|
+
t(n);
|
|
714
719
|
try {
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
...
|
|
720
|
+
const v = JSON.parse(n);
|
|
721
|
+
v && Array.isArray(v.nodes) && Array.isArray(v.edges) && Array.isArray(v.lines) ? (e(null), d.current = !0, s((I) => ({
|
|
722
|
+
...I,
|
|
718
723
|
canvases: {
|
|
719
|
-
...
|
|
720
|
-
[p]:
|
|
724
|
+
...I.canvases,
|
|
725
|
+
[p]: v
|
|
721
726
|
}
|
|
722
727
|
}))) : e("JSON must have nodes, edges, lines arrays");
|
|
723
|
-
} catch (
|
|
724
|
-
e(
|
|
728
|
+
} catch (v) {
|
|
729
|
+
e(v.message?.slice(0, 60) ?? "Invalid JSON");
|
|
725
730
|
}
|
|
726
|
-
}, [
|
|
727
|
-
return /* @__PURE__ */
|
|
731
|
+
}, [s, p]), b = u ? l.nodeIds.has(u) ? "Node" : l.edgeIds.has(u) ? "Edge" : "Line" : null;
|
|
732
|
+
return /* @__PURE__ */ X("div", {
|
|
728
733
|
style: {
|
|
729
734
|
display: "flex",
|
|
730
735
|
flexDirection: "column",
|
|
@@ -736,7 +741,7 @@ function je() {
|
|
|
736
741
|
className: "flow-json-header",
|
|
737
742
|
children: /* @__PURE__ */ h("span", {
|
|
738
743
|
className: "flow-json-scope",
|
|
739
|
-
children:
|
|
744
|
+
children: b ? `${b}: ${u.slice(0, 8)}` : "Canvas"
|
|
740
745
|
})
|
|
741
746
|
}),
|
|
742
747
|
f && /* @__PURE__ */ h("div", {
|
|
@@ -754,10 +759,10 @@ function je() {
|
|
|
754
759
|
flex: 1,
|
|
755
760
|
minHeight: 0
|
|
756
761
|
},
|
|
757
|
-
children: /* @__PURE__ */ h(
|
|
762
|
+
children: /* @__PURE__ */ h(he, {
|
|
758
763
|
ref: o,
|
|
759
|
-
value:
|
|
760
|
-
onChange:
|
|
764
|
+
value: i,
|
|
765
|
+
onChange: M,
|
|
761
766
|
language: "json",
|
|
762
767
|
lineNumbers: !1,
|
|
763
768
|
height: "100%",
|
|
@@ -767,13 +772,13 @@ function je() {
|
|
|
767
772
|
]
|
|
768
773
|
});
|
|
769
774
|
}
|
|
770
|
-
function
|
|
771
|
-
const { contextMenu:
|
|
772
|
-
if (!
|
|
773
|
-
const d =
|
|
775
|
+
function et() {
|
|
776
|
+
const { contextMenu: s, setContextMenu: p } = Y(), { doc: l, setDoc: w, currentCanvasId: i, pushCanvas: t, setSelection: f } = ee(), { duplicate: e } = re();
|
|
777
|
+
if (!s) return null;
|
|
778
|
+
const d = l.canvases[i];
|
|
774
779
|
if (!d)
|
|
775
780
|
return p(null), null;
|
|
776
|
-
const o =
|
|
781
|
+
const o = s.nodeId ? d.nodes.find((u) => u.id === s.nodeId) : null, g = [];
|
|
777
782
|
return o && (g.push({
|
|
778
783
|
label: "Duplicate",
|
|
779
784
|
icon: "⧉",
|
|
@@ -788,7 +793,7 @@ function qe() {
|
|
|
788
793
|
label: "Enter Sub-canvas",
|
|
789
794
|
icon: "↓",
|
|
790
795
|
action: () => {
|
|
791
|
-
|
|
796
|
+
t(o.data.childCanvasId), f({
|
|
792
797
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
793
798
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
794
799
|
lineIds: /* @__PURE__ */ new Set()
|
|
@@ -803,27 +808,27 @@ function qe() {
|
|
|
803
808
|
icon: "🗑",
|
|
804
809
|
danger: !0,
|
|
805
810
|
action: () => {
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
const
|
|
811
|
-
if (!
|
|
812
|
-
|
|
813
|
-
...
|
|
814
|
-
nodes:
|
|
815
|
-
...
|
|
811
|
+
const u = o.data.childCanvasId;
|
|
812
|
+
w((M) => {
|
|
813
|
+
const b = { ...M.canvases };
|
|
814
|
+
de(b, u);
|
|
815
|
+
const n = b[i];
|
|
816
|
+
if (!n) return M;
|
|
817
|
+
b[i] = {
|
|
818
|
+
...n,
|
|
819
|
+
nodes: n.nodes.map((I) => I.id === o.id ? {
|
|
820
|
+
...I,
|
|
816
821
|
data: {
|
|
817
|
-
...
|
|
822
|
+
...I.data,
|
|
818
823
|
childCanvasId: void 0
|
|
819
824
|
}
|
|
820
|
-
} :
|
|
825
|
+
} : I)
|
|
821
826
|
};
|
|
822
|
-
const
|
|
823
|
-
return
|
|
824
|
-
...
|
|
825
|
-
canvases:
|
|
826
|
-
stack:
|
|
827
|
+
const v = M.stack.filter((I) => b[I]);
|
|
828
|
+
return v.length === 0 && v.push(pe), {
|
|
829
|
+
...M,
|
|
830
|
+
canvases: b,
|
|
831
|
+
stack: v
|
|
827
832
|
};
|
|
828
833
|
});
|
|
829
834
|
}
|
|
@@ -831,48 +836,48 @@ function qe() {
|
|
|
831
836
|
label: "Create Sub-canvas",
|
|
832
837
|
icon: "⊞",
|
|
833
838
|
action: () => {
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
const
|
|
837
|
-
return
|
|
838
|
-
...
|
|
839
|
+
const u = Q("canvas");
|
|
840
|
+
w((M) => {
|
|
841
|
+
const b = M.canvases[i];
|
|
842
|
+
return b ? {
|
|
843
|
+
...M,
|
|
839
844
|
canvases: {
|
|
840
|
-
...
|
|
841
|
-
[
|
|
842
|
-
...
|
|
843
|
-
nodes:
|
|
844
|
-
...
|
|
845
|
+
...M.canvases,
|
|
846
|
+
[i]: {
|
|
847
|
+
...b,
|
|
848
|
+
nodes: b.nodes.map((n) => n.id === o.id ? {
|
|
849
|
+
...n,
|
|
845
850
|
data: {
|
|
846
|
-
...
|
|
847
|
-
childCanvasId:
|
|
851
|
+
...n.data,
|
|
852
|
+
childCanvasId: u
|
|
848
853
|
}
|
|
849
|
-
} :
|
|
854
|
+
} : n)
|
|
850
855
|
},
|
|
851
|
-
[
|
|
856
|
+
[u]: {
|
|
852
857
|
nodes: [],
|
|
853
858
|
edges: [],
|
|
854
859
|
lines: []
|
|
855
860
|
}
|
|
856
861
|
}
|
|
857
|
-
} :
|
|
858
|
-
}),
|
|
862
|
+
} : M;
|
|
863
|
+
}), t(u);
|
|
859
864
|
}
|
|
860
|
-
})), g.length === 0 ? null : /* @__PURE__ */ h(
|
|
861
|
-
x:
|
|
862
|
-
y:
|
|
865
|
+
})), g.length === 0 ? null : /* @__PURE__ */ h(Le, {
|
|
866
|
+
x: s.x,
|
|
867
|
+
y: s.y,
|
|
863
868
|
items: g,
|
|
864
869
|
onClose: () => p(null)
|
|
865
870
|
});
|
|
866
871
|
}
|
|
867
|
-
function
|
|
868
|
-
const
|
|
869
|
-
if (
|
|
870
|
-
for (const
|
|
871
|
-
delete
|
|
872
|
+
function de(s, p) {
|
|
873
|
+
const l = s[p];
|
|
874
|
+
if (l) {
|
|
875
|
+
for (const w of l.nodes) w.data.childCanvasId && de(s, w.data.childCanvasId);
|
|
876
|
+
delete s[p];
|
|
872
877
|
}
|
|
873
878
|
}
|
|
874
879
|
export {
|
|
875
|
-
|
|
880
|
+
Nt as default
|
|
876
881
|
};
|
|
877
882
|
|
|
878
883
|
//# sourceMappingURL=Flow.js.map
|