Is there any way of adding additional language support in a node that I'm developing with the Monaco Editor?

When the official editor of Node-RED was the Ace editor, even though it couldn't support all languages of the Ace editor, I still had the option of getting additional languages on their GitHub page, just so I could develop a node with support for other languages than the ones that Node-RED support by default... The page where I can find additional languages for the Ace Editor is this one:

However, I'd like to add additional languages to the Monaco editor since Node-RED is moving towards making it the default one... But checking the source code I see that the languages in Monaco seem to be all included in the file node-red/packages/node_modules/@node-red/editor-client/src/vendor/monaco/dist/editor.js... And I can only use the languages that are officially supported in Monaco

https://microsoft.github.io/monaco-editor/

I'd like to add support for LaTex in the editor of my node though, I've found a file for highlight syntax that Monaco supports

But I'm not sure if I can use it in Node-RED. Is it possible? Can I add additional languages to the editor of a node that I'm developing if I have a file with the Monarch syntax highlighting?

There is no API support in node-red - that would be the optimal way. If you feel up to the challenge you could contribute this to the node-red core

Alternatively you can programmatically setup a language direct on the monaco object. That's how we add JSONata support. However there are no guarantees future updates to node-red (and Monaco) would not break your node.

You can access the monaco object in window.monaco and configure your language support.

See how we did this for JSONata in the node-red src: node-red/packages/node_modules/@node-red/editor-client/src/js/ui/editors/code-editors/monaco.js at 37265cf4ef69571c0edc608189826da9504d1fde · node-red/node-red · GitHub

Thanks, I'll try doing it directly in my node by now.

But just as a curiosity, what would be the general procedure for doing it in an optimal way?

A discussion on design of the API then, once agreed, a pull request against the dev branch on the node-red repo is the way to go.

We can get a design discussion opened if you wish to travel down this path. Just let me know.

1 Like

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