diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 1124456e5ff..f62e8483f8d 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -26,6 +26,7 @@ namespace OCA\Talk\Controller; use OCA\Files_Sharing\SharedStorage; +use OCA\Talk\Participant; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; @@ -79,7 +80,10 @@ public function setUserSetting(string $key, ?string $value): DataResponse { } protected function validateUserSetting(string $setting, ?string $value): bool { - if ($setting === 'attachment_folder') { + if ($setting === 'send_message_key') { + return $value === Participant::SEND_MESSAGE_KEY_ENTER + || $value === Participant::SEND_MESSAGE_KEY_SHIFT_ENTER; + } elseif ($setting === 'attachment_folder') { $userFolder = $this->rootFolder->getUserFolder($this->userId); try { $node = $userFolder->get($value); diff --git a/lib/Participant.php b/lib/Participant.php index a8ea6c7d9e4..009749e41b7 100644 --- a/lib/Participant.php +++ b/lib/Participant.php @@ -47,6 +47,9 @@ class Participant { public const NOTIFY_MENTION = 2; public const NOTIFY_NEVER = 3; + public const SEND_MESSAGE_KEY_ENTER = 'enter'; + public const SEND_MESSAGE_KEY_SHIFT_ENTER = 'shift_enter'; + /** @var IDBConnection */ protected $db; /** @var IConfig */ diff --git a/lib/TInitialState.php b/lib/TInitialState.php index c918befe3fa..cd763e26d05 100644 --- a/lib/TInitialState.php +++ b/lib/TInitialState.php @@ -82,6 +82,13 @@ protected function publishInitialStateForUser(IUser $user, IRootFolder $rootFold $appManager->isEnabledForUser('circles', $user) ); + $this->initialStateService->provideInitialState( + 'talk', 'send_message_key', + $this->serverConfig->getUserValue( + $user->getUID(), 'spreed', 'send_message_key', Participant::SEND_MESSAGE_KEY_ENTER + ) + ); + $attachmentFolder = $this->talkConfig->getAttachmentFolder($user->getUID()); if ($attachmentFolder) { @@ -127,6 +134,10 @@ protected function publishInitialStateForGuest(): void { '' ); + $this->initialStateService->provideInitialState( + 'talk', 'send_message_key', Participant::SEND_MESSAGE_KEY_ENTER + ); + $this->initialStateService->provideInitialState( 'talk', 'enable_matterbridge', false diff --git a/src/components/NewMessageForm/AdvancedInput/AdvancedInput.vue b/src/components/NewMessageForm/AdvancedInput/AdvancedInput.vue index aef9ac933f8..c536ebf9690 100644 --- a/src/components/NewMessageForm/AdvancedInput/AdvancedInput.vue +++ b/src/components/NewMessageForm/AdvancedInput/AdvancedInput.vue @@ -198,6 +198,14 @@ export default { type: String, required: true, }, + + /** + * Whether to use the shift-enter key to submitting instead of enter + */ + submitWithShiftEnter: { + type: Boolean, + default: false, + }, }, data: function() { return { @@ -303,7 +311,7 @@ export default { } // TODO: add support for CTRL+ENTER new line - if (!(event.shiftKey)) { + if (event.shiftKey === this.submitWithShiftEnter) { event.preventDefault() this.$emit('submit', event) } diff --git a/src/components/NewMessageForm/NewMessageForm.vue b/src/components/NewMessageForm/NewMessageForm.vue index ca4ba11bfcf..a50519ae01b 100644 --- a/src/components/NewMessageForm/NewMessageForm.vue +++ b/src/components/NewMessageForm/NewMessageForm.vue @@ -80,6 +80,7 @@ ref="advancedInput" v-model="text" :token="token" + :submit-with-shift-enter="submitWithShiftEnter" @update:contentEditable="contentEditableToParsed" @submit="handleSubmit" @files-pasted="handleFiles" /> @@ -104,7 +105,7 @@ import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' import EmojiPicker from '@nextcloud/vue/dist/Components/EmojiPicker' import { shareFile } from '../../services/filesSharingServices' import { processFiles } from '../../utils/fileUpload' -import { CONVERSATION } from '../../constants' +import { CONVERSATION, SEND_MESSAGE_KEY } from '../../constants' import createTemporaryMessage from '../../utils/temporaryMessage' import EmoticonOutline from 'vue-material-design-icons/EmoticonOutline' @@ -142,6 +143,10 @@ export default { return this.$store.getters.getToken() }, + submitWithShiftEnter() { + return this.$store.getters.getSendMessageKey() === SEND_MESSAGE_KEY.SHIFT_ENTER + }, + conversation() { return this.$store.getters.conversation(this.token) || { readOnly: CONVERSATION.STATE.READ_WRITE, @@ -159,10 +164,6 @@ export default { canShareAndUploadFiles() { return !this.currentUserIsGuest && this.conversation.readOnly === CONVERSATION.STATE.READ_WRITE }, - - attachmentFolder() { - return this.$store.getters.getAttachmentFolder() - }, }, watch: { @@ -202,7 +203,26 @@ export default { * @returns {String} the parsed text */ rawToParsed(text) { + // first div doesn't count + text = text.replace(/^
{{ t('spreed', 'Speed up your Talk experience with these quick shortcuts.') }}
+