1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge branch 'dev' of github.com:node-red/node-red into dev

This commit is contained in:
Nick O'Leary 2021-10-05 11:26:19 +01:00
commit 57386edb7c
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
5 changed files with 58 additions and 14 deletions

View File

@ -253,6 +253,9 @@ module.exports = {
theme.page = theme.page || {_:{}} theme.page = theme.page || {_:{}}
theme.page._.scripts = scriptFiles.concat(theme.page._.scripts || []) theme.page._.scripts = scriptFiles.concat(theme.page._.scripts || [])
} }
if(theme.codeEditor) {
theme.codeEditor.options = Object.assign({}, themePlugin.monacoOptions, theme.codeEditor.options);
}
} }
activeThemeInitialised = true; activeThemeInitialised = true;
} }

View File

@ -54,6 +54,7 @@ RED.editor.codeEditor.monaco = (function() {
var initialised = false; var initialised = false;
const type = "monaco"; const type = "monaco";
const monacoThemes = ["vs","vs-dark","hc-black"]; //TODO: consider setting hc-black autmatically based on acessability? const monacoThemes = ["vs","vs-dark","hc-black"]; //TODO: consider setting hc-black autmatically based on acessability?
let userSelectedTheme;
//TODO: get from externalModules.js For now this is enough for feature parity with ACE (and then some). //TODO: get from externalModules.js For now this is enough for feature parity with ACE (and then some).
const knownModules = { const knownModules = {
@ -181,18 +182,34 @@ RED.editor.codeEditor.monaco = (function() {
var editorSettings = RED.editor.codeEditor.settings || {}; var editorSettings = RED.editor.codeEditor.settings || {};
var editorOptions = editorSettings.options || {}; var editorOptions = editorSettings.options || {};
if (editorOptions.theme) { //if editorOptions.theme is an object (set in theme.js context()), use the plugin theme name as the monaco theme name
if (!monacoThemes.includes(editorOptions.theme)) { //if editorOptions.theme is a string, it should be the name of a pre-set theme, load that
var customTheme = 'vendor/monaco/dist/theme/' + editorOptions.theme + '.json'; try {
$.get(customTheme, function (theme) { const addTheme = function (themeThemeName, theme) {
monacoThemes.push(editorOptions.theme);//add to list of loaded themes
if ((theme.rules && Array.isArray(theme.rules)) || theme.colors) { if ((theme.rules && Array.isArray(theme.rules)) || theme.colors) {
monaco.editor.defineTheme(editorOptions.theme, theme); monacoThemes.push(themeThemeName); //add to list of loaded themes
monaco.editor.setTheme(editorOptions.theme); monaco.editor.defineTheme(themeThemeName, theme);
monaco.editor.setTheme(themeThemeName);
userSelectedTheme = themeThemeName;
} }
};
if (editorOptions.theme) {
if (typeof editorOptions.theme == "object" && RED.settings.editorTheme.theme) {
let themeThemeName = editorOptions.theme.name || RED.settings.editorTheme.theme;
addTheme(themeThemeName, editorOptions.theme);
} else if (typeof editorOptions.theme == "string") {
let themeThemeName = editorOptions.theme;
if (!monacoThemes.includes(themeThemeName)) {
$.get('vendor/monaco/dist/theme/' + themeThemeName + '.json', function (theme) {
addTheme(themeThemeName, theme);
}); });
} }
} }
}
} catch (error) {
console.warn(error);
}
//Helper function to simplify snippet setup //Helper function to simplify snippet setup
function createMonacoCompletionItem(label, insertText, documentation, range, kind) { function createMonacoCompletionItem(label, insertText, documentation, range, kind) {
@ -744,6 +761,10 @@ RED.editor.codeEditor.monaco = (function() {
var editorOptions = $.extend({}, editorSettings.options, options); var editorOptions = $.extend({}, editorSettings.options, options);
editorOptions.language = convertAceModeToMonacoLang(options.mode); editorOptions.language = convertAceModeToMonacoLang(options.mode);
if(userSelectedTheme) {
editorOptions.theme = userSelectedTheme;//use user selected theme for this session
}
//by default, set javascript editors to text mode. //by default, set javascript editors to text mode.
//when element becomes visible, it will be (re) set to javascript mode //when element becomes visible, it will be (re) set to javascript mode
//this is to ensure multiple editors sharing the model dont present its //this is to ensure multiple editors sharing the model dont present its
@ -1169,7 +1190,10 @@ RED.editor.codeEditor.monaco = (function() {
return { row: p.lineNumber-1, column: p.column-1 }; return { row: p.lineNumber-1, column: p.column-1 };
} }
ed.setTheme = monaco.editor.setTheme; ed.setTheme = function(theme) {
monaco.editor.setTheme(theme);
userSelectedTheme = theme;//remember users choice for this session
}
ed.on = function (name, cb) { ed.on = function (name, cb) {
switch (name) { switch (name) {

View File

@ -86,6 +86,12 @@
</div> </div>
</div> </div>
<div class="form-row">
<input type="checkbox" id="node-input-senderr" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-senderr" style="width: auto" data-i18n="httpin.senderr"></label>
</div>
<div class="form-row"> <div class="form-row">
<label for="node-input-ret"><i class="fa fa-arrow-left"></i> <span data-i18n="httpin.label.return"></span></label> <label for="node-input-ret"><i class="fa fa-arrow-left"></i> <span data-i18n="httpin.label.return"></span></label>
<select type="text" id="node-input-ret" style="width:70%;"> <select type="text" id="node-input-ret" style="width:70%;">
@ -114,7 +120,8 @@
tls: {type:"tls-config",required: false}, tls: {type:"tls-config",required: false},
persist: {value:false}, persist: {value:false},
proxy: {type:"http proxy",required: false}, proxy: {type:"http proxy",required: false},
authType: {value: ""} authType: {value: ""},
senderr: {value: false}
}, },
credentials: { credentials: {
user: {type:"text"}, user: {type:"text"},

View File

@ -72,6 +72,7 @@ in your Node-RED user directory (${RED.settings.userDir}).
var paytoqs = false; var paytoqs = false;
var paytobody = false; var paytobody = false;
var redirectList = []; var redirectList = [];
var sendErrorsToCatch = n.senderr;
var nodeHTTPPersistent = n["persist"]; var nodeHTTPPersistent = n["persist"];
if (n.tls) { if (n.tls) {
@ -537,6 +538,12 @@ in your Node-RED user directory (${RED.settings.userDir}).
nodeSend(msg); nodeSend(msg);
nodeDone(); nodeDone();
}).catch(err => { }).catch(err => {
// Pre 2.1, any errors would be sent to both Catch node and sent on as normal.
// This is not ideal but is the legacy behaviour of the node.
// 2.1 adds the 'senderr' option, if set to true, will *only* send errors
// to Catch nodes. If false, it still does both behaviours.
// TODO: 3.0 - make it one or the other.
if (err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') { if (err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') {
node.error(RED._("common.notification.errors.no-response"), msg); node.error(RED._("common.notification.errors.no-response"), msg);
node.status({fill:"red", shape:"ring", text:"common.notification.errors.no-response"}); node.status({fill:"red", shape:"ring", text:"common.notification.errors.no-response"});
@ -549,7 +556,9 @@ in your Node-RED user directory (${RED.settings.userDir}).
if (node.metric() && timingLog) { if (node.metric() && timingLog) {
emitTimingMetricLog(err.timings, msg); emitTimingMetricLog(err.timings, msg);
} }
if (!sendErrorsToCatch) {
nodeSend(msg); nodeSend(msg);
}
nodeDone(); nodeDone();
}); });
}); });

View File

@ -486,6 +486,7 @@
"proxy-config": "Proxy Configuration", "proxy-config": "Proxy Configuration",
"use-proxyauth": "Use proxy authentication", "use-proxyauth": "Use proxy authentication",
"noproxy-hosts": "Ignore hosts", "noproxy-hosts": "Ignore hosts",
"senderr": "Only send non-2xx responses to Catch node",
"utf8": "a UTF-8 string", "utf8": "a UTF-8 string",
"binary": "a binary buffer", "binary": "a binary buffer",
"json": "a parsed JSON object", "json": "a parsed JSON object",