feat: duplicate node #918 (#1136)

### What problem does this PR solve?
feat: duplicate node #918


### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-06-13 09:09:34 +08:00
committed by GitHub
parent 3b7b6240c3
commit 64c83f300a
6 changed files with 79 additions and 27 deletions

View File

@@ -8,7 +8,6 @@ import ReactFlow, {
} from 'reactflow';
import 'reactflow/dist/style.css';
import { NodeContextMenu, useHandleNodeContextMenu } from './context-menu';
import { ButtonEdge } from './edge';
import FlowDrawer from '../flow-drawer';
@@ -30,12 +29,11 @@ const edgeTypes = {
};
interface IProps {
sideWidth: number;
chatDrawerVisible: boolean;
hideChatDrawer(): void;
}
function FlowCanvas({ sideWidth, chatDrawerVisible, hideChatDrawer }: IProps) {
function FlowCanvas({ chatDrawerVisible, hideChatDrawer }: IProps) {
const {
nodes,
edges,
@@ -45,8 +43,6 @@ function FlowCanvas({ sideWidth, chatDrawerVisible, hideChatDrawer }: IProps) {
onSelectionChange,
} = useSelectCanvasData();
const { ref, menu, onNodeContextMenu, onPaneClick } =
useHandleNodeContextMenu(sideWidth);
const { drawerVisible, hideDrawer, showDrawer, clickedNode } =
useShowDrawer();
@@ -64,18 +60,15 @@ function FlowCanvas({ sideWidth, chatDrawerVisible, hideChatDrawer }: IProps) {
return (
<div className={styles.canvasWrapper}>
<ReactFlow
ref={ref}
connectionMode={ConnectionMode.Loose}
nodes={nodes}
onNodesChange={onNodesChange}
onNodeContextMenu={onNodeContextMenu}
edges={edges}
onEdgesChange={onEdgesChange}
fitView
onConnect={onConnect}
nodeTypes={nodeTypes}
edgeTypes={edgeTypes}
onPaneClick={onPaneClick}
onDrop={onDrop}
onDragOver={onDragOver}
onNodeClick={onNodeClick}
@@ -95,9 +88,6 @@ function FlowCanvas({ sideWidth, chatDrawerVisible, hideChatDrawer }: IProps) {
>
<Background />
<Controls />
{Object.keys(menu).length > 0 && (
<NodeContextMenu onClick={onPaneClick} {...(menu as any)} />
)}
</ReactFlow>
<FlowDrawer
node={clickedNode}