From dea91498482df511becb8fa333fdfa13f10f7dbc Mon Sep 17 00:00:00 2001 From: sokripon Date: Mon, 30 Dec 2024 03:44:38 +0100 Subject: [PATCH] fix(TextComponent): add white-space pre formatting for inline text (#4985) * fix(TextComponent): add white-space pre formatting for inline text * feat(TextComponent): add preFormattingMonospace * fix(multiplayer): disable preFormattingMonospace for TextComponent --- .../src/routes/menu/common/TextComponent.svelte | 13 +++++++++---- .../src/routes/menu/multiplayer/Multiplayer.svelte | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src-theme/src/routes/menu/common/TextComponent.svelte b/src-theme/src/routes/menu/common/TextComponent.svelte index 86afd86bf224..78fc521d5544 100644 --- a/src-theme/src/routes/menu/common/TextComponent.svelte +++ b/src-theme/src/routes/menu/common/TextComponent.svelte @@ -3,6 +3,7 @@ export let textComponent: TTextComponent | string; export let allowPreformatting = false; + export let preFormattingMonospace = true; export let inheritedColor = "#ffffff"; export let inheritedStrikethrough = false; export let inheritedItalic = false; @@ -107,7 +108,7 @@ {#if typeof textComponent === "string"} - + {:else if textComponent} {#if textComponent.text} {#if !textComponent.text.includes("§")} @@ -116,9 +117,10 @@ class:underlined={textComponent.underlined !== undefined ? textComponent.underlined : inheritedUnderlined} class:strikethrough={textComponent.strikethrough !== undefined ? textComponent.strikethrough : inheritedStrikethrough} class:allow-preformatting={allowPreformatting} + class:monospace={preFormattingMonospace && allowPreformatting} style="color: {textComponent.color !== undefined ? translateColor(textComponent.color) : translateColor(inheritedColor)}; font-size: {fontSize}px;">{textComponent.text} {:else} - connectToServer(server.address)}> -