Submit on enter, start a new line on shift+enter
This commit is contained in:
parent
5fc9ef0bfb
commit
fdef990c6a
5 changed files with 28 additions and 7 deletions
|
@ -106,6 +106,10 @@
|
|||
position: -webkit-sticky;
|
||||
position: sticky;
|
||||
bottom: 0px;
|
||||
|
||||
textarea {
|
||||
outline: none
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
@input="onEmojiInputInput"
|
||||
@sticker-uploaded="addMediaFile"
|
||||
@sticker-upload-failed="uploadFailed"
|
||||
@shown="handleEmojiInputShow"
|
||||
>
|
||||
<textarea
|
||||
ref="textarea"
|
||||
|
@ -95,7 +96,8 @@
|
|||
:disabled="posting"
|
||||
class="form-post-body"
|
||||
:class="{ 'scrollable-form': !!maxHeight }"
|
||||
@keydown.meta.enter="postStatus(newStatus)"
|
||||
@keydown.exact.stop.prevent.enter="submitOnEnter && postStatus(newStatus)"
|
||||
@keydown.meta.enter="postStatus(newStatus, { control: true })"
|
||||
@keyup.ctrl.enter="postStatus(newStatus)"
|
||||
@drop="fileDrop"
|
||||
@dragover.prevent="fileDrag"
|
||||
|
@ -214,10 +216,10 @@
|
|||
</button>
|
||||
<button
|
||||
v-else
|
||||
@touchstart.stop.prevent="postStatus(newStatus)"
|
||||
@mousedown.stop.prevent="postStatus(newStatus)"
|
||||
:disabled="submitDisabled"
|
||||
class="btn btn-default"
|
||||
@touchstart.stop.prevent="postStatus(newStatus)"
|
||||
@mousedown.stop.prevent="postStatus(newStatus)"
|
||||
>
|
||||
{{ $t('general.submit') }}
|
||||
</button>
|
||||
|
|
Loading…
Reference in a new issue