jupyter-specta 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/lib/document/plugin.js +7 -18
- package/lib/specta_cell_output.js +8 -1
- package/lib/token.d.ts +8 -0
- package/lib/tool.d.ts +7 -1
- package/lib/tool.js +43 -1
- package/package.json +1 -1
- package/schema/cell-meta.json +9 -0
- package/style/article.css +31 -4
package/README.md
CHANGED
|
@@ -115,10 +115,11 @@ By default, when you open a notebook in Specta, all code cells are hidden, and p
|
|
|
115
115
|
|
|
116
116
|

|
|
117
117
|
|
|
118
|
-
By opening the `Property Inspector` panel of JupyterLab and selecting the `Specta Cell Config` section, you can change the
|
|
118
|
+
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:
|
|
119
119
|
|
|
120
120
|
- `Show cell source`: use this toggle to show or hide the cell source code. Default to `false`
|
|
121
121
|
- `Show output placeholder`: use this toggle to show or hide the output skeleton. Default to `true`
|
|
122
|
+
- `Output size`: use this dropdown to select the size of the cell output. Default to `Small`
|
|
122
123
|
|
|
123
124
|
### Slides layout configuration
|
|
124
125
|
|
package/lib/document/plugin.js
CHANGED
|
@@ -8,7 +8,7 @@ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
|
8
8
|
import { IKernelSpecManager } from '@jupyterlab/services';
|
|
9
9
|
import { Widget } from '@lumino/widgets';
|
|
10
10
|
import { ISpectaDocTracker, ISpectaLayoutRegistry } from '../token';
|
|
11
|
-
import { createFileBrowser, hideAppLoadingIndicator, isSpectaApp, registerDocumentFactory } from '../tool';
|
|
11
|
+
import { configLabLayout, createFileBrowser, hideAppLoadingIndicator, isSpectaApp, readSpectaConfig, registerDocumentFactory } from '../tool';
|
|
12
12
|
const activate = (app, rendermime, tracker, editorServices, contentFactory, spectaLayoutRegistry, themeManager) => {
|
|
13
13
|
const namespace = 'specta';
|
|
14
14
|
const spectaTracker = new WidgetTracker({ namespace });
|
|
@@ -61,24 +61,13 @@ export const spectaOpener = {
|
|
|
61
61
|
app.restored.then(async () => {
|
|
62
62
|
const labShell = app.shell;
|
|
63
63
|
if (PathExt.extname(path) === '.ipynb') {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const commands = app.commands;
|
|
65
|
+
const spectaConfig = readSpectaConfig({});
|
|
66
|
+
await configLabLayout({
|
|
67
|
+
config: spectaConfig.labConfig,
|
|
68
|
+
labShell,
|
|
69
|
+
commands
|
|
66
70
|
});
|
|
67
|
-
labShell.collapseLeft();
|
|
68
|
-
labShell.collapseRight();
|
|
69
|
-
if (labShell.isSideTabBarVisible('right')) {
|
|
70
|
-
labShell.toggleSideTabBarVisibility('right');
|
|
71
|
-
}
|
|
72
|
-
if (labShell.isSideTabBarVisible('left')) {
|
|
73
|
-
labShell.toggleSideTabBarVisibility('left');
|
|
74
|
-
}
|
|
75
|
-
if (labShell.isTopInSimpleModeVisible()) {
|
|
76
|
-
await app.commands.execute('application:toggle-header');
|
|
77
|
-
}
|
|
78
|
-
const statusBar = document.getElementById('jp-bottom-panel');
|
|
79
|
-
if (statusBar && statusBar.clientHeight !== 0) {
|
|
80
|
-
await app.commands.execute('statusbar:toggle');
|
|
81
|
-
}
|
|
82
71
|
const widget = docManager.openOrReveal(path, 'specta');
|
|
83
72
|
if (widget) {
|
|
84
73
|
app.shell.add(widget, 'main');
|
|
@@ -8,9 +8,16 @@ export class SpectaCellOutput extends Panel {
|
|
|
8
8
|
super();
|
|
9
9
|
this._info = {};
|
|
10
10
|
this._placeholder = undefined;
|
|
11
|
+
const { showOutput, outputSize } = cellConfig;
|
|
11
12
|
this.removeClass('lm-Widget');
|
|
12
13
|
this.removeClass('p-Widget');
|
|
13
14
|
this.addClass('specta-cell-output');
|
|
15
|
+
if (outputSize === 'Big') {
|
|
16
|
+
this.addClass('specta-cell-output-big');
|
|
17
|
+
}
|
|
18
|
+
else if (outputSize === 'Full') {
|
|
19
|
+
this.addClass('specta-cell-output-full');
|
|
20
|
+
}
|
|
14
21
|
const content = new Panel();
|
|
15
22
|
content.addClass('specta-cell-content');
|
|
16
23
|
cell.addClass('specta-item-widget');
|
|
@@ -23,7 +30,7 @@ export class SpectaCellOutput extends Panel {
|
|
|
23
30
|
this.cellIdentity = cellIdentity;
|
|
24
31
|
this._info = info !== null && info !== void 0 ? info : {};
|
|
25
32
|
if (((_a = info.cellModel) === null || _a === void 0 ? void 0 : _a.cell_type) === 'code') {
|
|
26
|
-
if (
|
|
33
|
+
if (showOutput) {
|
|
27
34
|
this._placeholder = ReactWidget.create(React.createElement(RandomSkeleton, null));
|
|
28
35
|
this._placeholder.addClass('specta-cell-placeholder');
|
|
29
36
|
this.addWidget(this._placeholder);
|
package/lib/token.d.ts
CHANGED
|
@@ -50,10 +50,18 @@ export interface ISpectaAppConfig {
|
|
|
50
50
|
hideTopbar?: boolean;
|
|
51
51
|
slidesTheme?: string;
|
|
52
52
|
loadingName?: string;
|
|
53
|
+
labConfig?: {
|
|
54
|
+
setSingleMode?: boolean;
|
|
55
|
+
hideLeftPanel?: boolean;
|
|
56
|
+
hideRightPanel?: boolean;
|
|
57
|
+
hideStatusbar?: boolean;
|
|
58
|
+
hideHeader?: boolean;
|
|
59
|
+
};
|
|
53
60
|
}
|
|
54
61
|
export interface ISpectaCellConfig {
|
|
55
62
|
showSource?: boolean;
|
|
56
63
|
showOutput?: boolean;
|
|
64
|
+
outputSize?: 'Small' | 'Big' | 'Full';
|
|
57
65
|
}
|
|
58
66
|
export declare const ISpectaLayoutRegistry: Token<ISpectaLayoutRegistry>;
|
|
59
67
|
export declare const ISpectaDocTracker: Token<IWidgetTracker<Widget>>;
|
package/lib/tool.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { JupyterFrontEnd } from '@jupyterlab/application';
|
|
1
|
+
import { ILabShell, JupyterFrontEnd } from '@jupyterlab/application';
|
|
2
2
|
import { IThemeManager, WidgetTracker } from '@jupyterlab/apputils';
|
|
3
3
|
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
4
4
|
import { IDefaultFileBrowser } from '@jupyterlab/filebrowser';
|
|
5
5
|
import { ICell, INotebookMetadata } from '@jupyterlab/nbformat';
|
|
6
6
|
import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
|
|
7
7
|
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
8
|
+
import { CommandRegistry } from '@lumino/commands';
|
|
8
9
|
import { ISpectaAppConfig, ISpectaCellConfig, ISpectaLayoutRegistry, ISpectaShell } from './token';
|
|
9
10
|
export declare function registerDocumentFactory(options: {
|
|
10
11
|
factoryName: string;
|
|
@@ -32,3 +33,8 @@ export declare function readCellConfig(cell?: ICell): Required<ISpectaCellConfig
|
|
|
32
33
|
export declare function debounce<T extends (...args: any[]) => void>(fn: T, delay?: number): (...args: Parameters<T>) => void;
|
|
33
34
|
export declare const emitResizeEvent: () => void;
|
|
34
35
|
export declare function setRevealTheme(themeName: string): void;
|
|
36
|
+
export declare function configLabLayout(options: {
|
|
37
|
+
config?: ISpectaAppConfig['labConfig'];
|
|
38
|
+
labShell: ILabShell;
|
|
39
|
+
commands: CommandRegistry;
|
|
40
|
+
}): Promise<void>;
|
package/lib/tool.js
CHANGED
|
@@ -144,7 +144,8 @@ export function readCellConfig(cell) {
|
|
|
144
144
|
const metaData = ((_b = (_a = cell === null || cell === void 0 ? void 0 : cell.metadata) === null || _a === void 0 ? void 0 : _a.specta) !== null && _b !== void 0 ? _b : {});
|
|
145
145
|
const spectaCellConfig = {
|
|
146
146
|
showSource: false,
|
|
147
|
-
showOutput: true
|
|
147
|
+
showOutput: true,
|
|
148
|
+
outputSize: 'Small'
|
|
148
149
|
};
|
|
149
150
|
if (metaData.showSource && metaData.showSource === 'Yes') {
|
|
150
151
|
spectaCellConfig.showSource = true;
|
|
@@ -152,6 +153,9 @@ export function readCellConfig(cell) {
|
|
|
152
153
|
if (metaData.showOutput && metaData.showOutput === 'No') {
|
|
153
154
|
spectaCellConfig.showOutput = false;
|
|
154
155
|
}
|
|
156
|
+
if (metaData.outputSize) {
|
|
157
|
+
spectaCellConfig.outputSize = metaData.outputSize;
|
|
158
|
+
}
|
|
155
159
|
return spectaCellConfig;
|
|
156
160
|
}
|
|
157
161
|
export function debounce(fn, delay = 100) {
|
|
@@ -178,3 +182,41 @@ export function setRevealTheme(themeName) {
|
|
|
178
182
|
// Set or update href to new theme
|
|
179
183
|
themeLink.href = getSpectaAssetUrl(`reveal.js/${themeName}.css`);
|
|
180
184
|
}
|
|
185
|
+
export async function configLabLayout(options) {
|
|
186
|
+
const { config, labShell, commands } = options;
|
|
187
|
+
if (!config) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
console.log('vvvvvvvvvvv', config);
|
|
191
|
+
const { setSingleMode, hideLeftPanel, hideRightPanel, hideStatusbar, hideHeader } = config;
|
|
192
|
+
if (setSingleMode) {
|
|
193
|
+
await commands.execute('application:set-mode', {
|
|
194
|
+
mode: 'single-document'
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
if (hideLeftPanel) {
|
|
198
|
+
labShell.collapseLeft();
|
|
199
|
+
if (labShell.isSideTabBarVisible('left')) {
|
|
200
|
+
labShell.toggleSideTabBarVisibility('left');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (hideRightPanel) {
|
|
204
|
+
labShell.collapseRight();
|
|
205
|
+
if (labShell.isSideTabBarVisible('right')) {
|
|
206
|
+
labShell.toggleSideTabBarVisibility('right');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (hideHeader) {
|
|
210
|
+
if (labShell.isTopInSimpleModeVisible()) {
|
|
211
|
+
await commands.execute('application:toggle-header');
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (hideStatusbar) {
|
|
215
|
+
const statusBar = document.getElementById('jp-main-statusbar');
|
|
216
|
+
console.log('statusBar.clientHeight', statusBar === null || statusBar === void 0 ? void 0 : statusBar.clientHeight);
|
|
217
|
+
if (statusBar && !statusBar.classList.contains('lm-mod-hidden')) {
|
|
218
|
+
console.log('toggle status');
|
|
219
|
+
await commands.execute('statusbar:toggle');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
package/package.json
CHANGED
package/schema/cell-meta.json
CHANGED
|
@@ -20,6 +20,12 @@
|
|
|
20
20
|
"type": "string",
|
|
21
21
|
"enum": ["Yes", "No"],
|
|
22
22
|
"default": "Yes"
|
|
23
|
+
},
|
|
24
|
+
"/specta/outputSize": {
|
|
25
|
+
"title": "Output size",
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": ["Small", "Big", "Full"],
|
|
28
|
+
"default": "Small"
|
|
23
29
|
}
|
|
24
30
|
}
|
|
25
31
|
},
|
|
@@ -29,6 +35,9 @@
|
|
|
29
35
|
},
|
|
30
36
|
"/specta/showOutput": {
|
|
31
37
|
"writeDefault": false
|
|
38
|
+
},
|
|
39
|
+
"/specta/outputSize": {
|
|
40
|
+
"writeDefault": false
|
|
32
41
|
}
|
|
33
42
|
}
|
|
34
43
|
}
|
package/style/article.css
CHANGED
|
@@ -23,12 +23,15 @@
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.specta-article-outputs-panel {
|
|
26
|
-
max-width: 680px;
|
|
27
|
-
width: 100%;
|
|
28
26
|
font-size: 1rem;
|
|
29
27
|
line-height: 1.6;
|
|
28
|
+
width: 100%;
|
|
30
29
|
}
|
|
31
30
|
|
|
31
|
+
.specta-cell-output {
|
|
32
|
+
max-width: 680px;
|
|
33
|
+
margin: auto;
|
|
34
|
+
}
|
|
32
35
|
.specta-article-outputs-panel {
|
|
33
36
|
.jp-MarkdownOutput {
|
|
34
37
|
padding-left: 0px !important;
|
|
@@ -194,7 +197,7 @@
|
|
|
194
197
|
margin-top: 40px !important;
|
|
195
198
|
}
|
|
196
199
|
|
|
197
|
-
.jp-
|
|
200
|
+
.jp-OutputArea > .jp-OutputArea-child:first-child {
|
|
198
201
|
margin-top: 40px !important;
|
|
199
202
|
}
|
|
200
203
|
.jp-InputArea-editor {
|
|
@@ -307,8 +310,32 @@
|
|
|
307
310
|
margin-top: 56px !important;
|
|
308
311
|
}
|
|
309
312
|
|
|
310
|
-
.jp-
|
|
313
|
+
.jp-OutputArea > .jp-OutputArea-child:first-child {
|
|
311
314
|
margin-top: 56px !important;
|
|
312
315
|
}
|
|
316
|
+
|
|
317
|
+
.specta-cell-output-big {
|
|
318
|
+
max-width: 1192px;
|
|
319
|
+
}
|
|
320
|
+
.specta-cell-output-big .jp-Cell {
|
|
321
|
+
max-width: 680px;
|
|
322
|
+
margin: auto;
|
|
323
|
+
}
|
|
324
|
+
.specta-cell-output-big .jp-Cell.jp-MarkdownCell {
|
|
325
|
+
max-width: 1192px;
|
|
326
|
+
margin: auto;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.specta-cell-output-full {
|
|
330
|
+
max-width: 100%;
|
|
331
|
+
}
|
|
332
|
+
.specta-cell-output-full .jp-Cell {
|
|
333
|
+
max-width: 680px;
|
|
334
|
+
margin: auto;
|
|
335
|
+
}
|
|
336
|
+
.specta-cell-output-full .jp-Cell.jp-MarkdownCell {
|
|
337
|
+
max-width: 100%;
|
|
338
|
+
margin: auto;
|
|
339
|
+
}
|
|
313
340
|
}
|
|
314
341
|
}
|