can add and edit json/txt files

This commit is contained in:
Cassie Tarakajian 2016-10-22 15:23:37 -04:00
parent 280d3e69ea
commit d262783ec1
2 changed files with 6 additions and 2 deletions

View File

@ -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');
}
}

View File

@ -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;