Skip to content

Commit

Permalink
fix(core): outputs should not be included for editable cell
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinesmilelk committed Oct 17, 2024
1 parent 9520fe9 commit 83cad8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/libro-core/src/cell/libro-cell-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions packages/libro-core/src/cell/libro-executable-cell-view.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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;
}
}

/**
Expand Down

0 comments on commit 83cad8e

Please sign in to comment.