From 499c0aa5554b8cf5c5ff4e361dfabcf830e6e0a0 Mon Sep 17 00:00:00 2001 From: rainbownapkin Date: Thu, 5 Dec 2024 05:56:36 -0500 Subject: [PATCH] Improved invisible white-space injection. --- www/js/channel/chatPreprocessor.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/www/js/channel/chatPreprocessor.js b/www/js/channel/chatPreprocessor.js index e435dd7..b434fcd 100644 --- a/www/js/channel/chatPreprocessor.js +++ b/www/js/channel/chatPreprocessor.js @@ -53,11 +53,23 @@ class chatPreprocessor{ addWhitespace(){ //for each word object in the body - this.bodyArray.forEach((wordObj, index) => { + this.bodyArray.forEach((wordObj, wordIndex) => { //if the word object hasn't been pre-processed elsewhere if(wordObj.type == "word"){ + var wordArray = []; //Add invisible whitespace in-between characters to keep it from breaking page layout - this.bodyArray[index].string = wordObj.string.split("").join("ㅤ"); + //this.bodyArray[index].string = wordObj.string.split("").join("ㅤ"); + this.bodyArray[wordIndex].string.split("").forEach((char, charIndex) => { + wordArray.push(char); + //Every eight characters + if(charIndex != 0 && charIndex % 8 == 0){ + //Push an invisible line-break character + wordArray.push("ㅤ"); + } + + }); + + this.bodyArray[wordIndex].string = wordArray.join(""); } }); }