dishui 0.0.61 → 0.0.64
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.
|
@@ -8,7 +8,7 @@ import { generateId as Q } from "./nodes/nodeUtils.js";
|
|
|
8
8
|
import { normalizeEdgeHandles as xe } from "./edges/edgePaths.js";
|
|
9
9
|
import { useDeleteSelection as Se } from "./hooks/useDeleteSelection.js";
|
|
10
10
|
import Ce from "./FlowCanvas.js";
|
|
11
|
-
import { downloadDataURL as
|
|
11
|
+
import { downloadDataURL as Pe, safeFileBaseName as Me } from "./hooks/useFlowImportExport.js";
|
|
12
12
|
import Ne, { FlowZoomControls as ke } from "./panels/FlowToolbar.js";
|
|
13
13
|
import { MediaStampContent as De, ShapePaletteContent as Ee, SvgStampContent as Ae } from "./panels/ShapePalette.js";
|
|
14
14
|
import { InspectorPanelContent as ze } from "./panels/InspectorPanel.js";
|
|
@@ -27,43 +27,43 @@ import { usePdfExport as Ze } from "./hooks/usePdfExport.js";
|
|
|
27
27
|
import { useKeyboardShortcuts as Je } from "./hooks/useKeyboardShortcuts.js";
|
|
28
28
|
import { useMindMap as Oe } from "./hooks/useMindMap.js";
|
|
29
29
|
/* empty css */
|
|
30
|
-
import { forwardRef as _e, useCallback as
|
|
30
|
+
import { forwardRef as _e, useCallback as E, useEffect as X, useImperativeHandle as $e, useMemo as le, useRef as F, useState as j } from "react";
|
|
31
31
|
import { jsx as r, jsxs as _ } from "react/jsx-runtime";
|
|
32
32
|
import { EditorView as Be } from "@codemirror/view";
|
|
33
33
|
function Ve(o) {
|
|
34
34
|
let p = !1;
|
|
35
35
|
const a = { ...o.canvases };
|
|
36
|
-
for (const [
|
|
36
|
+
for (const [v, u] of Object.entries(a)) {
|
|
37
37
|
const s = u.nodes.map((e) => {
|
|
38
38
|
if (e.type !== "shapeSvg") return e;
|
|
39
|
-
const
|
|
40
|
-
return
|
|
39
|
+
const I = e.data.labelPlacement, m = I === "above" ? "top" : I === "center" ? "middle" : I === "below" ? "bottom" : e.data.labelPlacement;
|
|
40
|
+
return m === e.data.labelPlacement ? e : (p = !0, {
|
|
41
41
|
...e,
|
|
42
42
|
data: {
|
|
43
43
|
...e.data,
|
|
44
|
-
labelPlacement:
|
|
44
|
+
labelPlacement: m
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
48
|
let l = !1;
|
|
49
49
|
const n = s.map((e) => {
|
|
50
50
|
if (!e.data.isMindMapNode) return e;
|
|
51
|
-
const
|
|
52
|
-
return
|
|
51
|
+
const I = e.data.fill === "#ffffff" || e.data.fill === "#eef2ff" ? "theme:base-100" : e.data.fill, m = e.data.stroke === "#6366f1" ? "theme:base-content" : e.data.stroke === "#4f46e5" ? "theme:primary" : e.data.stroke;
|
|
52
|
+
return I === e.data.fill && m === e.data.stroke ? e : (l = !0, {
|
|
53
53
|
...e,
|
|
54
54
|
data: {
|
|
55
55
|
...e.data,
|
|
56
|
-
fill:
|
|
57
|
-
stroke:
|
|
56
|
+
fill: I,
|
|
57
|
+
stroke: m
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
-
}),
|
|
61
|
-
for (const e of n)
|
|
62
|
-
let
|
|
63
|
-
const
|
|
60
|
+
}), b = /* @__PURE__ */ new Map();
|
|
61
|
+
for (const e of n) b.set(e.id, e);
|
|
62
|
+
let c = !1;
|
|
63
|
+
const y = xe(u.edges, b).map((e) => {
|
|
64
64
|
if (e.data.strokeColor !== "#94a3b8") return e;
|
|
65
|
-
const
|
|
66
|
-
return !
|
|
65
|
+
const I = b.get(e.source), m = b.get(e.target);
|
|
66
|
+
return !I?.data.isMindMapNode || !m?.data.isMindMapNode ? e : (c = !0, {
|
|
67
67
|
...e,
|
|
68
68
|
data: {
|
|
69
69
|
...e.data,
|
|
@@ -71,10 +71,10 @@ function Ve(o) {
|
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
|
-
(l ||
|
|
74
|
+
(l || c) && (p = !0), (n !== s || y !== u.edges) && (a[v] = {
|
|
75
75
|
...u,
|
|
76
76
|
nodes: n,
|
|
77
|
-
edges:
|
|
77
|
+
edges: y
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
return p ? {
|
|
@@ -87,171 +87,171 @@ var je = {
|
|
|
87
87
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
88
88
|
lineIds: /* @__PURE__ */ new Set()
|
|
89
89
|
};
|
|
90
|
-
function Xe({ onUndo: o, onRedo: p, groupRef: a, geoGroupRef:
|
|
91
|
-
const { selection: s, setSelection: l, currentCanvas: n, setDoc:
|
|
90
|
+
function Xe({ onUndo: o, onRedo: p, groupRef: a, geoGroupRef: v, ungroupRef: u }) {
|
|
91
|
+
const { selection: s, setSelection: l, currentCanvas: n, setDoc: b, currentCanvasId: c } = ee(), { viewport: y } = Y(), { copy: e, cut: I, paste: m, duplicate: h } = ae(), x = Se(), g = E(() => {
|
|
92
92
|
l({
|
|
93
93
|
nodeIds: new Set(n.nodes.map((f) => f.id)),
|
|
94
94
|
edgeIds: new Set(n.edges.map((f) => f.id)),
|
|
95
95
|
lineIds: new Set(n.lines.map((f) => f.id))
|
|
96
96
|
});
|
|
97
|
-
}, [n, l]), S =
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
const
|
|
101
|
-
let
|
|
102
|
-
for (const
|
|
103
|
-
|
|
104
|
-
for (const
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
id:
|
|
97
|
+
}, [n, l]), S = E((f) => {
|
|
98
|
+
const w = s.nodeIds, N = s.lineIds;
|
|
99
|
+
if (w.size + N.size < 2) return;
|
|
100
|
+
const k = n.nodes.filter((M) => w.has(M.id)), d = n.lines.filter((M) => N.has(M.id)), t = 20;
|
|
101
|
+
let i = 1 / 0, R = 1 / 0, L = -1 / 0, W = -1 / 0;
|
|
102
|
+
for (const M of k)
|
|
103
|
+
i = Math.min(i, M.position.x), R = Math.min(R, M.position.y), L = Math.max(L, M.position.x + M.width), W = Math.max(W, M.position.y + M.height);
|
|
104
|
+
for (const M of d) for (const D of M.points)
|
|
105
|
+
i = Math.min(i, D.x), R = Math.min(R, D.y), L = Math.max(L, D.x), W = Math.max(W, D.y);
|
|
106
|
+
const H = f === "geometryGroup", U = Q("group"), P = {
|
|
107
|
+
id: U,
|
|
108
108
|
type: f,
|
|
109
109
|
position: {
|
|
110
|
-
x:
|
|
111
|
-
y:
|
|
110
|
+
x: i - t,
|
|
111
|
+
y: R - t
|
|
112
112
|
},
|
|
113
|
-
width:
|
|
114
|
-
height:
|
|
113
|
+
width: L - i + t * 2,
|
|
114
|
+
height: W - R + t * 2,
|
|
115
115
|
data: {
|
|
116
116
|
...se,
|
|
117
|
-
label:
|
|
118
|
-
fill:
|
|
117
|
+
label: H ? "Geo Group" : "Group",
|
|
118
|
+
fill: H ? "#fefce8" : "#f0f9ff",
|
|
119
119
|
stroke: "#9ca3af",
|
|
120
120
|
strokeWidth: 1.5,
|
|
121
|
-
borderStyle:
|
|
121
|
+
borderStyle: H ? "dashed" : "dotted",
|
|
122
122
|
isGroup: !0
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
return
|
|
128
|
-
...
|
|
125
|
+
b((M) => {
|
|
126
|
+
const D = M.canvases[c];
|
|
127
|
+
return D ? {
|
|
128
|
+
...M,
|
|
129
129
|
canvases: {
|
|
130
|
-
...
|
|
131
|
-
[
|
|
132
|
-
...
|
|
133
|
-
nodes:
|
|
130
|
+
...M.canvases,
|
|
131
|
+
[c]: {
|
|
132
|
+
...D,
|
|
133
|
+
nodes: H ? [P, ...D.nodes] : [P, ...D.nodes.map((O) => w.has(O.id) ? {
|
|
134
134
|
...O,
|
|
135
|
-
parentId:
|
|
135
|
+
parentId: U
|
|
136
136
|
} : O)],
|
|
137
|
-
lines:
|
|
137
|
+
lines: H ? D.lines : D.lines.map((O) => N.has(O.id) ? {
|
|
138
138
|
...O,
|
|
139
|
-
parentId:
|
|
139
|
+
parentId: U
|
|
140
140
|
} : O)
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
} :
|
|
143
|
+
} : M;
|
|
144
144
|
}), l({
|
|
145
|
-
nodeIds: /* @__PURE__ */ new Set([
|
|
145
|
+
nodeIds: /* @__PURE__ */ new Set([U]),
|
|
146
146
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
147
147
|
lineIds: /* @__PURE__ */ new Set()
|
|
148
148
|
});
|
|
149
149
|
}, [
|
|
150
150
|
s,
|
|
151
151
|
n,
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
b,
|
|
153
|
+
c,
|
|
154
154
|
l
|
|
155
|
-
]),
|
|
155
|
+
]), K = E(() => S("flowGroup"), [S]), z = E(() => S("geometryGroup"), [S]), J = E(() => {
|
|
156
156
|
const f = s.nodeIds;
|
|
157
157
|
if (f.size === 0) return;
|
|
158
|
-
const
|
|
159
|
-
for (const
|
|
160
|
-
if (
|
|
161
|
-
for (const
|
|
162
|
-
for (const
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
return
|
|
166
|
-
...
|
|
158
|
+
const w = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set(), k = /* @__PURE__ */ new Set();
|
|
159
|
+
for (const d of n.nodes) f.has(d.id) && (d.type === "flowGroup" || d.type === "geometryGroup" || d.data.isGroup) && w.add(d.id);
|
|
160
|
+
if (w.size !== 0) {
|
|
161
|
+
for (const d of n.nodes) d.parentId && w.has(d.parentId) && N.add(d.id);
|
|
162
|
+
for (const d of n.lines) d.parentId && w.has(d.parentId) && k.add(d.id);
|
|
163
|
+
b((d) => {
|
|
164
|
+
const t = d.canvases[c];
|
|
165
|
+
return t ? {
|
|
166
|
+
...d,
|
|
167
167
|
canvases: {
|
|
168
|
-
...
|
|
169
|
-
[
|
|
170
|
-
...
|
|
171
|
-
nodes:
|
|
172
|
-
...
|
|
168
|
+
...d.canvases,
|
|
169
|
+
[c]: {
|
|
170
|
+
...t,
|
|
171
|
+
nodes: t.nodes.filter((i) => !w.has(i.id)).map((i) => N.has(i.id) ? {
|
|
172
|
+
...i,
|
|
173
173
|
parentId: void 0
|
|
174
|
-
} :
|
|
175
|
-
lines:
|
|
176
|
-
...
|
|
174
|
+
} : i),
|
|
175
|
+
lines: t.lines.map((i) => k.has(i.id) ? {
|
|
176
|
+
...i,
|
|
177
177
|
parentId: void 0
|
|
178
|
-
} :
|
|
178
|
+
} : i)
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
} :
|
|
181
|
+
} : d;
|
|
182
182
|
}), l({
|
|
183
183
|
nodeIds: N,
|
|
184
184
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
185
|
-
lineIds:
|
|
185
|
+
lineIds: k
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
}, [
|
|
189
189
|
s,
|
|
190
190
|
n,
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
b,
|
|
192
|
+
c,
|
|
193
193
|
l
|
|
194
194
|
]);
|
|
195
|
-
a.current =
|
|
196
|
-
const C =
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
if (!
|
|
201
|
-
const
|
|
195
|
+
a.current = K, v.current = z, u.current = J;
|
|
196
|
+
const C = E((f) => {
|
|
197
|
+
const w = s.nodeIds, N = s.lineIds;
|
|
198
|
+
w.size === 0 && N.size === 0 || b((k) => {
|
|
199
|
+
const d = k.canvases[c];
|
|
200
|
+
if (!d) return k;
|
|
201
|
+
const t = d.nodes.map((P) => P.zIndex ?? 0), i = t.length > 0 ? Math.max(...t) : 0, R = t.length > 0 ? Math.min(...t) : 0, L = d.lines.map((P) => P.zIndex ?? 0), W = L.length > 0 ? Math.max(...L) : 0, H = L.length > 0 ? Math.min(...L) : 0, U = (P, M, D) => f === "front" ? M + 1 : f === "back" ? D - 1 : f === "up" ? P + 1 : P - 1;
|
|
202
202
|
return {
|
|
203
|
-
...
|
|
203
|
+
...k,
|
|
204
204
|
canvases: {
|
|
205
|
-
...
|
|
206
|
-
[
|
|
207
|
-
...
|
|
208
|
-
nodes:
|
|
209
|
-
...
|
|
210
|
-
zIndex:
|
|
211
|
-
} :
|
|
212
|
-
lines:
|
|
213
|
-
...
|
|
214
|
-
zIndex:
|
|
215
|
-
} :
|
|
205
|
+
...k.canvases,
|
|
206
|
+
[c]: {
|
|
207
|
+
...d,
|
|
208
|
+
nodes: d.nodes.map((P) => w.has(P.id) ? {
|
|
209
|
+
...P,
|
|
210
|
+
zIndex: U(P.zIndex ?? 0, i, R)
|
|
211
|
+
} : P),
|
|
212
|
+
lines: d.lines.map((P) => N.has(P.id) ? {
|
|
213
|
+
...P,
|
|
214
|
+
zIndex: U(P.zIndex ?? 0, W, H)
|
|
215
|
+
} : P)
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
219
|
});
|
|
220
220
|
}, [
|
|
221
221
|
s,
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
b,
|
|
223
|
+
c
|
|
224
224
|
]);
|
|
225
225
|
return X(() => {
|
|
226
|
-
const f = (
|
|
227
|
-
const N =
|
|
226
|
+
const f = (w) => {
|
|
227
|
+
const N = w.target;
|
|
228
228
|
if (N?.tagName === "INPUT" || N?.tagName === "TEXTAREA" || N?.isContentEditable) return;
|
|
229
|
-
const
|
|
230
|
-
if (!
|
|
231
|
-
|
|
229
|
+
const k = Array.from(w.clipboardData?.items ?? []).find((i) => i.type.startsWith("image/"));
|
|
230
|
+
if (!k) {
|
|
231
|
+
w.preventDefault(), m();
|
|
232
232
|
return;
|
|
233
233
|
}
|
|
234
|
-
const
|
|
235
|
-
if (!
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
if (typeof
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
const $ = A.canvases[
|
|
234
|
+
const d = k.getAsFile();
|
|
235
|
+
if (!d) return;
|
|
236
|
+
w.preventDefault();
|
|
237
|
+
const t = new FileReader();
|
|
238
|
+
t.onload = () => {
|
|
239
|
+
if (typeof t.result != "string") return;
|
|
240
|
+
const i = s.nodeIds.size === 1 ? n.nodes.find((A) => s.nodeIds.has(A.id) && A.type === "mediaNode" && A.data.mediaKind === "image") : void 0;
|
|
241
|
+
if (i) {
|
|
242
|
+
b((A) => {
|
|
243
|
+
const $ = A.canvases[c];
|
|
244
244
|
return $ ? {
|
|
245
245
|
...A,
|
|
246
246
|
canvases: {
|
|
247
247
|
...A.canvases,
|
|
248
|
-
[
|
|
248
|
+
[c]: {
|
|
249
249
|
...$,
|
|
250
|
-
nodes: $.nodes.map((V) => V.id ===
|
|
250
|
+
nodes: $.nodes.map((V) => V.id === i.id ? {
|
|
251
251
|
...V,
|
|
252
252
|
data: {
|
|
253
253
|
...V.data,
|
|
254
|
-
mediaContent:
|
|
254
|
+
mediaContent: t.result
|
|
255
255
|
}
|
|
256
256
|
} : V)
|
|
257
257
|
}
|
|
@@ -260,19 +260,19 @@ function Xe({ onUndo: o, onRedo: p, groupRef: a, geoGroupRef: w, ungroupRef: u }
|
|
|
260
260
|
});
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
|
-
const
|
|
264
|
-
id:
|
|
263
|
+
const R = Q("node"), L = 320, W = 220, H = window.innerWidth, U = window.innerHeight, P = (H / 2 - y.x) / y.zoom, M = (U / 2 - y.y) / y.zoom, D = Math.max(0, ...n.nodes.map((A) => A.zIndex ?? 0)), O = {
|
|
264
|
+
id: R,
|
|
265
265
|
type: "mediaNode",
|
|
266
266
|
position: {
|
|
267
|
-
x:
|
|
268
|
-
y:
|
|
267
|
+
x: P - L / 2,
|
|
268
|
+
y: M - W / 2
|
|
269
269
|
},
|
|
270
|
-
width:
|
|
271
|
-
height:
|
|
272
|
-
zIndex:
|
|
270
|
+
width: L,
|
|
271
|
+
height: W,
|
|
272
|
+
zIndex: D + 1,
|
|
273
273
|
data: {
|
|
274
274
|
...se,
|
|
275
|
-
label:
|
|
275
|
+
label: d.name || "Image",
|
|
276
276
|
fill: "theme:base-100",
|
|
277
277
|
stroke: "theme:base-content",
|
|
278
278
|
strokeWidth: 1.5,
|
|
@@ -280,49 +280,49 @@ function Xe({ onUndo: o, onRedo: p, groupRef: a, geoGroupRef: w, ungroupRef: u }
|
|
|
280
280
|
fontSize: 13,
|
|
281
281
|
borderStyle: "solid",
|
|
282
282
|
mediaKind: "image",
|
|
283
|
-
mediaContent:
|
|
283
|
+
mediaContent: t.result
|
|
284
284
|
}
|
|
285
285
|
};
|
|
286
|
-
|
|
287
|
-
const $ = A.canvases[
|
|
286
|
+
b((A) => {
|
|
287
|
+
const $ = A.canvases[c];
|
|
288
288
|
return $ ? {
|
|
289
289
|
...A,
|
|
290
290
|
canvases: {
|
|
291
291
|
...A.canvases,
|
|
292
|
-
[
|
|
292
|
+
[c]: {
|
|
293
293
|
...$,
|
|
294
294
|
nodes: [...$.nodes, O]
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
} : A;
|
|
298
298
|
}), l({
|
|
299
|
-
nodeIds: /* @__PURE__ */ new Set([
|
|
299
|
+
nodeIds: /* @__PURE__ */ new Set([R]),
|
|
300
300
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
301
301
|
lineIds: /* @__PURE__ */ new Set()
|
|
302
302
|
});
|
|
303
|
-
},
|
|
303
|
+
}, t.readAsDataURL(d);
|
|
304
304
|
};
|
|
305
305
|
return window.addEventListener("paste", f), () => window.removeEventListener("paste", f);
|
|
306
306
|
}, [
|
|
307
307
|
n,
|
|
308
|
-
d,
|
|
309
308
|
c,
|
|
309
|
+
m,
|
|
310
310
|
s,
|
|
311
|
-
|
|
311
|
+
b,
|
|
312
312
|
l,
|
|
313
|
-
|
|
313
|
+
y
|
|
314
314
|
]), Je(le(() => ({
|
|
315
315
|
undo: o,
|
|
316
316
|
redo: p,
|
|
317
317
|
copy: e,
|
|
318
|
-
cut:
|
|
319
|
-
paste:
|
|
320
|
-
duplicate:
|
|
321
|
-
deleteSelected:
|
|
318
|
+
cut: I,
|
|
319
|
+
paste: m,
|
|
320
|
+
duplicate: h,
|
|
321
|
+
deleteSelected: x,
|
|
322
322
|
selectAll: g,
|
|
323
|
-
group:
|
|
324
|
-
geoGroup:
|
|
325
|
-
ungroup:
|
|
323
|
+
group: K,
|
|
324
|
+
geoGroup: z,
|
|
325
|
+
ungroup: J,
|
|
326
326
|
bringToFront: () => C("front"),
|
|
327
327
|
bringForward: () => C("up"),
|
|
328
328
|
sendBackward: () => C("down"),
|
|
@@ -331,130 +331,130 @@ function Xe({ onUndo: o, onRedo: p, groupRef: a, geoGroupRef: w, ungroupRef: u }
|
|
|
331
331
|
o,
|
|
332
332
|
p,
|
|
333
333
|
e,
|
|
334
|
+
I,
|
|
335
|
+
m,
|
|
334
336
|
h,
|
|
335
|
-
|
|
336
|
-
v,
|
|
337
|
-
b,
|
|
337
|
+
x,
|
|
338
338
|
g,
|
|
339
|
-
G,
|
|
340
|
-
L,
|
|
341
339
|
K,
|
|
340
|
+
z,
|
|
341
|
+
J,
|
|
342
342
|
C
|
|
343
343
|
])), Oe(), null;
|
|
344
344
|
}
|
|
345
345
|
function Ye({ pixiRef: o, exportPdfRef: p }) {
|
|
346
346
|
return p.current = Ze(o), null;
|
|
347
347
|
}
|
|
348
|
-
var Ht = _e(function({ initialDocument: p, onChange: a, width:
|
|
349
|
-
const [S,
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
exportPNG: async (
|
|
354
|
-
const
|
|
355
|
-
return !
|
|
348
|
+
var Ht = _e(function({ initialDocument: p, onChange: a, width: v, height: u, readOnly: s = !1, onBack: l, onExportPNG: n, onPublish: b, showMiniMap: c = !0, showGrid: y = !0, gridSize: e = 20, className: I, showAI: m = !0, showAIConfig: h = !0, aiConfig: x }, g) {
|
|
349
|
+
const [S, K] = j(() => Ve(p ?? Ie())), [z, J] = j(je), C = F(null), f = F(null), w = F(null), N = F(null), k = Ue(N), { wrappedSetDoc: d, undo: t, redo: i, canUndo: R, canRedo: L } = He(S, K), W = F(null), H = F(null), U = F(null), P = F(null), M = F(a);
|
|
350
|
+
M.current = a;
|
|
351
|
+
const D = F(S);
|
|
352
|
+
D.current = S, $e(g, () => ({
|
|
353
|
+
exportPNG: async (G) => {
|
|
354
|
+
const T = C.current;
|
|
355
|
+
return !T || T.destroyed ? null : T.exportPNG(G);
|
|
356
356
|
},
|
|
357
|
-
getDocument: () =>
|
|
357
|
+
getDocument: () => D.current
|
|
358
358
|
}), []);
|
|
359
|
-
const O =
|
|
360
|
-
|
|
361
|
-
const B = typeof
|
|
362
|
-
return s ? B.canvases ===
|
|
359
|
+
const O = E((G) => {
|
|
360
|
+
d((T) => {
|
|
361
|
+
const B = typeof G == "function" ? G(T) : G;
|
|
362
|
+
return s ? B.canvases === T.canvases && B.title === T.title ? B : T : (queueMicrotask(() => M.current?.(B)), B);
|
|
363
363
|
});
|
|
364
|
-
}, [
|
|
364
|
+
}, [d, s]), A = E(() => {
|
|
365
|
+
s || t();
|
|
366
|
+
}, [s, t]), $ = E(() => {
|
|
365
367
|
s || i();
|
|
366
|
-
}, [s, i]),
|
|
367
|
-
|
|
368
|
-
}, [
|
|
369
|
-
C.current = F, f.current && !m.current && (m.current = new We(f.current));
|
|
370
|
-
}, []), de = D(async () => {
|
|
368
|
+
}, [s, i]), V = E((G) => {
|
|
369
|
+
C.current = G, f.current && !w.current && (w.current = new We(f.current));
|
|
370
|
+
}, []), de = E(async () => {
|
|
371
371
|
if (n) return void n();
|
|
372
|
-
const
|
|
373
|
-
if (!
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
}, [n]), ue =
|
|
377
|
-
await
|
|
372
|
+
const G = C.current;
|
|
373
|
+
if (!G || G.destroyed) return;
|
|
374
|
+
const T = await G.exportPNG(16777215);
|
|
375
|
+
T && Pe(T, `${Me(D.current.title)}.png`);
|
|
376
|
+
}, [n]), ue = E(async () => {
|
|
377
|
+
await P.current?.();
|
|
378
378
|
}, []);
|
|
379
379
|
X(() => {
|
|
380
|
-
let
|
|
380
|
+
let G = !1, T = null;
|
|
381
381
|
const B = () => {
|
|
382
|
-
const
|
|
383
|
-
if (!
|
|
382
|
+
const Z = C.current, ne = w.current;
|
|
383
|
+
if (!Z || Z.destroyed || !ne) return;
|
|
384
384
|
const pe = {
|
|
385
|
-
x:
|
|
386
|
-
y:
|
|
387
|
-
zoom:
|
|
385
|
+
x: Z.world.position.x,
|
|
386
|
+
y: Z.world.position.y,
|
|
387
|
+
zoom: Z.world.scale.x
|
|
388
388
|
}, me = S.stack[S.stack.length - 1] ?? "root", oe = S.canvases[me];
|
|
389
|
-
oe && ne.update(oe.nodes, pe,
|
|
389
|
+
oe && ne.update(oe.nodes, pe, Z.app.screen.width, Z.app.screen.height);
|
|
390
390
|
}, te = () => {
|
|
391
|
-
if (
|
|
392
|
-
const
|
|
393
|
-
|
|
391
|
+
if (G) return;
|
|
392
|
+
const Z = C.current;
|
|
393
|
+
Z && !Z.destroyed && w.current ? (Z.app.ticker.add(B), T = Z) : requestAnimationFrame(te);
|
|
394
394
|
};
|
|
395
395
|
return te(), () => {
|
|
396
|
-
|
|
396
|
+
G = !0, T && !T.destroyed && T.app.ticker.remove(B);
|
|
397
397
|
};
|
|
398
398
|
}, [S]);
|
|
399
399
|
const fe = {
|
|
400
|
-
width:
|
|
400
|
+
width: v ?? "100%",
|
|
401
401
|
height: u ?? "100%"
|
|
402
402
|
};
|
|
403
403
|
return /* @__PURE__ */ r("div", {
|
|
404
404
|
ref: N,
|
|
405
|
-
className: `flow-container ${
|
|
405
|
+
className: `flow-container ${I ?? ""}`,
|
|
406
406
|
style: fe,
|
|
407
407
|
children: /* @__PURE__ */ r(ve, {
|
|
408
408
|
doc: S,
|
|
409
409
|
setDoc: O,
|
|
410
|
-
selection:
|
|
411
|
-
setSelection:
|
|
410
|
+
selection: z,
|
|
411
|
+
setSelection: J,
|
|
412
412
|
children: /* @__PURE__ */ r(ye, {
|
|
413
|
-
showMiniMap:
|
|
414
|
-
showGrid:
|
|
413
|
+
showMiniMap: c,
|
|
414
|
+
showGrid: y,
|
|
415
415
|
gridSize: e,
|
|
416
|
-
showAI:
|
|
416
|
+
showAI: m,
|
|
417
417
|
readOnly: s,
|
|
418
418
|
children: /* @__PURE__ */ _(be, {
|
|
419
|
-
initialConfig:
|
|
420
|
-
showAIConfig:
|
|
419
|
+
initialConfig: x,
|
|
420
|
+
showAIConfig: h,
|
|
421
421
|
children: [
|
|
422
422
|
/* @__PURE__ */ r(Xe, {
|
|
423
423
|
onUndo: A,
|
|
424
424
|
onRedo: $,
|
|
425
|
-
groupRef:
|
|
426
|
-
geoGroupRef:
|
|
427
|
-
ungroupRef:
|
|
425
|
+
groupRef: W,
|
|
426
|
+
geoGroupRef: H,
|
|
427
|
+
ungroupRef: U
|
|
428
428
|
}),
|
|
429
429
|
/* @__PURE__ */ r(Ye, {
|
|
430
430
|
pixiRef: C,
|
|
431
|
-
exportPdfRef:
|
|
431
|
+
exportPdfRef: P
|
|
432
432
|
}),
|
|
433
433
|
/* @__PURE__ */ _(tt, {
|
|
434
|
-
compact:
|
|
434
|
+
compact: k,
|
|
435
435
|
toolbar: s ? null : /* @__PURE__ */ r(Ne, {
|
|
436
|
-
compact:
|
|
436
|
+
compact: k,
|
|
437
437
|
onBack: l,
|
|
438
438
|
onUndo: A,
|
|
439
439
|
onRedo: $,
|
|
440
|
-
canUndo:
|
|
441
|
-
canRedo:
|
|
442
|
-
onGroup: () =>
|
|
443
|
-
onGeoGroup: () =>
|
|
444
|
-
onUngroup: () =>
|
|
440
|
+
canUndo: R,
|
|
441
|
+
canRedo: L,
|
|
442
|
+
onGroup: () => W.current?.(),
|
|
443
|
+
onGeoGroup: () => H.current?.(),
|
|
444
|
+
onUngroup: () => U.current?.(),
|
|
445
445
|
onExportPNG: de,
|
|
446
446
|
onExportPDF: ue,
|
|
447
|
-
onPublish:
|
|
447
|
+
onPublish: b
|
|
448
448
|
}),
|
|
449
449
|
children: [
|
|
450
450
|
/* @__PURE__ */ r(Ce, { onPixiReady: V }),
|
|
451
451
|
/* @__PURE__ */ r(Fe, {}),
|
|
452
452
|
/* @__PURE__ */ _(qe, { children: [!s && /* @__PURE__ */ r(ke, {}), /* @__PURE__ */ r(Ge, {})] }),
|
|
453
|
-
!s && /* @__PURE__ */ r(
|
|
453
|
+
!s && /* @__PURE__ */ r(rt, {}),
|
|
454
454
|
/* @__PURE__ */ r(nt, {
|
|
455
455
|
canvasRef: f,
|
|
456
456
|
pixiRef: C,
|
|
457
|
-
miniMapRef:
|
|
457
|
+
miniMapRef: w
|
|
458
458
|
}),
|
|
459
459
|
/* @__PURE__ */ r(Le, {})
|
|
460
460
|
]
|
|
@@ -517,7 +517,7 @@ var Qe = [
|
|
|
517
517
|
showKey: "showAI"
|
|
518
518
|
}
|
|
519
519
|
];
|
|
520
|
-
function
|
|
520
|
+
function ie(o) {
|
|
521
521
|
switch (o) {
|
|
522
522
|
case "shapes":
|
|
523
523
|
return /* @__PURE__ */ r(Ee, {});
|
|
@@ -530,7 +530,7 @@ function re(o) {
|
|
|
530
530
|
case "outline":
|
|
531
531
|
return /* @__PURE__ */ r(Te, {});
|
|
532
532
|
case "json":
|
|
533
|
-
return /* @__PURE__ */ r(
|
|
533
|
+
return /* @__PURE__ */ r(it, {});
|
|
534
534
|
case "ai":
|
|
535
535
|
return /* @__PURE__ */ r(Re, {});
|
|
536
536
|
default:
|
|
@@ -543,49 +543,51 @@ var et = /* @__PURE__ */ new Set([
|
|
|
543
543
|
"media"
|
|
544
544
|
]);
|
|
545
545
|
function tt({ children: o, toolbar: p, compact: a }) {
|
|
546
|
-
const
|
|
546
|
+
const v = Y(), { panelDocks: u, setPanelDock: s, presentation: l, readOnly: n, setPendingPlacement: b } = v, { setShowPalette: c, setShowInspector: y, setShowOutline: e, setShowJson: I, setShowAI: m } = v, h = n ? [] : Qe.filter((t) => !t.showKey || v[t.showKey]), x = (t) => ({
|
|
547
547
|
id: t.id,
|
|
548
548
|
label: t.label,
|
|
549
549
|
icon: t.icon,
|
|
550
|
-
content:
|
|
551
|
-
}), [
|
|
550
|
+
content: ie(t.id)
|
|
551
|
+
}), [g, S] = j(null), K = F(null);
|
|
552
552
|
X(() => {
|
|
553
553
|
if (!a) {
|
|
554
|
-
|
|
554
|
+
K.current = null;
|
|
555
555
|
return;
|
|
556
556
|
}
|
|
557
|
-
const t =
|
|
558
|
-
|
|
557
|
+
const t = v.pendingPlacement, i = t ? `${t.type}:${t.data?.svgId ?? ""}:${t.data?.mediaKind ?? ""}` : null, R = K.current;
|
|
558
|
+
K.current = i, i && i !== R && g && et.has(g) && S(null);
|
|
559
559
|
}, [
|
|
560
|
-
|
|
560
|
+
v.pendingPlacement,
|
|
561
561
|
a,
|
|
562
|
-
|
|
562
|
+
g
|
|
563
563
|
]);
|
|
564
|
-
const [
|
|
565
|
-
t === "inspector" ?
|
|
564
|
+
const [z, J] = j(null), C = E((t, i) => s(t, i), [s]), f = E((t) => {
|
|
565
|
+
t === "inspector" ? y(!1) : t === "outline" ? e(!1) : t === "json" ? I(!1) : t === "ai" ? m(!1) : c(!1);
|
|
566
566
|
}, [
|
|
567
|
-
|
|
568
|
-
I,
|
|
567
|
+
y,
|
|
569
568
|
e,
|
|
570
|
-
|
|
571
|
-
|
|
569
|
+
I,
|
|
570
|
+
m,
|
|
571
|
+
c
|
|
572
572
|
]);
|
|
573
573
|
if (a && !l) {
|
|
574
|
-
const t =
|
|
574
|
+
const t = h.find((i) => i.id === g) ?? null;
|
|
575
575
|
return /* @__PURE__ */ _("div", {
|
|
576
576
|
className: "flow-workspace",
|
|
577
577
|
children: [
|
|
578
578
|
p,
|
|
579
|
-
|
|
579
|
+
h.length > 0 && /* @__PURE__ */ r("div", {
|
|
580
580
|
className: "flow-mobile-panel-bar",
|
|
581
581
|
children: /* @__PURE__ */ r(he, {
|
|
582
582
|
placeholder: "选择面板…",
|
|
583
|
-
options:
|
|
583
|
+
options: h.map((i) => ({
|
|
584
584
|
value: i.id,
|
|
585
585
|
label: i.label
|
|
586
586
|
})),
|
|
587
|
-
value:
|
|
588
|
-
onChange: (i) =>
|
|
587
|
+
value: g ?? void 0,
|
|
588
|
+
onChange: (i) => {
|
|
589
|
+
b(null), S(String(i));
|
|
590
|
+
}
|
|
589
591
|
})
|
|
590
592
|
}),
|
|
591
593
|
/* @__PURE__ */ _("div", {
|
|
@@ -607,48 +609,48 @@ function tt({ children: o, toolbar: p, compact: a }) {
|
|
|
607
609
|
type: "button",
|
|
608
610
|
className: "flow-mobile-panel-close",
|
|
609
611
|
"aria-label": "关闭面板",
|
|
610
|
-
onClick: () =>
|
|
612
|
+
onClick: () => S(null),
|
|
611
613
|
children: "✕"
|
|
612
614
|
})]
|
|
613
615
|
}), /* @__PURE__ */ r("div", {
|
|
614
616
|
className: "flow-mobile-panel-body",
|
|
615
|
-
children:
|
|
617
|
+
children: ie(t.id)
|
|
616
618
|
})]
|
|
617
619
|
})]
|
|
618
620
|
})
|
|
619
621
|
]
|
|
620
622
|
});
|
|
621
623
|
}
|
|
622
|
-
const
|
|
624
|
+
const w = (t) => u[t] ?? "left", N = h.filter((t) => w(t.id) === "left").map(x), k = h.filter((t) => w(t.id) === "right").map(x), d = h.filter((t) => w(t.id) === "float");
|
|
623
625
|
return /* @__PURE__ */ _("div", {
|
|
624
626
|
className: "flow-workspace",
|
|
625
627
|
children: [!l && p, /* @__PURE__ */ _("div", {
|
|
626
628
|
className: "flow-workspace-main",
|
|
627
629
|
children: [
|
|
628
|
-
!l &&
|
|
629
|
-
tabs:
|
|
630
|
-
defaultTab:
|
|
630
|
+
!l && N.length > 0 && /* @__PURE__ */ r(q, {
|
|
631
|
+
tabs: N,
|
|
632
|
+
defaultTab: N[0]?.id,
|
|
631
633
|
resizeEdge: "right",
|
|
632
634
|
defaultWidth: 220,
|
|
633
635
|
dock: "left",
|
|
634
|
-
onDock:
|
|
635
|
-
onClose:
|
|
636
|
+
onDock: C,
|
|
637
|
+
onClose: f
|
|
636
638
|
}),
|
|
637
639
|
/* @__PURE__ */ r("div", {
|
|
638
640
|
className: "flow-stage",
|
|
639
641
|
children: o
|
|
640
642
|
}),
|
|
641
|
-
!l &&
|
|
642
|
-
tabs:
|
|
643
|
-
defaultTab:
|
|
643
|
+
!l && k.length > 0 && /* @__PURE__ */ r(q, {
|
|
644
|
+
tabs: k,
|
|
645
|
+
defaultTab: k[0]?.id,
|
|
644
646
|
resizeEdge: "left",
|
|
645
647
|
defaultWidth: 220,
|
|
646
648
|
dock: "right",
|
|
647
|
-
onDock:
|
|
648
|
-
onClose:
|
|
649
|
+
onDock: C,
|
|
650
|
+
onClose: f
|
|
649
651
|
}),
|
|
650
|
-
!l &&
|
|
651
|
-
tabs: [
|
|
652
|
+
!l && d.map((t, i) => /* @__PURE__ */ r(q, {
|
|
653
|
+
tabs: [x(t)],
|
|
652
654
|
resizeEdge: "right",
|
|
653
655
|
defaultWidth: 220,
|
|
654
656
|
dock: "float",
|
|
@@ -656,29 +658,29 @@ function tt({ children: o, toolbar: p, compact: a }) {
|
|
|
656
658
|
top: 48 + i * 40,
|
|
657
659
|
left: 24 + i * 30
|
|
658
660
|
},
|
|
659
|
-
onDock:
|
|
660
|
-
onClose:
|
|
661
|
-
onDragHintChange:
|
|
661
|
+
onDock: C,
|
|
662
|
+
onClose: f,
|
|
663
|
+
onDragHintChange: J
|
|
662
664
|
}, t.id)),
|
|
663
|
-
!l &&
|
|
664
|
-
className: `flow-dock-dropzone flow-dock-dropzone--${
|
|
665
|
-
children: /* @__PURE__ */ r("span", { children:
|
|
665
|
+
!l && z && /* @__PURE__ */ r("div", {
|
|
666
|
+
className: `flow-dock-dropzone flow-dock-dropzone--${z}`,
|
|
667
|
+
children: /* @__PURE__ */ r("span", { children: z === "left" ? "⇤ 停靠左侧" : "停靠右侧 ⇥" })
|
|
666
668
|
})
|
|
667
669
|
]
|
|
668
670
|
})]
|
|
669
671
|
});
|
|
670
672
|
}
|
|
671
673
|
function nt({ canvasRef: o, pixiRef: p, miniMapRef: a }) {
|
|
672
|
-
const { showMiniMap:
|
|
673
|
-
const
|
|
674
|
-
if (!
|
|
675
|
-
const g =
|
|
674
|
+
const { showMiniMap: v, setViewport: u, presentation: s } = Y(), l = F(!1), n = E((e, I) => {
|
|
675
|
+
const m = o.current, h = p.current, x = a.current;
|
|
676
|
+
if (!m || !h || h.destroyed || !x) return;
|
|
677
|
+
const g = m.getBoundingClientRect();
|
|
676
678
|
if (g.width === 0 || g.height === 0) return;
|
|
677
|
-
const { width: S, height:
|
|
679
|
+
const { width: S, height: K } = x.size, z = (e - g.left) / g.width * S, J = (I - g.top) / g.height * K, C = x.minimapToWorld(z, J);
|
|
678
680
|
if (!C) return;
|
|
679
|
-
const f =
|
|
681
|
+
const f = h.world.scale.x || 1, w = h.app.screen.width, N = h.app.screen.height;
|
|
680
682
|
u({
|
|
681
|
-
x:
|
|
683
|
+
x: w / 2 - C.x * f,
|
|
682
684
|
y: N / 2 - C.y * f,
|
|
683
685
|
zoom: f
|
|
684
686
|
});
|
|
@@ -687,11 +689,11 @@ function nt({ canvasRef: o, pixiRef: p, miniMapRef: a }) {
|
|
|
687
689
|
p,
|
|
688
690
|
a,
|
|
689
691
|
u
|
|
690
|
-
]),
|
|
692
|
+
]), b = E((e) => {
|
|
691
693
|
e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId), l.current = !0, n(e.clientX, e.clientY);
|
|
692
|
-
}, [n]),
|
|
694
|
+
}, [n]), c = E((e) => {
|
|
693
695
|
l.current && n(e.clientX, e.clientY);
|
|
694
|
-
}, [n]),
|
|
696
|
+
}, [n]), y = E((e) => {
|
|
695
697
|
l.current = !1;
|
|
696
698
|
try {
|
|
697
699
|
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
@@ -701,12 +703,12 @@ function nt({ canvasRef: o, pixiRef: p, miniMapRef: a }) {
|
|
|
701
703
|
return /* @__PURE__ */ r("div", {
|
|
702
704
|
className: "flow-minimap",
|
|
703
705
|
style: {
|
|
704
|
-
display:
|
|
706
|
+
display: v && !s ? void 0 : "none",
|
|
705
707
|
cursor: "pointer"
|
|
706
708
|
},
|
|
707
|
-
onPointerDown:
|
|
708
|
-
onPointerMove:
|
|
709
|
-
onPointerUp:
|
|
709
|
+
onPointerDown: b,
|
|
710
|
+
onPointerMove: c,
|
|
711
|
+
onPointerUp: y,
|
|
710
712
|
title: "点击或拖动以移动画布",
|
|
711
713
|
children: /* @__PURE__ */ r("canvas", {
|
|
712
714
|
ref: o,
|
|
@@ -721,10 +723,10 @@ function nt({ canvasRef: o, pixiRef: p, miniMapRef: a }) {
|
|
|
721
723
|
});
|
|
722
724
|
}
|
|
723
725
|
function ot(o, p) {
|
|
724
|
-
const a = `"id": "${p}"`,
|
|
725
|
-
if (
|
|
726
|
+
const a = `"id": "${p}"`, v = o.indexOf(a);
|
|
727
|
+
if (v === -1) return null;
|
|
726
728
|
let u = 0, s = -1;
|
|
727
|
-
for (let n =
|
|
729
|
+
for (let n = v; n >= 0; n--)
|
|
728
730
|
if (o[n] === "}" && u++, o[n] === "{") {
|
|
729
731
|
if (u === 0) {
|
|
730
732
|
s = n;
|
|
@@ -747,69 +749,69 @@ function ot(o, p) {
|
|
|
747
749
|
`).length
|
|
748
750
|
};
|
|
749
751
|
}
|
|
750
|
-
function
|
|
752
|
+
function re(o) {
|
|
751
753
|
o.querySelectorAll(".cm-line.flow-json-hl").forEach((p) => p.classList.remove("flow-json-hl"));
|
|
752
754
|
}
|
|
753
755
|
function st(o, p, a) {
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
756
|
+
const v = o.getView();
|
|
757
|
+
if (v)
|
|
756
758
|
for (let u = p; u <= a; u++) try {
|
|
757
|
-
const s =
|
|
759
|
+
const s = v.state.doc.line(u), l = v.domAtPos(s.from), n = l.node instanceof HTMLElement ? l.node.closest(".cm-line") : l.node.parentElement?.closest(".cm-line");
|
|
758
760
|
n && n.classList.add("flow-json-hl");
|
|
759
761
|
} catch {
|
|
760
762
|
}
|
|
761
763
|
}
|
|
762
|
-
function
|
|
763
|
-
const { setDoc: o, currentCanvasId: p, selection: a, currentCanvas:
|
|
764
|
+
function it() {
|
|
765
|
+
const { setDoc: o, currentCanvasId: p, selection: a, currentCanvas: v } = ee(), [u, s] = j(""), [l, n] = j(null), b = F(!1), c = F(null), y = F(null), e = le(() => a.nodeIds.size + a.edgeIds.size + a.lineIds.size !== 1 ? null : a.nodeIds.size === 1 ? [...a.nodeIds][0] : a.edgeIds.size === 1 ? [...a.edgeIds][0] : a.lineIds.size === 1 ? [...a.lineIds][0] : null, [a]);
|
|
764
766
|
X(() => {
|
|
765
|
-
if (
|
|
766
|
-
|
|
767
|
+
if (b.current) {
|
|
768
|
+
b.current = !1;
|
|
767
769
|
return;
|
|
768
770
|
}
|
|
769
|
-
s(JSON.stringify(
|
|
770
|
-
}, [
|
|
771
|
-
const
|
|
772
|
-
if (
|
|
773
|
-
const
|
|
771
|
+
s(JSON.stringify(v, null, 2)), n(null);
|
|
772
|
+
}, [v]), X(() => {
|
|
773
|
+
const h = y.current;
|
|
774
|
+
if (h && re(h), !e) return;
|
|
775
|
+
const x = setTimeout(() => {
|
|
774
776
|
const g = ot(u, e);
|
|
775
|
-
if (!g || !
|
|
776
|
-
const S =
|
|
777
|
+
if (!g || !y.current) return;
|
|
778
|
+
const S = c.current?.getView();
|
|
777
779
|
if (!S) return;
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
const
|
|
781
|
-
S.dispatch({ effects: Be.scrollIntoView(
|
|
780
|
+
const K = y.current, z = S.scrollDOM;
|
|
781
|
+
z.style.scrollBehavior = "smooth";
|
|
782
|
+
const J = S.state.doc.line(g.startLine);
|
|
783
|
+
S.dispatch({ effects: Be.scrollIntoView(J.from, {
|
|
782
784
|
y: "start",
|
|
783
785
|
yMargin: 0
|
|
784
786
|
}) });
|
|
785
787
|
const C = () => {
|
|
786
|
-
|
|
788
|
+
z.style.scrollBehavior = "", re(K), st(c.current, g.startLine, g.endLine);
|
|
787
789
|
};
|
|
788
790
|
let f;
|
|
789
|
-
const
|
|
791
|
+
const w = () => {
|
|
790
792
|
clearTimeout(f), f = setTimeout(C, 100);
|
|
791
793
|
};
|
|
792
|
-
|
|
793
|
-
|
|
794
|
+
z.addEventListener("scroll", w), f = setTimeout(() => {
|
|
795
|
+
z.removeEventListener("scroll", w), C();
|
|
794
796
|
}, 800);
|
|
795
797
|
}, 120);
|
|
796
|
-
return () => clearTimeout(
|
|
798
|
+
return () => clearTimeout(x);
|
|
797
799
|
}, [e, u]);
|
|
798
|
-
const
|
|
799
|
-
s(
|
|
800
|
+
const I = E((h) => {
|
|
801
|
+
s(h);
|
|
800
802
|
try {
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
+
const x = JSON.parse(h);
|
|
804
|
+
x && Array.isArray(x.nodes) && Array.isArray(x.edges) && Array.isArray(x.lines) ? (n(null), b.current = !0, o((g) => ({
|
|
803
805
|
...g,
|
|
804
806
|
canvases: {
|
|
805
807
|
...g.canvases,
|
|
806
|
-
[p]:
|
|
808
|
+
[p]: x
|
|
807
809
|
}
|
|
808
810
|
}))) : n("JSON must have nodes, edges, lines arrays");
|
|
809
|
-
} catch (
|
|
810
|
-
n(
|
|
811
|
+
} catch (x) {
|
|
812
|
+
n(x.message?.slice(0, 60) ?? "Invalid JSON");
|
|
811
813
|
}
|
|
812
|
-
}, [o, p]),
|
|
814
|
+
}, [o, p]), m = e ? a.nodeIds.has(e) ? "Node" : a.edgeIds.has(e) ? "Edge" : "Line" : null;
|
|
813
815
|
return /* @__PURE__ */ _("div", {
|
|
814
816
|
style: {
|
|
815
817
|
display: "flex",
|
|
@@ -822,7 +824,7 @@ function rt() {
|
|
|
822
824
|
className: "flow-json-header",
|
|
823
825
|
children: /* @__PURE__ */ r("span", {
|
|
824
826
|
className: "flow-json-scope",
|
|
825
|
-
children:
|
|
827
|
+
children: m ? `${m}: ${e.slice(0, 8)}` : "Canvas"
|
|
826
828
|
})
|
|
827
829
|
}),
|
|
828
830
|
l && /* @__PURE__ */ r("div", {
|
|
@@ -835,15 +837,15 @@ function rt() {
|
|
|
835
837
|
children: l
|
|
836
838
|
}),
|
|
837
839
|
/* @__PURE__ */ r("div", {
|
|
838
|
-
ref:
|
|
840
|
+
ref: y,
|
|
839
841
|
style: {
|
|
840
842
|
flex: 1,
|
|
841
843
|
minHeight: 0
|
|
842
844
|
},
|
|
843
845
|
children: /* @__PURE__ */ r(ge, {
|
|
844
|
-
ref:
|
|
846
|
+
ref: c,
|
|
845
847
|
value: u,
|
|
846
|
-
onChange:
|
|
848
|
+
onChange: I,
|
|
847
849
|
language: "json",
|
|
848
850
|
lineNumbers: !1,
|
|
849
851
|
height: "100%",
|
|
@@ -853,51 +855,51 @@ function rt() {
|
|
|
853
855
|
]
|
|
854
856
|
});
|
|
855
857
|
}
|
|
856
|
-
function
|
|
857
|
-
const { contextMenu: o, setContextMenu: p } = Y(), { doc: a, setDoc:
|
|
858
|
+
function rt() {
|
|
859
|
+
const { contextMenu: o, setContextMenu: p } = Y(), { doc: a, setDoc: v, currentCanvasId: u, pushCanvas: s, setSelection: l } = ee(), { duplicate: n } = ae();
|
|
858
860
|
if (!o) return null;
|
|
859
|
-
const
|
|
860
|
-
if (!
|
|
861
|
+
const b = a.canvases[u];
|
|
862
|
+
if (!b)
|
|
861
863
|
return p(null), null;
|
|
862
|
-
const
|
|
863
|
-
return
|
|
864
|
+
const c = o.nodeId ? b.nodes.find((e) => e.id === o.nodeId) : null, y = [];
|
|
865
|
+
return c && (y.push({
|
|
864
866
|
label: "Duplicate",
|
|
865
867
|
icon: "⧉",
|
|
866
868
|
action: () => {
|
|
867
|
-
n(24, 24, { nodeIds: /* @__PURE__ */ new Set([
|
|
869
|
+
n(24, 24, { nodeIds: /* @__PURE__ */ new Set([c.id]) });
|
|
868
870
|
}
|
|
869
|
-
}),
|
|
871
|
+
}), y.push({
|
|
870
872
|
label: "---",
|
|
871
873
|
action: () => {
|
|
872
874
|
}
|
|
873
|
-
}),
|
|
875
|
+
}), c.data.childCanvasId ? (y.push({
|
|
874
876
|
label: "Enter Sub-canvas",
|
|
875
877
|
icon: "↓",
|
|
876
878
|
action: () => {
|
|
877
|
-
s(
|
|
879
|
+
s(c.data.childCanvasId), l({
|
|
878
880
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
879
881
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
880
882
|
lineIds: /* @__PURE__ */ new Set()
|
|
881
883
|
});
|
|
882
884
|
}
|
|
883
|
-
}),
|
|
885
|
+
}), y.push({
|
|
884
886
|
label: "---",
|
|
885
887
|
action: () => {
|
|
886
888
|
}
|
|
887
|
-
}),
|
|
889
|
+
}), y.push({
|
|
888
890
|
label: "Delete Sub-canvas",
|
|
889
891
|
icon: "🗑",
|
|
890
892
|
danger: !0,
|
|
891
893
|
action: () => {
|
|
892
|
-
const e =
|
|
893
|
-
|
|
894
|
-
const
|
|
895
|
-
ce(
|
|
896
|
-
const
|
|
897
|
-
if (!
|
|
898
|
-
|
|
899
|
-
...
|
|
900
|
-
nodes:
|
|
894
|
+
const e = c.data.childCanvasId;
|
|
895
|
+
v((I) => {
|
|
896
|
+
const m = { ...I.canvases };
|
|
897
|
+
ce(m, e);
|
|
898
|
+
const h = m[u];
|
|
899
|
+
if (!h) return I;
|
|
900
|
+
m[u] = {
|
|
901
|
+
...h,
|
|
902
|
+
nodes: h.nodes.map((g) => g.id === c.id ? {
|
|
901
903
|
...g,
|
|
902
904
|
data: {
|
|
903
905
|
...g.data,
|
|
@@ -905,34 +907,34 @@ function it() {
|
|
|
905
907
|
}
|
|
906
908
|
} : g)
|
|
907
909
|
};
|
|
908
|
-
const
|
|
909
|
-
return
|
|
910
|
-
...
|
|
911
|
-
canvases:
|
|
912
|
-
stack:
|
|
910
|
+
const x = I.stack.filter((g) => m[g]);
|
|
911
|
+
return x.length === 0 && x.push(we), {
|
|
912
|
+
...I,
|
|
913
|
+
canvases: m,
|
|
914
|
+
stack: x
|
|
913
915
|
};
|
|
914
916
|
});
|
|
915
917
|
}
|
|
916
|
-
})) :
|
|
918
|
+
})) : y.push({
|
|
917
919
|
label: "Create Sub-canvas",
|
|
918
920
|
icon: "⊞",
|
|
919
921
|
action: () => {
|
|
920
922
|
const e = Q("canvas");
|
|
921
|
-
|
|
922
|
-
const
|
|
923
|
-
return
|
|
924
|
-
...
|
|
923
|
+
v((I) => {
|
|
924
|
+
const m = I.canvases[u];
|
|
925
|
+
return m ? {
|
|
926
|
+
...I,
|
|
925
927
|
canvases: {
|
|
926
|
-
...
|
|
928
|
+
...I.canvases,
|
|
927
929
|
[u]: {
|
|
928
|
-
...
|
|
929
|
-
nodes:
|
|
930
|
-
...
|
|
930
|
+
...m,
|
|
931
|
+
nodes: m.nodes.map((h) => h.id === c.id ? {
|
|
932
|
+
...h,
|
|
931
933
|
data: {
|
|
932
|
-
...
|
|
934
|
+
...h.data,
|
|
933
935
|
childCanvasId: e
|
|
934
936
|
}
|
|
935
|
-
} :
|
|
937
|
+
} : h)
|
|
936
938
|
},
|
|
937
939
|
[e]: {
|
|
938
940
|
nodes: [],
|
|
@@ -940,20 +942,20 @@ function it() {
|
|
|
940
942
|
lines: []
|
|
941
943
|
}
|
|
942
944
|
}
|
|
943
|
-
} :
|
|
945
|
+
} : I;
|
|
944
946
|
}), s(e);
|
|
945
947
|
}
|
|
946
|
-
})),
|
|
948
|
+
})), y.length === 0 ? null : /* @__PURE__ */ r(Ke, {
|
|
947
949
|
x: o.x,
|
|
948
950
|
y: o.y,
|
|
949
|
-
items:
|
|
951
|
+
items: y,
|
|
950
952
|
onClose: () => p(null)
|
|
951
953
|
});
|
|
952
954
|
}
|
|
953
955
|
function ce(o, p) {
|
|
954
956
|
const a = o[p];
|
|
955
957
|
if (a) {
|
|
956
|
-
for (const
|
|
958
|
+
for (const v of a.nodes) v.data.childCanvasId && ce(o, v.data.childCanvasId);
|
|
957
959
|
delete o[p];
|
|
958
960
|
}
|
|
959
961
|
}
|