/** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ import { FlowNodeEntity, FlowOperationService, useClientContext, usePlayground, useService, } from '@flowgram.ai/fixed-layout-editor'; import { Dropdown } from '@douyinfe/semi-ui'; import { IconPlusCircle } from '@douyinfe/semi-icons'; import { nodeRegistries } from '../node-registries'; export const NodeAdder = (props: { from: FlowNodeEntity; to?: FlowNodeEntity; hoverActivated: boolean; }) => { const { from, hoverActivated } = props; const playground = usePlayground(); const context = useClientContext(); const flowOperationService = useService(FlowOperationService) as FlowOperationService; const add = (addProps: any) => { const blocks = addProps.blocks ? addProps.blocks : undefined; const block = flowOperationService.addFromNode(from, { ...addProps, blocks, }); setTimeout(() => { playground.scrollToView({ bounds: block.bounds, scrollToCenter: true, }); }, 10); }; if (playground.config.readonlyOrDisabled) return null; return ( {nodeRegistries.map((registry) => ( { const props = registry?.onAdd(context, from); add(props); }} > {registry.type} ))} } >
{hoverActivated ? ( ) : null}
); };