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