HTML and Markdown emotes.

This commit is contained in:
Matthew Hodgson 2015-11-28 22:34:45 +00:00
parent 52376091cb
commit f028b343b0
2 changed files with 13 additions and 15 deletions

View file

@ -311,23 +311,21 @@ module.exports = React.createClass({
var isEmote = /^\/me /i.test(contentText); var isEmote = /^\/me /i.test(contentText);
var sendMessagePromise; var sendMessagePromise;
if (isEmote) { if (isEmote) {
sendMessagePromise = MatrixClientPeg.get().sendEmoteMessage( contentText = contentText.substring(4);
this.props.room.roomId, contentText.substring(4) }
);
var htmlText;
if (this.markdownEnabled) && (htmlText = mdownToHtml(contentText)) !== contentText) {
sendMessagePromise = isEmote ?
MatrixClientPeg.get().sendHtmlEmote(this.props.room.roomId, contentText, htmlText) :
MatrixClientPeg.get().sendHtmlMessage(this.props.room.roomId, contentText, htmlText);
} }
else { else {
var htmlText = mdownToHtml(contentText); sendMessagePromise = isEmote ?
if (this.markdownEnabled && htmlText !== contentText) { MatrixClientPeg.get().sendEmoteMessage(this.props.room.roomId, contentText) :
sendMessagePromise = MatrixClientPeg.get().sendHtmlMessage( MatrixClientPeg.get().sendTextMessage(this.props.room.roomId, contentText);
this.props.room.roomId, contentText, htmlText
);
}
else {
sendMessagePromise = MatrixClientPeg.get().sendTextMessage(
this.props.room.roomId, contentText
);
}
} }
sendMessagePromise.then(function() { sendMessagePromise.then(function() {

View file

@ -56,7 +56,7 @@ module.exports = React.createClass({
var name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender(); var name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender();
return ( return (
<span ref="content" className="mx_MEmoteTile mx_MessageTile_content"> <span ref="content" className="mx_MEmoteTile mx_MessageTile_content">
* {name} {content.body} * { name } { body }
</span> </span>
); );
case "m.notice": case "m.notice":