From fdef990c6a5deccf7cc8cddbe1467c6e62d8f674 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Tue, 26 May 2020 22:22:36 +0300 Subject: [PATCH] Submit on enter, start a new line on shift+enter --- src/components/chat/chat.scss | 4 ++++ src/components/chat/chat.vue | 2 +- src/components/emoji_input/emoji_input.js | 5 +++++ .../post_status_form/post_status_form.js | 16 +++++++++++++--- .../post_status_form/post_status_form.vue | 8 +++++--- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/components/chat/chat.scss b/src/components/chat/chat.scss index 25727d7e..84e44e0b 100644 --- a/src/components/chat/chat.scss +++ b/src/components/chat/chat.scss @@ -106,6 +106,10 @@ position: -webkit-sticky; position: sticky; bottom: 0px; + + textarea { + outline: none + } } } } diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue index dd8be63b..bf005216 100644 --- a/src/components/chat/chat.vue +++ b/src/components/chat/chat.vue @@ -66,8 +66,8 @@ :disable-notice="true" :disable-polls="true" :poster="poster" + :submit-on-enter="!isMobileLayout" :preserve-focus="!isMobileLayout" - :polls-available="false" :auto-focus="!isMobileLayout" :placeholder="formPlaceholder" :file-limit="1" diff --git a/src/components/emoji_input/emoji_input.js b/src/components/emoji_input/emoji_input.js index f4c3479c..6a77815d 100644 --- a/src/components/emoji_input/emoji_input.js +++ b/src/components/emoji_input/emoji_input.js @@ -162,6 +162,11 @@ const EmojiInput = { input.elm.removeEventListener('input', this.onInput) } }, + watch: { + showSuggestions: function (newValue) { + this.$emit('shown', newValue) + } + }, methods: { triggerShowPicker () { this.showPicker = true diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 739e36a7..dd9f71d0 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -41,7 +41,8 @@ const PostStatusForm = { 'poster', 'preserveFocus', 'autoFocus', - 'fileLimit' + 'fileLimit', + 'submitOnEnter' ], components: { MediaUpload, @@ -92,7 +93,8 @@ const PostStatusForm = { contentType }, caret: 0, - pollFormVisible: false + pollFormVisible: false, + emojiInputShown: false } }, computed: { @@ -175,9 +177,14 @@ const PostStatusForm = { ...mapGetters(['mergedConfig']) }, methods: { - postStatus (newStatus) { + postStatus (newStatus, opts = {}) { if (this.posting) { return } if (this.submitDisabled) { return } + if (this.emojiInputShown) { return } + if (opts.control && this.submitOnEnter) { + newStatus.status = `${newStatus.status}\n` + return + } if (this.newStatus.status === '') { if (this.newStatus.files.length === 0) { @@ -405,6 +412,9 @@ const PostStatusForm = { }, dismissScopeNotice () { this.$store.dispatch('setOption', { name: 'hideScopeNotice', value: true }) + }, + handleEmojiInputShow (value) { + this.emojiInputShown = value } } } diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index f1400b2d..53f745bd 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -86,6 +86,7 @@ @input="onEmojiInputInput" @sticker-uploaded="addMediaFile" @sticker-upload-failed="uploadFailed" + @shown="handleEmojiInputShow" >