@bcc-code/vue-bcc-chat-ui 3.14.1 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@bcc-code/vue-bcc-chat-ui",
3
3
  "author": "bcc-code",
4
4
  "license": "Apache-2.0",
5
- "version": "3.14.1",
5
+ "version": "3.15.0",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "files": [
@@ -37,6 +37,7 @@ function closePreview(_event?: MouseEvent) {
37
37
  const onMessageEditStart = CometChatMessageEvents.ccMessageEdited.subscribe(
38
38
  ({ status }) => {
39
39
  if (status === MessageStatus.inprogress) {
40
+ if (chatInstance) chatInstance.value.replyToMessage = null;
40
41
  closePreview();
41
42
  }
42
43
  }
@@ -54,6 +55,7 @@ onMounted(() => {
54
55
  if (msgComposerData) {
55
56
  msgComposerData.inputRef.querySelector(".messageinput-input").focus()
56
57
  if (msgComposerData.messageToBeEdited) {
58
+ msgComposerData.showPreview = false; // This is only used for edit message preview
57
59
  msgComposerData.messageToBeEdited = null;
58
60
  msgComposerData.messageText = "";
59
61
  msgComposerData.textRef = "";
@@ -93,7 +93,7 @@ const replyPreviewStyle = {
93
93
  </script>
94
94
 
95
95
  <template>
96
- <div :style="{'display': src != null ? 'table-caption' : 'block'}">
96
+ <div class="bcc-message-wrapper" :class="{'has-text': text, 'has-image': src != null}" >
97
97
  <div v-if="metadata?.replyToMessageId" class="bcc-chat-msg-bubble">
98
98
  <div class="bcc-chat-msg-bubble--reply">
99
99
  <BccReplyPreview
@@ -102,29 +102,46 @@ const replyPreviewStyle = {
102
102
  />
103
103
  </div>
104
104
  </div>
105
- <div v-if="src != null" style="display: block; width: max-content;">
105
+ <div v-if="src != null" class="bcc-chat-img-msg-bubble">
106
106
  <BccImageBubble
107
107
  :message="message"
108
108
  :placeholderImage="placeholderImage"
109
109
  :src="src"
110
110
  />
111
111
  </div>
112
- <div v-if="metadata && metadata.translated_message" v-html="toMarkdownHtml(metadata.translated_message)"
112
+ <div v-if="text && metadata && metadata.translated_message" v-html="toMarkdownHtml(metadata.translated_message)"
113
113
  class="bcc-chat-msg-bubble bcc-chat-msg-bubble--translation" />
114
- <div v-html="toMarkdownHtml(text)" class="bcc-chat-msg-bubble"
114
+ <div v-if="text" v-html="toMarkdownHtml(text)" class="bcc-chat-msg-bubble"
115
115
  :class="{ 'bcc-chat-msg-bubble--translated': metadata && !!metadata.translated_message }" />
116
116
  </div>
117
117
  </template>
118
118
 
119
119
  <style lang="scss">
120
+ .bcc-chat-img-msg-bubble {
121
+ display: block;
122
+ width: max-content;
123
+ max-width: 100%;
124
+ margin: 0 auto;
125
+ border-radius: 8px;
126
+ padding-bottom: 8px;
127
+ position: relative;
128
+
129
+ &:last-child {
130
+ padding-bottom: 0;
131
+ }
132
+ }
120
133
  .bcc-chat-msg-bubble {
121
- padding: 8px 12px;
134
+ padding: 0 12px 8px;
122
135
  width: auto;
123
136
  max-width: 500px;
124
137
  line-height: 1.2;
125
138
  font: 400 14px Archivo, sans-serif, Inter;
126
139
  color: var(--cc__text-color);
127
140
 
141
+ &:first-child {
142
+ padding-top: 8px;
143
+ }
144
+
128
145
  p {
129
146
  color: var(--cc__text-color);
130
147
  line-height: 1.2;
@@ -197,7 +214,6 @@ const replyPreviewStyle = {
197
214
  position: relative;
198
215
  z-index: 0;
199
216
  margin-top: 3px;
200
- margin-bottom: -8px;
201
217
  border-radius: 6px;
202
218
  overflow: hidden;
203
219
  }
@@ -45,6 +45,7 @@ const chatInstance: Ref<ChatInstance> = ref({
45
45
  const messageComposerConfiguration = getMessageComposerConfiguration(chatInstance);
46
46
  const messageListConfiguration = getMessageListConfiguration(chatInstance, chatGroup);
47
47
  const threadedMessagesConfiguration = getThreadedMessagesConfiguration(chatGroup);
48
+ threadedMessagesConfiguration.messageComposerConfiguration = messageComposerConfiguration.value;
48
49
 
49
50
  provide("chatInstance", chatInstance);
50
51
 
@@ -54,7 +55,8 @@ const onMessageSend = CometChatMessageEvents.ccMessageSent.subscribe(({ message,
54
55
  let scope: string | undefined = chatGroup.value?.getScope();
55
56
 
56
57
  if (chatInstance.value.replyToMessage) {
57
- metadata.replyToMessageId = chatInstance.value.replyToMessage?.getId()
58
+ metadata.replyToMessageId = chatInstance.value.replyToMessage?.getId();
59
+ chatInstance.value.replyToMessage = null;
58
60
  }
59
61
 
60
62
  if (props.senderDisplayName && (scope == "moderator" || scope == "admin")) {
@@ -66,25 +68,7 @@ const onMessageSend = CometChatMessageEvents.ccMessageSent.subscribe(({ message,
66
68
  });
67
69
 
68
70
  watchEffect(() => {
69
- if (!chatInstance.value.replyToMessage) {
70
- messageComposerConfiguration.value.headerView = undefined;
71
- } else {
72
- messageComposerConfiguration.value.headerView = {
73
- componentName: "bcc-reply-box",
74
- props: {
75
- replyToMessage: chatInstance.value.replyToMessage,
76
- }
77
- }
78
- }
79
- });
80
-
81
- watchEffect(() => {
82
- if (!chatInstance.value.captionedAttachment) {
83
- messageComposerConfiguration.value.headerView = undefined;
84
- messageComposerConfiguration.value.sendButtonView = undefined;
85
- } else {
86
- chatInstance.value.captionedAttachment.caption = messageComposerConfiguration.value.text;
87
-
71
+ if (chatInstance.value.captionedAttachment) {
88
72
  messageComposerConfiguration.value.headerView = {
89
73
  componentName: BccAttachmentBox,
90
74
  props: {
@@ -95,6 +79,18 @@ watchEffect(() => {
95
79
  messageComposerConfiguration.value.sendButtonView = {
96
80
  componentName: BccChatSendButton
97
81
  };
82
+ } else {
83
+ messageComposerConfiguration.value.sendButtonView = undefined;
84
+ if (chatInstance.value.replyToMessage) {
85
+ messageComposerConfiguration.value.headerView = {
86
+ componentName: "bcc-reply-box",
87
+ props: {
88
+ replyToMessage: chatInstance.value.replyToMessage,
89
+ }
90
+ };
91
+ } else {
92
+ messageComposerConfiguration.value.headerView = undefined;
93
+ }
98
94
  }
99
95
  });
100
96
 
@@ -130,13 +126,6 @@ onMounted(() => {
130
126
  shadowDomSelector: "cometchat-preview",
131
127
  }
132
128
  ]);
133
-
134
- messageComposerConfiguration.value.onTextChange = (text: any) => {
135
- messageComposerConfiguration.value.text = text;
136
- if (chatInstance.value.captionedAttachment?.caption) {
137
- chatInstance.value.captionedAttachment.caption = text;
138
- }
139
- }
140
129
  });
141
130
 
142
131
  onBeforeUnmount(() => {
@@ -279,6 +268,22 @@ accent900: text in avatar
279
268
  margin-bottom: 5px;
280
269
  }
281
270
  }
271
+
272
+ .cc-messagebubble-wrapper__content {
273
+ max-width: 100%;
274
+ }
275
+
276
+ .cc-messagebubble-wrapper__content > div > .bcc-message-wrapper.has-text.has-image + div > div > div:not([class]) {
277
+ justify-content: flex-end !important;
278
+ padding: 0px 8px 8px !important;
279
+ margin-top: -5px !important;
280
+ height: unset !important;
281
+ border-radius: unset !important;
282
+ line-height: unset !important;
283
+ position: unset !important;
284
+ margin-right: unset !important;
285
+ background: unset !important;
286
+ }
282
287
  }
283
288
 
284
289
  .cc-messagebubble-wrapper__container {
@@ -64,14 +64,10 @@ onBeforeUnmount(() => {
64
64
  if (chatInstance) {
65
65
  // Here we add an additional onKeyDown event on the input field that sends our image when pressing Enter if the input field **is empty**.
66
66
  // We need this in addition to hooking into the "cc-text-input-entered" event because that event isn't triggered if the input field is empty.
67
- const ccTextInputs = document.querySelectorAll(`.${chatInstance.value.componentId} cometchat-text-input .messageinput-input`);
68
- const ccTextInput = ccTextInputs[ccTextInputs.length - 1];
69
- (ccTextInput as Element & {onkeydown: Function}).onkeydown = (function(onkeydown){
70
- return function(this: any, e: KeyboardEvent) {
71
- if (chatInstance.value.captionedAttachment?.caption?.trim() == "" && e.keyCode === 13 && !e.shiftKey) sendMessage();
72
- else if (onkeydown) return onkeydown.bind(this)(e);
73
- }
74
- })((ccTextInput as Element & {onkeydown: Function}).onkeydown);
67
+ const ccTextInput = msgComposerData.inputRef.querySelector(".messageinput-input");
68
+ ccTextInput.addEventListener("keydown", function(event: KeyboardEvent) {
69
+ if (msgComposerData.messageText?.trim() == "" && event.keyCode === 13 && !event.shiftKey) sendMessage();
70
+ });
75
71
  }
76
72
 
77
73
  </script>
@@ -54,21 +54,26 @@ const onMessageSend = CometChatMessageEvents.ccMessageSent.subscribe(
54
54
  }
55
55
  );
56
56
 
57
+ let originalGetAttachmentOptions: Function;
57
58
  onMounted(() => {
58
- if (msgComposerData) {
59
- msgComposerData.actionSheetRef.style.display="none";
59
+ if (msgComposerData && chatInstance) {
60
60
  msgComposerData.inputRef.querySelector(".messageinput-input").focus()
61
61
  if (msgComposerData.messageToBeEdited) {
62
+ msgComposerData.showPreview = false; // This is only used for edit message preview
62
63
  msgComposerData.messageToBeEdited = null;
63
64
  msgComposerData.messageText = "";
64
65
  msgComposerData.textRef = "";
65
66
  msgComposerData.inputRef?.emptyInputField();
66
67
  }
68
+ originalGetAttachmentOptions = msgComposerData.getAttachmentOptions;
69
+ msgComposerData.getAttachmentOptions = function() {
70
+ return originalGetAttachmentOptions().filter((option: any) => option.id === "captionedimage");
71
+ }
67
72
  }
68
73
  });
69
74
 
70
75
  onBeforeUnmount(() => {
71
- msgComposerData.actionSheetRef.style.removeProperty("display");
76
+ msgComposerData.getAttachmentOptions = originalGetAttachmentOptions;
72
77
  onMessageEditStart.unsubscribe();
73
78
  onMessageSend.unsubscribe();
74
79
  });
@@ -76,6 +76,7 @@ function getThumbnailURL() {
76
76
  padding: 0 12px;
77
77
  position: relative;
78
78
  display: grid;
79
+ justify-content: start;
79
80
  }
80
81
  .bcc__reply_preview__content_bar {
81
82
  position: absolute;