summaryrefslogtreecommitdiffstats
path: root/webapp/utils/emoticons.jsx
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-05-31 16:10:12 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-05-31 16:10:12 -0400
commit9e1cf71bc397444654302c61ad9f777a8e2a38c7 (patch)
treefccaa963192aa531836322357df42d842a79210f /webapp/utils/emoticons.jsx
parent8e2f427b46c0f38f2137f05b50f365d49c12fb61 (diff)
downloadchat-9e1cf71bc397444654302c61ad9f777a8e2a38c7.tar.gz
chat-9e1cf71bc397444654302c61ad9f777a8e2a38c7.tar.bz2
chat-9e1cf71bc397444654302c61ad9f777a8e2a38c7.zip
Fixed emoticons consuming the preceeding whitespace (#3187)
Diffstat (limited to 'webapp/utils/emoticons.jsx')
-rw-r--r--webapp/utils/emoticons.jsx8
1 files changed, 4 insertions, 4 deletions
diff --git a/webapp/utils/emoticons.jsx b/webapp/utils/emoticons.jsx
index 35c7dba04..58057a187 100644
--- a/webapp/utils/emoticons.jsx
+++ b/webapp/utils/emoticons.jsx
@@ -132,7 +132,7 @@ export function getEmoticonsByCodePoint() {
export function handleEmoticons(text, tokens) {
let output = text;
- function replaceEmoticonWithToken(fullMatch, matchText, name) {
+ function replaceEmoticonWithToken(fullMatch, prefix, matchText, name) {
if (getEmoticonsByName().has(name)) {
const index = tokens.size;
const alias = `MM_EMOTICON${index}`;
@@ -143,14 +143,14 @@ export function handleEmoticons(text, tokens) {
originalText: fullMatch
});
- return alias;
+ return prefix + alias;
}
return fullMatch;
}
// match named emoticons like :goat:
- output = output.replace(/(:([a-zA-Z0-9_-]+):)/g, (fullMatch, matchText, name) => replaceEmoticonWithToken(fullMatch, matchText, name));
+ output = output.replace(/(:([a-zA-Z0-9_-]+):)/g, (fullMatch, matchText, name) => replaceEmoticonWithToken(fullMatch, '', matchText, name));
// match text smilies like :D
for (const name of Object.keys(emoticonPatterns)) {
@@ -158,7 +158,7 @@ export function handleEmoticons(text, tokens) {
// this might look a bit funny, but since the name isn't contained in the actual match
// like with the named emoticons, we need to add it in manually
- output = output.replace(pattern, (fullMatch, matchText) => replaceEmoticonWithToken(fullMatch, matchText, name));
+ output = output.replace(pattern, (fullMatch, prefix, matchText) => replaceEmoticonWithToken(fullMatch, prefix, matchText, name));
}
return output;