diff --git a/Gruntfile.js b/Gruntfile.js index 4fc9b6fed..0e15c8dcd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -161,7 +161,9 @@ module.exports = function(grunt) { files: { 'public/red/red.min.js': 'public/red/red.js', 'public/red/main.min.js': 'public/red/main.js', - 'public/vendor/jsonata/jsonata.min.js': 'editor/vendor/jsonata/jsonata.js' + 'public/vendor/jsonata/jsonata.min.js': 'editor/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' } } }, diff --git a/editor/js/ui/common/typedInput.js b/editor/js/ui/common/typedInput.js index b30af8961..c433c0366 100644 --- a/editor/js/ui/common/typedInput.js +++ b/editor/js/ui/common/typedInput.js @@ -95,7 +95,21 @@ json: {value:"json",label:"JSON",icon:"red/images/typedInput/json.png", validate: function(v) { try{JSON.parse(v);return true;}catch(e){return false;}}}, re: {value:"re",label:"regular expression",icon:"red/images/typedInput/re.png"}, date: {value:"date",label:"timestamp",hasValue:false}, - jsonata: {value:"jsonata",label:"expression",icon:"red/images/typedInput/expr.png", validate: function(v) { try{jsonata(v);return true;}catch(e){return false;}}}, + jsonata: { + value: "jsonata", + label: "expression", + icon: "red/images/typedInput/expr.png", + validate: function(v) { try{jsonata(v);return true;}catch(e){return false;}}, + expand:function() { + var that = this; + RED.editor.editExpression({ + value: this.value(), + complete: function(v) { + that.value(v); + } + }) + } + } }; var nlsd = false; @@ -189,7 +203,7 @@ that.uiSelect.addClass('red-ui-typedInput-focus'); }); - + this.optionExpandButton = $('').appendTo(this.uiSelect); this.type(this.options.default||this.typeList[0].value); @@ -323,11 +337,16 @@ this.uiSelect.width(this.uiWidth); } if (this.typeMap[this.propertyType] && this.typeMap[this.propertyType].hasValue === false) { - this.selectTrigger.css('width',"100%"); + this.selectTrigger.addClass("red-ui-typedInput-full-width"); } else { - this.selectTrigger.width('auto'); + this.selectTrigger.removeClass("red-ui-typedInput-full-width"); var labelWidth = this._getLabelWidth(this.selectTrigger); this.elementDiv.css('left',labelWidth+"px"); + if (this.optionExpandButton.is(":visible")) { + this.elementDiv.css('right',"22px"); + } else { + this.elementDiv.css('right','0'); + } if (this.optionSelectTrigger) { this.optionSelectTrigger.css({'left':(labelWidth)+"px",'width':'calc( 100% - '+labelWidth+'px )'}); } @@ -397,6 +416,9 @@ this.selectLabel.text(opt.label); } if (opt.options) { + if (this.optionExpandButton) { + this.optionExpandButton.hide(); + } if (this.optionSelectTrigger) { this.optionSelectTrigger.show(); this.elementDiv.hide(); @@ -430,6 +452,16 @@ } this.elementDiv.show(); } + if (opt.expand && typeof opt.expand === 'function') { + this.optionExpandButton.show(); + this.optionExpandButton.off('click'); + this.optionExpandButton.on('click',function(evt) { + evt.preventDefault(); + opt.expand.call(that); + }) + } else { + this.optionExpandButton.hide(); + } this.element.trigger('change',this.propertyType,this.value()); } if (image) { diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index c689352b0..cb821d731 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -494,12 +494,13 @@ RED.editor = (function() { } function getEditStackTitle() { - var title = '