From 626be3882be5b220552632e5cfe393de4fd0ee5d Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Wed, 26 Sep 2018 13:53:22 +0100 Subject: [PATCH] Use supported languages --- embark-ui/src/components/TextEditor.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/embark-ui/src/components/TextEditor.js b/embark-ui/src/components/TextEditor.js index 1784ac61..a77a0be3 100644 --- a/embark-ui/src/components/TextEditor.js +++ b/embark-ui/src/components/TextEditor.js @@ -2,20 +2,12 @@ import React from 'react'; import MonacoEditor from 'react-monaco-editor'; import PropTypes from 'prop-types'; +const supportedLanguages = ['css', 'sol', 'html', 'json']; + class TextEditor extends React.Component { language() { - switch(this.props.file.name.split('.').pop()) { - case 'css': - return 'css'; - case 'sol': - return 'sol'; - case 'html': - return 'html'; - case 'json': - return 'json'; - default: - return 'javascript'; - } + const extension = this.props.file.name.split('.').pop(); + return supportedLanguages[supportedLanguages.indexOf(extension)] || 'javascript'; } extractRowCol(errorMessage) {