From 5b1defad9fc1b20f3b324b08e1cfb99f87ab5ce4 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 2 May 2019 16:09:13 +0100 Subject: [PATCH] Simplify index.mst to a single div to insert the editor --- .../@node-red/editor-api/lib/editor/theme.js | 3 + .../@node-red/editor-client/src/js/red.js | 59 +++++-- .../editor-client/src/js/settings.js | 2 +- .../editor-client/src/js/ui/common/menu.js | 18 +- .../editor-client/src/js/ui/common/tabs.js | 13 +- .../editor-client/src/js/ui/deploy.js | 2 +- .../editor-client/src/js/ui/library.js | 157 +++++++++--------- .../@node-red/editor-client/src/js/ui/tray.js | 3 +- .../editor-client/src/js/ui/workspaces.js | 10 +- .../@node-red/editor-client/src/js/user.js | 2 +- .../editor-client/src/sass/header.scss | 3 + .../editor-client/src/sass/library.scss | 18 -- .../editor-client/src/sass/style.scss | 2 +- .../editor-client/src/sass/workspace.scss | 6 +- .../editor-client/templates/index.mst | 21 +-- 15 files changed, 171 insertions(+), 148 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 ea088b3eb..234671f2e 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 @@ -169,6 +169,9 @@ module.exports = { } } } + themeApp.get("/", function(req,res) { + res.json(themeContext); + }) if (theme.hasOwnProperty("menu")) { themeSettings.menu = theme.menu; diff --git a/packages/node_modules/@node-red/editor-client/src/js/red.js b/packages/node_modules/@node-red/editor-client/src/js/red.js index 8fd56e601..c53249424 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/red.js +++ b/packages/node_modules/@node-red/editor-client/src/js/red.js @@ -433,7 +433,7 @@ var RED = (function() { }); } - function loadEditor() { + function buildMainMenu() { var menuOptions = []; if (RED.settings.theme("projects.enabled",false)) { menuOptions.push({id:"menu-item-projects-menu",label:RED._("menu.label.projects"),options:[ @@ -442,20 +442,7 @@ var RED = (function() { {id:"menu-item-projects-settings",label:RED._("menu.label.projects-settings"),disabled:false,onselect:"core:show-project-settings"} ]}); } - - menuOptions.push({id:"menu-item-view-menu",label:RED._("menu.label.view.view"),options:[ - // {id:"menu-item-view-show-grid",setting:"view-show-grid",label:RED._("menu.label.view.showGrid"),toggle:true,onselect:"core:toggle-show-grid"}, - // {id:"menu-item-view-snap-grid",setting:"view-snap-grid",label:RED._("menu.label.view.snapGrid"),toggle:true,onselect:"core:toggle-snap-grid"}, - // {id:"menu-item-status",setting:"node-show-status",label:RED._("menu.label.displayStatus"),toggle:true,onselect:"core:toggle-status", selected: true}, - //null, - // {id:"menu-item-bidi",label:RED._("menu.label.view.textDir"),options:[ - // {id:"menu-item-bidi-default",toggle:"text-direction",label:RED._("menu.label.view.defaultDir"),selected: true, onselect:function(s) { if(s){RED.text.bidi.setTextDirection("")}}}, - // {id:"menu-item-bidi-ltr",toggle:"text-direction",label:RED._("menu.label.view.ltr"), onselect:function(s) { if(s){RED.text.bidi.setTextDirection("ltr")}}}, - // {id:"menu-item-bidi-rtl",toggle:"text-direction",label:RED._("menu.label.view.rtl"), onselect:function(s) { if(s){RED.text.bidi.setTextDirection("rtl")}}}, - // {id:"menu-item-bidi-auto",toggle:"text-direction",label:RED._("menu.label.view.auto"), onselect:function(s) { if(s){RED.text.bidi.setTextDirection("auto")}}} - // ]}, - // null, {id:"menu-item-palette",label:RED._("menu.label.palette.show"),toggle:true,onselect:"core:toggle-palette", selected: true}, {id:"menu-item-sidebar",label:RED._("menu.label.sidebar.show"),toggle:true,onselect:"core:toggle-sidebar", selected: true}, {id:"menu-item-event-log",label:RED._("eventLog.title"),onselect:"core:show-event-log"}, @@ -494,6 +481,13 @@ var RED = (function() { menuOptions.push({id:"menu-item-node-red-version", label:"v"+RED.settings.version, onselect: "core:show-about" }); + $('
  • ').appendTo(".red-ui-header-toolbar") + RED.menu.init({id:"btn-sidemenu",options: menuOptions}); + + } + + function loadEditor() { + RED.workspaces.init(); RED.statusBar.init(); RED.view.init(); @@ -504,6 +498,7 @@ var RED = (function() { RED.keyboard.init(); RED.palette.init(); RED.eventLog.init(); + if (RED.settings.theme('palette.editable') !== false) { RED.palette.editor.init(); } else { @@ -524,20 +519,50 @@ var RED = (function() { RED.editor.init(); RED.diff.init(); - RED.menu.init({id:"btn-sidemenu",options: menuOptions}); RED.deploy.init(RED.settings.theme("deployButton",null)); - RED.actions.add("core:show-about", showAbout); + buildMainMenu(); + RED.nodes.init(); RED.comms.connect(); $("#red-ui-main-container").show(); $(".red-ui-header-toolbar").show(); + RED.actions.add("core:show-about", showAbout); + loadNodeList(); } + function buildEditor(options) { + var header = $('
    ').appendTo(options.target); + var logo = $('').appendTo(header); + $('').appendTo(header); + $('
    ').appendTo(header); + $('
    '+ + '
    '+ + '
    '+ + '
    '+ + '
    '+ + '
    '+ + '
    ').appendTo(options.target); + $('
    ').appendTo(options.target); + $.getJSON(options.apiRootUrl+"theme", function(theme) { + if (theme.header) { + if (theme.header.url) { + logo = $("",{href:theme.header.url}).appendTo(logo); + } + if (theme.header.image) { + $('',{src:theme.header.image}).appendTo(logo); + } + if (theme.header.title) { + $('').html(theme.header.title).appendTo(logo); + } + } + }); + } + var initialised = false; function init(options) { @@ -551,6 +576,8 @@ var RED = (function() { if (options.apiRootUrl && !/\/$/.test(options.apiRootUrl)) { options.apiRootUrl = options.apiRootUrl+"/"; } + options.target = $("#red-ui-editor"); + buildEditor(options); RED.i18n.init(options, function() { RED.settings.init(options, loadEditor); }) 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 1be00f851..c4a164fbe 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 @@ -131,7 +131,7 @@ RED.settings = (function () { RED.settings.remove("auth-tokens"); } console.log("Node-RED: " + data.version); - console.group("Versions"); + console.groupCollapsed("Versions"); console.log("jQuery",$().jquery) console.log("jQuery UI",$.ui.version); console.log("ACE",ace.version); diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/menu.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/menu.js index 6e88aeade..ca2a9f9cd 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/menu.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/menu.js @@ -150,13 +150,29 @@ RED.menu = (function() { } function createMenu(options) { - var topMenu = $("