From 547ff1e6c458b2b5e60e0a55e457e5ed38707ba2 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Wed, 20 Apr 2022 17:38:55 +0200 Subject: [PATCH] Revert "Don't break lines manually in chat messages." This reverts commit 2eca0e44d52fb64e1c6ed007da43ebd117affacd. --- static/galene.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/static/galene.js b/static/galene.js index f9b0e3f..77e1548 100644 --- a/static/galene.js +++ b/static/galene.js @@ -2959,6 +2959,23 @@ function formatLine(line) { return result; } +/** + * @param {string[]} lines + * @returns {HTMLElement} + */ +function formatLines(lines) { + let elts = []; + if(lines.length > 0) + elts = formatLine(lines[0]); + for(let i = 1; i < lines.length; i++) { + elts.push(document.createElement('br')); + elts = elts.concat(formatLine(lines[i])); + } + let elt = document.createElement('p'); + elts.forEach(e => elt.appendChild(e)); + return elt; +} + /** * @param {number} time * @returns {string} @@ -3009,8 +3026,7 @@ function addToChatbox(peerId, dest, nick, time, privileged, history, kind, messa container.classList.add('message-private'); if(kind !== 'me') { - let p = document.createElement('p'); - p.textContent = message.toString(); + let p = formatLines(message.toString().split('\n')); let doHeader = true; if(!peerId && !dest && !nick) { doHeader = false;