mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add jsonata function help
This commit is contained in:
@@ -23,7 +23,7 @@ RED.i18n = (function() {
|
||||
dynamicLoad: false,
|
||||
load:'current',
|
||||
ns: {
|
||||
namespaces: ["editor","node-red"],
|
||||
namespaces: ["editor","node-red","jsonata"],
|
||||
defaultNs: "editor"
|
||||
},
|
||||
fallbackLng: ['en-US'],
|
||||
|
@@ -85,6 +85,7 @@
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
var allOptions = {
|
||||
msg: {value:"msg",label:"msg.",validate:validateExpression},
|
||||
flow: {value:"flow",label:"flow.",validate:validateExpression},
|
||||
@@ -103,9 +104,9 @@
|
||||
expand:function() {
|
||||
var that = this;
|
||||
RED.editor.editExpression({
|
||||
value: this.value(),
|
||||
value: jsonata.format(this.value()),
|
||||
complete: function(v) {
|
||||
that.value(v);
|
||||
that.value(v.replace(/\s*\n\s*/g," "));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@@ -1392,6 +1392,7 @@ RED.editor = (function() {
|
||||
text: RED._("common.label.done"),
|
||||
class: "primary",
|
||||
click: function() {
|
||||
$("#node-input-expression-help").html("");
|
||||
onComplete(expressionEditor.getValue());
|
||||
RED.tray.close();
|
||||
}
|
||||
@@ -1412,8 +1413,19 @@ RED.editor = (function() {
|
||||
},
|
||||
open: function(tray) {
|
||||
var trayBody = tray.find('.editor-tray-body');
|
||||
var dialogForm = buildEditForm(tray,'dialog-form','_expression');
|
||||
var dialogForm = buildEditForm(tray,'dialog-form','_expression','editor');
|
||||
var funcSelect = $("#node-input-expression-func");
|
||||
jsonata.functions.forEach(function(f) {
|
||||
funcSelect.append($("<option></option>").val(f).text(f));
|
||||
})
|
||||
funcSelect.change(function(e) {
|
||||
var f = $(this).val();
|
||||
var args = RED._('jsonata:'+f+".args",{defaultValue:''});
|
||||
var title = "<h4>"+f+"("+args+")</h4>";
|
||||
var body = marked(RED._('jsonata:'+f+'.desc',{defaultValue:''}));
|
||||
$("#node-input-expression-help").html(title+"<p>"+body+"</p>");
|
||||
|
||||
})
|
||||
expressionEditor = RED.editor.createEditor({
|
||||
id: 'node-input-expression',
|
||||
value: "",
|
||||
@@ -1426,6 +1438,15 @@ RED.editor = (function() {
|
||||
});
|
||||
expressionEditor.getSession().setValue(value||"",-1);
|
||||
|
||||
expressionEditor.on("changeSelection", function() {
|
||||
var c = expressionEditor.getCursorPosition();
|
||||
var token = expressionEditor.getSession().getTokenAt(c.row,c.column);
|
||||
//console.log(token);
|
||||
if (token && token.type === 'keyword') {
|
||||
funcSelect.val(token.value).change();
|
||||
}
|
||||
});
|
||||
|
||||
dialogForm.i18n();
|
||||
|
||||
},
|
||||
|
Reference in New Issue
Block a user