From 69dafd6c686fedbf43955a22fe9927ad02a269bb Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Thu, 29 Apr 2021 16:53:59 +0100 Subject: [PATCH] add codeEditor settings --- .../node_modules/@node-red/editor-api/lib/editor/theme.js | 3 ++- .../@node-red/editor-client/locales/en-US/editor.json | 4 ++++ .../node_modules/@node-red/editor-client/src/js/settings.js | 3 ++- packages/node_modules/@node-red/runtime/lib/api/settings.js | 5 +++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/editor-api/lib/editor/theme.js b/packages/node_modules/@node-red/editor-api/lib/editor/theme.js index 3ea4ede73..8fb7df9d4 100644 --- a/packages/node_modules/@node-red/editor-api/lib/editor/theme.js +++ b/packages/node_modules/@node-red/editor-api/lib/editor/theme.js @@ -33,7 +33,7 @@ var defaultContext = { asset: { red: (process.env.NODE_ENV == "development")? "red/red.js":"red/red.min.js", main: (process.env.NODE_ENV == "development")? "red/main.js":"red/main.min.js", - + vendorMonaco: "" } }; @@ -93,6 +93,7 @@ module.exports = { themeContext = clone(defaultContext); themeSettings = null; theme = settings.editorTheme || {}; + themeContext.asset.vendorMonaco = ((theme.codeEditor || {}).lib === "monaco") ? "vendor/monaco/monaco-bootstrap.js" : ""; activeTheme = theme.theme; }, diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json index 466eda94d..3f1e32588 100755 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json @@ -111,6 +111,7 @@ "projects-open": "Open", "projects-settings": "Project Settings", "showNodeLabelDefault": "Show label of newly added nodes", + "codeEditor": "Code Editor", "groups": "Groups", "groupSelection": "Group selection", "ungroupSelection": "Ungroup selection", @@ -885,6 +886,9 @@ "eval": "Error evaluating expression:\n __message__" } }, + "monaco": { + "setTheme": "Set theme" + }, "jsEditor": { "title": "JavaScript editor" }, diff --git a/packages/node_modules/@node-red/editor-client/src/js/settings.js b/packages/node_modules/@node-red/editor-client/src/js/settings.js index 109554418..39f372974 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/settings.js +++ b/packages/node_modules/@node-red/editor-client/src/js/settings.js @@ -143,7 +143,8 @@ RED.settings = (function () { console.groupCollapsed("Versions"); console.log("jQuery",$().jquery) console.log("jQuery UI",$.ui.version); - console.log("ACE",ace.version); + if(window.ace) { console.log("ACE",ace.version); } + if(window.monaco) { console.log("MONACO",monaco.version || "unknown"); } console.log("D3",d3.version); console.groupEnd(); loadUserSettings(done); diff --git a/packages/node_modules/@node-red/runtime/lib/api/settings.js b/packages/node_modules/@node-red/runtime/lib/api/settings.js index 02f991722..e8ea36f04 100644 --- a/packages/node_modules/@node-red/runtime/lib/api/settings.js +++ b/packages/node_modules/@node-red/runtime/lib/api/settings.js @@ -81,6 +81,11 @@ var api = module.exports = { if (!runtime.settings.disableEditor) { safeSettings.context = runtime.nodes.listContextStores(); + if (runtime.settings.editorTheme && runtime.settings.editorTheme.codeEditor) { + safeSettings.codeEditor = runtime.settings.editorTheme.codeEditor || {}; + safeSettings.codeEditor.lib = safeSettings.codeEditor.lib || "ace"; + safeSettings.codeEditor.options = safeSettings.codeEditor.options || {}; + } safeSettings.libraries = runtime.library.getLibraries(); if (util.isArray(runtime.settings.paletteCategories)) { safeSettings.paletteCategories = runtime.settings.paletteCategories;