newcat / baklavajs

Graph / node editor in the browser using VueJS
http://baklava.tech
MIT License
1.47k stars 107 forks source link

[V2] How to give extra props to component used in custom NodeInterface #407

Closed neko-para closed 2 months ago

neko-para commented 3 months ago
import { NodeInterface } from 'baklavajs'
import { markRaw } from 'vue'

import ISelectComp from './ISelectComp.vue'

export class ISelectInterface<KeySet extends string> extends NodeInterface<KeySet> {
  constructor(name: string, def: KeySet, vals: KeySet[]) {
    super(name, def)
    this.setComponent(markRaw(ISelectComp))
    this.setPort(false)
  }
}

As shown above, I've set ISelectComp as the component. Beside modelValue, it requires some extra options (like the vals as the choices). But how can I pass these options? I've searched documents and issues but not found yet.

neko-para commented 3 months ago

After inspect into the predefined interfaces, it seems that there is a prop intf with the type of the defined interface passed. Hope this information could be mentioned in the document.

newcat commented 3 months ago

Is this what you are looking for? https://v2.baklava.tech/visual-editor/customization.html#custom-components