# Export text in text editor

**URL:** <https://discourse.nodered.org/t/export-text-in-text-editor/84394>\
**Category:** Developing Nodes\
**Tags:** function-node\
**Created:** [8 January 2024 15:37 UTC](https://discourse.nodered.org/t/export-text-in-text-editor/84394 "2024-01-08T15:37:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![riri](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@riri](https://discourse.nodered.org/u/riri)\
**Post date:** [8 January 2024 15:37 UTC](https://discourse.nodered.org/t/export-text-in-text-editor/84394/1 "2024-01-08T15:37:44Z")

</div>

hi everyone

I am creating a custom node containing a text editor, except that I would like the existing text in the text editor to be in the export json which is not the case. I was looked at the function node on github but I could not understand how it made here is my code below. Thank you in advance for your help

```auto
<script type="text/javascript">
    RED.nodes.registerType('InitSVI',{
        category: 'matrice_svi',
        color: '#EF4040',
        defaults: {
            name: {value:"",required:true},
            statName:{value:""},
            func:{}
        },
        inputs: 0,
        outputs: 1,
        icon: "icons/icon.svg",
        label: function() {
            return this.name||"InitSVI";
        },
        oneditprepare: function () {
            this.editor = RED.editor.createEditor({
            id: 'node-input-example-editor',
            mode: 'ace/mode/json',
            value: this.exampleText
        });
        },
        oneditsave: function() {
            this.exampleText = this.editor.getValue();
            this.editor.destroy();
            delete this.editor;
        },
        oneditcancel: function() {
            this.editor.destroy();
            delete this.editor;
        },
    });
</script>

<script type="text/html" data-template-name="InitSVI">

    <div class="form-row">
        <label for="node-input-name"><i class="fa fa-tag"></i>Name</label>
        <input type="text" id="node-input-name" placeholder="Name">
    </div>
    <div class="form-row">
        <label for="node-input-statName"><i class="fa fa-tag"></i>statName</label>
        <input type="text" id="node-input-statName" placeholder="statName">
    </div>
    <div style="height: 90%; min-height:150px;width: 90%;margin: auto;" class="node-text-editor" id="node-input-example-editor"></div>

</script>
<script type="text/html" data-help-name="InitSVI">
    <p>Noeud InitSVI du SVI</p>
</script>

```

---

<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:** [8 January 2024 15:59 UTC](https://discourse.nodered.org/t/export-text-in-text-editor/84394/2 "2024-01-08T15:59:33Z")

</div>

> [@riri](#):
>
> ```auto
> defaults: {
> name: {value:"",required:true},
> statName:{value:""},
> func:{}
> },
> 
> ```

> [@riri](#):
>
> `this.exampleText = this.editor.getValue();`

`exampleText` is NOT in the `defaults: {...}` object so will not be saved to flow JSON

From the docs: [Node properties : Node-RED](https://nodered.org/docs/creating-nodes/properties)

> A node’s properties are defined by the `defaults` object in its html definition. These are the properties that get passed to the node constructor function when an instance of the node is created in the runtime.

---

<div class="post-metadata">

**Author:** ![riri](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@riri](https://discourse.nodered.org/u/riri)\
**Post date:** [9 January 2024 10:41 UTC](https://discourse.nodered.org/t/export-text-in-text-editor/84394/3 "2024-01-09T10:41:52Z")

</div>

Thank for the help 😃

---

<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 2024 10:42 UTC](https://discourse.nodered.org/t/export-text-in-text-editor/84394/4 "2024-01-23T10:42:29Z")

</div>

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