From: Dessalines Date: Sun, 12 Apr 2020 18:55:52 +0000 (-0400) Subject: Use twemoji style for emoji picker. X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%22https:/hacktivis.me/%7BpictshareAvatarThumbnail%28mod.avatar%29%7D?a=commitdiff_plain;h=676690097f0e781dfca2704b1ee88e5a7dfeb91c;p=lemmy.git Use twemoji style for emoji picker. --- diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 6898ebc7..5239eb2c 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -230,11 +230,14 @@ export class CommentForm extends Component { } setupEmojiPicker() { - emojiPicker.on('emoji', emoji => { + emojiPicker.on('emoji', twemojiHtmlStr => { if (this.state.commentForm.content == null) { this.state.commentForm.content = ''; } - let shortName = `:${emojiShortName[emoji]}:`; + var el = document.createElement('div'); + el.innerHTML = twemojiHtmlStr; + let nativeUnicode = (el.childNodes[0] as HTMLElement).getAttribute('alt'); + let shortName = `:${emojiShortName[nativeUnicode]}:`; this.state.commentForm.content += shortName; this.setState(this.state); }); diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx index a65ead46..912d8e58 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -383,11 +383,14 @@ export class PostForm extends Component { } setupEmojiPicker() { - emojiPicker.on('emoji', emoji => { + emojiPicker.on('emoji', twemojiHtmlStr => { if (this.state.postForm.body == null) { this.state.postForm.body = ''; } - let shortName = `:${emojiShortName[emoji]}:`; + var el = document.createElement('div'); + el.innerHTML = twemojiHtmlStr; + let nativeUnicode = (el.childNodes[0] as HTMLElement).getAttribute('alt'); + let shortName = `:${emojiShortName[nativeUnicode]}:`; this.state.postForm.body += shortName; this.setState(this.state); }); diff --git a/ui/src/utils.ts b/ui/src/utils.ts index fd23bf9e..21a7fef8 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -91,7 +91,7 @@ export const themes = [ export const emojiPicker = new EmojiButton({ // Use the emojiShortName from native - // style: 'twemoji', + style: 'twemoji', theme: 'dark', position: 'auto-start', // TODO i18n