diff --git a/client/modules/IDE/components/Editor.jsx b/client/modules/IDE/components/Editor.jsx index 422b13cd..facb7d45 100644 --- a/client/modules/IDE/components/Editor.jsx +++ b/client/modules/IDE/components/Editor.jsx @@ -4,7 +4,6 @@ import CodeMirror from 'codemirror'; import beautifyJS from 'js-beautify'; const beautifyCSS = beautifyJS.css; const beautifyHTML = beautifyJS.html; -import 'codemirror/mode/javascript/javascript'; import '../../../utils/p5-javascript'; import 'codemirror/mode/css/css'; import 'codemirror/mode/htmlmixed/htmlmixed'; @@ -59,7 +58,10 @@ class Editor extends React.Component { if (this.props.lintMessages.length > 0 && this.props.lintWarning) { this.beep.play(); } - }, 2000) + }, 2000), + options: { + asi: true + } } }); @@ -133,7 +135,7 @@ class Editor extends React.Component { getFileMode(fileName) { let mode; if (fileName.match(/.+\.js$/i)) { - mode = 'p5-javascript'; + mode = 'javascript'; } else if (fileName.match(/.+\.css$/i)) { mode = 'css'; } else if (fileName.match(/.+\.html$/i)) { diff --git a/client/utils/p5-javascript.js b/client/utils/p5-javascript.js index 86ebe915..1c7152a4 100644 --- a/client/utils/p5-javascript.js +++ b/client/utils/p5-javascript.js @@ -17,7 +17,7 @@ function expressionAllowed(stream, state, backUp) { (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)))) } -CodeMirror.defineMode("p5-javascript", function(config, parserConfig) { +CodeMirror.defineMode("javascript", function(config, parserConfig) { var indentUnit = config.indentUnit; var statementIndent = parserConfig.statementIndent; var jsonldMode = parserConfig.jsonld; @@ -830,7 +830,7 @@ CodeMirror.defineMode("p5-javascript", function(config, parserConfig) { fold: "brace", closeBrackets: "()[]{}''\"\"``", - helperType: jsonMode ? "json" : "p5-javascript", + helperType: jsonMode ? "json" : "javascript", jsonldMode: jsonldMode, jsonMode: jsonMode, @@ -842,14 +842,17 @@ CodeMirror.defineMode("p5-javascript", function(config, parserConfig) { }; }); -CodeMirror.registerHelper("wordChars", "p5-javascript", /[\w$]/); +CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/); -CodeMirror.defineMIME("text/javascript", "p5-javascript"); -CodeMirror.defineMIME("text/ecmascript", "p5-javascript"); -CodeMirror.defineMIME("application/javascript", "p5-javascript"); -CodeMirror.defineMIME("application/x-javascript", "p5-javascript"); -CodeMirror.defineMIME("application/ecmascript", "p5-javascript"); -CodeMirror.defineMIME("text/typescript", { name: "p5-javascript", typescript: true }); -CodeMirror.defineMIME("application/typescript", { name: "p5-javascript", typescript: true }); +CodeMirror.defineMIME("text/javascript", "javascript"); +CodeMirror.defineMIME("text/ecmascript", "javascript"); +CodeMirror.defineMIME("application/javascript", "javascript"); +CodeMirror.defineMIME("application/x-javascript", "javascript"); +CodeMirror.defineMIME("application/ecmascript", "javascript"); +CodeMirror.defineMIME("application/json", {name: "javascript", json: true}); +CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true}); +CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true}); +CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); +CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); });