Skip to content

Commit

Permalink
revert notebookId change
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejpurves committed Jul 14, 2024
1 parent aefbd35 commit 4fdea73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 5 additions & 6 deletions packages/core/src/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,30 @@ import { CellStatusEvent, ErrorStatusEvent, errorToMessage, EventSubject } from
import { EventEmitter } from './emitter';
import type { ICodeCell, IError, IOutput } from '@jupyterlab/nbformat';
import { ensureString, shortId } from './utils';
import type ThebeNotebook from './notebook';

class ThebeCodeCell extends PassiveCellRenderer implements IThebeCell {
kind: CellKind;
notebookId: string;
source: string;
metadata: JsonObject;
session?: ThebeSession;
executionCount: number | null;
notebook?: ThebeNotebook;
protected busy: boolean;
protected events: EventEmitter;

constructor(
id: string,
notebookId: string,
source: string,
outputs: IOutput[],
config: Config,
metadata: JsonObject,
rendermime: IRenderMimeRegistry,
notebook?: ThebeNotebook,
) {
super(id, outputs, rendermime);
this.kind = 'code';
this.events = new EventEmitter(id, config, EventSubject.cell, this);
this.notebook = notebook;
this.notebookId = notebookId;
this.source = source;
this.metadata = metadata;
this.busy = false;
Expand All @@ -41,18 +40,18 @@ class ThebeCodeCell extends PassiveCellRenderer implements IThebeCell {

static fromICodeCell(
icc: ICodeCell,
notebookId: string,
config: Config,
rendermime: IRenderMimeRegistry,
notebook?: ThebeNotebook,
) {
const cell = new ThebeCodeCell(
icc.id ?? shortId(),
notebookId,
ensureString(icc.source),
icc.outputs ?? [],
config,
icc.metadata,
rendermime,
notebook,
);
Object.assign(cell.metadata, icc.metadata);

Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ class ThebeNotebook {
const metadata = {};
const cell = new ThebeCodeCell(
c.id,
notebook.id,
c.source,
c.outputs ?? [],
config,
metadata,
notebook.rendermime,
notebook,
);
console.debug(`thebe:notebook:fromCodeBlocks Initializing cell ${c.id}`);
return cell;
Expand All @@ -73,7 +73,12 @@ class ThebeNotebook {

notebook.cells = ipynb.cells.map((c) => {
if ((c as ICodeCell).cell_type === 'code')
return ThebeCodeCell.fromICodeCell(c as ICodeCell, config, notebook.rendermime, notebook);
return ThebeCodeCell.fromICodeCell(
c as ICodeCell,
notebook.id,
config,
notebook.rendermime,
);
return ThebeMarkdownCell.fromICell(c, notebook.rendermime, notebook);
});

Expand Down

0 comments on commit 4fdea73

Please sign in to comment.