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