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/%24%7BgetStaticDir%28%29%7D/styles/maint-mode.css?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