Prevent Markdown Cells from Collapsing (#8317)

This commit is contained in:
Chris LaFreniere
2019-11-12 18:40:06 -08:00
committed by GitHub
parent 62d7c71093
commit 2f1f5b2376
2 changed files with 32 additions and 1 deletions

View File

@@ -108,6 +108,9 @@ export class CellModel implements ICellModel {
}
public set isCollapsed(value: boolean) {
if (this.cellType !== CellTypes.Code) {
return;
}
let stateChanged = this._isCollapsed !== value;
this._isCollapsed = value;
@@ -603,7 +606,7 @@ export class CellModel implements ICellModel {
this._source = this.getMultilineSource(cell.source);
this._metadata = cell.metadata || {};
if (this._metadata.tags && this._metadata.tags.some(x => x === HideInputTag)) {
if (this._metadata.tags && this._metadata.tags.some(x => x === HideInputTag) && this._cellType === CellTypes.Code) {
this._isCollapsed = true;
} else {
this._isCollapsed = false;

View File

@@ -335,6 +335,34 @@ suite('Cell Model', function (): void {
assert(!isCollapsed);
});
test('Should not allow markdown cells to be collapsible', async function (): Promise<void> {
let mdCellData: nb.ICellContents = {
cell_type: CellTypes.Markdown,
source: 'some *markdown*',
outputs: [],
metadata: { language: 'python' }
};
let cell = factory.createCell(mdCellData, undefined);
assert(cell.isCollapsed === false);
cell.isCollapsed = true;
// The typescript compiler will complain if we don't ignore the error from the following line,
// claiming that cell.isCollapsed will return true. It doesn't.
// @ts-ignore
assert(cell.isCollapsed === false);
let codeCellData: nb.ICellContents = {
cell_type: CellTypes.Code,
source: '1+1',
outputs: [],
metadata: { language: 'python' },
execution_count: 1
};
cell = factory.createCell(codeCellData, undefined);
assert(cell.isCollapsed === false);
cell.isCollapsed = true;
assert(cell.isCollapsed === true);
});
suite('Model Future handling', function (): void {
let future: TypeMoq.Mock<EmptyFuture>;
let cell: ICellModel;