diff --git a/client/modules/IDE/components/FileUploader.js b/client/modules/IDE/components/FileUploader.js index 2fc5618b..a52b4ca6 100644 --- a/client/modules/IDE/components/FileUploader.js +++ b/client/modules/IDE/components/FileUploader.js @@ -24,7 +24,7 @@ class FileUploader extends React.Component { thumbnailWidth: 200, thumbnailHeight: 200, // TODO what is a good list of MIME types???? - acceptedFiles: 'image/*,audio/*,text/javascript,text/html,text/css,application/json,application/x-font-ttf,application/x-font-truetype,text/plain', + acceptedFiles: 'image/*,audio/*,text/javascript,text/html,text/css,application/json,application/x-font-ttf,application/x-font-truetype,text/plain,text/csv', dictDefaultMessage: 'Drop files here to upload or click to use the file browser', accept: this.props.dropzoneAcceptCallback, sending: this.props.dropzoneSendingCallback, diff --git a/client/modules/IDE/components/NewFileModal.js b/client/modules/IDE/components/NewFileModal.js index a1fea74c..e01d084c 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$|.+\.json$|.+\.txt$)/i)) { - errors.name = 'File must be of type JavaScript, CSS, JSON, or TXT.'; + } else if (!formProps.name.match(/(.+\.js$|.+\.css$|.+\.json$|.+\.txt$|.+\.csv$)/i)) { + errors.name = 'File must be of type JavaScript, CSS, JSON, TXT, or CSV.'; } return errors; diff --git a/client/modules/IDE/components/PreviewFrame.js b/client/modules/IDE/components/PreviewFrame.js index 6c826f3c..f7baf4f0 100644 --- a/client/modules/IDE/components/PreviewFrame.js +++ b/client/modules/IDE/components/PreviewFrame.js @@ -167,19 +167,21 @@ class PreviewFrame extends React.Component { htmlFile = hijackConsoleLogsScript() + htmlFile; const mediaFiles = this.props.files.filter(file => file.url); - const textFiles = this.props.files.filter(file => file.name.match(/(.+\.json$|.+\.txt$)/i)); + const textFiles = this.props.files.filter(file => file.name.match(/(.+\.json$|.+\.txt$|.+\.csv$)/i) && file.url === undefined); + console.log(textFiles); const jsFiles = []; this.props.jsFiles.forEach(jsFile => { const newJSFile = { ...jsFile }; let jsFileStrings = newJSFile.content.match(/(['"])((\\\1|.)*?)\1/gm); - const jsFileRegex = /^('|")(?!(http:\/\/|https:\/\/)).*\.(png|jpg|jpeg|gif|bmp|mp3|wav|aiff|ogg|json|txt)('|")$/i; + const jsFileRegex = /^('|")(?!(http:\/\/|https:\/\/)).*\.(png|jpg|jpeg|gif|bmp|mp3|wav|aiff|ogg|json|txt|csv)('|")$/i; jsFileStrings = jsFileStrings || []; jsFileStrings.forEach(jsFileString => { if (jsFileString.match(jsFileRegex)) { const filePath = jsFileString.substr(1, jsFileString.length - 2); const filePathArray = filePath.split('/'); const fileName = filePathArray[filePathArray.length - 1]; + console.log(fileName); mediaFiles.forEach(file => { if (file.name === fileName) { newJSFile.content = newJSFile.content.replace(filePath, file.url); // eslint-disable-line