Merge branch 'syntax-errors' of https://github.com/boazsender/p5.js-web-editor into boazsender-syntax-errors
This commit is contained in:
commit
a043dc16fe
1 changed files with 19 additions and 6 deletions
|
@ -4,6 +4,7 @@ import ReactDOM from 'react-dom';
|
||||||
import srcDoc from 'srcdoc-polyfill';
|
import srcDoc from 'srcdoc-polyfill';
|
||||||
|
|
||||||
import loopProtect from 'loop-protect';
|
import loopProtect from 'loop-protect';
|
||||||
|
import { JSHINT } from 'jshint';
|
||||||
import { getBlobUrl } from '../actions/files';
|
import { getBlobUrl } from '../actions/files';
|
||||||
import { resolvePathToFile } from '../../../../server/utils/filePath';
|
import { resolvePathToFile } from '../../../../server/utils/filePath';
|
||||||
|
|
||||||
|
@ -161,6 +162,22 @@ class PreviewFrame extends React.Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jsPreprocess(sketchDoc) {
|
||||||
|
let newContent = sketchDoc;
|
||||||
|
// check the code for js errors before sending it to strip comments
|
||||||
|
// or loops.
|
||||||
|
JSHINT(newContent);
|
||||||
|
|
||||||
|
if (!JSHINT.errors) {
|
||||||
|
newContent = decomment(newContent, {
|
||||||
|
ignore: /noprotect/g,
|
||||||
|
space: true
|
||||||
|
});
|
||||||
|
newContent = loopProtect(newContent);
|
||||||
|
}
|
||||||
|
return newContent;
|
||||||
|
}
|
||||||
|
|
||||||
injectLocalFiles() {
|
injectLocalFiles() {
|
||||||
const htmlFile = this.props.htmlFile.content;
|
const htmlFile = this.props.htmlFile.content;
|
||||||
let scriptOffs = [];
|
let scriptOffs = [];
|
||||||
|
@ -289,12 +306,8 @@ class PreviewFrame extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
newContent = decomment(newContent, {
|
|
||||||
ignore: /noprotect/g,
|
return this.jsPreprocess(newContent);
|
||||||
space: true
|
|
||||||
});
|
|
||||||
newContent = loopProtect(newContent);
|
|
||||||
return newContent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveCSSLinksInString(content, files) {
|
resolveCSSLinksInString(content, files) {
|
||||||
|
|
Loading…
Reference in a new issue