Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write :smile: for 😄, :tada: for 🎉, :rocket: for 🚀 #540 #1822

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading