diff --git a/packages/libro-core/src/cell/libro-cell-view.tsx b/packages/libro-core/src/cell/libro-cell-view.tsx index 08b85c65..e6c6bc27 100644 --- a/packages/libro-core/src/cell/libro-cell-view.tsx +++ b/packages/libro-core/src/cell/libro-cell-view.tsx @@ -137,7 +137,7 @@ export class LibroCellView extends BaseView implements CellView { super.dispose(); } toJSON(): LibroCell { - const meta = { ...(this.model.toJSON() as LibroCell), outputs: [] }; + const meta = { ...(this.model.toJSON() as LibroCell) }; const modelContribution = this.cellService.findModelProvider(this.model.options); if (modelContribution?.cellMeta.nbformatType) { meta.metadata.libroCellType = modelContribution?.cellMeta.type; diff --git a/packages/libro-core/src/cell/libro-executable-cell-view.ts b/packages/libro-core/src/cell/libro-executable-cell-view.ts index 59cd6511..892e7b51 100644 --- a/packages/libro-core/src/cell/libro-executable-cell-view.ts +++ b/packages/libro-core/src/cell/libro-executable-cell-view.ts @@ -1,3 +1,4 @@ +import type { ICodeCell } from '@difizen/libro-common'; import { watch } from '@difizen/mana-app'; import { ViewOption } from '@difizen/mana-app'; import { inject } from '@difizen/mana-app'; @@ -6,6 +7,7 @@ import type { CellModel } from '../libro-protocol.js'; import type { CellViewOptions } from '../libro-protocol.js'; import type { BaseOutputArea } from '../output/index.js'; +import type { LibroCell } from './libro-cell-protocol.js'; import { CellService } from './libro-cell-protocol.js'; import { EditorCellView, LibroEditorCellView } from './libro-edit-cell-view.js'; import { ExecutableCellModel } from './libro-executable-cell-model.js'; @@ -78,6 +80,15 @@ export abstract class LibroEditableExecutableCellView }), ); } + + override toJSON(): LibroCell { + const meta = super.toJSON(); + return { + ...meta, + source: meta.source ?? this.options.cell.source, + outputs: this.outputArea?.toJSON() ?? [], + } as ICodeCell; + } } /**