var React = require('react'); var _ = require('lodash'); var cx = require('classnames'); var SnippetIcons = require('./snippets/snippets.js'); var Editor = React.createClass({ getDefaultProps: function() { return { text : "", onChange : function(){} }; }, componentDidMount: function() { this.refs.textarea.focus(); }, handleTextChange : function(e){ this.props.onChange(e.target.value); }, iconClick : function(snippetFn){ var curPos = this.refs.textarea.selectionStart; this.props.onChange(this.props.text.slice(0, curPos) + snippetFn() + this.props.text.slice(curPos + 1)); }, renderTemplateIcons : function(){ return _.map(SnippetIcons, (t) => { return
; }) }, render : function(){ var self = this; return(
{this.renderTemplateIcons()}