Add support for unicode emojis
refs: https://github.com/syuilo/misskey/pull/3117#issuecomment-435745613
This commit is contained in:
parent
b7f10fdc10
commit
200ebefe92
@ -9,7 +9,11 @@ export default Vue.extend({
|
|||||||
props: {
|
props: {
|
||||||
emoji: {
|
emoji: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: false
|
||||||
|
},
|
||||||
|
raw: {
|
||||||
|
type: String,
|
||||||
|
required: false
|
||||||
},
|
},
|
||||||
customEmojis: {
|
customEmojis: {
|
||||||
required: false
|
required: false
|
||||||
@ -27,12 +31,11 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
exec() {
|
exec() {
|
||||||
const { emoji, customEmojis } = this;
|
const { emoji, raw, customEmojis } = this;
|
||||||
this.name = emoji;
|
this.name = emoji || raw;
|
||||||
console.log(emoji, customEmojis)
|
this.url = !raw && customEmojis && customEmojis.length ? customEmojis.find(e => e.name === emoji || e.aliases && e.aliases.includes(emoji)).url : null;
|
||||||
this.url = customEmojis && customEmojis.length ? customEmojis.find(e => e.name === emoji || e.aliases && e.aliases.includes(emoji)).url : null;
|
|
||||||
if (!this.url) {
|
if (!this.url) {
|
||||||
const { char } = lib[emoji] || { char: null };
|
const char = raw || lib[emoji] && lib[emoji].char;
|
||||||
if (char) {
|
if (char) {
|
||||||
this.url = `https://twemoji.maxcdn.com/2/svg/${char.codePointAt(0).toString(16)}.svg`;
|
this.url = `https://twemoji.maxcdn.com/2/svg/${char.codePointAt(0).toString(16)}.svg`;
|
||||||
this.alt = char;
|
this.alt = char;
|
||||||
|
@ -187,10 +187,10 @@ export default Vue.component('misskey-flavored-markdown', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'emoji': {
|
case 'emoji': {
|
||||||
const { emoji } = token;
|
const { emoji, raw } = token;
|
||||||
const { customEmojis } = this;
|
const { customEmojis } = this;
|
||||||
return [createElement('mk-emoji', {
|
return [createElement('mk-emoji', {
|
||||||
attrs: { emoji },
|
attrs: { emoji, raw },
|
||||||
props: { customEmojis }
|
props: { customEmojis }
|
||||||
})];
|
})];
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user