Skip to content

Commit b4e6af9

Browse files
authored
Optionally shows the code cell prompt (execution count) (#12)
1 parent 8605410 commit b4e6af9

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

js/jupyterlab-slideshow/schema/plugin.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
"default": false,
3838
"description": "Whether presentation mode is currently active."
3939
},
40+
"showCodeCellPrompt": {
41+
"title": "Show execution count",
42+
"type": "boolean",
43+
"default": false,
44+
"description": "Whether to show the execution count (input prompt) in Notebook presentation"
45+
},
4046
"stylePresets": {
4147
"title": "Style Presets",
4248
"$ref": "#/definitions/style-presets",

js/jupyterlab-slideshow/src/manager.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class DeckManager implements IDeckManager {
5757
protected _layover: Layover | null = null;
5858
protected _activePresenter: IPresenter<Widget> | null = null;
5959
protected _activeWidgetStack: Widget[] = [];
60+
protected _showCodeCellPrompt: boolean = false;
6061

6162
constructor(options: DeckManager.IOptions) {
6263
this._appStarted = options.appStarted;
@@ -107,6 +108,10 @@ export class DeckManager implements IDeckManager {
107108
return this._layoverChanged;
108109
}
109110

111+
public get showCodeCellPrompt(): boolean {
112+
return this._showCodeCellPrompt
113+
}
114+
110115
/**
111116
* translate a string by message id (usually the en-US string), potentially
112117
* with positional arguments, starting with %1.
@@ -525,6 +530,12 @@ export class DeckManager implements IDeckManager {
525530
composite = settings.composite as IDeckSettings;
526531
const active = composite.active === true;
527532

533+
const showCodeCellPrompt = composite.showCodeCellPrompt === true;
534+
if (showCodeCellPrompt !== this._showCodeCellPrompt) {
535+
this._showCodeCellPrompt = showCodeCellPrompt;
536+
void this._addDeckStyles();
537+
}
538+
528539
if (active && !this._active) {
529540
void this.start();
530541
} else if (!active && this._active) {

js/jupyterlab-slideshow/src/notebook/presenter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
7979

8080
public async style(panel: NotebookPanel): Promise<void> {
8181
panel.addClass(CSS.deck);
82+
if (this._manager.showCodeCellPrompt) {
83+
panel.addClass(CSS.showCodeCellPrompt);
84+
} else {
85+
panel.removeClass(CSS.showCodeCellPrompt);
86+
}
8287
this._manager.cacheStyle(panel.node, panel.content.node);
8388
}
8489

js/jupyterlab-slideshow/src/tokens.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface IDeckManager {
5656
setLayerScope(layerScope: TLayerScope | null): void;
5757
getPartStyles(): GlobalStyles | null;
5858
setPartStyles(styles: GlobalStyles | null): void;
59+
readonly showCodeCellPrompt: boolean;
5960
}
6061

6162
export const IDeckManager = new Token<IDeckManager>(PLUGIN_ID);
@@ -128,6 +129,7 @@ export namespace CSS {
128129
export const stop = 'jp-deck-mod-stop';
129130
export const widgetStack = 'jp-Deck-Remote-WidgetStack';
130131
// notebook
132+
export const showCodeCellPrompt = 'jp-deck-showCodeCellPrompt';
131133
export const direction = 'jp-deck-mod-direction';
132134
export const onScreen = 'jp-deck-mod-onscreen';
133135
export const visible = 'jp-deck-mod-visible';
@@ -266,6 +268,7 @@ export interface IStylePreset {
266268

267269
export interface IDeckSettings {
268270
active?: boolean;
271+
showCodeCellPrompt?: boolean;
269272
stylePresets?: {
270273
[key: string]: Partial<IStylePreset>;
271274
};

js/jupyterlab-slideshow/style/notebook.css

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
/** heavy ui tweaks **/
2-
.jp-Deck .jp-InputPrompt,
3-
.jp-Deck .jp-OutputPrompt,
2+
.jp-Deck:not(.jp-deck-showCodeCellPrompt) .jp-InputPrompt,
3+
.jp-Deck:not(.jp-deck-showCodeCellPrompt) .jp-OutputPrompt,
44
.jp-Deck .jp-Notebook-footer,
55
.jp-Deck .jp-cell-toolbar {
66
display: none;
77
}
88

9+
.jp-Deck.jp-deck-showCodeCellPrompt .jp-InputPrompt,
10+
.jp-Deck.jp-deck-showCodeCellPrompt .jp-OutputPrompt {
11+
/* uses visibility instead of display to keep alignment between markdown and code cell */
12+
visibility: hidden;
13+
}
14+
15+
.jp-Deck.jp-deck-showCodeCellPrompt .jp-CodeCell .jp-InputPrompt,
16+
.jp-Deck.jp-deck-showCodeCellPrompt .jp-CodeCell .jp-OutputPrompt {
17+
display: inherit;
18+
visibility: inherit;
19+
}
20+
921
.jp-Deck .jp-NotebookPanel-toolbar {
1022
position: absolute;
1123
border: 0;

0 commit comments

Comments
 (0)