项目文件夹

文件
wehub-resource-sync d13100ebf3
Update draft releases / main (push) Has been cancelled
Build and push docs image / build-image (push) Has been cancelled
Build Web Application / build-web (macos-latest) (push) Has been cancelled
Build Web Application / build-web (ubuntu-latest) (push) Has been cancelled
Python Code Quality Checks / build (push) Has been cancelled
Test Python / test-python (macos-latest, 3.10) (push) Has been cancelled
Test Python / test-python (macos-latest, 3.11) (push) Has been cancelled
Test Python / test-python (ubuntu-latest, 3.10) (push) Has been cancelled
Test Python / test-python (ubuntu-latest, 3.11) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:27:08 +08:00

52 行
1.3 KiB
TypeScript

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
import React from 'react';
import { BaseEdge, EdgeProps, getBezierPath, useReactFlow } from 'reactflow';
const ButtonEdge: React.FC<EdgeProps> = ({
id,
sourceX,
sourceY,
targetX,
targetY,
sourcePosition,
targetPosition,
style = {},
markerEnd,
}) => {
const [edgePath, edgeCenterX, edgeCenterY] = getBezierPath({
sourceX,
sourceY,
sourcePosition,
targetX,
targetY,
targetPosition,
});
const reactFlow = useReactFlow();
function onEdgeClick(event: React.MouseEvent, id: string) {
event.stopPropagation();
reactFlow.setEdges(reactFlow.getEdges().filter(edge => edge.id !== id));
}
return (
<>
<BaseEdge id={id} style={style} path={edgePath} markerEnd={markerEnd} />
<foreignObject
width={40}
height={40}
x={edgeCenterX - 40 / 2}
y={edgeCenterY - 40 / 2}
className='bg-transparent w-10 h-10 relative'
requiredExtensions='http://www.w3.org/1999/xhtml'
>
<button
className='absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-5 h-5 rounded-full bg-stone-400 dark:bg-zinc-700 cursor-pointer text-sm'
onClick={event => onEdgeClick(event, id)}
>
×
</button>
</foreignObject>
</>
);
};
export default ButtonEdge;