mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add insert-function button to expression editor
This commit is contained in:
parent
8caee09ea4
commit
eeaff6b553
@ -167,7 +167,8 @@ module.exports = function(grunt) {
|
||||
'public/red/main.min.js': 'public/red/main.js',
|
||||
'public/vendor/jsonata/jsonata.min.js': 'public/vendor/jsonata/jsonata.js',
|
||||
'public/vendor/ace/mode-jsonata.js': 'editor/vendor/jsonata/mode-jsonata.js',
|
||||
'public/vendor/ace/worker-jsonata.js': 'editor/vendor/jsonata/worker-jsonata.js'
|
||||
'public/vendor/ace/worker-jsonata.js': 'editor/vendor/jsonata/worker-jsonata.js',
|
||||
'public/vendor/ace/snippets/jsonata.js': 'editor/vendor/jsonata/snippets-jsonata.js'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1421,7 +1421,7 @@ RED.editor = (function() {
|
||||
funcSelect.change(function(e) {
|
||||
var f = $(this).val();
|
||||
var args = RED._('jsonata:'+f+".args",{defaultValue:''});
|
||||
var title = "<h4>"+f+"("+args+")</h4>";
|
||||
var title = "<h5>"+f+"("+args+")</h5>";
|
||||
var body = marked(RED._('jsonata:'+f+'.desc',{defaultValue:''}));
|
||||
$("#node-input-expression-help").html(title+"<p>"+body+"</p>");
|
||||
|
||||
@ -1432,7 +1432,7 @@ RED.editor = (function() {
|
||||
mode:"ace/mode/jsonata",
|
||||
options: {
|
||||
enableBasicAutocompletion:true,
|
||||
enableSnippets:false,
|
||||
enableSnippets:true,
|
||||
enableLiveAutocompletion: true
|
||||
}
|
||||
});
|
||||
@ -1448,7 +1448,16 @@ RED.editor = (function() {
|
||||
});
|
||||
|
||||
dialogForm.i18n();
|
||||
|
||||
$("#node-input-expression-func-insert").click(function(e) {
|
||||
e.preventDefault();
|
||||
var pos = expressionEditor.getCursorPosition();
|
||||
var f = funcSelect.val();
|
||||
var args = RED._('jsonata:'+f+".args",{defaultValue:''});
|
||||
expressionEditor.insert(f+"("+args+")");
|
||||
pos.column += f.length+1;
|
||||
expressionEditor.moveCursorToPosition(pos);
|
||||
expressionEditor.focus();
|
||||
})
|
||||
},
|
||||
close: function() {
|
||||
editStack.pop();
|
||||
|
@ -166,7 +166,7 @@
|
||||
<div class="form-row">
|
||||
<label for="node-input-expression-func" data-i18n="expressionEditor.functions"></label>
|
||||
<select id="node-input-expression-func"></select>
|
||||
|
||||
<button id="node-input-expression-func-insert" class="editor-button" data-i18n="expressionEditor.insert"></button>
|
||||
<div style="min-height: 200px;" id="node-input-expression-help"></div>
|
||||
</div>
|
||||
</script>
|
||||
|
3
editor/vendor/jsonata/jsonata.js
vendored
3
editor/vendor/jsonata/jsonata.js
vendored
@ -2788,6 +2788,9 @@ var jsonata = (function() {
|
||||
},
|
||||
assign: function (name, value) {
|
||||
environment.bind(name, value);
|
||||
},
|
||||
ast: function() {
|
||||
return ast;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -320,6 +320,7 @@
|
||||
"empty": "No matches found"
|
||||
},
|
||||
"expressionEditor": {
|
||||
"functions": "Functions"
|
||||
"functions": "Functions",
|
||||
"insert": "Insert"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user