Browse Source

make docs jsx compiler highlight transpiled js code

main
Cheng Lou 11 years ago
parent
commit
0e18bc2843
  1. 2
      _css/react.scss
  2. 10
      _js/live_editor.js

2
_css/react.scss

@ -459,7 +459,7 @@ section.black content {
} }
.playgroundPreview { .playgroundPreview {
padding: 14px; padding: 0;
width: 600px; width: 600px;
pre { pre {

10
_js/live_editor.js

@ -22,7 +22,8 @@ var CodeMirrorEditor = React.createClass({
mode: 'javascript', mode: 'javascript',
lineNumbers: false, lineNumbers: false,
matchBrackets: true, matchBrackets: true,
theme: 'solarized-light' theme: 'solarized-light',
readOnly: this.props.readOnly
}); });
this.editor.on('change', this.onChange); this.editor.on('change', this.onChange);
this.onChange(); this.onChange();
@ -82,7 +83,7 @@ var ReactPlayground = React.createClass({
} else if (this.state.mode === this.MODES.JS) { } else if (this.state.mode === this.MODES.JS) {
content = content =
<div className="playgroundJS playgroundStage"> <div className="playgroundJS playgroundStage">
{this.getDesugaredCode()} {this.getDesugaredCode()}
</div>; </div>;
} }
@ -111,13 +112,14 @@ var ReactPlayground = React.createClass({
} catch (e) { } } catch (e) { }
try { try {
var desugaredCode = this.getDesugaredCode();
if (this.props.renderCode) { if (this.props.renderCode) {
React.renderComponent( React.renderComponent(
<pre>{this.getDesugaredCode()}</pre>, <CodeMirrorEditor codeText={desugaredCode} readOnly={true} />,
mountNode mountNode
); );
} else { } else {
eval(this.getDesugaredCode()); eval(desugaredCode);
} }
} catch (e) { } catch (e) {
React.renderComponent( React.renderComponent(

Loading…
Cancel
Save