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