import { Graph } from "@antv/x6";
import { useEffect } from "react";

export const useEvent = (graph?: Graph) => { 
  useEffect(() => { 
    const params = new URL(document.location.href.replace('#', '')).searchParams;
    const mode = params.get("mode") ?? "edit";
    // 空白双击-添加节点
    graph?.on("blank:dblclick", args => {
      if (mode === 'ops') return;
      graph.addNode({
        shape: "menu-popover",
        x: args.x,
        y: args.y
      });
    });
    
  }, [graph]);

}