From c111777f85fc93ab18c6e28473e70c9ed2810683 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Tue, 1 Dec 2015 00:37:00 +0100 Subject: Allow to switch between default and emoji-one emoji style --- web/react/utils/emoticons.jsx | 7 +++---- web/react/utils/utils.jsx | 9 +++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'web/react/utils') diff --git a/web/react/utils/emoticons.jsx b/web/react/utils/emoticons.jsx index bb948b6dc..6a8ba6984 100644 --- a/web/react/utils/emoticons.jsx +++ b/web/react/utils/emoticons.jsx @@ -1,6 +1,8 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. +import * as Utils from './utils.jsx'; + const emoticonPatterns = { smile: /(^|\s)(:-?\))(?=$|\s)/g, // :) wink: /(^|\s)(;-?\))(?=$|\s)/g, // ;) @@ -133,7 +135,7 @@ export function handleEmoticons(text, tokens) { const alias = `MM_EMOTICON${index}`; tokens.set(alias, { - value: `${matchText}`, + value: `${matchText}`, originalText: fullMatch }); @@ -154,6 +156,3 @@ export function handleEmoticons(text, tokens) { return output; } -function getImagePathForEmoticon(name) { - return `/static/images/emoji/${name}.png`; -} diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index aa9146183..df323eb0f 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -1227,3 +1227,12 @@ export function getPostTerm(post) { export function isFeatureEnabled(feature) { return PreferenceStore.getPreference(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS, Constants.FeatureTogglePrefix + feature.label, {value: 'false'}).value === 'true'; } + +export function getImagePathForEmoticon(name, style) { + const emojiStyle = style || PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'emoji_style', {value: 'default'}).value; + + if (name) { + return `/static/images/emoji/${emojiStyle}/${name}.png`; + } + return `/static/images/emoji/${emojiStyle}`; +} \ No newline at end of file -- cgit v1.2.3-1-g7c22