diff --git a/src/App.vue b/src/App.vue index d628715..80087d8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,6 +3,7 @@ import interact from 'interactjs'; import FloatingVue from 'floating-vue'; import 'floating-vue/dist/style.css'; import { Mentionable } from 'vue-mention'; +import EmojiPicker from 'vue3-emoji-picker'; import LoginModal from './components/LoginModal.vue'; import ExplicitOpenModal from './components/ExplicitOpenModal.vue'; @@ -36,9 +37,12 @@ const FileUploadMaxSize = 1024 * 1024 * 8; // 8 MB export default { name: 'BareRTC', components: { + // Third party components FloatingVue, Mentionable, + EmojiPicker, + // My components LoginModal, ExplicitOpenModal, ReportModal, @@ -108,6 +112,9 @@ export default { typingNotifDebounce: null, status: "online", // away/idle status + // Emoji picker visible for messages + showEmojiPicker: false, + // Idle detection variables idleTimeout: null, idleThreshold: 300, // number of seconds you must be idle @@ -740,6 +747,21 @@ export default { * Chat API Methods (WebSocket packets sent/received) */ + onSelectEmoji(e) { + // Callback from EmojiPicker to add an emoji to the user textbox. + let selectionStart = this.messageBox.selectionStart; + this.message = this.message.slice(0, selectionStart) + e.i + this.message.slice(selectionStart); + this.hideEmojiPicker(); + }, + hideEmojiPicker() { + // Hide the emoji menu (after sending an emoji or clicking the react button again) + if (!this.showEmojiPicker) return; + window.requestAnimationFrame(() => { + this.showEmojiPicker = false; + this.messageBox.focus(); + this.messageBox.selectionStart = this.messageBox.selectionEnd = this.messageBox.value.length; + }); + }, sendMessage() { if (!this.message) { return; @@ -3664,7 +3686,7 @@ export default { offset="12" insert-space> - + @@ -3687,6 +3709,31 @@ export default { +