Skip to content

Commit 24f3312

Browse files
authored
Merge pull request #1738 from jasongrout/outputlayout
JLab Output displayed trigger
2 parents c27a9ad + 874ee32 commit 24f3312

File tree

3 files changed

+51
-12
lines changed

3 files changed

+51
-12
lines changed

packages/base/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@types/lodash": "^4.14.66",
6565
"@types/semver": "^5.3.30",
6666
"backbone": "1.2.3",
67+
"base64-js": "^1.2.1",
6768
"jquery": "^3.1.1",
6869
"lodash": "^4.17.4",
6970
"semver": "^5.1.0"

packages/controls/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"@phosphor/algorithm": "^1.1.0",
7373
"@phosphor/domutils": "^1.1.0",
7474
"@phosphor/messaging": "^1.2.0",
75+
"@phosphor/signaling": "^1.2.0",
7576
"@phosphor/widgets": "^1.2.0",
7677
"@types/backbone": "^1.3.33",
7778
"@types/semver": "^5.3.30",

packages/jupyterlab-manager/src/output.ts

+49-12
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33

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

6+
import {
7+
DOMWidgetView, JupyterPhosphorWidget
8+
} from '@jupyter-widgets/base';
9+
610
import {
711
IDisposable
812
} from '@phosphor/disposable';
913

14+
import {
15+
Message
16+
} from '@phosphor/messaging';
17+
1018
import {
1119
Panel, Widget
1220
} from '@phosphor/widgets';
@@ -100,13 +108,51 @@ class OutputModel extends outputBase.OutputModel {
100108
private _outputs: OutputAreaModel;
101109
}
102110

111+
export
112+
class JupyterPhosphorPanelWidget extends Panel {
113+
constructor(options: JupyterPhosphorWidget.IOptions & Panel.IOptions) {
114+
let view = options.view;
115+
delete options.view;
116+
super(options);
117+
this._view = view;
118+
}
119+
120+
/**
121+
* Process the phosphor message.
122+
*
123+
* Any custom phosphor widget used inside a Jupyter widget should override
124+
* the processMessage function like this.
125+
*/
126+
processMessage(msg: Message) {
127+
super.processMessage(msg);
128+
this._view.processPhosphorMessage(msg);
129+
}
130+
131+
/**
132+
* Dispose the widget.
133+
*
134+
* This causes the view to be destroyed as well with 'remove'
135+
*/
136+
dispose() {
137+
if (this.isDisposed) {
138+
return;
139+
}
140+
super.dispose();
141+
if (this._view) {
142+
this._view.remove();
143+
}
144+
this._view = null;
145+
}
146+
147+
private _view: DOMWidgetView;
148+
}
103149

104150
export
105151
class OutputView extends outputBase.OutputView {
106152

107153
_createElement(tagName: string) {
108-
this.pWidget = new Panel();
109-
return this.pWidget.node;
154+
this.pWidget = new JupyterPhosphorPanelWidget({ view: this });
155+
return this.pWidget.node;
110156
}
111157

112158
_setElement(el: HTMLElement) {
@@ -123,6 +169,7 @@ class OutputView extends outputBase.OutputView {
123169
* Called when view is rendered.
124170
*/
125171
render() {
172+
super.render();
126173
this._outputView = new OutputArea({
127174
rendermime: this.model.widget_manager.rendermime,
128175
contentFactory: OutputArea.defaultContentFactory,
@@ -139,16 +186,6 @@ class OutputView extends outputBase.OutputView {
139186
this.update(); // Set defaults.
140187
}
141188

142-
/**
143-
* Update the contents of this view
144-
*
145-
* Called when the model is changed. The model may have been
146-
* changed by another view or by a state update from the back-end.
147-
*/
148-
update() {
149-
return super.update();
150-
}
151-
152189
remove() {
153190
this._outputView.dispose();
154191
return super.remove();

0 commit comments

Comments
 (0)