# Multiline Text Editor with Javascript Formatting and custom context

**URL:** <https://discourse.nodered.org/t/multiline-text-editor-with-javascript-formatting-and-custom-context/99764>\
**Category:** Developing Nodes\
**Created:** [24 November 2025 10:56 UTC](https://discourse.nodered.org/t/multiline-text-editor-with-javascript-formatting-and-custom-context/99764 "2025-11-24T10:56:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TacticalNudge](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@TacticalNudge](https://discourse.nodered.org/u/TacticalNudge)\
**Post date:** [24 November 2025 10:56 UTC](https://discourse.nodered.org/t/multiline-text-editor-with-javascript-formatting-and-custom-context/99764/1 "2025-11-24T10:56:08Z")

</div>

Hi there....

I am currently stuck on this particular conundrum and can't seem to find a workaround.

The premise is that we have a node with two or three multi-line text editor inputs that will contain some user-editable javascript similar to the way the function block currently operates. The catch is that the context in which the script gets applied / executed is completely different to the one used by the function node- it does not make any node-red (RED, util, flow, global, context etc etc) or browser (window, document, etc) specific references but instead references custom properties, functions and types we've built for the node specifically- eg: for a the `Accounting Function Node` it might be:

```js
let account = accounts.getAccount(msg.acocuntID);
// do something with the account here.

```

where `accounts` is a type with a `getAccount` function declared on it that might fetch an account from the accounting system.  
Is there a simple way of removing / restricting what gets added to the mode specified in the `RED.editor.createEditor({.....})` call in terms of validation / auto-completion / intellisense or is my only real option to pull in an untainted instance of monaco via an iframe and embedding it in the node editor?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 November 2025 13:35 UTC](https://discourse.nodered.org/t/multiline-text-editor-with-javascript-formatting-and-custom-context/99764/2 "2025-11-24T13:35:28Z")

</div>

Iirc, createEditor returns an instance of the editor you can manipulate. The createEditor function does not provide a mechanism for applying custom completions itself. Also, Monaco is present in the window object (so importing a copy seems superfluous.

However , a means of providing options in the RED API would be the ideal in case Monaco ever changes its APIs (which it has done in the past). A plan and a PR to the core node red would be appreciated but realise this wouldn't help you in the short term.

---

<div class="post-metadata">

**Author:** ![TacticalNudge](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@TacticalNudge](https://discourse.nodered.org/u/TacticalNudge)\
**Post date:** [24 November 2025 23:12 UTC](https://discourse.nodered.org/t/multiline-text-editor-with-javascript-formatting-and-custom-context/99764/3 "2025-11-24T23:12:14Z")

</div>

I think the problem here is that monaco's languages exist in a type of "global context". Any changes such as registering another `compilationitemprovider` for javascript will result in in all javascript editors now applying that specific `compilationitemprovider`. The way around this is to declare a new language for the purpose: such in my previous example: `accounting_jay_esh` and then selectively reuse components defined for the javascript language definition from monaco.

The advantage of going this route is that you effectively start off with a blank slate and gradually add parts- it also means that you can filter out suggestions from the javascript that you don't want while adding custom ones.

I manged to get a proof of concept going, now I just need to tidy it up and package it for easy reuse.

Its probably worthwhile adopting a similar approach for the `function` node as well: That way obscure functions and packages like "MIDIAccess" (which is part of the web api) can be filtered out.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 January 2026 23:12 UTC](https://discourse.nodered.org/t/multiline-text-editor-with-javascript-formatting-and-custom-context/99764/4 "2026-01-23T23:12:24Z")

</div>

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