API for configuring & watching the editor?

Hi,

A project I'm working on is using the node-red editor as some sort of interface to the main system. For that, I'm looking for a way to both configure the editor itself and watch (hook) when something happens.
I vaguely remember reading here about a way to configure which settings appear under the "Deploy" button, for example, or to hook when a user has pressed the "Deploy" button (i.e. calling my own function, sort of "OnDeploy()").

A couple of examples of my needs would be:

  1. When a user pressed "deploy", my function would be called. It would get the current flow, modify some nodes, and writes them back. Only then would the actual Deploy functionally would be invoked (either explicitly via my function, or implicitly at the end of my function).
  2. A similar functionality, yet triggered when a user has added a node from the palette into the workspace.

I've looked at the API's runtime hooks, yet I'm not sure if I'm in the right place. If I understand correctly, those hooks pertain to the runtime functionality of the flow, yet not during editing time?

Another place I looked at was the storage API, after reading this post. I'm not sure if this would fit my needs as well.

Am I looking in the right place/s? Is this functionality even possible, without modifying node-red's core code?

Thank you.

Hi @ItayKishon-Vayyar

the editor does not have the sorts of hooks built into it that you're looking for. To do it today will require customising the editor code.

Extensibility is a goal for both the runtime and editor - so it is an area I would like to improve. But as it stands, it isn't something we have specific plans for yet.

1 Like

Hi,

I'm taking part in the project that Itay was talking about.
Examining the application code, I found that the editor already has a hooks system (@node-red/editor-client/src/js/hooks.js). Using it, I implemented preDeploy, postDeploy and onDrop editor hooks. And that covers our needs.
I want to make sure that I'm on the right way to create a PR.

Thank you.

1 Like

We prefer to begin with a design and discussion before leaping straight to PR and code - especially when it comes to adding new external APIs.

You are welcome to raise a PR (against the dev branch as it is new functionality) and we can review/discuss there.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.