From f484156d8e1a6c448e87da04791ce89aaa1bc6f5 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 28 Jul 2016 17:14:55 +0100 Subject: [PATCH] Tell ace about Function node globals Closes #927 --- editor/js/ui/editor.js | 8 ++++++++ nodes/core/core/80-function.html | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index 5e518a40e..c9f19578d 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -1360,6 +1360,14 @@ RED.editor = (function() { if (options.value) { session.setValue(options.value,-1); } + if (options.globals) { + setTimeout(function() { + if (!!session.$worker) { + session.$worker.send("setOptions", [{globals: options.globals}]); + } + },100); + } + return editor; } } diff --git a/nodes/core/core/80-function.html b/nodes/core/core/80-function.html index 85e58a2b9..112a62b60 100644 --- a/nodes/core/core/80-function.html +++ b/nodes/core/core/80-function.html @@ -91,7 +91,21 @@ this.editor = RED.editor.createEditor({ id: 'node-input-func-editor', mode: 'ace/mode/javascript', - value: $("#node-input-func").val() + value: $("#node-input-func").val(), + globals: { + msg:true, + context:true, + RED: true, + util: true, + flow: true, + global: true, + console: true, + Buffer: true, + setTimeout: true, + clearTimeout: true, + setInterval: true, + clearInterval: true + } }); RED.library.create({