From f09b6b9bdbf8deacd37cb4459c047fbb041ad36b Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Wed, 9 Apr 2014 09:48:15 +0200 Subject: [PATCH] preserve line breaks when editing comments, finally closes #77 --- isso/js/app/isso.js | 2 +- isso/js/app/utils.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/isso/js/app/isso.js b/isso/js/app/isso.js index 580cceb..0bec02e 100644 --- a/isso/js/app/isso.js +++ b/isso/js/app/isso.js @@ -194,7 +194,7 @@ define(["app/text/html", "app/dom", "app/utils", "app/config", "app/api", "app/m api.view(comment.id, 1).then(function(rv) { var textarea = lib.editorify($.new("div.textarea")); - textarea.textContent = rv.text; + textarea.innerHTML = utils.detext(rv.text); textarea.focus(); text.classList.remove("text"); diff --git a/isso/js/app/utils.js b/isso/js/app/utils.js index 4cf56cb..a7bbe59 100644 --- a/isso/js/app/utils.js +++ b/isso/js/app/utils.js @@ -48,9 +48,15 @@ define(["app/markup"], function(Mark) { return _.textContent.trim(); }; + var detext = function(text) { + return text.replace(/\n\n/gi, '

') + .replace(/\n/gi, '
'); + }; + return { cookie: cookie, ago: ago, - text: text + text: text, + detext: detext }; });