1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

Fix editing of non-html replies (#8418)

This commit is contained in:
Michael Telatynski
2022-04-27 09:43:10 +01:00
committed by GitHub
parent e718242912
commit 83ab266533
2 changed files with 26 additions and 4 deletions

View File

@ -20,7 +20,7 @@ import { createPartCreator } from "./mock";
const FOUR_SPACES = " ".repeat(4);
function htmlMessage(formattedBody, msgtype = "m.text") {
function htmlMessage(formattedBody: string, msgtype = "m.text") {
return {
getContent() {
return {
@ -32,7 +32,7 @@ function htmlMessage(formattedBody, msgtype = "m.text") {
} as unknown as MatrixEvent;
}
function textMessage(body, msgtype = "m.text") {
function textMessage(body: string, msgtype = "m.text") {
return {
getContent() {
return {
@ -43,6 +43,13 @@ function textMessage(body, msgtype = "m.text") {
} as unknown as MatrixEvent;
}
function textMessageReply(body: string, msgtype = "m.text") {
return {
...textMessage(body, msgtype),
replyEventId: "!foo:bar",
} as unknown as MatrixEvent;
}
function mergeAdjacentParts(parts) {
let prevPart;
for (let i = 0; i < parts.length; ++i) {
@ -404,5 +411,14 @@ describe('editor/deserialize', function() {
text: "> <del>no formatting here</del>",
});
});
it("it strips plaintext replies", () => {
const body = "> Sender: foo\n\nMessage";
const parts = normalize(parseEvent(textMessageReply(body), createPartCreator(), { shouldEscape: false }));
expect(parts.length).toBe(1);
expect(parts[0]).toStrictEqual({
type: "plain",
text: "Message",
});
});
});
});