0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-25 18:22:42 +00:00

Added cursor activity to editor, removed uneeded languages

This commit is contained in:
Scott Tolksdorf
2016-05-04 14:05:37 -04:00
parent 582602740f
commit 1db6553365
119 changed files with 31 additions and 26101 deletions

View File

@@ -16,23 +16,40 @@ if(typeof navigator !== 'undefined'){
var CodeEditor = React.createClass({
getDefaultProps: function() {
return {
language : 'javascript',
text : 'yo dawg',
onChange : function(){}
language : '',
value : '',
onChange : function(){},
onCursorActivity : function(){},
};
},
componentDidMount: function() {
this.editor = CodeMirror(this.refs.editor,{
this.codeMirror = CodeMirror(this.refs.editor,{
value : this.props.value,
lineNumbers: true,
mode : this.props.language
});
this.codeMirror.on('change', this.handleChange);
this.codeMirror.on('cursorActivity', this.handleCursorActivity);
},
componentWillReceiveProps: _.debounce((nextProps)=>{
if(this.codeMirror && nextProps.value !== undefined && this.codeMirror.getValue() != nextProps.value) {
this.codeMirror.setValue(nextProps.value);
}
}, 0),
handleChange : function(editor){
this.props.onChange(editor.getValue());
},
handleCursorActivity : function(){
this.props.onCursorActivity(this.codeMirror.getCursor());
},
render : function(){
return <div className='codeEditor' ref='editor'>
CodeEditor Ready!
</div>
return <div className='codeEditor' ref='editor' />
}
});