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