Skip to content

Commit 2af23d4

Browse files
dbg
1 parent fea9560 commit 2af23d4

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

kernel/src/components/Dialog.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { ConnectCard } from './ConnectCard';
22
import { ServiceContainer } from '../services/ServiceContainer';
33
import { Card } from './Card';
44
import { NotebookPanel } from '@jupyterlab/notebook';
5-
import type { JupyterLiteServer } from '@jupyterlite/server';
5+
import { INotebookTracker} from '@jupyterlab/notebook';
66

77
export interface DialogProps {
88
closeDialog: () => void;
99
serviceContainer: ServiceContainer;
10-
app: JupyterLiteServer;
10+
nTracker: INotebookTracker;
1111
}
1212

1313
export class Dialog {
@@ -48,8 +48,10 @@ export class Dialog {
4848
// create an arrow function that calls the save method on the serviceContainer but first iterates over all cells and gathers their code content if they are code cells
4949
async () => {
5050
// TODO: current widget might not be correct at this level, need to check and possibly change how we're getting this
51-
console.log("[Dialog] saveCard: props.app =", props.app);
52-
const notebook = (props.app.shell as any).currentWidget as NotebookPanel | null;
51+
// console.log("[Dialog] saveCard: props.app =", props.app);
52+
// const notebook = (props.app.shell as any).currentWidget as NotebookPanel | null;
53+
// console.log("[Dialog] saveCard: notebook =", notebook);
54+
const notebook = props.nTracker.currentWidget as NotebookPanel | null;
5355
var allCellContent : string = '';
5456

5557
console.log("[Dialog] saveCard: Saving notebook content...");

kernel/src/index.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Removed Widget import as we're no longer using @lumino/widgets
22
import { JupyterLiteServer, JupyterLiteServerPlugin } from '@jupyterlite/server';
33
import { IKernel, IKernelSpecs } from '@jupyterlite/kernel';
4-
// import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
4+
import { INotebookTracker} from '@jupyterlab/notebook';
55
import { EmbeddedKernel } from './kernel';
66
import WelcomePanel from './panel';
77
import { ServiceContainer } from './services/ServiceContainer';
@@ -14,8 +14,8 @@ var devService: DeviceService | null = null;
1414
const kernelPlugin: JupyterLiteServerPlugin<void> = {
1515
id: 'jupyterlite-embedded-kernel:kernel',
1616
autoStart: true,
17-
requires: [IKernelSpecs],
18-
activate: (app: JupyterLiteServer, kernelspecs: IKernelSpecs) => {
17+
requires: [IKernelSpecs, INotebookTracker],
18+
activate: (app: JupyterLiteServer, kernelspecs: IKernelSpecs, notebookTracker: INotebookTracker) => {
1919
const activeKernels = new Map<string, EmbeddedKernel>();
2020

2121
app.router.post('/api/kernels/(.*)/interrupt', async (req, kernelId: string) => {
@@ -54,7 +54,7 @@ const kernelPlugin: JupyterLiteServerPlugin<void> = {
5454

5555
const welcomePanel = new WelcomePanel(
5656
serviceContainer,
57-
app
57+
notebookTracker
5858
);
5959
document.body.appendChild(welcomePanel.getElement());
6060
const kernel = new EmbeddedKernel(options, serviceContainer);
@@ -73,18 +73,6 @@ const kernelPlugin: JupyterLiteServerPlugin<void> = {
7373
return kernel;
7474
}
7575
});
76-
77-
// notebookTracker.currentChanged.connect((tracker, panel: NotebookPanel | null) => {
78-
// if (panel) {
79-
// console.log("Notebook changed to: ", panel.context.path);
80-
// const currentNotebookPanel = notebookTracker.currentWidget;
81-
82-
83-
// }
84-
// else{
85-
// console.log("No notebook currently active on currentChanged event.")
86-
// }
87-
// });
8876
}
8977
};
9078

kernel/src/panel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { globalStyles, animations, overlayStyles, dialogStyles, minimizedStyles,
22
import { MinimizedButton } from './components/MinimizedButton';
33
import { Dialog } from './components/Dialog';
44
import { ServiceContainer } from './services/ServiceContainer';
5-
import type { JupyterLiteServer } from '@jupyterlite/server';
5+
import { INotebookTracker} from '@jupyterlab/notebook';
66

77
class DialogPanel {
88
private element: HTMLDivElement;
@@ -94,7 +94,7 @@ export default class WelcomePanel {
9494

9595
constructor(
9696
private serviceContainer: ServiceContainer,
97-
private app: JupyterLiteServer
97+
private nTracker: INotebookTracker
9898
) {
9999

100100
this.element = document.createElement('div');
@@ -119,7 +119,7 @@ export default class WelcomePanel {
119119
const dialog = new Dialog({
120120
closeDialog: () => this.hide(),
121121
serviceContainer: this.serviceContainer,
122-
app: this.app,
122+
nTracker: this.nTracker,
123123
});
124124
this.dialogPanel = new DialogPanel(dialog);
125125

0 commit comments

Comments
 (0)