Fix list formatting alternating on edit (#7422)

Co-authored-by: Andy Balaam <andyb@element.io>
This commit is contained in:
Renan Cleyson
2021-12-21 10:07:44 +00:00
committed by GitHub
co-authored by Andy Balaam
parent 8b2a478a25
commit 9ac85bcaa3
2 changed files with 35 additions and 1 deletions
+13 -1
View File
@@ -242,7 +242,19 @@ function parseHtmlMessage(html: string, partCreator: PartCreator, isQuotedMessag
}
if (n.nodeType === Node.TEXT_NODE) {
newParts.push(...parseAtRoomMentions(n.nodeValue, partCreator));
let { nodeValue } = n;
// Sometimes commonmark adds a newline at the end of the list item text
if (n.parentNode.nodeName === "LI") {
nodeValue = nodeValue.trimEnd();
}
newParts.push(...parseAtRoomMentions(nodeValue, partCreator));
const grandParent = n.parentNode.parentNode;
const isTight = n.parentNode.nodeName !== "P" || grandParent?.nodeName !== "LI";
if (!isTight) {
newParts.push(partCreator.newline());
}
} else if (n.nodeType === Node.ELEMENT_NODE) {
const parseResult = parseElement(n, partCreator, lastNode, state);
if (parseResult) {