feat: Add "Enter to send" option on format mode (#1671)
This commit is contained in:
parent
2ff0af3c8d
commit
12491fa8d5
5 changed files with 78 additions and 15 deletions
|
@ -9,16 +9,15 @@
|
||||||
|
|
||||||
.reply-box__top {
|
.reply-box__top {
|
||||||
.canned {
|
.canned {
|
||||||
@include elegant-card;
|
background: var(--white);
|
||||||
background: $color-white;
|
border-bottom: var(--space-small) solid var(--white);
|
||||||
border-bottom: $space-small solid $color-white;
|
border-top: 1px solid var(--color-border);
|
||||||
border-top: $space-small solid $color-white;
|
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|
||||||
max-height: 14rem;
|
max-height: 14rem;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
padding-top: var(--space-small);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 24rem;
|
width: 100%;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
|
||||||
.active a {
|
.active a {
|
||||||
|
|
|
@ -31,6 +31,17 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="right-wrap">
|
<div class="right-wrap">
|
||||||
|
<div v-if="isFormatMode" class="enter-to-send--checkbox">
|
||||||
|
<input
|
||||||
|
:checked="enterToSendEnabled"
|
||||||
|
type="checkbox"
|
||||||
|
value="enterToSend"
|
||||||
|
@input="toggleEnterToSend"
|
||||||
|
/>
|
||||||
|
<label for="enterToSend">
|
||||||
|
{{ $t('CONVERSATION.REPLYBOX.ENTER_TO_SEND') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<button
|
<button
|
||||||
class="button nice primary button--send"
|
class="button nice primary button--send"
|
||||||
:class="buttonClass"
|
:class="buttonClass"
|
||||||
|
@ -95,6 +106,10 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
enterToSendEnabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isNote() {
|
isNote() {
|
||||||
|
@ -119,6 +134,9 @@ export default {
|
||||||
toggleFormatMode() {
|
toggleFormatMode() {
|
||||||
this.setFormatMode(!this.isFormatMode);
|
this.setFormatMode(!this.isFormatMode);
|
||||||
},
|
},
|
||||||
|
toggleEnterToSend() {
|
||||||
|
this.$emit('toggleEnterToSend', !this.enterToSendEnabled);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -173,8 +191,8 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-wrap {
|
.left-wrap {
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button--reply {
|
.button--reply {
|
||||||
|
@ -185,4 +203,21 @@ export default {
|
||||||
color: var(--s-600);
|
color: var(--s-600);
|
||||||
font-size: var(--font-size-default);
|
font-size: var(--font-size-default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.right-wrap {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.enter-to-send--checkbox {
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
input {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
color: var(--s-500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -35,6 +35,13 @@ export default {
|
||||||
cannedMessages: 'getCannedResponses',
|
cannedMessages: 'getCannedResponses',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
cannedMessages(newCannedMessages) {
|
||||||
|
if (newCannedMessages.length < this.selectedIndex + 1) {
|
||||||
|
this.selectedIndex = 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
document.addEventListener('keydown', this.keyListener);
|
document.addEventListener('keydown', this.keyListener);
|
||||||
},
|
},
|
||||||
|
@ -44,7 +51,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
getTopPadding() {
|
getTopPadding() {
|
||||||
if (this.cannedMessages.length <= 4) {
|
if (this.cannedMessages.length <= 4) {
|
||||||
return -this.cannedMessages.length * 3.5;
|
return -(this.cannedMessages.length * 2.8 + 1.7);
|
||||||
}
|
}
|
||||||
return -14;
|
return -14;
|
||||||
},
|
},
|
||||||
|
@ -75,7 +82,7 @@ export default {
|
||||||
if (this.isEnter(e)) {
|
if (this.isEnter(e)) {
|
||||||
this.onKeyenter(this.cannedMessages[this.selectedIndex].content);
|
this.onKeyenter(this.cannedMessages[this.selectedIndex].content);
|
||||||
}
|
}
|
||||||
this.$el.scrollTop = 34 * this.selectedIndex;
|
this.$el.scrollTop = 28 * this.selectedIndex;
|
||||||
},
|
},
|
||||||
onHover(index) {
|
onHover(index) {
|
||||||
this.selectedIndex = index;
|
this.selectedIndex = index;
|
||||||
|
|
|
@ -61,6 +61,8 @@
|
||||||
:set-format-mode="setFormatMode"
|
:set-format-mode="setFormatMode"
|
||||||
:is-format-mode="isFormatMode"
|
:is-format-mode="isFormatMode"
|
||||||
:enable-rich-editor="isRichEditorEnabled"
|
:enable-rich-editor="isRichEditorEnabled"
|
||||||
|
:enter-to-send-enabled="enterToSendEnabled"
|
||||||
|
@toggleEnterToSend="toggleEnterToSend"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -115,7 +117,13 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({ currentChat: 'getSelectedChat' }),
|
...mapGetters({
|
||||||
|
currentChat: 'getSelectedChat',
|
||||||
|
uiSettings: 'getUISettings',
|
||||||
|
}),
|
||||||
|
enterToSendEnabled() {
|
||||||
|
return !!this.uiSettings.enter_to_send_enabled;
|
||||||
|
},
|
||||||
isPrivate() {
|
isPrivate() {
|
||||||
if (this.currentChat.can_reply) {
|
if (this.currentChat.can_reply) {
|
||||||
return this.replyType === REPLY_EDITOR_MODES.NOTE;
|
return this.replyType === REPLY_EDITOR_MODES.NOTE;
|
||||||
|
@ -209,6 +217,12 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
currentChat(conversation) {
|
currentChat(conversation) {
|
||||||
const { can_reply: canReply } = conversation;
|
const { can_reply: canReply } = conversation;
|
||||||
|
const isUserReplyingOnPrivate =
|
||||||
|
this.replyType === REPLY_EDITOR_MODES.NOTE;
|
||||||
|
if (isUserReplyingOnPrivate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (canReply) {
|
if (canReply) {
|
||||||
this.replyType = REPLY_EDITOR_MODES.REPLY;
|
this.replyType = REPLY_EDITOR_MODES.REPLY;
|
||||||
} else {
|
} else {
|
||||||
|
@ -216,9 +230,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
message(updatedMessage) {
|
message(updatedMessage) {
|
||||||
if (this.isPrivate) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const isSlashCommand = updatedMessage[0] === '/';
|
const isSlashCommand = updatedMessage[0] === '/';
|
||||||
const hasNextWord = updatedMessage.includes(' ');
|
const hasNextWord = updatedMessage.includes(' ');
|
||||||
const isShortCodeActive = isSlashCommand && !hasNextWord;
|
const isShortCodeActive = isSlashCommand && !hasNextWord;
|
||||||
|
@ -247,14 +258,24 @@ export default {
|
||||||
this.hideEmojiPicker();
|
this.hideEmojiPicker();
|
||||||
this.hideCannedResponse();
|
this.hideCannedResponse();
|
||||||
} else if (isEnter(e)) {
|
} else if (isEnter(e)) {
|
||||||
|
const hasSendOnEnterEnabled =
|
||||||
|
(this.isFormatMode && this.enterToSendEnabled) || !this.isFormatMode;
|
||||||
const shouldSendMessage =
|
const shouldSendMessage =
|
||||||
!this.isFormatMode && !hasPressedShift(e) && this.isFocused;
|
hasSendOnEnterEnabled && !hasPressedShift(e) && this.isFocused;
|
||||||
if (shouldSendMessage) {
|
if (shouldSendMessage) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.sendMessage();
|
this.sendMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
toggleEnterToSend(enterToSendEnabled) {
|
||||||
|
this.$store.dispatch('updateUISettings', {
|
||||||
|
uiSettings: {
|
||||||
|
...this.uiSettings,
|
||||||
|
enter_to_send_enabled: enterToSendEnabled,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
async sendMessage() {
|
async sendMessage() {
|
||||||
if (this.isReplyButtonDisabled) {
|
if (this.isReplyButtonDisabled) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -44,7 +44,8 @@
|
||||||
"TWEET": "Tweet",
|
"TWEET": "Tweet",
|
||||||
"TIP_FORMAT_ICON": "Show rich text editor",
|
"TIP_FORMAT_ICON": "Show rich text editor",
|
||||||
"TIP_EMOJI_ICON": "Show emoji selector",
|
"TIP_EMOJI_ICON": "Show emoji selector",
|
||||||
"TIP_ATTACH_ICON": "Attach files"
|
"TIP_ATTACH_ICON": "Attach files",
|
||||||
|
"ENTER_TO_SEND": "Enter to send"
|
||||||
},
|
},
|
||||||
"VISIBLE_TO_AGENTS": "Private Note: Only visible to you and your team",
|
"VISIBLE_TO_AGENTS": "Private Note: Only visible to you and your team",
|
||||||
"CHANGE_STATUS": "Conversation status changed",
|
"CHANGE_STATUS": "Conversation status changed",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue