2015-06-15 20:35:28 +03:00
|
|
|
var React = require('react');
|
|
|
|
|
|
|
|
var MatrixClientPeg = require("../MatrixClientPeg");
|
|
|
|
|
|
|
|
module.exports = React.createClass({
|
2015-06-16 13:08:27 +03:00
|
|
|
onKeyDown: function (ev) {
|
|
|
|
if (ev.keyCode == 13) {
|
|
|
|
var contentText = this.refs.textarea.getDOMNode().value;
|
2015-06-16 17:29:13 +03:00
|
|
|
|
|
|
|
var content = null;
|
|
|
|
if (/^\/me /i.test(contentText)) {
|
|
|
|
content = {
|
|
|
|
msgtype: 'm.emote',
|
|
|
|
body: contentText.substring(4)
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
content = {
|
|
|
|
msgtype: 'm.text',
|
|
|
|
body: contentText
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixClientPeg.get().sendMessage(this.props.roomId, content);
|
2015-06-16 13:08:27 +03:00
|
|
|
this.refs.textarea.getDOMNode().value = '';
|
|
|
|
ev.preventDefault();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-06-15 20:35:28 +03:00
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<div className="mx_MessageComposer">
|
2015-06-16 13:08:27 +03:00
|
|
|
<textarea ref="textarea" onKeyDown={this.onKeyDown} />
|
2015-06-15 20:35:28 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|