rete-render-utils packagesockets-position/base-socket-position.ts
Abstract class for socket position calculation. It can be extended to implement custom socket position calculation.
class BaseSocketPosition<Schemes extends BaseSchemes, K extends unknown>
| Parameter | Extends | Description | 
|---|---|---|
| Schemes | BaseSchemes | |
| K | unknown | 
Extended by DOMSocketPosition
Implements SocketPositionWatcher<Scope<never, K>>
Listens render rendered unmount nodetranslated noderesized
sockets-position/base-socket-position.ts
Attach the watcher to the area's child scope.
attach(scope: Scope<never, [K]>): void
| Parameter | Type | Description | 
|---|---|---|
| scope | Scope<never, [K]> | Scope of the watcher that should be a child of BaseAreaPlugin | 
Returns void
sockets-position/base-socket-position.ts
The method needs to be implemented that calculates the position of the socket.
calculatePosition(nodeId: string, side: Side, key: string, element: HTMLElement): Promise<null | Position>
| Parameter | Type | Description | 
|---|---|---|
| nodeId | string | Node ID | 
| side | Side | Side of the socket, 'input' or 'output' | 
| key | string | Socket key | 
| element | HTMLElement | Socket element | 
Returns Promise<null | Position>
sockets-position/base-socket-position.ts
Listen to socket position changes. Usually used by rendering plugins to update the start/end of the connection.
listen(nodeId: string, side: Side, key: string, change: OnChange): () => void
| Parameter | Type | Description | 
|---|---|---|
| nodeId | string | Node ID | 
| side | Side | Side of the socket, 'input' or 'output' | 
| key | string | Socket key | 
| change | OnChange | Callback function that is called when the socket position changes | 
Returns () => void
sockets-position/dom-socket-position.ts
Class for socket position calculation based on DOM elements. It uses getElementCenter function to calculate the position.
class DOMSocketPosition<Schemes extends BaseSchemes, K extends unknown>
| Parameter | Extends | Description | 
|---|---|---|
| Schemes | BaseSchemes | |
| K | unknown | 
Extends BaseSocketPosition<Schemes, K>
sockets-position/base-socket-position.ts
Attach the watcher to the area's child scope.
attach(scope: Scope<never, [K]>): void
| Parameter | Type | Description | 
|---|---|---|
| scope | Scope<never, [K]> | Scope of the watcher that should be a child of BaseAreaPlugin | 
Returns void
sockets-position/base-socket-position.ts
Listen to socket position changes. Usually used by rendering plugins to update the start/end of the connection.
listen(nodeId: string, side: Side, key: string, change: OnChange): () => void
| Parameter | Type | Description | 
|---|---|---|
| nodeId | string | Node ID | 
| side | Side | Side of the socket, 'input' or 'output' | 
| key | string | Socket key | 
| change | OnChange | Callback function that is called when the socket position changes | 
Returns () => void
Interface for socket position watcher.
type SocketPositionWatcher<ChildScope extends unknown> = {
  attach: unknown;
  listen: unknown;
};
| Parameter | Extends | Description | 
|---|---|---|
| ChildScope | unknown | 
Implemented by BaseSocketPosition
Get classic SVG path for a connection between two points.
classicConnectionPath(points: [Position, Position], curvature: number): string
| Parameter | Type | Description | 
|---|---|---|
| points | [Position, Position] | Array of two points | 
| curvature | number | Curvature of the connection | 
Returns string
sockets-position/dom-socket-position.ts
Wrapper function for DOMSocketPosition class.
getDOMSocketPosition(props: Props): DOMSocketPosition<Schemes, K>
| Parameter | Type | Description | 
|---|---|---|
| props | Props | Props for DOMSocketPositionclass | 
Returns DOMSocketPosition<Schemes, K>
Calculates the center coordinates of a child element relative to a parent element.
getElementCenter(child: HTMLElement, parent: HTMLElement): Promise<{ x: number, y: number }>
Throws Error if the child element has a null offsetParent.
| Parameter | Type | Description | 
|---|---|---|
| child | HTMLElement | The child element whose center coordinates need to be calculated. | 
| parent | HTMLElement | The parent element relative to which the child element's center is calculated. | 
Returns Promise<{ x: number, y: number }>
Position of the child element's center
Get loop SVG path for a connection between two points.
loopConnectionPath(points: [Position, Position], curvature: number, size: number): string
| Parameter | Type | Description | 
|---|---|---|
| points | [Position, Position] | Array of two points | 
| curvature | number | Curvature of the loop | 
| size | number | Size of the loop | 
Returns string