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