mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: add 'emoji-custom' class to custom emojis
This commit is contained in:
@@ -35,15 +35,20 @@ export function performEmojiUnescape(string, opts) {
|
||||
const emojiVal = isEmoticon ? translations[m] : m.slice(1, m.length - 1);
|
||||
const hasEndingColon = m.lastIndexOf(":") === m.length - 1;
|
||||
const url = buildEmojiUrl(emojiVal, opts);
|
||||
const classes = isCustomEmoji(emojiVal) ? "emoji emoji-custom" : "emoji";
|
||||
|
||||
return url && (isEmoticon || hasEndingColon) ?
|
||||
`<img src='${url}' title='${emojiVal}' alt='${emojiVal}' class='emoji'>` : m;
|
||||
`<img src='${url}' title='${emojiVal}' alt='${emojiVal}' class='${classes}'>` : m;
|
||||
});
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
export function isCustomEmoji(code) {
|
||||
return extendedEmoji.hasOwnProperty(code.toLowerCase());
|
||||
}
|
||||
|
||||
export function buildEmojiUrl(code, opts) {
|
||||
let url;
|
||||
code = code.toLowerCase();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { registerOption } from 'pretty-text/pretty-text';
|
||||
import { buildEmojiUrl } from 'pretty-text/emoji';
|
||||
import { buildEmojiUrl, isCustomEmoji } from 'pretty-text/emoji';
|
||||
import { translations } from 'pretty-text/emoji/data';
|
||||
|
||||
let _unicodeReplacements;
|
||||
@@ -38,10 +38,12 @@ export function setup(helper) {
|
||||
|
||||
function imageFor(code) {
|
||||
code = code.toLowerCase();
|
||||
const url = buildEmojiUrl(code, helper.getOptions());
|
||||
const options = helper.getOptions();
|
||||
const url = buildEmojiUrl(code, options);
|
||||
if (url) {
|
||||
const title = `:${code}:`;
|
||||
return ['img', { href: url, title, 'class': 'emoji', alt: title }];
|
||||
const classes = isCustomEmoji(code) ? "emoji emoji-custom" : "emoji";
|
||||
return ['img', { href: url, title, 'class': classes, alt: title }];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user