Skip to content

Commit

Permalink
Merge pull request #54983 from bernhardoj/fix/53145-handle-format-com…
Browse files Browse the repository at this point in the history
…mand
  • Loading branch information
blimpich authored Jan 10, 2025
2 parents d22d9b5 + 1106916 commit d7a0088
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
},
"dependencies": {
"@dotlottie/react-player": "^1.6.3",
"@expensify/react-native-live-markdown": "0.1.210",
"@expensify/react-native-live-markdown": "0.1.215",
"@expo/metro-runtime": "^4.0.0",
"@firebase/app": "^0.10.10",
"@firebase/performance": "^0.6.8",
Expand Down
12 changes: 12 additions & 0 deletions src/components/RNMarkdownTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ type AnimatedMarkdownTextInputRef = typeof AnimatedMarkdownTextInput & MarkdownT

type RNMarkdownTextInputProps = Omit<MarkdownTextInputProps, 'parser'>;

function handleFormatSelection(selectedText: string, formatCommand: string) {
switch (formatCommand) {
case 'formatBold':
return `*${selectedText}*`;
case 'formatItalic':
return `_${selectedText}_`;
default:
return selectedText;
}
}

function RNMarkdownTextInputWithRef({maxLength, ...props}: RNMarkdownTextInputProps, ref: ForwardedRef<AnimatedMarkdownTextInputRef>) {
const theme = useTheme();

Expand All @@ -28,6 +39,7 @@ function RNMarkdownTextInputWithRef({maxLength, ...props}: RNMarkdownTextInputPr
}
ref(refHandle as AnimatedMarkdownTextInputRef);
}}
formatSelection={handleFormatSelection}
// eslint-disable-next-line
{...props}
/**
Expand Down

0 comments on commit d7a0088

Please sign in to comment.