@@ -67,15 +67,15 @@ const DIRTY_CLASS = 'jp-mod-dirty';
6767export
6868class DrawioWidget extends DocumentWidget < Widget > {
6969
70- constructor ( context : DocumentRegistry . Context ) {
71- super ( ) ;
72- this . context = context ;
70+ constructor ( options : DocumentWidget . IOptions < Widget > ) {
71+ super ( { ... options } ) ;
72+ this . context = options [ ' context' ] ;
7373
7474 this . _onTitleChanged ( ) ;
75- context . pathChanged . connect ( this . _onTitleChanged , this ) ;
75+ this . context . pathChanged . connect ( this . _onTitleChanged , this ) ;
7676
7777 this . context . ready . then ( ( ) => { this . _onContextReady ( ) ; } ) ;
78- this . context . ready . then ( ( ) => { this . _handleDirtyState ( ) ; } ) ;
78+ this . context . ready . then ( ( ) => { this . _handleDirtyStateNew ( ) ; } ) ;
7979 }
8080
8181 protected onAfterShow ( msg : Message ) : void {
@@ -94,7 +94,7 @@ class DrawioWidget extends DocumentWidget<Widget> {
9494 this . _onContentChanged ( ) ;
9595
9696 contextModel . contentChanged . connect ( this . _onContentChanged , this ) ;
97- contextModel . stateChanged . connect ( this . _onModelStateChanged , this ) ;
97+ contextModel . stateChanged . connect ( this . _onModelStateChangedNew , this ) ;
9898
9999 this . _editor . sidebarContainer . style . width = '208px' ;
100100 var footer = document . getElementsByClassName ( 'geFooterContainer' ) ;
@@ -170,13 +170,13 @@ class DrawioWidget extends DocumentWidget<Widget> {
170170 this . context . model . fromString ( xml ) ;
171171 }
172172
173- private _onModelStateChanged ( sender : DocumentRegistry . IModel , args : IChangedArgs < any > ) : void {
173+ private _onModelStateChangedNew ( sender : DocumentRegistry . IModel , args : IChangedArgs < any > ) : void {
174174 if ( args . name === 'dirty' ) {
175- this . _handleDirtyState ( ) ;
175+ this . _handleDirtyStateNew ( ) ;
176176 }
177177 }
178178
179- private _handleDirtyState ( ) : void {
179+ private _handleDirtyStateNew ( ) : void {
180180 if ( this . context . model . dirty ) {
181181 this . title . className += ` ${ DIRTY_CLASS } ` ;
182182 } else {
@@ -204,10 +204,14 @@ class DrawioWidget extends DocumentWidget<Widget> {
204204 */
205205export
206206class DrawioFactory extends ABCWidgetFactory < DrawioWidget , DocumentRegistry . IModel > {
207- /**
208- * Create a new widget given a context.
209- */
210- protected createNewWidget ( context : DocumentRegistry . Context ) : DrawioWidget {
211- return new DrawioWidget ( context ) ;
212- }
207+ /**
208+ * Create a new widget given a context.
209+ */
210+ constructor ( options : DocumentRegistry . IWidgetFactoryOptions ) {
211+ super ( options ) ;
212+ }
213+
214+ protected createNewWidget ( context : DocumentRegistry . Context ) : DrawioWidget {
215+ return new DrawioWidget ( { context, content : new Widget ( ) } ) ;
216+ }
213217}
0 commit comments