Merge pull request #3046 from wbkd/refactor/baseedge
refactor(base-edge): pass id to base edge path
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@reactflow/core': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
refactor(base-edge): pass id to base edge path
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { EdgeProps, getBezierPath } from 'reactflow';
|
import { BaseEdge, EdgeProps, getBezierPath } from 'reactflow';
|
||||||
|
|
||||||
const CustomEdge: FC<EdgeProps> = ({
|
const CustomEdge: FC<EdgeProps> = ({
|
||||||
id,
|
id,
|
||||||
@@ -22,7 +22,7 @@ const CustomEdge: FC<EdgeProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<path id={id} className="react-flow__edge-path" d={edgePath} />
|
<BaseEdge path={edgePath} id={id} />
|
||||||
<text>
|
<text>
|
||||||
<textPath href={`#${id}`} style={{ fontSize: '12px' }} startOffset="50%" textAnchor="middle">
|
<textPath href={`#${id}`} style={{ fontSize: '12px' }} startOffset="50%" textAnchor="middle">
|
||||||
{data.text}
|
{data.text}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { EdgeProps, getBezierPath, EdgeText } from 'reactflow';
|
import { EdgeProps, getBezierPath, EdgeText, BaseEdge } from 'reactflow';
|
||||||
|
|
||||||
const CustomEdge: FC<EdgeProps> = ({
|
const CustomEdge: FC<EdgeProps> = ({
|
||||||
id,
|
id,
|
||||||
@@ -22,7 +22,7 @@ const CustomEdge: FC<EdgeProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<path id={id} className="react-flow__edge-path" d={edgePath} />
|
<BaseEdge id={id} path={edgePath} />
|
||||||
<EdgeText
|
<EdgeText
|
||||||
x={labelX}
|
x={labelX}
|
||||||
y={labelY}
|
y={labelY}
|
||||||
@@ -34,7 +34,6 @@ const CustomEdge: FC<EdgeProps> = ({
|
|||||||
labelBgBorderRadius={2}
|
labelBgBorderRadius={2}
|
||||||
onClick={() => console.log(data)}
|
onClick={() => console.log(data)}
|
||||||
/>
|
/>
|
||||||
;
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { isNumeric } from '../../utils';
|
|||||||
import type { BaseEdgeProps } from '../../types';
|
import type { BaseEdgeProps } from '../../types';
|
||||||
|
|
||||||
const BaseEdge = ({
|
const BaseEdge = ({
|
||||||
|
id,
|
||||||
path,
|
path,
|
||||||
labelX,
|
labelX,
|
||||||
labelY,
|
labelY,
|
||||||
@@ -20,6 +21,7 @@ const BaseEdge = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<path
|
<path
|
||||||
|
id={id}
|
||||||
style={style}
|
style={style}
|
||||||
d={path}
|
d={path}
|
||||||
fill="none"
|
fill="none"
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ export type EdgeProps<T = any> = Pick<
|
|||||||
|
|
||||||
export type BaseEdgeProps = Pick<EdgeProps, 'style' | 'markerStart' | 'markerEnd' | 'interactionWidth'> &
|
export type BaseEdgeProps = Pick<EdgeProps, 'style' | 'markerStart' | 'markerEnd' | 'interactionWidth'> &
|
||||||
EdgeLabelOptions & {
|
EdgeLabelOptions & {
|
||||||
|
id?: string;
|
||||||
labelX?: number;
|
labelX?: number;
|
||||||
labelY?: number;
|
labelY?: number;
|
||||||
path: string;
|
path: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user