jupyter-specta 0.3.0 → 0.3.1

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.
@@ -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
- await app.commands.execute('application:set-mode', {
65
- mode: 'single-document'
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');
package/lib/token.d.ts CHANGED
@@ -50,6 +50,13 @@ 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;
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
@@ -178,3 +178,41 @@ export function setRevealTheme(themeName) {
178
178
  // Set or update href to new theme
179
179
  themeLink.href = getSpectaAssetUrl(`reveal.js/${themeName}.css`);
180
180
  }
181
+ export async function configLabLayout(options) {
182
+ const { config, labShell, commands } = options;
183
+ if (!config) {
184
+ return;
185
+ }
186
+ console.log('vvvvvvvvvvv', config);
187
+ const { setSingleMode, hideLeftPanel, hideRightPanel, hideStatusbar, hideHeader } = config;
188
+ if (setSingleMode) {
189
+ await commands.execute('application:set-mode', {
190
+ mode: 'single-document'
191
+ });
192
+ }
193
+ if (hideLeftPanel) {
194
+ labShell.collapseLeft();
195
+ if (labShell.isSideTabBarVisible('left')) {
196
+ labShell.toggleSideTabBarVisibility('left');
197
+ }
198
+ }
199
+ if (hideRightPanel) {
200
+ labShell.collapseRight();
201
+ if (labShell.isSideTabBarVisible('right')) {
202
+ labShell.toggleSideTabBarVisibility('right');
203
+ }
204
+ }
205
+ if (hideHeader) {
206
+ if (labShell.isTopInSimpleModeVisible()) {
207
+ await commands.execute('application:toggle-header');
208
+ }
209
+ }
210
+ if (hideStatusbar) {
211
+ const statusBar = document.getElementById('jp-main-statusbar');
212
+ console.log('statusBar.clientHeight', statusBar === null || statusBar === void 0 ? void 0 : statusBar.clientHeight);
213
+ if (statusBar && !statusBar.classList.contains('lm-mod-hidden')) {
214
+ console.log('toggle status');
215
+ await commands.execute('statusbar:toggle');
216
+ }
217
+ }
218
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jupyter-specta",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/trungleduc/specta",