Hello, I'm creating a custom configuration node which uses a multiline code editor. However, the text entered into the editor isn't saving. Based on the instructions, I have the following:
oneditprepare: function () {
this.editor = RED.editor.createEditor({
id: "node-config-input-pttns",
mode: "ace/mode/text",
value: this.pttns ?? "",
});
},
oneditsave: function () {
const val = this.editor.getValue();
this.pttns = val ?? "^https:\/\/";
console.log("val | pttns", val, this.pttns);
this.editor.destroy();
delete this.editor;
console.log("oneditsave", this);
},
oneditcancel: function () {
this.editor.destroy();
delete this.editor;
},
You can see I've added a few console logs to try to debug the values. There are a few issues that I've been wracking my head trying to fix:
The original value of ^https:\/\/ isn't loaded into the editor.
The new value entered into the editor is picked up by getValue() and this.pttns is re-assigned locally, but logging this separately shows an empty pttns attribute.
The value is not persisted inside the flow json.
No errors are thrown on the client or the server.
What've I done wrong, how can I further debug this? Thanks
Rename the id node-config-input-pttns to something like pttns-editor
Or
Add a hidden element with the id of node-config-input-pttns and set it's value in oneditsave $('node-config-input-pttns').val(val)
The issue is node-config-input-pttns is bound to the defaults.pttns but the element never updated. So when the form closes, the defaults.pttn is set the the val() of the element (which is never updated). So the choices are don't add the html element or set the html element value manually.
brill! I was assuming that the binding to the node-config- ID would update when the editor was triggered, but obviously not. I went with option 1. Thank you