mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-12 13:12:46 +00:00
50 lines
1.0 KiB
JavaScript
50 lines
1.0 KiB
JavaScript
var React = require('react');
|
|
var _ = require('lodash');
|
|
var cx = require('classnames');
|
|
|
|
var CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx');
|
|
|
|
var SheetEditor = React.createClass({
|
|
getDefaultProps: function() {
|
|
return {
|
|
value : "",
|
|
onChange : function(){}
|
|
};
|
|
},
|
|
cursorPosition : {
|
|
line : 0,
|
|
ch : 0
|
|
},
|
|
|
|
componentDidMount: function() {
|
|
var paneHeight = this.refs.main.parentNode.clientHeight;
|
|
this.refs.codeEditor.codeMirror.setSize(null, paneHeight);
|
|
},
|
|
|
|
handleTextChange : function(text){
|
|
this.props.onChange(text);
|
|
},
|
|
handleCursorActivty : function(curpos){
|
|
this.cursorPosition = curpos;
|
|
},
|
|
|
|
//Called when there are changes to the editor's dimensions
|
|
update : function(){
|
|
this.refs.codeEditor.updateSize();
|
|
},
|
|
|
|
render : function(){
|
|
return <div className='sheetEditor' ref='main'>
|
|
<CodeEditor
|
|
ref='codeEditor'
|
|
wrap={true}
|
|
language='jsx'
|
|
value={this.props.value}
|
|
onChange={this.handleTextChange}
|
|
onCursorActivity={this.handleCursorActivty} />
|
|
</div>
|
|
}
|
|
});
|
|
|
|
module.exports = SheetEditor;
|