From d262783ec13df14b6c627d32713aa09a9cee7a30 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Sat, 22 Oct 2016 15:23:37 -0400 Subject: [PATCH] can add and edit json/txt files --- client/modules/IDE/components/Editor.js | 4 ++++ client/modules/IDE/components/NewFileModal.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/modules/IDE/components/Editor.js b/client/modules/IDE/components/Editor.js index 913987c5..1f82fa22 100644 --- a/client/modules/IDE/components/Editor.js +++ b/client/modules/IDE/components/Editor.js @@ -110,6 +110,10 @@ class Editor extends React.Component { this._cm.setOption('mode', 'css'); } else if (this.props.file.name.match(/.+\.html$/i)) { this._cm.setOption('mode', 'htmlmixed'); + } else if (this.props.file.name.match(/.+\.json$/i)) { + this._cm.setOption('mode', 'application/json'); + } else { + this._cm.setOption('mode', 'text/plain'); } } diff --git a/client/modules/IDE/components/NewFileModal.js b/client/modules/IDE/components/NewFileModal.js index 784ec2a7..df3592d0 100644 --- a/client/modules/IDE/components/NewFileModal.js +++ b/client/modules/IDE/components/NewFileModal.js @@ -51,8 +51,8 @@ function validate(formProps) { if (!formProps.name) { errors.name = 'Please enter a name'; - } else if (!formProps.name.match(/(.+\.js$|.+\.css$)/)) { - errors.name = 'File must be of type JavaScript or CSS.'; + } else if (!formProps.name.match(/(.+\.js$|.+\.css$|.+\.json$|.+\.txt)/i)) { + errors.name = 'File must be of type JavaScript, CSS, JSON, or TXT.'; } return errors;