diff --git a/src/editor/deserialize.js b/src/editor/deserialize.js index 1b99d70946..947ce30ce7 100644 --- a/src/editor/deserialize.js +++ b/src/editor/deserialize.js @@ -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);