Skip to content

Commit

Permalink
write πŸ˜„ for πŸ˜„, πŸŽ‰ for πŸŽ‰, rocket for πŸš€ TryQuiet#540
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Sep 17, 2023
1 parent 1366d05 commit 62a2681
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ export const ChannelInputComponent: React.FC<ChannelInputProps> = ({
} else if (inputStateRef.current === INPUT_STATE.AVAILABLE) {
e.preventDefault()
const target = e.target as HTMLInputElement
target.innerText = replaceEmojicodesWithEmoji(target.innerText);
onChange(target.innerText)
onKeyPress(target.innerText)
setMessage('')
Expand Down Expand Up @@ -508,6 +509,16 @@ export const ChannelInputComponent: React.FC<ChannelInputProps> = ({
]
)

const emojiMap: { [key: string]: string } = {
"smile": "πŸ˜„",
"tada": "πŸŽ‰",
"rocket": "πŸš€",
};

function replaceEmojicodesWithEmoji(text: string) {
return text.replace(/:(\w+):/g, (match, p1) => emojiMap[p1] || match);
}

const handleFileInput = (event: React.ChangeEvent<HTMLInputElement>) => {
const target = event.target as HTMLInputElement
if (!target.files) return
Expand Down

0 comments on commit 62a2681

Please sign in to comment.