44 */
55
66import {
7- ChatArea ,
7+ Chat ,
88 ChatWidget ,
99 IActiveCellManager ,
10- IAttachmentOpenerRegistry ,
11- IChatCommandRegistry ,
12- IInputToolbarRegistry ,
13- IMessageFooterRegistry ,
1410 ISelectionWatcher ,
1511 IInputToolbarRegistryFactory
1612} from '@jupyter/chat' ;
17- import { IThemeManager } from '@jupyterlab/apputils' ;
1813import { IDocumentManager } from '@jupyterlab/docmanager' ;
1914import { ABCWidgetFactory , DocumentRegistry } from '@jupyterlab/docregistry' ;
20- import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
2115import { Contents , User } from '@jupyterlab/services' ;
2216import { CommandRegistry } from '@lumino/commands' ;
2317import { ISignal , Signal } from '@lumino/signaling' ;
@@ -78,13 +72,8 @@ export class ChatWidgetFactory extends ABCWidgetFactory<
7872 */
7973 constructor ( options : ChatWidgetFactory . IOptions < LabChatPanel > ) {
8074 super ( options ) ;
81- this . _themeManager = options . themeManager ;
82- this . _rmRegistry = options . rmRegistry ;
83- this . _chatCommandRegistry = options . chatCommandRegistry ;
84- this . _attachmentOpenerRegistry = options . attachmentOpenerRegistry ;
75+ this . _chatOptions = options ;
8576 this . _inputToolbarFactory = options . inputToolbarFactory ;
86- this . _messageFooterRegistry = options . messageFooterRegistry ;
87- this . _welcomeMessage = options . welcomeMessage ;
8877 }
8978
9079 /**
@@ -94,13 +83,7 @@ export class ChatWidgetFactory extends ABCWidgetFactory<
9483 * @returns The widget
9584 */
9685 protected createNewWidget ( context : ChatWidgetFactory . IContext ) : LabChatPanel {
97- context . rmRegistry = this . _rmRegistry ;
98- context . themeManager = this . _themeManager ;
99- context . chatCommandRegistry = this . _chatCommandRegistry ;
100- context . attachmentOpenerRegistry = this . _attachmentOpenerRegistry ;
101- context . messageFooterRegistry = this . _messageFooterRegistry ;
102- context . welcomeMessage = this . _welcomeMessage ;
103- context . area = 'main' ;
86+ context = { ...context , area : 'main' , ...this . _chatOptions } ;
10487 if ( this . _inputToolbarFactory ) {
10588 context . inputToolbarRegistry = this . _inputToolbarFactory . create ( ) ;
10689 }
@@ -120,37 +103,19 @@ export class ChatWidgetFactory extends ABCWidgetFactory<
120103 }
121104 // Must override both getter and setter from ABCFactory for type compatibility.
122105 set contentProviderId ( _value : string | undefined ) { }
123- private _themeManager : IThemeManager | null ;
124- private _rmRegistry : IRenderMimeRegistry ;
125- private _chatCommandRegistry ?: IChatCommandRegistry ;
126- private _attachmentOpenerRegistry ?: IAttachmentOpenerRegistry ;
106+ private _chatOptions : Omit < Chat . IOptions , 'model' > ;
127107 private _inputToolbarFactory ?: IInputToolbarRegistryFactory ;
128- private _messageFooterRegistry ?: IMessageFooterRegistry ;
129- private _welcomeMessage ?: string ;
130108}
131109
132110export namespace ChatWidgetFactory {
133- export interface IContext extends DocumentRegistry . IContext < LabChatModel > {
134- themeManager : IThemeManager | null ;
135- rmRegistry : IRenderMimeRegistry ;
136- documentManager ?: IDocumentManager ;
137- chatCommandRegistry ?: IChatCommandRegistry ;
138- attachmentOpenerRegistry ?: IAttachmentOpenerRegistry ;
139- inputToolbarRegistry ?: IInputToolbarRegistry ;
140- messageFooterRegistry ?: IMessageFooterRegistry ;
141- welcomeMessage ?: string ;
142- area ?: ChatArea ;
143- }
111+ export interface IContext
112+ extends DocumentRegistry . IContext < LabChatModel > ,
113+ Omit < Chat . IOptions , 'model' > { }
144114
145115 export interface IOptions < T extends LabChatPanel >
146- extends DocumentRegistry . IWidgetFactoryOptions < T > {
147- themeManager : IThemeManager | null ;
148- rmRegistry : IRenderMimeRegistry ;
149- chatCommandRegistry ?: IChatCommandRegistry ;
150- attachmentOpenerRegistry ?: IAttachmentOpenerRegistry ;
151- inputToolbarFactory ?: IInputToolbarRegistryFactory ;
152- messageFooterRegistry ?: IMessageFooterRegistry ;
153- welcomeMessage ?: string ;
116+ extends DocumentRegistry . IWidgetFactoryOptions < T > ,
117+ Omit < Chat . IOptions , 'model' | 'inputToolbarRegistry' > {
118+ inputToolbarFactory : IInputToolbarRegistryFactory ;
154119 }
155120}
156121
0 commit comments