From 6c4e27d2174c38c1b7af48a7fa629c25aae5fa88 Mon Sep 17 00:00:00 2001 From: NoriDev Date: Wed, 7 Sep 2022 14:49:54 +0900 Subject: [PATCH] feat(client): Add option to press enter to send --- CHANGELOG_CHERRYPICK.md | 1 + locales/en-US.yml | 2 ++ locales/ja-JP.yml | 2 ++ locales/ko-KR.yml | 2 ++ packages/client/src/components/post-form.vue | 7 ++++++- .../client/src/pages/messaging/messaging-room.form.vue | 10 ++++++++-- packages/client/src/pages/settings/general.vue | 5 +++++ .../client/src/pages/settings/preferences-backups.vue | 1 + packages/client/src/store.ts | 4 ++++ 9 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CHANGELOG_CHERRYPICK.md b/CHANGELOG_CHERRYPICK.md index 1932c2b706..00bd408261 100644 --- a/CHANGELOG_CHERRYPICK.md +++ b/CHANGELOG_CHERRYPICK.md @@ -13,6 +13,7 @@ ### Improvements - 클라이언트: Google Translate 서비스 추가 (thanks lapy) - 클라이언트: DeepL과 Google Translate를 선택할 수 있는 옵션 추가 +- 클라이언트: Enter 키를 눌러 보내기 옵션 추가 ## 12.x.x-cp-2.x.x (unreleased)_legacy diff --git a/locales/en-US.yml b/locales/en-US.yml index 3b04b401dd..1133cf6901 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1,5 +1,7 @@ --- _lang_: "English" +useEnterToSend: "Press Enter to send" +useEnterToSendDescription: "When the option is enabled, you can use the Shift+Enter key for line break." headlineMisskey: "A network connected by notes" introMisskey: "Welcome! Misskey is an open source, decentralized microblogging service.\nCreate \"notes\" to share your thoughts with everyone around you. 📡\nWith \"reactions\", you can also quickly express your feelings about everyone's notes. 👍\nLet's explore a new world! 🚀" monthAndDay: "{month}/{day}" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index b10cce9231..1a256ef4c7 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1,5 +1,7 @@ _lang_: "日本語" +useEnterToSend: "Enterキーを押して送信" +useEnterToSendDescription: "オプションを有効にすると、行替えはShift+Enterキーでできます。" headlineMisskey: "ノートでつながるネットワーク" introMisskey: "ようこそ!Misskeyは、オープンソースの分散型マイクロブログサービスです。\n「ノート」を作成して、いま起こっていることを共有したり、あなたについて皆に発信しよう📡\n「リアクション」機能で、皆のノートに素早く反応を追加することもできます👍\n新しい世界を探検しよう🚀" monthAndDay: "{month}月 {day}日" diff --git a/locales/ko-KR.yml b/locales/ko-KR.yml index feaf1984ca..7598c5e7fa 100644 --- a/locales/ko-KR.yml +++ b/locales/ko-KR.yml @@ -1,5 +1,7 @@ --- _lang_: "한국어" +useEnterToSend: "Enter 키를 눌러 보내기" +useEnterToSendDescription: "옵션을 활성화하면 줄 바꿈은 Shift + Enter 키로 할 수 있어요." headlineMisskey: "노트로 연결되는 네트워크" introMisskey: "어서오세요! CherryPick은 오픈 소스 분산형 마이크로 블로그 서비스에요.\n\"노트\" 를 작성해서, 지금 일어나고 있는 일을 공유하거나, 당신만의 이야기를 모두에게 발신할 수 있어요📡\n\"리액션\" 기능으로, 친구의 노트에 총알같이 반응을 추가할 수도 있어요👍\n새로운 세계를 탐험해 보세요🚀" monthAndDay: "{month}월 {day}일" diff --git a/packages/client/src/components/post-form.vue b/packages/client/src/components/post-form.vue index 217df8ad7b..c7d329228c 100644 --- a/packages/client/src/components/post-form.vue +++ b/packages/client/src/components/post-form.vue @@ -430,7 +430,12 @@ function clear() { } function onKeydown(ev: KeyboardEvent) { - if ((ev.which === 10 || ev.which === 13) && (ev.ctrlKey || ev.metaKey) && canPost) post(); + if (defaultStore.state.useEnterToSend && !ev.shiftKey) { + if ((ev.which === 10 || ev.which === 13) && canPost) post(); + } else { + if ((ev.which === 10 || ev.which === 13) && (ev.ctrlKey || ev.metaKey) && canPost) post(); + } + if (ev.which === 27) emit('esc'); typing(); } diff --git a/packages/client/src/pages/messaging/messaging-room.form.vue b/packages/client/src/pages/messaging/messaging-room.form.vue index 38bab90502..20e97a580f 100644 --- a/packages/client/src/pages/messaging/messaging-room.form.vue +++ b/packages/client/src/pages/messaging/messaging-room.form.vue @@ -125,8 +125,14 @@ function onDrop(ev: DragEvent): void { function onKeydown(ev: KeyboardEvent) { typing(); - if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey) && canSend) { - send(); + if (defaultStore.state.useEnterToSend && !ev.shiftKey) { + if ((ev.key === 'Enter') && canSend) { + send(); + } + } else { + if ((ev.key === 'Enter') && (ev.ctrlKey || ev.metaKey) && canSend) { + send(); + } } } diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 6ce7f26d53..4e04c8be81 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -28,6 +28,10 @@ {{ i18n.ts.enableInfiniteScroll }} {{ i18n.ts.useReactionPickerForContextMenu }} {{ i18n.ts.disablePagesScript }} + + + + @@ -145,6 +149,7 @@ const enableInfiniteScroll = computed(defaultStore.makeGetterSetter('enableInfin const useReactionPickerForContextMenu = computed(defaultStore.makeGetterSetter('useReactionPickerForContextMenu')); const squareAvatars = computed(defaultStore.makeGetterSetter('squareAvatars')); const aiChanMode = computed(defaultStore.makeGetterSetter('aiChanMode')); +const useEnterToSend = computed(defaultStore.makeGetterSetter('useEnterToSend')); watch(lang, () => { localStorage.setItem('lang', lang.value as string); diff --git a/packages/client/src/pages/settings/preferences-backups.vue b/packages/client/src/pages/settings/preferences-backups.vue index 991bb7902d..aa08e09840 100644 --- a/packages/client/src/pages/settings/preferences-backups.vue +++ b/packages/client/src/pages/settings/preferences-backups.vue @@ -82,6 +82,7 @@ const defaultStoreSaveKeys: (keyof typeof defaultStore['state'])[] = [ 'squareAvatars', 'numberOfPageCache', 'aiChanMode', + 'useEnterToSend', ]; const coldDeviceStorageSaveKeys: (keyof typeof ColdDeviceStorage.default)[] = [ 'lightTheme', diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index bedce53a14..2b668b84f2 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, }, + useEnterToSend: { + where: 'device', + default: false, + }, })); // TODO: 他のタブと永続化されたstateを同期