mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:35:04 +08:00
add extra newline before P tags (when not first node)
This commit is contained in:
parent
0a663398ed
commit
2445421270
@ -76,7 +76,7 @@ function parseHeader(el, partCreator) {
|
||||
return partCreator.plain("#".repeat(depth) + " ");
|
||||
}
|
||||
|
||||
function parseElement(n, partCreator, state) {
|
||||
function parseElement(n, partCreator, lastNode, state) {
|
||||
switch (n.nodeName) {
|
||||
case "H1":
|
||||
case "H2":
|
||||
@ -107,6 +107,12 @@ function parseElement(n, partCreator, state) {
|
||||
return partCreator.plain(`${indent}- `);
|
||||
}
|
||||
}
|
||||
case "P": {
|
||||
if (lastNode) {
|
||||
return partCreator.newline();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "OL":
|
||||
case "UL":
|
||||
state.listDepth = (state.listDepth || 0) + 1;
|
||||
@ -183,7 +189,7 @@ function parseHtmlMessage(html, partCreator, isQuotedMessage) {
|
||||
if (n.nodeType === Node.TEXT_NODE) {
|
||||
newParts.push(...parseAtRoomMentions(n.nodeValue, partCreator));
|
||||
} else if (n.nodeType === Node.ELEMENT_NODE) {
|
||||
const parseResult = parseElement(n, partCreator, state);
|
||||
const parseResult = parseElement(n, partCreator, lastNode, state);
|
||||
if (parseResult) {
|
||||
if (Array.isArray(parseResult)) {
|
||||
newParts.push(...parseResult);
|
||||
|
Loading…
Reference in New Issue
Block a user