Make title attribute on emoji widget optional.

This commit is contained in:
Guo Xiang Tan 2016-11-18 12:35:23 +08:00
parent 00c0410fc7
commit 3f54730c2d
2 changed files with 8 additions and 2 deletions

View File

@ -92,7 +92,11 @@ class PluginApi {
if (result.icon) {
iconBody = iconNode(result.icon);
} else if (result.emoji) {
iconBody = result.emoji.split('|').map(name => dec.attach('emoji', { name }));
iconBody = result.emoji.split('|').map(name => {
let widgetAttrs = { name };
if (result.title) widgetAttrs.title = true;
dec.attach('emoji', widgetAttrs);
});
}
if (result.text) {

View File

@ -11,6 +11,8 @@ export default createWidget('emoji', {
tagName: 'img.emoji',
buildAttributes(attrs) {
return { src: emojiUrlFor(attrs.name), title: attrs.name, alt: `:${attrs.name}:` };
let result = { src: emojiUrlFor(attrs.name), alt: `:${attrs.name}:` };
if (attrs.title) result.title = attrs.name;
return result;
},
});