mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: Fixed the issue where the operator added by clicking the plus sign in the data flow would overlap with the original section #9886 (#10458)
### What problem does this PR solve? Fix: Fixed the issue where the operator added by clicking the plus sign in the data flow would overlap with the original section #9886 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -41,7 +41,7 @@ export function HomeCard({
|
|||||||
<div className="flex flex-col justify-between gap-1 flex-1 h-full w-[calc(100%-50px)]">
|
<div className="flex flex-col justify-between gap-1 flex-1 h-full w-[calc(100%-50px)]">
|
||||||
<section className="flex justify-between w-full">
|
<section className="flex justify-between w-full">
|
||||||
<section className="flex gap-1 items-center w-full">
|
<section className="flex gap-1 items-center w-full">
|
||||||
<div className="text-[20px] font-bold w-80% leading-5 text-ellipsis overflow-hidden">
|
<div className="text-base font-bold w-80% text-ellipsis overflow-hidden leading-snug">
|
||||||
{data.name}
|
{data.name}
|
||||||
</div>
|
</div>
|
||||||
{icon}
|
{icon}
|
||||||
|
|||||||
@ -116,6 +116,7 @@ export const useInitializeOperatorParams = () => {
|
|||||||
[Operator.UserFillUp]: initialUserFillUpValues,
|
[Operator.UserFillUp]: initialUserFillUpValues,
|
||||||
[Operator.StringTransform]: initialStringTransformValues,
|
[Operator.StringTransform]: initialStringTransformValues,
|
||||||
[Operator.TavilyExtract]: initialTavilyExtractValues,
|
[Operator.TavilyExtract]: initialTavilyExtractValues,
|
||||||
|
[Operator.Placeholder]: {},
|
||||||
};
|
};
|
||||||
}, [llmId]);
|
}, [llmId]);
|
||||||
|
|
||||||
|
|||||||
@ -178,11 +178,17 @@ function DataFlowCanvas({ drawerVisible, hideDrawer, showLogSheet }: IProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onConnectEnd: OnConnectEnd = (event, connectionState) => {
|
const onConnectEnd: OnConnectEnd = (event, connectionState) => {
|
||||||
|
const target = event.target as HTMLElement;
|
||||||
const nodeId = connectionState.fromNode?.id;
|
const nodeId = connectionState.fromNode?.id;
|
||||||
|
|
||||||
// Events triggered by Handle are directly interrupted
|
// Events triggered by Handle are directly interrupted
|
||||||
if (connectionState.toNode !== null || (nodeId && hasChildNode(nodeId))) {
|
if (
|
||||||
|
target?.classList.contains('react-flow__handle') ||
|
||||||
|
(nodeId && hasChildNode(nodeId))
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('clientX' in event && 'clientY' in event) {
|
if ('clientX' in event && 'clientY' in event) {
|
||||||
const { clientX, clientY } = event;
|
const { clientX, clientY } = event;
|
||||||
setDropdownPosition({ x: clientX, y: clientY });
|
setDropdownPosition({ x: clientX, y: clientY });
|
||||||
|
|||||||
@ -52,31 +52,33 @@ function OperatorItemList({
|
|||||||
const getNodeName = useGetNodeName();
|
const getNodeName = useGetNodeName();
|
||||||
const getNodeDescription = useGetNodeDescription();
|
const getNodeDescription = useGetNodeDescription();
|
||||||
|
|
||||||
const handleClick = (operator: Operator) => {
|
const handleClick =
|
||||||
const contextData = handleContext || {
|
(operator: Operator): React.MouseEventHandler<HTMLElement> =>
|
||||||
nodeId: '',
|
(e) => {
|
||||||
id: '',
|
const contextData = handleContext || {
|
||||||
type: 'source' as const,
|
nodeId: '',
|
||||||
position: Position.Right,
|
id: '',
|
||||||
isFromConnectionDrag: true,
|
type: 'source' as const,
|
||||||
|
position: Position.Right,
|
||||||
|
isFromConnectionDrag: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockEvent = mousePosition
|
||||||
|
? {
|
||||||
|
clientX: mousePosition.x,
|
||||||
|
clientY: mousePosition.y,
|
||||||
|
}
|
||||||
|
: e;
|
||||||
|
|
||||||
|
const newNodeId = addCanvasNode(operator, contextData)(mockEvent);
|
||||||
|
|
||||||
|
if (onNodeCreated && newNodeId) {
|
||||||
|
onNodeCreated(newNodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
hideModal?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockEvent = mousePosition
|
|
||||||
? {
|
|
||||||
clientX: mousePosition.x,
|
|
||||||
clientY: mousePosition.y,
|
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const newNodeId = addCanvasNode(operator, contextData)(mockEvent);
|
|
||||||
|
|
||||||
if (onNodeCreated && newNodeId) {
|
|
||||||
onNodeCreated(newNodeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
hideModal?.();
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderOperatorItem = (operator: Operator) => {
|
const renderOperatorItem = (operator: Operator) => {
|
||||||
const commonContent = (
|
const commonContent = (
|
||||||
<div className="hover:bg-background-card py-1 px-3 cursor-pointer rounded-sm flex gap-2 items-center justify-start">
|
<div className="hover:bg-background-card py-1 px-3 cursor-pointer rounded-sm flex gap-2 items-center justify-start">
|
||||||
@ -89,12 +91,12 @@ function OperatorItemList({
|
|||||||
<Tooltip key={operator}>
|
<Tooltip key={operator}>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
{isCustomDropdown ? (
|
{isCustomDropdown ? (
|
||||||
<li onClick={() => handleClick(operator)}>{commonContent}</li>
|
<li onClick={handleClick(operator)}>{commonContent}</li>
|
||||||
) : (
|
) : (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
key={operator}
|
key={operator}
|
||||||
className="hover:bg-background-card py-1 px-3 cursor-pointer rounded-sm flex gap-2 items-center justify-start"
|
className="hover:bg-background-card py-1 px-3 cursor-pointer rounded-sm flex gap-2 items-center justify-start"
|
||||||
onClick={() => handleClick(operator)}
|
onClick={handleClick(operator)}
|
||||||
onSelect={() => hideModal?.()}
|
onSelect={() => hideModal?.()}
|
||||||
>
|
>
|
||||||
<OperatorIcon name={operator} />
|
<OperatorIcon name={operator} />
|
||||||
|
|||||||
Reference in New Issue
Block a user