remove custom node
This commit is contained in:
@@ -14,7 +14,6 @@ import ReactFlow, {
|
|||||||
NodeChange,
|
NodeChange,
|
||||||
EdgeChange,
|
EdgeChange,
|
||||||
} from 'reactflow'
|
} from 'reactflow'
|
||||||
import CustomNode from './components/CustomNode'
|
|
||||||
import ConfigNode from './components/ConfigNode'
|
import ConfigNode from './components/ConfigNode'
|
||||||
import RenderingNode from './components/RenderingNode'
|
import RenderingNode from './components/RenderingNode'
|
||||||
import FlowContext from './lib/flowContext'
|
import FlowContext from './lib/flowContext'
|
||||||
@@ -56,7 +55,7 @@ export default function App() {
|
|||||||
const [contextTarget, setContextTarget] = React.useState<null | { type: 'canvas' | 'node'; nodeId?: string; clientX: number; clientY: number }>(null)
|
const [contextTarget, setContextTarget] = React.useState<null | { type: 'canvas' | 'node'; nodeId?: string; clientX: number; clientY: number }>(null)
|
||||||
|
|
||||||
const nodeTypes = React.useMemo(
|
const nodeTypes = React.useMemo(
|
||||||
() => ({ custom: CustomNode, config: ConfigNode, render: RenderingNode }),
|
() => ({ config: ConfigNode, render: RenderingNode }),
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -107,7 +106,7 @@ export default function App() {
|
|||||||
const id = genId()
|
const id = genId()
|
||||||
const newNode: Node = {
|
const newNode: Node = {
|
||||||
id,
|
id,
|
||||||
type: type === 'custom' ? 'custom' : type === 'config' ? 'config' : 'render',
|
type: type === 'config' ? 'config' : 'render',
|
||||||
position: { x: position.x, y: position.y },
|
position: { x: position.x, y: position.y },
|
||||||
data: type === 'config' ? { yaml: '# Enter YAML here\n', title: `config-${id}` } : {},
|
data: type === 'config' ? { yaml: '# Enter YAML here\n', title: `config-${id}` } : {},
|
||||||
}
|
}
|
||||||
@@ -157,7 +156,6 @@ export default function App() {
|
|||||||
<ContextMenuLabel>New Node</ContextMenuLabel>
|
<ContextMenuLabel>New Node</ContextMenuLabel>
|
||||||
<ContextMenuItem onSelect={() => createNode('config')}>Config</ContextMenuItem>
|
<ContextMenuItem onSelect={() => createNode('config')}>Config</ContextMenuItem>
|
||||||
<ContextMenuItem onSelect={() => createNode('render')}>Renderer</ContextMenuItem>
|
<ContextMenuItem onSelect={() => createNode('render')}>Renderer</ContextMenuItem>
|
||||||
<ContextMenuItem onSelect={() => createNode('custom')}>Custom</ContextMenuItem>
|
|
||||||
</ContextMenuGroup>
|
</ContextMenuGroup>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import { Handle, Position } from 'reactflow'
|
|
||||||
|
|
||||||
export default function CustomNode({ data }: any) {
|
|
||||||
return (
|
|
||||||
<div className="p-3 rounded-lg bg-white shadow hover:shadow-md border border-gray-200 w-56">
|
|
||||||
<div className="flex items-center justify-between mb-2">
|
|
||||||
<div className="text-sm font-semibold">{data.label}</div>
|
|
||||||
<div className="text-xs text-gray-400">ID: {data?.id ?? ''}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="text-xs text-gray-500 mb-2">Custom content</div>
|
|
||||||
|
|
||||||
<div className="flex justify-between mt-2">
|
|
||||||
<Handle
|
|
||||||
type="target"
|
|
||||||
position={Position.Left}
|
|
||||||
id="a"
|
|
||||||
style={{ background: '#F97316', width: 12, height: 12, borderRadius: 3 }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Handle
|
|
||||||
type="source"
|
|
||||||
position={Position.Right}
|
|
||||||
id="b"
|
|
||||||
style={{ background: '#10B981', width: 12, height: 12, borderRadius: 3 }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user