mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
Support for emoji poster icons
This commit is contained in:
parent
6935925f10
commit
4d599612a2
@ -62,17 +62,19 @@ class PluginApi {
|
||||
*
|
||||
* This function can be used to add an icon with a link that will be displayed
|
||||
* beside a poster's name. The `callback` is called with the post's user custom
|
||||
* fields, and will render an icon if it receives an object back.
|
||||
* fields and post attrions. An icon will be rendered if the callback returns
|
||||
* an object with the appropriate attributes.
|
||||
*
|
||||
* The returned object can have the following attributes:
|
||||
*
|
||||
* icon (required) the font awesome icon to render
|
||||
* icon the font awesome icon to render
|
||||
* emoji an emoji icon to render
|
||||
* className (optional) a css class to apply to the icon
|
||||
* url (optional) where to link the icon
|
||||
* title (optional) the tooltip title for the icon on hover
|
||||
*
|
||||
* ```
|
||||
* api.addPosterIcon(cfs => {
|
||||
* api.addPosterIcon((cfs, attrs) => {
|
||||
* if (cfs.customer) {
|
||||
* return { icon: 'user', className: 'customer', title: 'customer' };
|
||||
* }
|
||||
|
@ -64,10 +64,18 @@ export default createWidget('poster-name', {
|
||||
const cfs = attrs.userCustomFields;
|
||||
if (cfs) {
|
||||
_callbacks.forEach(cb => {
|
||||
const result = cb(cfs);
|
||||
const result = cb(cfs, attrs);
|
||||
if (result) {
|
||||
|
||||
let iconBody = iconNode(result.icon);
|
||||
let iconBody;
|
||||
|
||||
if (result.icon) {
|
||||
iconBody = iconNode(result.icon);
|
||||
} else if (result.emoji) {
|
||||
const src = Discourse.Emoji.urlFor(result.emoji);
|
||||
iconBody = h('img', { className: 'emoji', attributes: { src } });
|
||||
}
|
||||
|
||||
if (result.url) {
|
||||
iconBody = h('a', { attributes: { href: result.url } }, iconBody);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user