API for rete-connection-plugin package - Rete.js

API for rete-connection-plugin package

Connection

types.ts

Signal types produced by ConnectionPlugin instance

ts
type Connection =
  | { data: Object; type: "connectionpick" }
  | { data: Object; type: "connectiondrop" };

ConnectionPlugin

index.ts

Connection plugin. Responsible for user interaction with connections (creation, deletion)

ts
class ConnectionPlugin<Schemes extends ClassicScheme, K extends unknown>
ParameterExtendsDescription
SchemesClassicScheme
Kunknown

Extends Scope<Connection, Requires | K>

Emits connectionpick connectiondrop

Listens pointermove pointerup render unmount

addPreset

index.ts

Add preset to the plugin

ts
addPreset(preset: Preset<Schemes>): void
ParameterTypeDescription
presetPreset<Schemes>Preset to add

Returns void

drop

index.ts

Drop pseudo-connection if exists

ts
drop(): void

Emits connectiondrop

Returns void

Presets

presets/index.ts

Built-in presets

classic

presets/classic.ts

setup

presets/classic.ts

Classic preset. Uses ClassicFlow for managing connections by user

ts
setup(): () => ClassicFlow<ClassicScheme, any[]>

Returns () => ClassicFlow<ClassicScheme, any[]>

BidirectFlow

flow/builtin/bidirect.ts

Bidirect flow. User can pick a socket and connect it by releasing mouse button. More simple than classic flow, but less functional (can't remove connection by clicking on input socket).

ts
class BidirectFlow<Schemes extends ClassicScheme, K extends any[]>
ParameterExtendsDescription
SchemesClassicScheme
Kany[]

Implements StateContext<Schemes, K>, Flow<Schemes, K>

ClassicFlow

flow/builtin/classic/index.ts

Classic flow. User can pick/click a socket and connect it by releasing/clicking on another socket. If connection already exists and user clicks on input socket, connection will be removed.

ts
class ClassicFlow<Schemes extends ClassicScheme, K extends any[]>
ParameterExtendsDescription
SchemesClassicScheme
Kany[]

Implements StateContext<Schemes, K>, Flow<Schemes, K>

BidirectParams

flow/builtin/bidirect.ts

Bidirect flow params

ts
type BidirectParams<Schemes extends ClassicScheme> = {
  makeConnection: Function;
  pickByClick: boolean;
};
ParameterExtendsDescription
SchemesClassicScheme

ClassicParams

flow/builtin/classic/index.ts

Classic flow params

ts
type ClassicParams<Schemes extends ClassicScheme> = {
  canMakeConnection: Function;
  makeConnection: Function;
};
ParameterExtendsDescription
SchemesClassicScheme

createPseudoconnection

pseudoconnection.ts

Create pseudoconnection. Used to trigger rendering of connection that is being created by user. Has additional isPseudo property in payload.

ts
createPseudoconnection(extra: Partial<Schemes["Connection"]>): { mount: Function, unmount: Function, isMounted: unknown, render: unknown }
ParameterTypeDescription
extraPartial<Schemes["Connection"]>Extra payload to add to connection

Returns { mount: Function, unmount: Function, isMounted: unknown, render: unknown }