Skip to content

Commit 7bd0bbd

Browse files
author
Alan
committed
Merge remote-tracking branch 'origin/OutputWidget-enhancements' into combine_v1
1 parent 9647eea commit 7bd0bbd

4 files changed

Lines changed: 59 additions & 32 deletions

File tree

packages/controls/css/widgets-base.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@
125125
flex-direction: column;
126126
}
127127

128+
.jupyter-widget-output {
129+
box-sizing: border-box;
130+
display: flex;
131+
margin: 0;
132+
overflow: auto;
133+
flex-direction: column;
134+
}
135+
128136
/* General Tags Styling */
129137

130138
.jupyter-widget-tagsinput {
@@ -907,7 +915,7 @@
907915
flex: 1 1 var(--jp-widgets-inline-width-short);
908916
outline: none !important;
909917
overflow: auto;
910-
height: inherit;
918+
height: 100%;
911919

912920
/* Because Firefox defines the baseline of a select as the bottom of the
913921
control, we align the entire control to the top and add padding to the

python/jupyterlab_widgets/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"@jupyterlab/translation": "^3.0.0 || ^4.0.0",
6767
"@lumino/coreutils": "^1.11.1 || ^2.1",
6868
"@lumino/disposable": "^1.10.1 || ^2.1",
69+
"@lumino/messaging": "^2.0.3",
6970
"@lumino/properties": "^2.0.1",
7071
"@lumino/signaling": "^1.10.1 || ^2.1",
7172
"@lumino/widgets": "^1.30.0 || ^2.1",

python/jupyterlab_widgets/src/output.ts

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33

44
import * as outputBase from '@jupyter-widgets/output';
55

6-
import { JupyterLuminoPanelWidget } from '@jupyter-widgets/base';
7-
8-
import { Panel } from '@lumino/widgets';
9-
106
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
117

128
import { KernelWidgetManager } from './manager';
139

14-
import { OutputAreaModel, OutputArea } from '@jupyterlab/outputarea';
10+
import {
11+
OutputArea,
12+
SimplifiedOutputArea,
13+
OutputAreaModel,
14+
} from '@jupyterlab/outputarea';
1515

1616
import * as nbformat from '@jupyterlab/nbformat';
1717

1818
import { KernelMessage } from '@jupyterlab/services';
1919

2020
import $ from 'jquery';
2121

22+
import type { Message } from '@lumino/messaging';
23+
2224
export const OUTPUT_WIDGET_VERSION = outputBase.OUTPUT_WIDGET_VERSION;
2325

2426
export class OutputModel extends outputBase.OutputModel {
@@ -105,7 +107,15 @@ export class OutputModel extends outputBase.OutputModel {
105107

106108
export 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
}

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ __metadata:
10411041
"@jupyterlab/translation": ^3.0.0 || ^4.0.0
10421042
"@lumino/coreutils": ^1.11.1 || ^2.1
10431043
"@lumino/disposable": ^1.10.1 || ^2.1
1044+
"@lumino/messaging": ^2.0.3
10441045
"@lumino/properties": ^2.0.1
10451046
"@lumino/signaling": ^1.10.1 || ^2.1
10461047
"@lumino/widgets": ^1.30.0 || ^2.1

0 commit comments

Comments
 (0)