From 338ea57eb9d3f48c8741fc4e6dad53d8cd49a902 Mon Sep 17 00:00:00 2001 From: Amy Evans Date: Fri, 24 May 2024 11:48:13 -0400 Subject: [PATCH] Revert "add possibility of excluding styles in useMarkdownStyles" --- src/components/Composer/index.native.tsx | 3 +- src/components/Composer/index.tsx | 3 +- src/components/Composer/types.ts | 3 -- src/hooks/useMarkdownStyle.ts | 35 +++---------------- .../ComposerWithSuggestions.tsx | 1 - 5 files changed, 7 insertions(+), 38 deletions(-) diff --git a/src/components/Composer/index.native.tsx b/src/components/Composer/index.native.tsx index ac7eb95191eee..4d135cdd88e2b 100644 --- a/src/components/Composer/index.native.tsx +++ b/src/components/Composer/index.native.tsx @@ -27,7 +27,6 @@ function Composer( // On Android the selection prop is required on the TextInput but this prop has issues on IOS selection, value, - isGroupPolicyReport = false, ...props }: ComposerProps, ref: ForwardedRef, @@ -35,7 +34,7 @@ function Composer( const textInput = useRef(null); const {isFocused, shouldResetFocus} = useResetComposerFocus(textInput); const theme = useTheme(); - const markdownStyle = useMarkdownStyle(value, !isGroupPolicyReport ? ['mentionReport'] : []); + const markdownStyle = useMarkdownStyle(value); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); diff --git a/src/components/Composer/index.tsx b/src/components/Composer/index.tsx index f7bf277050a21..4bc54d13b0561 100755 --- a/src/components/Composer/index.tsx +++ b/src/components/Composer/index.tsx @@ -70,14 +70,13 @@ function Composer( isReportActionCompose = false, isComposerFullSize = false, shouldContainScroll = false, - isGroupPolicyReport = false, ...props }: ComposerProps, ref: ForwardedRef, ) { const theme = useTheme(); const styles = useThemeStyles(); - const markdownStyle = useMarkdownStyle(value, !isGroupPolicyReport ? ['mentionReport'] : []); + const markdownStyle = useMarkdownStyle(value); const StyleUtils = useStyleUtils(); const textRef = useRef(null); const textInput = useRef(null); diff --git a/src/components/Composer/types.ts b/src/components/Composer/types.ts index 0ff91111bd07c..531bcd03f8bf8 100644 --- a/src/components/Composer/types.ts +++ b/src/components/Composer/types.ts @@ -70,9 +70,6 @@ type ComposerProps = TextInputProps & { /** Should make the input only scroll inside the element avoid scroll out to parent */ shouldContainScroll?: boolean; - - /** Indicates whether the composer is in a group policy report. Used for disabling report mentioning style in markdown input */ - isGroupPolicyReport?: boolean; }; export type {TextSelection, ComposerProps}; diff --git a/src/hooks/useMarkdownStyle.ts b/src/hooks/useMarkdownStyle.ts index 57d17ffefb0b5..b1f430e232e44 100644 --- a/src/hooks/useMarkdownStyle.ts +++ b/src/hooks/useMarkdownStyle.ts @@ -5,25 +5,12 @@ import FontUtils from '@styles/utils/FontUtils'; import variables from '@styles/variables'; import useTheme from './useTheme'; -function useMarkdownStyle(message: string | null = null, excludeStyles: Array = []): MarkdownStyle { +function useMarkdownStyle(message: string | null = null): MarkdownStyle { const theme = useTheme(); const emojiFontSize = containsOnlyEmojis(message ?? '') ? variables.fontSizeOnlyEmojis : variables.fontSizeNormal; - // this map is used to reset the styles that are not needed - passing undefined value can break the native side - const nonStylingDefaultValues: Record = useMemo( + const markdownStyle = useMemo( () => ({ - color: theme.text, - backgroundColor: 'transparent', - marginLeft: 0, - paddingLeft: 0, - borderColor: 'transparent', - borderWidth: 0, - }), - [theme], - ); - - const markdownStyle = useMemo(() => { - const styling = { syntax: { color: theme.syntax, }, @@ -66,21 +53,9 @@ function useMarkdownStyle(message: string | null = null, excludeStyles: Array { - const style: Record = styling[key]; - if (style) { - Object.keys(style).forEach((styleKey) => { - style[styleKey] = nonStylingDefaultValues[styleKey] ?? style[styleKey]; - }); - } - }); - } - - return styling; - }, [theme, emojiFontSize, excludeStyles, nonStylingDefaultValues]); + }), + [theme, emojiFontSize], + ); return markdownStyle; } diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 29b25828d24bc..7c7ab9a013076 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -765,7 +765,6 @@ function ComposerWithSuggestions( onLayout={onLayout} onScroll={hideSuggestionMenu} shouldContainScroll={Browser.isMobileSafari()} - isGroupPolicyReport={isGroupPolicyReport} />