@kseniass/react-flow-editor v2.4.7
Flow Editor
Try in your browser.
Main features
- DnD to move canvas or nodes
- Available autoScroll when DnD connection or nodes
- Multiple Selection with SHIFT + click nodes
- Multiple Selection with SHIFT and dragging select zone
- Delete (multiple too) selected nodes with DELETE/BACKSPACE
- DnD multiple selected nodes with SHIFT
- Scroll mouse to zoom
- Connectors could be disconnected from both edges
- Overview function to place all the nodes to viewPort
API
Editor Configuration
The editor props looks as follow
export type EditorProps = {
nodes: Node[]
setNodes: (action: SetStateAction<Node[]>) => void
transformation: Transformation
setTransformation: (transformation: Transformation) => void
onSelectionZoneChanged?: (value: RectZone) => void
onEditorRectsMounted?: (value: OnEditorRectsMountedProps) => void
styleConfig?: StyleConfig
}
export type Output = {
id: string
position: Point
nextNodeId: string | null
}
export type NodeBase = {
id: string
outputs: Output[]
position: Point
rectPosition?: DOMRect
inputPosition?: Point
inputNumber: number
state: NodeState | null
}
export type Node = NodeBase & {
children: React.FC<NodeProps>
}
export type NodeProps = NodeBase & {
onSizeChanged: () => void
}
export type Transformation = {
dx: number
dy: number
zoom: number
}
export type RectZone = {
left: number
right: number
top: number
bottom: number
}
export type OnEditorRectsMountedProps = {
zoomContainerRef: MutableRefObject<HTMLDivElement>
editorContainerRef: MutableRefObject<HTMLDivElement>
overview: () => void
}
Prop | Description |
---|---|
nodes | Array of nodes to render in editor |
setNodes | Function for nodes managing |
transformation | Editor translate and scale transformation |
setTransformation | Transformation managing function |
onEditorRectsMounted | Callback for receiving editor DOMRect and nodes container DOMRect |
onSelectionZoneChanged | Callback for receiving selection zone coordinates |
styleConfig | Config of editor parts styles |
Node
Prop | Description |
---|---|
id | The unique identifier for the node |
position | Coordinates of the node |
rectPosition | DOMRect for the node |
outputs | Array of outputs. Each output contains data about point position (relatively to node) and connected node id. |
inputPosition | Position of input point for connectors (relatively to node) |
inputNumber | Max number of inputs |
state | Node state |
Node states
null
dragging
selected
draggingConnector
connectorHovered
Rules for node states
- node mouseDown = no changes in state
- node mouseDown -> mouseUp =
selected
- node mouseDown -> mouseMove =
dragging
node mouseDown -> mouseMove -> mouseUp =
null
SHIFT + node mouseDown = no changes in state
- SHIFT + (node mouseDown -> mouseUp) =
selected
- SHIFT + (node mouseDown-> mouseMove) =
dragging
SHIFT + (node mouseDown-> mouseMove -> mouseUp) =
selected
SHIFT + (node click -> node_2 click) =
selected
both- SHIFT + (node click -> node_2 click -> (node or node_2) mouseDown -> mouseMove) =
dragging
both SHIFT + (node click -> node_2 click -> (node or node_2) mouseDown -> mouseMove -> mouseUp) =
selected
bothDnD from node_1 point =
draggingConnector
- DnD from node_1 point over node_2 point = node_1
draggingConnector
and node_2connectorHovered
DnD from node_1 point drop in any place =
null
for allclick away from nodes =
null
for all
Transfromation
Prop | Description |
---|---|
dx | Horizontal editor offset |
dy | Vertical editor offset |
zoom | Editor zoom |
Selection zone
Prop | Description |
---|---|
cornerStart | Coordinates of the start selection point |
cornerEnd | Coordinates of the end selection point |
OnEditorRectsMountedProps
Prop | Description |
---|---|
zoomContainerRef | React Ref Object of nodes container |
editorContainerRef | React Ref Object of editor |
overview | Function for applying transformation to place all the nodes into viewPort |
styleConfig
Prop | Description |
---|---|
point | Point styles |
connector | Connector styles |
PointStyleConfig
Prop | Description |
---|---|
width | Point width |
height | Point height |
color | Point color |
ConnectorStyleConfig
Prop | Description |
---|---|
width | Connector width |
color | Connector color |
Changelog
8 months ago
9 months ago
8 months ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago