dishui 0.0.46 → 0.0.48
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 +35 -33
- package/dist/components/Chart/index.d.ts +1 -1
- package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js +1 -2
- package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js.map +1 -1
- package/dist/components/pro/CodeEditor/themes.js +0 -25
- package/dist/components/pro/CodeEditor/themes.js.map +1 -1
- package/dist/components/pro/CodeEditor/types.d.ts +1 -1
- package/dist/components/pro/DataTable/pivotExtension.d.ts +6 -0
- package/dist/components/pro/DataTable/pivotExtension.js +31 -30
- package/dist/components/pro/DataTable/pivotExtension.js.map +1 -1
- package/dist/components/pro/Flow/Flow.js +500 -459
- package/dist/components/pro/Flow/Flow.js.map +1 -1
- package/dist/components/pro/Flow/FlowCanvas.js +526 -524
- package/dist/components/pro/Flow/FlowCanvas.js.map +1 -1
- package/dist/components/pro/Flow/canvas/GridRenderer.d.ts +3 -0
- package/dist/components/pro/Flow/canvas/GridRenderer.js +28 -23
- package/dist/components/pro/Flow/canvas/GridRenderer.js.map +1 -1
- package/dist/components/pro/Flow/canvas/MiniMapRenderer.js +18 -17
- package/dist/components/pro/Flow/canvas/MiniMapRenderer.js.map +1 -1
- package/dist/components/pro/Flow/canvas/PixiApp.d.ts +24 -0
- package/dist/components/pro/Flow/canvas/PixiApp.js +60 -15
- package/dist/components/pro/Flow/canvas/PixiApp.js.map +1 -1
- package/dist/components/pro/Flow/constants.js +7 -7
- package/dist/components/pro/Flow/constants.js.map +1 -1
- package/dist/components/pro/Flow/context/FlowAIContext.d.ts +15 -0
- package/dist/components/pro/Flow/context/FlowAIContext.js +32 -0
- package/dist/components/pro/Flow/context/FlowAIContext.js.map +1 -0
- package/dist/components/pro/Flow/context/FlowUIContext.d.ts +4 -1
- package/dist/components/pro/Flow/context/FlowUIContext.js +58 -55
- package/dist/components/pro/Flow/context/FlowUIContext.js.map +1 -1
- package/dist/components/pro/Flow/edges/EdgeRenderer.js +22 -21
- package/dist/components/pro/Flow/edges/EdgeRenderer.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useFlowImportExport.d.ts +6 -0
- package/dist/components/pro/Flow/hooks/useFlowImportExport.js +146 -89
- package/dist/components/pro/Flow/hooks/useFlowImportExport.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useLayoutActions.d.ts +2 -0
- package/dist/components/pro/Flow/hooks/useLayoutActions.js +94 -65
- package/dist/components/pro/Flow/hooks/useLayoutActions.js.map +1 -1
- package/dist/components/pro/Flow/hooks/usePdfExport.d.ts +10 -0
- package/dist/components/pro/Flow/hooks/usePdfExport.js +60 -0
- package/dist/components/pro/Flow/hooks/usePdfExport.js.map +1 -0
- package/dist/components/pro/Flow/hooks/usePixiApp.d.ts +6 -1
- package/dist/components/pro/Flow/hooks/usePixiApp.js +49 -30
- package/dist/components/pro/Flow/hooks/usePixiApp.js.map +1 -1
- package/dist/components/pro/Flow/index.d.ts +5 -2
- package/dist/components/pro/Flow/lines/FreehandTool.js +21 -20
- package/dist/components/pro/Flow/lines/FreehandTool.js.map +1 -1
- package/dist/components/pro/Flow/lines/GeometricLineTool.js +22 -18
- package/dist/components/pro/Flow/lines/GeometricLineTool.js.map +1 -1
- package/dist/components/pro/Flow/lines/LineRenderer.js +19 -18
- package/dist/components/pro/Flow/lines/LineRenderer.js.map +1 -1
- package/dist/components/pro/Flow/nodes/DataNodeView.d.ts +7 -0
- package/dist/components/pro/Flow/nodes/DataNodeView.js +217 -0
- package/dist/components/pro/Flow/nodes/DataNodeView.js.map +1 -0
- package/dist/components/pro/Flow/nodes/MediaContent.js +149 -120
- package/dist/components/pro/Flow/nodes/MediaContent.js.map +1 -1
- package/dist/components/pro/Flow/nodes/MediaOverlay.js +22 -17
- package/dist/components/pro/Flow/nodes/MediaOverlay.js.map +1 -1
- package/dist/components/pro/Flow/nodes/NodeRenderer.js +77 -76
- package/dist/components/pro/Flow/nodes/NodeRenderer.js.map +1 -1
- package/dist/components/pro/Flow/nodes/aiClient.d.ts +22 -0
- package/dist/components/pro/Flow/nodes/aiClient.js +107 -54
- package/dist/components/pro/Flow/nodes/aiClient.js.map +1 -1
- package/dist/components/pro/Flow/nodes/dataUtils.d.ts +52 -0
- package/dist/components/pro/Flow/nodes/dataUtils.js +270 -0
- package/dist/components/pro/Flow/nodes/dataUtils.js.map +1 -0
- package/dist/components/pro/Flow/nodes/svgIcons.js +59 -27
- package/dist/components/pro/Flow/nodes/svgIcons.js.map +1 -1
- package/dist/components/pro/Flow/panels/AIPanel.d.ts +2 -0
- package/dist/components/pro/Flow/panels/AIPanel.js +498 -0
- package/dist/components/pro/Flow/panels/AIPanel.js.map +1 -0
- package/dist/components/pro/Flow/panels/DataInspectorSection.d.ts +11 -0
- package/dist/components/pro/Flow/panels/DataInspectorSection.js +436 -0
- package/dist/components/pro/Flow/panels/DataInspectorSection.js.map +1 -0
- package/dist/components/pro/Flow/panels/ExpandableTextarea.d.ts +16 -0
- package/dist/components/pro/Flow/panels/ExpandableTextarea.js +65 -0
- package/dist/components/pro/Flow/panels/ExpandableTextarea.js.map +1 -0
- package/dist/components/pro/Flow/panels/FlowPanelGroup.js +51 -39
- package/dist/components/pro/Flow/panels/FlowPanelGroup.js.map +1 -1
- package/dist/components/pro/Flow/panels/FlowToolbar.d.ts +5 -1
- package/dist/components/pro/Flow/panels/FlowToolbar.js +310 -233
- package/dist/components/pro/Flow/panels/FlowToolbar.js.map +1 -1
- package/dist/components/pro/Flow/panels/InspectorPanel.js +358 -363
- package/dist/components/pro/Flow/panels/InspectorPanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/OutlinePanel.js +63 -62
- package/dist/components/pro/Flow/panels/OutlinePanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/ProjectTitle.d.ts +8 -0
- package/dist/components/pro/Flow/panels/ProjectTitle.js +49 -0
- package/dist/components/pro/Flow/panels/ProjectTitle.js.map +1 -0
- package/dist/components/pro/Flow/panels/ShapePalette.js +128 -115
- package/dist/components/pro/Flow/panels/ShapePalette.js.map +1 -1
- package/dist/components/pro/Flow/panels/toolbarIcons.d.ts +13 -0
- package/dist/components/pro/Flow/panels/toolbarIcons.js +241 -87
- package/dist/components/pro/Flow/panels/toolbarIcons.js.map +1 -1
- package/dist/components/pro/Flow/types.d.ts +77 -1
- package/dist/components/pro/Flow/types.js.map +1 -1
- package/dist/components/pro/Flow/utils/pdfExport.d.ts +20 -0
- package/dist/components/pro/Flow/utils/pdfExport.js +95 -0
- package/dist/components/pro/Flow/utils/pdfExport.js.map +1 -0
- package/dist/components/pro/Flow/utils/themeColor.d.ts +86 -0
- package/dist/components/pro/Flow/utils/themeColor.js +190 -0
- package/dist/components/pro/Flow/utils/themeColor.js.map +1 -0
- package/dist/contexts/AppContext.d.ts +1 -1
- package/dist/contexts/AppContext.js +28 -29
- package/dist/contexts/AppContext.js.map +1 -1
- package/dist/dishui.css +1 -1
- package/dist/favicon.svg +10 -0
- package/dist/flow.js +59 -51
- package/dist/index-nostyled.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/styles/themeStyles.js +6 -11
- package/dist/styles/themeStyles.js.map +1 -1
- package/dist/utils/themes.js +3 -23
- package/dist/utils/themes.js.map +1 -1
- package/package.json +17 -18
|
@@ -1,137 +1,194 @@
|
|
|
1
|
-
import { ROOT_CANVAS_ID as
|
|
2
|
-
import { useFlowContext as
|
|
3
|
-
import { generateId as
|
|
4
|
-
import { useCallback as
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
|
|
1
|
+
import { ROOT_CANVAS_ID as $, createEmptyDocument as x } from "../constants.js";
|
|
2
|
+
import { useFlowContext as C } from "../context/FlowContext.js";
|
|
3
|
+
import { generateId as N } from "../nodes/nodeUtils.js";
|
|
4
|
+
import { useCallback as k } from "react";
|
|
5
|
+
var S = 1;
|
|
6
|
+
function F(s, a = "flowchart") {
|
|
7
|
+
return (s ?? "").trim().replace(/[\\/:*?"<>|]+/g, "-").replace(/\s+/g, " ").trim() || a;
|
|
8
|
+
}
|
|
9
|
+
function J() {
|
|
10
|
+
const { doc: s, setDoc: a } = C();
|
|
8
11
|
return {
|
|
9
|
-
exportJSON:
|
|
10
|
-
const
|
|
11
|
-
version:
|
|
12
|
-
canvases:
|
|
13
|
-
stack:
|
|
12
|
+
exportJSON: k(() => {
|
|
13
|
+
const e = {
|
|
14
|
+
version: S,
|
|
15
|
+
canvases: s.canvases,
|
|
16
|
+
stack: s.stack,
|
|
17
|
+
title: s.title
|
|
14
18
|
};
|
|
15
|
-
return JSON.stringify(
|
|
16
|
-
}, [
|
|
17
|
-
importJSON:
|
|
19
|
+
return JSON.stringify(e, null, 2);
|
|
20
|
+
}, [s]),
|
|
21
|
+
importJSON: k((e) => {
|
|
18
22
|
try {
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
|
|
22
|
-
canvases:
|
|
23
|
-
stack:
|
|
23
|
+
const n = JSON.parse(e);
|
|
24
|
+
if (!n.canvases || !n.stack) throw new Error("Invalid document format");
|
|
25
|
+
a({
|
|
26
|
+
canvases: n.canvases,
|
|
27
|
+
stack: n.stack,
|
|
28
|
+
title: n.title
|
|
24
29
|
});
|
|
25
|
-
} catch (
|
|
26
|
-
console.error("Failed to import JSON:",
|
|
30
|
+
} catch (n) {
|
|
31
|
+
console.error("Failed to import JSON:", n);
|
|
27
32
|
}
|
|
28
|
-
}, [
|
|
29
|
-
importMermaid:
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
}, [a]),
|
|
34
|
+
importMermaid: k((e) => {
|
|
35
|
+
const n = R(e);
|
|
36
|
+
a(n);
|
|
37
|
+
}, [a]),
|
|
38
|
+
exportMarkdown: k(() => O(s), [s]),
|
|
39
|
+
clearDocument: k(() => {
|
|
40
|
+
a(x());
|
|
41
|
+
}, [a])
|
|
36
42
|
};
|
|
37
43
|
}
|
|
38
|
-
function
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
function O(s) {
|
|
45
|
+
const a = [], e = (i) => {
|
|
46
|
+
const l = (i.data.label ?? "").trim();
|
|
47
|
+
return l ? l.replace(/\s+/g, " ") : i.type === "mediaNode" ? `(${i.data.mediaKind ?? "media"})` : `(${i.type})`;
|
|
48
|
+
}, n = (i, l, h) => {
|
|
49
|
+
const m = s.canvases[i];
|
|
50
|
+
if (!m) return;
|
|
51
|
+
const b = new Map(m.nodes.map((t) => [t.id, t])), o = /* @__PURE__ */ new Map();
|
|
52
|
+
for (const t of m.nodes) {
|
|
53
|
+
const r = t.parentId && b.has(t.parentId) ? t.parentId : void 0, d = o.get(r) ?? [];
|
|
54
|
+
d.push(t), o.set(r, d);
|
|
55
|
+
}
|
|
56
|
+
const p = (t, r) => {
|
|
57
|
+
const d = " ".repeat(r), c = t.data.isGroup || t.type === "flowGroup" || t.type === "geometryGroup" ? `**${e(t)}**` : e(t);
|
|
58
|
+
if (a.push(`${d}- ${c}`), t.type === "mediaNode" && t.data.mediaKind) {
|
|
59
|
+
const g = t.data.mediaKind;
|
|
60
|
+
if (g === "data" && t.data.dataConfig) {
|
|
61
|
+
const y = t.data.dataConfig, M = y.columns.map((I) => I.label ?? I.key).join(", ");
|
|
62
|
+
a.push(`${d} - 数据表:${y.rows.length} 行 · 列(${M})`);
|
|
63
|
+
} else if (t.data.mediaContent && g !== "image" && g !== "model3d") {
|
|
64
|
+
const y = t.data.mediaContent.trim().split(`
|
|
65
|
+
`)[0].slice(0, 80);
|
|
66
|
+
y && a.push(`${d} - ${g}: ${y}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const v = o.get(t.id) ?? [];
|
|
70
|
+
for (const g of v) p(g, r + 1);
|
|
71
|
+
const w = t.data.childCanvasId;
|
|
72
|
+
w && s.canvases[w] && !h.has(w) && (h.add(w), n(w, l + 1, h));
|
|
73
|
+
}, u = o.get(void 0) ?? [];
|
|
74
|
+
for (const t of u) p(t, 0);
|
|
75
|
+
if (m.edges.length > 0) {
|
|
76
|
+
a.push(""), a.push(`${"#".repeat(Math.min(6, l + 1))} 连接关系`);
|
|
77
|
+
for (const t of m.edges) {
|
|
78
|
+
const r = b.get(t.source), d = b.get(t.target);
|
|
79
|
+
if (!r || !d) continue;
|
|
80
|
+
const c = t.data.labelText ? ` (${t.data.labelText})` : "";
|
|
81
|
+
a.push(`- ${e(r)} → ${e(d)}${c}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, f = /* @__PURE__ */ new Set([$]);
|
|
85
|
+
a.push("# 流程图"), a.push(""), n($, 1, f);
|
|
86
|
+
for (const i of Object.keys(s.canvases))
|
|
87
|
+
f.has(i) || (f.add(i), a.push(""), a.push(`## 画布 ${i}`), a.push(""), n(i, 2, f));
|
|
88
|
+
return a.join(`
|
|
89
|
+
`).replace(/\n{3,}/g, `
|
|
90
|
+
|
|
91
|
+
`).trim() + `
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
function R(s) {
|
|
95
|
+
const a = s.split(`
|
|
96
|
+
`).map((o) => o.trim()).filter((o) => o && !o.startsWith("%%")), e = /* @__PURE__ */ new Map(), n = [];
|
|
97
|
+
let f = !1;
|
|
98
|
+
for (const o of a) {
|
|
99
|
+
if (/^(graph|flowchart)\s+(LR|RL)/i.test(o)) {
|
|
100
|
+
f = !0;
|
|
45
101
|
continue;
|
|
46
102
|
}
|
|
47
|
-
if (/^(graph|flowchart)\s+/i.test(
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
const [,
|
|
51
|
-
|
|
52
|
-
id:
|
|
53
|
-
label: c
|
|
54
|
-
}), u && !t.has(r) && t.set(r, {
|
|
55
|
-
id: r,
|
|
56
|
-
label: u
|
|
57
|
-
}), t.has(o) || t.set(o, {
|
|
58
|
-
id: o,
|
|
59
|
-
label: o
|
|
60
|
-
}), t.has(r) || t.set(r, {
|
|
61
|
-
id: r,
|
|
103
|
+
if (/^(graph|flowchart)\s+/i.test(o)) continue;
|
|
104
|
+
const p = o.match(/^(\w+)(?:\[([^\]]*)\])?\s*(-->|---|-\.->|==>)(?:\|([^|]*)\|)?\s*(\w+)(?:\[([^\]]*)\])?/);
|
|
105
|
+
if (p) {
|
|
106
|
+
const [, t, r, , d, c, v] = p;
|
|
107
|
+
r && !e.has(t) && e.set(t, {
|
|
108
|
+
id: t,
|
|
62
109
|
label: r
|
|
63
|
-
}),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
110
|
+
}), v && !e.has(c) && e.set(c, {
|
|
111
|
+
id: c,
|
|
112
|
+
label: v
|
|
113
|
+
}), e.has(t) || e.set(t, {
|
|
114
|
+
id: t,
|
|
115
|
+
label: t
|
|
116
|
+
}), e.has(c) || e.set(c, {
|
|
117
|
+
id: c,
|
|
118
|
+
label: c
|
|
119
|
+
}), n.push({
|
|
120
|
+
from: t,
|
|
121
|
+
to: c,
|
|
122
|
+
label: d?.trim()
|
|
67
123
|
});
|
|
68
124
|
continue;
|
|
69
125
|
}
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
const [,
|
|
73
|
-
|
|
74
|
-
id:
|
|
75
|
-
label:
|
|
126
|
+
const u = o.match(/^(\w+)\[([^\]]*)\]/);
|
|
127
|
+
if (u) {
|
|
128
|
+
const [, t, r] = u;
|
|
129
|
+
e.has(t) || e.set(t, {
|
|
130
|
+
id: t,
|
|
131
|
+
label: r
|
|
76
132
|
});
|
|
77
133
|
}
|
|
78
134
|
}
|
|
79
|
-
const
|
|
135
|
+
const i = [...e.keys()], l = f ? i.length : Math.ceil(Math.sqrt(i.length)), h = {
|
|
80
136
|
x: 200,
|
|
81
137
|
y: 120
|
|
82
|
-
},
|
|
83
|
-
const
|
|
138
|
+
}, m = i.map((o, p) => {
|
|
139
|
+
const u = p % l, t = Math.floor(p / l), r = e.get(o);
|
|
84
140
|
return {
|
|
85
|
-
id:
|
|
141
|
+
id: r.id,
|
|
86
142
|
type: "shapeRoundRect",
|
|
87
143
|
position: {
|
|
88
|
-
x: 100 +
|
|
89
|
-
y: 100 +
|
|
144
|
+
x: 100 + u * h.x,
|
|
145
|
+
y: 100 + t * h.y
|
|
90
146
|
},
|
|
91
147
|
width: 140,
|
|
92
148
|
height: 60,
|
|
93
149
|
data: {
|
|
94
|
-
label:
|
|
95
|
-
fill: "
|
|
96
|
-
stroke: "
|
|
150
|
+
label: r.label,
|
|
151
|
+
fill: "theme:base-100",
|
|
152
|
+
stroke: "theme:base-content",
|
|
97
153
|
strokeWidth: 2,
|
|
98
|
-
color: "
|
|
154
|
+
color: "theme:base-content",
|
|
99
155
|
fontSize: 14
|
|
100
156
|
}
|
|
101
157
|
};
|
|
102
|
-
}), b =
|
|
103
|
-
id:
|
|
104
|
-
source:
|
|
105
|
-
target:
|
|
158
|
+
}), b = n.map((o) => ({
|
|
159
|
+
id: N("edge"),
|
|
160
|
+
source: o.from,
|
|
161
|
+
target: o.to,
|
|
106
162
|
type: "smoothstep",
|
|
107
163
|
data: {
|
|
108
|
-
strokeColor: "
|
|
164
|
+
strokeColor: "theme:base-content",
|
|
109
165
|
strokeWidth: 2,
|
|
110
166
|
lineStyle: "solid",
|
|
111
167
|
markerEnd: "arrowclosed",
|
|
112
|
-
labelText:
|
|
168
|
+
labelText: o.label
|
|
113
169
|
}
|
|
114
170
|
}));
|
|
115
171
|
return {
|
|
116
|
-
canvases: { [
|
|
117
|
-
nodes:
|
|
172
|
+
canvases: { [$]: {
|
|
173
|
+
nodes: m,
|
|
118
174
|
edges: b,
|
|
119
175
|
lines: []
|
|
120
176
|
} },
|
|
121
|
-
stack: [
|
|
177
|
+
stack: [$]
|
|
122
178
|
};
|
|
123
179
|
}
|
|
124
|
-
async function
|
|
125
|
-
return
|
|
180
|
+
async function G(s) {
|
|
181
|
+
return s.toDataURL("image/png");
|
|
126
182
|
}
|
|
127
|
-
function
|
|
128
|
-
const
|
|
129
|
-
|
|
183
|
+
function j(s, a) {
|
|
184
|
+
const e = document.createElement("a");
|
|
185
|
+
e.href = s, e.download = a, document.body.appendChild(e), e.click(), document.body.removeChild(e);
|
|
130
186
|
}
|
|
131
187
|
export {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
188
|
+
j as downloadDataURL,
|
|
189
|
+
G as exportCanvasToPNG,
|
|
190
|
+
F as safeFileBaseName,
|
|
191
|
+
J as useFlowImportExport
|
|
135
192
|
};
|
|
136
193
|
|
|
137
194
|
//# sourceMappingURL=useFlowImportExport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFlowImportExport.js","names":[],"sources":["../../../../../src/components/pro/Flow/hooks/useFlowImportExport.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useFlowContext } from '../context/FlowContext';\nimport type { FlowDocument, FlowCanvasData, FlowNode, FlowEdge, FlowLine } from '../types';\nimport { createEmptyDocument, ROOT_CANVAS_ID } from '../constants';\nimport { generateId } from '../nodes/nodeUtils';\n\nconst PERSIST_VERSION = 1;\n\ninterface SerializedDocument {\n version: number;\n canvases: Record<string, FlowCanvasData>;\n stack: string[];\n}\n\n/**\n * Serialize/deserialize FlowDocument to/from JSON.\n * Also includes Mermaid flowchart import.\n */\nexport function useFlowImportExport() {\n const { doc, setDoc } = useFlowContext();\n\n const exportJSON = useCallback((): string => {\n const serialized: SerializedDocument = {\n version: PERSIST_VERSION,\n canvases: doc.canvases,\n stack: doc.stack,\n };\n return JSON.stringify(serialized, null, 2);\n }, [doc]);\n\n const importJSON = useCallback((json: string) => {\n try {\n const parsed = JSON.parse(json) as SerializedDocument;\n if (!parsed.canvases || !parsed.stack) throw new Error('Invalid document format');\n setDoc({\n canvases: parsed.canvases,\n stack: parsed.stack,\n });\n } catch (err) {\n console.error('Failed to import JSON:', err);\n }\n }, [setDoc]);\n\n const importMermaid = useCallback((mermaidCode: string) => {\n const doc = parseMermaidFlowchart(mermaidCode);\n setDoc(doc);\n }, [setDoc]);\n\n const clearDocument = useCallback(() => {\n setDoc(createEmptyDocument());\n }, [setDoc]);\n\n return { exportJSON, importJSON, importMermaid, clearDocument };\n}\n\n/**\n * Simple Mermaid flowchart parser.\n * Handles basic `graph TD` / `flowchart LR` syntax with node definitions and edges.\n */\nfunction parseMermaidFlowchart(code: string): FlowDocument {\n const lines = code.split('\\n').map(l => l.trim()).filter(l => l && !l.startsWith('%%'));\n\n const nodeMap = new Map<string, { id: string; label: string }>();\n const edges: Array<{ from: string; to: string; label?: string }> = [];\n\n let isHorizontal = false;\n\n for (const line of lines) {\n // Detect direction\n if (/^(graph|flowchart)\\s+(LR|RL)/i.test(line)) {\n isHorizontal = true;\n continue;\n }\n if (/^(graph|flowchart)\\s+/i.test(line)) continue;\n\n // Edge patterns: A --> B, A -->|label| B, A --- B\n const edgeMatch = line.match(/^(\\w+)(?:\\[([^\\]]*)\\])?\\s*(-->|---|-\\.->|==>)(?:\\|([^|]*)\\|)?\\s*(\\w+)(?:\\[([^\\]]*)\\])?/);\n if (edgeMatch) {\n const [, fromId, fromLabel, , edgeLabel, toId, toLabel] = edgeMatch;\n if (fromLabel && !nodeMap.has(fromId)) nodeMap.set(fromId, { id: fromId, label: fromLabel });\n if (toLabel && !nodeMap.has(toId)) nodeMap.set(toId, { id: toId, label: toLabel });\n if (!nodeMap.has(fromId)) nodeMap.set(fromId, { id: fromId, label: fromId });\n if (!nodeMap.has(toId)) nodeMap.set(toId, { id: toId, label: toId });\n edges.push({ from: fromId, to: toId, label: edgeLabel?.trim() });\n continue;\n }\n\n // Standalone node: A[Label]\n const nodeMatch = line.match(/^(\\w+)\\[([^\\]]*)\\]/);\n if (nodeMatch) {\n const [, id, label] = nodeMatch;\n if (!nodeMap.has(id)) nodeMap.set(id, { id, label });\n }\n }\n\n // Layout: simple grid placement\n const nodeIds = [...nodeMap.keys()];\n const cols = isHorizontal ? nodeIds.length : Math.ceil(Math.sqrt(nodeIds.length));\n const spacing = { x: 200, y: 120 };\n\n const nodes: FlowNode[] = nodeIds.map((id, i) => {\n const col = i % cols;\n const row = Math.floor(i / cols);\n const data = nodeMap.get(id)!;\n return {\n id: data.id,\n type: 'shapeRoundRect' as const,\n position: { x: 100 + col * spacing.x, y: 100 + row * spacing.y },\n width: 140,\n height: 60,\n data: {\n label: data.label,\n fill: '#ffffff',\n stroke: '#374151',\n strokeWidth: 2,\n color: '#111827',\n fontSize: 14,\n },\n };\n });\n\n const flowEdges: FlowEdge[] = edges.map((e) => ({\n id: generateId('edge'),\n source: e.from,\n target: e.to,\n type: 'smoothstep' as const,\n data: {\n strokeColor: '#374151',\n strokeWidth: 2,\n lineStyle: 'solid' as const,\n markerEnd: 'arrowclosed' as const,\n labelText: e.label,\n },\n }));\n\n return {\n canvases: {\n [ROOT_CANVAS_ID]: { nodes, edges: flowEdges, lines: [] },\n },\n stack: [ROOT_CANVAS_ID],\n };\n}\n\n/**\n * Export the PixiJS canvas as PNG data URL.\n */\nexport async function exportCanvasToPNG(canvas: HTMLCanvasElement): Promise<string> {\n return canvas.toDataURL('image/png');\n}\n\n/**\n * Download a data URL as a file.\n */\nexport function downloadDataURL(dataUrl: string, filename: string): void {\n const a = document.createElement('a');\n a.href = dataUrl;\n a.download = filename;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n}\n"],"mappings":";;;;AAMA,IAAM,IAAkB;AAYxB,SAAgB,IAAsB;AACpC,QAAM,EAAE,KAAA,GAAK,QAAA,EAAA,IAAW,EAAe;AAiCvC,SAAO;AAAA,IAAE,YA/BU,EAAA,MAA0B;AAC3C,YAAM,IAAiC;AAAA,QACrC,SAAS;AAAA,QACT,UAAU,EAAI;AAAA,QACd,OAAO,EAAI;AAAA,MACb;AACA,aAAO,KAAK,UAAU,GAAY,MAAM,CAAC;AAAA,IAC3C,GAAG,CAAC,CAAG,CAwBE;AAAA,IAAY,YAtBF,EAAA,CAAa,MAAiB;AAC/C,UAAI;AACF,cAAM,IAAS,KAAK,MAAM,CAAI;AAC9B,YAAI,CA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;AAAA,IACF;AAAA,EACF,CAAC,GAEK,IAAwB,EAAM,IAAA,CAAK,OAAO;AAAA,IAC9C,IAAI,EAAW,MAAM;AAAA,IACrB,QAAQ,EAAE;AAAA,IACV,QAAQ,EAAE;AAAA,IACV,MAAM;AAAA,IACN,MAAM;AAAA,MACJ,aAAa;AAAA,MACb,aAAa;AAAA,MACb,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW,EAAE;AAAA,IACf;AAAA,EACF,EAAE;AAEF,SAAO;AAAA,IACL,UAAU,EAAA,CACP,CAAA,GAAiB;AAAA,MAAE,OAAA;AAAA,MAAO,OAAO;AAAA,MAAW,OAAO,CAAC;AAAA,IAAE,EACzD;AAAA,IACA,OAAO,CAAC,CAAc;AAAA,EACxB;AACF;AAKA,eAAsB,EAAkB,GAA4C;AAClF,SAAO,EAAO,UAAU,WAAW;AACrC;AAKA,SAAgB,EAAgB,GAAiB,GAAwB;AACvE,QAAM,IAAI,SAAS,cAAc,GAAG;AACpC,EAAA,EAAE,OAAO,GACT,EAAE,WAAW,GACb,SAAS,KAAK,YAAY,CAAC,GAC3B,EAAE,MAAM,GACR,SAAS,KAAK,YAAY,CAAC;AAC7B"}
|
|
1
|
+
{"version":3,"file":"useFlowImportExport.js","names":[],"sources":["../../../../../src/components/pro/Flow/hooks/useFlowImportExport.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useFlowContext } from '../context/FlowContext';\nimport type { FlowDocument, FlowCanvasData, FlowNode, FlowEdge, FlowLine } from '../types';\nimport { createEmptyDocument, ROOT_CANVAS_ID } from '../constants';\nimport { generateId } from '../nodes/nodeUtils';\n\nconst PERSIST_VERSION = 1;\n\ninterface SerializedDocument {\n version: number;\n canvases: Record<string, FlowCanvasData>;\n stack: string[];\n title?: string;\n}\n\n/**\n * Sanitize a project title into a safe file base name, falling back to a\n * default when empty. Shared by all export paths so filenames stay consistent.\n */\nexport function safeFileBaseName(title: string | undefined, fallback = 'flowchart'): string {\n const name = (title ?? '').trim().replace(/[\\\\/:*?\"<>|]+/g, '-').replace(/\\s+/g, ' ').trim();\n return name || fallback;\n}\n\n/**\n * Serialize/deserialize FlowDocument to/from JSON.\n * Also includes Mermaid flowchart import.\n */\nexport function useFlowImportExport() {\n const { doc, setDoc } = useFlowContext();\n\n const exportJSON = useCallback((): string => {\n const serialized: SerializedDocument = {\n version: PERSIST_VERSION,\n canvases: doc.canvases,\n stack: doc.stack,\n title: doc.title,\n };\n return JSON.stringify(serialized, null, 2);\n }, [doc]);\n\n const importJSON = useCallback((json: string) => {\n try {\n const parsed = JSON.parse(json) as SerializedDocument;\n if (!parsed.canvases || !parsed.stack) throw new Error('Invalid document format');\n setDoc({\n canvases: parsed.canvases,\n stack: parsed.stack,\n title: parsed.title,\n });\n } catch (err) {\n console.error('Failed to import JSON:', err);\n }\n }, [setDoc]);\n\n const importMermaid = useCallback((mermaidCode: string) => {\n const doc = parseMermaidFlowchart(mermaidCode);\n setDoc(doc);\n }, [setDoc]);\n\n const exportMarkdown = useCallback((): string => {\n return documentToMarkdown(doc);\n }, [doc]);\n\n const clearDocument = useCallback(() => {\n setDoc(createEmptyDocument());\n }, [setDoc]);\n\n return { exportJSON, importJSON, importMermaid, exportMarkdown, clearDocument };\n}\n\n/**\n * Render a FlowDocument as a Markdown outline describing the node hierarchy\n * and connections. Groups become sections with their children nested beneath;\n * edges are listed as a connection summary per canvas. Sub-canvases (drill-down\n * nodes) are rendered as nested sections.\n */\nfunction documentToMarkdown(doc: FlowDocument): string {\n const lines: string[] = [];\n\n const nodeLabel = (n: FlowNode): string => {\n const raw = (n.data.label ?? '').trim();\n if (raw) return raw.replace(/\\s+/g, ' ');\n if (n.type === 'mediaNode') return `(${n.data.mediaKind ?? 'media'})`;\n return `(${n.type})`;\n };\n\n const renderCanvas = (canvasId: string, headingLevel: number, seenCanvases: Set<string>) => {\n const canvas = doc.canvases[canvasId];\n if (!canvas) return;\n\n // Index nodes by id and by parent for hierarchy traversal.\n const byId = new Map(canvas.nodes.map((n) => [n.id, n]));\n const childrenOf = new Map<string | undefined, FlowNode[]>();\n for (const n of canvas.nodes) {\n const key = n.parentId && byId.has(n.parentId) ? n.parentId : undefined;\n const list = childrenOf.get(key) ?? [];\n list.push(n);\n childrenOf.set(key, list);\n }\n\n const emitNode = (node: FlowNode, depth: number) => {\n const indent = ' '.repeat(depth);\n const isGroup = node.data.isGroup || node.type === 'flowGroup' || node.type === 'geometryGroup';\n const bullet = isGroup ? `**${nodeLabel(node)}**` : nodeLabel(node);\n lines.push(`${indent}- ${bullet}`);\n\n // Media content (markdown/data/etc.) as a short description line.\n if (node.type === 'mediaNode' && node.data.mediaKind) {\n const kind = node.data.mediaKind;\n if (kind === 'data' && node.data.dataConfig) {\n const cfg = node.data.dataConfig;\n const cols = cfg.columns.map((c) => c.label ?? c.key).join(', ');\n lines.push(`${indent} - 数据表:${cfg.rows.length} 行 · 列(${cols})`);\n } else if (node.data.mediaContent && kind !== 'image' && kind !== 'model3d') {\n const preview = node.data.mediaContent.trim().split('\\n')[0].slice(0, 80);\n if (preview) lines.push(`${indent} - ${kind}: ${preview}`);\n }\n }\n\n // Recurse into visual group children.\n const kids = childrenOf.get(node.id) ?? [];\n for (const kid of kids) emitNode(kid, depth + 1);\n\n // Recurse into a drill-down sub-canvas, if any.\n const childCanvasId = node.data.childCanvasId;\n if (childCanvasId && doc.canvases[childCanvasId] && !seenCanvases.has(childCanvasId)) {\n seenCanvases.add(childCanvasId);\n renderCanvas(childCanvasId, headingLevel + 1, seenCanvases);\n }\n };\n\n const roots = childrenOf.get(undefined) ?? [];\n for (const root of roots) emitNode(root, 0);\n\n // Connections summary.\n if (canvas.edges.length > 0) {\n lines.push('');\n lines.push(`${'#'.repeat(Math.min(6, headingLevel + 1))} 连接关系`);\n for (const edge of canvas.edges) {\n const from = byId.get(edge.source);\n const to = byId.get(edge.target);\n if (!from || !to) continue;\n const edgeLabel = edge.data.labelText ? ` (${edge.data.labelText})` : '';\n lines.push(`- ${nodeLabel(from)} → ${nodeLabel(to)}${edgeLabel}`);\n }\n }\n };\n\n const seen = new Set<string>([ROOT_CANVAS_ID]);\n lines.push('# 流程图');\n lines.push('');\n renderCanvas(ROOT_CANVAS_ID, 1, seen);\n\n // Any orphan canvases not reached via drill-down nodes.\n for (const canvasId of Object.keys(doc.canvases)) {\n if (seen.has(canvasId)) continue;\n seen.add(canvasId);\n lines.push('');\n lines.push(`## 画布 ${canvasId}`);\n lines.push('');\n renderCanvas(canvasId, 2, seen);\n }\n\n return lines.join('\\n').replace(/\\n{3,}/g, '\\n\\n').trim() + '\\n';\n}\n\n/**\n * Simple Mermaid flowchart parser.\n * Handles basic `graph TD` / `flowchart LR` syntax with node definitions and edges.\n */\nfunction parseMermaidFlowchart(code: string): FlowDocument {\n const lines = code.split('\\n').map(l => l.trim()).filter(l => l && !l.startsWith('%%'));\n\n const nodeMap = new Map<string, { id: string; label: string }>();\n const edges: Array<{ from: string; to: string; label?: string }> = [];\n\n let isHorizontal = false;\n\n for (const line of lines) {\n // Detect direction\n if (/^(graph|flowchart)\\s+(LR|RL)/i.test(line)) {\n isHorizontal = true;\n continue;\n }\n if (/^(graph|flowchart)\\s+/i.test(line)) continue;\n\n // Edge patterns: A --> B, A -->|label| B, A --- B\n const edgeMatch = line.match(/^(\\w+)(?:\\[([^\\]]*)\\])?\\s*(-->|---|-\\.->|==>)(?:\\|([^|]*)\\|)?\\s*(\\w+)(?:\\[([^\\]]*)\\])?/);\n if (edgeMatch) {\n const [, fromId, fromLabel, , edgeLabel, toId, toLabel] = edgeMatch;\n if (fromLabel && !nodeMap.has(fromId)) nodeMap.set(fromId, { id: fromId, label: fromLabel });\n if (toLabel && !nodeMap.has(toId)) nodeMap.set(toId, { id: toId, label: toLabel });\n if (!nodeMap.has(fromId)) nodeMap.set(fromId, { id: fromId, label: fromId });\n if (!nodeMap.has(toId)) nodeMap.set(toId, { id: toId, label: toId });\n edges.push({ from: fromId, to: toId, label: edgeLabel?.trim() });\n continue;\n }\n\n // Standalone node: A[Label]\n const nodeMatch = line.match(/^(\\w+)\\[([^\\]]*)\\]/);\n if (nodeMatch) {\n const [, id, label] = nodeMatch;\n if (!nodeMap.has(id)) nodeMap.set(id, { id, label });\n }\n }\n\n // Layout: simple grid placement\n const nodeIds = [...nodeMap.keys()];\n const cols = isHorizontal ? nodeIds.length : Math.ceil(Math.sqrt(nodeIds.length));\n const spacing = { x: 200, y: 120 };\n\n const nodes: FlowNode[] = nodeIds.map((id, i) => {\n const col = i % cols;\n const row = Math.floor(i / cols);\n const data = nodeMap.get(id)!;\n return {\n id: data.id,\n type: 'shapeRoundRect' as const,\n position: { x: 100 + col * spacing.x, y: 100 + row * spacing.y },\n width: 140,\n height: 60,\n data: {\n label: data.label,\n fill: 'theme:base-100',\n stroke: 'theme:base-content',\n strokeWidth: 2,\n color: 'theme:base-content',\n fontSize: 14,\n },\n };\n });\n\n const flowEdges: FlowEdge[] = edges.map((e) => ({\n id: generateId('edge'),\n source: e.from,\n target: e.to,\n type: 'smoothstep' as const,\n data: {\n strokeColor: 'theme:base-content',\n strokeWidth: 2,\n lineStyle: 'solid' as const,\n markerEnd: 'arrowclosed' as const,\n labelText: e.label,\n },\n }));\n\n return {\n canvases: {\n [ROOT_CANVAS_ID]: { nodes, edges: flowEdges, lines: [] },\n },\n stack: [ROOT_CANVAS_ID],\n };\n}\n\n/**\n * Export the PixiJS canvas as PNG data URL.\n */\nexport async function exportCanvasToPNG(canvas: HTMLCanvasElement): Promise<string> {\n return canvas.toDataURL('image/png');\n}\n\n/**\n * Download a data URL as a file.\n */\nexport function downloadDataURL(dataUrl: string, filename: string): void {\n const a = document.createElement('a');\n a.href = dataUrl;\n a.download = filename;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n}\n"],"mappings":";;;;AAMA,IAAM,IAAkB;AAaxB,SAAgB,EAAiB,GAA2B,IAAW,aAAqB;AAE1F,UADc,KAAS,IAAI,KAAK,EAAE,QAAQ,kBAAkB,GAAG,EAAE,QAAQ,QAAQ,G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EAAE;AAEF,SAAO;AAAA,IACL,UAAU,EAAA,CACP,CAAA,GAAiB;AAAA,MAAE,OAAA;AAAA,MAAO,OAAO;AAAA,MAAW,OAAO,CAAC;AAAA,IAAE,EACzD;AAAA,IACA,OAAO,CAAC,CAAc;AAAA,EACxB;AACF;AAKA,eAAsB,EAAkB,GAA4C;AAClF,SAAO,EAAO,UAAU,WAAW;AACrC;AAKA,SAAgB,EAAgB,GAAiB,GAAwB;AACvE,QAAM,IAAI,SAAS,cAAc,GAAG;AACpC,EAAA,EAAE,OAAO,GACT,EAAE,WAAW,GACb,SAAS,KAAK,YAAY,CAAC,GAC3B,EAAE,MAAM,GACR,SAAS,KAAK,YAAY,CAAC;AAC7B"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
type Align = 'left' | 'center-h' | 'right' | 'top' | 'center-v' | 'bottom';
|
|
2
2
|
type Distribute = 'horizontal' | 'vertical';
|
|
3
|
+
type LayerMode = 'front' | 'back' | 'up' | 'down';
|
|
3
4
|
export declare function useLayoutActions(): {
|
|
4
5
|
align: (direction: Align) => void;
|
|
5
6
|
distribute: (direction: Distribute) => void;
|
|
7
|
+
changeZIndex: (mode: LayerMode) => void;
|
|
6
8
|
};
|
|
7
9
|
export {};
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { useFlowContext as
|
|
2
|
-
import { useCallback as
|
|
3
|
-
function
|
|
4
|
-
const { setDoc:
|
|
1
|
+
import { useFlowContext as M } from "../context/FlowContext.js";
|
|
2
|
+
import { useCallback as b } from "react";
|
|
3
|
+
function I() {
|
|
4
|
+
const { setDoc: u, currentCanvasId: h, selection: g, currentCanvas: m } = M();
|
|
5
5
|
return {
|
|
6
|
-
align:
|
|
7
|
-
const p =
|
|
6
|
+
align: b((l) => {
|
|
7
|
+
const p = g.nodeIds;
|
|
8
8
|
if (p.size < 2) return;
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
9
|
+
const a = m.nodes.filter((t) => p.has(t.id));
|
|
10
|
+
if (a.length < 2) return;
|
|
11
11
|
let e;
|
|
12
|
-
switch (
|
|
12
|
+
switch (l) {
|
|
13
13
|
case "left":
|
|
14
|
-
e = Math.min(...
|
|
14
|
+
e = Math.min(...a.map((t) => t.position.x));
|
|
15
15
|
break;
|
|
16
16
|
case "right":
|
|
17
|
-
e = Math.max(...
|
|
17
|
+
e = Math.max(...a.map((t) => t.position.x + t.width));
|
|
18
18
|
break;
|
|
19
19
|
case "center-h":
|
|
20
|
-
e =
|
|
20
|
+
e = a.reduce((t, i) => t + i.position.x + i.width / 2, 0) / a.length;
|
|
21
21
|
break;
|
|
22
22
|
case "top":
|
|
23
|
-
e = Math.min(...
|
|
23
|
+
e = Math.min(...a.map((t) => t.position.y));
|
|
24
24
|
break;
|
|
25
25
|
case "bottom":
|
|
26
|
-
e = Math.max(...
|
|
26
|
+
e = Math.max(...a.map((t) => t.position.y + t.height));
|
|
27
27
|
break;
|
|
28
28
|
case "center-v":
|
|
29
|
-
e =
|
|
29
|
+
e = a.reduce((t, i) => t + i.position.y + i.height / 2, 0) / a.length;
|
|
30
30
|
break;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
const i = t.canvases[
|
|
32
|
+
u((t) => {
|
|
33
|
+
const i = t.canvases[h];
|
|
34
34
|
return i ? {
|
|
35
35
|
...t,
|
|
36
36
|
canvases: {
|
|
37
37
|
...t.canvases,
|
|
38
|
-
[
|
|
38
|
+
[h]: {
|
|
39
39
|
...i,
|
|
40
40
|
nodes: i.nodes.map((o) => {
|
|
41
41
|
if (!p.has(o.id)) return o;
|
|
42
|
-
let
|
|
43
|
-
switch (
|
|
42
|
+
let d = o.position.x, c = o.position.y;
|
|
43
|
+
switch (l) {
|
|
44
44
|
case "left":
|
|
45
|
-
|
|
45
|
+
d = e;
|
|
46
46
|
break;
|
|
47
47
|
case "right":
|
|
48
|
-
|
|
48
|
+
d = e - o.width;
|
|
49
49
|
break;
|
|
50
50
|
case "center-h":
|
|
51
|
-
|
|
51
|
+
d = e - o.width / 2;
|
|
52
52
|
break;
|
|
53
53
|
case "top":
|
|
54
54
|
c = e;
|
|
@@ -63,7 +63,7 @@ function v() {
|
|
|
63
63
|
return {
|
|
64
64
|
...o,
|
|
65
65
|
position: {
|
|
66
|
-
x:
|
|
66
|
+
x: d,
|
|
67
67
|
y: c
|
|
68
68
|
}
|
|
69
69
|
};
|
|
@@ -73,68 +73,68 @@ function v() {
|
|
|
73
73
|
} : t;
|
|
74
74
|
});
|
|
75
75
|
}, [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
u,
|
|
77
|
+
h,
|
|
78
|
+
g,
|
|
79
|
+
m
|
|
80
80
|
]),
|
|
81
|
-
distribute:
|
|
82
|
-
const p =
|
|
81
|
+
distribute: b((l) => {
|
|
82
|
+
const p = g.nodeIds;
|
|
83
83
|
if (p.size < 3) return;
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
const e = [...
|
|
87
|
-
if (
|
|
88
|
-
const o = e.reduce((s, r) => s + r.width, 0),
|
|
84
|
+
const a = m.nodes.filter((o) => p.has(o.id));
|
|
85
|
+
if (a.length < 3) return;
|
|
86
|
+
const e = [...a].sort((o, d) => l === "horizontal" ? o.position.x - d.position.x : o.position.y - d.position.y), t = e[0], i = e[e.length - 1];
|
|
87
|
+
if (l === "horizontal") {
|
|
88
|
+
const o = e.reduce((s, r) => s + r.width, 0), d = (i.position.x + i.width - t.position.x - o) / (e.length - 1);
|
|
89
89
|
let c = t.position.x;
|
|
90
|
-
const
|
|
90
|
+
const f = /* @__PURE__ */ new Map();
|
|
91
91
|
for (const s of e)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const r = s.canvases[
|
|
92
|
+
f.set(s.id, c), c += s.width + d;
|
|
93
|
+
u((s) => {
|
|
94
|
+
const r = s.canvases[h];
|
|
95
95
|
return r ? {
|
|
96
96
|
...s,
|
|
97
97
|
canvases: {
|
|
98
98
|
...s.canvases,
|
|
99
|
-
[
|
|
99
|
+
[h]: {
|
|
100
100
|
...r,
|
|
101
|
-
nodes: r.nodes.map((
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
-
...
|
|
101
|
+
nodes: r.nodes.map((n) => {
|
|
102
|
+
const x = f.get(n.id);
|
|
103
|
+
return x !== void 0 ? {
|
|
104
|
+
...n,
|
|
105
105
|
position: {
|
|
106
|
-
...
|
|
107
|
-
x
|
|
106
|
+
...n.position,
|
|
107
|
+
x
|
|
108
108
|
}
|
|
109
|
-
} :
|
|
109
|
+
} : n;
|
|
110
110
|
})
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
} : s;
|
|
114
114
|
});
|
|
115
115
|
} else {
|
|
116
|
-
const o = e.reduce((s, r) => s + r.height, 0),
|
|
116
|
+
const o = e.reduce((s, r) => s + r.height, 0), d = (i.position.y + i.height - t.position.y - o) / (e.length - 1);
|
|
117
117
|
let c = t.position.y;
|
|
118
|
-
const
|
|
118
|
+
const f = /* @__PURE__ */ new Map();
|
|
119
119
|
for (const s of e)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const r = s.canvases[
|
|
120
|
+
f.set(s.id, c), c += s.height + d;
|
|
121
|
+
u((s) => {
|
|
122
|
+
const r = s.canvases[h];
|
|
123
123
|
return r ? {
|
|
124
124
|
...s,
|
|
125
125
|
canvases: {
|
|
126
126
|
...s.canvases,
|
|
127
|
-
[
|
|
127
|
+
[h]: {
|
|
128
128
|
...r,
|
|
129
|
-
nodes: r.nodes.map((
|
|
130
|
-
const
|
|
131
|
-
return
|
|
132
|
-
...
|
|
129
|
+
nodes: r.nodes.map((n) => {
|
|
130
|
+
const x = f.get(n.id);
|
|
131
|
+
return x !== void 0 ? {
|
|
132
|
+
...n,
|
|
133
133
|
position: {
|
|
134
|
-
...
|
|
135
|
-
y:
|
|
134
|
+
...n.position,
|
|
135
|
+
y: x
|
|
136
136
|
}
|
|
137
|
-
} :
|
|
137
|
+
} : n;
|
|
138
138
|
})
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -142,15 +142,44 @@ function v() {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
}, [
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
u,
|
|
146
|
+
h,
|
|
147
|
+
g,
|
|
148
|
+
m
|
|
149
|
+
]),
|
|
150
|
+
changeZIndex: b((l) => {
|
|
151
|
+
const p = g.nodeIds, a = g.lineIds;
|
|
152
|
+
p.size === 0 && a.size === 0 || u((e) => {
|
|
153
|
+
const t = e.canvases[h];
|
|
154
|
+
if (!t) return e;
|
|
155
|
+
const i = t.nodes.map((n) => n.zIndex ?? 0), o = i.length > 0 ? Math.max(...i) : 0, d = i.length > 0 ? Math.min(...i) : 0, c = t.lines.map((n) => n.zIndex ?? 0), f = c.length > 0 ? Math.max(...c) : 0, s = c.length > 0 ? Math.min(...c) : 0, r = (n, x, w) => l === "front" ? x + 1 : l === "back" ? w - 1 : l === "up" ? n + 1 : n - 1;
|
|
156
|
+
return {
|
|
157
|
+
...e,
|
|
158
|
+
canvases: {
|
|
159
|
+
...e.canvases,
|
|
160
|
+
[h]: {
|
|
161
|
+
...t,
|
|
162
|
+
nodes: t.nodes.map((n) => p.has(n.id) ? {
|
|
163
|
+
...n,
|
|
164
|
+
zIndex: r(n.zIndex ?? 0, o, d)
|
|
165
|
+
} : n),
|
|
166
|
+
lines: t.lines.map((n) => a.has(n.id) ? {
|
|
167
|
+
...n,
|
|
168
|
+
zIndex: r(n.zIndex ?? 0, f, s)
|
|
169
|
+
} : n)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}, [
|
|
175
|
+
u,
|
|
176
|
+
h,
|
|
177
|
+
g
|
|
149
178
|
])
|
|
150
179
|
};
|
|
151
180
|
}
|
|
152
181
|
export {
|
|
153
|
-
|
|
182
|
+
I as useLayoutActions
|
|
154
183
|
};
|
|
155
184
|
|
|
156
185
|
//# sourceMappingURL=useLayoutActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayoutActions.js","names":[],"sources":["../../../../../src/components/pro/Flow/hooks/useLayoutActions.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useFlowContext } from '../context/FlowContext';\nimport type { FlowNode } from '../types';\n\ntype Align = 'left' | 'center-h' | 'right' | 'top' | 'center-v' | 'bottom';\ntype Distribute = 'horizontal' | 'vertical';\n\nexport function useLayoutActions() {\n const { setDoc, currentCanvasId, selection, currentCanvas } = useFlowContext();\n\n const align = useCallback(\n (direction: Align) => {\n const ids = selection.nodeIds;\n if (ids.size < 2) return;\n const nodes = currentCanvas.nodes.filter(n => ids.has(n.id));\n if (nodes.length < 2) return;\n\n let target: number;\n switch (direction) {\n case 'left':\n target = Math.min(...nodes.map(n => n.position.x));\n break;\n case 'right':\n target = Math.max(...nodes.map(n => n.position.x + n.width));\n break;\n case 'center-h':\n target = nodes.reduce((s, n) => s + n.position.x + n.width / 2, 0) / nodes.length;\n break;\n case 'top':\n target = Math.min(...nodes.map(n => n.position.y));\n break;\n case 'bottom':\n target = Math.max(...nodes.map(n => n.position.y + n.height));\n break;\n case 'center-v':\n target = nodes.reduce((s, n) => s + n.position.y + n.height / 2, 0) / nodes.length;\n break;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n if (!ids.has(n.id)) return n;\n let newX = n.position.x;\n let newY = n.position.y;\n switch (direction) {\n case 'left': newX = target; break;\n case 'right': newX = target - n.width; break;\n case 'center-h': newX = target - n.width / 2; break;\n case 'top': newY = target; break;\n case 'bottom': newY = target - n.height; break;\n case 'center-v': newY = target - n.height / 2; break;\n }\n return { ...n, position: { x: newX, y: newY } };\n }),\n },\n },\n };\n });\n },\n [setDoc, currentCanvasId, selection, currentCanvas],\n );\n\n const distribute = useCallback(\n (direction: Distribute) => {\n const ids = selection.nodeIds;\n if (ids.size < 3) return;\n const nodes = currentCanvas.nodes.filter(n => ids.has(n.id));\n if (nodes.length < 3) return;\n\n const sorted = [...nodes].sort((a, b) =>\n direction === 'horizontal'\n ? a.position.x - b.position.x\n : a.position.y - b.position.y,\n );\n\n const first = sorted[0];\n const last = sorted[sorted.length - 1];\n\n if (direction === 'horizontal') {\n const totalWidth = sorted.reduce((s, n) => s + n.width, 0);\n const totalSpace = (last.position.x + last.width) - first.position.x - totalWidth;\n const gap = totalSpace / (sorted.length - 1);\n let x = first.position.x;\n\n const posMap = new Map<string, number>();\n for (const n of sorted) {\n posMap.set(n.id, x);\n x += n.width + gap;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n const newX = posMap.get(n.id);\n return newX !== undefined ? { ...n, position: { ...n.position, x: newX } } : n;\n }),\n },\n },\n };\n });\n } else {\n const totalHeight = sorted.reduce((s, n) => s + n.height, 0);\n const totalSpace = (last.position.y + last.height) - first.position.y - totalHeight;\n const gap = totalSpace / (sorted.length - 1);\n let y = first.position.y;\n\n const posMap = new Map<string, number>();\n for (const n of sorted) {\n posMap.set(n.id, y);\n y += n.height + gap;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n const newY = posMap.get(n.id);\n return newY !== undefined ? { ...n, position: { ...n.position, y: newY } } : n;\n }),\n },\n },\n };\n });\n }\n },\n [setDoc, currentCanvasId, selection, currentCanvas],\n );\n\n return { align, distribute };\n}\n"],"mappings":";;AAOA,SAAgB,IAAmB;AACjC,QAAM,EAAE,QAAA,GAAQ,iBAAA,GAAiB,WAAA,GAAW,eA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K;AAAA,eACP,CAAA,GAAkB;AAAA,gBACjB,GAAG;AAAA,gBACH,OAAO,EAAO,MAAM,IAAA,CAAI,MAAK;AAC3B,wBAAM,IAAO,EAAO,IAAI,EAAE,EAAE;AAC5B,yBAAO,MAAS,SAAY;AAAA,oBAAE,GAAG;AAAA,oBAAG,UAAU;AAAA,sBAAE,GAAG,EAAE;AAAA,sBAAU,GAAG;AAAA,oBAAK;AAAA,kBAAE,IAAI;AAAA,gBAC/E,CAAC;AAAA,cACH;AAAA,YACF;AAAA,UACF,IAboB;AAAA,QActB,CAAC;AAAA,MACH;AAAA,IACF,GACA;AAAA,MAAC;AAAA,MAAQ;AAAA,MAAiB;AAAA,MAAW;AAAA,IAAa,CAGpC;AAAA,EAAW;AAC7B"}
|
|
1
|
+
{"version":3,"file":"useLayoutActions.js","names":[],"sources":["../../../../../src/components/pro/Flow/hooks/useLayoutActions.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useFlowContext } from '../context/FlowContext';\nimport type { FlowNode } from '../types';\n\ntype Align = 'left' | 'center-h' | 'right' | 'top' | 'center-v' | 'bottom';\ntype Distribute = 'horizontal' | 'vertical';\ntype LayerMode = 'front' | 'back' | 'up' | 'down';\n\nexport function useLayoutActions() {\n const { setDoc, currentCanvasId, selection, currentCanvas } = useFlowContext();\n\n const align = useCallback(\n (direction: Align) => {\n const ids = selection.nodeIds;\n if (ids.size < 2) return;\n const nodes = currentCanvas.nodes.filter(n => ids.has(n.id));\n if (nodes.length < 2) return;\n\n let target: number;\n switch (direction) {\n case 'left':\n target = Math.min(...nodes.map(n => n.position.x));\n break;\n case 'right':\n target = Math.max(...nodes.map(n => n.position.x + n.width));\n break;\n case 'center-h':\n target = nodes.reduce((s, n) => s + n.position.x + n.width / 2, 0) / nodes.length;\n break;\n case 'top':\n target = Math.min(...nodes.map(n => n.position.y));\n break;\n case 'bottom':\n target = Math.max(...nodes.map(n => n.position.y + n.height));\n break;\n case 'center-v':\n target = nodes.reduce((s, n) => s + n.position.y + n.height / 2, 0) / nodes.length;\n break;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n if (!ids.has(n.id)) return n;\n let newX = n.position.x;\n let newY = n.position.y;\n switch (direction) {\n case 'left': newX = target; break;\n case 'right': newX = target - n.width; break;\n case 'center-h': newX = target - n.width / 2; break;\n case 'top': newY = target; break;\n case 'bottom': newY = target - n.height; break;\n case 'center-v': newY = target - n.height / 2; break;\n }\n return { ...n, position: { x: newX, y: newY } };\n }),\n },\n },\n };\n });\n },\n [setDoc, currentCanvasId, selection, currentCanvas],\n );\n\n const distribute = useCallback(\n (direction: Distribute) => {\n const ids = selection.nodeIds;\n if (ids.size < 3) return;\n const nodes = currentCanvas.nodes.filter(n => ids.has(n.id));\n if (nodes.length < 3) return;\n\n const sorted = [...nodes].sort((a, b) =>\n direction === 'horizontal'\n ? a.position.x - b.position.x\n : a.position.y - b.position.y,\n );\n\n const first = sorted[0];\n const last = sorted[sorted.length - 1];\n\n if (direction === 'horizontal') {\n const totalWidth = sorted.reduce((s, n) => s + n.width, 0);\n const totalSpace = (last.position.x + last.width) - first.position.x - totalWidth;\n const gap = totalSpace / (sorted.length - 1);\n let x = first.position.x;\n\n const posMap = new Map<string, number>();\n for (const n of sorted) {\n posMap.set(n.id, x);\n x += n.width + gap;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n const newX = posMap.get(n.id);\n return newX !== undefined ? { ...n, position: { ...n.position, x: newX } } : n;\n }),\n },\n },\n };\n });\n } else {\n const totalHeight = sorted.reduce((s, n) => s + n.height, 0);\n const totalSpace = (last.position.y + last.height) - first.position.y - totalHeight;\n const gap = totalSpace / (sorted.length - 1);\n let y = first.position.y;\n\n const posMap = new Map<string, number>();\n for (const n of sorted) {\n posMap.set(n.id, y);\n y += n.height + gap;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n const newY = posMap.get(n.id);\n return newY !== undefined ? { ...n, position: { ...n.position, y: newY } } : n;\n }),\n },\n },\n };\n });\n }\n },\n [setDoc, currentCanvasId, selection, currentCanvas],\n );\n\n const changeZIndex = useCallback(\n (mode: LayerMode) => {\n const nodeIds = selection.nodeIds;\n const lineIds = selection.lineIds;\n if (nodeIds.size === 0 && lineIds.size === 0) return;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n const nodeAllZ = canvas.nodes.map(n => n.zIndex ?? 0);\n const nodeMaxZ = nodeAllZ.length > 0 ? Math.max(...nodeAllZ) : 0;\n const nodeMinZ = nodeAllZ.length > 0 ? Math.min(...nodeAllZ) : 0;\n const lineAllZ = canvas.lines.map(l => l.zIndex ?? 0);\n const lineMaxZ = lineAllZ.length > 0 ? Math.max(...lineAllZ) : 0;\n const lineMinZ = lineAllZ.length > 0 ? Math.min(...lineAllZ) : 0;\n const applyZ = (z: number, maxZ: number, minZ: number) => {\n if (mode === 'front') return maxZ + 1;\n if (mode === 'back') return minZ - 1;\n if (mode === 'up') return z + 1;\n return z - 1;\n };\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => nodeIds.has(n.id) ? { ...n, zIndex: applyZ(n.zIndex ?? 0, nodeMaxZ, nodeMinZ) } : n),\n lines: canvas.lines.map(l => lineIds.has(l.id) ? { ...l, zIndex: applyZ(l.zIndex ?? 0, lineMaxZ, lineMinZ) } : l),\n },\n },\n };\n });\n },\n [setDoc, currentCanvasId, selection],\n );\n\n return { align, distribute,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