API for rete-render-utils package - Rete.js

API for rete-render-utils package

BaseSocketPosition

sockets-position/base-socket-position.ts

Abstract class for socket position calculation. It can be extended to implement custom socket position calculation.

ts
class BaseSocketPosition<Schemes extends BaseSchemes, K extends unknown>
ParameterExtendsDescription
SchemesBaseSchemes
Kunknown

Extended by DOMSocketPosition

Implements SocketPositionWatcher<Scope<never, K>>

Listens render rendered unmount nodetranslated noderesized

attach

sockets-position/base-socket-position.ts

Attach the watcher to the area's child scope.

ts
attach(scope: Scope<never, [K]>): void
ParameterTypeDescription
scopeScope<never, [K]>Scope of the watcher that should be a child of BaseAreaPlugin

Returns void

calculatePosition

sockets-position/base-socket-position.ts

The method needs to be implemented that calculates the position of the socket.

ts
calculatePosition(nodeId: string, side: Side, key: string, element: HTMLElement): Promise<null | Position>
ParameterTypeDescription
nodeIdstringNode ID
sideSideSide of the socket, 'input' or 'output'
keystringSocket key
elementHTMLElementSocket element

Returns Promise<null | Position>

listen

sockets-position/base-socket-position.ts

Listen to socket position changes. Usually used by rendering plugins to update the start/end of the connection.

ts
listen(nodeId: string, side: Side, key: string, change: OnChange): () => void
ParameterTypeDescription
nodeIdstringNode ID
sideSideSide of the socket, 'input' or 'output'
keystringSocket key
changeOnChangeCallback function that is called when the socket position changes

Returns () => void

DOMSocketPosition

sockets-position/dom-socket-position.ts

Class for socket position calculation based on DOM elements. It uses getElementCenter function to calculate the position.

ts
class DOMSocketPosition<Schemes extends BaseSchemes, K extends unknown>
ParameterExtendsDescription
SchemesBaseSchemes
Kunknown

Extends BaseSocketPosition<Schemes, K>

attach

sockets-position/base-socket-position.ts

Attach the watcher to the area's child scope.

ts
attach(scope: Scope<never, [K]>): void
ParameterTypeDescription
scopeScope<never, [K]>Scope of the watcher that should be a child of BaseAreaPlugin

Returns void

listen

sockets-position/base-socket-position.ts

Listen to socket position changes. Usually used by rendering plugins to update the start/end of the connection.

ts
listen(nodeId: string, side: Side, key: string, change: OnChange): () => void
ParameterTypeDescription
nodeIdstringNode ID
sideSideSide of the socket, 'input' or 'output'
keystringSocket key
changeOnChangeCallback function that is called when the socket position changes

Returns () => void

SocketPositionWatcher

sockets-position/types.ts

Interface for socket position watcher.

ts
type SocketPositionWatcher<ChildScope extends unknown> = {
  attach: unknown;
  listen: unknown;
};
ParameterExtendsDescription
ChildScopeunknown

Implemented by BaseSocketPosition

classicConnectionPath

connection.ts

Get classic SVG path for a connection between two points.

ts
classicConnectionPath(points: [Position, Position], curvature: number): string
ParameterTypeDescription
points[Position, Position]Array of two points
curvaturenumberCurvature of the connection

Returns string

getDOMSocketPosition

sockets-position/dom-socket-position.ts

Wrapper function for DOMSocketPosition class.

ts
getDOMSocketPosition(props: Props): DOMSocketPosition<Schemes, K>
ParameterTypeDescription
propsPropsProps for DOMSocketPosition class

Returns DOMSocketPosition<Schemes, K>

getElementCenter

utils.ts

Calculates the center coordinates of a child element relative to a parent element.

ts
getElementCenter(child: HTMLElement, parent: HTMLElement): Promise<{ x: number, y: number }>

Throws Error if the child element has a null offsetParent.

ParameterTypeDescription
childHTMLElementThe child element whose center coordinates need to be calculated.
parentHTMLElementThe 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

loopConnectionPath

connection.ts

Get loop SVG path for a connection between two points.

ts
loopConnectionPath(points: [Position, Position], curvature: number, size: number): string
ParameterTypeDescription
points[Position, Position]Array of two points
curvaturenumberCurvature of the loop
sizenumberSize of the loop

Returns string