From db09730d5f391c37bde87f59ed2ea6f3418034e4 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Jul 2020 13:32:23 -0400 Subject: Removing twemoji, and the massive emoji picker. Fixes #895 --- ui/src/components/comment-form.tsx | 29 ----------------------------- ui/src/components/post-form.tsx | 29 ----------------------------- ui/src/utils.ts | 17 +---------------- 3 files changed, 1 insertion(+), 74 deletions(-) (limited to 'ui/src') diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 32bc3786..22f871d2 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -17,7 +17,6 @@ import { toast, setupTribute, wsJsonToRes, - emojiPicker, pictrsDeleteToast, } from '../utils'; import { WebSocketService, UserService } from '../services'; @@ -72,7 +71,6 @@ export class CommentForm extends Component { super(props, context); this.tribute = setupTribute(); - this.setupEmojiPicker(); this.state = this.emptyState; @@ -241,15 +239,6 @@ export class CommentForm extends Component { )} - - - - - @@ -257,20 +246,6 @@ export class CommentForm extends Component { ); } - setupEmojiPicker() { - emojiPicker.on('emoji', twemojiHtmlStr => { - if (this.state.commentForm.content == null) { - this.state.commentForm.content = ''; - } - 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); - }); - } - handleFinished(op: UserOperation, data: CommentResponse) { let isReply = this.props.node !== undefined && data.comment.parent_id !== null; @@ -318,10 +293,6 @@ export class CommentForm extends Component { i.setState(i.state); } - handleEmojiPickerClick(_i: CommentForm, event: any) { - emojiPicker.togglePicker(event.target); - } - handleCommentContentChange(i: CommentForm, event: any) { i.state.commentForm.content = event.target.value; i.setState(i.state); diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx index a88d38c7..fc7884d7 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -33,7 +33,6 @@ import { randomStr, setupTribute, setupTippy, - emojiPicker, hostname, pictrsDeleteToast, } from '../utils'; @@ -95,7 +94,6 @@ export class PostForm extends Component { this.fetchPageTitle = debounce(this.fetchPageTitle).bind(this); this.tribute = setupTribute(); - this.setupEmojiPicker(); this.state = this.emptyState; @@ -332,15 +330,6 @@ export class PostForm extends Component { - - - - - {!this.props.post && ( @@ -420,20 +409,6 @@ export class PostForm extends Component { ); } - setupEmojiPicker() { - emojiPicker.on('emoji', twemojiHtmlStr => { - if (this.state.postForm.body == null) { - this.state.postForm.body = ''; - } - 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); - }); - } - handlePostSubmit(i: PostForm, event: any) { event.preventDefault(); @@ -596,10 +571,6 @@ export class PostForm extends Component { }); } - handleEmojiPickerClick(_i: PostForm, event: any) { - emojiPicker.togglePicker(event.target); - } - parseMessage(msg: WebSocketJsonResponse) { let res = wsJsonToRes(msg); if (msg.error) { diff --git a/ui/src/utils.ts b/ui/src/utils.ts index 3b077794..b3d0f368 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -51,11 +51,9 @@ import Tribute from 'tributejs/src/Tribute.js'; import markdown_it from 'markdown-it'; import markdownitEmoji from 'markdown-it-emoji/light'; import markdown_it_container from 'markdown-it-container'; -import twemoji from 'twemoji'; import emojiShortName from 'emoji-short-name'; import Toastify from 'toastify-js'; import tippy from 'tippy.js'; -import EmojiButton from '@joeattardi/emoji-button'; export const repoUrl = 'https://github.com/LemmyNet/lemmy'; export const helpGuideUrl = '/docs/about_guide.html'; @@ -114,14 +112,6 @@ export const themes = [ 'litely', ]; -export const emojiPicker = new EmojiButton({ - // Use the emojiShortName from native - style: 'twemoji', - theme: 'dark', - position: 'auto-start', - // TODO i18n -}); - const DEFAULT_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; @@ -178,10 +168,6 @@ export const md = new markdown_it({ defs: objectFlip(emojiShortName), }); -md.renderer.rules.emoji = function (token, idx) { - return twemoji.parse(token[idx].content); -}; - export function hotRankComment(comment: Comment): number { return hotRank(comment.score, comment.published); } @@ -590,8 +576,7 @@ export function setupTribute(): Tribute { trigger: ':', menuItemTemplate: (item: any) => { let shortName = `:${item.original.key}:`; - let twemojiIcon = twemoji.parse(item.original.val); - return `${twemojiIcon} ${shortName}`; + return `${item.original.val} ${shortName}`; }, selectTemplate: (item: any) => { return `:${item.original.key}:`; -- cgit v1.2.3