3
3
4
4
import * as outputBase from '@jupyter-widgets/output' ;
5
5
6
- import { JupyterLuminoPanelWidget } from '@jupyter-widgets/base' ;
7
-
8
- import { Panel } from '@lumino/widgets' ;
9
-
10
6
import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
11
7
12
- import { KernelWidgetManager } from './manager' ;
8
+ import type { KernelWidgetManager } from './manager' ;
13
9
14
- import { OutputAreaModel , OutputArea } from '@jupyterlab/outputarea' ;
10
+ import { OutputArea , OutputAreaModel } from '@jupyterlab/outputarea' ;
15
11
16
12
import * as nbformat from '@jupyterlab/nbformat' ;
17
13
18
- import { KernelMessage } from '@jupyterlab/services' ;
14
+ import type { KernelMessage } from '@jupyterlab/services' ;
19
15
20
16
import $ from 'jquery' ;
21
17
18
+ import type { Message } from '@lumino/messaging' ;
19
+
22
20
export const OUTPUT_WIDGET_VERSION = outputBase . OUTPUT_WIDGET_VERSION ;
23
21
24
22
export class OutputModel extends outputBase . OutputModel {
@@ -103,9 +101,50 @@ export class OutputModel extends outputBase.OutputModel {
103
101
static rendermime : IRenderMimeRegistry ;
104
102
}
105
103
104
+ class JupyterOutputArea extends OutputArea {
105
+ constructor ( options : JupyterOutputArea . IOptions & OutputArea . IOptions ) {
106
+ const view = options . view ;
107
+ delete ( options as any ) . view ;
108
+ super ( options ) ;
109
+ this . _view = view ;
110
+ }
111
+
112
+ processMessage ( msg : Message ) : void {
113
+ super . processMessage ( msg ) ;
114
+ this . _view ?. processLuminoMessage ( msg ) ;
115
+ }
116
+ /**
117
+ * Dispose the widget.
118
+ *
119
+ * This causes the view to be destroyed as well with 'remove'
120
+ */
121
+ dispose ( ) : void {
122
+ if ( this . isDisposed ) {
123
+ return ;
124
+ }
125
+ super . dispose ( ) ;
126
+ this . _view ?. remove ( ) ;
127
+ this . _view = null ! ;
128
+ }
129
+
130
+ private _view : OutputView ;
131
+ }
132
+
133
+ export namespace JupyterOutputArea {
134
+ export interface IOptions {
135
+ view : OutputView ;
136
+ }
137
+ }
138
+
106
139
export class OutputView extends outputBase . OutputView {
107
140
_createElement ( tagName : string ) : HTMLElement {
108
- this . luminoWidget = new JupyterLuminoPanelWidget ( { view : this } ) ;
141
+ this . luminoWidget = new JupyterOutputArea ( {
142
+ view : this ,
143
+ rendermime : OutputModel . rendermime ,
144
+ contentFactory : OutputArea . defaultContentFactory ,
145
+ model : this . model . outputs ,
146
+ promptOverlay : false ,
147
+ } ) ;
109
148
return this . luminoWidget . node ;
110
149
}
111
150
@@ -124,29 +163,16 @@ export class OutputView extends outputBase.OutputView {
124
163
*/
125
164
render ( ) : void {
126
165
super . render ( ) ;
127
- this . _outputView = new OutputArea ( {
128
- rendermime : OutputModel . rendermime ,
129
- contentFactory : OutputArea . defaultContentFactory ,
130
- model : this . model . outputs ,
131
- } ) ;
132
-
133
- // TODO: why is this a readonly property now?
134
- // this._outputView.model = this.model.outputs;
135
- // TODO: why is this on the model now?
136
- // this._outputView.trusted = true;
137
- this . luminoWidget . insertWidget ( 0 , this . _outputView ) ;
138
-
139
166
this . luminoWidget . addClass ( 'jupyter-widgets' ) ;
140
- this . luminoWidget . addClass ( 'widget-output' ) ;
167
+ this . luminoWidget . addClass ( 'jupyter- widget-output' ) ;
141
168
this . update ( ) ; // Set defaults.
142
169
}
143
170
144
171
remove ( ) : any {
145
- this . _outputView . dispose ( ) ;
172
+ this . luminoWidget . dispose ( ) ;
146
173
return super . remove ( ) ;
147
174
}
148
175
149
176
model : OutputModel ;
150
- _outputView : OutputArea ;
151
- luminoWidget : Panel ;
177
+ luminoWidget : OutputArea ;
152
178
}
0 commit comments