forked from Mirrors/gomuks
web/composer: add preference for using ctrl+enter to send
This commit is contained in:
parent
c038b517c6
commit
0ebfc15ad7
2 changed files with 10 additions and 1 deletions
|
@ -141,6 +141,12 @@ export const preferences = {
|
||||||
allowedContexts: anyContext,
|
allowedContexts: anyContext,
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
}),
|
}),
|
||||||
|
ctrl_enter_send: new Preference<boolean>({
|
||||||
|
displayName: "Use Ctrl+Enter to send",
|
||||||
|
description: "Disable sending on enter and use Ctrl+Enter for sending instead",
|
||||||
|
allowedContexts: anyContext,
|
||||||
|
defaultValue: false,
|
||||||
|
}),
|
||||||
custom_notification_sound: new Preference<ContentURI>({
|
custom_notification_sound: new Preference<ContentURI>({
|
||||||
displayName: "Custom notification sound",
|
displayName: "Custom notification sound",
|
||||||
description: "The mxc:// URI to a custom notification sound.",
|
description: "The mxc:// URI to a custom notification sound.",
|
||||||
|
|
|
@ -274,7 +274,10 @@ const MessageComposer = () => {
|
||||||
const onComposerKeyDown = useEvent((evt: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
const onComposerKeyDown = useEvent((evt: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||||
const inp = evt.currentTarget
|
const inp = evt.currentTarget
|
||||||
const fullKey = keyToString(evt)
|
const fullKey = keyToString(evt)
|
||||||
if (fullKey === "Enter" && (
|
const sendKey = fullKey === "Enter" || fullKey === "Ctrl+Enter"
|
||||||
|
? (room.preferences.ctrl_enter_send ? "Ctrl+Enter" : "Enter")
|
||||||
|
: null
|
||||||
|
if (fullKey === sendKey && (
|
||||||
// If the autocomplete already has a selected item or has no results, send message even if it's open.
|
// If the autocomplete already has a selected item or has no results, send message even if it's open.
|
||||||
// Otherwise, don't send message on enter, select the first autocomplete entry instead.
|
// Otherwise, don't send message on enter, select the first autocomplete entry instead.
|
||||||
!autocomplete
|
!autocomplete
|
||||||
|
|
Loading…
Add table
Reference in a new issue