From 13e8aeae4ede65e8839e8f22a47ab5e808b299ca Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sun, 3 Jul 2022 20:22:19 +0100 Subject: [PATCH 1/2] Fix defaulting to monaco if settings does not contain codeEditor --- .../node_modules/@node-red/editor-api/lib/editor/theme.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 5a8dacde4..88b3eeb62 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 @@ -101,7 +101,10 @@ module.exports = { } themeSettings = null; theme = settings.editorTheme || {}; - themeContext.asset.vendorMonaco = ((theme.codeEditor || {}).lib === "monaco") ? "vendor/monaco/monaco-bootstrap.js" : ""; + themeContext.asset.vendorMonaco = "vendor/monaco/monaco-bootstrap.js" + if (theme.codeEditor && theme.codeEditor.lib === 'ace') { + themeContext.asset.vendorMonaco = '' + } activeTheme = theme.theme; }, From ca20f41d0ef5cd14974837d8b7fff40a6daf66bb Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sun, 3 Jul 2022 20:37:55 +0100 Subject: [PATCH 2/2] Update theme tests to ensure monaco is loaded --- test/unit/@node-red/editor-api/lib/editor/theme_spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/@node-red/editor-api/lib/editor/theme_spec.js b/test/unit/@node-red/editor-api/lib/editor/theme_spec.js index 900be126f..fd1b42d61 100644 --- a/test/unit/@node-red/editor-api/lib/editor/theme_spec.js +++ b/test/unit/@node-red/editor-api/lib/editor/theme_spec.js @@ -51,7 +51,7 @@ describe("api/editor/theme", function () { context.should.have.a.property("asset"); context.asset.should.have.a.property("red", "red/red.min.js"); context.asset.should.have.a.property("main", "red/main.min.js"); - context.asset.should.have.a.property("vendorMonaco", ""); + context.asset.should.have.a.property("vendorMonaco", "vendor/monaco/monaco-bootstrap.js"); should.not.exist(theme.settings()); }); @@ -69,16 +69,16 @@ describe("api/editor/theme", function () { } }); - it("Adds monaco bootstrap when enabled", async function () { + it("Does not add monaco bootstrap when ace selected", async function () { theme.init({ editorTheme: { codeEditor: { - lib: 'monaco' + lib: 'ace' } } }); var context = await theme.context(); - context.asset.should.have.a.property("vendorMonaco", "vendor/monaco/monaco-bootstrap.js"); + context.asset.should.have.a.property("vendorMonaco", ""); }); it("picks up custom theme", async function () {