mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-05-02 00:44:47 -04:00
Support for emoji poster icons
This commit is contained in:
parent
6935925f10
commit
4d599612a2
2 changed files with 15 additions and 5 deletions
app/assets/javascripts/discourse
|
@ -62,17 +62,19 @@ class PluginApi {
|
||||||
*
|
*
|
||||||
* This function can be used to add an icon with a link that will be displayed
|
* 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
|
* 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:
|
* 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
|
* className (optional) a css class to apply to the icon
|
||||||
* url (optional) where to link the icon
|
* url (optional) where to link the icon
|
||||||
* title (optional) the tooltip title for the icon on hover
|
* title (optional) the tooltip title for the icon on hover
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* api.addPosterIcon(cfs => {
|
* api.addPosterIcon((cfs, attrs) => {
|
||||||
* if (cfs.customer) {
|
* if (cfs.customer) {
|
||||||
* return { icon: 'user', className: 'customer', title: 'customer' };
|
* return { icon: 'user', className: 'customer', title: 'customer' };
|
||||||
* }
|
* }
|
||||||
|
|
|
@ -64,10 +64,18 @@ export default createWidget('poster-name', {
|
||||||
const cfs = attrs.userCustomFields;
|
const cfs = attrs.userCustomFields;
|
||||||
if (cfs) {
|
if (cfs) {
|
||||||
_callbacks.forEach(cb => {
|
_callbacks.forEach(cb => {
|
||||||
const result = cb(cfs);
|
const result = cb(cfs, attrs);
|
||||||
if (result) {
|
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) {
|
if (result.url) {
|
||||||
iconBody = h('a', { attributes: { href: result.url } }, iconBody);
|
iconBody = h('a', { attributes: { href: result.url } }, iconBody);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue