# Adding modules to monaco editor

**URL:** https://discourse.nodered.org/t/adding-modules-to-monaco-editor/86153
**Category:** Developing Nodes
**Tags:** monaco
**Created:** [5 March 2024 11:24 UTC](https://discourse.nodered.org/t/adding-modules-to-monaco-editor/86153 "2024-03-05T11:24:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Felipet007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/felipet007/32/88914_2.png) [@Felipet007](https://discourse.nodered.org/u/Felipet007)
#### Post date: [5 March 2024 11:24 UTC](https://discourse.nodered.org/t/adding-modules-to-monaco-editor/86153/1 "2024-03-05T11:24:33Z")

</div>

Hi!

I'm trying to add modules to my Monaco editor but I don't know how to access to the monaco instance for doing that.

This is what I'm trying to do right now:

```auto
that.initEditor = () => {
        that.editor = RED.editor.createEditor({
          id: 'script-editor',
          mode: 'typescript',
          value: that.oldValue,
          fontLigatures: true
        });

       //now I want to change properties in my editor
 if(that.editor && that.editor.type === "monaco"){
         //ACCESS TO MONACO INSTANCE
         const tsDefaults = monaco.languages.typescript.typescriptDefaults;
        functionsDeclaration.forEach(fd =>
                  typeModels.push(tsDefaults.addExtraLib(fd.content, fd.filename))
          )
        }

```

I also want to configure my diagnostics options via: tsDefaults.setDiagnosticsOptions({}).

Can you help me, please?

Thank you!

---

<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: [5 March 2024 12:25 UTC](https://discourse.nodered.org/t/adding-modules-to-monaco-editor/86153/2 "2024-03-05T12:25:59Z")

</div>

> [@Felipet007](#):
>
> setDiagnosticsOptions

If it is for across your whole NR instance, then you can simply set those in `settings.js` file under

```javascript
    editorTheme: {
        codeEditor: {
            monaco: {
                languages: {
                     typescript: {
                        typescriptDefaults: {

```

> [@Felipet007](#):
>
> ` fontLigatures: true`

You should not be specifying things like this in your custom node. these kind of settings are personal to a user and should be user determined by the `options` object in `settings.js` or the users installed theme.

As for adding modules to monaco editor, this is not something yet formalised or implemented in the core as an exposed API. You could look at the node-red source and see if you can support this for the up-coming Node-RED v4 release (now is the time to add this kind of support)

---

<div class="post-metadata">

### Author: ![Felipet007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/felipet007/32/88914_2.png) [@Felipet007](https://discourse.nodered.org/u/Felipet007)
#### Post date: [5 March 2024 12:57 UTC](https://discourse.nodered.org/t/adding-modules-to-monaco-editor/86153/3 "2024-03-05T12:57:55Z")

</div>

Hi, thanks for your answer.

I need this configuration for my custom node exclusively and for me, the important thing is to achieve adding modules. Having the editor instance, it is possible to access to the monaco instance?

Thanks for your answer

---

<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: [4 May 2024 12:58 UTC](https://discourse.nodered.org/t/adding-modules-to-monaco-editor/86153/4 "2024-05-04T12:58:11Z")

</div>

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