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
1 changed files with 3 additions and 1 deletions

View File

@ -102,8 +102,10 @@ export function selectedText() {
$div.find("img.emoji").replaceWith(function() { return this.title; }); $div.find("img.emoji").replaceWith(function() { return this.title; });
// replace br with newlines // replace br with newlines
$div.find("br").replaceWith(() => "\n"); $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 // Determine the row and col of the caret in an element