44 */
55
66import {
7+ Chat ,
78 ChatWidget ,
89 IActiveCellManager ,
9- IAttachmentOpenerRegistry ,
10- IChatCommandRegistry ,
11- IInputToolbarRegistry ,
12- IMessageFooterRegistry ,
1310 ISelectionWatcher ,
1411 IInputToolbarRegistryFactory
1512} from '@jupyter/chat' ;
16- import { IThemeManager } from '@jupyterlab/apputils' ;
1713import { IDocumentManager } from '@jupyterlab/docmanager' ;
1814import { ABCWidgetFactory , DocumentRegistry } from '@jupyterlab/docregistry' ;
19- import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
2015import { Contents , User } from '@jupyterlab/services' ;
2116import { CommandRegistry } from '@lumino/commands' ;
2217import { ISignal , Signal } from '@lumino/signaling' ;
@@ -77,13 +72,8 @@ export class ChatWidgetFactory extends ABCWidgetFactory<
7772 */
7873 constructor ( options : ChatWidgetFactory . IOptions < LabChatPanel > ) {
7974 super ( options ) ;
80- this . _themeManager = options . themeManager ;
81- this . _rmRegistry = options . rmRegistry ;
82- this . _chatCommandRegistry = options . chatCommandRegistry ;
83- this . _attachmentOpenerRegistry = options . attachmentOpenerRegistry ;
75+ this . _chatOptions = options ;
8476 this . _inputToolbarFactory = options . inputToolbarFactory ;
85- this . _messageFooterRegistry = options . messageFooterRegistry ;
86- this . _welcomeMessage = options . welcomeMessage ;
8777 }
8878
8979 /**
@@ -93,12 +83,7 @@ export class ChatWidgetFactory extends ABCWidgetFactory<
9383 * @returns The widget
9484 */
9585 protected createNewWidget ( context : ChatWidgetFactory . IContext ) : LabChatPanel {
96- context . rmRegistry = this . _rmRegistry ;
97- context . themeManager = this . _themeManager ;
98- context . chatCommandRegistry = this . _chatCommandRegistry ;
99- context . attachmentOpenerRegistry = this . _attachmentOpenerRegistry ;
100- context . messageFooterRegistry = this . _messageFooterRegistry ;
101- context . welcomeMessage = this . _welcomeMessage ;
86+ context = { ...context , ...this . _chatOptions } ;
10287 if ( this . _inputToolbarFactory ) {
10388 context . inputToolbarRegistry = this . _inputToolbarFactory . create ( ) ;
10489 }
@@ -118,36 +103,19 @@ export class ChatWidgetFactory extends ABCWidgetFactory<
118103 }
119104 // Must override both getter and setter from ABCFactory for type compatibility.
120105 set contentProviderId ( _value : string | undefined ) { }
121- private _themeManager : IThemeManager | null ;
122- private _rmRegistry : IRenderMimeRegistry ;
123- private _chatCommandRegistry ?: IChatCommandRegistry ;
124- private _attachmentOpenerRegistry ?: IAttachmentOpenerRegistry ;
106+ private _chatOptions : Omit < Chat . IOptions , 'model' > ;
125107 private _inputToolbarFactory ?: IInputToolbarRegistryFactory ;
126- private _messageFooterRegistry ?: IMessageFooterRegistry ;
127- private _welcomeMessage ?: string ;
128108}
129109
130110export namespace ChatWidgetFactory {
131- export interface IContext extends DocumentRegistry . IContext < LabChatModel > {
132- themeManager : IThemeManager | null ;
133- rmRegistry : IRenderMimeRegistry ;
134- documentManager ?: IDocumentManager ;
135- chatCommandRegistry ?: IChatCommandRegistry ;
136- attachmentOpenerRegistry ?: IAttachmentOpenerRegistry ;
137- inputToolbarRegistry ?: IInputToolbarRegistry ;
138- messageFooterRegistry ?: IMessageFooterRegistry ;
139- welcomeMessage ?: string ;
140- }
111+ export interface IContext
112+ extends DocumentRegistry . IContext < LabChatModel > ,
113+ Omit < Chat . IOptions , 'model' > { }
141114
142115 export interface IOptions < T extends LabChatPanel >
143- extends DocumentRegistry . IWidgetFactoryOptions < T > {
144- themeManager : IThemeManager | null ;
145- rmRegistry : IRenderMimeRegistry ;
146- chatCommandRegistry ?: IChatCommandRegistry ;
147- attachmentOpenerRegistry ?: IAttachmentOpenerRegistry ;
148- inputToolbarFactory ?: IInputToolbarRegistryFactory ;
149- messageFooterRegistry ?: IMessageFooterRegistry ;
150- welcomeMessage ?: string ;
116+ extends DocumentRegistry . IWidgetFactoryOptions < T > ,
117+ Omit < Chat . IOptions , 'model' | 'inputToolbarRegistry' > {
118+ inputToolbarFactory : IInputToolbarRegistryFactory ;
151119 }
152120}
153121
0 commit comments