mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Add note node #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -269,9 +269,13 @@ function useResizeIterationNode() {
|
||||
|
||||
return { resizeIterationNode };
|
||||
}
|
||||
type CanvasMouseEvent = Pick<
|
||||
React.MouseEvent<HTMLElement>,
|
||||
'clientX' | 'clientY'
|
||||
>;
|
||||
|
||||
export function useAddNode(reactFlowInstance?: ReactFlowInstance<any, any>) {
|
||||
const { edges, nodes, addEdge, addNode, getNode, updateNode } = useGraphStore(
|
||||
const { edges, nodes, addEdge, addNode, getNode } = useGraphStore(
|
||||
(state) => state,
|
||||
);
|
||||
const getNodeName = useGetNodeName();
|
||||
@ -290,7 +294,7 @@ export function useAddNode(reactFlowInstance?: ReactFlowInstance<any, any>) {
|
||||
position: Position.Right,
|
||||
},
|
||||
) =>
|
||||
(event?: React.MouseEvent<HTMLElement>) => {
|
||||
(event?: CanvasMouseEvent) => {
|
||||
const nodeId = params.nodeId;
|
||||
|
||||
const node = getNode(nodeId);
|
||||
@ -303,7 +307,7 @@ export function useAddNode(reactFlowInstance?: ReactFlowInstance<any, any>) {
|
||||
y: event?.clientY || 0,
|
||||
});
|
||||
|
||||
if (params.position === Position.Right) {
|
||||
if (params.position === Position.Right && type !== Operator.Note) {
|
||||
position = calculateNewlyBackChildPosition(nodeId, params.id);
|
||||
}
|
||||
|
||||
@ -420,9 +424,16 @@ export function useAddNode(reactFlowInstance?: ReactFlowInstance<any, any>) {
|
||||
initializeOperatorParams,
|
||||
nodes,
|
||||
reactFlowInstance,
|
||||
updateNode,
|
||||
resizeIterationNode,
|
||||
],
|
||||
);
|
||||
|
||||
return { addCanvasNode };
|
||||
const addNoteNode = useCallback(
|
||||
(e: CanvasMouseEvent) => {
|
||||
addCanvasNode(Operator.Note)(e);
|
||||
},
|
||||
[addCanvasNode],
|
||||
);
|
||||
|
||||
return { addCanvasNode, addNoteNode };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user