Skip to content

Commit f6fca87

Browse files
committed
pass the full bundle
1 parent fc65002 commit f6fca87

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

packages/notebook-extension/src/index.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { Cell, CodeCell } from '@jupyterlab/cells';
1717

1818
import { PageConfig, Text, Time, URLExt } from '@jupyterlab/coreutils';
1919

20+
import { ReadonlyJSONObject } from '@lumino/coreutils';
21+
2022
import { IDocumentManager } from '@jupyterlab/docmanager';
2123

2224
import { DocumentRegistry } from '@jupyterlab/docregistry';
@@ -27,6 +29,13 @@ import {
2729
KernelConnector,
2830
} from '@jupyterlab/inspector';
2931

32+
/**
33+
* Interface for inspection handler with custom mime bundle handling
34+
*/
35+
interface ICustomInspectionHandler extends InspectionHandler {
36+
onMimeBundleChange(mimeData: ReadonlyJSONObject): void;
37+
}
38+
3039
import { IMainMenu } from '@jupyterlab/mainmenu';
3140

3241
import {
@@ -853,8 +862,6 @@ const pager: JupyterFrontEndPlugin<void> = {
853862
);
854863

855864
if (pagePayload && pagePayload.data) {
856-
const text = (pagePayload.data as any)['text/plain'];
857-
858865
// Remove the 'page' payload from the message to prevent it from also appearing in the cell's output area
859866
content.payload = content.payload.filter(
860867
(item) => item.source !== 'page'
@@ -864,10 +871,12 @@ const pager: JupyterFrontEndPlugin<void> = {
864871
delete content.payload;
865872
}
866873

867-
await app.commands.execute('inspector:open', {
868-
text,
869-
refresh: true,
870-
});
874+
await app.commands.execute('inspector:open');
875+
876+
// Call our custom handler directly with the whole mime bundle
877+
inspectionHandler.onMimeBundleChange(
878+
pagePayload.data as ReadonlyJSONObject
879+
);
871880
}
872881
}
873882
}
@@ -890,7 +899,7 @@ const pager: JupyterFrontEndPlugin<void> = {
890899
}
891900
};
892901

893-
let inspectionHandler: InspectionHandler;
902+
let inspectionHandler: ICustomInspectionHandler;
894903

895904
notebookTracker.widgetAdded.connect((_sender, panel) => {
896905
if (panel.sessionContext) {
@@ -924,26 +933,18 @@ const pager: JupyterFrontEndPlugin<void> = {
924933
return this._notebookInspected;
925934
}
926935

927-
onEditorChange(text: string): void {
928-
if (text && text.trim()) {
929-
this._previousInspectData = text;
930-
}
931-
932-
// Use the current text or fall back to previous data
933-
const dataToShow =
934-
text && text.trim() ? text : this._previousInspectData;
936+
onEditorChange(_text: string): void {
937+
// no-op
938+
}
935939

940+
onMimeBundleChange(mimeData: ReadonlyJSONObject): void {
936941
const update: IInspector.IInspectorUpdate = { content: null };
937942

938-
if (dataToShow) {
939-
const data = {
940-
'text/plain': dataToShow,
941-
};
942-
943-
const mimeType = rendermime.preferredMimeType(data);
943+
if (mimeData) {
944+
const mimeType = rendermime.preferredMimeType(mimeData);
944945
if (mimeType) {
945946
const widget = rendermime.createRenderer(mimeType);
946-
const model = new MimeModel({ data });
947+
const model = new MimeModel({ data: mimeData });
947948
void widget.renderModel(model);
948949
update.content = widget;
949950
}
@@ -953,7 +954,6 @@ const pager: JupyterFrontEndPlugin<void> = {
953954
this._notebookInspected.emit(update);
954955
}
955956

956-
private _previousInspectData = '';
957957
private _notebookInspected: Signal<
958958
InspectionHandler,
959959
IInspector.IInspectorUpdate

0 commit comments

Comments
 (0)