add quoting functionality to new composer

pull/21833/head
Bruno Windels 2019-08-20 12:36:19 +02:00
parent 10c218825b
commit 60e10364b0
1 changed files with 12 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import BasicMessageComposer from "./BasicMessageComposer";
import ReplyPreview from "./ReplyPreview";
import RoomViewStore from '../../../stores/RoomViewStore';
import ReplyThread from "../elements/ReplyThread";
import {parseEvent} from '../../../editor/deserialize';
function addReplyToMessageContent(content, repliedToEvent, permalinkCreator) {
const replyContent = ReplyThread.makeReplyMixIn(repliedToEvent);
@ -137,6 +138,17 @@ export default class SendMessageComposer extends React.Component {
this.model.insertPartsAt([userPillPart], this._editorRef.getCaret());
break;
}
case 'quote': {
const {partCreator} = this.model;
const quoteParts = parseEvent(payload.event, partCreator, { isQuotedMessage: true });
// add two newlines
quoteParts.push(partCreator.newline());
quoteParts.push(partCreator.newline());
this.model.insertPartsAt(quoteParts, {offset: 0});
// refocus on composer, as we just clicked "Quote"
this._editorRef.focus();
break;
}
}
};