Fix list formatting alternating on edit (#7422)
Co-authored-by: Andy Balaam <andyb@element.io>
This commit is contained in:
parent
8b2a478a25
commit
9ac85bcaa3
2 changed files with 35 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue