embeddedaichatux 1.5.1 → 1.6.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/EmbeddedChat.js +21 -7
- package/package.json +1 -1
package/EmbeddedChat.js
CHANGED
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
this.minimizedHeight = `${this.height * 0.3}px`; // 30% of the full height
|
|
17
17
|
this.mouseInsideChat = false;
|
|
18
18
|
this.hasRefreshed = false; // Flag to prevent endless loop
|
|
19
|
+
this.conversationId = null;
|
|
19
20
|
|
|
20
21
|
// Determine transition styles
|
|
21
22
|
const transitionStyle = this.enableAnimation ? 'transition: height 0.3s ease, opacity 0.3s ease;' : '';
|
|
22
23
|
|
|
23
24
|
this.positionStyle = this.containerDiv.dataset.position === 'in-place' ?
|
|
24
25
|
`width:100%; height:${this.height}px; ${transitionStyle}` :
|
|
25
|
-
`position: fixed; right: 0; bottom: 0; width: ${this.width}px; height: ${this.height}px; z-index: 100000; ${transitionStyle}`;
|
|
26
|
+
`position: fixed; right: 0; bottom: 0; width: ${this.width}px; height: ${this.height}px; z-index: 100000; max-height:80%; ${transitionStyle}`;
|
|
26
27
|
this.mode = options.mode || 'Chat'; // default to 'chat' if mode isn't provided
|
|
27
28
|
this.minimizeOnScroll = false; // Default to false
|
|
28
29
|
if (this.mode === 'ContactForm') {
|
|
@@ -44,7 +45,8 @@
|
|
|
44
45
|
|
|
45
46
|
getStoredConversationId() {
|
|
46
47
|
try {
|
|
47
|
-
|
|
48
|
+
const storedId = localStorage.getItem(`conversationId_${this.chatId}`);
|
|
49
|
+
return storedId;
|
|
48
50
|
} catch (error) {
|
|
49
51
|
console.error('Error accessing localStorage:', error);
|
|
50
52
|
return null;
|
|
@@ -59,6 +61,16 @@
|
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
setConversationId(newConversationId) {
|
|
65
|
+
const previousId = this.conversationId || 'null';
|
|
66
|
+
|
|
67
|
+
if (newConversationId !== previousId) {
|
|
68
|
+
// Separate block for changes to allow breakpoint placement
|
|
69
|
+
this.conversationId = newConversationId;
|
|
70
|
+
this.setStoredConversationId(newConversationId);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
62
74
|
init() {
|
|
63
75
|
this.updateIframes();
|
|
64
76
|
this.addEventListeners();
|
|
@@ -116,10 +128,11 @@
|
|
|
116
128
|
if (this.sessionInfo !== null) {
|
|
117
129
|
this.setSessionInfo(this.sessionInfo);
|
|
118
130
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Check and update conversationId after processing other conditions
|
|
134
|
+
if (e.data.conversationId) {
|
|
135
|
+
this.setConversationId(e.data.conversationId);
|
|
123
136
|
}
|
|
124
137
|
} else if (typeof e.data === "string") {
|
|
125
138
|
if (e.data === "minimize") {
|
|
@@ -162,6 +175,8 @@
|
|
|
162
175
|
|
|
163
176
|
this.iframe.style.height = `${this.height}px`;
|
|
164
177
|
this.iframe.style.opacity = '1';
|
|
178
|
+
|
|
179
|
+
this.iframe.contentWindow.postMessage({ message: "show" }, "*");
|
|
165
180
|
}
|
|
166
181
|
|
|
167
182
|
applyScale(scale) {
|
|
@@ -187,7 +202,6 @@
|
|
|
187
202
|
const iframe = this.containerDiv.querySelector("#embedded-chat");
|
|
188
203
|
|
|
189
204
|
const postMessage = () => {
|
|
190
|
-
console.log('Posting message to iframe:', { type: 'setSessionInfo', sessionInfo: sessionInfo });
|
|
191
205
|
iframe.contentWindow.postMessage({ type: 'setSessionInfo', sessionInfo: sessionInfo }, "*");
|
|
192
206
|
};
|
|
193
207
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "embeddedaichatux",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A lightweight and customizable embedded AI chat UI component that seamlessly integrates into web applications, offering minimized and expanded views, with iframe-based content rendering.",
|
|
5
5
|
"main": "EmbeddedChat.js",
|
|
6
6
|
"scripts": {
|