mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Don't convert :) into Emoji when emojis or emoji shurtcuts are disabled
This commit is contained in:
@@ -44,7 +44,7 @@ export function performEmojiUnescape(string, opts) {
|
||||
}
|
||||
|
||||
return string.replace(unicodeRegexp, m => {
|
||||
const isEmoticon = !!translations[m];
|
||||
const isEmoticon = opts.enableEmojiShortcuts && !!translations[m];
|
||||
const isUnicodeEmoticon = !!replacements[m];
|
||||
let emojiVal;
|
||||
if (isEmoticon) {
|
||||
@@ -70,12 +70,12 @@ export function performEmojiUnescape(string, opts) {
|
||||
return string;
|
||||
}
|
||||
|
||||
export function performEmojiEscape(string) {
|
||||
export function performEmojiEscape(string, opts) {
|
||||
return string.replace(unicodeRegexp, m => {
|
||||
if (!!translations[m]) {
|
||||
return ":" + translations[m] + ":";
|
||||
return opts.emojiShortcuts ? `:${translations[m]}:` : m;
|
||||
} else if (!!replacements[m]) {
|
||||
return ":" + replacements[m] + ":";
|
||||
return `:${replacements[m]}:`;
|
||||
} else {
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,8 @@ const rule = {
|
||||
if (options.enableEmoji) {
|
||||
title = performEmojiUnescape(topicInfo.title, {
|
||||
getURL: options.getURL,
|
||||
emojiSet: options.emojiSet
|
||||
emojiSet: options.emojiSet,
|
||||
enableEmojiShortcuts: options.enableEmojiShortcuts
|
||||
});
|
||||
}
|
||||
|
||||
@@ -154,6 +155,7 @@ export function setup(helper) {
|
||||
helper.registerOptions((opts, siteSettings) => {
|
||||
opts.enableEmoji = siteSettings.enable_emoji;
|
||||
opts.emojiSet = siteSettings.emoji_set;
|
||||
opts.enableEmojiShortcuts = siteSettings.enable_emoji_shortcuts;
|
||||
});
|
||||
|
||||
helper.registerPlugin(md => {
|
||||
|
||||
Reference in New Issue
Block a user