From: Dessalines Date: Sun, 12 Apr 2020 16:47:48 +0000 (-0400) Subject: Add Emoji squashed commit. X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%24%7B%60data:application/static/%7B%60https:/%7BmarkdownHelpUrl%7D?a=commitdiff_plain;h=d6d040f5da2317af19b3df426556914d1b2a14fe;p=lemmy.git Add Emoji squashed commit. --- diff --git a/ui/assets/css/main.css b/ui/assets/css/main.css index 1c8206e3..bf249e5b 100644 --- a/ui/assets/css/main.css +++ b/ui/assets/css/main.css @@ -156,7 +156,7 @@ hr { } .emoji { - height: 1.2em !important; + max-height: 1.2em !important; } .text-wrap-truncate { diff --git a/ui/package.json b/ui/package.json index 7d946614..25ee2e00 100644 --- a/ui/package.json +++ b/ui/package.json @@ -14,6 +14,7 @@ }, "keywords": [], "dependencies": { + "@joeattardi/emoji-button": "^2.12.1", "@types/autosize": "^3.0.6", "@types/js-cookie": "^2.2.5", "@types/jwt-decode": "^2.2.1", diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index ae3e7cfc..6898ebc7 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -17,10 +17,12 @@ import { toast, setupTribute, wsJsonToRes, + emojiPicker, } from '../utils'; import { WebSocketService, UserService } from '../services'; import autosize from 'autosize'; import Tribute from 'tributejs/src/Tribute.js'; +import emojiShortName from 'emoji-short-name'; import { i18n } from '../i18next'; interface CommentFormProps { @@ -69,6 +71,8 @@ export class CommentForm extends Component { super(props, context); this.tribute = setupTribute(); + this.setupEmojiPicker(); + this.state = this.emptyState; if (this.props.node) { @@ -209,6 +213,15 @@ export class CommentForm extends Component { )} + + + + + @@ -216,6 +229,17 @@ export class CommentForm extends Component { ); } + setupEmojiPicker() { + emojiPicker.on('emoji', emoji => { + if (this.state.commentForm.content == null) { + this.state.commentForm.content = ''; + } + let shortName = `:${emojiShortName[emoji]}:`; + this.state.commentForm.content += shortName; + this.setState(this.state); + }); + } + handleFinished() { this.state.previewMode = false; this.state.loading = false; @@ -242,6 +266,10 @@ 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 47920b9b..a65ead46 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -34,9 +34,11 @@ import { randomStr, setupTribute, setupTippy, + emojiPicker, } from '../utils'; import autosize from 'autosize'; import Tribute from 'tributejs/src/Tribute.js'; +import emojiShortName from 'emoji-short-name'; import Selectr from 'mobius1-selectr'; import { i18n } from '../i18next'; @@ -92,6 +94,8 @@ export class PostForm extends Component { this.fetchPageTitle = debounce(this.fetchPageTitle).bind(this); this.tribute = setupTribute(); + this.setupEmojiPicker(); + this.state = this.emptyState; if (this.props.post) { @@ -191,7 +195,7 @@ export class PostForm extends Component {