diff --git a/platform/src/ConsolePanel.js b/platform/src/ConsolePanel.js index a15403e..13e82e0 100644 --- a/platform/src/ConsolePanel.js +++ b/platform/src/ConsolePanel.js @@ -8,21 +8,20 @@ class ConsolePanel extends Panel { super(id); this.editor.setReadOnly(true); this.editor.setValue("", 1); - this.element.dataset.customButtons = JSON.stringify(this.getButtons()); - this.detectHyperlinks(this.editor); - this.setTitleAndIcon("Console", "console"); - } - getButtons() { - let clearButton = new Button({ - id:"clear", - hint:"Clear the console", - internal: `panels.find((p) => p.id==="${this.id}").editor.setValue('')`, - icon: "clear" - }, this.id + let buttons = []; + let clearButton = new Button( + { id:"clear", + hint:"Clear the console", + internal: `panels.find((p) => p.id==="${this.id}").editor.setValue('')`, + icon: "clear" }, + this.id ); - - return [clearButton.getView()]; + buttons.push(clearButton); + this.addButtons(buttons); + + this.detectHyperlinks(this.editor); + this.setTitleAndIcon("Console", "console"); } setOutput(str) { diff --git a/platform/src/OutputPanel.js b/platform/src/OutputPanel.js index 0b246ed..a6df7c2 100644 --- a/platform/src/OutputPanel.js +++ b/platform/src/OutputPanel.js @@ -1,6 +1,6 @@ import { ModelPanel } from "./ModelPanel.js"; -import { language } from "./Playground.js" +import { language } from "./Playground.js"; import { Button } from "./Button.js"; class OutputPanel extends ModelPanel { @@ -15,25 +15,26 @@ class OutputPanel extends ModelPanel { this.outputType = outputType; this.outputLanguage = outputLanguage; this.language = language; - this.element.dataset.customButtons = JSON.stringify(this.getButtons()); - this.getEditor().getSession().setMode("ace/mode/" + outputLanguage.toLowerCase()); - //this.getEditor().getSession().setUseWrapMode(false); - } - setupSyntaxHighlighting() {} - - getButtons() { - let highlightButton = new Button({ - id:"highlight", + let buttons = []; + if (this.outputType == "code"){ + let highlightButton = new Button( + { id:"highlight", hint:"Set generated text language", internal: `panels.find((p) => p.id==="${this.id}").editor.setOutputLanguage()`, - icon: "highlight" - }, this.id - ); + icon: "highlight" }, + this.id + ); + buttons.push(highlightButton); + } + this.addButtons(buttons); - return (this.outputType == "code") ? [highlightButton.getView()] : []; + this.getEditor().getSession().setMode("ace/mode/" + outputLanguage.toLowerCase()); } + setupSyntaxHighlighting() {} + + getSelect() { return Metro.getPlugin("#generatedFiles", 'select'); } diff --git a/platform/src/Panel.js b/platform/src/Panel.js index b4b2f1b..af624df 100644 --- a/platform/src/Panel.js +++ b/platform/src/Panel.js @@ -99,17 +99,18 @@ class Panel { /** * Add the buttons to the page - * @param {Button[]} buttons the Button objects to add + * @param {Button[]} buttons - The Button objects to add. */ addButtons(buttons){ + if (buttons.length > 0){ + var buttonViewData= buttons.map( (btn) => { + return btn.getView(); + }); - var buttonViewData= buttons.map( (btn) => { - return btn.getView(); - }); + buttonViewData.reverse(); // So they are displayed in the order they are defined - buttonViewData.reverse(); // So they are displayed in the order they are defined - - this.element.dataset.customButtons = JSON.stringify(buttonViewData); + this.element.dataset.customButtons = JSON.stringify(buttonViewData); + } } diff --git a/platform/src/Playground.js b/platform/src/Playground.js index 503581a..af24dde 100644 --- a/platform/src/Playground.js +++ b/platform/src/Playground.js @@ -263,8 +263,8 @@ function initialisePanels() { /** * Create a panel for a given panel config entry * - * @param {Object} activity config panel definition - * @return {Panel} platform Panel + * @param {Object} panel - The activity config panel definition. + * @return {Panel} the platform Panel */ function createPanelForDefinitionId(panel){ const panelDefinition = panel.ref;