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