embeddedaichatux 1.0.1 → 1.0.3

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/AIChat.npm.csproj CHANGED
@@ -1,4 +1,4 @@
1
- <Project Sdk="Microsoft.NET.Sdk.Web">
1
+ <Project Sdk="Microsoft.NET.Sdk.Web">
2
2
 
3
3
  <PropertyGroup>
4
4
  <TargetFramework>net7.0</TargetFramework>
@@ -6,12 +6,13 @@
6
6
  <ImplicitUsings>enable</ImplicitUsings>
7
7
  </PropertyGroup>
8
8
 
9
- <ItemGroup>
10
- <None Remove="EmbeddedChat.js" />
11
- </ItemGroup>
9
+ <Target Name="CopyCommonWebFiles" BeforeTargets="Build">
10
+ <ItemGroup>
11
+ <_CommonWebJsFiles Include="..\AIChat.Web\wwwroot\js\EmbeddedChat.js" />
12
+ </ItemGroup>
13
+
14
+ <Copy SourceFiles="@(_CommonWebJsFiles)" DestinationFolder="$(MSBuildProjectDirectory)" SkipUnchangedFiles="true" />
15
+ </Target>
12
16
 
13
- <ItemGroup>
14
- <Content Include="EmbeddedChat.js" />
15
- </ItemGroup>
16
17
 
17
18
  </Project>
package/EmbeddedChat.js CHANGED
@@ -1,23 +1,28 @@
1
+ // embeddedChat.js
1
2
  class EmbeddedChat {
2
3
  constructor(containerDiv, chatId, options) {
4
+ if (!containerDiv) {
5
+ containerDiv = this.createChatContainer();
6
+ }
3
7
  this.containerDiv = containerDiv;
4
8
  this.chatId = chatId;
5
9
  this.options = options || {};
6
10
  this.avatarImage = this.options.avatarImage || '/img/avatar.jpg';
7
11
  this.isPreview = this.options.isPreview || false;
8
12
  this.previewParam = this.isPreview ? "?isPreview=true" : "";
13
+ this.serverUrl = this.options.serverUrl || 'https://embedgpt.chat';
9
14
  this.positionStyle = this.containerDiv.dataset.position === 'in-place' ? 'width:100%; height:600px' : 'position: fixed; right: 0; bottom: 0; width: 300px; height: 600px';
10
15
  this.init();
11
16
  }
12
17
 
13
18
  init() {
14
19
  const iframeHtml = `
15
- <div id="embedded-chat-minimized" class="container" style="color:#43636e;width:100%; position: fixed; right: 0; bottom: 0; width: 300px; height: 50px; padding-top: 10px;padding-left: 100px;">
16
- <img title="Chat" src="${this.avatarImage}" style="height:40px; border-radius: 50%;" />
17
- <button id="embedded-chat-now" class="btn btn-primary">Chat Now</button>
18
- </div>
19
- <iframe id="embedded-chat" style="${this.positionStyle}; display: none; border:none; overflow:hidden;" frameborder="0" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" src="https://embedgpt.chat/ChatUX/${this.chatId}${this.previewParam}"></iframe>
20
- `;
20
+ <iframe id="embedded-chat" style="${this.positionStyle}; display: none; border:none; overflow:hidden;" frameborder="0" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" src="${this.serverUrl}/ChatUX/${this.chatId}${this.previewParam}"></iframe>
21
+ <div id="embedded-chat-minimized" class="container" style="display: none;; color:#43636e;width:100%; position: fixed; right: 0; bottom: 0; width: 300px; height: 50px; padding-top: 10px;padding-left: 100px;">
22
+ <img title="Chat" src="${this.avatarImage}" style="height:40px; border-radius: 50%;" />
23
+ <button id="embedded-chat-now" class="btn btn-primary">Chat Now</button>
24
+ </div>
25
+ `;
21
26
 
22
27
  this.containerDiv.innerHTML = iframeHtml;
23
28
  this.iframe = this.containerDiv.querySelector("#embedded-chat");
@@ -39,6 +44,14 @@ class EmbeddedChat {
39
44
  }
40
45
  });
41
46
  }
47
+
48
+ createChatContainer() {
49
+ const chatContainer = document.createElement('div');
50
+ chatContainer.className = 'embedded-chat-container';
51
+ chatContainer.style.position = 'relative';
52
+ document.body.appendChild(chatContainer);
53
+ return chatContainer;
54
+ }
42
55
  }
43
56
 
44
57
  export function initEmbeddedChat(containerDiv, chatId, options) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "embeddedaichatux",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "embeddedaichatux",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
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": {