cleanup
This commit is contained in:
parent
33b5443e25
commit
14af6aacb0
|
@ -1,9 +1,5 @@
|
|||
define(['react', 'lodash', 'jquery', './libs/codemirror-4.8/lib/codemirror',
|
||||
'./libs/codemirror-4.8/mode/javascript/javascript',
|
||||
'./libs/codemirror-4.8/addon/hint/html-hint',
|
||||
'./libs/codemirror-4.8/addon/hint/show-hint',
|
||||
'./libs/codemirror-4.8/addon/hint/xml-hint',
|
||||
'./libs/codemirror-4.8/addon/hint/html-hint',
|
||||
'./libs/codemirror-4.8/mode/xml/xml',
|
||||
'./libs/codemirror-4.8/addon/runmode/runmode'
|
||||
], function (React, _, $, CodeMirror) {
|
||||
|
@ -12,13 +8,10 @@ define(['react', 'lodash', 'jquery', './libs/codemirror-4.8/lib/codemirror',
|
|||
displayName: 'CodeMirrorViewer',
|
||||
propTypes: {
|
||||
id: React.PropTypes.string,
|
||||
runMode: React.PropTypes.bool,
|
||||
mode: React.PropTypes.string
|
||||
},
|
||||
getDefaultProps: function () {
|
||||
return {
|
||||
readOnly: false,
|
||||
runMode: true,
|
||||
mode: 'html'
|
||||
};
|
||||
},
|
||||
|
@ -42,25 +35,11 @@ define(['react', 'lodash', 'jquery', './libs/codemirror-4.8/lib/codemirror',
|
|||
},
|
||||
componentDidMount: function () {
|
||||
var value = this.props.valueLink ? this.props.valueLink() : this.props.value;
|
||||
var options = {
|
||||
readOnly: this.props.readOnly,
|
||||
lineWrapping: true,
|
||||
smartIndent: true,
|
||||
matchBrackets: true,
|
||||
value: value,
|
||||
lineNumbers: true,
|
||||
mode: 'javascript',
|
||||
gutters: ['CodeMirror-linenumbers', 'rt-annotations'],
|
||||
theme: 'solarized'
|
||||
};
|
||||
|
||||
var mode = this.props.mode;
|
||||
if (this.props.mode === 'html') {
|
||||
options.mode = 'text/html';
|
||||
} else {
|
||||
options.mode = 'javascript';
|
||||
mode = 'text/html';
|
||||
}
|
||||
|
||||
this.editor = CodeMirror.runMode(value, options.mode, this.getDOMNode());
|
||||
this.editor = CodeMirror.runMode(value, mode, this.getDOMNode());
|
||||
},
|
||||
componentWillUnmount: function () {
|
||||
this.editor.toTextArea();
|
||||
|
|
Loading…
Reference in New Issue