mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:24:05 -06:00
FIX: custom emojis leaking over multisite - take 2
This commit is contained in:
parent
ed1720cd02
commit
2710525d01
@ -35,7 +35,7 @@ export function performEmojiUnescape(string, opts) {
|
|||||||
const emojiVal = isEmoticon ? translations[m] : m.slice(1, m.length - 1);
|
const emojiVal = isEmoticon ? translations[m] : m.slice(1, m.length - 1);
|
||||||
const hasEndingColon = m.lastIndexOf(":") === m.length - 1;
|
const hasEndingColon = m.lastIndexOf(":") === m.length - 1;
|
||||||
const url = buildEmojiUrl(emojiVal, opts);
|
const url = buildEmojiUrl(emojiVal, opts);
|
||||||
const classes = isCustomEmoji(emojiVal) ? "emoji emoji-custom" : "emoji";
|
const classes = isCustomEmoji(emojiVal, opts) ? "emoji emoji-custom" : "emoji";
|
||||||
|
|
||||||
return url && (isEmoticon || hasEndingColon) ?
|
return url && (isEmoticon || hasEndingColon) ?
|
||||||
`<img src='${url}' title='${emojiVal}' alt='${emojiVal}' class='${classes}'>` : m;
|
`<img src='${url}' title='${emojiVal}' alt='${emojiVal}' class='${classes}'>` : m;
|
||||||
@ -45,8 +45,11 @@ export function performEmojiUnescape(string, opts) {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCustomEmoji(code) {
|
export function isCustomEmoji(code, opts) {
|
||||||
return extendedEmoji.hasOwnProperty(code.toLowerCase());
|
code = code.toLowerCase();
|
||||||
|
if (extendedEmoji.hasOwnProperty(code)) return true;
|
||||||
|
if (opts && opts.customEmoji && opts.customEmoji.hasOwnProperty(code)) return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildEmojiUrl(code, opts) {
|
export function buildEmojiUrl(code, opts) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { registerOption } from 'pretty-text/pretty-text';
|
import { registerOption } from 'pretty-text/pretty-text';
|
||||||
import { registerEmoji, buildEmojiUrl, isCustomEmoji } from 'pretty-text/emoji';
|
import { buildEmojiUrl, isCustomEmoji } from 'pretty-text/emoji';
|
||||||
import { translations } from 'pretty-text/emoji/data';
|
import { translations } from 'pretty-text/emoji/data';
|
||||||
|
|
||||||
let _unicodeReplacements;
|
let _unicodeReplacements;
|
||||||
@ -29,7 +29,7 @@ function checkPrev(prev) {
|
|||||||
registerOption((siteSettings, opts, state) => {
|
registerOption((siteSettings, opts, state) => {
|
||||||
opts.features.emoji = !!siteSettings.enable_emoji;
|
opts.features.emoji = !!siteSettings.enable_emoji;
|
||||||
opts.emojiSet = siteSettings.emoji_set || "";
|
opts.emojiSet = siteSettings.emoji_set || "";
|
||||||
_(state.customEmoji).each((url, name) => registerEmoji(name, url));
|
opts.customEmoji = state.customEmoji;
|
||||||
});
|
});
|
||||||
|
|
||||||
export function setup(helper) {
|
export function setup(helper) {
|
||||||
@ -38,11 +38,11 @@ export function setup(helper) {
|
|||||||
|
|
||||||
function imageFor(code) {
|
function imageFor(code) {
|
||||||
code = code.toLowerCase();
|
code = code.toLowerCase();
|
||||||
const options = helper.getOptions();
|
const opts = helper.getOptions();
|
||||||
const url = buildEmojiUrl(code, options);
|
const url = buildEmojiUrl(code, opts);
|
||||||
if (url) {
|
if (url) {
|
||||||
const title = `:${code}:`;
|
const title = `:${code}:`;
|
||||||
const classes = isCustomEmoji(code) ? "emoji emoji-custom" : "emoji";
|
const classes = isCustomEmoji(code, opts) ? "emoji emoji-custom" : "emoji";
|
||||||
return ['img', { href: url, title, 'class': classes, alt: title }];
|
return ['img', { href: url, title, 'class': classes, alt: title }];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user