With a custom node's parameter configuration editor, I'd like to convert a multi-line textarea's content from a single string to a list of strings, one per line.
Here is how I tried it with mynode.html
oneditsave: function() {
var node = this;
var nameText = $("#node-input-names").val();
var names = nameText.split('\n');
console.log(`node: ${Array.isArray(names)}`);
node.names = names;
}
....
<div class="form-tips"><i class="fa fa-hand-o-down"></i> user names</div>
<div class="form-row">
<label for="node-input-names"><i class="fa fa-list"></i>Names</label>
<textarea id="node-input-names" name="names">john smith</textarea>
</div>
When saving the node in the editor, I can see the print out "node: true", meaning the text extracted from textarea has been converted to an array of strings.
However, in mynode.js, I plugged
function myNode(this, config) {
...
console.log(`config.names is array: ${Array.isArray(config.names)}`);
...
This time I got
config.names is array: false
where I expect it to be
config.names is array: true
I also tried to set the textarea content in oneditsave() and that works as long as I provide a string to it.
What am I missing? Is it that I'm not allowed to convert variable types there?