From 5500e45d30161665d9763e9b66256479bf732fc1 Mon Sep 17 00:00:00 2001 From: Robert Kozik Date: Tue, 14 May 2024 10:39:51 +0200 Subject: [PATCH] use non styling values for overwriting excluded styles --- src/hooks/useMarkdownStyle.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hooks/useMarkdownStyle.ts b/src/hooks/useMarkdownStyle.ts index 2820f593128e..ef331ca31c9e 100644 --- a/src/hooks/useMarkdownStyle.ts +++ b/src/hooks/useMarkdownStyle.ts @@ -5,6 +5,16 @@ import FontUtils from '@styles/utils/FontUtils'; import variables from '@styles/variables'; import useTheme from './useTheme'; +const nonStylingDefaultValues: Record = { + color: 'black', + backgroundColor: 'transparent', + marginLeft: 0, + paddingLeft: 0, + borderColor: 'transparent', + borderWidth: 0, +} + + function useMarkdownStyle(message: string | null = null, excludeStyles: Array = []): MarkdownStyle { const theme = useTheme(); const emojiFontSize = containsOnlyEmojis(message ?? '') ? variables.fontSizeOnlyEmojis : variables.fontSizeNormal; @@ -60,7 +70,7 @@ function useMarkdownStyle(message: string | null = null, excludeStyles: Array = styling[key]; if (style) { Object.keys(style).forEach((styleKey) => { - style[styleKey] = undefined; + style[styleKey] = nonStylingDefaultValues[styleKey] ?? style[styleKey]; }); } });