From 60e10364b0642a477e3fefeb213ec412e6125174 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 20 Aug 2019 12:36:19 +0200 Subject: [PATCH] add quoting functionality to new composer --- src/components/views/rooms/SendMessageComposer.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/views/rooms/SendMessageComposer.js b/src/components/views/rooms/SendMessageComposer.js index b3c65b5a97..259e32682a 100644 --- a/src/components/views/rooms/SendMessageComposer.js +++ b/src/components/views/rooms/SendMessageComposer.js @@ -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; + } } };