Export text in text editor

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

<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>

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

From the docs: Node properties : Node-RED

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.

Thank for the help :smiley:

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