mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
docs better error display for live editor and JSX compiler
This commit is contained in:
+13
-2
@@ -466,6 +466,12 @@ section.black content {
|
|||||||
@include code-typography;
|
@include code-typography;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.playgroundError {
|
||||||
|
// The compiler view kills padding in order to render the CodeMirror code
|
||||||
|
// more nicely. For the error view, put a padding back
|
||||||
|
padding: 15px 20px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Button */
|
/* Button */
|
||||||
@@ -560,7 +566,7 @@ figure {
|
|||||||
margin-top: 60px;
|
margin-top: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Code Mirror */
|
/* CodeMirror */
|
||||||
|
|
||||||
div.CodeMirror pre, div.CodeMirror-linenumber, code {
|
div.CodeMirror pre, div.CodeMirror-linenumber, code {
|
||||||
@include code-typography;
|
@include code-typography;
|
||||||
@@ -622,6 +628,11 @@ p code {
|
|||||||
width: $columnWidth;
|
width: $columnWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.playgroundError {
|
||||||
|
color: darken($primary, 5%);
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
.MarkdownEditor textarea {
|
.MarkdownEditor textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100px
|
height: 100px
|
||||||
@@ -636,7 +647,7 @@ p code {
|
|||||||
padding-left: 9px;
|
padding-left: 9px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Codemirror doesn't support <jsx> syntax. Instead of highlighting it
|
/* CodeMirror doesn't support <jsx> syntax. Instead of highlighting it
|
||||||
as error, just ignore it */
|
as error, just ignore it */
|
||||||
.highlight .javascript .err {
|
.highlight .javascript .err {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
|
|||||||
+19
-5
@@ -53,7 +53,20 @@ var CodeMirrorEditor = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var selfCleaningTimeout = {
|
||||||
|
componentDidUpdate: function() {
|
||||||
|
clearTimeout(this.timeoutID);
|
||||||
|
},
|
||||||
|
|
||||||
|
setTimeout: function() {
|
||||||
|
clearTimeout(this.timeoutID);
|
||||||
|
this.timeoutID = setTimeout.apply(null, arguments);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var ReactPlayground = React.createClass({
|
var ReactPlayground = React.createClass({
|
||||||
|
mixins: [selfCleaningTimeout],
|
||||||
|
|
||||||
MODES: {XJS: 'XJS', JS: 'JS'}, //keyMirror({XJS: true, JS: true}),
|
MODES: {XJS: 'XJS', JS: 'JS'}, //keyMirror({XJS: true, JS: true}),
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@@ -137,11 +150,12 @@ var ReactPlayground = React.createClass({
|
|||||||
eval(compiledCode);
|
eval(compiledCode);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
React.renderComponent(
|
this.setTimeout(function() {
|
||||||
<div content={e.toString()} className="playgroundError" />,
|
React.renderComponent(
|
||||||
mountNode
|
<div className="playgroundError">{e.toString()}</div>,
|
||||||
);
|
mountNode
|
||||||
|
);
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user