From 489b56456f49ebcbb37f5957264a023c6d65b29d Mon Sep 17 00:00:00 2001 From: wajnberg Date: Thu, 8 Sep 2016 22:46:30 +0300 Subject: [PATCH] Completing STT support (#976) * Completing STT support Signed-off-by: Moshe Wajnberg * Adressing Nick comments Signed-off-by: Moshe Wajnberg --- editor/js/ui/editor.js | 39 +++++++++++++++++++++---------- editor/sass/forms.scss | 4 ++++ nodes/core/io/21-httpin.html | 4 ++-- nodes/core/io/21-httprequest.html | 6 ++--- nodes/core/io/22-websocket.html | 12 +++++----- nodes/core/storage/28-tail.html | 6 ++--- nodes/core/storage/50-file.html | 12 +++++----- 7 files changed, 51 insertions(+), 32 deletions(-) diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index 31dab88c3..33411bbf3 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -163,7 +163,11 @@ RED.editor = (function() { function validateNodeEditorProperty(node,defaults,property,prefix) { var input = $("#"+prefix+"-"+property); if (input.length > 0) { - if (!validateNodeProperty(node, defaults, property,input.val())) { + var value = input.val(); + if (defaults[property].hasOwnProperty("format") && defaults[property].format !== "" && input[0].nodeName === "DIV") { + value = input.text(); + } + if (!validateNodeProperty(node, defaults, property,value)) { input.addClass("input-error"); } else { input.removeClass("input-error"); @@ -307,11 +311,11 @@ RED.editor = (function() { if (val == null) { val = ""; } - if (definition !== undefined && definition[property].hasOwnProperty("format") && definition[property].format !== "" && input[0].nodeName === "DIV") { - input.html(RED.text.format.getHtml(val, definition[property].format, {}, false, "en")); + if (definition !== undefined && definition[property].hasOwnProperty("format") && definition[property].format !== "" && input[0].nodeName === "DIV") { + input.html(RED.text.format.getHtml(val, definition[property].format, {}, false, "en")); RED.text.format.attach(input[0], definition[property].format, {}, false, "en"); } else { - input.val(val); + input.val(val); RED.text.bidi.prepareInput(input); } } @@ -325,11 +329,20 @@ RED.editor = (function() { * @param prefix - the prefix to use in the input element ids (node-input|node-config-input) */ function attachPropertyChangeHandler(node,definition,property,prefix) { - $("#"+prefix+"-"+property).change(function(event,skipValidation) { - if (!skipValidation) { - validateNodeEditor(node,prefix); - } - }); + var input = $("#"+prefix+"-"+property); + if (definition !== undefined && "format" in definition[property] && definition[property].format !== "" && input[0].nodeName === "DIV") { + $("#"+prefix+"-"+property).on('change keyup', function(event,skipValidation) { + if (!skipValidation) { + validateNodeEditor(node,prefix); + } + }); + } else { + $("#"+prefix+"-"+property).change(function(event,skipValidation) { + if (!skipValidation) { + validateNodeEditor(node,prefix); + } + }); + } } /** @@ -353,7 +366,7 @@ RED.editor = (function() { $('#' + prefix + '-' + cred).val(''); } } else { - preparePropertyEditor(credData, cred, prefix); + preparePropertyEditor(credData, cred, prefix, credDef); } attachPropertyChangeHandler(node, credDef, cred, prefix); } @@ -413,10 +426,10 @@ RED.editor = (function() { } } else { console.log("Unknown type:", definition.defaults[d].type); - preparePropertyEditor(node,d,prefix); + preparePropertyEditor(node,d,prefix,definition.defaults); } } else { - preparePropertyEditor(node,d,prefix); + preparePropertyEditor(node,d,prefix,definition.defaults); } attachPropertyChangeHandler(node,definition.defaults,d,prefix); } @@ -597,6 +610,8 @@ RED.editor = (function() { var newValue; if (input.attr('type') === "checkbox") { newValue = input.prop('checked'); + } else if ("format" in editing_node._def.defaults[d] && editing_node._def.defaults[d].format !== "" && input[0].nodeName === "DIV") { + newValue = input.text(); } else { newValue = input.val(); } diff --git a/editor/sass/forms.scss b/editor/sass/forms.scss index 70d86664b..c0242a802 100644 --- a/editor/sass/forms.scss +++ b/editor/sass/forms.scss @@ -151,6 +151,7 @@ input[type="url"], input[type="search"], input[type="tel"], input[type="color"], +div[contenteditable="true"], .uneditable-input { box-sizing: border-box; display: inline-block; @@ -956,6 +957,9 @@ input.search-query { .form-search input, .form-inline input, .form-horizontal input, +.form-search div[contenteditable="true"], +.form-inline div[contenteditable="true"], +.form-horizontal div[contenteditable="true"], .form-search textarea, .form-inline textarea, .form-horizontal textarea, diff --git a/nodes/core/io/21-httpin.html b/nodes/core/io/21-httpin.html index e34a4d21f..84b0f39cf 100644 --- a/nodes/core/io/21-httpin.html +++ b/nodes/core/io/21-httpin.html @@ -27,7 +27,7 @@
- +
@@ -117,7 +117,7 @@ msg.cookies = { color:"rgb(231, 231, 174)", defaults: { name: {value:""}, - url: {value:"",required:true}, + url: {value:"",required:true,format:"url"}, method: {value:"get",required:true}, swaggerDoc: {type:"swagger-doc", required:false} }, diff --git a/nodes/core/io/21-httprequest.html b/nodes/core/io/21-httprequest.html index b743ac8ee..8a5f679ef 100644 --- a/nodes/core/io/21-httprequest.html +++ b/nodes/core/io/21-httprequest.html @@ -26,8 +26,8 @@
- - + +
@@ -102,7 +102,7 @@ name: {value:""}, method:{value:"GET"}, ret: {value:"txt"}, - url:{value:""}, + url:{value:"",format:"url"}, tls: {type:"tls-config",required: false} }, credentials: { diff --git a/nodes/core/io/22-websocket.html b/nodes/core/io/22-websocket.html index d6849ef1b..e4b82e3d0 100644 --- a/nodes/core/io/22-websocket.html +++ b/nodes/core/io/22-websocket.html @@ -145,7 +145,7 @@ RED.nodes.registerType('websocket-listener',{ category: 'config', defaults: { - path: {value:"",required:true,validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/) }, + path: {value:"",required:true,validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/),format:"filepath" }, wholemsg: {value:"false"} }, inputs:0, @@ -179,7 +179,7 @@ RED.nodes.registerType('websocket-client',{ category: 'config', defaults: { - path: {value:"",required:true,validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/) }, + path: {value:"",required:true,validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/),format:"filepath" }, wholemsg: {value:"false"} }, inputs:0, @@ -231,8 +231,8 @@