From 65ab5f58fe0c723493537e6c67b92025876074b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sun, 23 Jul 2017 15:25:28 +0200 Subject: [PATCH] FIX: keep newlines between paragraphs when quoting a post --- app/assets/javascripts/discourse/lib/utilities.js.es6 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/utilities.js.es6 b/app/assets/javascripts/discourse/lib/utilities.js.es6 index a1765cf9c6c..07ada98d4c5 100644 --- a/app/assets/javascripts/discourse/lib/utilities.js.es6 +++ b/app/assets/javascripts/discourse/lib/utilities.js.es6 @@ -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