send status on ctrl+enter (#81)
* send status on ctrl+enter (#24) * don't check for floating post button when pressing ctrl+enter oops, I was too eager. it doesn't matter too much, except that if the main compose form is off-screen but still focused, ctrl+enter would open the compose modal instead of posting
This commit is contained in:
parent
a150613b53
commit
8e08d08712
|
@ -9,7 +9,7 @@
|
||||||
<ComposeContentWarning :realm :contentWarning />
|
<ComposeContentWarning :realm :contentWarning />
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<ComposeInput :realm :text :autoFocus />
|
<ComposeInput :realm :text :autoFocus on:postAction="onPostAction()" />
|
||||||
<ComposeLengthGauge :length :overLimit />
|
<ComposeLengthGauge :length :overLimit />
|
||||||
<ComposeToolbar :realm :postPrivacy :media :contentWarningShown :text />
|
<ComposeToolbar :realm :postPrivacy :media :contentWarningShown :text />
|
||||||
<ComposeLengthIndicator :length :overLimit />
|
<ComposeLengthIndicator :length :overLimit />
|
||||||
|
@ -188,6 +188,10 @@
|
||||||
dialogs.showComposeDialog()
|
dialogs.showComposeDialog()
|
||||||
} else {
|
} else {
|
||||||
// else we're actually posting a new toot
|
// else we're actually posting a new toot
|
||||||
|
this.onPostAction();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onPostAction() {
|
||||||
let text = this.get('text')
|
let text = this.get('text')
|
||||||
let media = this.get('media')
|
let media = this.get('media')
|
||||||
let postPrivacyKey = this.get('postPrivacyKey')
|
let postPrivacyKey = this.get('postPrivacyKey')
|
||||||
|
@ -206,7 +210,6 @@
|
||||||
/* no await */
|
/* no await */
|
||||||
postStatus(realm, text, inReplyTo, mediaIds,
|
postStatus(realm, text, inReplyTo, mediaIds,
|
||||||
sensitive, contentWarning, postPrivacyKey, mediaDescriptions)
|
sensitive, contentWarning, postPrivacyKey, mediaDescriptions)
|
||||||
}
|
|
||||||
},
|
},
|
||||||
setupStickyObserver() {
|
setupStickyObserver() {
|
||||||
this.__stickyObserver = new IntersectionObserver(entries => {
|
this.__stickyObserver = new IntersectionObserver(entries => {
|
||||||
|
|
|
@ -101,11 +101,18 @@
|
||||||
},
|
},
|
||||||
onKeydown(e) {
|
onKeydown(e) {
|
||||||
let { keyCode } = e
|
let { keyCode } = e
|
||||||
|
const ctrlPressed =
|
||||||
|
e.getModifierState('Control') || e.getModifierState('Meta')
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case 9: // tab
|
case 9: // tab
|
||||||
case 13: //enter
|
|
||||||
this.clickSelectedAutosuggestion(e)
|
this.clickSelectedAutosuggestion(e)
|
||||||
break
|
break
|
||||||
|
case 13: //enter
|
||||||
|
const autosuggestionClicked = this.clickSelectedAutosuggestion(e)
|
||||||
|
if (!autosuggestionClicked && ctrlPressed) {
|
||||||
|
this.fire('postAction')
|
||||||
|
}
|
||||||
|
break
|
||||||
case 38: // up
|
case 38: // up
|
||||||
this.incrementAutosuggestSelected(-1, e)
|
this.incrementAutosuggestSelected(-1, e)
|
||||||
break
|
break
|
||||||
|
@ -121,7 +128,7 @@
|
||||||
clickSelectedAutosuggestion(event) {
|
clickSelectedAutosuggestion(event) {
|
||||||
let autosuggestionShown = this.store.get('composeAutosuggestionShown')
|
let autosuggestionShown = this.store.get('composeAutosuggestionShown')
|
||||||
if (!autosuggestionShown) {
|
if (!autosuggestionShown) {
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
let type = this.store.get('composeAutosuggestionType')
|
let type = this.store.get('composeAutosuggestionType')
|
||||||
if (type === 'account') {
|
if (type === 'account') {
|
||||||
|
@ -131,6 +138,7 @@
|
||||||
}
|
}
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
return true
|
||||||
},
|
},
|
||||||
incrementAutosuggestSelected(increment, event) {
|
incrementAutosuggestSelected(increment, event) {
|
||||||
let autosuggestionShown = this.store.get('composeAutosuggestionShown')
|
let autosuggestionShown = this.store.get('composeAutosuggestionShown')
|
||||||
|
|
Loading…
Reference in a new issue