From da00fa7868e383845cf14b1624e4d51e15c01049 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 23 Aug 2021 09:16:22 +0200 Subject: [PATCH 1/3] Update escapeHtml Update escapeHtml in HtmlUtils class to create paragraphe when user have \r\n in popup text Signed-off-by: Gregoire Parant --- front/src/WebRtc/HtmlUtils.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/front/src/WebRtc/HtmlUtils.ts b/front/src/WebRtc/HtmlUtils.ts index a12fddfe..b99ceffc 100644 --- a/front/src/WebRtc/HtmlUtils.ts +++ b/front/src/WebRtc/HtmlUtils.ts @@ -1,3 +1,5 @@ +import { blackListManager } from "./BlackListManager"; + export class HtmlUtils { public static getElementByIdOrFail(id: string): T { const elem = document.getElementById(id); @@ -25,10 +27,14 @@ export class HtmlUtils { } public static escapeHtml(html: string): string { - const text = document.createTextNode(html.replace(/(\r\n|\r|\n)/g, "
")); - const p = document.createElement("p"); - p.appendChild(text); - return p.innerHTML; + let innerHTML = ""; + const tabBackLine = html.match(/(\r\n|\r|\n)/g); + for (const text in blackListManager) { + const p = document.createElement("p"); + p.appendChild(document.createTextNode(text)); + innerHTML += p.innerHTML; + } + return innerHTML; } public static urlify(text: string, style: string = ""): string { From 8c4ead84217d17bce24812697f16695967719c99 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 23 Aug 2021 09:43:43 +0200 Subject: [PATCH 2/3] Add "\n\r" to match Signed-off-by: Gregoire Parant --- front/src/WebRtc/HtmlUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/WebRtc/HtmlUtils.ts b/front/src/WebRtc/HtmlUtils.ts index b99ceffc..454d9a5d 100644 --- a/front/src/WebRtc/HtmlUtils.ts +++ b/front/src/WebRtc/HtmlUtils.ts @@ -28,7 +28,7 @@ export class HtmlUtils { public static escapeHtml(html: string): string { let innerHTML = ""; - const tabBackLine = html.match(/(\r\n|\r|\n)/g); + const tabBackLine = html.match(/(\n\r|\r\n|\r|\n)/g); for (const text in blackListManager) { const p = document.createElement("p"); p.appendChild(document.createTextNode(text)); From 99a9b5f9a25b19d382fefed5afe57021e58f5eec Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 23 Aug 2021 10:20:48 +0200 Subject: [PATCH 3/3] Update strategy to use css Signed-off-by: Gregoire Parant --- front/src/WebRtc/HtmlUtils.ts | 14 ++++---------- front/style/style.scss | 6 +++++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/front/src/WebRtc/HtmlUtils.ts b/front/src/WebRtc/HtmlUtils.ts index 454d9a5d..07cde749 100644 --- a/front/src/WebRtc/HtmlUtils.ts +++ b/front/src/WebRtc/HtmlUtils.ts @@ -1,5 +1,3 @@ -import { blackListManager } from "./BlackListManager"; - export class HtmlUtils { public static getElementByIdOrFail(id: string): T { const elem = document.getElementById(id); @@ -27,14 +25,10 @@ export class HtmlUtils { } public static escapeHtml(html: string): string { - let innerHTML = ""; - const tabBackLine = html.match(/(\n\r|\r\n|\r|\n)/g); - for (const text in blackListManager) { - const p = document.createElement("p"); - p.appendChild(document.createTextNode(text)); - innerHTML += p.innerHTML; - } - return innerHTML; + const text = document.createTextNode(html); + const p = document.createElement("p"); + p.appendChild(text); + return p.innerHTML; } public static urlify(text: string, style: string = ""): string { diff --git a/front/style/style.scss b/front/style/style.scss index 9b37e122..68e31cbc 100644 --- a/front/style/style.scss +++ b/front/style/style.scss @@ -1085,10 +1085,14 @@ div.action.danger p.action-body{ text-align: left; color: white; } -.popUpElement div { +.popUpElement div{ font-family: 'Press Start 2P'; font-size: 10px; background-color: #727678; + white-space: pre-line; +} +.popUpElement .nes-container{ + padding: 1rem 1rem; } .popUpElement button {