Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ By default, when you open a notebook in Specta, all code cells are hidden, and p

![Cell toolbar](./docs/images/specta-config.jpg)

By opening the `Property Inspector` panel of JupyterLab and selecting the `Specta Cell Config` section, you can change the visibility of each cell as follows:
By opening the `Property Inspector` panel of JupyterLab and selecting the `Specta Cell Config` section, you can change the display of each cell as follows:

- `Show cell source`: use this toggle to show or hide the cell source code. Default to `false`
- `Show output placeholder`: use this toggle to show or hide the output skeleton. Default to `true`
- `Output size`: use this dropdown to select the size of the cell output. Default to `Small`

### Slides layout configuration

Expand Down
9 changes: 7 additions & 2 deletions demo/files/blog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
{
"cell_type": "markdown",
"id": "21b59e76",
"metadata": {},
"metadata": {
"specta": {
"outputSize":"Full"
}
},
"source": [
"![Banner](./top.jpeg \"Banner\")\n"
]
Expand Down Expand Up @@ -231,7 +235,8 @@
"id": "2b2c01c4",
"metadata": {
"specta": {
"showSource": "Yes"
"showSource": "Yes",
"outputSize":"Big"
},
"tags": [
"specta:visible"
Expand Down
Binary file modified docs/images/specta-config.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 0 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions schema/cell-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
"type": "string",
"enum": ["Yes", "No"],
"default": "Yes"
},
"/specta/outputSize": {
"title": "Output size",
"type": "string",
"enum": ["Small", "Big", "Full"],
"default": "Small"
}
}
},
Expand All @@ -29,6 +35,9 @@
},
"/specta/showOutput": {
"writeDefault": false
},
"/specta/outputSize": {
"writeDefault": false
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/specta_cell_output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ export class SpectaCellOutput extends Panel {
cellConfig: Required<ISpectaCellConfig>;
}) {
super();
const { showOutput, outputSize } = cellConfig;
this.removeClass('lm-Widget');
this.removeClass('p-Widget');
this.addClass('specta-cell-output');

if (outputSize === 'Big') {
this.addClass('specta-cell-output-big');
} else if (outputSize === 'Full') {
this.addClass('specta-cell-output-full');
}
const content = new Panel();
content.addClass('specta-cell-content');

Expand All @@ -42,7 +48,7 @@ export class SpectaCellOutput extends Panel {
this.cellIdentity = cellIdentity;
this._info = info ?? {};
if (info.cellModel?.cell_type === 'code') {
if (cellConfig.showOutput) {
if (showOutput) {
this._placeholder = ReactWidget.create(<RandomSkeleton />);
this._placeholder.addClass('specta-cell-placeholder');
this.addWidget(this._placeholder);
Expand Down
1 change: 1 addition & 0 deletions src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface ISpectaAppConfig {
export interface ISpectaCellConfig {
showSource?: boolean;
showOutput?: boolean;
outputSize?: 'Small' | 'Big' | 'Full';
}
export const ISpectaLayoutRegistry = new Token<ISpectaLayoutRegistry>(
'specta:ISpectaLayoutRegistry'
Expand Down
7 changes: 6 additions & 1 deletion src/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ export function readCellConfig(cell?: ICell): Required<ISpectaCellConfig> {
const metaData = (cell?.metadata?.specta ?? {}) as any;
const spectaCellConfig: Required<ISpectaCellConfig> = {
showSource: false,
showOutput: true
showOutput: true,
outputSize: 'Small'
};

if (metaData.showSource && metaData.showSource === 'Yes') {
Expand All @@ -202,6 +203,10 @@ export function readCellConfig(cell?: ICell): Required<ISpectaCellConfig> {
spectaCellConfig.showOutput = false;
}

if (metaData.outputSize) {
spectaCellConfig.outputSize = metaData.outputSize;
}

return spectaCellConfig;
}

Expand Down
Loading