From 50a7d10f27e22c28714d0644008a59d98db784f7 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Wed, 6 Jul 2022 17:54:04 -0700 Subject: [PATCH 1/8] Enter sends message, ctrl/meta/shift + enter makes newline --- packages/client/src/pages/messaging/messaging-room.form.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/client/src/pages/messaging/messaging-room.form.vue b/packages/client/src/pages/messaging/messaging-room.form.vue index 38bab90502..2e008bf40e 100644 --- a/packages/client/src/pages/messaging/messaging-room.form.vue +++ b/packages/client/src/pages/messaging/messaging-room.form.vue @@ -125,7 +125,10 @@ function onDrop(ev: DragEvent): void { function onKeydown(ev: KeyboardEvent) { typing(); - if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey) && canSend) { + if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey || ev.shiftKey) && canSend) { + textEl.value += '\n' + } + else if (ev.key === 'Enter' && canSend) { send(); } } From 49c4d345f28919b7c8d30604616d08aa136957f6 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Wed, 6 Jul 2022 17:59:21 -0700 Subject: [PATCH 2/8] Don't need for shift key --- packages/client/src/pages/messaging/messaging-room.form.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/client/src/pages/messaging/messaging-room.form.vue b/packages/client/src/pages/messaging/messaging-room.form.vue index 2e008bf40e..b50d626bf0 100644 --- a/packages/client/src/pages/messaging/messaging-room.form.vue +++ b/packages/client/src/pages/messaging/messaging-room.form.vue @@ -125,10 +125,10 @@ function onDrop(ev: DragEvent): void { function onKeydown(ev: KeyboardEvent) { typing(); - if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey || ev.shiftKey) && canSend) { + if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey)) { textEl.value += '\n' } - else if (ev.key === 'Enter' && canSend) { + else if (ev.key === 'Enter' && !ev.shiftKey && canSend) { send(); } } From 033462653ca923932ad53530d32f1fc628d4175d Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Wed, 6 Jul 2022 18:14:05 -0700 Subject: [PATCH 3/8] Fix client lint --- packages/client/src/pages/messaging/messaging-room.form.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/pages/messaging/messaging-room.form.vue b/packages/client/src/pages/messaging/messaging-room.form.vue index b50d626bf0..f2657dfa8a 100644 --- a/packages/client/src/pages/messaging/messaging-room.form.vue +++ b/packages/client/src/pages/messaging/messaging-room.form.vue @@ -126,7 +126,7 @@ function onDrop(ev: DragEvent): void { function onKeydown(ev: KeyboardEvent) { typing(); if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey)) { - textEl.value += '\n' + textEl.value += '\n'; } else if (ev.key === 'Enter' && !ev.shiftKey && canSend) { send(); From e37dd8b93e87f61f02fe5878c89a5f04f8a8c938 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Wed, 6 Jul 2022 18:35:45 -0700 Subject: [PATCH 4/8] Disable enter for touchscreens --- packages/client/src/pages/messaging/messaging-room.form.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/pages/messaging/messaging-room.form.vue b/packages/client/src/pages/messaging/messaging-room.form.vue index f2657dfa8a..a6424a5fb4 100644 --- a/packages/client/src/pages/messaging/messaging-room.form.vue +++ b/packages/client/src/pages/messaging/messaging-room.form.vue @@ -128,7 +128,7 @@ function onKeydown(ev: KeyboardEvent) { if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey)) { textEl.value += '\n'; } - else if (ev.key === 'Enter' && !ev.shiftKey && canSend) { + else if (ev.key === 'Enter' && !ev.shiftKey && !('ontouchstart' in document.documentElement) && canSend) { send(); } } From 81d8c223ad52fc842587a9233598bd41a97ab5f6 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Wed, 6 Jul 2022 18:39:32 -0700 Subject: [PATCH 5/8] prevent default for good enter --- packages/client/src/pages/messaging/messaging-room.form.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/client/src/pages/messaging/messaging-room.form.vue b/packages/client/src/pages/messaging/messaging-room.form.vue index a6424a5fb4..0b609e0581 100644 --- a/packages/client/src/pages/messaging/messaging-room.form.vue +++ b/packages/client/src/pages/messaging/messaging-room.form.vue @@ -129,6 +129,7 @@ function onKeydown(ev: KeyboardEvent) { textEl.value += '\n'; } else if (ev.key === 'Enter' && !ev.shiftKey && !('ontouchstart' in document.documentElement) && canSend) { + ev.preventDefault(); send(); } } From fe95244f496482d746248ff3ee3957d28de67de9 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Fri, 8 Jul 2022 15:45:19 -0700 Subject: [PATCH 6/8] Make optional --- .../pages/messaging/messaging-room.form.vue | 19 ++++++++++++++----- .../client/src/pages/settings/general.vue | 3 +++ packages/client/src/store.ts | 4 ++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/client/src/pages/messaging/messaging-room.form.vue b/packages/client/src/pages/messaging/messaging-room.form.vue index 0b609e0581..f0d8c8666e 100644 --- a/packages/client/src/pages/messaging/messaging-room.form.vue +++ b/packages/client/src/pages/messaging/messaging-room.form.vue @@ -125,12 +125,21 @@ function onDrop(ev: DragEvent): void { function onKeydown(ev: KeyboardEvent) { typing(); - if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey)) { - textEl.value += '\n'; + let sendOnEnter = localStorage.getItem('enterSendsMessage') === 'true' || defaultStore.state.enterSendsMessage; + if (sendOnEnter) { + if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey)) { + textEl.value += '\n'; + } + else if (ev.key === 'Enter' && !ev.shiftKey && !('ontouchstart' in document.documentElement) && canSend) { + ev.preventDefault(); + send(); + } } - else if (ev.key === 'Enter' && !ev.shiftKey && !('ontouchstart' in document.documentElement) && canSend) { - ev.preventDefault(); - send(); + else { + if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey) && canSend) { + ev.preventDefault(); + send(); + } } } diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 74fa0bc926..9c3f6b3d53 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -27,6 +27,7 @@ {{ i18n.ts.openImageInNewTab }} {{ i18n.ts.enableInfiniteScroll }} {{ i18n.ts.useReactionPickerForContextMenu }} + {{ i18n.ts.enterSendsMessage }} {{ i18n.ts.disablePagesScript }} @@ -140,6 +141,7 @@ const showFixedPostForm = computed(defaultStore.makeGetterSetter('showFixedPostF const numberOfPageCache = computed(defaultStore.makeGetterSetter('numberOfPageCache')); const instanceTicker = computed(defaultStore.makeGetterSetter('instanceTicker')); const enableInfiniteScroll = computed(defaultStore.makeGetterSetter('enableInfiniteScroll')); +const enterSendsMessage = computed(defaultStore.makeGetterSetter('enterSendsMessage')); const useReactionPickerForContextMenu = computed(defaultStore.makeGetterSetter('useReactionPickerForContextMenu')); const squareAvatars = computed(defaultStore.makeGetterSetter('squareAvatars')); const aiChanMode = computed(defaultStore.makeGetterSetter('aiChanMode')); @@ -170,6 +172,7 @@ watch([ fontSize, useSystemFont, enableInfiniteScroll, + enterSendsMessage, squareAvatars, aiChanMode, showGapBetweenNotesInTimeline, diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index d87e05a4de..a3545c836c 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -251,6 +251,10 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: false, }, + enterSendsMessage: { + where: 'device', + default: false, + }, })); // TODO: 他のタブと永続化されたstateを同期 From 7b66ac609fd47f0a97f611247da1caf147feee66 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Fri, 8 Jul 2022 15:48:18 -0700 Subject: [PATCH 7/8] Add locale --- locales/ja-JP.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index de5826b21b..d127f0cd41 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -797,6 +797,7 @@ translatedFrom: "{x}から翻訳" accountDeletionInProgress: "アカウントの削除が進行中です" usernameInfo: "サーバー上であなたのアカウントを一意に識別するための名前。アルファベット(a~z, A~Z)、数字(0~9)、およびアンダーバー(_)が使用できます。ユーザー名は後から変更することは出来ません。" aiChanMode: "藍モード" +enterSendsMessage: "メッセージングでReturnキーを押すと、メッセージが送信されます(デフォルトはCtrl + Returnです)" keepCw: "CWを維持する" pubSub: "Pub/Subのアカウント" lastCommunication: "直近の通信" From 03b7f7d7f31777f14f4ae557f21b0bd14633f07e Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Fri, 8 Jul 2022 16:09:18 -0700 Subject: [PATCH 8/8] Remove from watch --- packages/client/src/pages/settings/general.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 9c3f6b3d53..46daa143fc 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -172,7 +172,6 @@ watch([ fontSize, useSystemFont, enableInfiniteScroll, - enterSendsMessage, squareAvatars, aiChanMode, showGapBetweenNotesInTimeline,