mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-25 16:26:51 +08:00
### What problem does this PR solve? Feat: Use memo to wrap canvas nodes to improve fluency #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
41 lines
816 B
TypeScript
41 lines
816 B
TypeScript
import { Handle, Position } from '@xyflow/react';
|
|
|
|
import React, { memo } from 'react';
|
|
import styles from './index.less';
|
|
|
|
const DEFAULT_HANDLE_STYLE = {
|
|
width: 6,
|
|
height: 6,
|
|
bottom: -5,
|
|
fontSize: 8,
|
|
};
|
|
|
|
interface IProps extends React.PropsWithChildren {
|
|
top: number;
|
|
right: number;
|
|
id: string;
|
|
idx?: number;
|
|
}
|
|
|
|
const CategorizeHandle = ({ top, right, id, children }: IProps) => {
|
|
return (
|
|
<Handle
|
|
type="source"
|
|
position={Position.Right}
|
|
id={id}
|
|
isConnectable
|
|
style={{
|
|
...DEFAULT_HANDLE_STYLE,
|
|
top: `${top}%`,
|
|
right: `${right}%`,
|
|
background: 'red',
|
|
color: 'black',
|
|
}}
|
|
>
|
|
<span className={styles.categorizeAnchorPointText}>{children || id}</span>
|
|
</Handle>
|
|
);
|
|
};
|
|
|
|
export default memo(CategorizeHandle);
|