# RED.library without RED.editor?

**URL:** https://discourse.nodered.org/t/red-library-without-red-editor/61247
**Category:** Developing Nodes
**Created:** [13 April 2022 14:57 UTC](https://discourse.nodered.org/t/red-library-without-red-editor/61247 "2022-04-13T14:57:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Fredrik](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fredrik/32/107652_2.png) [@Fredrik](https://discourse.nodered.org/u/Fredrik)
#### Post date: [13 April 2022 14:57 UTC](https://discourse.nodered.org/t/red-library-without-red-editor/61247/1 "2022-04-13T14:57:15Z")

</div>

I've been hacking away at RED.library, trying to understand how it works. I'm actually getting somewhere and managed to save and read information from the library in my test node.

However, I have a question. Is there a way to use the library function and NOT use an editor?

```auto
RED.library.create({
                url:"templates", // where to get the data from
                type:"template", // the type of object the library is for
                editor:that.editor, // the field name the main text body goes to
                fields:['name'],
                ext: "txt"
            });

```

I've tried to not including the editor parameter, which fails, and tried to just create an editor object and not use it, which works but looks kinda ugly:

```auto
RED.library.create({
                url:"templates", // where to get the data from
                type:"template", // the type of object the library is for
                editor:RED.editor.createEditor()
});

```

Any way to just skip it?

Thanks.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [13 April 2022 18:09 UTC](https://discourse.nodered.org/t/red-library-without-red-editor/61247/2 "2022-04-13T18:09:48Z")

</div>

Not sure there is a way to skip it. The only uses of the library API for saving individual nodes has been for nodes that have an editor - such as the Function and Template nodes. So it is probably a built-in assumption that there is a editor to save/restore from.

I'm sure it's something that could be improved if there was a specific requirement.

---

<div class="post-metadata">

### Author: ![Fredrik](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fredrik/32/107652_2.png) [@Fredrik](https://discourse.nodered.org/u/Fredrik)
#### Post date: [14 April 2022 06:57 UTC](https://discourse.nodered.org/t/red-library-without-red-editor/61247/3 "2022-04-14T06:57:29Z")

</div>

Good to know, thanks knolleary.

I want to use it to save a definition of a Thing in node-red-contrib-hal2, to use as a template for creating other similar Things so you don't have to start from scratch each time. I'll try it, see how far I get! 😉

---

<div class="post-metadata">

### Author: ![Fredrik](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fredrik/32/107652_2.png) [@Fredrik](https://discourse.nodered.org/u/Fredrik)
#### Post date: [15 April 2022 17:31 UTC](https://discourse.nodered.org/t/red-library-without-red-editor/61247/4 "2022-04-15T17:31:31Z")

</div>

Okay, this actually worked pretty well, but I did run into a few problems.

RED.editor obviously, but I got around that by creating an editor object and just not use it.

The node where I want to use RED.library is actually a config node, and RED.library didn't like that much. I ended up creating a hidden input with id='node-input-name' and kept it up to date with an on change function in 'oneditprepare'. Kinda ugly, but works.

```auto
  $('#node-config-input-name').on('change', function() {
      $("#node-input-name").val($('#node-config-input-name').val());
  });

```

Named fields doesn't work for the same reason, but that was fairly easy to get around.

```auto
fields:[
      {
          name: 'show_state',
          get: function() {
              return $("#node-config-input-nodestatus").val();
          },
          set: function(v) {
              $("#node-config-input-nodestatus").val(v)
          }
      }
]

```

It's a great function. I wouldn't mind seeing it getting a bit more love in future releases!

---

<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: [14 June 2022 17:32 UTC](https://discourse.nodered.org/t/red-library-without-red-editor/61247/5 "2022-06-14T17:32:05Z")

</div>

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