preserve line breaks when editing comments, finally closes #77

This commit is contained in:
Martin Zimmermann 2014-04-09 09:48:15 +02:00
parent 13d979e290
commit f09b6b9bdb
2 changed files with 8 additions and 2 deletions

View File

@ -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) { api.view(comment.id, 1).then(function(rv) {
var textarea = lib.editorify($.new("div.textarea")); var textarea = lib.editorify($.new("div.textarea"));
textarea.textContent = rv.text; textarea.innerHTML = utils.detext(rv.text);
textarea.focus(); textarea.focus();
text.classList.remove("text"); text.classList.remove("text");

View File

@ -48,9 +48,15 @@ define(["app/markup"], function(Mark) {
return _.textContent.trim(); return _.textContent.trim();
}; };
var detext = function(text) {
return text.replace(/\n\n/gi, '<br><div><br></div>')
.replace(/\n/gi, '<br>');
};
return { return {
cookie: cookie, cookie: cookie,
ago: ago, ago: ago,
text: text text: text,
detext: detext
}; };
}); });