retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
10.17k stars 653 forks source link

How to send an event to a node #602

Closed xakslim closed 1 year ago

xakslim commented 1 year ago

Hello. I created custom nodes with a certain number of inputs and outputs. node fields are displayed in a separate dialog box. everything works here. at the moment I need to carry out the necessary checks. for example, I should not have unconnected nodes. and it is necessary to highlight this node and display an error under it. How can I send an event to a node? using vue2? vue-render-plugin, area-plugin

Ni55aN commented 1 year ago

do you need to display an error inside the node block or outside? In the first case definitely you need a custom node

xakslim commented 1 year ago

needed outside. The custom element already has a class and an error text. I get a list of invalid nodes, but somehow I need to pass either an event or this class to them

Ni55aN commented 1 year ago

but somehow I need to pass either an event or this class to them

const node = editor.nodes.find(node => ... // find particular node
node.data /// put error identifier or whatever into this object
node.update()

Respectively, your custom node should retrieve error info from node.data

Hatead1 commented 1 year ago

Event to node - https://codepen.io/hatead1/pen/eYKpOmr