feat(client): Add option to press enter to send

This commit is contained in:
NoriDev 2022-09-07 14:49:54 +09:00
parent d5a43f6338
commit 6c4e27d217
9 changed files with 31 additions and 3 deletions

View file

@ -13,6 +13,7 @@
### Improvements
- 클라이언트: Google Translate 서비스 추가 (thanks lapy)
- 클라이언트: DeepL과 Google Translate를 선택할 수 있는 옵션 추가
- 클라이언트: Enter 키를 눌러 보내기 옵션 추가
## 12.x.x-cp-2.x.x (unreleased)_legacy

View file

@ -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}"

View file

@ -1,5 +1,7 @@
_lang_: "日本語"
useEnterToSend: "Enterキーを押して送信"
useEnterToSendDescription: "オプションを有効にすると、行替えはShiftEnterキーでできます。"
headlineMisskey: "ノートでつながるネットワーク"
introMisskey: "ようこそMisskeyは、オープンソースの分散型マイクロブログサービスです。\n「ート」を作成して、いま起こっていることを共有したり、あなたについて皆に発信しよう📡\n「リアクション」機能で、皆のートに素早く反応を追加することもできます👍\n新しい世界を探検しよう🚀"
monthAndDay: "{month}月 {day}日"

View file

@ -1,5 +1,7 @@
---
_lang_: "한국어"
useEnterToSend: "Enter 키를 눌러 보내기"
useEnterToSendDescription: "옵션을 활성화하면 줄 바꿈은 Shift + Enter 키로 할 수 있어요."
headlineMisskey: "노트로 연결되는 네트워크"
introMisskey: "어서오세요! CherryPick은 오픈 소스 분산형 마이크로 블로그 서비스에요.\n\"노트\" 를 작성해서, 지금 일어나고 있는 일을 공유하거나, 당신만의 이야기를 모두에게 발신할 수 있어요📡\n\"리액션\" 기능으로, 친구의 노트에 총알같이 반응을 추가할 수도 있어요👍\n새로운 세계를 탐험해 보세요🚀"
monthAndDay: "{month}월 {day}일"

View file

@ -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();
}

View file

@ -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();
}
}
}

View file

@ -28,6 +28,10 @@
<FormSwitch v-model="enableInfiniteScroll" class="_formBlock">{{ i18n.ts.enableInfiniteScroll }}</FormSwitch>
<FormSwitch v-model="useReactionPickerForContextMenu" class="_formBlock">{{ i18n.ts.useReactionPickerForContextMenu }}</FormSwitch>
<FormSwitch v-model="disablePagesScript" class="_formBlock">{{ i18n.ts.disablePagesScript }}</FormSwitch>
<FormSwitch v-model="useEnterToSend" class="_formBlock">
<template #label>{{ i18n.ts.useEnterToSend }}</template>
<template #caption>{{ i18n.ts.useEnterToSendDescription }}</template>
</FormSwitch>
<FormSelect v-model="serverDisconnectedBehavior" class="_formBlock">
<template #label>{{ i18n.ts.whenServerDisconnected }}</template>
@ -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);

View file

@ -82,6 +82,7 @@ const defaultStoreSaveKeys: (keyof typeof defaultStore['state'])[] = [
'squareAvatars',
'numberOfPageCache',
'aiChanMode',
'useEnterToSend',
];
const coldDeviceStorageSaveKeys: (keyof typeof ColdDeviceStorage.default)[] = [
'lightTheme',

View file

@ -251,6 +251,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: false,
},
useEnterToSend: {
where: 'device',
default: false,
},
}));
// TODO: 他のタブと永続化されたstateを同期