File tree Expand file tree Collapse file tree 3 files changed +49
-1
lines changed Expand file tree Collapse file tree 3 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ export const TriggerMode = {
8
8
manually : 'Manually' ,
9
9
}
10
10
11
+ export const DisplayMode = {
12
+ sidebar : 'Display in sidebar' ,
13
+ floatingToolbar : 'Display in floating toolbar' ,
14
+ }
15
+
11
16
export const ThemeMode = {
12
17
light : 'Light' ,
13
18
dark : 'Dark' ,
@@ -202,6 +207,8 @@ export const defaultConfig = {
202
207
203
208
/** @type {keyof TriggerMode }*/
204
209
triggerMode : 'manually' ,
210
+ /** @type {keyof DisplayMode }*/
211
+ displayMode : 'sidebar' ,
205
212
/** @type {keyof ThemeMode }*/
206
213
themeMode : 'auto' ,
207
214
/** @type {keyof Models }*/
Original file line number Diff line number Diff line change @@ -70,11 +70,33 @@ async function mountComponent(siteConfig, userConfig) {
70
70
unmountComponentAtNode ( e )
71
71
e . remove ( )
72
72
} )
73
+
74
+ const position = {
75
+ x : window . innerWidth - 300 - ( Math . floor ( ( 20 / 100 ) * window . innerWidth ) ) ,
76
+ y : window . innerHeight / 2 - 200 ,
77
+ }
78
+ const toolbarContainer = createElementAtPosition ( position . x , position . y )
79
+ toolbarContainer . className = 'chatgptbox-toolbar-container-not-queryable'
80
+ if ( userConfig . displayMode === 'floatingToolbar' ) {
81
+ render (
82
+ < FloatingToolbar
83
+ session = { initSession ( { modelName : userConfig . modelName } ) }
84
+ selection = { question }
85
+ container = { toolbarContainer }
86
+ dockable = { true }
87
+ triggered = { true }
88
+ closeable = { true }
89
+ prompt = { question }
90
+ /> ,
91
+ toolbarContainer ,
92
+ )
93
+ return
94
+ }
73
95
const container = document . createElement ( 'div' )
74
96
container . id = 'chatgptbox-container'
75
97
render (
76
98
< DecisionCard
77
- session = { initSession ( { modelName : ( await getUserConfig ( ) ) . modelName } ) }
99
+ session = { initSession ( { modelName : userConfig . modelName } ) }
78
100
question = { question }
79
101
siteConfig = { siteConfig }
80
102
container = { container }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
14
14
Models ,
15
15
ThemeMode ,
16
16
TriggerMode ,
17
+ DisplayMode ,
17
18
isUsingMoonshotApi ,
18
19
} from '../../config/index.mjs'
19
20
import Browser from 'webextension-polyfill'
@@ -118,6 +119,24 @@ export function GeneralPart({ config, updateConfig }) {
118
119
} ) }
119
120
</ select >
120
121
</ label >
122
+ < label >
123
+ < legend > { t ( 'DisplayMode' ) } </ legend >
124
+ < select
125
+ required
126
+ onChange = { ( e ) => {
127
+ const mode = e . target . value
128
+ updateConfig ( { displayMode : mode } )
129
+ } }
130
+ >
131
+ { Object . entries ( DisplayMode ) . map ( ( [ key , desc ] ) => {
132
+ return (
133
+ < option value = { key } key = { key } selected = { key === config . displayMode } >
134
+ { t ( desc ) }
135
+ </ option >
136
+ )
137
+ } ) }
138
+ </ select >
139
+ </ label >
121
140
< label >
122
141
< legend > { t ( 'Theme' ) } </ legend >
123
142
< select
You can’t perform that action at this time.
0 commit comments