1
0
forked from mirror/misskey

Add support for unicode emojis

refs: https://github.com/syuilo/misskey/pull/3117#issuecomment-435745613
This commit is contained in:
Acid Chicken (硫酸鶏) 2018-11-05 15:15:30 +09:00
parent b7f10fdc10
commit 200ebefe92
3 changed files with 37 additions and 17 deletions

View File

@ -9,7 +9,11 @@ export default Vue.extend({
props: {
emoji: {
type: String,
required: true
required: false
},
raw: {
type: String,
required: false
},
customEmojis: {
required: false
@ -27,12 +31,11 @@ export default Vue.extend({
},
methods: {
exec() {
const { emoji, customEmojis } = this;
this.name = emoji;
console.log(emoji, customEmojis)
this.url = customEmojis && customEmojis.length ? customEmojis.find(e => e.name === emoji || e.aliases && e.aliases.includes(emoji)).url : null;
const { emoji, raw, customEmojis } = this;
this.name = emoji || raw;
this.url = !raw && customEmojis && customEmojis.length ? customEmojis.find(e => e.name === emoji || e.aliases && e.aliases.includes(emoji)).url : null;
if (!this.url) {
const { char } = lib[emoji] || { char: null };
const char = raw || lib[emoji] && lib[emoji].char;
if (char) {
this.url = `https://twemoji.maxcdn.com/2/svg/${char.codePointAt(0).toString(16)}.svg`;
this.alt = char;

View File

@ -187,10 +187,10 @@ export default Vue.component('misskey-flavored-markdown', {
}
case 'emoji': {
const { emoji } = token;
const { emoji, raw } = token;
const { customEmojis } = this;
return [createElement('mk-emoji', {
attrs: { emoji },
attrs: { emoji, raw },
props: { customEmojis }
})];
}

File diff suppressed because one or more lines are too long