FIX: Support emoji in "Popular Links"
This commit is contained in:
parent
7c092b0fe0
commit
87b52e4cea
|
@ -1,5 +1,11 @@
|
|||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { emojiUrlFor } from 'discourse/lib/text';
|
||||
import { emojiUrlFor, emojiUnescape } from 'discourse/lib/text';
|
||||
import RawHtml from 'discourse/widgets/raw-html';
|
||||
|
||||
export function replaceEmoji(str) {
|
||||
const escaped = emojiUnescape(Handlebars.Utils.escapeExpression(str));
|
||||
return [new RawHtml({ html: `<span>${escaped}</span>` })];
|
||||
}
|
||||
|
||||
export default createWidget('emoji', {
|
||||
tagName: 'img.emoji',
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { iconNode } from 'discourse/helpers/fa-icon';
|
||||
import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
import RawHtml from 'discourse/widgets/raw-html';
|
||||
import { emojiUnescape } from 'discourse/lib/text';
|
||||
import { replaceEmoji } from 'discourse/widgets/emoji';
|
||||
|
||||
export default createWidget('post-links', {
|
||||
tagName: 'div.post-links-container',
|
||||
|
@ -13,8 +12,7 @@ export default createWidget('post-links', {
|
|||
},
|
||||
|
||||
linkHtml(link) {
|
||||
const escapedTitle = emojiUnescape(Handlebars.Utils.escapeExpression(link.title));
|
||||
const linkBody = [new RawHtml({ html: `<span>${escapedTitle}</span>` })];
|
||||
const linkBody = replaceEmoji(link.title);
|
||||
if (link.clicks) {
|
||||
linkBody.push(h('span.badge.badge-notification.clicks', link.clicks.toString()));
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { createWidget } from 'discourse/widgets/widget';
|
|||
import { h } from 'virtual-dom';
|
||||
import { avatarImg, avatarFor } from 'discourse/widgets/post';
|
||||
import { dateNode, numberNode } from 'discourse/helpers/node';
|
||||
import { replaceEmoji } from 'discourse/widgets/emoji';
|
||||
|
||||
const LINKS_SHOWN = 5;
|
||||
|
||||
|
@ -115,8 +116,7 @@ createWidget('topic-map-link', {
|
|||
},
|
||||
|
||||
html(attrs) {
|
||||
if (attrs.title) { return attrs.title; }
|
||||
return attrs.url;
|
||||
return attrs.title ? replaceEmoji(attrs.title) : attrs.url;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue