2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2021-01-13 12:36:25 +00:00
|
|
|
<div class="reply-box" :class="replyBoxClass">
|
2021-01-13 13:46:45 +00:00
|
|
|
<reply-top-panel
|
|
|
|
:mode="replyType"
|
|
|
|
:set-reply-mode="setReplyMode"
|
|
|
|
:is-message-length-reaching-threshold="isMessageLengthReachingThreshold"
|
|
|
|
:characters-remaining="charactersRemaining"
|
|
|
|
/>
|
2021-01-13 12:36:25 +00:00
|
|
|
<div class="reply-box__top">
|
|
|
|
<canned-response
|
2021-01-26 18:34:11 +00:00
|
|
|
v-if="showMentions && hasSlashCommand"
|
|
|
|
v-on-clickaway="hideMentions"
|
|
|
|
:search-key="mentionSearchKey"
|
2021-01-23 08:37:01 +00:00
|
|
|
@click="replaceText"
|
2021-01-13 12:36:25 +00:00
|
|
|
/>
|
|
|
|
<emoji-input
|
|
|
|
v-if="showEmojiPicker"
|
|
|
|
v-on-clickaway="hideEmojiPicker"
|
|
|
|
:on-click="emojiOnClick"
|
|
|
|
/>
|
|
|
|
<resizable-text-area
|
2021-01-26 18:34:11 +00:00
|
|
|
v-if="!showRichContentEditor"
|
2021-01-13 12:36:25 +00:00
|
|
|
ref="messageInput"
|
|
|
|
v-model="message"
|
|
|
|
class="input"
|
|
|
|
:placeholder="messagePlaceHolder"
|
|
|
|
:min-height="4"
|
|
|
|
@typing-off="onTypingOff"
|
|
|
|
@typing-on="onTypingOn"
|
|
|
|
@focus="onFocus"
|
|
|
|
@blur="onBlur"
|
|
|
|
/>
|
2021-01-18 05:50:19 +00:00
|
|
|
<woot-message-editor
|
|
|
|
v-else
|
|
|
|
v-model="message"
|
|
|
|
class="input"
|
2021-01-26 18:34:11 +00:00
|
|
|
:is-private="isOnPrivateNote"
|
2021-01-18 05:50:19 +00:00
|
|
|
:placeholder="messagePlaceHolder"
|
|
|
|
:min-height="4"
|
|
|
|
@typing-off="onTypingOff"
|
|
|
|
@typing-on="onTypingOn"
|
|
|
|
@focus="onFocus"
|
|
|
|
@blur="onBlur"
|
2021-01-26 18:34:11 +00:00
|
|
|
@toggle-user-mention="toggleUserMention"
|
2021-06-02 04:50:40 +00:00
|
|
|
@toggle-canned-menu="toggleCannedMenu"
|
2021-01-18 05:50:19 +00:00
|
|
|
/>
|
2021-01-13 12:36:25 +00:00
|
|
|
</div>
|
2021-01-06 12:26:29 +00:00
|
|
|
<div v-if="hasAttachments" class="attachment-preview-box">
|
|
|
|
<attachment-preview
|
|
|
|
:attachments="attachedFiles"
|
|
|
|
:remove-attachment="removeAttachment"
|
2019-12-16 12:53:14 +00:00
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
2021-01-13 12:36:25 +00:00
|
|
|
<reply-bottom-panel
|
|
|
|
:mode="replyType"
|
|
|
|
:send-button-text="replyButtonLabel"
|
|
|
|
:on-file-upload="onFileUpload"
|
|
|
|
:show-file-upload="showFileUpload"
|
|
|
|
:toggle-emoji-picker="toggleEmojiPicker"
|
|
|
|
:show-emoji-picker="showEmojiPicker"
|
|
|
|
:on-send="sendMessage"
|
|
|
|
:is-send-disabled="isReplyButtonDisabled"
|
2021-01-18 05:50:19 +00:00
|
|
|
:set-format-mode="setFormatMode"
|
2021-01-26 18:34:11 +00:00
|
|
|
:is-on-private-note="isOnPrivateNote"
|
|
|
|
:is-format-mode="showRichContentEditor"
|
2021-01-18 05:50:19 +00:00
|
|
|
:enable-rich-editor="isRichEditorEnabled"
|
2021-01-19 13:58:40 +00:00
|
|
|
:enter-to-send-enabled="enterToSendEnabled"
|
|
|
|
@toggleEnterToSend="toggleEnterToSend"
|
2021-01-13 12:36:25 +00:00
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { mixin as clickaway } from 'vue-clickaway';
|
2021-04-15 16:58:19 +00:00
|
|
|
import alertMixin from 'shared/mixins/alertMixin';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2020-09-13 17:19:01 +00:00
|
|
|
import EmojiInput from 'shared/components/emoji/EmojiInput';
|
2019-08-14 09:48:44 +00:00
|
|
|
import CannedResponse from './CannedResponse';
|
2020-06-18 09:47:45 +00:00
|
|
|
import ResizableTextArea from 'shared/components/ResizableTextArea';
|
2021-01-06 12:26:29 +00:00
|
|
|
import AttachmentPreview from 'dashboard/components/widgets/AttachmentsPreview';
|
2021-01-13 12:36:25 +00:00
|
|
|
import ReplyTopPanel from 'dashboard/components/widgets/WootWriter/ReplyTopPanel';
|
|
|
|
import ReplyBottomPanel from 'dashboard/components/widgets/WootWriter/ReplyBottomPanel';
|
|
|
|
import { REPLY_EDITOR_MODES } from 'dashboard/components/widgets/WootWriter/constants';
|
2021-01-18 05:50:19 +00:00
|
|
|
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor';
|
2021-04-15 16:58:19 +00:00
|
|
|
import { checkFileSizeLimit } from 'shared/helpers/FileHelper';
|
|
|
|
import { MAXIMUM_FILE_UPLOAD_SIZE } from 'shared/constants/messages';
|
|
|
|
|
2020-07-16 19:02:32 +00:00
|
|
|
import {
|
|
|
|
isEscape,
|
|
|
|
isEnter,
|
|
|
|
hasPressedShift,
|
|
|
|
} from 'shared/helpers/KeyboardHelpers';
|
|
|
|
import { MESSAGE_MAX_LENGTH } from 'shared/helpers/MessageTypeHelper';
|
2020-08-05 12:16:17 +00:00
|
|
|
import inboxMixin from 'shared/mixins/inboxMixin';
|
2021-02-07 07:24:32 +00:00
|
|
|
import uiSettingsMixin from 'dashboard/mixins/uiSettings';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
export default {
|
2020-03-05 20:17:37 +00:00
|
|
|
components: {
|
|
|
|
EmojiInput,
|
|
|
|
CannedResponse,
|
2020-06-18 09:47:45 +00:00
|
|
|
ResizableTextArea,
|
2021-01-06 12:26:29 +00:00
|
|
|
AttachmentPreview,
|
2021-01-13 12:36:25 +00:00
|
|
|
ReplyTopPanel,
|
|
|
|
ReplyBottomPanel,
|
2021-01-18 05:50:19 +00:00
|
|
|
WootMessageEditor,
|
2020-03-05 20:17:37 +00:00
|
|
|
},
|
2021-04-15 16:58:19 +00:00
|
|
|
mixins: [clickaway, inboxMixin, uiSettingsMixin, alertMixin],
|
2020-08-11 04:27:42 +00:00
|
|
|
props: {
|
2021-08-02 10:37:30 +00:00
|
|
|
selectedTweet: {
|
|
|
|
type: [Object, String],
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
isATweet: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
2020-08-11 04:27:42 +00:00
|
|
|
},
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
message: '',
|
2020-07-04 08:20:44 +00:00
|
|
|
isFocused: false,
|
2019-08-14 09:48:44 +00:00
|
|
|
showEmojiPicker: false,
|
2021-01-26 18:34:11 +00:00
|
|
|
showMentions: false,
|
2021-01-06 12:26:29 +00:00
|
|
|
attachedFiles: [],
|
2021-01-13 12:36:25 +00:00
|
|
|
isUploading: false,
|
|
|
|
replyType: REPLY_EDITOR_MODES.REPLY,
|
2021-01-26 18:34:11 +00:00
|
|
|
mentionSearchKey: '',
|
|
|
|
hasUserMention: false,
|
|
|
|
hasSlashCommand: false,
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
},
|
2019-11-17 08:45:05 +00:00
|
|
|
computed: {
|
2021-01-26 18:34:11 +00:00
|
|
|
showRichContentEditor() {
|
2021-04-16 13:33:46 +00:00
|
|
|
if (this.isOnPrivateNote) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.isRichEditorEnabled) {
|
|
|
|
const {
|
|
|
|
display_rich_content_editor: displayRichContentEditor,
|
|
|
|
} = this.uiSettings;
|
|
|
|
|
|
|
|
return displayRichContentEditor;
|
|
|
|
}
|
|
|
|
return false;
|
2021-01-26 18:34:11 +00:00
|
|
|
},
|
2021-02-07 07:24:32 +00:00
|
|
|
...mapGetters({ currentChat: 'getSelectedChat' }),
|
2021-01-19 13:58:40 +00:00
|
|
|
enterToSendEnabled() {
|
|
|
|
return !!this.uiSettings.enter_to_send_enabled;
|
|
|
|
},
|
2020-07-25 17:24:45 +00:00
|
|
|
isPrivate() {
|
2021-04-12 10:45:11 +00:00
|
|
|
if (this.currentChat.can_reply || this.isATwilioWhatsappChannel) {
|
2021-01-26 18:34:11 +00:00
|
|
|
return this.isOnPrivateNote;
|
2020-07-25 17:24:45 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
2020-07-16 19:02:32 +00:00
|
|
|
inboxId() {
|
|
|
|
return this.currentChat.inbox_id;
|
|
|
|
},
|
|
|
|
inbox() {
|
|
|
|
return this.$store.getters['inboxes/getInbox'](this.inboxId);
|
|
|
|
},
|
|
|
|
messagePlaceHolder() {
|
|
|
|
return this.isPrivate
|
|
|
|
? this.$t('CONVERSATION.FOOTER.PRIVATE_MSG_INPUT')
|
|
|
|
: this.$t('CONVERSATION.FOOTER.MSG_INPUT');
|
|
|
|
},
|
|
|
|
isMessageLengthReachingThreshold() {
|
2021-01-13 13:46:45 +00:00
|
|
|
return this.message.length > this.maxLength - 50;
|
2020-07-16 19:02:32 +00:00
|
|
|
},
|
2021-01-13 13:46:45 +00:00
|
|
|
charactersRemaining() {
|
|
|
|
return this.maxLength - this.message.length;
|
2020-07-16 19:02:32 +00:00
|
|
|
},
|
|
|
|
isReplyButtonDisabled() {
|
2021-08-02 10:37:30 +00:00
|
|
|
if (this.isATweet && !this.inReplyTo) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-01-06 12:26:29 +00:00
|
|
|
|
|
|
|
if (this.hasAttachments) return false;
|
2021-08-02 10:37:30 +00:00
|
|
|
|
2020-07-16 19:02:32 +00:00
|
|
|
return (
|
2021-08-02 10:37:30 +00:00
|
|
|
this.isMessageEmpty ||
|
2020-07-16 19:02:32 +00:00
|
|
|
this.message.length === 0 ||
|
|
|
|
this.message.length > this.maxLength
|
|
|
|
);
|
|
|
|
},
|
2020-03-05 20:17:37 +00:00
|
|
|
conversationType() {
|
2020-03-09 04:30:11 +00:00
|
|
|
const { additional_attributes: additionalAttributes } = this.currentChat;
|
|
|
|
const type = additionalAttributes ? additionalAttributes.type : '';
|
|
|
|
return type || '';
|
2020-03-05 20:17:37 +00:00
|
|
|
},
|
|
|
|
maxLength() {
|
2020-07-16 19:02:32 +00:00
|
|
|
if (this.isPrivate) {
|
|
|
|
return MESSAGE_MAX_LENGTH.GENERAL;
|
|
|
|
}
|
|
|
|
if (this.isAFacebookInbox) {
|
|
|
|
return MESSAGE_MAX_LENGTH.FACEBOOK;
|
|
|
|
}
|
2021-05-04 14:01:00 +00:00
|
|
|
if (this.isATwilioWhatsappChannel) {
|
|
|
|
return MESSAGE_MAX_LENGTH.TWILIO_WHATSAPP;
|
|
|
|
}
|
2020-07-16 19:02:32 +00:00
|
|
|
if (this.isATwilioSMSChannel) {
|
|
|
|
return MESSAGE_MAX_LENGTH.TWILIO_SMS;
|
2020-03-05 20:17:37 +00:00
|
|
|
}
|
2020-07-16 19:02:32 +00:00
|
|
|
if (this.isATwitterInbox) {
|
2020-03-05 20:17:37 +00:00
|
|
|
if (this.conversationType === 'tweet') {
|
2021-08-02 10:37:30 +00:00
|
|
|
return MESSAGE_MAX_LENGTH.TWEET - this.replyToUserLength - 2;
|
2020-03-05 20:17:37 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-16 19:02:32 +00:00
|
|
|
return MESSAGE_MAX_LENGTH.GENERAL;
|
2020-03-05 20:17:37 +00:00
|
|
|
},
|
2020-07-16 19:02:32 +00:00
|
|
|
showFileUpload() {
|
|
|
|
return (
|
|
|
|
this.isAWebWidgetInbox ||
|
|
|
|
this.isAFacebookInbox ||
|
2020-10-21 07:33:04 +00:00
|
|
|
this.isATwilioWhatsappChannel ||
|
|
|
|
this.isAPIInbox
|
2020-07-16 19:02:32 +00:00
|
|
|
);
|
|
|
|
},
|
2020-03-05 20:17:37 +00:00
|
|
|
replyButtonLabel() {
|
|
|
|
if (this.isPrivate) {
|
|
|
|
return this.$t('CONVERSATION.REPLYBOX.CREATE');
|
|
|
|
}
|
|
|
|
if (this.conversationType === 'tweet') {
|
|
|
|
return this.$t('CONVERSATION.REPLYBOX.TWEET');
|
|
|
|
}
|
|
|
|
return this.$t('CONVERSATION.REPLYBOX.SEND');
|
|
|
|
},
|
2020-07-04 08:20:44 +00:00
|
|
|
replyBoxClass() {
|
|
|
|
return {
|
2021-01-13 12:36:25 +00:00
|
|
|
'is-private': this.isPrivate,
|
2021-01-06 12:26:29 +00:00
|
|
|
'is-focused': this.isFocused || this.hasAttachments,
|
2020-07-04 08:20:44 +00:00
|
|
|
};
|
|
|
|
},
|
2021-01-06 12:26:29 +00:00
|
|
|
hasAttachments() {
|
|
|
|
return this.attachedFiles.length;
|
|
|
|
},
|
2021-01-18 05:50:19 +00:00
|
|
|
isRichEditorEnabled() {
|
2021-04-16 13:33:46 +00:00
|
|
|
return this.isAWebWidgetInbox || this.isAnEmailChannel;
|
2021-01-18 05:50:19 +00:00
|
|
|
},
|
2021-01-26 18:34:11 +00:00
|
|
|
isOnPrivateNote() {
|
|
|
|
return this.replyType === REPLY_EDITOR_MODES.NOTE;
|
|
|
|
},
|
2021-08-02 10:37:30 +00:00
|
|
|
inReplyTo() {
|
|
|
|
const selectedTweet = this.selectedTweet || {};
|
|
|
|
return selectedTweet.id;
|
|
|
|
},
|
|
|
|
replyToUserLength() {
|
|
|
|
const selectedTweet = this.selectedTweet || {};
|
|
|
|
const {
|
|
|
|
sender: {
|
|
|
|
additional_attributes: { screen_name: screenName = '' } = {},
|
|
|
|
} = {},
|
|
|
|
} = selectedTweet;
|
|
|
|
return screenName ? screenName.length : 0;
|
|
|
|
},
|
2021-07-27 02:08:27 +00:00
|
|
|
isMessageEmpty() {
|
2021-08-02 10:37:30 +00:00
|
|
|
if (!this.message) {
|
|
|
|
return true;
|
2021-07-27 02:08:27 +00:00
|
|
|
}
|
|
|
|
return !this.message.trim().replace(/\n/g, '').length;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
watch: {
|
2020-07-25 17:24:45 +00:00
|
|
|
currentChat(conversation) {
|
2021-01-13 12:36:25 +00:00
|
|
|
const { can_reply: canReply } = conversation;
|
2021-01-26 18:34:11 +00:00
|
|
|
if (this.isOnPrivateNote) {
|
2021-01-19 13:58:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-12 10:45:11 +00:00
|
|
|
if (canReply || this.isATwilioWhatsappChannel) {
|
2021-01-13 12:36:25 +00:00
|
|
|
this.replyType = REPLY_EDITOR_MODES.REPLY;
|
2020-07-25 17:24:45 +00:00
|
|
|
} else {
|
2021-01-13 12:36:25 +00:00
|
|
|
this.replyType = REPLY_EDITOR_MODES.NOTE;
|
2020-07-25 17:24:45 +00:00
|
|
|
}
|
|
|
|
},
|
2020-07-16 19:02:32 +00:00
|
|
|
message(updatedMessage) {
|
2021-06-02 04:50:40 +00:00
|
|
|
this.hasSlashCommand =
|
|
|
|
updatedMessage[0] === '/' && !this.showRichContentEditor;
|
2020-07-16 19:02:32 +00:00
|
|
|
const hasNextWord = updatedMessage.includes(' ');
|
2021-01-26 18:34:11 +00:00
|
|
|
const isShortCodeActive = this.hasSlashCommand && !hasNextWord;
|
2019-08-14 09:48:44 +00:00
|
|
|
if (isShortCodeActive) {
|
2021-01-26 18:34:11 +00:00
|
|
|
this.mentionSearchKey = updatedMessage.substr(1, updatedMessage.length);
|
|
|
|
this.showMentions = true;
|
2019-08-14 09:48:44 +00:00
|
|
|
} else {
|
2021-01-26 18:34:11 +00:00
|
|
|
this.mentionSearchKey = '';
|
|
|
|
this.showMentions = false;
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2019-10-27 05:18:26 +00:00
|
|
|
mounted() {
|
2019-11-17 08:45:05 +00:00
|
|
|
document.addEventListener('keydown', this.handleKeyEvents);
|
|
|
|
},
|
|
|
|
destroyed() {
|
|
|
|
document.removeEventListener('keydown', this.handleKeyEvents);
|
|
|
|
},
|
|
|
|
methods: {
|
2021-01-26 18:34:11 +00:00
|
|
|
toggleUserMention(currentMentionState) {
|
|
|
|
this.hasUserMention = currentMentionState;
|
|
|
|
},
|
2021-06-02 04:50:40 +00:00
|
|
|
toggleCannedMenu(value) {
|
|
|
|
this.showCannedMenu = value;
|
|
|
|
},
|
2019-11-17 08:45:05 +00:00
|
|
|
handleKeyEvents(e) {
|
2020-07-16 19:02:32 +00:00
|
|
|
if (isEscape(e)) {
|
2019-10-27 05:18:26 +00:00
|
|
|
this.hideEmojiPicker();
|
2021-01-26 18:34:11 +00:00
|
|
|
this.hideMentions();
|
2020-07-16 19:02:32 +00:00
|
|
|
} else if (isEnter(e)) {
|
2021-01-19 13:58:40 +00:00
|
|
|
const hasSendOnEnterEnabled =
|
2021-01-26 18:34:11 +00:00
|
|
|
(this.showRichContentEditor &&
|
|
|
|
this.enterToSendEnabled &&
|
2021-06-02 04:50:40 +00:00
|
|
|
!this.hasUserMention &&
|
|
|
|
!this.showCannedMenu) ||
|
2021-01-26 18:34:11 +00:00
|
|
|
!this.showRichContentEditor;
|
2021-01-18 05:50:19 +00:00
|
|
|
const shouldSendMessage =
|
2021-01-19 13:58:40 +00:00
|
|
|
hasSendOnEnterEnabled && !hasPressedShift(e) && this.isFocused;
|
2021-01-18 05:50:19 +00:00
|
|
|
if (shouldSendMessage) {
|
2019-10-27 05:18:26 +00:00
|
|
|
e.preventDefault();
|
|
|
|
this.sendMessage();
|
|
|
|
}
|
|
|
|
}
|
2019-11-17 08:45:05 +00:00
|
|
|
},
|
2021-01-19 13:58:40 +00:00
|
|
|
toggleEnterToSend(enterToSendEnabled) {
|
2021-02-07 07:24:32 +00:00
|
|
|
this.updateUISettings({ enter_to_send_enabled: enterToSendEnabled });
|
2021-01-19 13:58:40 +00:00
|
|
|
},
|
2020-03-22 10:24:36 +00:00
|
|
|
async sendMessage() {
|
2020-07-16 19:02:32 +00:00
|
|
|
if (this.isReplyButtonDisabled) {
|
2020-05-17 18:14:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-01-26 18:34:11 +00:00
|
|
|
if (!this.showMentions) {
|
2021-01-06 12:26:29 +00:00
|
|
|
const newMessage = this.message;
|
|
|
|
const messagePayload = this.getMessagePayload(newMessage);
|
2020-07-02 06:28:02 +00:00
|
|
|
this.clearMessage();
|
2020-03-22 10:24:36 +00:00
|
|
|
try {
|
2020-08-11 04:27:42 +00:00
|
|
|
await this.$store.dispatch('sendMessage', messagePayload);
|
2020-03-22 10:24:36 +00:00
|
|
|
this.$emit('scrollToMessage');
|
|
|
|
} catch (error) {
|
|
|
|
// Error
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
this.hideEmojiPicker();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
replaceText(message) {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.message = message;
|
2019-11-17 08:45:05 +00:00
|
|
|
}, 100);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2021-01-13 12:36:25 +00:00
|
|
|
setReplyMode(mode = REPLY_EDITOR_MODES.REPLY) {
|
|
|
|
const { can_reply: canReply } = this.currentChat;
|
|
|
|
|
2021-04-12 10:45:11 +00:00
|
|
|
if (canReply || this.isATwilioWhatsappChannel) this.replyType = mode;
|
2021-02-07 07:24:32 +00:00
|
|
|
if (this.showRichContentEditor) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.$nextTick(() => this.$refs.messageInput.focus());
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
emojiOnClick(emoji) {
|
2020-09-13 17:19:01 +00:00
|
|
|
this.message = `${this.message}${emoji} `;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
clearMessage() {
|
|
|
|
this.message = '';
|
2021-01-06 12:26:29 +00:00
|
|
|
this.attachedFiles = [];
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
toggleEmojiPicker() {
|
|
|
|
this.showEmojiPicker = !this.showEmojiPicker;
|
|
|
|
},
|
|
|
|
hideEmojiPicker() {
|
|
|
|
if (this.showEmojiPicker) {
|
|
|
|
this.toggleEmojiPicker();
|
|
|
|
}
|
|
|
|
},
|
2021-01-26 18:34:11 +00:00
|
|
|
hideMentions() {
|
|
|
|
this.showMentions = false;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2020-11-26 18:47:55 +00:00
|
|
|
onTypingOn() {
|
|
|
|
this.toggleTyping('on');
|
|
|
|
},
|
|
|
|
onTypingOff() {
|
|
|
|
this.toggleTyping('off');
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
onBlur() {
|
2020-07-04 08:20:44 +00:00
|
|
|
this.isFocused = false;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2020-05-04 17:37:56 +00:00
|
|
|
onFocus() {
|
2020-07-04 08:20:44 +00:00
|
|
|
this.isFocused = true;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2019-10-27 13:31:59 +00:00
|
|
|
toggleTyping(status) {
|
2020-07-16 19:02:32 +00:00
|
|
|
if (this.isAWebWidgetInbox && !this.isPrivate) {
|
2020-05-04 17:37:56 +00:00
|
|
|
const conversationId = this.currentChat.id;
|
2020-06-14 08:37:52 +00:00
|
|
|
this.$store.dispatch('conversationTypingStatus/toggleTyping', {
|
2019-11-17 08:45:05 +00:00
|
|
|
status,
|
2020-05-04 17:37:56 +00:00
|
|
|
conversationId,
|
2019-11-17 08:45:05 +00:00
|
|
|
});
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2020-03-22 10:24:36 +00:00
|
|
|
onFileUpload(file) {
|
2020-04-29 20:11:13 +00:00
|
|
|
if (!file) {
|
|
|
|
return;
|
|
|
|
}
|
2021-04-15 16:58:19 +00:00
|
|
|
if (checkFileSizeLimit(file, MAXIMUM_FILE_UPLOAD_SIZE)) {
|
|
|
|
this.attachedFiles = [];
|
|
|
|
const reader = new FileReader();
|
|
|
|
reader.readAsDataURL(file.file);
|
|
|
|
reader.onloadend = () => {
|
|
|
|
this.attachedFiles.push({
|
|
|
|
currentChatId: this.currentChat.id,
|
|
|
|
resource: file,
|
|
|
|
isPrivate: this.isPrivate,
|
|
|
|
thumb: reader.result,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
this.showAlert(
|
|
|
|
this.$t('CONVERSATION.FILE_SIZE_LIMIT', {
|
|
|
|
MAXIMUM_FILE_UPLOAD_SIZE,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2021-01-06 12:26:29 +00:00
|
|
|
},
|
|
|
|
removeAttachment(itemIndex) {
|
|
|
|
this.attachedFiles = this.attachedFiles.filter(
|
|
|
|
(item, index) => itemIndex !== index
|
|
|
|
);
|
|
|
|
},
|
|
|
|
getMessagePayload(message) {
|
|
|
|
const [attachment] = this.attachedFiles;
|
|
|
|
const messagePayload = {
|
|
|
|
conversationId: this.currentChat.id,
|
|
|
|
message,
|
|
|
|
private: this.isPrivate,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (this.inReplyTo) {
|
|
|
|
messagePayload.contentAttributes = { in_reply_to: this.inReplyTo };
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attachment) {
|
|
|
|
messagePayload.file = attachment.resource.file;
|
|
|
|
}
|
|
|
|
|
|
|
|
return messagePayload;
|
2020-03-22 10:24:36 +00:00
|
|
|
},
|
2021-01-18 05:50:19 +00:00
|
|
|
setFormatMode(value) {
|
2021-02-07 07:24:32 +00:00
|
|
|
this.updateUISettings({ display_rich_content_editor: value });
|
2021-01-18 05:50:19 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
2021-01-13 12:36:25 +00:00
|
|
|
<style lang="scss" scoped>
|
2019-10-27 05:18:26 +00:00
|
|
|
.send-button {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
2021-01-13 12:36:25 +00:00
|
|
|
|
2021-01-06 12:26:29 +00:00
|
|
|
.attachment-preview-box {
|
2021-01-13 12:36:25 +00:00
|
|
|
padding: 0 var(--space-normal);
|
|
|
|
background: transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
.reply-box {
|
|
|
|
border-top: 1px solid var(--color-border);
|
|
|
|
background: white;
|
|
|
|
|
|
|
|
&.is-private {
|
|
|
|
background: var(--y-50);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.send-button {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.reply-box__top {
|
|
|
|
padding: 0 var(--space-normal);
|
|
|
|
border-top: 1px solid var(--color-border);
|
|
|
|
margin-top: -1px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.emoji-dialog {
|
|
|
|
top: unset;
|
|
|
|
bottom: 12px;
|
|
|
|
left: -320px;
|
|
|
|
right: unset;
|
|
|
|
|
|
|
|
&::before {
|
|
|
|
right: -16px;
|
|
|
|
bottom: 10px;
|
|
|
|
transform: rotate(270deg);
|
|
|
|
filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.08));
|
|
|
|
}
|
2021-01-06 12:26:29 +00:00
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
</style>
|