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