File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export type WidgetConfig = {
37
37
api_key : string ;
38
38
firebaseconfig : any ;
39
39
dbpath : string ;
40
+ submitOnKeydown : boolean ;
40
41
} ;
41
42
42
43
@@ -81,6 +82,7 @@ const config: WidgetConfig = {
81
82
api_key : "" ,
82
83
firebaseconfig : { } ,
83
84
dbpath : "xyz" ,
85
+ submitOnKeydown : false ,
84
86
...( window as any ) . ChatWidget ?. config ,
85
87
} ;
86
88
@@ -284,6 +286,18 @@ function open(e: Event) {
284
286
. getElementById ( "chat-widget__form" ) !
285
287
. addEventListener ( "submit" , submit ) ;
286
288
289
+ if ( config . submitOnKeydown ) {
290
+ document
291
+ . getElementById ( "chat-widget__input" ) !
292
+ . addEventListener ( "keydown" , ( e : KeyboardEvent ) => {
293
+ if ( e . which === 13 && ! e . shiftKey ) {
294
+ e . preventDefault ( ) ;
295
+ const submitBtn = document . getElementById ( "chat-widget__submit" ) as HTMLButtonElement ; ;
296
+ submitBtn . click ( ) ;
297
+ }
298
+ } ) ;
299
+ }
300
+
287
301
const peerchatSwitchElem = document . getElementById ( "peerchat-switch" ) as HTMLInputElement ;
288
302
if ( peerchatSwitchElem ) {
289
303
peerchatSwitchElem . checked = peerchatmode ;
Original file line number Diff line number Diff line change @@ -699,6 +699,7 @@ <h3 class="section__title">Share/Collaborate</h3>
699
699
window . ChatWidget . config . dbpath = getExampleRef ( ) ;
700
700
if ( ! ismob ( ) ) {
701
701
window . ChatWidget . config . openOnLoad = true ;
702
+ window . ChatWidget . config . submitOnKeydown = true ;
702
703
}
703
704
window . insertcodesnippet = ( encodedcode ) => {
704
705
const code = atob ( encodedcode ) ;
You can’t perform that action at this time.
0 commit comments