33
44import * as outputBase from '@jupyter-widgets/output' ;
55
6- import { JupyterLuminoPanelWidget } from '@jupyter-widgets/base' ;
7-
8- import { Panel } from '@lumino/widgets' ;
9-
106import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
117
128import { KernelWidgetManager } from './manager' ;
139
14- import { OutputAreaModel , OutputArea } from '@jupyterlab/outputarea' ;
10+ import {
11+ OutputArea ,
12+ SimplifiedOutputArea ,
13+ OutputAreaModel ,
14+ } from '@jupyterlab/outputarea' ;
1515
1616import * as nbformat from '@jupyterlab/nbformat' ;
1717
1818import { KernelMessage } from '@jupyterlab/services' ;
1919
2020import $ from 'jquery' ;
2121
22+ import type { Message } from '@lumino/messaging' ;
23+
2224export const OUTPUT_WIDGET_VERSION = outputBase . OUTPUT_WIDGET_VERSION ;
2325
2426export class OutputModel extends outputBase . OutputModel {
@@ -105,7 +107,15 @@ export class OutputModel extends outputBase.OutputModel {
105107
106108export class OutputView extends outputBase . OutputView {
107109 _createElement ( tagName : string ) : HTMLElement {
108- this . luminoWidget = new JupyterLuminoPanelWidget ( { view : this } ) ;
110+ this . luminoWidget = new JupyterOutputArea ( {
111+ view : this ,
112+ rendermime : OutputModel . rendermime ,
113+ contentFactory : OutputArea . defaultContentFactory ,
114+ model : this . model . outputs ,
115+ promptOverlay : false ,
116+ } ) ;
117+ this . luminoWidget . addClass ( 'jupyter-widgets' ) ;
118+ this . luminoWidget . addClass ( 'jupyter-widget-output' ) ;
109119 return this . luminoWidget . node ;
110120 }
111121
@@ -119,34 +129,41 @@ export class OutputView extends outputBase.OutputView {
119129 this . $el = $ ( this . luminoWidget . node ) ;
120130 }
121131
122- /**
123- * Called when view is rendered.
124- */
125- render ( ) : void {
126- 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 ) ;
132+ model : OutputModel ;
133+ luminoWidget : JupyterOutputArea ;
134+ }
138135
139- this . luminoWidget . addClass ( 'jupyter-widgets' ) ;
140- this . luminoWidget . addClass ( 'widget-output' ) ;
141- this . update ( ) ; // Set defaults.
136+ class JupyterOutputArea extends SimplifiedOutputArea {
137+ constructor ( options : JupyterOutputArea . IOptions & OutputArea . IOptions ) {
138+ const view = options . view ;
139+ delete ( options as any ) . view ;
140+ super ( options ) ;
141+ this . _view = view ;
142142 }
143143
144- remove ( ) : any {
145- this . _outputView . dispose ( ) ;
146- return super . remove ( ) ;
144+ processMessage ( msg : Message ) : void {
145+ super . processMessage ( msg ) ;
146+ this . _view ?. processLuminoMessage ( msg ) ;
147+ }
148+ /**
149+ * Dispose the widget.
150+ *
151+ * This causes the view to be destroyed as well with 'remove'
152+ */
153+ dispose ( ) : void {
154+ if ( this . isDisposed ) {
155+ return ;
156+ }
157+ super . dispose ( ) ;
158+ this . _view ?. remove ( ) ;
159+ this . _view = null ! ;
147160 }
148161
149- model : OutputModel ;
150- _outputView : OutputArea ;
151- luminoWidget : Panel ;
162+ private _view : OutputView ;
163+ }
164+
165+ export namespace JupyterOutputArea {
166+ export interface IOptions {
167+ view : OutputView ;
168+ }
152169}
0 commit comments