Custom node category and node-red retro compatibility

Hi there!

As per node-red 1.0.0, most i/o nodes have been moved to the network category.
This makes some of our custom nodes look all alone and sad in their old input and output categories. We want to move them to the new network category, but keep input and output for <1.0.0 installs.
What would be the best way to achieve this? I looked a bit but didn't find anything in the docs regarding this.

Thanks!

I have not personally used RED.version() in a custom node myself.
https://nodered.org/docs/api/modules/v/0.20.0/node-red.html#.version
Seeing that the category in the palette is specified in the HTML file that has access to RED.foo kind of functions, you could try to define it as a ternary: category: version >= 1 ? 'network' : 'input', where version would be the major from the aforementioned function.

1 Like

I'll try this, thanks!

That will not work because RED.version() is a runtime API available in the JavaScript file - but the node category is set in the HTML file. There is no equivalent API available in the HTML side of things.

Taking the API docs in mind, when calling RED.nodes.registerType in the HTML file, which of the RED.nodes parts does it refer to?

The docs you link to are all runtime docs. We haven't formally documented the html side API beyond what is described throughout the 'creating nodes' docs.

Good to know. That means I've been referencing the wrong docs for both relevant topics, as well as working on nodes myself all the time. Note to self for the future, definitely. Thanks :smiley: