1
- import {
2
- type InkeepAIChatSettings ,
3
- InkeepEmbeddedChat ,
4
- type InkeepWidgetBaseSettings ,
5
- } from "@inkeep/widgets" ;
1
+ import React , { useEffect , useRef } from "react" ;
6
2
7
- const baseSettings : InkeepWidgetBaseSettings = {
3
+ type _react = typeof React ;
4
+
5
+ const baseSettings = {
8
6
apiKey : "499c156cf7a9798343949c8bb5665ac95e48132c6d68c42e" ,
9
7
integrationId : "clot3asdz0000s601nc8jwnzx" ,
10
8
organizationId : "org_dDOlt2uJlMWM8oIS" ,
@@ -28,7 +26,7 @@ const baseSettings: InkeepWidgetBaseSettings = {
28
26
} ,
29
27
} ;
30
28
31
- const aiChatSettings : InkeepAIChatSettings = {
29
+ const aiChatSettings = {
32
30
shareChatUrlBasePath : `${ process . env . NODE_ENV === "development" ? "http://localhost:9000" : "https://zuplo.com" } /docs/ask` ,
33
31
isChatSharingEnabled : true ,
34
32
quickQuestions : [
@@ -39,22 +37,38 @@ const aiChatSettings: InkeepAIChatSettings = {
39
37
] ,
40
38
} ;
41
39
40
+ interface InkeepWidget {
41
+ render : ( config : any & { isOpen : boolean } ) => void ;
42
+ }
43
+
44
+ declare global {
45
+ let Inkeep : ( ) => {
46
+ embed : ( config : any ) => InkeepWidget ;
47
+ } ;
48
+ }
49
+
42
50
const EmbeddedChat = ( ) => {
43
- return (
44
- < div >
45
- < InkeepEmbeddedChat
46
- stylesheetUrls = { [ "/docs/styles/inkeep.css" ] }
47
- baseSettings = { {
51
+ const ref = useRef < HTMLDivElement > ( null ) ;
52
+
53
+ useEffect ( ( ) => {
54
+ Inkeep ( ) . embed ( {
55
+ componentType : "EmbeddedChat" ,
56
+ targetElement : ref . current ! ,
57
+ properties : {
58
+ stylesheetUrls : [ "/docs/styles/inkeep.css" ] ,
59
+ baseSettings : {
48
60
...baseSettings ,
49
61
colorMode : {
50
- ...baseSettings . colorMode ,
62
+ // ...baseSettings.colorMode,
51
63
forcedColorMode : "dark" ,
52
64
} ,
53
- } }
54
- aiChatSettings = { aiChatSettings }
55
- />
56
- </ div >
57
- ) ;
65
+ } ,
66
+ aiChatSettings,
67
+ } ,
68
+ } ) ;
69
+ } , [ ref ] ) ;
70
+
71
+ return < div ref = { ref } /> ;
58
72
} ;
59
73
60
74
export default EmbeddedChat ;
0 commit comments