mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 18:25:49 +03:00
add newline parts for text messages as well
This commit is contained in:
parent
3abdf6b100
commit
34dbe5f314
1 changed files with 12 additions and 1 deletions
|
@ -59,6 +59,17 @@ export default function parseEvent(event) {
|
|||
if (content.format === "org.matrix.custom.html") {
|
||||
return parseHtmlMessage(content.formatted_body);
|
||||
} else {
|
||||
return [new PlainPart(content.body)];
|
||||
const lines = content.body.split("\n");
|
||||
const parts = lines.reduce((parts, line, i) => {
|
||||
const isLast = i === lines.length - 1;
|
||||
const text = new PlainPart(line);
|
||||
const newLine = !isLast && new NewlinePart("\n");
|
||||
if (newLine) {
|
||||
return parts.concat(text, newLine);
|
||||
} else {
|
||||
return parts.concat(text);
|
||||
}
|
||||
}, []);
|
||||
return parts;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue