Skip to content

Commit b31062e

Browse files
committed
feat: Add support for grouping nodes in the flow
1 parent 0b30ccf commit b31062e

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

packages/client/flow/core/src/lib/flow/base-flow.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import CustomEdge from '../node/custom-edge'
2020
import { NodeSpecJSON } from '@magickml/behave-graph'
2121
import { CommentNode } from '../nodeTypes/comment'
2222
import { MagickEdgeType, MagickNodeType } from '@magickml/client-types'
23+
import { NodeGrouping } from '../components/nodeGroups'
24+
import { GroupNodeComponent } from '../nodeTypes/group'
2325

2426
export type MagickReactFlowInstance = ReactFlowInstance<
2527
MagickNodeType,
@@ -50,6 +52,10 @@ type BaseFlowHandlers = Pick<
5052
| 'handleSelectionDragStart'
5153
| 'handleDelete'
5254
| 'handleNodeDragStart'
55+
| 'handleNodeDrag'
56+
| 'handleDrop'
57+
| 'onDragOver'
58+
| 'handleNodeDragStop'
5359
>
5460

5561
type BaseFlowBehaveGraphFlow = Pick<
@@ -115,7 +121,11 @@ export const BaseFlow: React.FC<BaseFlowProps> = ({
115121
// memoize node types
116122
const nodeTypes = useMemo(() => {
117123
if (!behaveNodeTypes) return {}
118-
return { ...behaveNodeTypes, comment: CommentNode }
124+
return {
125+
...behaveNodeTypes,
126+
comment: CommentNode,
127+
group: GroupNodeComponent,
128+
}
119129
}, [behaveNodeTypes])
120130

121131
const { projectId, currentAgentId } = globalConfig || {}
@@ -155,6 +165,10 @@ export const BaseFlow: React.FC<BaseFlowProps> = ({
155165
handleNodeDragStart,
156166
handleDelete,
157167
handleSelectionDragStart,
168+
handleNodeDrag,
169+
handleDrop,
170+
onDragOver,
171+
handleNodeDragStop,
158172
} = flowHandlers
159173

160174
const togglePlay = () => {
@@ -214,6 +228,10 @@ export const BaseFlow: React.FC<BaseFlowProps> = ({
214228
elementsSelectable={!readOnly}
215229
onConnect={handleOnConnect}
216230
onNodeDragStart={handleNodeDragStart}
231+
onNodeDragStop={handleNodeDragStop}
232+
onNodeDrag={handleNodeDrag}
233+
onDrop={handleDrop}
234+
onDragOver={onDragOver}
217235
onSelectionDragStart={handleSelectionDragStart}
218236
onDelete={handleDelete}
219237
edgeTypes={edgeTypes}
@@ -245,6 +263,7 @@ export const BaseFlow: React.FC<BaseFlowProps> = ({
245263
color="var(--background-color-light)"
246264
style={{ backgroundColor: 'var(--background-color)' }}
247265
/>
266+
<NodeGrouping />
248267
{miniMapOpen && (
249268
<MiniMap<MagickNodeType>
250269
nodeStrokeWidth={3}

0 commit comments

Comments
 (0)