({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, style = {}, data, markerEnd })
| 11 | const foreignObjectSize = 40 |
| 12 | |
| 13 | const ButtonEdge = ({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, style = {}, data, markerEnd }) => { |
| 14 | const [edgePath, edgeCenterX, edgeCenterY] = getBezierPath({ |
| 15 | sourceX, |
| 16 | sourceY, |
| 17 | sourcePosition, |
| 18 | targetX, |
| 19 | targetY, |
| 20 | targetPosition |
| 21 | }) |
| 22 | |
| 23 | const { deleteEdge } = useContext(flowContext) |
| 24 | |
| 25 | const dispatch = useDispatch() |
| 26 | |
| 27 | const onEdgeClick = (evt, id) => { |
| 28 | evt.stopPropagation() |
| 29 | deleteEdge(id) |
| 30 | dispatch({ type: SET_DIRTY }) |
| 31 | } |
| 32 | |
| 33 | return ( |
| 34 | <> |
| 35 | <path id={id} style={style} className='react-flow__edge-path' d={edgePath} markerEnd={markerEnd} /> |
| 36 | {data && data.label && ( |
| 37 | <EdgeText |
| 38 | x={sourceX + 10} |
| 39 | y={sourceY + 10} |
| 40 | label={data.label} |
| 41 | labelStyle={{ fill: 'black' }} |
| 42 | labelBgStyle={{ fill: 'transparent' }} |
| 43 | labelBgPadding={[2, 4]} |
| 44 | labelBgBorderRadius={2} |
| 45 | /> |
| 46 | )} |
| 47 | <foreignObject |
| 48 | width={foreignObjectSize} |
| 49 | height={foreignObjectSize} |
| 50 | x={edgeCenterX - foreignObjectSize / 2} |
| 51 | y={edgeCenterY - foreignObjectSize / 2} |
| 52 | className='edgebutton-foreignobject' |
| 53 | requiredExtensions='http://www.w3.org/1999/xhtml' |
| 54 | > |
| 55 | <div> |
| 56 | <button className='edgebutton' onClick={(event) => onEdgeClick(event, id)}> |
| 57 | <IconX stroke={2} size='12' /> |
| 58 | </button> |
| 59 | </div> |
| 60 | </foreignObject> |
| 61 | </> |
| 62 | ) |
| 63 | } |
| 64 | |
| 65 | ButtonEdge.propTypes = { |
| 66 | id: PropTypes.string, |
nothing calls this directly
no test coverage detected