Skip to content

Custom Connection class #64

@Fi1osof

Description

@Fi1osof

Now editor.addConnection passed pure data:

    context.editor.addConnection({
      id: getUID(),
      source: source.nodeId,
      sourceOutput: source.key,
      target: target.nodeId,
      targetInput: target.key
    })

But we can use cusom Connection class, f.e.: https://github.com/Ni55aN/allmatter/blob/main/src/editor/connections/index.ts

import { ClassicPreset } from 'rete'
import { Node } from '../types';

export class Connection<A extends Node, B extends Node> extends ClassicPreset.Connection<A, B> { }

https://github.com/Ni55aN/allmatter/blob/main/src/editor/import-export.ts#L81-L83

      const conn = new Connection(source, c.sourceOutput, target, c.targetInput);

      await di.editor.addConnection(conn);

I want to have ability to provide connection class resolver (middleware) like this

  render.addPreset(Presets.classic.setup({
    customize: {
      control(data) {
        if (data.payload instanceof ColorPicker) return ColorPickerUI
        if (data.payload instanceof Preview) return PreviewUI
        return Presets.classic.InputControl as any
      },
    }
  }));

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions