2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FIX: keep newlines between paragraphs when quoting a post

This commit is contained in:
Régis Hanol 2017-07-23 15:25:28 +02:00
parent 93f2c97266
commit 65ab5f58fe

View file

@ -102,8 +102,10 @@ export function selectedText() {
$div.find("img.emoji").replaceWith(function() { return this.title; });
// replace br with newlines
$div.find("br").replaceWith(() => "\n");
// enforce newline at the end of paragraphs
$div.find("p").append(() => "\n");
return String($div.text()).trim();
return String($div.text()).trim().replace(/(^\s*\n)+/gm, "\n");
}
// Determine the row and col of the caret in an element