Added connectionLineContainerStyle property
This commit is contained in:
@@ -24,6 +24,7 @@ interface EdgeRendererProps {
|
|||||||
connectionLineType: ConnectionLineType;
|
connectionLineType: ConnectionLineType;
|
||||||
connectionLineStyle?: CSSProperties;
|
connectionLineStyle?: CSSProperties;
|
||||||
connectionLineComponent?: ConnectionLineComponent;
|
connectionLineComponent?: ConnectionLineComponent;
|
||||||
|
connectionLineContainerStyle?: CSSProperties;
|
||||||
onEdgeClick?: (event: React.MouseEvent, node: Edge) => void;
|
onEdgeClick?: (event: React.MouseEvent, node: Edge) => void;
|
||||||
onEdgeDoubleClick?: (event: React.MouseEvent, edge: Edge) => void;
|
onEdgeDoubleClick?: (event: React.MouseEvent, edge: Edge) => void;
|
||||||
defaultMarkerColor: string;
|
defaultMarkerColor: string;
|
||||||
@@ -75,6 +76,15 @@ const EdgeRenderer = (props: EdgeRendererProps) => {
|
|||||||
const { connectionLineType, defaultMarkerColor, connectionLineStyle, connectionLineComponent } = props;
|
const { connectionLineType, defaultMarkerColor, connectionLineStyle, connectionLineComponent } = props;
|
||||||
const renderConnectionLine = connectionNodeId && connectionHandleType;
|
const renderConnectionLine = connectionNodeId && connectionHandleType;
|
||||||
|
|
||||||
|
let { connectionLineContainerStyle } = props
|
||||||
|
if (connectionLineContainerStyle?.zIndex === undefined) {
|
||||||
|
// if not set already, set the zIndex to the max level of the any edge
|
||||||
|
connectionLineContainerStyle = {
|
||||||
|
...connectionLineContainerStyle,
|
||||||
|
zIndex: edgeTree.find(({ isMaxLevel }) => isMaxLevel)?.level
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{edgeTree.map(({ level, edges, isMaxLevel }) => (
|
{edgeTree.map(({ level, edges, isMaxLevel }) => (
|
||||||
@@ -179,22 +189,29 @@ const EdgeRenderer = (props: EdgeRendererProps) => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{renderConnectionLine && isMaxLevel && (
|
|
||||||
<ConnectionLine
|
|
||||||
connectionNodeId={connectionNodeId!}
|
|
||||||
connectionHandleId={connectionHandleId}
|
|
||||||
connectionHandleType={connectionHandleType!}
|
|
||||||
connectionPositionX={connectionPosition.x}
|
|
||||||
connectionPositionY={connectionPosition.y}
|
|
||||||
connectionLineStyle={connectionLineStyle}
|
|
||||||
connectionLineType={connectionLineType}
|
|
||||||
isConnectable={nodesConnectable}
|
|
||||||
CustomConnectionLineComponent={connectionLineComponent}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
))}
|
))}
|
||||||
|
{renderConnectionLine && <svg
|
||||||
|
style={connectionLineContainerStyle}
|
||||||
|
width={width}
|
||||||
|
height={height}
|
||||||
|
className="react-flow__edges react-flow__container"
|
||||||
|
>
|
||||||
|
<g>
|
||||||
|
<ConnectionLine
|
||||||
|
connectionNodeId={connectionNodeId!}
|
||||||
|
connectionHandleId={connectionHandleId}
|
||||||
|
connectionHandleType={connectionHandleType!}
|
||||||
|
connectionPositionX={connectionPosition.x}
|
||||||
|
connectionPositionY={connectionPosition.y}
|
||||||
|
connectionLineStyle={connectionLineStyle}
|
||||||
|
connectionLineType={connectionLineType}
|
||||||
|
isConnectable={nodesConnectable}
|
||||||
|
CustomConnectionLineComponent={connectionLineComponent}
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
</svg>}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ interface FlowRendererProps
|
|||||||
| 'edgeTypes'
|
| 'edgeTypes'
|
||||||
| 'snapGrid'
|
| 'snapGrid'
|
||||||
| 'connectionLineType'
|
| 'connectionLineType'
|
||||||
|
| 'connectionLineContainerStyle'
|
||||||
| 'arrowHeadColor'
|
| 'arrowHeadColor'
|
||||||
| 'onlyRenderVisibleElements'
|
| 'onlyRenderVisibleElements'
|
||||||
| 'selectNodesOnDrag'
|
| 'selectNodesOnDrag'
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ const GraphView = ({
|
|||||||
connectionLineType,
|
connectionLineType,
|
||||||
connectionLineStyle,
|
connectionLineStyle,
|
||||||
connectionLineComponent,
|
connectionLineComponent,
|
||||||
|
connectionLineContainerStyle,
|
||||||
selectionKeyCode,
|
selectionKeyCode,
|
||||||
multiSelectionKeyCode,
|
multiSelectionKeyCode,
|
||||||
zoomActivationKeyCode,
|
zoomActivationKeyCode,
|
||||||
@@ -125,6 +126,7 @@ const GraphView = ({
|
|||||||
connectionLineType={connectionLineType}
|
connectionLineType={connectionLineType}
|
||||||
connectionLineStyle={connectionLineStyle}
|
connectionLineStyle={connectionLineStyle}
|
||||||
connectionLineComponent={connectionLineComponent}
|
connectionLineComponent={connectionLineComponent}
|
||||||
|
connectionLineContainerStyle={connectionLineContainerStyle}
|
||||||
onEdgeUpdate={onEdgeUpdate}
|
onEdgeUpdate={onEdgeUpdate}
|
||||||
onlyRenderVisibleElements={onlyRenderVisibleElements}
|
onlyRenderVisibleElements={onlyRenderVisibleElements}
|
||||||
onEdgeContextMenu={onEdgeContextMenu}
|
onEdgeContextMenu={onEdgeContextMenu}
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ const ReactFlow = forwardRef<ReactFlowRefType, ReactFlowProps>(
|
|||||||
connectionLineType = ConnectionLineType.Bezier,
|
connectionLineType = ConnectionLineType.Bezier,
|
||||||
connectionLineStyle,
|
connectionLineStyle,
|
||||||
connectionLineComponent,
|
connectionLineComponent,
|
||||||
|
connectionLineContainerStyle,
|
||||||
deleteKeyCode = 'Backspace',
|
deleteKeyCode = 'Backspace',
|
||||||
selectionKeyCode = 'Shift',
|
selectionKeyCode = 'Shift',
|
||||||
multiSelectionKeyCode = 'Meta',
|
multiSelectionKeyCode = 'Meta',
|
||||||
@@ -169,6 +170,7 @@ const ReactFlow = forwardRef<ReactFlowRefType, ReactFlowProps>(
|
|||||||
connectionLineType={connectionLineType}
|
connectionLineType={connectionLineType}
|
||||||
connectionLineStyle={connectionLineStyle}
|
connectionLineStyle={connectionLineStyle}
|
||||||
connectionLineComponent={connectionLineComponent}
|
connectionLineComponent={connectionLineComponent}
|
||||||
|
connectionLineContainerStyle={connectionLineContainerStyle}
|
||||||
selectionKeyCode={selectionKeyCode}
|
selectionKeyCode={selectionKeyCode}
|
||||||
deleteKeyCode={deleteKeyCode}
|
deleteKeyCode={deleteKeyCode}
|
||||||
multiSelectionKeyCode={multiSelectionKeyCode}
|
multiSelectionKeyCode={multiSelectionKeyCode}
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ export interface ReactFlowProps extends HTMLAttributes<HTMLDivElement> {
|
|||||||
connectionLineType?: ConnectionLineType;
|
connectionLineType?: ConnectionLineType;
|
||||||
connectionLineStyle?: CSSProperties;
|
connectionLineStyle?: CSSProperties;
|
||||||
connectionLineComponent?: ConnectionLineComponent;
|
connectionLineComponent?: ConnectionLineComponent;
|
||||||
|
connectionLineContainerStyle?: CSSProperties;
|
||||||
deleteKeyCode?: KeyCode | null;
|
deleteKeyCode?: KeyCode | null;
|
||||||
selectionKeyCode?: KeyCode | null;
|
selectionKeyCode?: KeyCode | null;
|
||||||
multiSelectionKeyCode?: KeyCode | null;
|
multiSelectionKeyCode?: KeyCode | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user