layers tree I

This commit is contained in:
2025-11-11 23:31:22 +01:00
parent 4092b12aef
commit ae02080563
5 changed files with 176 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ import { defaultGraph, graphContext, type EdgeModel, type NodeContext } from "./
import { useContext } from "react";
import { cloneDeep } from "lodash";
import { useGraphsStore } from "../stores/GraphsStore";
import { useGraphLayersTreeStore } from "../stores/TreeStore";
const items: MenuProps['items'] = [
{
@@ -39,6 +40,7 @@ export default function NodeContextMenu({
const graphContextValue = useContext(graphContext)!;
const graphsById = useGraphsStore((s) => s.graphsById);
const addTreeNode = useGraphLayersTreeStore(store => store.add);
function contextMenuOpenChange(open: boolean) {
if (!open) {
@@ -64,9 +66,10 @@ export default function NodeContextMenu({
if (!selectedGraph) {
selectedGraph = defaultGraph();
graphsById.set(nodeContext.nodeId, selectedGraph);
const parenNodeId = graphContextValue.graphId === 'main' ? undefined : graphContextValue.graphId;
addTreeNode(nodeContext, parenNodeId);
}
console.info(graphsById)
graphContextValue.setGraph(selectedGraph);
break;