yelda-webchat 1.1.6 → 1.1.7
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
package/src/config/index.js
CHANGED
|
@@ -27,7 +27,8 @@ module.exports = {
|
|
|
27
27
|
LISTEN_LEAVE_VIEWPORT: 'listenLeaveViewport',
|
|
28
28
|
LISTEN_URL_UPDATE: 'listenUrlUpdate',
|
|
29
29
|
ABSTAIN_URL_UPDATE: 'abstainUrlUpdate',
|
|
30
|
-
ADD_BUBBLE_TEXT: 'addBubbleText'
|
|
30
|
+
ADD_BUBBLE_TEXT: 'addBubbleText',
|
|
31
|
+
ADD_MINIMAL_NOTIFICATION_TEXT: 'addMinimalNotificationText'
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -82,16 +82,20 @@ class YeldaChat {
|
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Create an assistantBubbleText component and add it to webChatContainer element
|
|
85
|
+
* @param {String} text - default null
|
|
85
86
|
*/
|
|
86
|
-
addAssistantBubbleText() {
|
|
87
|
-
|
|
87
|
+
addAssistantBubbleText(text = null) {
|
|
88
|
+
text = text || this.webchatSettings && this.webchatSettings.bubbleText
|
|
89
|
+
if (!this.webChatContainer || !text) {
|
|
88
90
|
return
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
// Remove the assistant bubble text element before adding a new one
|
|
94
|
+
this.removeElement('yelda_assistant_bubble_text')
|
|
91
95
|
// create assistantBubbleText element and set the text
|
|
92
96
|
this.assistantBubbleText = document.createElement('span')
|
|
93
97
|
this.assistantBubbleText.setAttribute('id', 'yelda_assistant_bubble_text')
|
|
94
|
-
this.assistantBubbleText.innerText = this.webchatSettings.bubbleText
|
|
98
|
+
this.assistantBubbleText.innerText = text || this.webchatSettings.bubbleText
|
|
95
99
|
|
|
96
100
|
// Add click event to assistant text
|
|
97
101
|
this.assistantBubbleText.addEventListener('click', this.openChat.bind(this))
|
|
@@ -437,6 +441,9 @@ class YeldaChat {
|
|
|
437
441
|
window.dispatchEvent(new CustomEvent('isSendingMessage', { detail: eventData.data }))
|
|
438
442
|
}
|
|
439
443
|
break
|
|
444
|
+
case config.FRAME_EVENT_TYPES.RECEIVED.ADD_MINIMAL_NOTIFICATION_TEXT:
|
|
445
|
+
this.addAssistantBubbleText(eventData.text)
|
|
446
|
+
break;
|
|
440
447
|
}
|
|
441
448
|
}
|
|
442
449
|
|
|
@@ -522,9 +529,12 @@ class YeldaChat {
|
|
|
522
529
|
|
|
523
530
|
// hide the assistant bubble text while opening the webchat window
|
|
524
531
|
if (this.assistantBubbleText) {
|
|
525
|
-
this.assistantBubbleText
|
|
532
|
+
this.assistantBubbleText = null
|
|
526
533
|
}
|
|
527
534
|
|
|
535
|
+
// Remove assistant bubble text while opening the webchat window
|
|
536
|
+
this.removeElement('yelda_assistant_bubble_text')
|
|
537
|
+
|
|
528
538
|
// Propagate the event to the webchat
|
|
529
539
|
document.getElementById('web_chat_frame').contentWindow.postMessage(config.FRAME_EVENT_TYPES.SENT.OPEN_CHAT, '*')
|
|
530
540
|
}
|