From 35413702dc2e5cb6f8e0ac8f15a295d09130add2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ska=C5=82ka?= Date: Wed, 7 Feb 2024 11:14:41 +0100 Subject: [PATCH] move input styles to separate variable --- src/MarkdownTextInput.web.tsx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index c53784cb..9ebeb36c 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -167,6 +167,7 @@ const MarkdownTextInput = React.forwardRef( // Empty placeholder would collapse the div, so we need to use zero-width space to prevent it const heightSafePlaceholder = useMemo(() => getPlaceholderValue(placeholder), [placeholder]); + const parseText = useCallback( (target: HTMLDivElement, text: string | null, customMarkdownStyles: MarkdownStyle, cursorPosition: number | null = null, shouldAddToHistory = true) => { if (text === null) { @@ -197,6 +198,19 @@ const MarkdownTextInput = React.forwardRef( return newMarkdownStyle; }, [markdownStyle]); + const inputStyles = useMemo( + () => + StyleSheet.flatten([ + styles.defaultInputStyles, + flattenedStyle && { + caretColor: (flattenedStyle as TextStyle).color || 'black', + }, + disabled && styles.disabledInputStyles, + createReactDOMStyle(preprocessStyle(flattenedStyle)), + ]) as CSSProperties, + [flattenedStyle, disabled], + ); + const undo = useCallback( (target: HTMLDivElement) => { if (!history.current) return ''; @@ -461,16 +475,7 @@ const MarkdownTextInput = React.forwardRef(