-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b12fafc
commit ee89339
Showing
4 changed files
with
103 additions
and
162 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 49 additions & 115 deletions
164
examples/chat-demo-app/ui/src/components/emojiHelper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,52 @@ | ||
const emojiMap: Record<string, string> = { | ||
// Smiles and positive emotions | ||
'sourit': '😊', | ||
'smiles': '😊', | ||
'rit': '😄', | ||
'laughs': '😄', | ||
'rire aux éclats': '🤣', | ||
'laughs out loud': '🤣', | ||
'clin d\'oeil': '😉', | ||
'winks': '😉', | ||
'warmly': '🤗', | ||
'chaleureusement': '🤗', | ||
'excité': '😃', | ||
'excited': '😃', | ||
'heureux': '😄', | ||
'happy': '😄', | ||
'joyeux': '😊', | ||
'joyful': '😊', | ||
|
||
// Thinking and pondering | ||
'réfléchit': '🤔', | ||
'thinks': '🤔', | ||
'pense': '💭', | ||
'ponders': '💭', | ||
'curieux': '🧐', | ||
'curious': '🧐', | ||
|
||
// Negative emotions | ||
'triste': '😢', | ||
'sad': '😢', | ||
'inquiet': '😟', | ||
'worried': '😟', | ||
'confus': '😕', | ||
'confused': '😕', | ||
'frustré': '😤', | ||
'frustrated': '😤', | ||
'en colère': '😠', | ||
'angry': '😠', | ||
|
||
// Surprise and shock | ||
'surpris': '😮', | ||
'surprised': '😮', | ||
'choqué': '😱', | ||
'shocked': '😱', | ||
'bouche bée': '😲', | ||
'jaw drops': '😲', | ||
|
||
// Gestures and actions | ||
'hoche la tête': '🙂', | ||
'nods': '🙂', | ||
'fronce les sourcils': '😟', | ||
'frowns': '😟', | ||
'soupire': '😮💨', | ||
'sighs': '😮💨', | ||
'applaudit': '👏', | ||
'applauds': '👏', | ||
'pouce en l\'air': '👍', | ||
'thumbs up': '👍', | ||
'pouce en bas': '👎', | ||
'thumbs down': '👎', | ||
'lève la main': '🙋', | ||
'raises hand': '🙋', | ||
|
||
// Miscellaneous | ||
'cœur': '❤️', | ||
'heart': '❤️', | ||
'cligne des yeux': '😳', | ||
'blinks': '😳', | ||
'bâille': '🥱', | ||
'yawns': '🥱', | ||
'dort': '😴', | ||
'sleeps': '😴', | ||
'rêve': '💤', | ||
'dreams': '💤', | ||
'réfléchit profondément': '🧠', | ||
'thinks deeply': '🧠', | ||
'a une idée': '💡', | ||
'has an idea': '💡', | ||
'fête': '🎉', | ||
'celebrates': '🎉', | ||
|
||
// Sarcasm and humor | ||
'sarcastic': '😏', | ||
'sarcastique': '😏', | ||
'rolls eyes': '🙄', | ||
'lève les yeux au ciel': '🙄', | ||
'plaisante': '😜', | ||
'jokes': '😜', | ||
|
||
// Professional and formal | ||
'serre la main': '🤝', | ||
'shakes hands': '🤝', | ||
'salue': '👋', | ||
'waves': '👋', | ||
'présente': '👨🏫', | ||
'presents': '👨🏫', | ||
'cheerfully': '😄', | ||
'gaiement': '😄', | ||
'joyeusement': '😄', | ||
|
||
// Technology and modern life | ||
'tape sur le clavier': '⌨️', | ||
'types': '⌨️', | ||
'prend une photo': '📸', | ||
'takes a photo': '📸', | ||
'regarde son téléphone': '📱', | ||
'checks phone': '📱' | ||
}; | ||
// Smiles and positive emotions | ||
':)': '😊', | ||
':-)': '😊', | ||
':D': '😄', | ||
':-D': '😄', | ||
'XD': '🤣', | ||
';)': '😉', | ||
';-)': '😉', | ||
':>': '😃', | ||
':->': '😃', | ||
|
||
const defaultEmoji = '🌟'; // Using a star emoji as default | ||
// Negative emotions | ||
':(': '😢', | ||
':-(': '😢', | ||
':/': '😕', | ||
':-/': '😕', | ||
':@': '😠', | ||
':-@': '😠', | ||
|
||
// Surprise and shock | ||
':o': '😮', | ||
':-o': '😮', | ||
':O': '😱', | ||
':-O': '😱', | ||
|
||
// Other expressions | ||
':p': '😛', | ||
':-p': '😛', | ||
':P': '😛', | ||
':-P': '😛', | ||
':|': '😐', | ||
':-|': '😐', | ||
':3': '😊', | ||
|
||
// Additional emotes | ||
'<3': '❤️', | ||
'^_^': '😊', | ||
'-_-': '😑', | ||
'o_o': '😳', | ||
'O_O': '😳', | ||
'T_T': '😭', | ||
'¬_¬': '😒', | ||
}; | ||
|
||
export function replaceTextEmotesWithEmojis(text: string): string { | ||
return text.replace(/\*(.*?)\*/g, (match, p1) => { | ||
const lowercaseEmote = p1.toLowerCase().trim(); | ||
return emojiMap[lowercaseEmote] || defaultEmoji; | ||
}); | ||
} | ||
export function replaceTextEmotesWithEmojis(text: string): string { | ||
const emoteRegex = /(?<=\s|^)[:;XD@OP3<>^T¬\-\/_o]+(?=\s|$)|(?<=\s|^)[()]+(?=\s|$)/g; | ||
|
||
return text.replace(emoteRegex, (match) => { | ||
return emojiMap[match] || match; | ||
}); | ||
} |