diff --git a/CHANGELOG.md b/CHANGELOG.md index b07e3ea..def2cf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed - Typo: getAmountOfDateEditors renamed to getNumberOfDataEditors (see [issue 3](https://github.com/RMLio/matey/issues/2)). +- Make download buttons work again (see [issue 2](https://github.com/RMLio/matey/issues/2)) ## [1.0.2] - 2022-01-24 diff --git a/lib/editor-manager.js b/lib/editor-manager.js index 7fc0d0d..c11ff38 100644 --- a/lib/editor-manager.js +++ b/lib/editor-manager.js @@ -52,6 +52,22 @@ module.exports = class EditorManager { return activeEditor; } + /** + * Returns the ioutput editor that is currently active in the page. + * @returns {Object} object that contains information about the active editor + */ + getActiveOutputEditor() { + let activeEditor = null; + + this.outputEditors.forEach(outputEditor => { + if (outputEditor.elem.hasClass('active')) { + activeEditor = outputEditor; + } + }); + + return activeEditor; + } + /** * Sets the content of the RML editor * @param {String} rml - the rml to be placed in the editor @@ -315,6 +331,13 @@ module.exports = class EditorManager { return this.rmlEditor.getValue(); } + /** + @returns {String} text inside YARRRML editor + */ + getYARRRML() { + return this.inputEditor.getValue(); + } + /** @returns {String} text inside active data editor */ diff --git a/lib/front.js b/lib/front.js index 6836a0e..963017c 100644 --- a/lib/front.js +++ b/lib/front.js @@ -108,15 +108,18 @@ module.exports = class Front { }); $('#yarrrml-dl-matey').on('click', () => { - downloadString(this.matey.editor.getValue(), 'text', 'yarrrml.yaml'); + downloadString(this.matey.editorManager.getYARRRML(), 'text', 'yarrrml.yaml'); }); $('#turtle-dl-matey').on('click', () => { - downloadString(this.matey.outputEditor.getValue(), 'text/turtle', 'output.ttl'); + const activeEditor = this.matey.editorManager.getActiveOutputEditor(); + console.log(activeEditor) + + downloadString(activeEditor.editor.getValue(), 'text', activeEditor.path); }); $('#rml-dl-matey').on('click', () => { - downloadString(this.matey.rmlEditor.getValue(), 'text/turtle', 'output.rml.ttl'); + downloadString(this.matey.editorManager.getRML(), 'text/turtle', 'output.rml.ttl'); }); }